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

Use openssl? instead of OpenSSL::OPENSSL_VERSION_NUMBER. #663

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/openssl/test_cipher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def test_aes_ccm
assert_raise(OpenSSL::Cipher::CipherError) { cipher.update(ct2) }
end if has_cipher?("aes-128-ccm") &&
OpenSSL::Cipher.new("aes-128-ccm").authenticated? &&
OpenSSL::OPENSSL_VERSION_NUMBER >= 0x1010103f # version >= 1.1.1c
openssl?(1, 1, 1, 0x03, 0xf) # version >= 1.1.1c

def test_aes_gcm
# GCM spec Appendix B Test Case 4
Expand Down
2 changes: 1 addition & 1 deletion test/openssl/test_pkey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_x25519
end

def raw_initialize
pend "Ed25519 is not implemented" unless OpenSSL::OPENSSL_VERSION_NUMBER >= 0x10101000 && # >= v1.1.1
pend "Ed25519 is not implemented" unless openssl?(1, 1, 1) # >= v1.1.1

assert_raise(OpenSSL::PKey::PKeyError) { OpenSSL::PKey.new_raw_private_key("foo123", "xxx") }
assert_raise(OpenSSL::PKey::PKeyError) { OpenSSL::PKey.new_raw_private_key("ED25519", "xxx") }
Expand Down
5 changes: 3 additions & 2 deletions test/openssl/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ def get_subject_key_id(cert, hex: true)
end
end

def openssl?(major = nil, minor = nil, fix = nil, patch = 0)
def openssl?(major = nil, minor = nil, fix = nil, patch = 0, status = 0)
return false if OpenSSL::OPENSSL_VERSION.include?("LibreSSL")
return true unless major
OpenSSL::OPENSSL_VERSION_NUMBER >=
major * 0x10000000 + minor * 0x100000 + fix * 0x1000 + patch * 0x10
major * 0x10000000 + minor * 0x100000 + fix * 0x1000 + patch * 0x10 +
status * 0x1
end

def libressl?(major = nil, minor = nil, fix = nil)
Expand Down