summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_pkey_rsa.c
diff options
context:
space:
mode:
authorKazuki Yamaguchi <[email protected]>2021-04-22 16:33:59 +0900
committerKazuki Yamaguchi <[email protected]>2021-12-20 23:42:01 +0900
commitdf6589e418adb2a4018e40d53dab2fd5556ed41e (patch)
tree1b4440517b7052710e691ced134b369eef26e69c /ext/openssl/ossl_pkey_rsa.c
parentc1a36ebfda8ba570173e2844bc584786852e6190 (diff)
[ruby/openssl] 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. https://github.com/ruby/openssl/commit/66cd8cbaaf
Diffstat (limited to 'ext/openssl/ossl_pkey_rsa.c')
-rw-r--r--ext/openssl/ossl_pkey_rsa.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c
index b8dbc0e1c4..4d66010f49 100644
--- a/ext/openssl/ossl_pkey_rsa.c
+++ b/ext/openssl/ossl_pkey_rsa.c
@@ -135,6 +135,7 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+#ifndef HAVE_EVP_PKEY_DUP
static VALUE
ossl_rsa_initialize_copy(VALUE self, VALUE other)
{
@@ -161,6 +162,7 @@ ossl_rsa_initialize_copy(VALUE self, VALUE other)
return self;
}
+#endif
/*
* call-seq:
@@ -535,7 +537,9 @@ Init_ossl_rsa(void)
cRSA = rb_define_class_under(mPKey, "RSA", cPKey);
rb_define_method(cRSA, "initialize", ossl_rsa_initialize, -1);
+#ifndef HAVE_EVP_PKEY_DUP
rb_define_method(cRSA, "initialize_copy", ossl_rsa_initialize_copy, 1);
+#endif
rb_define_method(cRSA, "public?", ossl_rsa_is_public, 0);
rb_define_method(cRSA, "private?", ossl_rsa_is_private, 0);