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
impl Header
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
Sourcepub fn quick_lookup(data: Vec<u8>) -> Result<(u16, u16), Box<dyn Error>>
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
Sourcepub fn new_from_vector(data: Vec<u8>) -> Result<Header, Box<dyn Error>>
pub fn new_from_vector(data: Vec<u8>) -> Result<Header, Box<dyn Error>>
Initialize new Header
from Vec<u8>
Sourcepub fn parse_tlv_header(&mut self, data: Vec<u8>) -> Result<(), Box<dyn Error>>
pub fn parse_tlv_header(&mut self, data: Vec<u8>) -> Result<(), Box<dyn Error>>
Parse the dynamic part (Type-Length-Value list) of header
Sourcepub fn construct_header(&mut self) -> Result<Vec<u8>, Box<dyn Error>>
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
Sourcepub fn validate_version(&mut self) -> bool
pub fn validate_version(&mut self) -> bool
Check whether the header is valid in the current version
Trait Implementations§
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> 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