Merge pull request #251 from alex/dont-query-openssl
Don't query OpenSSL for block sizes, we already know them
diff --git a/cryptography/hazmat/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py
index 89ee2b5..71b94ab 100644
--- a/cryptography/hazmat/bindings/openssl/backend.py
+++ b/cryptography/hazmat/bindings/openssl/backend.py
@@ -206,7 +206,6 @@
class Ciphers(object):
def __init__(self, backend):
- super(Ciphers, self).__init__()
self._backend = backend
self._cipher_registry = {}
self._register_default_ciphers()
@@ -313,7 +312,6 @@
class Hashes(object):
def __init__(self, backend):
- super(Hashes, self).__init__()
self._backend = backend
def supported(self, algorithm):
@@ -328,7 +326,6 @@
class HMACs(object):
def __init__(self, backend):
- super(HMACs, self).__init__()
self._backend = backend
def create_ctx(self, key, hash_cls):
diff --git a/cryptography/hazmat/primitives/ciphers/algorithms.py b/cryptography/hazmat/primitives/ciphers/algorithms.py
index 61e93b0..c135f56 100644
--- a/cryptography/hazmat/primitives/ciphers/algorithms.py
+++ b/cryptography/hazmat/primitives/ciphers/algorithms.py
@@ -20,7 +20,6 @@
key_sizes = frozenset([128, 192, 256])
def __init__(self, key):
- super(AES, self).__init__()
self.key = key
# Verify that the key size matches the expected key size
@@ -40,7 +39,6 @@
key_sizes = frozenset([128, 192, 256])
def __init__(self, key):
- super(Camellia, self).__init__()
self.key = key
# Verify that the key size matches the expected key size
@@ -60,7 +58,6 @@
key_sizes = frozenset([64, 128, 192])
def __init__(self, key):
- super(TripleDES, self).__init__()
if len(key) == 8:
key += key + key
elif len(key) == 16:
@@ -84,7 +81,6 @@
key_sizes = frozenset(range(32, 449, 8))
def __init__(self, key):
- super(Blowfish, self).__init__()
self.key = key
# Verify that the key size matches the expected key size
@@ -104,7 +100,6 @@
key_sizes = frozenset([40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128])
def __init__(self, key):
- super(CAST5, self).__init__()
self.key = key
# Verify that the key size matches the expected key size
@@ -124,7 +119,6 @@
key_sizes = frozenset([40, 56, 64, 80, 128, 192, 256])
def __init__(self, key):
- super(ARC4, self).__init__()
self.key = key
# Verify that the key size matches the expected key size
diff --git a/cryptography/hazmat/primitives/ciphers/base.py b/cryptography/hazmat/primitives/ciphers/base.py
index 1599308..d48f9cc 100644
--- a/cryptography/hazmat/primitives/ciphers/base.py
+++ b/cryptography/hazmat/primitives/ciphers/base.py
@@ -18,8 +18,6 @@
class Cipher(object):
def __init__(self, algorithm, mode, backend=None):
- super(Cipher, self).__init__()
-
if backend is None:
from cryptography.hazmat.bindings import (
_default_backend as backend,
diff --git a/cryptography/hazmat/primitives/ciphers/modes.py b/cryptography/hazmat/primitives/ciphers/modes.py
index e54872a..915fd83 100644
--- a/cryptography/hazmat/primitives/ciphers/modes.py
+++ b/cryptography/hazmat/primitives/ciphers/modes.py
@@ -22,7 +22,6 @@
name = "CBC"
def __init__(self, initialization_vector):
- super(CBC, self).__init__()
self.initialization_vector = initialization_vector
@@ -37,7 +36,6 @@
name = "OFB"
def __init__(self, initialization_vector):
- super(OFB, self).__init__()
self.initialization_vector = initialization_vector
@@ -47,7 +45,6 @@
name = "CFB"
def __init__(self, initialization_vector):
- super(CFB, self).__init__()
self.initialization_vector = initialization_vector
@@ -57,5 +54,4 @@
name = "CTR"
def __init__(self, nonce):
- super(CTR, self).__init__()
self.nonce = nonce
diff --git a/cryptography/hazmat/primitives/hashes.py b/cryptography/hazmat/primitives/hashes.py
index c14d043..6ae622c 100644
--- a/cryptography/hazmat/primitives/hashes.py
+++ b/cryptography/hazmat/primitives/hashes.py
@@ -42,8 +42,9 @@
self._ctx.update(data)
def copy(self):
- return self.__class__(self.algorithm, backend=self._backend,
- ctx=self._ctx.copy())
+ return Hash(
+ self.algorithm, backend=self._backend, ctx=self._ctx.copy()
+ )
def finalize(self):
return self._ctx.finalize()
diff --git a/cryptography/hazmat/primitives/hmac.py b/cryptography/hazmat/primitives/hmac.py
index 1457ed7..ed2dd54 100644
--- a/cryptography/hazmat/primitives/hmac.py
+++ b/cryptography/hazmat/primitives/hmac.py
@@ -21,7 +21,6 @@
@interfaces.register(interfaces.HashContext)
class HMAC(object):
def __init__(self, key, algorithm, ctx=None, backend=None):
- super(HMAC, self).__init__()
if not isinstance(algorithm, interfaces.HashAlgorithm):
raise TypeError("Expected instance of interfaces.HashAlgorithm.")
self.algorithm = algorithm
@@ -43,8 +42,12 @@
self._backend.hmacs.update_ctx(self._ctx, msg)
def copy(self):
- return self.__class__(self._key, self.algorithm, backend=self._backend,
- ctx=self._backend.hmacs.copy_ctx(self._ctx))
+ return HMAC(
+ self._key,
+ self.algorithm,
+ backend=self._backend,
+ ctx=self._backend.hmacs.copy_ctx(self._ctx)
+ )
def finalize(self):
return self._backend.hmacs.finalize_ctx(self._ctx,
diff --git a/cryptography/hazmat/primitives/padding.py b/cryptography/hazmat/primitives/padding.py
index eac18c2..f41c62c 100644
--- a/cryptography/hazmat/primitives/padding.py
+++ b/cryptography/hazmat/primitives/padding.py
@@ -18,7 +18,6 @@
class PKCS7(object):
def __init__(self, block_size):
- super(PKCS7, self).__init__()
if not (0 <= block_size < 256):
raise ValueError("block_size must be in range(0, 256)")
@@ -37,7 +36,6 @@
@interfaces.register(interfaces.PaddingContext)
class _PKCS7PaddingContext(object):
def __init__(self, block_size):
- super(_PKCS7PaddingContext, self).__init__()
self.block_size = block_size
# TODO: O(n ** 2) complexity for repeated concatentation, we should use
# zero-buffer (#193)
@@ -72,7 +70,6 @@
@interfaces.register(interfaces.PaddingContext)
class _PKCS7UnpaddingContext(object):
def __init__(self, block_size):
- super(_PKCS7UnpaddingContext, self).__init__()
self.block_size = block_size
# TODO: O(n ** 2) complexity for repeated concatentation, we should use
# zero-buffer (#193)