@@ -82,6 +82,13 @@ def test_hmac_sign_verify
8282 end
8383
8484 def test_ed25519
85+ # Ed25519 is not approved in OpenSSL 3.1+ FIPS code.
86+ # See OpenSSL providers/fips/fipsprov.c PROV_NAMES_ED25519 entries
87+ # with FIPS_UNAPPROVED_PROPERTIES in OpenSSL 3.1+.
88+ if OpenSSL . fips_mode && openssl? ( 3 , 1 , 0 , 0 )
89+ omit "Ed25519 is not approved in OpenSSL 3.1+ FIPS code"
90+ end
91+
8592 # Test vector from RFC 8032 Section 7.1 TEST 2
8693 priv_pem = <<~EOF
8794 -----BEGIN PRIVATE KEY-----
@@ -96,15 +103,11 @@ def test_ed25519
96103 begin
97104 priv = OpenSSL ::PKey . read ( priv_pem )
98105 pub = OpenSSL ::PKey . read ( pub_pem )
99- rescue OpenSSL ::PKey ::PKeyError
106+ rescue OpenSSL ::PKey ::PKeyError => e
100107 # 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
108+ pend "Ed25519 is not implemented" unless openssl? ( 1 , 1 , 1 )
109+
110+ raise e
108111 end
109112 assert_instance_of OpenSSL ::PKey ::PKey , priv
110113 assert_instance_of OpenSSL ::PKey ::PKey , pub
@@ -145,6 +148,21 @@ def test_ed25519
145148 assert_raise ( OpenSSL ::PKey ::PKeyError ) { priv . derive ( pub ) }
146149 end
147150
151+ def test_ed25519_not_supported_on_openssl_3_1_plus_fips
152+ unless OpenSSL . fips_mode && openssl? ( 3 , 1 , 0 , 0 )
153+ omit "Only for OpenSSL 3.1+ FIPS"
154+ end
155+
156+ priv_pem = <<~EOF
157+ -----BEGIN PRIVATE KEY-----
158+ MC4CAQAwBQYDK2VwBCIEIEzNCJso/5banbbDRuwRTg9bijGfNaumJNqM9u1PuKb7
159+ -----END PRIVATE KEY-----
160+ EOF
161+ assert_raise ( OpenSSL ::PKey ::PKeyError ) do
162+ OpenSSL ::PKey . read ( priv_pem )
163+ end
164+ end
165+
148166 def test_x25519
149167 # Test vector from RFC 7748 Section 6.1
150168 alice_pem = <<~EOF
0 commit comments