diff options
Diffstat (limited to 'cryptech_backup')
-rwxr-xr-x | cryptech_backup | 8 |
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] |