diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-05-13 15:36:43 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-05-13 15:36:43 +0900 |
commit | 0b8db854a4c595826eeec11aa03ab20f242f651e (patch) | |
tree | 7ac8bafede901ff77c42f4f1b5b7d03351264e3a /ext/openssl/ossl_pkey_rsa.c | |
parent | ed84536dd88340ea4a38f8e5f7e07b23bd68c00f (diff) | |
download | ruby-0b8db854a4c595826eeec11aa03ab20f242f651e.tar.gz |
ext/openssl: implement OpenSSL::PKey::{DSA,RSA,EC}#public_pkeytopic/openssl-pkey-ec
Add OpenSSL::PKey::{DSA,RSA,EC}#public_pkey. They return a new instance
of itself, which contains only parameters and public information.
The old methods, {DSA,RSA}#public_key, are now deprecated.
There are 3 types of PKey#public_key: 1) EC#public_key, which returns
the actual public key (EC::Point). 2) RSA/DSA#public_key, which returns
a new instance of PKey with no private information. 3) DH#public_key,
which returns a new instance of DH which contains only DH params. This
doesn't even contain 'private key'. This is very confusing. The new
methods are intend to replace the 2).
Diffstat (limited to 'ext/openssl/ossl_pkey_rsa.c')
-rw-r--r-- | ext/openssl/ossl_pkey_rsa.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c index 20b993abb8..bb51453442 100644 --- a/ext/openssl/ossl_pkey_rsa.c +++ b/ext/openssl/ossl_pkey_rsa.c @@ -562,12 +562,16 @@ ossl_rsa_to_text(VALUE self) /* * call-seq: - * rsa.public_key -> RSA + * rsa.public_pkey -> RSA * * Makes new RSA instance containing the public key from the private key. + * + * === Note + * This method was renamed from OpenSSL::PKey::RSA#public_key. It remains as + * an alias. */ static VALUE -ossl_rsa_to_public_key(VALUE self) +ossl_rsa_to_public_pkey(VALUE self) { EVP_PKEY *pkey; RSA *rsa; @@ -664,7 +668,8 @@ Init_ossl_rsa(void) rb_define_alias(cRSA, "to_pem", "export"); rb_define_alias(cRSA, "to_s", "export"); rb_define_method(cRSA, "to_der", ossl_rsa_to_der, 0); - rb_define_method(cRSA, "public_key", ossl_rsa_to_public_key, 0); + rb_define_method(cRSA, "public_pkey", ossl_rsa_to_public_pkey, 0); + rb_define_alias(cRSA, "public_key", "public_pkey"); rb_define_method(cRSA, "public_encrypt", ossl_rsa_public_encrypt, -1); rb_define_method(cRSA, "public_decrypt", ossl_rsa_public_decrypt, -1); rb_define_method(cRSA, "private_encrypt", ossl_rsa_private_encrypt, -1); |