From 0bfa20470f4335a9cef88c2f32c43c8e303e1219 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 10 Apr 2017 11:43:06 +0200 Subject: [PATCH] strip extraneous parameters from decryption handler ctor Format and parameter version as well as the salt are supplied from the headers. Decrypting should thus only require the password and, depending on context, an explicit counter as well as the list of valid IV fixed parts. --- deltatar/crypto.py | 27 +++++---------------------- 1 files changed, 5 insertions(+), 22 deletions(-) diff --git a/deltatar/crypto.py b/deltatar/crypto.py index 3e512ba..bcc89b8 100755 --- a/deltatar/crypto.py +++ b/deltatar/crypto.py @@ -446,8 +446,8 @@ class Crypto (object): self.next_pfx () - def set_parameters (self, password, paramversion, nacl=None, counter=None, - nextpfx=None): + def set_parameters (self, password, paramversion=None, nacl=None, + counter=None, nextpfx=None): if nextpfx is not None: self.next_pfx = nextpfx self.next_pfx () @@ -599,8 +599,7 @@ class Decrypt (Crypto): tag = None # GCM tag, part of header - def __init__ (self, password, paramversion=None, nacl=None, counter=None, - fixedparts=None): + def __init__ (self, password, counter=None, fixedparts=None): # passwort if isinstance (password, str) is False: raise InvalidParameter ("__init__: password must be a string, not %s" @@ -608,22 +607,6 @@ class Decrypt (Crypto): if len (password) == 0: raise InvalidParameter ("__init__: supplied empty password but not " "permitted for PDT encrypted files") - # version - if isinstance (version, int) is False: - raise InvalidParameter ("__init__: version number must be an " - "integer, not %s" % type (version)) - if version < 0: - raise InvalidParameter ("__init__: version number must be a " - "nonnegative integer, not %d" % version) - # paramversion - if isinstance (paramversion, int) is False: - raise InvalidParameter ("__init__: crypto parameter version number " - "must be an integer, not %s" - % type (paramversion)) - if paramversion < 0: - raise InvalidParameter ("__init__: crypto parameter version number " - "must be a nonnegative integer, not %d" - % paramversion) # fixed parts if fixedparts is not None: if isinstance (fixedparts, list) is False: @@ -632,8 +615,8 @@ class Decrypt (Crypto): % type (fixedparts)) self.fixed = fixedparts self.fixed.sort () - super().__init__ (password, paramversion, nacl, counter=counter) - super().__init__ (password, paramversion, nacl, counter=counter) + super().__init__ (password, counter=counter) + super().__init__ (password, counter=counter) def valid_fixed_part (self, iv): -- 1.7.1