diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2020-05-17 20:48:23 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2021-07-18 17:44:47 +0900 |
commit | 098985a5e66e4dd6b01d246909b66d3d7e4024c0 (patch) | |
tree | f0afa592ec0f525787c512090b08c277b28f60fd /test/openssl/test_pkey_dh.rb | |
parent | 595644e4f65f35e35f4c81e3aa228ac7d7f091d4 (diff) |
[ruby/openssl] 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.
https://github.com/ruby/openssl/commit/c2e9b16f0b
Diffstat (limited to 'test/openssl/test_pkey_dh.rb')
-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 9efc3ba68d..279ce1984c 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 |