summaryrefslogtreecommitdiff
path: root/test/openssl/test_pkey_dh.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2020-07-10 14:34:51 +0900
committerKazuki Yamaguchi <k@rhe.jp>2021-07-18 17:44:52 +0900
commit6d71918d94a6b34249015499e5e822d3b20fd10f (patch)
tree84c38f39a5007c5f3d3ab9d1e59fc533dfb0a1e5 /test/openssl/test_pkey_dh.rb
parent3fe8387950f83874372172a79233ffc0d5d335b0 (diff)
[ruby/openssl] pkey/dh, pkey/ec: use EVP_PKEY_check() family
Use EVP_PKEY_param_check() instead of DH_check() if available. Also, use EVP_PKEY_public_check() instead of EC_KEY_check_key(). EVP_PKEY_*check() is part of the EVP API and is meant to replace those low-level functions. They were added by OpenSSL 1.1.1. It is currently not provided by LibreSSL. https://github.com/ruby/openssl/commit/797e9f8e08
Diffstat (limited to 'test/openssl/test_pkey_dh.rb')
-rw-r--r--test/openssl/test_pkey_dh.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/openssl/test_pkey_dh.rb b/test/openssl/test_pkey_dh.rb
index 279ce1984c..f80af8f841 100644
--- a/test/openssl/test_pkey_dh.rb
+++ b/test/openssl/test_pkey_dh.rb
@@ -86,6 +86,22 @@ class OpenSSL::TestPKeyDH < OpenSSL::PKeyTestCase
assert_equal(dh.compute_key(dh2.pub_key), dh2.compute_key(dh.pub_key))
end
+ def test_params_ok?
+ dh0 = Fixtures.pkey("dh1024")
+
+ dh1 = OpenSSL::PKey::DH.new(OpenSSL::ASN1::Sequence([
+ OpenSSL::ASN1::Integer(dh0.p),
+ OpenSSL::ASN1::Integer(dh0.g)
+ ]))
+ assert_equal(true, dh1.params_ok?)
+
+ dh2 = OpenSSL::PKey::DH.new(OpenSSL::ASN1::Sequence([
+ OpenSSL::ASN1::Integer(dh0.p + 1),
+ OpenSSL::ASN1::Integer(dh0.g)
+ ]))
+ assert_equal(false, dh2.params_ok?)
+ end
+
def test_dup
dh = Fixtures.pkey("dh1024")
dh2 = dh.dup