Skip to content

Commit f1db5c8

Browse files
committed
Check for compatible openssl versions earlier
test_pkey wasn't checking for libressl as is done elsewhere. Note the libressl version check is different when testing pkey, because PKey#sign relies on EVP_PKey_sign, whereas signing an X509 cert/request/crl relies on ASN1_item_sign.
1 parent 2b9f444 commit f1db5c8

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

test/openssl/test_pkey.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def test_hmac_sign_verify
9090
def test_ed25519
9191
# Ed25519 is not FIPS-approved.
9292
omit_on_fips
93+
# See EVP_PKEY_sign in Changelog for 3.7.0: https://github.com/libressl/portable/blob/master/ChangeLog
94+
omit "Ed25519 not supported" unless openssl?(1, 1, 1) || libressl?(3, 7, 0)
9395

9496
# Test vector from RFC 8032 Section 7.1 TEST 2
9597
priv_pem = <<~EOF
@@ -102,15 +104,8 @@ def test_ed25519
102104
MCowBQYDK2VwAyEAPUAXw+hDiVqStwqnTRt+vJyYLM8uxJaMwM1V8Sr0Zgw=
103105
-----END PUBLIC KEY-----
104106
EOF
105-
begin
106-
priv = OpenSSL::PKey.read(priv_pem)
107-
pub = OpenSSL::PKey.read(pub_pem)
108-
rescue OpenSSL::PKey::PKeyError => e
109-
# OpenSSL < 1.1.1
110-
pend "Ed25519 is not implemented" unless openssl?(1, 1, 1)
111-
112-
raise e
113-
end
107+
priv = OpenSSL::PKey.read(priv_pem)
108+
pub = OpenSSL::PKey.read(pub_pem)
114109
assert_instance_of OpenSSL::PKey::PKey, priv
115110
assert_instance_of OpenSSL::PKey::PKey, pub
116111
assert_equal priv_pem, priv.private_to_pem

test/openssl/test_x509cert.rb

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -292,24 +292,11 @@ def test_sign_and_verify_dsa_md5
292292
end
293293

294294
def test_sign_and_verify_ed25519
295-
# See test_ed25519 in test_pkey.rb
296-
297295
# Ed25519 is not FIPS-approved.
298296
omit_on_fips
299-
300-
begin
301-
ed25519 = OpenSSL::PKey::generate_key("ED25519")
302-
rescue OpenSSL::PKey::PKeyError => e
303-
# OpenSSL < 1.1.1
304-
#
305-
pend "Ed25519 is not implemented" unless openssl?(1, 1, 1)
306-
307-
raise e
308-
end
309-
310297
# See ASN1_item_sign_ctx in ChangeLog for 3.8.1: https://github.com/libressl/portable/blob/master/ChangeLog
311-
pend 'ASN1 signing with Ed25519 not yet working' unless openssl? or libressl?(3, 8, 1)
312-
298+
omit "Ed25519 not supported" unless openssl?(1, 1, 1) || libressl?(3, 8, 1)
299+
ed25519 = OpenSSL::PKey::generate_key("ED25519")
313300
cert = issue_cert(@ca, ed25519, 1, [], nil, nil, digest: nil)
314301
assert_equal(true, cert.verify(ed25519))
315302
end

0 commit comments

Comments
 (0)