mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 04:06:18 +08:00
pkcs7: fix error message
This commit is contained in:
parent
94e533ca15
commit
057ddb5bcb
@ -430,7 +430,7 @@ func signData(data []byte, pkey crypto.PrivateKey, hasher crypto.Hash, isDigestP
|
|||||||
if !isDigestProvided {
|
if !isDigestProvided {
|
||||||
opts = sm2.DefaultSM2SignerOpts
|
opts = sm2.DefaultSM2SignerOpts
|
||||||
} else if len(hash) != sm3.Size {
|
} 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) {
|
switch realKey := key.(type) {
|
||||||
case *ecdsa.PrivateKey:
|
case *ecdsa.PrivateKey:
|
||||||
@ -441,14 +441,14 @@ func signData(data []byte, pkey crypto.PrivateKey, hasher crypto.Hash, isDigestP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("pkcs7: unsupported hash function %s", hasher)
|
return nil, fmt.Errorf("pkcs7: unsupported hash function %v", hasher)
|
||||||
}
|
}
|
||||||
} else if !isDigestProvided {
|
} else if !isDigestProvided {
|
||||||
h := hasher.New()
|
h := hasher.New()
|
||||||
h.Write(data)
|
h.Write(data)
|
||||||
hash = h.Sum(nil)
|
hash = h.Sum(nil)
|
||||||
} else if len(hash) != hasher.Size() {
|
} 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)
|
return key.Sign(rand.Reader, hash, opts)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user