Trait sm9::Encapsulator
source · pub trait Encapsulator<EK>where
EK: EncappedKey,{
// Required method
fn try_encap<R>(
&self,
csprng: &mut R,
recip_pubkey: &<EK as EncappedKey>::RecipientPublicKey
) -> Result<(EK, SharedSecret<EK>), Error>
where R: CryptoRng + RngCore;
}Expand description
Represents the functionality of a key encapsulator. For unauthenticated encapsulation, Self
can be an empty struct. For authenticated encapsulation, Self is a private key.
Required Methods§
sourcefn try_encap<R>(
&self,
csprng: &mut R,
recip_pubkey: &<EK as EncappedKey>::RecipientPublicKey
) -> Result<(EK, SharedSecret<EK>), Error>
fn try_encap<R>( &self, csprng: &mut R, recip_pubkey: &<EK as EncappedKey>::RecipientPublicKey ) -> Result<(EK, SharedSecret<EK>), Error>
Attempts to encapsulate a fresh shared secret with the given recipient. The resulting
shared secret is bound to the identity encoded in Self (i.e., authenticated wrt Self).
If Self is empty, then this is equivalent to unauthenticated encapsulation. Returns the
shared secret and encapsulated key on success, or an error if something went wrong.
Object Safety§
This trait is not object safe.