diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2020-06-30 14:27:13 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2021-03-16 19:16:11 +0900 |
commit | baea36c95500b128869690958262db9538c3162e (patch) | |
tree | 8902f7fe11a7c5760493f01325f0fef88c4f324e /test/openssl/test_hmac.rb | |
parent | fde9f806cb4fa9145e6eb73406ea4b932ddb8eb7 (diff) |
[ruby/openssl] hmac: add a test case for OpenSSL::HMAC singleton methods
https://github.com/ruby/openssl/commit/8253d7c9ce
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4275
Diffstat (limited to 'test/openssl/test_hmac.rb')
-rw-r--r-- | test/openssl/test_hmac.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/openssl/test_hmac.rb b/test/openssl/test_hmac.rb index 9cb3c5a864..7202a5902f 100644 --- a/test/openssl/test_hmac.rb +++ b/test/openssl/test_hmac.rb @@ -49,6 +49,15 @@ class OpenSSL::TestHMAC < OpenSSL::TestCase 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 |