Struct deadbolt_parser::Parser

source ·
pub struct Parser {
    pub header: Header,
    pub data: Vec<Data>,
    pub signature_key: Secret<Vec<u8>>,
    pub root_key: Secret<Vec<u8>>,
    pub filepath: String,
    pub config: Config,
    /* private fields */
}

Fields§

§header: Header§data: Vec<Data>§signature_key: Secret<Vec<u8>>§root_key: Secret<Vec<u8>>§filepath: String§config: Config

Implementations§

source§

impl Parser

source

pub fn new( signature_key: Secret<Vec<u8>>, root_key: Secret<Vec<u8>>, master_salt: Vec<u8>, encrypted_root_key: Option<Vec<u8>>, nonce: Option<Vec<u8>> ) -> Parser

source

pub fn new_default() -> Parser

source

pub fn read_from_file(&mut self, filepath: &str) -> Result<(), Box<dyn Error>>

Read db from file and store the content. Only header section will be parsed

source

pub fn verify_password_from_file( filepath: &str, master_password: Secret<String> ) -> Result<(Secret<Vec<u8>>, Secret<Vec<u8>>), Box<dyn Error>>

Verify password without having to read the whole file content

source

pub fn derive_master_key( master_password: Secret<String>, salt: &[u8], algorithm: String, iterations: u8, threads: u8, memory: u32 ) -> (Secret<Vec<u8>>, Secret<Vec<u8>>)

Derive master_key and signature_key from master_password

source

pub fn get_root_key(&mut self, master_key: &Secret<Vec<u8>>)

Decrypt encrypted_root_key and set it as current root_key

source

pub fn generate_root_key( master_key: Secret<Vec<u8>>, encryption_alg: u8 ) -> (Secret<Vec<u8>>, Vec<u8>, [u8; 12])

Generate new random root_key and its encrypted form

source

pub fn generate_child_key(&mut self) -> Secret<Vec<u8>>

Get the child_key from the current root_key

source

pub fn new_password_entry( &mut self, key: String, metadata: String, password: Secret<String> )

Add new entry to the Parser.data

source

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

Parse the TLV data

source

pub fn verify_signature(&mut self) -> Result<(), Box<dyn Error>>

Verify whether the signature is correct with the header data

source

pub fn read_raw_content(&mut self) -> Result<(), Box<dyn Error>>

Parse Parser.raw_content into Parser.data

source

pub fn write_to_file(&mut self) -> Result<(), Box<dyn Error>>

Write content into file

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