-
-
Notifications
You must be signed in to change notification settings - Fork 486
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
Add support for HMAC-SHA256 (builds on PR#388) #498
Conversation
To avoid confusion, HMAC constant name should explicitly state which SHA variant is used, but for backwards compatibility, SIGNATURE_HMAC is still needed
The "HMAC-SHA256" signature method uses the HMAC-SHA256 signature | ||
algorithm as defined in `RFC4634`_:: | ||
|
||
digest = HMAC-SHA256 (key, text) |
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.
There is no such thing in RFC5849.
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.
Agreed. Note that my comment didn't claim it was in RFC5849, but defined in RFC4634 (as one of the suite of accepted Secure Hash Algorithms beyond SHA-1).
I took 5849's provision of three signature methods as not exclusive. In section 3.4, it says "OAuth does not mandate a particular signature method" (my emphasis), and so it seems useful, with little harm, to add support for SHA2-family signing methods.
If the maintainers would prefer to have clients add support for more modern signing methods via extension, rather than provided in the library, I can understand that decision. I would have thought having the support in-library would at least help clients ensure consistency, but it's clearly not my decision.
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.
@ViktorHaag See my comment. There is a register function to extend signature methods. The folder is named as rfc5849, things beyond this scope should not be included.
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.
Yes, I understand your point. I had assumed from the comments in #388, that the blocking factor here was a lack of testing and documentation, and not the idea in the first place. It was for that reason that I decided to help by "finishing" the original PR. If the maintainer group would prefer not to include it, that's fine: I'm glad there is a way to extend the package usefully.
Actually there is a way to register your own signature method. This HMAC-SHA256 is not a part of the specification in RFC. This patch should not be included in this repo. |
I have given this some thought. |
Thank you @ViktorHaag @mick88 @lepture If you strongly disagree let's chat about this over email. |
This pull incorporates changes from PR #388 as it appears orphaned.
I cleaned up the comments for the HMAC-SHA256 signing method, and added tests for the SHA1 and SHA256 signing methods (I verified the signature generation code against node's
oauth-1.0a
andcrypto
modules, to be satisfied that the test signature values were valid).