From 591a722f561ac341e30a66ae097d553cb04ec16a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 6 Apr 2017 14:34:20 +0200 Subject: [PATCH] accept external counter in crypto.py Required when encrypting an auxiliary file of type info. --- deltatar/crypto.py | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/deltatar/crypto.py b/deltatar/crypto.py index 4ca4e10..e6374ad 100755 --- a/deltatar/crypto.py +++ b/deltatar/crypto.py @@ -245,6 +245,7 @@ def hex_spaced_of_bytes (b): for c1, c2 in zip (b[0::2], b[1::2]) ]) \ + (len (b) | 1 == len (b) and " %.2x" % b[-1] or "") # odd lengths + hdr_dump = hex_spaced_of_bytes @@ -465,9 +466,9 @@ class Encrypt (Crypto): return struct.pack(FMT_I2N_IV, self.pfx [-1], self.cnt) - def next (self, filename, version, nacl): + def next (self, filename, version, nacl, counter=None): self.curobj = (filename, version, nacl or self.nacl) - self.set_object_counter (self.cnt + 1) + self.set_object_counter (counter if counter is not None else self.cnt + 1) self.iv = self.iv_make () if self.paramenc == "aes-gcm": @@ -590,7 +591,7 @@ class PDTDecryptionError (Exception): def noise (*a, **b): - print (file=sys.stderr, *a, *b) + print (file=sys.stderr, *a, **b) def depdtcrypt (pw, ins, outs): -- 1.7.1