aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2020-05-26 15:18:19 -0400
committerRob Austein <sra@hactrn.net>2020-05-26 15:18:19 -0400
commited4c22473f5fb07006e773137ed047950e25a4d8 (patch)
tree26f7b93d5447b2e0cf5bd9c92dcda70161a46545 /utils
parent1cd42f6d3332e1edf78b06bd7dcf51f5a1a7bb23 (diff)
Wow, python-version-independent hexadecimal is painful
Diffstat (limited to 'utils')
-rwxr-xr-xutils/last_gasp_default_pin8
1 files changed, 6 insertions, 2 deletions
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)))