aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat
diff options
context:
space:
mode:
authorStanisław Pitucha <stanislaw.pitucha@hp.com>2015-08-14 18:16:48 +1000
committerStanisław Pitucha <stanislaw.pitucha@hp.com>2015-08-14 18:16:48 +1000
commiteafa4b1c5d5b9fe6981309349a0daa641a070ea7 (patch)
treee5d1ff4adb3f0f6849a95d646f3529d47a7c2875 /src/cryptography/hazmat
parent5e885db2e77b054a6597c1ddea4e7905b8350040 (diff)
downloadcryptography-eafa4b1c5d5b9fe6981309349a0daa641a070ea7.tar.gz
cryptography-eafa4b1c5d5b9fe6981309349a0daa641a070ea7.tar.bz2
cryptography-eafa4b1c5d5b9fe6981309349a0daa641a070ea7.zip
Move signature type checks
Move the point of checking signatures, as suggested by alex in PR 2262.
Diffstat (limited to 'src/cryptography/hazmat')
-rw-r--r--src/cryptography/hazmat/backends/openssl/dsa.py6
-rw-r--r--src/cryptography/hazmat/backends/openssl/ec.py5
-rw-r--r--src/cryptography/hazmat/backends/openssl/rsa.py6
3 files changed, 9 insertions, 8 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/dsa.py b/src/cryptography/hazmat/backends/openssl/dsa.py
index f1bb6d9b..ec056767 100644
--- a/src/cryptography/hazmat/backends/openssl/dsa.py
+++ b/src/cryptography/hazmat/backends/openssl/dsa.py
@@ -29,9 +29,6 @@ def _truncate_digest_for_dsa(dsa_cdata, digest, backend):
@utils.register_interface(AsymmetricVerificationContext)
class _DSAVerificationContext(object):
def __init__(self, backend, public_key, signature, algorithm):
- if not isinstance(signature, bytes):
- raise TypeError("signature must be bytes.")
-
self._backend = backend
self._public_key = public_key
self._signature = signature
@@ -179,6 +176,9 @@ class _DSAPublicKey(object):
key_size = utils.read_only_property("_key_size")
def verifier(self, signature, signature_algorithm):
+ if not isinstance(signature, bytes):
+ raise TypeError("signature must be bytes.")
+
return _DSAVerificationContext(
self._backend, self, signature, signature_algorithm
)
diff --git a/src/cryptography/hazmat/backends/openssl/ec.py b/src/cryptography/hazmat/backends/openssl/ec.py
index b8692e49..6764416d 100644
--- a/src/cryptography/hazmat/backends/openssl/ec.py
+++ b/src/cryptography/hazmat/backends/openssl/ec.py
@@ -119,8 +119,6 @@ class _ECDSASignatureContext(object):
@utils.register_interface(AsymmetricVerificationContext)
class _ECDSAVerificationContext(object):
def __init__(self, backend, public_key, signature, algorithm):
- if not isinstance(signature, bytes):
- raise TypeError("signature must be bytes.")
self._backend = backend
self._public_key = public_key
self._signature = signature
@@ -227,6 +225,9 @@ class _EllipticCurvePublicKey(object):
curve = utils.read_only_property("_curve")
def verifier(self, signature, signature_algorithm):
+ if not isinstance(signature, bytes):
+ raise TypeError("signature must be bytes.")
+
if isinstance(signature_algorithm, ec.ECDSA):
return _ECDSAVerificationContext(
self._backend, self, signature, signature_algorithm.algorithm
diff --git a/src/cryptography/hazmat/backends/openssl/rsa.py b/src/cryptography/hazmat/backends/openssl/rsa.py
index 8e32eb02..7da42292 100644
--- a/src/cryptography/hazmat/backends/openssl/rsa.py
+++ b/src/cryptography/hazmat/backends/openssl/rsa.py
@@ -337,9 +337,6 @@ class _RSASignatureContext(object):
@utils.register_interface(AsymmetricVerificationContext)
class _RSAVerificationContext(object):
def __init__(self, backend, public_key, signature, padding, algorithm):
- if not isinstance(signature, bytes):
- raise TypeError("signature must be bytes.")
-
self._backend = backend
self._public_key = public_key
self._signature = signature
@@ -578,6 +575,9 @@ class _RSAPublicKey(object):
key_size = utils.read_only_property("_key_size")
def verifier(self, signature, padding, algorithm):
+ if not isinstance(signature, bytes):
+ raise TypeError("signature must be bytes.")
+
return _RSAVerificationContext(
self._backend, self, signature, padding, algorithm
)