correct the public key comparison logic

This commit is contained in:
ahrtr 2021-10-03 06:12:36 +08:00
parent e2273f94c4
commit 63ff6d403d

View File

@ -145,7 +145,7 @@ func (opts *jwtOptions) rsaKey() (interface{}, error) {
} }
// both keys provided, make sure they match // both keys provided, make sure they match
if pub != nil && pub.E != priv.E && pub.N.Cmp(priv.N) != 0 { if pub != nil && !pub.Equal(priv.Public()) {
return nil, ErrKeyMismatch return nil, ErrKeyMismatch
} }
@ -183,8 +183,7 @@ func (opts *jwtOptions) ecKey() (interface{}, error) {
} }
// both keys provided, make sure they match // both keys provided, make sure they match
if pub != nil && pub.Curve != priv.Curve && if pub != nil && !pub.Equal(priv.Public()) {
pub.X.Cmp(priv.X) != 0 && pub.Y.Cmp(priv.Y) != 0 {
return nil, ErrKeyMismatch return nil, ErrKeyMismatch
} }