EncryptionHeader

Struct EncryptionHeader 

Source
pub struct EncryptionHeader { /* private fields */ }
Expand description

The encryption header contains all informations (and the encrypted key) for the data and header encryption.
The encryption header is the only optional header part of the main header (With the exception of the PBEHeader, which is, however, part of the EncryptionHeader). The encryption header contains an encrypted key (encrypted encryption key). This key is encrypted with a password based encryption method, described by the containing PBEHeader. This key (decrypted with the appropriate password) is used to decrypt the encrypted data or the optionally encrypted header.

Implementations§

Source§

impl EncryptionHeader

Source

pub fn new( version: u8, pbe_header: PBEHeader, algorithm: EncryptionAlgorithm, encrypted_encryption_key: Vec<u8>, encrypted_header_nonce: [u8; 12], ) -> EncryptionHeader

creates a new encryption header by the given values.

Source

pub fn algorithm(&self) -> &EncryptionAlgorithm

returns the used encryption algorithm as a reference.

Source

pub fn pbe_header(&self) -> &PBEHeader

returns a reference to the inner PBE header.

Source

pub fn nonce(&self) -> &[u8; 12]

returns the nonce, used for header encryption. Note: this nonce is only used for the optionally header encryption.

Source

pub fn decrypt_encryption_key<P: AsRef<[u8]>>( &self, password: P, ) -> Result<Vec<u8>>

tries to decrypt the encryption key.

Trait Implementations§

Source§

impl Clone for EncryptionHeader

Source§

fn clone(&self) -> EncryptionHeader

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EncryptionHeader

Source§

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

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

impl HeaderCoding for EncryptionHeader

Source§

type Item = EncryptionHeader

the return value for decode_content(), decode_directly(), decode_for_key();
Source§

fn identifier() -> u32

returns the identifier (=Magic bytes) of the header.
Source§

fn version(&self) -> u8

returns the version of the header.
Source§

fn encode_header(&self) -> Vec<u8>

encodes the header.
Source§

fn decode_content(data: Vec<u8>) -> Result<EncryptionHeader>

decodes the content of the header.
Source§

fn header_size(&self) -> usize

returns the size of the encoded header (in bytes)
Source§

fn encode_key<K: Into<String>>(key: K) -> Vec<u8>

encodes a given key.
Source§

fn encode_directly(&self) -> Vec<u8>

encodes the (header) value/object directly (= without key).
Source§

fn encode_for_key<K: Into<String>>(&self, key: K) -> Vec<u8>

encodes a key to the (header) value/object.
Source§

fn decode_header_length<R: Read>(data: &mut R) -> Result<u64>

decodes the length of the header.
Source§

fn check_identifier<R: Read>(data: &mut R) -> bool

checks if the read identifier is valid for this header.
Source§

fn check_key_on_position<K: Into<String>, R: Read>(data: &mut R, key: K) -> bool

helper method to check, if the key is on position.
Source§

fn decode_directly<R: Read>(data: &mut R) -> Result<Self::Item>

decodes the header directly.
Source§

fn decode_for_key<K: Into<String>, R: Read>( data: &mut R, key: K, ) -> Result<Self::Item>

decodes the header for the given key.
Source§

impl PartialEq for EncryptionHeader

Source§

fn eq(&self, other: &EncryptionHeader) -> 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 Eq for EncryptionHeader

Source§

impl StructuralPartialEq for EncryptionHeader

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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