Repository navigation
Conversation
cram_secret mixed the UTF-8 secret with the binary challenge and digest, which raised Encoding::CompatibilityError, and it compared the character count (not the byte count) against the 64 byte HMAC block size. Work on the secret's bytes so the response matches HMAC-MD5 per RFC 2195.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
authtype: :cram_md5fails as soon as the password has a non-ASCII character:cram_secretXORs the secret character by character and then appends the binary challenge and digest to it, so a UTF-8 secret with multibyte characters can't be combined with them. It also comparessecret.size(characters) with the 64-byte HMAC block size, so a secret of 33 to 64 characters that is longer than 64 bytes wasn't hashed first as RFC 2104 requires.This converts the secret to bytes before building the pads and checks
bytesize, so the response is the plain HMAC-MD5 from RFC 2195. ASCII secrets give the same result as before.I added a test with the RFC 2195 example and compared non-ASCII and long secrets against
OpenSSL::HMAC. The new test fails on master with the error above, andbundle exec rake testpasses.