-
Notifications
You must be signed in to change notification settings - Fork 124
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 Ed25519ph Signer/Verifier #1595
Conversation
I'd appreciate any comment or concern, in particular with regards to the change of behaviour of |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@ret2libc I'm going to be taking a look at all PRs later today and tomorrow. I have a bit of a backlog I'm working through. |
Thanks! Actually, I have a WIP branch which I think is a bit cleaner. It uses the Options pattern and it looks like this: func LoadSignerVerifier(privateKey crypto.PrivateKey, hashFunc crypto.Hash, opts ...SignerVerifierOption) (SignerVerifier, error) {
o := makeSignerVerifierOpts(opts...)
switch pk := privateKey.(type) {
case *rsa.PrivateKey:
if o.rsaPSSOptions != nil {
return LoadRSAPSSSignerVerifier(pk, hashFunc, o.rsaPSSOptions)
}
return LoadRSAPKCS1v15SignerVerifier(pk, hashFunc)
case *ecdsa.PrivateKey:
return LoadECDSASignerVerifier(pk, hashFunc)
case ed25519.PrivateKey:
if o.useED25519ph {
return LoadED25519phSignerVerifier(pk)
}
return LoadED25519SignerVerifier(pk)
}
return nil, errors.New("unsupported public key type")
} which avoids having to modify all callers of sv, err := LoadSignerVerifier(privateKey, crypto.SHA256, WithED25519ph(), WithRSAPSS(opts)) What do you think? You can have a quick look at it at https://github.com/trail-of-forks/sigstore/tree/ed25519ph-2 and I can use that instead if you like that approach more. |
@ret2libc I'm a big fan of that API design, that looks great! Do you think we can create a second set of functions, Edit: Sorry misread it was a branch, yes, I like that design a lot! |
I think this is still, in theory, a breaking change as it changes the signature of the API. Probably it won't be noticed in practice, but it depends on how others are using the Signature/Verifier API.
I can, yes! |
Added |
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.
a couple nits but overall LGTM
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.
Looks great!
I think I've addressed all comments, thanks for the reviews! |
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.
two nits, otherwise LGTM
Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
Before this commit, the Signer/Verifier to load was determined exclusively by the public/private key type, however there may be multiple Signers/Verifiers available, like in the case of RSA and ED25519. This commit adds LoadVerifierWithOpts, LoadSignerWithOpts, and LoadSignerVerifierWithOpts to give clients more flexibility, allowing the user of the API to choose between the available options by using options. Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
please fix the linting issues, otherwise LGTM |
Signed-off-by: Riccardo Schirone <riccardo.schirone@trailofbits.com>
Great! Thanks a lot for the review! Should be good now. |
Summary
Add support for Ed25519ph digital signature to be used by other repos like Rekor, Cosign and sigstore-go.
Full e2e tests require changes in cosign and rekor as well.
Tests have been added for the Ed25519ph Signer/Verifier similar to the others.
Release Note
ED25519phSigner
,ED25519phVerifier
, andED25519phSignerVerifier
LoadSigner
,LoadVerifier
, andLoadSignerVerifier
to default to theph
version of Ed25519 whenever a ed25519 private/public key is found.Documentation
No changes in documentation required, I think.