-
Notifications
You must be signed in to change notification settings - Fork 26
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 RS256
, COSEAlgorithmIdentifier -257
#140
Conversation
5ca7980
to
8bab3b9
Compare
Signed-off-by: Herman Slatman <hermanslatman@hotmail.com>
8bab3b9
to
a745f5a
Compare
Codecov Report
@@ Coverage Diff @@
## main #140 +/- ##
==========================================
+ Coverage 92.77% 92.87% +0.09%
==========================================
Files 10 10
Lines 1024 1038 +14
==========================================
+ Hits 950 964 +14
Misses 49 49
Partials 25 25
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Hi @hslatman, thanks very much for initiating the contribution, much appreciated! As you probably know already RS256 is not amongst the recommended algorithms for COSE -- and for pretty good reasons :-) So, it'd be good if you could file an associated issue where you describe the use case and where we can have a conversation on requirements, caveats, etc. cheers! |
Thank you, @thomas-fossati, I've opened an issue: #141. For my use case, having just the |
Fantastic, thanks! I'm on holiday until the 11th, so I can't join the discussion until then. @SteveLasker @qmuntal @shizhMSFT @roywill @yogeshbdeshpande could you please chime in so we don't let Herman wait too long? TIA |
@hslatman Request please create a new PR fr adding the RS256 constant |
@@ -22,6 +22,10 @@ const ( | |||
// Requires an available crypto.SHA512. | |||
AlgorithmPS512 Algorithm = -39 | |||
|
|||
// RSASSA-PKCS1-v1_5 using SHA-256 by RFC 8812. | |||
// Requires an available crypto.SHA256. | |||
AlgorithmRS256 Algorithm = -257 |
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.
consider a link / comment to webauthn: https://www.w3.org/TR/webauthn-2/#sctn-sample-registration
return ErrVerification | ||
switch rv.alg { | ||
case AlgorithmRS256: | ||
if err := rsa.VerifyPKCS1v15(rv.key, hash, digest, signature); err != nil { |
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.
maybe you want to remove this part
} | ||
|
||
// set up signer for RS256 | ||
algRS256 := AlgorithmRS256 |
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.
maybe you want to remove this part
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.
seems like folks are requesting the constant be kept but APIs on it throw some error related to it not being supported, without using an external signer
We are not going to implement this algorithms but allowed the constant to be added in another pull request |
This PR adds support for RSASSA PKCS#1 v1.5 signing and verification. I started with just
RS256
, but I can add the others too if this PR will be considered to be merged at some point.Let me know if you want the tests to be more like a table; currently they're more like multiple copies.
I noticed that registering an algorithm was removed with #101, but I could use the
RS256
(and potentially others) for some things, primarily for checking/validating values to be valid COSE values. Adding in theRS256
in all required places seemed to be the way to go,or willI noticed signing and verifying can be done backed by a user-providedRegisterAlgorithm
be reconsidered?Signer
andVerifier
. Should I remove the signing and verification code, and just keep theAlgorithmRS256
around?