From: Philipp Gesang Date: Mon, 10 Apr 2017 09:43:06 +0000 (+0200) Subject: strip extraneous parameters from decryption handler ctor X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=0bfa20470f4335a9cef88c2f32c43c8e303e1219;p=python-delta-tar 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. --- 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):