From db6ff2a1c195be12f274b8e027a94358254cafe9 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 30 Nov 2021 14:54:49 -0500 Subject: [PATCH] Add P-256K alias for secp256k1 Resolves #241 Signed-off-by: Simo Sorce --- jwcrypto/jwk.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jwcrypto/jwk.py b/jwcrypto/jwk.py index c5f36a7..977bd62 100644 --- a/jwcrypto/jwk.py +++ b/jwcrypto/jwk.py @@ -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): @@ -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