'|gz': '.gz',
'|bz2': '.bz2',
'#gz': '.gz',
- '#gz.aes128': '.gz',
- '#aes128': '',
+ '#gz.pdtcrypt': '.gz',
+ '#pdtcrypt': '',
}
# valid index modes and their corresponding default file extension
'': '',
'gz': '.gz',
'bz2': '.bz2',
- 'gz.aes128': '.gz',
- 'aes128': '',
+ 'gz.pdtcrypt': '.gz',
+ 'pdtcrypt': '',
}
# valid path prefixes
'|gz' open a gzip compressed stream of tar blocks
'|bz2' open a bzip2 compressed stream of tar blocks
'#gz' open a stream of gzip compressed tar blocks
- '#gz.aes128' open an aes128 encrypted stream of gzip compressed tar blocks
- '#aes128' open an aes128 encrypted stream of tar blocks
- - password: used together with aes modes to encrypt and decrypt backups.
+ - password: used to encrypt and decrypt backups. Encryption will be
+ enabled automatically if a password is supplied.
- logger: python logger object. Optional.
- index_mode: specifies the index mode in the same format as @param
- mode, but without the ':', '|' or '#' at the begining. It doesn't
- make sense to specify that the index is encrypted if no no password
- is given in the constructor. This is an optional parameter that will
- automatically mimic @param mode by default if not provided. Valid
- modes are:
+ mode, but without the ':', '|' or '#' at the begining. If encryption
+ is requested it will extend to the auxiliary (index, info) files as
+ well. This is an optional parameter that will automatically mimic
+ @param mode by default if not provided. Valid modes are:
'' open uncompressed
'gz' open with gzip compression
'bz2' open with bzip2 compression
- 'gz.aes128' open an aes128 encrypted stream of gzip compressed tar blocks
- 'aes128' open an aes128 encrypted stream of tar blocks
- index_name_func: function that sets a custom name for the index file.
This function receives the backup_path and if it's a full backup as
# generate index_mode
if index_mode is None:
index_mode = ''
- if 'gz.aes' in mode:
- index_mode = mode[1:]
- elif 'gz' in mode:
+ if 'gz' in mode:
index_mode = "gz"
elif 'bz2' in mode:
index_mode = "bz2"
- elif 'aes' in mode:
- index_mode = mode[1:]
elif mode not in self.__index_extensions_dict:
raise Exception('Unrecognized extension mode=[%s] requested for index'
% str(mode))
flags |= GZ_FLAG_ORIG_NAME
if type(name) is str:
name = name.encode("iso-8859-1", "replace")
- if name.endswith(b".aes128"):
- name = name[:-7]
+ if name.endswith(b".pdtcrypt"):
+ name = name[:-9]
if name.endswith(b".gz"):
name = name[:-3]
# RFC1952 says we must use ISO-8859-1 for the FNAME field.
else:
self.cmp = lzma.LZMACompressor()
- elif comptype not in [ "tar", "aes128" ]:
+ elif comptype not in [ "tar" ]:
if self.encryption is not None:
raise InvalidEncryptionError("encryption not available for "
"compression %s" % comptype)
"""Initialize encryption for next entry in archive. Read a header and
notify the crypto context."""
if self.encryption is not None:
- self.lasthdr = self.fileobj.tell ()
+ lasthdr = self.fileobj.tell ()
try:
hdr = crypto.hdr_read_stream (self.fileobj)
except crypto.EndOfFile:
return False
- except crypto.InvalidHeader:
+ except crypto.InvalidHeader as exn:
raise DecryptionError ("Crypto.hdr_read_stream(): error “%s” "
- "processing %r" % (hdr, self.fileobj)) \
+ "processing %r at pos %d"
+ % (exn, self.fileobj, lasthdr)) \
from exn
+ self.lasthdr = lasthdr
self.remainder = hdr ["ctsize"] # distance to next header
self.encryption.next (hdr)
'r#gz' open a stream of gzip compressed tar blocks for reading
'w#gz' open a stream of gzip compressed tar blocks for writing
-
- 'r#gz.aes128' open an aes128 encrypted stream of gzip compressed tar blocks for reading
- 'w#gz.aes128' open an aes128 encrypted stream of gzip compressed tar blocks for writing
- 'r#aes128' open an aes128 encrypted stream of tar blocks for reading
- 'w#aes128' open an aes128 encrypted stream of tar blocks for writing
"""
if not name and not fileobj: