Skip to content

Commit 4262e31

Browse files
committed
Fix test_pkey_ec.rb on FIPS.
1 parent 2deb3a0 commit 4262e31

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Rake::TestTask.new(:test_fips) do |t|
2323
t.test_files = FileList[
2424
'test/openssl/test_fips.rb',
2525
'test/openssl/test_pkey.rb',
26+
'test/openssl/test_pkey_ec.rb',
2627
]
2728
t.warning = true
2829
end

test/openssl/test_pkey_ec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ def test_ECPrivateKey_with_parameters
229229
end
230230

231231
def test_ECPrivateKey_encrypted
232+
omit_on_fips
233+
232234
p256 = Fixtures.pkey("p256")
233235
# key = abcdef
234236
pem = <<~EOF

test/openssl/utils.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ def libressl?(major = nil, minor = nil, fix = nil)
119119
return false unless version
120120
!major || (version.map(&:to_i) <=> [major, minor, fix]) >= 0
121121
end
122+
123+
def omit_on_fips
124+
# The password based encryption used in the PEM format uses MD5 for
125+
# deriving the encryption key from the password, and MD5 is not
126+
# FIPS-approved.
127+
#
128+
# See https://github.com/openssl/openssl/discussions/21830#discussioncomment-6865636
129+
# for details.
130+
if OpenSSL.fips_mode
131+
omit "The encryption used in the test is not approved in FIPS"
132+
end
133+
end
122134
end
123135

124136
class OpenSSL::TestCase < Test::Unit::TestCase

0 commit comments

Comments
 (0)