Skip to content

Commit 3651884

Browse files
committed
test/openssl/test_pkey_dsa.rb: skip all tests in FIPS mode
OpenSSL running in the FIPS mode will stop supporting DSA key generation and signature generation due to a FIPS 140-3 requirement. Although it appears that FIPS 186-5 still allows signature verification in some cases, there would be little point in writing such a specific test case. DSA will still be tested if OpenSSL is not running in the FIPS mode. test_generate_on_non_fips is merged to test_generate again.
1 parent 3982fe7 commit 3651884

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

test/openssl/test_pkey_dsa.rb

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
if defined?(OpenSSL) && defined?(OpenSSL::PKey::DSA)
55

66
class OpenSSL::TestPKeyDSA < OpenSSL::PKeyTestCase
7+
def setup
8+
# May not be available in FIPS mode as DSA has been deprecated in FIPS 186-5
9+
omit_on_fips
10+
end
11+
712
def test_private
813
key = Fixtures.pkey("dsa1024")
914
assert_equal true, key.private?
@@ -31,6 +36,11 @@ def test_new_break
3136
def test_generate
3237
# DSA.generate used to call DSA_generate_parameters_ex(), which adjusts the
3338
# size of q according to the size of p
39+
key1024 = OpenSSL::PKey::DSA.generate(1024)
40+
assert_predicate key1024, :private?
41+
assert_equal 1024, key1024.p.num_bits
42+
assert_equal 160, key1024.q.num_bits
43+
3444
key2048 = OpenSSL::PKey::DSA.generate(2048)
3545
assert_equal 2048, key2048.p.num_bits
3646
assert_equal 256, key2048.q.num_bits
@@ -42,17 +52,6 @@ def test_generate
4252
end
4353
end
4454

45-
def test_generate_on_non_fips
46-
# DSA with 1024 bits is invalid on FIPS 186-4.
47-
# https://github.com/openssl/openssl/commit/49ed5ba8f62875074f04417189147fd3dda072ab
48-
omit_on_fips
49-
50-
key1024 = OpenSSL::PKey::DSA.generate(1024)
51-
assert_predicate key1024, :private?
52-
assert_equal 1024, key1024.p.num_bits
53-
assert_equal 160, key1024.q.num_bits
54-
end
55-
5655
def test_sign_verify
5756
# The DSA valid size is 2048 or 3072 on FIPS.
5857
# https://github.com/openssl/openssl/blob/7649b5548e5c0352b91d9d3ed695e42a2ac1e99c/providers/common/securitycheck.c#L185-L188
@@ -135,8 +134,6 @@ def test_DSAPrivateKey
135134
end
136135

137136
def test_DSAPrivateKey_encrypted
138-
omit_on_fips
139-
140137
# key = abcdef
141138
dsa512 = Fixtures.pkey("dsa512")
142139
pem = <<~EOF

0 commit comments

Comments
 (0)