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>
impl<Crypto: HpkeCrypto> Context<Crypto>
sourcepub fn seal(
&mut self,
aad: &[u8],
plain_txt: &[u8]
) -> Result<Vec<u8>, HpkeError>
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
sourcepub fn open(
&mut self,
aad: &[u8],
cipher_txt: &[u8]
) -> Result<Vec<u8>, HpkeError>
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
sourcepub fn export(
&self,
exporter_context: &[u8],
length: usize
) -> Result<Vec<u8>, HpkeError>
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§
Auto Trait Implementations§
impl<Crypto> RefUnwindSafe for Context<Crypto>
impl<Crypto> Send for Context<Crypto>
impl<Crypto> Sync for Context<Crypto>
impl<Crypto> Unpin for Context<Crypto>
impl<Crypto> UnwindSafe for Context<Crypto>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more