diff options
author | Donald Stufft <donald@stufft.io> | 2014-05-17 15:59:16 -0400 |
---|---|---|
committer | Donald Stufft <donald@stufft.io> | 2014-05-17 15:59:16 -0400 |
commit | b6d8f7b95f4db772794a4f908a2156e34edd8332 (patch) | |
tree | f15f52d1403f158c26ff0951748e98f9c0781192 | |
parent | a741aad3bd7d6347b9816025cb4905558c2c71c6 (diff) | |
parent | 3b39ae4fc80020bba3d0c2888aa9c250b46e7071 (diff) | |
download | cryptography-b6d8f7b95f4db772794a4f908a2156e34edd8332.tar.gz cryptography-b6d8f7b95f4db772794a4f908a2156e34edd8332.tar.bz2 cryptography-b6d8f7b95f4db772794a4f908a2156e34edd8332.zip |
Merge pull request #1051 from alex/bytes-is-bytes
We don't need six.binary_type, it's always bytes
-rw-r--r-- | cryptography/fernet.py | 4 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/cmac.py | 6 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/constant_time.py | 5 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/hashes.py | 4 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/hmac.py | 6 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/kdf/hkdf.py | 8 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/kdf/pbkdf2.py | 6 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/padding.py | 4 |
8 files changed, 16 insertions, 27 deletions
diff --git a/cryptography/fernet.py b/cryptography/fernet.py index 93eb32bd..86920b48 100644 --- a/cryptography/fernet.py +++ b/cryptography/fernet.py @@ -60,7 +60,7 @@ class Fernet(object): return self._encrypt_from_parts(data, current_time, iv) def _encrypt_from_parts(self, data, current_time, iv): - if not isinstance(data, six.binary_type): + if not isinstance(data, bytes): raise TypeError("data must be bytes") padder = padding.PKCS7(algorithms.AES.block_size).padder() @@ -80,7 +80,7 @@ class Fernet(object): return base64.urlsafe_b64encode(basic_parts + hmac) def decrypt(self, token, ttl=None): - if not isinstance(token, six.binary_type): + if not isinstance(token, bytes): raise TypeError("token must be bytes") current_time = int(time.time()) diff --git a/cryptography/hazmat/primitives/cmac.py b/cryptography/hazmat/primitives/cmac.py index b01c5170..7f7cc0f0 100644 --- a/cryptography/hazmat/primitives/cmac.py +++ b/cryptography/hazmat/primitives/cmac.py @@ -13,8 +13,6 @@ from __future__ import absolute_import, division, print_function -import six - from cryptography import utils from cryptography.exceptions import ( AlreadyFinalized, InvalidSignature, UnsupportedAlgorithm, _Reasons @@ -47,7 +45,7 @@ class CMAC(object): def update(self, data): if self._ctx is None: raise AlreadyFinalized("Context was already finalized") - if not isinstance(data, six.binary_type): + if not isinstance(data, bytes): raise TypeError("data must be bytes") self._ctx.update(data) @@ -59,7 +57,7 @@ class CMAC(object): return digest def verify(self, signature): - if not isinstance(signature, six.binary_type): + if not isinstance(signature, bytes): raise TypeError("signature must be bytes") digest = self.finalize() if not constant_time.bytes_eq(digest, signature): diff --git a/cryptography/hazmat/primitives/constant_time.py b/cryptography/hazmat/primitives/constant_time.py index 6d325a9d..7172741a 100644 --- a/cryptography/hazmat/primitives/constant_time.py +++ b/cryptography/hazmat/primitives/constant_time.py @@ -17,8 +17,6 @@ import sys import cffi -import six - from cryptography.hazmat.bindings.utils import _create_modulename TYPES = """ @@ -57,8 +55,7 @@ _lib = _ffi.verify( def bytes_eq(a, b): - if (not isinstance(a, six.binary_type) or - not isinstance(b, six.binary_type)): + if not isinstance(a, bytes) or not isinstance(b, bytes): raise TypeError("a and b must be bytes") return _lib.Cryptography_constant_time_bytes_eq(a, len(a), b, len(b)) == 1 diff --git a/cryptography/hazmat/primitives/hashes.py b/cryptography/hazmat/primitives/hashes.py index 2efd8484..4e6d2fb1 100644 --- a/cryptography/hazmat/primitives/hashes.py +++ b/cryptography/hazmat/primitives/hashes.py @@ -13,8 +13,6 @@ from __future__ import absolute_import, division, print_function -import six - from cryptography import utils from cryptography.exceptions import ( AlreadyFinalized, UnsupportedAlgorithm, _Reasons @@ -46,7 +44,7 @@ class Hash(object): def update(self, data): if self._ctx is None: raise AlreadyFinalized("Context was already finalized") - if not isinstance(data, six.binary_type): + if not isinstance(data, bytes): raise TypeError("data must be bytes") self._ctx.update(data) diff --git a/cryptography/hazmat/primitives/hmac.py b/cryptography/hazmat/primitives/hmac.py index 5d7bad59..0f89df94 100644 --- a/cryptography/hazmat/primitives/hmac.py +++ b/cryptography/hazmat/primitives/hmac.py @@ -13,8 +13,6 @@ from __future__ import absolute_import, division, print_function -import six - from cryptography import utils from cryptography.exceptions import ( AlreadyFinalized, InvalidSignature, UnsupportedAlgorithm, _Reasons @@ -46,7 +44,7 @@ class HMAC(object): def update(self, msg): if self._ctx is None: raise AlreadyFinalized("Context was already finalized") - if not isinstance(msg, six.binary_type): + if not isinstance(msg, bytes): raise TypeError("msg must be bytes") self._ctx.update(msg) @@ -68,7 +66,7 @@ class HMAC(object): return digest def verify(self, signature): - if not isinstance(signature, six.binary_type): + if not isinstance(signature, bytes): raise TypeError("signature must be bytes") digest = self.finalize() if not constant_time.bytes_eq(digest, signature): diff --git a/cryptography/hazmat/primitives/kdf/hkdf.py b/cryptography/hazmat/primitives/kdf/hkdf.py index adeecaff..d329cb61 100644 --- a/cryptography/hazmat/primitives/kdf/hkdf.py +++ b/cryptography/hazmat/primitives/kdf/hkdf.py @@ -34,7 +34,7 @@ class HKDF(object): self._algorithm = algorithm - if not isinstance(salt, six.binary_type) and salt is not None: + if not isinstance(salt, bytes) and salt is not None: raise TypeError("salt must be bytes") if salt is None: @@ -52,7 +52,7 @@ class HKDF(object): return h.finalize() def derive(self, key_material): - if not isinstance(key_material, six.binary_type): + if not isinstance(key_material, bytes): raise TypeError("key_material must be bytes") return self._hkdf_expand.derive(self._extract(key_material)) @@ -85,7 +85,7 @@ class HKDFExpand(object): self._length = length - if not isinstance(info, six.binary_type) and info is not None: + if not isinstance(info, bytes) and info is not None: raise TypeError("info must be bytes") if info is None: @@ -110,7 +110,7 @@ class HKDFExpand(object): return b"".join(output)[:self._length] def derive(self, key_material): - if not isinstance(key_material, six.binary_type): + if not isinstance(key_material, bytes): raise TypeError("key_material must be bytes") if self._used: diff --git a/cryptography/hazmat/primitives/kdf/pbkdf2.py b/cryptography/hazmat/primitives/kdf/pbkdf2.py index 66a9b462..158e98e7 100644 --- a/cryptography/hazmat/primitives/kdf/pbkdf2.py +++ b/cryptography/hazmat/primitives/kdf/pbkdf2.py @@ -13,8 +13,6 @@ from __future__ import absolute_import, division, print_function -import six - from cryptography import utils from cryptography.exceptions import ( AlreadyFinalized, InvalidKey, UnsupportedAlgorithm, _Reasons @@ -41,7 +39,7 @@ class PBKDF2HMAC(object): self._used = False self._algorithm = algorithm self._length = length - if not isinstance(salt, six.binary_type): + if not isinstance(salt, bytes): raise TypeError("salt must be bytes") self._salt = salt self._iterations = iterations @@ -52,7 +50,7 @@ class PBKDF2HMAC(object): raise AlreadyFinalized("PBKDF2 instances can only be used once") self._used = True - if not isinstance(key_material, six.binary_type): + if not isinstance(key_material, bytes): raise TypeError("key_material must be bytes") return self._backend.derive_pbkdf2_hmac( self._algorithm, diff --git a/cryptography/hazmat/primitives/padding.py b/cryptography/hazmat/primitives/padding.py index e8e6a6df..d58f8731 100644 --- a/cryptography/hazmat/primitives/padding.py +++ b/cryptography/hazmat/primitives/padding.py @@ -104,7 +104,7 @@ class _PKCS7PaddingContext(object): if self._buffer is None: raise AlreadyFinalized("Context was already finalized") - if not isinstance(data, six.binary_type): + if not isinstance(data, bytes): raise TypeError("data must be bytes") self._buffer += data @@ -137,7 +137,7 @@ class _PKCS7UnpaddingContext(object): if self._buffer is None: raise AlreadyFinalized("Context was already finalized") - if not isinstance(data, six.binary_type): + if not isinstance(data, bytes): raise TypeError("data must be bytes") self._buffer += data |