dissect.evidence.asdf.stream

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.stream.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.

fh
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.stream.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.

crc = 0
write(b: bytes) → int
digest() → bytes
finalize() → None
class dissect.evidence.asdf.stream.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.

ctx
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.stream.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.

cobj
write(b: bytes) → int
finalize() → None