Skip to main content

read_file_version

Function read_file_version 

Source
pub fn read_file_version<R>(reader: &mut R) -> Result<(u8, u8), AescryptError>
where R: Read,
Expand description

Reads and validates the 5-byte AES Crypt file header.

Returns (version, modulo_or_reserved) where:

  • version is the file format version (0..=3).
  • modulo_or_reserved is the 5th header byte:
    • For v0: the modulo byte (any value; passed to StreamConfig::V0 for final plaintext-length recovery).
    • For v1–v3: the reserved byte; an error is returned unless it is 0x00.

This is the strict counterpart to crate::read_version, which only reads as many bytes as needed and is permissive about short v0 stubs.

§Errors

§Security

Reads exactly 5 bytes regardless of input, capping pre-authentication effort. The output is plain (u8, u8) — there is nothing secret to zeroize.