From a39e3d165bfc3e4dd94a80d8ff17af356113d918 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Sat, 8 Aug 2015 11:10:32 -0500 Subject: py3 int.to_bytes is dead to me --- src/cryptography/utils.py | 14 ++++---------- src/cryptography/x509.py | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py index 4ca4a7a2..993571bd 100644 --- a/src/cryptography/utils.py +++ b/src/cryptography/utils.py @@ -47,16 +47,10 @@ else: return result -if hasattr(int, "to_bytes"): - int_to_bytes = int.to_bytes -else: - def int_to_bytes(integer, byteorder, signed=False): - assert byteorder == 'big' - assert not signed - - hex_string = '%x' % integer - n = len(hex_string) - return binascii.unhexlify(hex_string.zfill(n + (n & 1))) +def int_to_bytes(integer): + hex_string = '%x' % integer + n = len(hex_string) + return binascii.unhexlify(hex_string.zfill(n + (n & 1))) class InterfaceNotImplemented(Exception): diff --git a/src/cryptography/x509.py b/src/cryptography/x509.py index 3254f26f..82b8bd36 100644 --- a/src/cryptography/x509.py +++ b/src/cryptography/x509.py @@ -698,7 +698,7 @@ class SubjectKeyIdentifier(object): for bit in spki.getComponentByName("subjectPublicKey"): bits = bits << 1 | bit - data = utils.int_to_bytes(bits, "big") + data = utils.int_to_bytes(bits) return cls(hashlib.sha1(data).digest()) digest = utils.read_only_property("_digest") -- cgit v1.2.3