From 057ddb5bcb009d50ee6249446ea8f214055a4f87 Mon Sep 17 00:00:00 2001 From: Sun Yimin Date: Wed, 15 Jan 2025 17:18:37 +0800 Subject: [PATCH] pkcs7: fix error message --- pkcs7/sign.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkcs7/sign.go b/pkcs7/sign.go index 5f5958e..388d282 100644 --- a/pkcs7/sign.go +++ b/pkcs7/sign.go @@ -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: @@ -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) }