Skip to main content

Module metadata

Module metadata 

Source
Expand description

Plaintext layout of the encrypted metadata envelope. Plaintext layout of the encrypted metadata envelope.

The envelope is serialized, then AEAD-encrypted under the metadata domain and stored in the header. Layout (little endian):

fieldsizepresent
flags1 bytealways
filename_len2 bytesalways
filenamevariablealways (UTF-8)
mtime_secs8 bytesflags bit 0 (signed)
mtime_nanos4 bytesflags bit 0
mode4 bytesflags bit 1

Flags bit 2 marks the content as a crate::archive stream (a directory tree) instead of a single file’s bytes; filename is then the directory name.

Trailing unknown bytes are rejected: this layout is fixed for the v3 format, and any extension is a new format version.

Functions§

parse
Parses a decrypted metadata envelope. Any structural mismatch (bad lengths, unknown flags, trailing bytes, invalid UTF-8 filename) is FileError::InvalidMetadata.
serialize
Serializes a metadata envelope. Fails with HeaderError::MetadataTooLong when the filename pushes the envelope past what the header can hold.