You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
openssl-master: rake test_fips failures about keys #926
I executed the current latest master branch dfbbac6 with the latest OpenSSL master branch openssl/openssl@b20da23 in my forked repository today. I am seeing the failures in the FIPS tests below.
So, maybe a commit on OpenSSL master branch between the b8c46cba5fa0894fc026f1d965beec8089b79dbf (passed) and b20da2328018107414fe896e59e7d4d6c8af8174 (failed) caused the Ruby OpenSSL's test failures.
I can't reproduce the errors on my box with OpenSSL b20da2328018107414fe896e59e7d4d6c8af8174 compiled with the fips provider, and all tests passed as expected.
The error is also weird. require "openssl" succeeds, and during it, a DH PEM is decoded.
In my case with the above test.rb, I confirmed the test.rb passed with the the commit openssl/openssl@dc5cd6f (dc5cd6f70a0eeb30e272fe885a64f3e3d76b5e42). CI log. So, I ran the git bisect for the b20da2328018107414fe896e59e7d4d6c8af8174 (failed) and dc5cd6f70a0eeb30e272fe885a64f3e3d76b5e42 (passed). The bisect.sh code is here.
$ git bisect log
# bad: [b20da2328018107414fe896e59e7d4d6c8af8174] Revert "Pairwise check for DH keys import as part of FIPS"
# good: [dc5cd6f70a0eeb30e272fe885a64f3e3d76b5e42] rsa: expose pairwise consistency test API
git bisect start 'b20da2328018107414fe896e59e7d4d6c8af8174' 'dc5cd6f70a0eeb30e272fe885a64f3e3d76b5e42'
# bad: [32ff539daf83cccc15a159fe214cac66acc80fec] changes: add note about PCT on key import to the FIPS provider
git bisect bad 32ff539daf83cccc15a159fe214cac66acc80fec
# bad: [a177798e0b8f3c7ff66b2a609924aafeb66b8b12] ec (fips): add PCT for key import
git bisect bad a177798e0b8f3c7ff66b2a609924aafeb66b8b12
# good: [58ab3b0ffeea2b4c30f8794d281650ce7bfec6d2] ecx (fips): add PCT for key import
git bisect good 58ab3b0ffeea2b4c30f8794d281650ce7bfec6d2
# first bad commit: [a177798e0b8f3c7ff66b2a609924aafeb66b8b12] ec (fips): add PCT for key import
Then I found the openssl/openssl@a177798 was the first bad (failed) commit in my case with the test.rb reading EC PRIVATE KEY.
Seeing the commits of the openssl/openssl, there are similar commits for the other algorithms below. I assume that these commits caused the test failures for the other algorithms
57230da2bd0be6b219cec2995832034b1e09e0e9 rsa (fips): add PCT for key import
a177798e0b8f3c7ff66b2a609924aafeb66b8b12 ec (fips): add PCT for key import
58ab3b0ffeea2b4c30f8794d281650ce7bfec6d2 ecx (fips): add PCT for key import
Then I found the openssl/openssl@a177798 was the first bad (failed) commit in my case with the test.rb reading EC PRIVATE KEY.
This commit would explain the behavior. The PEM block from test_check_key is specially crafted so that it fails a pair-wise consistency test, and OpenSSL self-destructs itself when it encounters this which seems like a requirement by FIPS 140.
This commit would explain the behavior. The PEM block from test_check_key is specially crafted so that it fails a pair-wise consistency test, and OpenSSL self-destructs itself when it encounters this which seems like a requirement by FIPS 140.
I found the issue ticket openssl/openssl#26572 managing the changes. I still don't understand how to fix our tests by the OpenSSL's changes.
For example, in the case of the test/openssl/test_pkey_ec.rb#test_check_key, how can we change the value of the ec_key_data?
I think that would mean tests using invalid keys have to be skipped. #930
Thank you for the fix!
I was surprised that skipping the only 2 tests (test/openssl/test_pkey_dh.rb#test_params_ok?, and test/openssl/test_pkey_ec.rb#test_check_key) makes all the tests pass.
Below is my test by reverting the fixed commit 25ad8f4 on the latest master branch commit 58cf287. You see many failures except for these 2 tests. Why did this happen? If unnecessary tests failed for some reasons, I think it's better to improve the tests for only essential tests to fail.
Since it appears that it's a FIPS requirement to do a pair-wise check on loading keys, these test cases in ruby/openssl would not be meaningful in the FIPS mode anyway.
Activity
junaruga commentedon Aug 1, 2025
The following CI passed with the openssl/openssl@b8c46cb.
https://github.com/ruby/openssl/actions/runs/16656447633/job/47142524897
So, maybe a commit on OpenSSL master branch between the
b8c46cba5fa0894fc026f1d965beec8089b79dbf(passed) andb20da2328018107414fe896e59e7d4d6c8af8174(failed) caused the Ruby OpenSSL's test failures.rhenium commentedon Aug 2, 2025
I can't reproduce the errors on my box with OpenSSL b20da2328018107414fe896e59e7d4d6c8af8174 compiled with the fips provider, and all tests passed as expected.
The error is also weird.
require "openssl"succeeds, and during it, a DH PEM is decoded.openssl/lib/openssl/ssl.rb
Lines 36 to 45 in dfbbac6
However, loading the exact same PEM fails later (
dh2048_ffdhe2048.pemhas the identical content as the heredoc inlib/openssl/ssl.rb).openssl/test/openssl/test_pkey_dh.rb
Lines 140 to 157 in dfbbac6
https://github.com/junaruga/ruby-openssl/actions/runs/16680199093/job/47216748820#step:11:683
junaruga commentedon Aug 4, 2025
I was able to reproduce this issue with openssl/openssl@b20da23 on my local.
junaruga commentedon Aug 4, 2025
The following test always fails with the openssl/openssl@b20da23.
junaruga commentedon Aug 4, 2025
Sorry after compiling, the failure disappeared. Weird.
junaruga commentedon Aug 4, 2025
I am working on the following branch.
https://github.com/junaruga/ruby-openssl/tree/wip/fips-failures-debug
I found the following
test.rbfails with error on the openssl-master, but passes on the openssl-3.5.0.https://github.com/junaruga/ruby-openssl/actions/runs/16729044811/job/47352316360
junaruga commentedon Aug 4, 2025
In my case with the above
test.rb, I confirmed thetest.rbpassed with the the commit openssl/openssl@dc5cd6f (dc5cd6f70a0eeb30e272fe885a64f3e3d76b5e42). CI log. So, I ran thegit bisectfor theb20da2328018107414fe896e59e7d4d6c8af8174(failed) anddc5cd6f70a0eeb30e272fe885a64f3e3d76b5e42(passed). Thebisect.shcode is here.Then I found the openssl/openssl@a177798 was the first bad (failed) commit in my case with the
test.rbreading EC PRIVATE KEY.Seeing the commits of the openssl/openssl, there are similar commits for the other algorithms below. I assume that these commits caused the test failures for the other algorithms
[-]openssl-master: rake test_fips failures[/-][+]openssl-master: rake test_fips failures about keys[/+]rhenium commentedon Aug 5, 2025
Thanks for looking into this.
This commit would explain the behavior. The PEM block from
test_check_keyis specially crafted so that it fails a pair-wise consistency test, and OpenSSL self-destructs itself when it encounters this which seems like a requirement by FIPS 140.junaruga commentedon Aug 5, 2025
I found the issue ticket openssl/openssl#26572 managing the changes. I still don't understand how to fix our tests by the OpenSSL's changes.
For example, in the case of the
test/openssl/test_pkey_ec.rb#test_check_key, how can we change the value of theec_key_data?rhenium commentedon Aug 12, 2025
I think that would mean tests using invalid keys have to be skipped. #930
pkey: skip tests using invalid keys in the FIPS mode
[ruby/openssl] pkey: skip tests using invalid keys in the FIPS mode
junaruga commentedon Aug 13, 2025
Thank you for the fix!
I was surprised that skipping the only 2 tests (
test/openssl/test_pkey_dh.rb#test_params_ok?, andtest/openssl/test_pkey_ec.rb#test_check_key) makes all the tests pass.Below is my test by reverting the fixed commit 25ad8f4 on the latest master branch commit 58cf287. You see many failures except for these 2 tests. Why did this happen? If unnecessary tests failed for some reasons, I think it's better to improve the tests for only essential tests to fail.
https://github.com/junaruga/ruby-openssl/actions/runs/16933565029/job/47984681154#step:11:357
rhenium commentedon Aug 27, 2025
The OpenSSL commit caused OpenSSL to enter into an error state and stop working entirely. I think that behavior can change, looking at the openssl/openssl discussion: https://redirect.github.com/openssl/openssl/issues/28326
Since it appears that it's a FIPS requirement to do a pair-wise check on loading keys, these test cases in ruby/openssl would not be meaningful in the FIPS mode anyway.
pkey: skip tests using invalid keys in the FIPS mode