-
Notifications
You must be signed in to change notification settings - Fork 30
Make built-in types implement the new DigestSigner and DigestVerify interface #144
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
Changes from all commits
258e185
d314e95
2893601
bbfd793
82a1648
c36e47e
5548b0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,17 @@ type Signer interface { | |
| Sign(rand io.Reader, content []byte) ([]byte, error) | ||
| } | ||
|
|
||
| // DigestSigner is an interface for private keys to sign digested COSE signatures. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is interface also an integration point with remote KMS? any time you have hardware isolated keys, you need a signer interface to request signatures from them. |
||
| type DigestSigner interface { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Does this interface support signing digest from any Digest Algorithm ? Meaning should
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How could we restrict that? Everyone is free to implement the interface as needed, Go doesn't allow intercepting interface implementations to do custom validations. Also, in this PR we don't use this interface anywhere, users would have to construct the
Yes |
||
| // Algorithm returns the signing algorithm associated with the private key. | ||
| Algorithm() Algorithm | ||
|
|
||
| // SignDigest signs message digest with the private key, possibly using | ||
| // entropy from rand. | ||
| // The resulting signature should follow RFC 8152 section 8. | ||
| SignDigest(rand io.Reader, digest []byte) ([]byte, error) | ||
| } | ||
|
|
||
| // NewSigner returns a signer with a given signing key. | ||
| // The signing key can be a golang built-in crypto private key, a key in HSM, or | ||
| // a remote KMS. | ||
|
|
@@ -34,6 +45,8 @@ type Signer interface { | |
| // public key of type `*rsa.PublicKey`, `*ecdsa.PublicKey`, or | ||
| // `ed25519.PublicKey` are accepted. | ||
| // | ||
| // The returned signer for rsa and ecdsa keys also implements `cose.DigestSigner`. | ||
| // | ||
| // Note: `*rsa.PrivateKey`, `*ecdsa.PrivateKey`, and `ed25519.PrivateKey` | ||
| // implement `crypto.Signer`. | ||
| func NewSigner(alg Algorithm, key crypto.Signer) (Signer, error) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.