Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/openssl/test_pkey_ec.rb: refactor tests for EC.builtin_curves #675

Merged
merged 1 commit into from
Aug 31, 2023

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Aug 29, 2023

Check that OpenSSL::PKey::EC.builtin_curves returns an array in the expected format.

Similarly to OpenSSL::Cipher.ciphers, OpenSSL::PKey::EC.builtin_curves returns a list of known named curves rather than actually usable ones.

#671 found that the list may include unapproved (and thus unusable) curves when the FIPS module is loaded.

Check that OpenSSL::PKey::EC.builtin_curves returns an array in the
expected format.

Similarly to OpenSSL::Cipher.ciphers, OpenSSL::PKey::EC.builtin_curves
returns a list of known named curves rather than actually usable ones.

ruby#671 found that the list may
include unapproved (and thus unusable) curves when the FIPS module is
loaded.
@junaruga
Copy link
Member

Thanks for the PR. I tested the PR on my local in FIPS case. And I can see the test_ec_key and newly added test_builtin_curves pass in the case. The failure of the test_ECPrivateKey_encrypted is not related to this PR.

$ OPENSSL_CONF=/home/jaruga/.local/openssl-3.2.0-dev-fips-debug-cf712830b7/ssl/openssl_fips.cnf \
  bundle exec ruby -I./lib -ropenssl test/openssl/test_pkey_ec.rb
Loaded suite test/openssl/test_pkey_ec
Started
E
===================================================================================================================================================================================================================
Error: test_ECPrivateKey_encrypted(OpenSSL::TestEC): OpenSSL::PKey::ECError: invalid curve name
test/openssl/test_pkey_ec.rb:244:in `initialize'
test/openssl/test_pkey_ec.rb:244:in `new'
test/openssl/test_pkey_ec.rb:244:in `test_ECPrivateKey_encrypted'
     241:     0/dGSU5SzFG+iT9iFXCwCvv+bxyegkBOyALFje1NAsM=
     242:     -----END EC PRIVATE KEY-----
     243:     EOF
  => 244:     key = OpenSSL::PKey::EC.new(pem, "abcdef")
     245:     assert_same_ec p256, key
     246:     key = OpenSSL::PKey::EC.new(pem) { "abcdef" }
     247:     assert_same_ec p256, key
===================================================================================================================================================================================================================
Finished in 0.04712535 seconds.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
17 tests, 130 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
94.1176% passed
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
360.74 tests/s, 2758.60 assertions/s

@rhenium
Copy link
Member Author

rhenium commented Aug 31, 2023

Thanks for the confirmation!

BTW, please press the merge button whenever the changes look good to merge.

@rhenium rhenium merged commit 5ccd76c into ruby:master Aug 31, 2023
43 checks passed
@junaruga
Copy link
Member

BTW, please press the merge button whenever the changes look good to merge.

All right. I will keep it in mind, and will do it next time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants