pub struct Header {
pub digest: [u8; 32],
pub byte_size: u64,
pub media_type: String,
pub kek_id: String,
pub stream_nonce: [u8; 19],
}Expand description
The authenticated header, decoded.
Fields§
§digest: [u8; 32]Raw SHA-256 over the plaintext — the same bytes the address hexes.
byte_size: u64§media_type: String§kek_id: StringNonsecret label of the KEK that wrapped this blob’s DEK.
stream_nonce: [u8; 19]Implementations§
Source§impl Header
impl Header
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
The exact bytes that open the container AND serve as associated data.
One function for both, deliberately: if the AAD were assembled separately from the bytes on disk, the two could disagree and the authentication would be checking something the reader never parsed.
Sourcepub fn decode(bytes: &[u8]) -> Result<(Self, usize), BlobError>
pub fn decode(bytes: &[u8]) -> Result<(Self, usize), BlobError>
Parse a header, returning it and how many bytes it occupied.
Strict: unknown magic, an unknown version, a length that runs past the buffer, or non-UTF-8 in either string is a refusal. Nothing here is recovered from or guessed at — the header is the thing every other byte is authenticated against.
Trait Implementations§
impl Eq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnsafeUnpin for Header
impl UnwindSafe for Header
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more