Merge pull request #13382 from ahrtr/public_key_match_issue

The public key doesn't match if any field doesn't match
This commit is contained in:
Piotr Tabor 2022-01-15 17:14:02 +01:00 committed by GitHub
commit b8c5d44a1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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