aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-03-06 14:22:56 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2014-03-06 14:22:56 -0800
commitc6a6f317fca2aa368943870ecc3854bb53399f06 (patch)
tree6c975bf178f47d504da5edbce3233ca54a89d82d /cryptography
parent8b347932fb3612e622d07643af62ed939976b9cb (diff)
downloadcryptography-c6a6f317fca2aa368943870ecc3854bb53399f06.tar.gz
cryptography-c6a6f317fca2aa368943870ecc3854bb53399f06.tar.bz2
cryptography-c6a6f317fca2aa368943870ecc3854bb53399f06.zip
Convert stuff
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/backends/multibackend.py24
-rw-r--r--cryptography/hazmat/primitives/kdf/pbkdf2.py4
2 files changed, 15 insertions, 13 deletions
diff --git a/cryptography/hazmat/backends/multibackend.py b/cryptography/hazmat/backends/multibackend.py
index de1fff7c..cca82a59 100644
--- a/cryptography/hazmat/backends/multibackend.py
+++ b/cryptography/hazmat/backends/multibackend.py
@@ -14,7 +14,9 @@
from __future__ import absolute_import, division, print_function
from cryptography import utils
-from cryptography.exceptions import UnsupportedAlgorithm
+from cryptography.exceptions import (
+ UnsupportedAlgorithm, UnsupportedCipher, UnsupportedHash
+)
from cryptography.hazmat.backends.interfaces import (
CipherBackend, HashBackend, HMACBackend, PBKDF2HMACBackend, RSABackend
)
@@ -46,17 +48,17 @@ class MultiBackend(object):
for b in self._filtered_backends(CipherBackend):
try:
return b.create_symmetric_encryption_ctx(algorithm, mode)
- except UnsupportedAlgorithm:
+ except UnsupportedCipher:
pass
- raise UnsupportedAlgorithm
+ raise UnsupportedCipher
def create_symmetric_decryption_ctx(self, algorithm, mode):
for b in self._filtered_backends(CipherBackend):
try:
return b.create_symmetric_decryption_ctx(algorithm, mode)
- except UnsupportedAlgorithm:
+ except UnsupportedCipher:
pass
- raise UnsupportedAlgorithm
+ raise UnsupportedCipher
def hash_supported(self, algorithm):
return any(
@@ -68,9 +70,9 @@ class MultiBackend(object):
for b in self._filtered_backends(HashBackend):
try:
return b.create_hash_ctx(algorithm)
- except UnsupportedAlgorithm:
+ except UnsupportedHash:
pass
- raise UnsupportedAlgorithm
+ raise UnsupportedHash
def hmac_supported(self, algorithm):
return any(
@@ -82,9 +84,9 @@ class MultiBackend(object):
for b in self._filtered_backends(HMACBackend):
try:
return b.create_hmac_ctx(key, algorithm)
- except UnsupportedAlgorithm:
+ except UnsupportedHash:
pass
- raise UnsupportedAlgorithm
+ raise UnsupportedHash
def pbkdf2_hmac_supported(self, algorithm):
return any(
@@ -99,9 +101,9 @@ class MultiBackend(object):
return b.derive_pbkdf2_hmac(
algorithm, length, salt, iterations, key_material
)
- except UnsupportedAlgorithm:
+ except UnsupportedHash:
pass
- raise UnsupportedAlgorithm
+ raise UnsupportedHash
def generate_rsa_private_key(self, public_exponent, key_size):
for b in self._filtered_backends(RSABackend):
diff --git a/cryptography/hazmat/primitives/kdf/pbkdf2.py b/cryptography/hazmat/primitives/kdf/pbkdf2.py
index 71b88211..39427780 100644
--- a/cryptography/hazmat/primitives/kdf/pbkdf2.py
+++ b/cryptography/hazmat/primitives/kdf/pbkdf2.py
@@ -17,7 +17,7 @@ import six
from cryptography import utils
from cryptography.exceptions import (
- InvalidKey, UnsupportedAlgorithm, AlreadyFinalized
+ InvalidKey, UnsupportedHash, AlreadyFinalized
)
from cryptography.hazmat.primitives import constant_time, interfaces
@@ -26,7 +26,7 @@ from cryptography.hazmat.primitives import constant_time, interfaces
class PBKDF2HMAC(object):
def __init__(self, algorithm, length, salt, iterations, backend):
if not backend.pbkdf2_hmac_supported(algorithm):
- raise UnsupportedAlgorithm(
+ raise UnsupportedHash(
"{0} is not supported for PBKDF2 by this backend".format(
algorithm.name)
)