Skip to content

Commit

Permalink
Add P-256K alias for secp256k1
Browse files Browse the repository at this point in the history
Resolves #241

Signed-off-by: Simo Sorce <simo@redhat.com>
  • Loading branch information
simo5 committed Nov 30, 2021
1 parent 3ba7408 commit db6ff2a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions jwcrypto/jwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,13 @@ class ParmType(Enum):
'deriveBits': 'Derive bits not to be used as a key'}
"""Registry of allowed operations"""

# P-256K is an alias for 'secp256k1' to handle compatibility with some
# implementation using this old drafting name
JWKpycaCurveMap = {'secp256r1': 'P-256',
'secp384r1': 'P-384',
'secp521r1': 'P-521',
'secp256k1': 'secp256k1'}
'secp256k1': 'secp256k1',
'secp256k1': 'P-256K'}


class InvalidJWKType(JWException):
Expand Down Expand Up @@ -400,7 +403,7 @@ def _get_curve_by_name(self, name):
return ec.SECP384R1()
elif name == 'P-521':
return ec.SECP521R1()
elif name == 'secp256k1':
elif name == 'secp256k1' or name == 'P-256K':
return ec.SECP256K1()
elif name in _OKP_CURVES_TABLE:
return name
Expand Down

0 comments on commit db6ff2a

Please sign in to comment.