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 3 FIPS mode - creating encrypted RSA key pair fails with PEM_write_bio_PrivateKey_traditional: initialization error (OpenSSL::PKey::PKeyError) #643
$ LD_LIBRARY_PATH=${HOME}/.local/openssl-3.0.9-fips-debug/lib/ \
OPENSSL_CONF=/home/jaruga/.local/openssl-3.0.9-fips-debug/ssl/openssl_fips.cnf \
./fips_mode
Loaded providers:
fips
base
FIPS mode enabled: 1
I think this might be unfixable. OpenSSL's traditional PEM encryption format uses MD5 to derive encryption keys from the password, but MD5 is prohibited under the FIPS mode, hence it fails.
We should document this. There is also room for improvement in the exception message. Running the code with OpenSSL.debug = true shows more information:
@rhenium Thanks for the info. In that case, I think we can improve the logic to print the error message to tell users the reason with a better error message, and I think that can be a solution to close this issue ticket.
As a note OpenSSL 3.0 FIPS supports FIPS 140-2, and OpenSSL 3.1 FIPS supports FIPS 140-3. I learned it recently. :)
We should document this. There is also room for improvement in the exception message. Running the code with OpenSSL.debug = true shows more information:
Those are nice tips. For another improvement, perhaps, we might be able to create an issue template for this repository, adding the info as a reporting way.
I plan to list up all the supported encryptions in Ruby OpenSSL binding, then to compare the specification with OpenSSL 3.0 FIPS (FIPS 140-2) and OpenSSL 3.1 FIPS (FIPS 140-3) manually to decide how to implement.
Activity
junaruga commentedon Jun 27, 2023
I was reproduce this issue on the current master branch < 97fb410> with OpenSSL 3.0.9 FIPS built from the source.
The reproducing steps:
Install the OpenSSL seeing the Documents - How to debug Ruby OpenSSL binding.
Check the enabled FIPS and fips and base providers by this testing program.
Compile
Check the compiled Ruby binding is linked to the OpenSSL 3.0.9, and FIPS is enabled.
Here is your script.
Your reproducing script fails on FIPS as reported.
Your script succeeds as reported.
rhenium commentedon Jun 27, 2023
I think this might be unfixable. OpenSSL's traditional PEM encryption format uses MD5 to derive encryption keys from the password, but MD5 is prohibited under the FIPS mode, hence it fails.
We should document this. There is also room for improvement in the exception message. Running the code with
OpenSSL.debug = trueshows more information:junaruga commentedon Jun 27, 2023
@rhenium Thanks for the info. In that case, I think we can improve the logic to print the error message to tell users the reason with a better error message, and I think that can be a solution to close this issue ticket.
As a note OpenSSL 3.0 FIPS supports FIPS 140-2, and OpenSSL 3.1 FIPS supports FIPS 140-3. I learned it recently. :)
Those are nice tips. For another improvement, perhaps, we might be able to create an issue template for this repository, adding the info as a reporting way.
junaruga commentedon Jun 27, 2023
I plan to list up all the supported encryptions in Ruby OpenSSL binding, then to compare the specification with OpenSSL 3.0 FIPS (FIPS 140-2) and OpenSSL 3.1 FIPS (FIPS 140-3) manually to decide how to implement.
rhenium commentedon Jun 28, 2023
#645 updates the RDoc for exporting PKeys.
junaruga commentedon Jun 29, 2023
@tarnowsc I suppose that the following code with
OpenSSL::PKey::RSA#private_to_pemis a right way to achieve what you want to do.instead of the following code.
The #645 is to explain the details.
tarnowsc commentedon Jun 30, 2023
yes, thanks for your support, the output of those two commands is not exactly identical, but it should do the trick: