From 1cd42f6d3332e1edf78b06bd7dcf51f5a1a7bb23 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Mon, 25 May 2020 19:33:38 -0400 Subject: Untested conversion to support Python 3 --- utils/last_gasp_default_pin | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'utils') diff --git a/utils/last_gasp_default_pin b/utils/last_gasp_default_pin index 8a91b8a..4dd1d54 100755 --- a/utils/last_gasp_default_pin +++ b/utils/last_gasp_default_pin @@ -44,6 +44,7 @@ generates the default. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter +from binascii import hexlify from os import urandom from Crypto.Protocol.KDF import PBKDF2 from Crypto.Hash import SHA256, HMAC @@ -65,9 +66,6 @@ args = parser.parse_args() def HMAC_SHA256(pin, salt): return HMAC.new(pin, salt, SHA256).digest() -def hexify(value): - return ", ".join("0x%02x" % ord(v) for v in value) - salt = urandom(16) pin = PBKDF2(password = args.pin, @@ -76,7 +74,7 @@ pin = PBKDF2(password = args.pin, count = args.iterations, prf = HMAC_SHA256) -print '''\ +print('''\ /* * Automatically generated by a script, do not edit. */ @@ -86,5 +84,5 @@ static const hal_ks_pin_t hal_last_gasp_pin = {{ {{{pin}}}, {{{salt}}} }};'''.format(iterations = args.iterations, - pin = hexify(pin), - salt = hexify(salt)) + pin = ", ".join(hexlify(v) for v in pin), + salt = ", ".join(hexlify(v) for v in salt))) -- cgit v1.2.3