Expand description
Whole-file content hash + canonical-encoding integrity gates (P0.3).
The .10d container has two integrity layers:
- Per-section CRC-32C (P0.2, in
super::section) — each section descriptor carries a CRC-32C over its payload; a flipped payload bit is caught at section read. - Whole-file content hash (P0.3, here) — a CRC-32C over the entire
file (header + section table + payloads + padding), stored in the
header’s
header_crc32cfield. This catches header corruption and table corruption that the per-section CRC cannot (e.g. a flippedbyte_offsetin a descriptor that still points somewhere valid).
The whole-file hash is computed with header_crc32c zeroed during
computation (the standard self-referential CRC technique): on encode, the
field is written zero, the CRC is computed over the full buffer, then the
CRC is written into the field; on verify, the stored value is saved, the
field is zeroed in-place, the CRC is recomputed, and the two are compared.
Determinism / canonical bytes. Because super::section::encode_container
produces byte-identical output for identical input (canonical section
order, zeroed padding), the whole-file hash is stable across encodes and
changes on any payload-byte change. This is the P0.3 “whole-file hash is
stable across encodes and changes on any payload-byte change, zero-alloc
over the caller buffer” gate.
Enums§
- Integrity
Error - Integrity verification error.
Functions§
- compute_
whole_ file_ crc32c - Compute the whole-file CRC-32C over
data, treating theheader_crc32cfield (bytes 52..56) as zero. Zero-heap: operates directly over the caller buffer. Does not modifydata. - seal_
whole_ file_ crc32c - Write the whole-file CRC-32C into the header’s
header_crc32cfield in-place withindata. Called by the encoder after the full file is written. Zero-heap. - verify_
whole_ file_ crc32c - Verify the whole-file CRC-32C stored in the header against a recomputed
value. Returns
Ok(())if they match, or an error naming both values. Zero-heap: saves the stored CRC, zeroes the field in-place, recomputes, restores the field.