aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-03-17 17:40:06 -0400
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-03-17 17:40:06 -0400
commitc480f6e23fcc162057fb892c676ea61b691fce16 (patch)
tree25ca3fdd24ef46f5c766ed04298dc79619ee0eac
parent92e8ae835d543403279a416e16ae17f222de5d74 (diff)
downloadcryptography-c480f6e23fcc162057fb892c676ea61b691fce16.tar.gz
cryptography-c480f6e23fcc162057fb892c676ea61b691fce16.tar.bz2
cryptography-c480f6e23fcc162057fb892c676ea61b691fce16.zip
change exception and improve some language
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py12
-rw-r--r--tests/hazmat/primitives/test_rsa.py6
2 files changed, 12 insertions, 6 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py
index 6f024da5..9b8e8f0f 100644
--- a/cryptography/hazmat/backends/openssl/backend.py
+++ b/cryptography/hazmat/backends/openssl/backend.py
@@ -19,7 +19,7 @@ import itertools
from cryptography import utils
from cryptography.exceptions import (
InvalidTag, InternalError, AlreadyFinalized, UnsupportedCipher,
- UnsupportedHash, UnsupportedPadding, InvalidSignature
+ UnsupportedAlgorithm, UnsupportedHash, UnsupportedPadding, InvalidSignature
)
from cryptography.hazmat.backends.interfaces import (
CipherBackend, HashBackend, HMACBackend, PBKDF2HMACBackend, RSABackend
@@ -777,11 +777,15 @@ class _RSAVerificationContext(object):
self._verify_method = self._verify_pkcs1
elif isinstance(padding, PSS):
if not isinstance(padding._mgf, MGF1):
- raise TypeError("Only MGF1 is supported by this backend")
+ raise UnsupportedAlgorithm(
+ "Only MGF1 is supported by this backend"
+ )
if not self._backend.mgf1_hash_supported(padding._mgf._algorithm):
- raise UnsupportedHash("This backend only supports MGF1 with "
- "SHA1 when OpenSSL is not 1.0.1+")
+ raise UnsupportedHash(
+ "When OpenSSL is older than 1.0.1 then only SHA1 is "
+ "supported with MGF1."
+ )
if self._backend._lib.Cryptography_HAS_PKEY_CTX:
self._verify_method = self._verify_pkey_ctx
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py
index a09d6d66..955e69c9 100644
--- a/tests/hazmat/primitives/test_rsa.py
+++ b/tests/hazmat/primitives/test_rsa.py
@@ -21,7 +21,9 @@ import os
import pytest
from cryptography import exceptions, utils
-from cryptography.exceptions import UnsupportedInterface
+from cryptography.exceptions import (
+ UnsupportedAlgorithm, UnsupportedInterface
+)
from cryptography.hazmat.primitives import hashes, interfaces
from cryptography.hazmat.primitives.asymmetric import rsa, padding
@@ -713,7 +715,7 @@ class TestRSAVerification(object):
backend=backend
)
public_key = private_key.public_key()
- with pytest.raises(TypeError):
+ with pytest.raises(UnsupportedAlgorithm):
public_key.verifier(b"sig", padding.PSS(mgf=DummyMGF()),
hashes.SHA1(), backend)