summaryrefslogtreecommitdiff
path: root/jwt/algorithms.py
diff options
context:
space:
mode:
Diffstat (limited to 'jwt/algorithms.py')
-rw-r--r--jwt/algorithms.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/jwt/algorithms.py b/jwt/algorithms.py
index 1f8865a..739df80 100644
--- a/jwt/algorithms.py
+++ b/jwt/algorithms.py
@@ -417,6 +417,12 @@ if has_crypto:
except ValueError:
key = load_pem_private_key(key, password=None)
+ # Explicit check the key to prevent confusing errors from cryptography
+ if not isinstance(key, (EllipticCurvePrivateKey, EllipticCurvePublicKey)):
+ raise InvalidKeyError(
+ "Expecting a EllipticCurvePrivateKey/EllipticCurvePublicKey. Wrong key provided for ECDSA algorithms"
+ )
+
return key
def sign(self, msg, key):