Skip to content

Commit 3f2fc9e

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 f6d81c9 commit 3f2fc9e

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
@@ -648,7 +648,7 @@ func (sd *SignedData) AddSignerInfo(chain []*x509.Certificate, signer crypto.Sig
648648
if err != nil {
649649
return err
650650
}
651-
digestAlgorithmID := digestAlgorithmForPublicKey(pub)
651+
digestAlgorithmID := digestAlgorithmForPublicKey(signer.Public())
652652

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

0 commit comments

Comments
 (0)