Skip to content

Commit 1be7f13

Browse files
committed
cppki: use appropriate digest algorithm during CMS signature creation
Mirror of github/smimesign#97 Pass the public key instead of the marshalled public key to digestAlgorithmForPublicKey in SignedData.AddSignerInfo. Previously, the marshalled public key was passed instead of the actual public key. The result is that always SHA256 was being selected, even for ECDSA where the hash algorithm should be selected based on the curve.
1 parent 5a169de commit 1be7f13

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/scrypto/cms/protocol/protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ func (sd *SignedData) AddSignerInfo(chain []*x509.Certificate, signer crypto.Sig
647647
if err != nil {
648648
return err
649649
}
650-
digestAlgorithmID := digestAlgorithmForPublicKey(pub)
650+
digestAlgorithmID := digestAlgorithmForPublicKey(signer.Public())
651651

652652
signatureAlgorithmOID, ok := oid.X509PublicKeyAndDigestAlgorithmToSignatureAlgorithm[cert.PublicKeyAlgorithm][digestAlgorithmID.Algorithm.String()] // nolint:lll
653653
if !ok {

0 commit comments

Comments
 (0)