diff --git a/stdlib/openssl/0/openssl.rbs b/stdlib/openssl/0/openssl.rbs index 7e0709910..a04c9b94a 100644 --- a/stdlib/openssl/0/openssl.rbs +++ b/stdlib/openssl/0/openssl.rbs @@ -3665,6 +3665,23 @@ module OpenSSL # def self.hexdigest: (String | Digest algo, String key, String data) -> String + # + # Returns the authentication code as a Base64-encoded string. The _digest_ + # parameter specifies the digest algorithm to use. This may be a String + # representing the algorithm name or an instance of OpenSSL::Digest. + # + # === Example + # key = 'key' + # data = 'The quick brown fox jumps over the lazy dog' + # + # hmac = OpenSSL::HMAC.base64digest('SHA1', key, data) + # #=> "3nybhbi3iqa8ino29wqQcBydtNk=" + # + def self.base64digest: (String | Digest algo, String key, String data) -> String + # # Returns *hmac* updated with the message to be authenticated. Can be called # repeatedly with chunks of the message. @@ -3712,6 +3729,15 @@ module OpenSSL # def hexdigest: () -> String + # + # Returns the authentication code an instance represents as a Base64-encoded + # string. + # + def base64digest: () -> String + # # Returns the authentication code as a hex-encoded string. The *digest* # parameter specifies the digest algorithm to use. This may be a String diff --git a/test/stdlib/OpenSSL_test.rb b/test/stdlib/OpenSSL_test.rb index 76645ccf7..28a64aadb 100644 --- a/test/stdlib/OpenSSL_test.rb +++ b/test/stdlib/OpenSSL_test.rb @@ -525,6 +525,11 @@ def test_hexdigest assert_send_type "(String, String, String) -> String", OpenSSL::HMAC, :hexdigest, "SHA256", "key", "data" end + + def test_base64digest + assert_send_type "(String, String, String) -> String", + OpenSSL::HMAC, :base64digest, "SHA256", "key", "data" + end end class OpenSSLHMACTest < Test::Unit::TestCase @@ -542,6 +547,11 @@ def test_hexdigest hmac, :hexdigest end + def test_base64digest + assert_send_type "() -> String", + hmac, :base64digest + end + def test_reset assert_send_type "() -> OpenSSL::HMAC", hmac, :reset