diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2020-05-17 20:48:23 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2021-04-05 00:41:42 +0900 |
commit | c2e9b16f0b46371498232d68c01ac32d98a8ca0c (patch) | |
tree | 5a6835c45a8d75048fc394596a0ba3af5e927898 /test | |
parent | 88b90fb8568a9f104dfed1ace3b33b8586eafeed (diff) | |
download | ruby-openssl-c2e9b16f0b46371498232d68c01ac32d98a8ca0c.tar.gz |
pkey/dh: use high level EVP interface to generate parameters and keys
Implement PKey::DH.new(size, gen), PKey::DH.generate(size, gen), and
PKey::DH#generate_key! using PKey.generate_parameters and .generate_key
instead of the low level DH functions.
Note that the EVP interface can enforce additional restrictions - for
example, DH key shorter than 2048 bits is no longer accepted by default
in OpenSSL 3.0. The test code is updated accordingly.
Diffstat (limited to 'test')
-rw-r--r-- | test/openssl/test_pkey_dh.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/test/openssl/test_pkey_dh.rb b/test/openssl/test_pkey_dh.rb index 9efc3ba6..279ce198 100644 --- a/test/openssl/test_pkey_dh.rb +++ b/test/openssl/test_pkey_dh.rb @@ -4,12 +4,19 @@ require_relative 'utils' if defined?(OpenSSL) && defined?(OpenSSL::PKey::DH) class OpenSSL::TestPKeyDH < OpenSSL::PKeyTestCase - NEW_KEYLEN = 256 + NEW_KEYLEN = 2048 - def test_new + def test_new_empty + dh = OpenSSL::PKey::DH.new + assert_equal nil, dh.p + assert_equal nil, dh.priv_key + end + + def test_new_generate + # This test is slow dh = OpenSSL::PKey::DH.new(NEW_KEYLEN) assert_key(dh) - end + end if ENV["OSSL_TEST_ALL"] def test_new_break assert_nil(OpenSSL::PKey::DH.new(NEW_KEYLEN) { break }) @@ -80,7 +87,7 @@ class OpenSSL::TestPKeyDH < OpenSSL::PKeyTestCase end def test_dup - dh = OpenSSL::PKey::DH.new(NEW_KEYLEN) + dh = Fixtures.pkey("dh1024") dh2 = dh.dup assert_equal dh.to_der, dh2.to_der # params assert_equal_params dh, dh2 # keys |