From ed4c22473f5fb07006e773137ed047950e25a4d8 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Tue, 26 May 2020 15:18:19 -0400 Subject: Wow, python-version-independent hexadecimal is painful --- utils/last_gasp_default_pin | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/last_gasp_default_pin b/utils/last_gasp_default_pin index 4dd1d54..1f340d0 100755 --- a/utils/last_gasp_default_pin +++ b/utils/last_gasp_default_pin @@ -66,6 +66,10 @@ args = parser.parse_args() def HMAC_SHA256(pin, salt): return HMAC.new(pin, salt, SHA256).digest() +def uint8(value): + value = hexlify(value).decode("ascii") + return ", ".join("0x" + value[i : i + 2] for i in range(0, len(value), 2)) + salt = urandom(16) pin = PBKDF2(password = args.pin, @@ -84,5 +88,5 @@ static const hal_ks_pin_t hal_last_gasp_pin = {{ {{{pin}}}, {{{salt}}} }};'''.format(iterations = args.iterations, - pin = ", ".join(hexlify(v) for v in pin), - salt = ", ".join(hexlify(v) for v in salt))) + pin = uint8(pin), + salt = uint8(salt))) -- cgit v1.2.3