From: Philipp Gesang Date: Fri, 21 Apr 2017 07:39:02 +0000 (+0200) Subject: permit setting crypto.py parameter version via deltatar ctor X-Git-Tag: v2.2~7^2~156 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=dbee011c8194c0b2d1741eeca944e16531353dde;p=python-delta-tar permit setting crypto.py parameter version via deltatar ctor Introduce an optional argument to request a specific crypto parameter version when invoking Deltatar. This isn’t of much use ATM since only the one version is implemented, but it’s handy for testing nonetheless. --- diff --git a/deltatar/deltatar.py b/deltatar/deltatar.py index b9eae99..ac702e3 100644 --- a/deltatar/deltatar.py +++ b/deltatar/deltatar.py @@ -90,6 +90,10 @@ class DeltaTar(object): # used together with aes modes to encrypt and decrypt backups. password = None + # parameter version to use when encrypting; note that this has no effect + # on decryption since the required settings are determined from the headers + crypto_paramversion = None + # when encrypting or decrypting, this holds crypto handler; created before # establishing the Tarfile stream iff a password is supplied. crypto_ctx = None @@ -146,6 +150,7 @@ class DeltaTar(object): def __init__(self, excluded_files=[], included_files=[], filter_func=None, mode="", password=None, + crypto_paramversion=DELTATAR_PARAMETER_VERSION, logger=None, index_mode=None, index_name_func=None, volume_name_func=None): ''' @@ -182,6 +187,10 @@ class DeltaTar(object): - password: used to encrypt and decrypt backups. Encryption will be enabled automatically if a password is supplied. + - crypto_paramversion: optionally request encryption conforming to + a specific parameter version. Defaults to the standard PDT value + which as of 2017 is the only one available. + - logger: python logger object. Optional. - index_mode: specifies the index mode in the same format as @param @@ -220,6 +229,10 @@ class DeltaTar(object): if password is not None: self.password = password + if crypto_paramversion is not None: + self.crypto_paramversion = crypto_paramversion + + # generate index_mode if index_mode is None: index_mode = '' @@ -596,7 +609,7 @@ class DeltaTar(object): self.crypto_ctx = \ crypto.Encrypt (self.password, version=DELTATAR_HEADER_VERSION, - paramversion=DELTATAR_PARAMETER_VERSION) + paramversion=self.crypto_paramversion) # some initialization self.vol_no = 0 @@ -767,7 +780,7 @@ class DeltaTar(object): self.crypto_ctx = \ crypto.Encrypt (self.password, version=DELTATAR_HEADER_VERSION, - paramversion=DELTATAR_PARAMETER_VERSION) + paramversion=self.crypto_paramversion) # some initialization self.vol_no = 0