fix(crypto): fix ECIES invalid-curve handling #33669 (#2043)

Co-authored-by: fengjian <445077+fengjian@users.noreply.github.com>
This commit is contained in:
Daniel Liu 2026-02-28 21:00:35 +08:00 committed by GitHub
parent 2a96ecf87e
commit f11cf2cce7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -124,6 +124,9 @@ func (prv *PrivateKey) GenerateShared(pub *PublicKey, skLen, macLen int) (sk []b
if prv.PublicKey.Curve != pub.Curve {
return nil, ErrInvalidCurve
}
if pub.X == nil || pub.Y == nil || !pub.Curve.IsOnCurve(pub.X, pub.Y) {
return nil, ErrInvalidPublicKey
}
if skLen+macLen > MaxSharedKeyLength(pub) {
return nil, ErrSharedKeyTooBig
}