@@ -82,6 +82,9 @@ def test_hmac_sign_verify
8282 end
8383
8484 def test_ed25519
85+ # Ed25519 is not FIPS-approved.
86+ omit_on_fips
87+
8588 # Test vector from RFC 8032 Section 7.1 TEST 2
8689 priv_pem = <<~EOF
8790 -----BEGIN PRIVATE KEY-----
@@ -96,15 +99,11 @@ def test_ed25519
9699 begin
97100 priv = OpenSSL ::PKey . read ( priv_pem )
98101 pub = OpenSSL ::PKey . read ( pub_pem )
99- rescue OpenSSL ::PKey ::PKeyError
102+ rescue OpenSSL ::PKey ::PKeyError => e
100103 # OpenSSL < 1.1.1
101- if !openssl? ( 1 , 1 , 1 )
102- pend "Ed25519 is not implemented"
103- elsif OpenSSL . fips_mode && openssl? ( 3 , 1 , 0 , 0 )
104- # See OpenSSL providers/fips/fipsprov.c PROV_NAMES_ED25519 entries
105- # with FIPS_UNAPPROVED_PROPERTIES in OpenSSL 3.1+.
106- pend "Ed25519 is not approved in OpenSSL 3.1+ FIPS code"
107- end
104+ pend "Ed25519 is not implemented" unless openssl? ( 1 , 1 , 1 )
105+
106+ raise e
108107 end
109108 assert_instance_of OpenSSL ::PKey ::PKey , priv
110109 assert_instance_of OpenSSL ::PKey ::PKey , pub
@@ -145,6 +144,32 @@ def test_ed25519
145144 assert_raise ( OpenSSL ::PKey ::PKeyError ) { priv . derive ( pub ) }
146145 end
147146
147+ def test_ed25519_not_approved_on_fips
148+ omit_on_non_fips
149+ # Ed25519 is technically allowed in the OpenSSL 3.0 code as a kind of bug.
150+ # So, we need to omit OpenSSL 3.0.
151+ #
152+ # See OpenSSL providers/fips/fipsprov.c PROV_NAMES_ED25519 entries with
153+ # FIPS_DEFAULT_PROPERTIES on openssl-3.0 branch and
154+ # FIPS_UNAPPROVED_PROPERTIES on openssl-3.1 branch.
155+ #
156+ # See also
157+ # https://github.com/openssl/openssl/issues/20758#issuecomment-1639658102
158+ # for details.
159+ unless openssl? ( 3 , 1 , 0 , 0 )
160+ omit 'Ed25519 is allowed in the OpenSSL 3.0 FIPS code as a kind of bug'
161+ end
162+
163+ priv_pem = <<~EOF
164+ -----BEGIN PRIVATE KEY-----
165+ MC4CAQAwBQYDK2VwBCIEIEzNCJso/5banbbDRuwRTg9bijGfNaumJNqM9u1PuKb7
166+ -----END PRIVATE KEY-----
167+ EOF
168+ assert_raise ( OpenSSL ::PKey ::PKeyError ) do
169+ OpenSSL ::PKey . read ( priv_pem )
170+ end
171+ end
172+
148173 def test_x25519
149174 # Test vector from RFC 7748 Section 6.1
150175 alice_pem = <<~EOF
0 commit comments