-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation for OpenSSL::HMAC class. #4434
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The python docs are a good reference for this documentation: https://docs.python.org/3.6/library/hmac.html
# Allows computing Hash-based Message Authentication Code (HMAC). | ||
# | ||
# It is a type of message authentication code (MAC) | ||
# involving a hash function in combination with a key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This paragraph doesn't explain how to use a HMAC or what to use it for. The RFC has quite a good introduction on this topic (and is the source of truth for the implementation) so I suggest we link that: RFC2104.
src/openssl/hmac.cr
Outdated
class OpenSSL::HMAC | ||
# Returns the *data* in combination with the *key* hash computed with *algorithm* Digest. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be written better simplified:
Returns the HMAC digest of data using the secret key key.
Adding a note that the result is binary might be useful.
It may contain non-ASCII bytes, including NUL bytes.
src/openssl/hmac.cr
Outdated
@@ -20,6 +37,10 @@ class OpenSSL::HMAC | |||
buffer[0, buffer_len.to_i] | |||
end | |||
|
|||
# Returns the *data* in combination with the *key* hash computed with *algorithm* Digest | |||
# as hexadecimal string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns the HMAC digest of data using the secret key key, formatted as a hexadecimal string. This is neccesary to safely transfer the digest where binary messages are not allowed.
No description provided.