aboutsummaryrefslogtreecommitdiffstats
path: root/test/openssl/test_pkey_dh.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-05-13 15:36:43 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-05-13 15:36:43 +0900
commit0b8db854a4c595826eeec11aa03ab20f242f651e (patch)
tree7ac8bafede901ff77c42f4f1b5b7d03351264e3a /test/openssl/test_pkey_dh.rb
parented84536dd88340ea4a38f8e5f7e07b23bd68c00f (diff)
downloadruby-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_dh.rb')
-rw-r--r--test/openssl/test_pkey_dh.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/openssl/test_pkey_dh.rb b/test/openssl/test_pkey_dh.rb
index a0eca53c48..bca40ee202 100644
--- a/test/openssl/test_pkey_dh.rb
+++ b/test/openssl/test_pkey_dh.rb
@@ -68,6 +68,13 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
assert_equal(dh.to_pem, public_key.to_pem)
end
+ def test_public_pkey
+ dh = OpenSSL::TestUtils::TEST_KEY_DH1024
+ dh_test = dh.public_pkey
+ assert(!dh_test.private?)
+ assert(dh_test.public?)
+ end
+
def test_generate_key
dh = OpenSSL::TestUtils::TEST_KEY_DH1024.public_key # creates a copy
assert_no_key(dh)