Skip to content

Commit 71e6cf0

Browse files
committed
Translate errors raised by cryptography when signing with EC to JWKErrors.
This is to mirror the behavior of the PyCrypto backend.
1 parent 59fef68 commit 71e6cf0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

jose/backends/cryptography_backend.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,15 @@ def _process_jwk(self, jwk_dict):
249249
return private.private_key(self.cryptography_backend())
250250

251251
def sign(self, msg):
252-
signer = self.prepared_key.signer(
253-
padding.PKCS1v15(),
254-
self.hash_alg()
255-
)
256-
signer.update(msg)
257-
signature = signer.finalize()
252+
try:
253+
signer = self.prepared_key.signer(
254+
padding.PKCS1v15(),
255+
self.hash_alg()
256+
)
257+
signer.update(msg)
258+
signature = signer.finalize()
259+
except Exception as e:
260+
raise JWKError(e)
258261
return signature
259262

260263
def verify(self, msg, sig):

0 commit comments

Comments
 (0)