pub struct Header {
    pub version: u16,
    pub data_length: u16,
    pub encryption_alg: u8,
    pub hash_alg: u8,
    pub kdf_alg: u8,
    pub kdf_params: KdfParams,
    pub compression_alg: u8,
    pub master_salt: Vec<u8>,
    pub nonce: Option<Vec<u8>>,
    pub root_key_nonce: Option<Vec<u8>>,
    pub root_key_ciphertext: Option<Vec<u8>>,
}

Fields§

§version: u16§data_length: u16§encryption_alg: u8§hash_alg: u8§kdf_alg: u8§kdf_params: KdfParams§compression_alg: u8§master_salt: Vec<u8>§nonce: Option<Vec<u8>>§root_key_nonce: Option<Vec<u8>>§root_key_ciphertext: Option<Vec<u8>>

Implementations§

source§

impl Header

source

pub fn new( encryption_alg: Option<u8>, hash_alg: Option<u8>, kdf_alg: Option<u8>, compression_alg: Option<u8>, master_salt: Option<Vec<u8>> ) -> Header

source

pub fn quick_lookup(data: Vec<u8>) -> Result<(u16, u16), Box<dyn Error>>

Read fixed part of header which will return version and the header total length. Return Err if the data is not started with MAGIC_HEADER bytes

source

pub fn new_from_vector(data: Vec<u8>) -> Result<Header, Box<dyn Error>>

Initialize new Header from Vec<u8>

source

pub fn parse_tlv_header(&mut self, data: Vec<u8>) -> Result<(), Box<dyn Error>>

Parse the dynamic part (Type-Length-Value list) of header

source

pub fn construct_header(&mut self) -> Result<Vec<u8>, Box<dyn Error>>

Construct header section and return the buffer. It will also automatically update data_length

source

pub fn validate_version(&mut self) -> bool

Check whether the header is valid in the current version

Trait Implementations§

source§

impl Debug for Header

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<Header> for Header

source§

fn eq(&self, other: &Header) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Header

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V