From 66cd8cbaaf85604a13fd68bd9cd280a2881044ad Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Thu, 22 Apr 2021 16:33:59 +0900 Subject: pkey: use EVP_PKEY_dup() if available We can use it to implement OpenSSL::PKey::PKey#initialize_copy. This should work on all key types, not just DH/DSA/EC/RSA types. --- ext/openssl/ossl_pkey_dsa.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ext/openssl/ossl_pkey_dsa.c') diff --git a/ext/openssl/ossl_pkey_dsa.c b/ext/openssl/ossl_pkey_dsa.c index 15724548..25404aa7 100644 --- a/ext/openssl/ossl_pkey_dsa.c +++ b/ext/openssl/ossl_pkey_dsa.c @@ -139,6 +139,7 @@ ossl_dsa_initialize(int argc, VALUE *argv, VALUE self) return self; } +#ifndef HAVE_EVP_PKEY_DUP static VALUE ossl_dsa_initialize_copy(VALUE self, VALUE other) { @@ -166,6 +167,7 @@ ossl_dsa_initialize_copy(VALUE self, VALUE other) return self; } +#endif /* * call-seq: @@ -327,7 +329,9 @@ Init_ossl_dsa(void) cDSA = rb_define_class_under(mPKey, "DSA", cPKey); rb_define_method(cDSA, "initialize", ossl_dsa_initialize, -1); +#ifndef HAVE_EVP_PKEY_DUP rb_define_method(cDSA, "initialize_copy", ossl_dsa_initialize_copy, 1); +#endif rb_define_method(cDSA, "public?", ossl_dsa_is_public, 0); rb_define_method(cDSA, "private?", ossl_dsa_is_private, 0); -- cgit v1.2.3