[Cryptech-Commits] [sw/libhal] branch master updated: Can't write bytes to JSON, only str
git at cryptech.is
git at cryptech.is
Sun Sep 6 04:50:03 UTC 2020
This is an automated email from the git hooks/post-receive script.
sra at hactrn.net pushed a commit to branch master
in repository sw/libhal.
The following commit(s) were added to refs/heads/master by this push:
new fe62a7a Can't write bytes to JSON, only str
fe62a7a is described below
commit fe62a7a3bfa0829c367433659d4bdf2a2b004d77
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Sun Sep 6 00:06:57 2020 -0400
Can't write bytes to JSON, only str
---
cryptech_backup | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/cryptech_backup b/cryptech_backup
index 4292eaf..def2a31 100755
--- a/cryptech_backup
+++ b/cryptech_backup
@@ -149,10 +149,10 @@ def defcmd(subparsers, func):
def b64(der):
- return base64.b64encode(der).splitlines()
+ return base64.b64encode(der).decode().splitlines()
def b64join(lines):
- return base64.b64decode("".join(lines))
+ return base64.b64decode("".join(lines).encode())
def cmd_setup(args, hsm):
@@ -350,7 +350,7 @@ class AESKeyWrapWithPadding(object):
if len(C) % 8 != 0:
raise self.UnwrapError("Ciphertext length {} is not an integral number of blocks"
.format(len(C)))
- n = (len(C) / 8) - 1
+ n = (len(C) // 8) - 1
R = [C[i : i + 8] for i in range(0, len(C), 8)]
if n == 1:
R[0], R[1] = self._decrypt(R[0], R[1])
@@ -368,9 +368,8 @@ class AESKeyWrapWithPadding(object):
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(
- binascii.hexlify(R[m:]).decode("ascii")))
+ if R[m:].strip(b"\x00"):
+ raise self.UnwrapError("Nonzero trailing bytes 0x{}".format(binascii.hexlify(R[m:]).decode("ascii")))
return R[:m]
@@ -415,7 +414,7 @@ class SoftKEKEK(object):
return AESKeyWrapWithPadding(PBKDF2(
password = getpass.getpass("KEKEK Passphrase: "),
salt = salt,
- dkLen = keylen/8,
+ dkLen = keylen//8,
count = iterations,
prf = lambda p, s: HMAC.new(p, s, SHA256).digest()))
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Commits
mailing list