pub struct Header {
pub version: u8,
pub suite: u8,
pub flags: u8,
pub key_id: [u8; 8],
}Expand description
The parsed header of an encrypted file.
Fields§
§version: u8Format version; only FORMAT_VERSION is accepted today.
suite: u8Cipher suite; only SUITE_AES_256_SIV is accepted today.
flags: u8Conversion flags recorded at encryption time.
key_id: [u8; 8]Fingerprint of the master key this file was encrypted with.
Implementations§
Source§impl Header
impl Header
Sourcepub fn new(flags: u8, key_id: [u8; 8]) -> Self
pub fn new(flags: u8, key_id: [u8; 8]) -> Self
Builds a header for the suite and version we write today.
Sourcepub fn to_bytes(self) -> [u8; 22]
pub fn to_bytes(self) -> [u8; 22]
Serialises the header exactly as it appears at the start of a file.
Sourcepub fn parse(blob: &[u8]) -> Result<Self>
pub fn parse(blob: &[u8]) -> Result<Self>
Parses the header at the start of blob, refusing anything unknown.
Fail closed is the rule here: an older binary meeting a newer file must stop rather than guess. That covers an unknown format version, an unknown suite and any reserved flag bit being set.
§Errors
Error::Format when the blob is too short, lacks the magic, or names
a version, suite or flag bit this build does not understand.