Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/cryptojwt/jwk/ec.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,20 @@ def __eq__(self, other):
if self.__class__ != other.__class__:
return False

if self.use and other.use:
if self.use != other.use:
return False

if self.kid:
if other.kid:
if self.kid != other.kid:
return False
else:
return False
else:
if other.kid:
return False

if cmp_keys(self.pub_key, other.pub_key, ec.EllipticCurvePublicKey):
if other.private_key():
if cmp_keys(self.priv_key, other.priv_key, ec.EllipticCurvePrivateKey):
Expand Down
16 changes: 16 additions & 0 deletions tests/test_02_jwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ def test_cmp_eq_ec():
assert _key1 == _key2


def test_cmp_eq_ec_kid():
ec_key = new_ec_key("P-256")
_key1 = ECKey(priv_key=ec_key.priv_key, kid="foo")
_key2 = ECKey(priv_key=ec_key.priv_key, kid="bar")

assert _key1 != _key2


def test_cmp_eq_rsa_kid():
rsa_key = new_rsa_key()
_key1 = RSAKey(priv_key=rsa_key.priv_key, kid="foo")
_key2 = RSAKey(priv_key=rsa_key.priv_key, kid="bar")

assert _key1 != _key2


def test_get_key():
ec_key = new_ec_key("P-256")
asym_private_key = ECKey(priv_key=ec_key.priv_key)
Expand Down