Skip to content
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

Merged
merged 2 commits into from Jun 2, 2017

Conversation

akzhan
Copy link
Contributor

@akzhan akzhan commented May 20, 2017

No description provided.

Copy link
Contributor

@RX14 RX14 left a 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.
Copy link
Contributor

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.

class OpenSSL::HMAC
# Returns the *data* in combination with the *key* hash computed with *algorithm* Digest.
Copy link
Contributor

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.

@@ -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.
Copy link
Contributor

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.

@akzhan
Copy link
Contributor Author

akzhan commented May 20, 2017

Thanks, @RX14. Just followed by 3531387.

@mverzilli mverzilli merged commit e7caa7d into crystal-lang:master Jun 2, 2017
@mverzilli
Copy link

Thank you @akzhan and @RX14 !

@mverzilli mverzilli added this to the Next milestone Jun 2, 2017
@akzhan akzhan deleted the doc-openssl/hmac.cr branch June 2, 2017 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants