summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2016-04-23 13:47:39 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2016-04-23 13:47:39 -0400
commit57c1635bc8ce3445122a28b6bc00b19b3e7ef57a (patch)
treec898d87ca050564d2eba100cc7fc136918adb357
parentf133db64b23649111c7d485825b9f45d7f3f07a5 (diff)
handle invalid keys in ecdsa
-rw-r--r--paramiko/ecdsakey.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/paramiko/ecdsakey.py b/paramiko/ecdsakey.py
index eed9e68d..9635c49c 100644
--- a/paramiko/ecdsakey.py
+++ b/paramiko/ecdsakey.py
@@ -134,7 +134,9 @@ class ECDSAKey(PKey):
sigR, sigS = self._sigdecode(sig)
signature = encode_rfc6979_signature(sigR, sigS)
- verifier = self.verifying_key.verifier(signature, ec.ECDSA(hashes.SHA256()))
+ verifier = self.verifying_key.verifier(
+ signature, ec.ECDSA(hashes.SHA256())
+ )
verifier.update(data)
try:
verifier.verify()
@@ -185,7 +187,13 @@ class ECDSAKey(PKey):
byte_chr(5) * 5, byte_chr(6) * 6, byte_chr(7) * 7]
def _decode_key(self, data):
- key = serialization.load_der_private_key(data, password=None, backend=default_backend())
+ try:
+ key = serialization.load_der_private_key(
+ data, password=None, backend=default_backend()
+ )
+ except ValueError as e:
+ raise SSHException(str(e))
+
self.signing_key = key
self.verifying_key = key.public_key()
self.size = key.curve.key_size