@@ -82,6 +82,17 @@ def test_hmac_sign_verify
8282 end
8383
8484 def test_ed25519
85+ # Ed25519 is not FIPS-approved in OpenSSL 3.0 security policy documents.
86+ # However, it's technically allowed in the OpenSSL 3.0 code.
87+ #
88+ # See OpenSSL providers/fips/fipsprov.c PROV_NAMES_ED25519 entries with
89+ # FIPS_DEFAULT_PROPERTIES in OpenSSL 3.0 (openssl-3.0 branch) and
90+ # FIPS_UNAPPROVED_PROPERTIES in OpenSSL 3.1 (openssl-3.1 branch).
91+ #
92+ # See https://github.com/openssl/openssl/issues/20758#issuecomment-1639658102
93+ # for details.
94+ omit_on_fips { openssl? ( 3 , 1 , 0 , 0 ) }
95+
8596 # Test vector from RFC 8032 Section 7.1 TEST 2
8697 priv_pem = <<~EOF
8798 -----BEGIN PRIVATE KEY-----
@@ -96,15 +107,11 @@ def test_ed25519
96107 begin
97108 priv = OpenSSL ::PKey . read ( priv_pem )
98109 pub = OpenSSL ::PKey . read ( pub_pem )
99- rescue OpenSSL ::PKey ::PKeyError
110+ rescue OpenSSL ::PKey ::PKeyError => e
100111 # 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
112+ pend "Ed25519 is not implemented" unless openssl? ( 1 , 1 , 1 )
113+
114+ raise e
108115 end
109116 assert_instance_of OpenSSL ::PKey ::PKey , priv
110117 assert_instance_of OpenSSL ::PKey ::PKey , pub
@@ -145,6 +152,21 @@ def test_ed25519
145152 assert_raise ( OpenSSL ::PKey ::PKeyError ) { priv . derive ( pub ) }
146153 end
147154
155+ def test_ed25519_not_approved_on_fips
156+ unless OpenSSL . fips_mode && openssl? ( 3 , 1 , 0 , 0 )
157+ omit "Only for OpenSSL 3.1+ FIPS"
158+ end
159+
160+ priv_pem = <<~EOF
161+ -----BEGIN PRIVATE KEY-----
162+ MC4CAQAwBQYDK2VwBCIEIEzNCJso/5banbbDRuwRTg9bijGfNaumJNqM9u1PuKb7
163+ -----END PRIVATE KEY-----
164+ EOF
165+ assert_raise ( OpenSSL ::PKey ::PKeyError ) do
166+ OpenSSL ::PKey . read ( priv_pem )
167+ end
168+ end
169+
148170 def test_x25519
149171 # Test vector from RFC 7748 Section 6.1
150172 alice_pem = <<~EOF
0 commit comments