dissect.evidence.asdf.streams#

Module Contents#

Classes#

SubStreamBase

Convenience class for easy sub stream subclassing.

Crc32Stream

Compute a CRC32 over all written data.

HashedStream

Compute a hash over all written data.

CompressedStream

Compress data as it's being written.

class dissect.evidence.asdf.streams.SubStreamBase(fh: BinaryIO)#

Bases: io.RawIOBase

Convenience class for easy sub stream subclassing.

Additionally adds the finalize method.

Parameters:

fh – The file-like object to wrap.

write(b: bytes) int#
tell() int#

Return current stream position.

seek(pos: int, whence: int = io.SEEK_CUR) int#

Change stream position.

Change the stream position to the given byte offset. The offset is interpreted relative to the position indicated by whence. Values for whence are:

  • 0 – start of stream (the default); offset should be zero or positive

  • 1 – current stream position; offset may be negative

  • 2 – end of stream; offset is usually negative

Return the new absolute position.

close() None#

Flush and close the IO object.

This method has no effect if the file is already closed.

finalize() None#
class dissect.evidence.asdf.streams.Crc32Stream(fh: BinaryIO)#

Bases: SubStreamBase

Compute a CRC32 over all written data.

This assumes that all data is written as a continuous stream.

Parameters:

fh – The file-like object to wrap.

write(b: bytes) int#
digest() bytes#
finalize() None#
class dissect.evidence.asdf.streams.HashedStream(fh: BinaryIO, alg: str = 'sha256')#

Bases: SubStreamBase

Compute a hash over all written data.

This assumes that all data is written as a continuous stream.

Parameters:
  • fh – The file-like object to wrap.

  • alg – The hashing algorithm to use. Must be supported by hashlib.

write(b: bytes) int#
digest() bytes#
hexdigest() str#
close() None#

Flush and close the IO object.

This method has no effect if the file is already closed.

class dissect.evidence.asdf.streams.CompressedStream(fh: BinaryIO)#

Bases: SubStreamBase

Compress data as it’s being written.

This assumes that all data is written as a continuous stream.

Parameters:

fh – The file-like object to wrap.

write(b: bytes) int#
finalize() None#