Skip to content

Commit

Permalink
pkcs7: fix error message
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Jan 15, 2025
1 parent 94e533c commit 057ddb5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkcs7/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ func signData(data []byte, pkey crypto.PrivateKey, hasher crypto.Hash, isDigestP
if !isDigestProvided {
opts = sm2.DefaultSM2SignerOpts
} else if len(hash) != sm3.Size {
return nil, fmt.Errorf("pkcs7: invalid hash value fo SM2 signature")
return nil, fmt.Errorf("pkcs7: invalid hash value for SM2 signature")
}
switch realKey := key.(type) {
case *ecdsa.PrivateKey:
Expand All @@ -441,14 +441,14 @@ func signData(data []byte, pkey crypto.PrivateKey, hasher crypto.Hash, isDigestP
}
}
} else {
return nil, fmt.Errorf("pkcs7: unsupported hash function %s", hasher)
return nil, fmt.Errorf("pkcs7: unsupported hash function %v", hasher)
}
} else if !isDigestProvided {
h := hasher.New()
h.Write(data)
hash = h.Sum(nil)
} else if len(hash) != hasher.Size() {
return nil, fmt.Errorf("pkcs7: invalid hash for %s", hasher)
return nil, fmt.Errorf("pkcs7: invalid hash value for %v", hasher)
}
return key.Sign(rand.Reader, hash, opts)
}
Expand Down

0 comments on commit 057ddb5

Please sign in to comment.