From: Philipp Gesang Date: Thu, 6 Apr 2017 12:34:20 +0000 (+0200) Subject: accept external counter in crypto.py X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=898190c25d4110e9065b9ea33b181265f9bc39f8;p=python-delta-tar accept external counter in crypto.py Required when encrypting an auxiliary file of type info. --- 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):