[go: up one dir, main page]

Struct Encryptor

Source
pub struct Encryptor<A, S>{ /* 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>

Source

pub fn new(key: &Key<A>, nonce: &Nonce<A, S>) -> Self
where 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>) -> Self
where 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> Freeze for Encryptor<A, S>

§

impl<A, S> RefUnwindSafe for Encryptor<A, S>

§

impl<A, S> Send for Encryptor<A, S>
where <<A as AeadCore>::NonceSize as Sub<<S as StreamPrimitive<A>>::NonceOverhead>>::Output: Sized, S: Send, <S as StreamPrimitive<A>>::Counter: Send,

§

impl<A, S> Sync for Encryptor<A, S>
where <<A as AeadCore>::NonceSize as Sub<<S as StreamPrimitive<A>>::NonceOverhead>>::Output: Sized, S: Sync, <S as StreamPrimitive<A>>::Counter: Sync,

§

impl<A, S> Unpin for Encryptor<A, S>
where <<A as AeadCore>::NonceSize as Sub<<S as StreamPrimitive<A>>::NonceOverhead>>::Output: Sized, S: Unpin, <S as StreamPrimitive<A>>::Counter: Unpin,

§

impl<A, S> UnwindSafe for Encryptor<A, S>

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.