-
Notifications
You must be signed in to change notification settings - Fork 15
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
Implement rsa-sha1/rsa-sha256/ecdsa-sha256 algorithms #12
base: master
Are you sure you want to change the base?
Conversation
AlgorithmHmacSha1 = &Algorithm{"hmac-sha1", hmacSign(crypto.SHA1), hmacVerify(crypto.SHA1)} | ||
AlgorithmRsaSha256 = &Algorithm{"rsa-sha256", rsaSign(crypto.SHA256), rsaVerify(crypto.SHA256)} | ||
AlgorithmRsaSha1 = &Algorithm{"rsa-sha1", rsaSign(crypto.SHA1), rsaVerify(crypto.SHA1)} | ||
AlgorithmEcdsaSha256 = &Algorithm{"ecdsa-sha256", ecdsaSign(crypto.SHA256), ecdsaVerify(crypto.SHA256)} |
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 should probably validate that the key is using a P256 curve. If someone generates a P224 curve, the hash would be truncated when siging:
Sign signs a hash (which should be the result of hashing a larger message) using the private key, priv. If the hash is longer than the bit-length of the private key's curve order, the hash will be truncated to that length. It returns the signature as a pair of integers. The security of the private key depends on the entropy of rand.
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.
Technically "ecdsa-sha256" only prescribes that the digest function uses SHA-256. The EC key can use any curve or number of bits. That's something the consumer must be able to infer from the key id.
Thanks for submitting this. I think it's really important. It also needs some careful review which I can't do right now. I hope somebody else can, otherwise I'll get to it eventually. |
No worries :). Definitely agree that this should be reviewed carefully, especially the ECDSA implementation, since the RFC is pretty light on details for it. |
Hi @ejholmes, I'm looking at adding EC support to 99designs/http-signatures-php , and I'm also working on improving the RFC itself. Agreed it's not up to scratch, what specifically are you looking to see? From my end, I don't like that we're pointing to the JWS spec, we should rather aim at an EC-specific spec but I'm not familiar with the literature (or much about EC in general), so some research needed. |
@liamdennehy I think most of my issues were addressed with the addition of a https://github.com/w3c-ccg/http-signatures-test-suite, but I haven't had a chance to test this PR against it. |
This supersedes my original PR that only implemented the rsa-* algorithms, and adds support for ecdsa-sha256 as well.
Notes for reviewer