Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
25 changes: 25 additions & 0 deletions stdlib/openssl/0/openssl.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -3665,6 +3665,23 @@ module OpenSSL
#
def self.hexdigest: (String | Digest algo, String key, String data) -> String

# <!--
# rdoc-file=ext/openssl/lib/openssl/hmac.rb
# - HMAC.base64digest(digest, key, data) -> aString
# -->
# 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

# <!-- rdoc-file=ext/openssl/ossl_hmac.c -->
# Returns *hmac* updated with the message to be authenticated. Can be called
# repeatedly with chunks of the message.
Expand Down Expand Up @@ -3712,6 +3729,14 @@ module OpenSSL
#
def hexdigest: () -> String

# <!--
# rdoc-file=ext/openssl/lib/openssl/hmac.rb
# - hmac.base64digest -> string
# -->
# Returns the authentication code an a Base64-encoded string.
#
def base64digest: () -> String

# <!-- rdoc-file=ext/openssl/lib/openssl/hmac.rb -->
# Returns the authentication code as a hex-encoded string. The *digest*
# parameter specifies the digest algorithm to use. This may be a String
Expand Down
10 changes: 10 additions & 0 deletions test/stdlib/OpenSSL_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit da6925e

Please sign in to comment.