aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Stapleton <alexs@prol.etari.at>2014-04-01 12:02:02 +0100
committerAlex Stapleton <alexs@prol.etari.at>2014-04-01 12:11:08 +0100
commit621635712962267e589b19fb2292a764e5ad71de (patch)
tree2a05ae3b20bd56ed968e105ba0e45a72e79d372d
parent476682af2d4a9438026e69b6c1f3500c19f2f200 (diff)
downloadcryptography-621635712962267e589b19fb2292a764e5ad71de.tar.gz
cryptography-621635712962267e589b19fb2292a764e5ad71de.tar.bz2
cryptography-621635712962267e589b19fb2292a764e5ad71de.zip
Add _Reasons.UNSUPPORTED_MGF
-rw-r--r--cryptography/exceptions.py1
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py6
-rw-r--r--tests/hazmat/primitives/test_rsa.py4
3 files changed, 7 insertions, 4 deletions
diff --git a/cryptography/exceptions.py b/cryptography/exceptions.py
index 4b4d4c37..d2782be6 100644
--- a/cryptography/exceptions.py
+++ b/cryptography/exceptions.py
@@ -19,6 +19,7 @@ class _Reasons(object):
UNSUPPORTED_HASH = object()
UNSUPPORTED_CIPHER = object()
UNSUPPORTED_PADDING = object()
+ UNSUPPORTED_MGF = object()
class UnsupportedAlgorithm(Exception):
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py
index 753717d4..3293741c 100644
--- a/cryptography/hazmat/backends/openssl/backend.py
+++ b/cryptography/hazmat/backends/openssl/backend.py
@@ -731,7 +731,8 @@ class _RSASignatureContext(object):
elif isinstance(padding, PSS):
if not isinstance(padding._mgf, MGF1):
raise UnsupportedAlgorithm(
- "Only MGF1 is supported by this backend"
+ "Only MGF1 is supported by this backend",
+ _Reasons.UNSUPPORTED_MGF
)
# Size of key in bytes - 2 is the maximum
@@ -915,7 +916,8 @@ class _RSAVerificationContext(object):
elif isinstance(padding, PSS):
if not isinstance(padding._mgf, MGF1):
raise UnsupportedAlgorithm(
- "Only MGF1 is supported by this backend"
+ "Only MGF1 is supported by this backend",
+ _Reasons.UNSUPPORTED_MGF
)
# Size of key in bytes - 2 is the maximum
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py
index 5d94e790..32f54945 100644
--- a/tests/hazmat/primitives/test_rsa.py
+++ b/tests/hazmat/primitives/test_rsa.py
@@ -630,7 +630,7 @@ class TestRSASignature(object):
key_size=512,
backend=backend
)
- with pytest.raises(UnsupportedAlgorithm):
+ with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_MGF):
private_key.signer(padding.PSS(mgf=DummyMGF()), hashes.SHA1(),
backend)
@@ -881,7 +881,7 @@ class TestRSAVerification(object):
backend=backend
)
public_key = private_key.public_key()
- with pytest.raises(UnsupportedAlgorithm):
+ with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_MGF):
public_key.verifier(b"sig", padding.PSS(mgf=DummyMGF()),
hashes.SHA1(), backend)