Skip to content

Commit b41059f

Browse files
committed
Allow setting crv as argument when looking for a key.
1 parent 9f60ffe commit b41059f

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/cryptojwt/key_issuer.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,20 @@ def get(self, key_use, key_type="", kid=None, alg="", **kwargs):
323323
lst = [key for key in lst if not key.alg or key.alg == alg]
324324

325325
# if elliptic curve, have to check if I have a key of the right curve
326-
if key_type and key_type.upper() == "EC" and alg:
327-
name = "P-{}".format(alg[2:]) # the type
328-
_lst = []
329-
for key in lst:
330-
if name != key.crv:
331-
continue
332-
_lst.append(key)
333-
lst = _lst
334-
326+
if key_type and key_type.upper() == "EC":
327+
if alg:
328+
name = "P-{}".format(alg[2:]) # the type
329+
_lst = []
330+
for key in lst:
331+
if name != key.crv:
332+
continue
333+
_lst.append(key)
334+
lst = _lst
335+
else:
336+
_crv = kwargs.get('crv')
337+
if _crv:
338+
_lst = [k for k in lst if k.crv == _crv]
339+
lst = _lst
335340
return lst
336341

337342
def copy(self):

0 commit comments

Comments
 (0)