PAX_FORMAT = 2 # POSIX.1-2001 (pax) format
DEFAULT_FORMAT = GNU_FORMAT
-DELTATAR_HEADER_VERSION = 1
-DELTATAR_PARAMETER_VERSION = 1
+DELTATAR_HEADER_VERSION = 1
+DELTATAR_PARAMETER_VERSION = 1
+DELTATAR_PDTCRYPT_EXTENSION = "pdtcrypt"
GZ_FMT_HEADER = b"<BBBBLBB"
GZ_MAGIC = (0x1f, 0x8b) # 0o37, 0o213
"size": int
}
-VALID_ENCRYPTION_MODES = [ "aes" ]
-
#---------------------------------------------------------
# initialization
#---------------------------------------------------------
Seek back to header position, read dummy bytes, finalize crypto
obtaining the actual header, write header, seek back to current
position.
+
+ Returns the list of IV fixed parts as used during encryption.
"""
+ fixed = None
if self.encryption is not None \
and self.lasthdr is not None :
self.__sync ()
dpos = pos1 - self.lasthdr
assert dpos == crypto.I2N_HDR_SIZE
self.fileobj.seek_set (pos0)
- data, hdr = self.encryption.done (dummy)
+ data, hdr, fixed = self.encryption.done (dummy)
self.__write_to_file(hdr, pos=self.lasthdr)
self.__write_to_file(data) # append remainder of data
self.lasthdr = -1
+ return fixed
def _finalize_write_gz (self):
"""Close the _Stream object. No operation should be
done on it afterwards.
"""
+ fixed = None
+
if self.closed:
return
if self.mode == "w":
self._finalize_write_gz ()
self.__enc_write(self.buf)
- self._finalize_write_encrypt ()
-
- if close_fileobj and not self._extfileobj:
- self.fileobj.close()
-
- # read the zlib crc and length and check them
- if not close_fileobj and self.mode == "r" and self.comptype == "gz":
- read_crc = self.__read(4)
- read_length = self.__read(4)
- calculated_crc = self.crc
- if struct.unpack("<L", read_crc)[0] != calculated_crc:
- raise CompressionError("bad gzip crc")
+ fixed = self._finalize_write_encrypt ()
+ if close_fileobj is True:
+ if not self._extfileobj:
+ self.fileobj.close()
+ else:
+ # read the zlib crc and length and check them
+ if self.mode == "r" and self.comptype == "gz":
+ read_crc = self.__read(4)
+ read_length = self.__read(4)
+ calculated_crc = self.crc
+ if struct.unpack("<L", read_crc)[0] != calculated_crc:
+ raise CompressionError("bad gzip crc")
self.closed = True
+ return fixed
+
def _init_read_gz(self):
"""Initialize for reading a gzip compressed fileobj.
"""