[ruby/openssl] test_bn.rb: AWS-LC does not support BN::CONSTTIME

AWS-LC does not support BN_FLG_CONSTTIME due to its historically
inconsistent constant-time guarantees.

https://github.com/ruby/openssl/commit/9875a01b5f
This commit is contained in:
Samuel Chiang 2025-02-12 01:13:38 +00:00 committed by git
parent f14995e212
commit ee5af8860f

View File

@ -321,6 +321,8 @@ class OpenSSL::TestBN < OpenSSL::TestCase
end end
def test_get_flags_and_set_flags def test_get_flags_and_set_flags
return if aws_lc? # AWS-LC does not support BN::CONSTTIME.
e = OpenSSL::BN.new(999) e = OpenSSL::BN.new(999)
assert_equal(0, e.get_flags(OpenSSL::BN::CONSTTIME)) assert_equal(0, e.get_flags(OpenSSL::BN::CONSTTIME))
@ -364,7 +366,9 @@ class OpenSSL::TestBN < OpenSSL::TestCase
assert_equal(true, Ractor.new(@e2) { _1.negative? }.take) assert_equal(true, Ractor.new(@e2) { _1.negative? }.take)
assert_include(128..255, Ractor.new { OpenSSL::BN.rand(8)}.take) assert_include(128..255, Ractor.new { OpenSSL::BN.rand(8)}.take)
assert_include(0...2**32, Ractor.new { OpenSSL::BN.generate_prime(32) }.take) assert_include(0...2**32, Ractor.new { OpenSSL::BN.generate_prime(32) }.take)
if !aws_lc? # AWS-LC does not support BN::CONSTTIME.
assert_equal(0, Ractor.new { OpenSSL::BN.new(999).get_flags(OpenSSL::BN::CONSTTIME) }.take) assert_equal(0, Ractor.new { OpenSSL::BN.new(999).get_flags(OpenSSL::BN::CONSTTIME) }.take)
end
# test if shareable when frozen # test if shareable when frozen
assert Ractor.shareable?(@e1.freeze) assert Ractor.shareable?(@e1.freeze)
end end