Skip to main content

Sealer

Struct Sealer 

Source
pub struct Sealer<A: Aead> { /* private fields */ }
Expand description

Seals messages under nonces it builds itself, each used once.

Implementations§

Source§

impl<A: Aead> Sealer<A>

Source

pub fn new(key: &[u8], fixed: [u8; 4]) -> Result<Self>

A sealer whose first nonce is fixed || 0.

fixed names this sender. Any other party sealing under key must use a different one.

Source

pub fn resume(key: &[u8], fixed: [u8; 4], counter: u64) -> Result<Self>

A sealer that continues from counter, the value a previous sealer on this key and fixed field reported from Sealer::counter when it was last used.

Restoring a counter lower than one already used reuses nonces. Persist the counter before sending what it sealed, not after.

Source

pub fn counter(&self) -> u64

The counter the next seal will use.

Source

pub fn seal( &mut self, aad: &[u8], in_out: &mut [u8], tag: &mut [u8], ) -> Result<[u8; 12]>

Encrypt in_out in place, write the tag, and return the nonce used.

The receiver needs the nonce, or the counter, to open the message. On failure the counter does not advance.

Trait Implementations§

Source§

impl<A: Aead> Debug for Sealer<A>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A> Freeze for Sealer<A>
where A: Freeze,

§

impl<A> RefUnwindSafe for Sealer<A>
where A: RefUnwindSafe,

§

impl<A> Send for Sealer<A>
where A: Send,

§

impl<A> Sync for Sealer<A>
where A: Sync,

§

impl<A> Unpin for Sealer<A>
where A: Unpin,

§

impl<A> UnsafeUnpin for Sealer<A>
where A: UnsafeUnpin,

§

impl<A> UnwindSafe for Sealer<A>
where A: UnwindSafe,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.