From 73278747b04c3bfca3972d69a917c194db6c24e3 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 12 Nov 2013 14:27:19 -0800 Subject: Drop random support for weird inheritance --- cryptography/hazmat/bindings/openssl/backend.py | 3 --- cryptography/hazmat/primitives/ciphers/algorithms.py | 6 ------ cryptography/hazmat/primitives/ciphers/base.py | 2 -- cryptography/hazmat/primitives/ciphers/modes.py | 4 ---- cryptography/hazmat/primitives/hashes.py | 5 +++-- cryptography/hazmat/primitives/hmac.py | 9 ++++++--- cryptography/hazmat/primitives/padding.py | 3 --- 7 files changed, 9 insertions(+), 23 deletions(-) diff --git a/cryptography/hazmat/bindings/openssl/backend.py b/cryptography/hazmat/bindings/openssl/backend.py index 235a8e30..b65583df 100644 --- a/cryptography/hazmat/bindings/openssl/backend.py +++ b/cryptography/hazmat/bindings/openssl/backend.py @@ -207,7 +207,6 @@ class _CipherContext(object): class Ciphers(object): def __init__(self, backend): - super(Ciphers, self).__init__() self._backend = backend self._cipher_registry = {} self._register_default_ciphers() @@ -314,7 +313,6 @@ class _HashContext(object): class Hashes(object): def __init__(self, backend): - super(Hashes, self).__init__() self._backend = backend def supported(self, algorithm): @@ -329,7 +327,6 @@ class Hashes(object): 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 cbfaceb8..32acab14 100644 --- a/cryptography/hazmat/primitives/ciphers/algorithms.py +++ b/cryptography/hazmat/primitives/ciphers/algorithms.py @@ -20,7 +20,6 @@ class AES(object): 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 @@ class Camellia(object): 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 @@ class TripleDES(object): 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 @@ class Blowfish(object): 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 @@ class CAST5(object): 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 @@ -123,7 +118,6 @@ class ARC4(object): 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 1599308c..d48f9cc7 100644 --- a/cryptography/hazmat/primitives/ciphers/base.py +++ b/cryptography/hazmat/primitives/ciphers/base.py @@ -18,8 +18,6 @@ from cryptography.hazmat.primitives import interfaces 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 e54872a6..915fd83d 100644 --- a/cryptography/hazmat/primitives/ciphers/modes.py +++ b/cryptography/hazmat/primitives/ciphers/modes.py @@ -22,7 +22,6 @@ class CBC(object): name = "CBC" def __init__(self, initialization_vector): - super(CBC, self).__init__() self.initialization_vector = initialization_vector @@ -37,7 +36,6 @@ class OFB(object): name = "OFB" def __init__(self, initialization_vector): - super(OFB, self).__init__() self.initialization_vector = initialization_vector @@ -47,7 +45,6 @@ class CFB(object): name = "CFB" def __init__(self, initialization_vector): - super(CFB, self).__init__() self.initialization_vector = initialization_vector @@ -57,5 +54,4 @@ class CTR(object): 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 c14d0437..6ae622cd 100644 --- a/cryptography/hazmat/primitives/hashes.py +++ b/cryptography/hazmat/primitives/hashes.py @@ -42,8 +42,9 @@ class Hash(object): 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 1457ed78..ed2dd54a 100644 --- a/cryptography/hazmat/primitives/hmac.py +++ b/cryptography/hazmat/primitives/hmac.py @@ -21,7 +21,6 @@ from cryptography.hazmat.primitives import interfaces @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 @@ class HMAC(object): 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 eac18c2a..f41c62c3 100644 --- a/cryptography/hazmat/primitives/padding.py +++ b/cryptography/hazmat/primitives/padding.py @@ -18,7 +18,6 @@ from cryptography.hazmat.primitives import interfaces 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 @@ class PKCS7(object): @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 @@ class _PKCS7PaddingContext(object): @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) -- cgit v1.2.3