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 /test/openssl/test_pkey_ec.rb | |
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 'test/openssl/test_pkey_ec.rb')
-rw-r--r-- | test/openssl/test_pkey_ec.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/openssl/test_pkey_ec.rb b/test/openssl/test_pkey_ec.rb index fe128fd455..e5c4056114 100644 --- a/test/openssl/test_pkey_ec.rb +++ b/test/openssl/test_pkey_ec.rb @@ -189,6 +189,16 @@ class OpenSSL::TestEC < Test::Unit::TestCase assert(pem) end + def test_public_pkey + ec = OpenSSL::TestUtils::TEST_KEY_EC_P256V1 + ec_pub = OpenSSL::PKey::EC.new(ec.group) + ec_pub.public_key = ec.public_key + test_obj = ec.public_pkey + assert(!test_obj.private?) + assert(test_obj.public?) + assert_equal(ec_pub.to_der, test_obj.to_der) + end + def test_ec_point_mul ec = OpenSSL::TestUtils::TEST_KEY_EC_P256V1 p1 = ec.public_key |