crypto/ecies: correctly return ErrInvalidMessage (#35037)

This commit is contained in:
cui 2026-05-27 22:30:03 +08:00 committed by GitHub
parent 14820029c9
commit 9d21f6ebd5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -254,9 +254,12 @@ func Encrypt(rand io.Reader, pub *PublicKey, m, s1, s2 []byte) (ct []byte, err e
Ke, Km := deriveKeys(hash, z, s1, params.KeyLen)
em, err := symEncrypt(rand, params, Ke, m)
if err != nil || len(em) <= params.BlockSize {
if err != nil {
return nil, err
}
if len(em) <= params.BlockSize {
return nil, ErrInvalidMessage
}
d := messageTag(params.Hash, Km, em, s2)