Struct Header

Source
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 for Header

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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§

§

impl Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V