From baea36c95500b128869690958262db9538c3162e Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Tue, 30 Jun 2020 14:27:13 +0900 Subject: [PATCH] [ruby/openssl] hmac: add a test case for OpenSSL::HMAC singleton methods https://github.com/ruby/openssl/commit/8253d7c9ce --- test/openssl/test_hmac.rb | 9 +++++++++ 1 file changed, 9 insertions(+) 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