change extension for encrypted files
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Tue, 28 Mar 2017 13:12:04 +0000 (15:12 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 2 Apr 2018 11:34:08 +0000 (13:34 +0200)
deltatar/deltatar.py
deltatar/tarfile.py

index f5493ce..762b70d 100644 (file)
@@ -47,6 +47,14 @@ NO_MATCH        = False
 MATCH           = True
 PARENT_MATCH    = 2
 
+# The canonical extension for encrypted backup files regardless of the actual
+# encryption parameters is “.pdtcrypt”. This is analogous to the encryption
+# header which starts with the eight ASCII bytes “PDTCRYPT”. Historical note:
+# Since the introduction of the versioned header there no longer any need
+# for encoding encryption parameters in the file extensions (“.aes128” and
+# suchlike).
+PDTCRYPT_EXTENSION = "pdtcrypt"
+
 class DeltaTar(object):
     '''
     Backup class used to create backups
@@ -104,8 +112,8 @@ class DeltaTar(object):
         '|gz': '.gz',
         '|bz2': '.bz2',
         '#gz': '.gz',
-        '#gz.aes128': '.gz.aes128',
-        '#aes128': '.aes128',
+        '#gz.aes128': '.gz.%s' % PDTCRYPT_EXTENSION,
+        '#aes128': '.%s' % PDTCRYPT_EXTENSION,
     }
 
     # valid index modes and their corresponding default file extension
@@ -113,8 +121,8 @@ class DeltaTar(object):
         '': '',
         'gz': '.gz',
         'bz2': '.bz2',
-        'gz.aes128': '.gz.aes128',
-        'aes128': '.aes128',
+        'gz.aes128': '.gz.%s' % PDTCRYPT_EXTENSION,
+        'aes128': '.%s' % PDTCRYPT_EXTENSION,
     }
 
     # valid path prefixes
index 0431d5f..0832d7d 100644 (file)
@@ -117,9 +117,8 @@ GNU_FORMAT = 1                  # GNU tar format
 PAX_FORMAT = 2                  # POSIX.1-2001 (pax) format
 DEFAULT_FORMAT = GNU_FORMAT
 
-DELTATAR_HEADER_VERSION     = 1
-DELTATAR_PARAMETER_VERSION  = 1
-DELTATAR_PDTCRYPT_EXTENSION = "pdtcrypt"
+DELTATAR_HEADER_VERSION    = 1
+DELTATAR_PARAMETER_VERSION = 1
 
 GZ_FMT_HEADER        = b"<BBBBLBB"
 GZ_MAGIC             = (0x1f, 0x8b) # 0o37, 0o213