aboutsummaryrefslogtreecommitdiff
path: root/cryptech_backup
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 /cryptech_backup
parent1cd42f6d3332e1edf78b06bd7dcf51f5a1a7bb23 (diff)
Wow, python-version-independent hexadecimal is painful
Diffstat (limited to 'cryptech_backup')
-rwxr-xr-xcryptech_backup8
1 files changed, 5 insertions, 3 deletions
diff --git a/cryptech_backup b/cryptech_backup
index be70f8b..1f6f3d1 100755
--- a/cryptech_backup
+++ b/cryptech_backup
@@ -52,6 +52,7 @@ import base64
import struct
import getpass
import argparse
+import binascii
from cryptech.libhal import *
@@ -361,14 +362,15 @@ class AESKeyWrapWithPadding(object):
R[0], R[i] = self._decrypt(R[0], R[i])
magic, m = struct.unpack(">LL", R[0])
if magic != 0xa65959a6:
- raise self.UnwrapError("Magic value in AIV should have been 0xa65959a6, was 0x{:02x}"
- .format(magic))
+ raise self.UnwrapError("Magic value in AIV should have been 0xa65959a6, was 0x{:08x}"
+ .format(magic))
if m <= 8 * (n - 1) or m > 8 * n:
raise self.UnwrapError("Length encoded in AIV out of range: m {}, n {}".format(m, n))
R = b"".join(R[1:])
assert len(R) == 8 * n
if any(r != b"\x00" for r in R[m:]):
- raise self.UnwrapError("Nonzero trailing bytes {}".format(R[m:].encode("hex")))
+ raise self.UnwrapError("Nonzero trailing bytes {}".format(
+ binascii.hexlify(R[m:]).decode("ascii")))
return R[:m]