Struct hpke_rs::Context

source ·
pub struct Context<Crypto: 'static + HpkeCrypto> { /* private fields */ }
Expand description

The HPKE context. Note that the RFC currently doesn’t define this. Also see https://github.com/cfrg/draft-irtf-cfrg-hpke/issues/161.

Implementations§

source§

impl<Crypto: HpkeCrypto> Context<Crypto>

source

pub fn seal( &mut self, aad: &[u8], plain_txt: &[u8] ) -> Result<Vec<u8>, HpkeError>

5.2. Encryption and Decryption

Takes the associated data and the plain text as byte slices and returns the ciphertext or an error.

def Context.Seal(aad, pt):
  ct = Seal(self.key, self.ComputeNonce(self.seq), aad, pt)
  self.IncrementSeq()
  return ct
source

pub fn open( &mut self, aad: &[u8], cipher_txt: &[u8] ) -> Result<Vec<u8>, HpkeError>

5.2. Encryption and Decryption

Takes the associated data and the ciphertext as byte slices and returns the plain text or an error.

def Context.Open(aad, ct):
  pt = Open(self.key, self.ComputeNonce(self.seq), aad, ct)
  if pt == OpenError:
    raise OpenError
  self.IncrementSeq()
  return pt
source

pub fn export( &self, exporter_context: &[u8], length: usize ) -> Result<Vec<u8>, HpkeError>

5.3. Secret Export

Takes a serialised exporter context as byte slice and a length for the output secret and returns an exporter secret as byte vector.

def Context.Export(exporter_context, L):
 return LabeledExpand(self.exporter_secret, "sec", exporter_context, L)

Trait Implementations§

source§

impl<Crypto: HpkeCrypto> Debug for Context<Crypto>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Crypto> RefUnwindSafe for Context<Crypto>
where <Crypto as HpkeCrypto>::HpkePrng: RefUnwindSafe,

§

impl<Crypto> Send for Context<Crypto>
where <Crypto as HpkeCrypto>::HpkePrng: Send,

§

impl<Crypto> Sync for Context<Crypto>
where <Crypto as HpkeCrypto>::HpkePrng: Sync,

§

impl<Crypto> Unpin for Context<Crypto>
where <Crypto as HpkeCrypto>::HpkePrng: Unpin,

§

impl<Crypto> UnwindSafe for Context<Crypto>
where <Crypto as HpkeCrypto>::HpkePrng: 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>,

§

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

§

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.