Skip to content

Conversation

@ejholmes
Copy link

This implements the rsa-sha1 and rsa-sha256 algorithms according to the most recent spec.

There's another PR for this (#3) but that PR is implemented incorrectly. In #3, verification of the signature requires access to the private key. The benefit of RSA public/private keys is that you only need access to the public key to verify that the request was signed by a private key.

}

// IsValidRSA validates that the signature was signed by an RSA private key.
func (s Signature) IsValidRSA(key *rsa.PublicKey, r *http.Request) bool {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to take note of here. I didn't want to break the existing api for IsValid, but I also don't want this code to be dealing with RSA keys as strings, and would rather just have consumers parse the public/private keys.

So, I just added the the IsValidRSA/SignRequestRSA versions of the IsValid/SignRequest methods. The downside is that this leaks details about the underlying algorithm. Alternatively, I could add a more generic IsValid<xxx>(key interface{}, r *http.Request) method as well so that you can pass a string for HMAC, or an *rsa.PublicKey for RSA.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self. Also need an AuthRequestRSA method.

@ejholmes ejholmes mentioned this pull request Oct 25, 2017
@ejholmes
Copy link
Author

See #12, which adds everything here as well as ecdsa-sha256.

@ejholmes ejholmes closed this Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant