diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-04-01 10:12:53 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-04-01 10:12:53 -0500 |
commit | 550f1739d88e8a40a905797544af21dd83bec477 (patch) | |
tree | eef1cab9a29231664c8c2aa189792bc8ee3dd703 /cryptography | |
parent | 476682af2d4a9438026e69b6c1f3500c19f2f200 (diff) | |
parent | df16f4a573d0d9a81236818c79032f4c12ffec00 (diff) | |
download | cryptography-550f1739d88e8a40a905797544af21dd83bec477.tar.gz cryptography-550f1739d88e8a40a905797544af21dd83bec477.tar.bz2 cryptography-550f1739d88e8a40a905797544af21dd83bec477.zip |
Merge pull request #876 from public/unsupported-algorithm-asym-tags
Extra UnsupportedAlgorithm reason tags
Diffstat (limited to 'cryptography')
-rw-r--r-- | cryptography/exceptions.py | 2 | ||||
-rw-r--r-- | cryptography/hazmat/backends/multibackend.py | 9 | ||||
-rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 6 |
3 files changed, 12 insertions, 5 deletions
diff --git a/cryptography/exceptions.py b/cryptography/exceptions.py index 4b4d4c37..b4ee8feb 100644 --- a/cryptography/exceptions.py +++ b/cryptography/exceptions.py @@ -19,6 +19,8 @@ class _Reasons(object): UNSUPPORTED_HASH = object() UNSUPPORTED_CIPHER = object() UNSUPPORTED_PADDING = object() + UNSUPPORTED_MGF = object() + UNSUPPORTED_PUBLIC_KEY_ALGORITHM = object() class UnsupportedAlgorithm(Exception): diff --git a/cryptography/hazmat/backends/multibackend.py b/cryptography/hazmat/backends/multibackend.py index 2a1ec439..aa649dd3 100644 --- a/cryptography/hazmat/backends/multibackend.py +++ b/cryptography/hazmat/backends/multibackend.py @@ -126,16 +126,19 @@ class MultiBackend(object): def generate_rsa_private_key(self, public_exponent, key_size): for b in self._filtered_backends(RSABackend): return b.generate_rsa_private_key(public_exponent, key_size) - raise UnsupportedAlgorithm("RSA is not supported by the backend") + raise UnsupportedAlgorithm("RSA is not supported by the backend", + _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM) def create_rsa_signature_ctx(self, private_key, padding, algorithm): for b in self._filtered_backends(RSABackend): return b.create_rsa_signature_ctx(private_key, padding, algorithm) - raise UnsupportedAlgorithm("RSA is not supported by the backend") + raise UnsupportedAlgorithm("RSA is not supported by the backend", + _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM) def create_rsa_verification_ctx(self, public_key, signature, padding, algorithm): for b in self._filtered_backends(RSABackend): return b.create_rsa_verification_ctx(public_key, signature, padding, algorithm) - raise UnsupportedAlgorithm("RSA is not supported by the backend") + raise UnsupportedAlgorithm("RSA is not supported by the backend", + _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM) 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 |