Skip to content

Commit

Permalink
hmac: add a test case for OpenSSL::HMAC singleton methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rhenium committed Jun 30, 2020
1 parent 93213b2 commit 8253d7c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/openssl/test_hmac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ def test_eq
refute_equal h1, h2.digest
refute_equal h1, h3
end

def test_singleton_methods
# RFC 2202 2. Test Cases for HMAC-MD5
key = ["0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"].pack("H*")
digest = OpenSSL::HMAC.digest("MD5", key, "Hi There")
assert_equal ["9294727a3638bb1c13f48ef8158bfc9d"].pack("H*"), digest
hexdigest = OpenSSL::HMAC.hexdigest("MD5", key, "Hi There")
assert_equal "9294727a3638bb1c13f48ef8158bfc9d", hexdigest
end
end

end

0 comments on commit 8253d7c

Please sign in to comment.