diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2017-06-02 07:51:09 -1000 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2017-06-02 13:51:09 -0400 |
commit | 26fcc5c24d7ef7e905181ba044447ed15746c73b (patch) | |
tree | 00d9d9d22f28434f57dab94fa03bd357558d6db0 /src/cryptography/hazmat/backends/openssl/ec.py | |
parent | a7e9a22886418b43ecdebd4ea3b5acba5425e822 (diff) | |
download | cryptography-26fcc5c24d7ef7e905181ba044447ed15746c73b.tar.gz cryptography-26fcc5c24d7ef7e905181ba044447ed15746c73b.tar.bz2 cryptography-26fcc5c24d7ef7e905181ba044447ed15746c73b.zip |
make signature and verification contexts error better re: prehashed (#3658)
* make signature and verification contexts error better re: prehashed
* code review feedback
Diffstat (limited to 'src/cryptography/hazmat/backends/openssl/ec.py')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/ec.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/ec.py b/src/cryptography/hazmat/backends/openssl/ec.py index 3a81f919..b70735dc 100644 --- a/src/cryptography/hazmat/backends/openssl/ec.py +++ b/src/cryptography/hazmat/backends/openssl/ec.py @@ -9,7 +9,7 @@ from cryptography.exceptions import ( InvalidSignature, UnsupportedAlgorithm, _Reasons ) from cryptography.hazmat.backends.openssl.utils import ( - _calculate_digest_and_algorithm + _calculate_digest_and_algorithm, _check_not_prehashed ) from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric import ( @@ -141,6 +141,7 @@ class _EllipticCurvePrivateKey(object): def signer(self, signature_algorithm): _check_signature_algorithm(signature_algorithm) + _check_not_prehashed(signature_algorithm.algorithm) return _ECDSASignatureContext( self._backend, self, signature_algorithm.algorithm ) @@ -244,6 +245,7 @@ class _EllipticCurvePublicKey(object): raise TypeError("signature must be bytes.") _check_signature_algorithm(signature_algorithm) + _check_not_prehashed(signature_algorithm.algorithm) return _ECDSAVerificationContext( self._backend, self, signature, signature_algorithm.algorithm ) |