aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-12-06 23:17:23 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-12-06 23:17:23 -0600
commit73251faf2cb043dc9795b46c98c7084482d2aed2 (patch)
tree3ba6a0affac68bdb282742d8cc22e3ef40cb90c8 /src
parentd5fe4ba989f1c8ff5494fee3f6404a14456eac8d (diff)
downloadcryptography-73251faf2cb043dc9795b46c98c7084482d2aed2.tar.gz
cryptography-73251faf2cb043dc9795b46c98c7084482d2aed2.tar.bz2
cryptography-73251faf2cb043dc9795b46c98c7084482d2aed2.zip
catch PyAsn1Error when decoding rfc6979 signature
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/utils.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cryptography/hazmat/primitives/asymmetric/utils.py b/src/cryptography/hazmat/primitives/asymmetric/utils.py
index 36b9080d..08bb40c7 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/utils.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/utils.py
@@ -5,6 +5,7 @@
from __future__ import absolute_import, division, print_function
from pyasn1.codec.der import decoder, encoder
+from pyasn1.error import PyAsn1Error
from pyasn1.type import namedtype, univ
@@ -16,7 +17,11 @@ class _DSSSigValue(univ.Sequence):
def decode_rfc6979_signature(signature):
- data, remaining = decoder.decode(signature, asn1Spec=_DSSSigValue())
+ try:
+ data, remaining = decoder.decode(signature, asn1Spec=_DSSSigValue())
+ except PyAsn1Error:
+ raise ValueError("Invalid signature data. Unable to decode ASN.1")
+
if remaining:
raise ValueError(
"The signature contains bytes after the end of the ASN.1 sequence."