Repository navigation
Conversation
crypto.Signer implementations in the standard library accept nil opts: ecdsa.PrivateKey.Sign picks the hash from the curve and ed25519 signs the raw message. Callers such as PKCS #11 CKM_ECDSA, which don't know which hash produced the digest, depend on this. Several of our signers instead panicked on opts.HashFunc() or rejected the call. Add cryptoutil.SignerOpts, which turns nil opts into what crypto/ecdsa would use: - ECDSA keys get the hash named by the curve (SHA-256, SHA-384 or SHA-512). Shorter digests are left-padded with zeros and longer ones are truncated, so the signature matches the one for the original digest. P-521 fails on digests longer than 64 bytes, and an empty digest fails. - RSA keys fail, because the signature depends on the hash. - Other keys sign with crypto.Hash(0). Use it in the awskms, azurekms, cloudkms, yubikey, tpm and tss2 signers. In capi, mackms and pkcs11, return an error instead of panicking when an RSA key gets nil opts; pkcs11 wraps crypto11 RSA signers to do this. x25519 now accepts nil opts as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
crypto.Signer implementations in the standard library accept nil opts: ecdsa.PrivateKey.Sign picks the hash from the curve and ed25519 signs the raw message. Callers such as PKCS #11 CKM_ECDSA, which don't know which hash produced the digest, depend on this. Several of our signers instead panicked on opts.HashFunc() or rejected the call.
Add cryptoutil.SignerOpts, which turns nil opts into what crypto/ecdsa would use:
Use it in the awskms, azurekms, cloudkms, yubikey, tpm and tss2 signers. In capi, mackms and pkcs11, return an error instead of panicking when an RSA key gets nil opts; pkcs11 wraps crypto11 RSA signers to do this. x25519 now accepts nil opts as well.