pub struct AesCtrHmac {
    pub main_key: Vec<u8>,
    /* private fields */
}
Expand description

AesCtrHmac implements streaming AEAD encryption using AES-CTR and HMAC.

Each ciphertext uses new AES-CTR and HMAC keys. These keys are derived using HKDF and are derived from the key derivation key, a randomly chosen salt of the same size as the key and a nonce prefix.

Fields§

§main_key: Vec<u8>

Implementations§

source§

impl AesCtrHmac

source

pub fn new( main_key: &[u8], hkdf_alg: HashType, key_size_in_bytes: usize, tag_alg: HashType, tag_size_in_bytes: usize, ciphertext_segment_size: usize, first_segment_offset: usize ) -> Result<AesCtrHmac, TinkError>

Initialize an AES_CTR_HMAC primitive with a key derivation key and encryption parameters.

main_key is input keying material used to derive sub keys. This must be longer than the size of the sub keys (key_size_in_bytes). hkdf_alg is a MAC algorithm hash type, used for the HKDF key derivation. key_size_in_bytes is the key size of the sub keys. tag_alg is the MAC algorithm hash type, used for generating per segment tags. tag_size_in_bytes is the size of the per segment tags. ciphertext_segment_size is the size of ciphertext segments. first_segment_offset is the offset of the first ciphertext segment.

source

pub fn header_length(&self) -> usize

Return the length of the encryption header.

Trait Implementations§

source§

impl Clone for AesCtrHmac

source§

fn clone(&self) -> AesCtrHmac

Returns a copy 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 StreamingAead for AesCtrHmac

source§

fn new_encrypting_writer( &self, w: Box<dyn Write>, aad: &[u8] ) -> Result<Box<dyn EncryptingWrite>, TinkError>

Return a wrapper around an underlying [std::io.Write], such that any write-operation via the wrapper results in AEAD-encryption of the written data, using aad as associated authenticated data. The associated data is not included in the ciphertext and has to be passed in as parameter for decryption.

source§

fn new_decrypting_reader( &self, r: Box<dyn Read>, aad: &[u8] ) -> Result<Box<dyn Read>, TinkError>

Return a wrapper around an underlying std::io::Read, such that any read-operation via the wrapper results in AEAD-decryption of the underlying ciphertext, using aad as associated authenticated data.

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> StreamingAeadBoxClone for Twhere T: 'static + StreamingAead + Clone,

source§

fn box_clone(&self) -> Box<dyn StreamingAead + 'static, Global>

source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · 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