Skip to content

Commit f9980d8

Browse files
committed
test/openssl/test_pkey.rb: Fix pending tests in FIPS case.
1 parent db633c5 commit f9980d8

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

test/openssl/test_pkey.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ def test_hmac_sign_verify
8282
end
8383

8484
def test_ed25519
85-
# https://github.com/openssl/openssl/issues/20758
86-
pend('Not supported on FIPS mode enabled') if OpenSSL.fips_mode
85+
pend_on_openssl_issue_21493
8786

8887
# Test vector from RFC 8032 Section 7.1 TEST 2
8988
priv_pem = <<~EOF
@@ -101,7 +100,13 @@ def test_ed25519
101100
pub = OpenSSL::PKey.read(pub_pem)
102101
rescue OpenSSL::PKey::PKeyError
103102
# OpenSSL < 1.1.1
104-
pend "Ed25519 is not implemented"
103+
if !openssl?(1, 1, 1)
104+
pend "Ed25519 is not implemented"
105+
elsif OpenSSL.fips_mode && openssl?(3, 1, 0, 0)
106+
# See OpenSSL providers/fips/fipsprov.c PROV_NAMES_ED25519 entries
107+
# with FIPS_UNAPPROVED_PROPERTIES in OpenSSL 3.1+.
108+
pend "Ed25519 is not approved in OpenSSL 3.1+ FIPS code"
109+
end
105110
end
106111
assert_instance_of OpenSSL::PKey::PKey, priv
107112
assert_instance_of OpenSSL::PKey::PKey, pub
@@ -143,7 +148,7 @@ def test_ed25519
143148
end
144149

145150
def test_x25519
146-
pend('Not supported on FIPS mode enabled') if OpenSSL.fips_mode
151+
pend_on_openssl_issue_21493
147152

148153
# Test vector from RFC 7748 Section 6.1
149154
alice_pem = <<~EOF
@@ -197,7 +202,7 @@ def raw_initialize
197202
end
198203

199204
def test_compare?
200-
pend('Not supported on FIPS mode enabled') if OpenSSL.fips_mode
205+
pend_on_openssl_issue_21493
201206

202207
key1 = Fixtures.pkey("rsa1024")
203208
key2 = Fixtures.pkey("rsa1024")

test/openssl/utils.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,22 @@ def libressl?(major = nil, minor = nil, fix = nil)
143143
return false unless version
144144
!major || (version.map(&:to_i) <=> [major, minor, fix]) >= 0
145145
end
146+
147+
# OpenSSL 3: x25519 a decode from and then encode to a pem file corrupts the
148+
# key if fips+base provider is used
149+
# This issue happens in OpenSSL between 3.0,0 and 3.0.10 or between 3.1.0 and
150+
# 3.1.2.
151+
# https://github.com/openssl/openssl/issues/21493
152+
# https://github.com/openssl/openssl/pull/21519
153+
def pend_on_openssl_issue_21493
154+
if OpenSSL.fips_mode &&
155+
(
156+
(openssl?(3, 0, 0, 0) && !openssl?(3, 0, 0, 11)) ||
157+
(openssl?(3, 1, 0, 0) && !openssl?(3, 1, 0, 3))
158+
)
159+
pend('See <https://github.com/openssl/openssl/issues/21493>')
160+
end
161+
end
146162
end
147163

148164
class OpenSSL::TestCase < Test::Unit::TestCase

0 commit comments

Comments
 (0)