Skip to content

Commit 645a404

Browse files
committed
Use what's already there in the class init.
1 parent bf47439 commit 645a404

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/cryptojwt/jwk/jwk.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from cryptography.hazmat.primitives.asymmetric.rsa import rsa_crt_dmq1
88
from cryptography.hazmat.primitives.asymmetric.rsa import rsa_crt_iqmp
99

10+
from ..exception import MissingValue
1011
from ..exception import WrongKeyType
1112
from ..exception import UnknownKeyType
1213
from ..exception import UnsupportedAlgorithm
@@ -86,10 +87,10 @@ def key_from_jwk_dict(jwk_dict):
8687
'kty']))
8788
return RSAKey(**_jwk_dict)
8889
elif _jwk_dict['kty'] == 'oct':
89-
if isinstance(_jwk_dict['k'], bytes):
90-
_jwk_dict['key'] = b64d(_jwk_dict["k"])
91-
else:
92-
_jwk_dict['key'] = b64d(as_bytes(_jwk_dict["k"]))
90+
if not 'key' in _jwk_dict and not 'k' in _jwk_dict:
91+
raise MissingValue(
92+
'There has to be one of "k" or "key" in a symmetric key')
93+
9394
return SYMKey(**_jwk_dict)
9495
else:
9596
raise UnknownKeyType

0 commit comments

Comments
 (0)