Skip to content

Commit

Permalink
Merge pull request #864 from rhenium/ky/digest-test-sha3-aws-lc
Browse files Browse the repository at this point in the history
digest: always run SHA-3 and truncated SHA-2 tests
  • Loading branch information
rhenium authored Feb 27, 2025
2 parents 5544c6e + 8faa1d8 commit bf96565
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions test/openssl/test_digest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def test_sha2
end

def test_sha512_truncate
pend "SHA512_224 is not implemented" unless digest_available?('sha512-224')
sha512_224_a = "d5cdb9ccc769a5121d4175f2bfdd13d6310e0d3d361ea75d82108327"
sha512_256_a = "455e518824bc0601f9fb858ff5c37d417d67c2f8e0df2babe4808858aea830f8"

Expand All @@ -100,15 +99,14 @@ def test_sha512_truncate
end

def test_sha3
pend "SHA3 is not implemented" unless digest_available?('sha3-224')
s224 = '6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7'
s256 = 'a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a'
s384 = '0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004'
s512 = 'a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26'
assert_equal(OpenSSL::Digest.hexdigest('SHA3-224', ""), s224)
assert_equal(OpenSSL::Digest.hexdigest('SHA3-256', ""), s256)
assert_equal(OpenSSL::Digest.hexdigest('SHA3-384', ""), s384)
assert_equal(OpenSSL::Digest.hexdigest('SHA3-512', ""), s512)
assert_equal(s224, OpenSSL::Digest.hexdigest('SHA3-224', ""))
assert_equal(s256, OpenSSL::Digest.hexdigest('SHA3-256', ""))
assert_equal(s384, OpenSSL::Digest.hexdigest('SHA3-384', ""))
assert_equal(s512, OpenSSL::Digest.hexdigest('SHA3-512', ""))
end

def test_digest_by_oid_and_name_sha2
Expand Down Expand Up @@ -145,11 +143,6 @@ def check_digest(oid)
d = OpenSSL::Digest.new(oid.oid)
assert_not_nil(d)
end

def digest_available?(name)
@digests ||= OpenSSL::Digest.digests
@digests.include?(name)
end
end

end

0 comments on commit bf96565

Please sign in to comment.