diff options
author | Alex Stapleton <alexs@prol.etari.at> | 2014-04-01 12:02:02 +0100 |
---|---|---|
committer | Alex Stapleton <alexs@prol.etari.at> | 2014-04-01 12:11:08 +0100 |
commit | 621635712962267e589b19fb2292a764e5ad71de (patch) | |
tree | 2a05ae3b20bd56ed968e105ba0e45a72e79d372d | |
parent | 476682af2d4a9438026e69b6c1f3500c19f2f200 (diff) | |
download | cryptography-621635712962267e589b19fb2292a764e5ad71de.tar.gz cryptography-621635712962267e589b19fb2292a764e5ad71de.tar.bz2 cryptography-621635712962267e589b19fb2292a764e5ad71de.zip |
Add _Reasons.UNSUPPORTED_MGF
-rw-r--r-- | cryptography/exceptions.py | 1 | ||||
-rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 6 | ||||
-rw-r--r-- | tests/hazmat/primitives/test_rsa.py | 4 |
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) |