Struct aead::stream::Encryptor

source ·
pub struct Encryptor<A, S>where
    A: AeadInPlace,
    S: StreamPrimitive<A>,
    A::NonceSize: Sub<<S as StreamPrimitive<A>>::NonceOverhead>,
    NonceSize<A, S>: ArrayLength<u8>,{ /* private fields */ }
Available on crate feature stream only.
Expand description

Stateful STREAM object which can encrypt AEAD messages one-at-a-time.

This corresponds to the ℰ STREAM encryptor object as defined in the paper Online Authenticated-Encryption and its Nonce-Reuse Misuse-Resistance.

Implementations§

source§

impl<A, S> Encryptor<A, S>where A: AeadInPlace, S: StreamPrimitive<A>, A::NonceSize: Sub<<S as StreamPrimitive<A>>::NonceOverhead>, NonceSize<A, S>: ArrayLength<u8>,

source

pub fn new(key: &Key<A>, nonce: &Nonce<A, S>) -> Selfwhere A: KeyInit, S: NewStream<A>,

Create a ℰ STREAM encryptor object from the given AEAD key and nonce.

source

pub fn from_aead(aead: A, nonce: &Nonce<A, S>) -> Selfwhere A: KeyInit, S: NewStream<A>,

Create a ℰ STREAM encryptor object from the given AEAD primitive.

source

pub fn from_stream_primitive(stream: S) -> Self

Create a ℰ STREAM encryptor object from the given STREAM primitive.

source

pub fn encrypt_next<'msg, 'aad>( &mut self, payload: impl Into<Payload<'msg, 'aad>> ) -> Result<Vec<u8>>

Available on crate feature alloc only.

Use the underlying AEAD to encrypt the next AEAD message in this STREAM, returning the result as a Vec.

source

pub fn encrypt_next_in_place( &mut self, associated_data: &[u8], buffer: &mut dyn Buffer ) -> Result<()>

Use the underlying AEAD to encrypt the next AEAD message in this STREAM in-place.

source

pub fn encrypt_last<'msg, 'aad>( self, payload: impl Into<Payload<'msg, 'aad>> ) -> Result<Vec<u8>>

Available on crate feature alloc only.

Use the underlying AEAD to encrypt the last AEAD message in this STREAM, consuming the ℰ STREAM encryptor object in order to prevent further use.

source

pub fn encrypt_last_in_place( self, associated_data: &[u8], buffer: &mut dyn Buffer ) -> Result<()>

Use the underlying AEAD to encrypt the last AEAD message in this STREAM in-place, consuming the ℰ STREAM encryptor object in order to prevent further use.

Auto Trait Implementations§

§

impl<A, S> RefUnwindSafe for Encryptor<A, S>where S: RefUnwindSafe, <S as StreamPrimitive<A>>::Counter: RefUnwindSafe,

§

impl<A, S> Send for Encryptor<A, S>where S: Send, <S as StreamPrimitive<A>>::Counter: Send,

§

impl<A, S> Sync for Encryptor<A, S>where S: Sync, <S as StreamPrimitive<A>>::Counter: Sync,

§

impl<A, S> Unpin for Encryptor<A, S>where S: Unpin, <S as StreamPrimitive<A>>::Counter: Unpin,

§

impl<A, S> UnwindSafe for Encryptor<A, S>where S: UnwindSafe, <S as StreamPrimitive<A>>::Counter: UnwindSafe,

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, 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.