aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cryptography/utils.py3
-rw-r--r--tests/test_cryptography_utils.py2
2 files changed, 3 insertions, 2 deletions
diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py
index d69ed89f..14909c66 100644
--- a/src/cryptography/utils.py
+++ b/src/cryptography/utils.py
@@ -57,8 +57,7 @@ else:
assert byteorder == 'big'
assert not signed
- # call bytes() on data to allow the use of bytearrays
- return int(bytes(data).encode('hex'), 16)
+ return int(binascii.hexlify(data), 16)
if hasattr(int, "to_bytes"):
diff --git a/tests/test_cryptography_utils.py b/tests/test_cryptography_utils.py
index 320f7aa8..ddea7602 100644
--- a/tests/test_cryptography_utils.py
+++ b/tests/test_cryptography_utils.py
@@ -11,6 +11,8 @@ from cryptography import utils
def test_int_from_bytes_bytearray():
assert utils.int_from_bytes(bytearray(b"\x02\x10"), "big") == 528
+ with pytest.raises(TypeError):
+ utils.int_from_bytes(["list", "is", "not", "bytes"], "big")
class TestCachedProperty(object):