pub struct EncapsulationKey<Id = AlgorithmId>where
Id: AlgorithmIdentifier,{ /* private fields */ }
Expand description
A serializable encapsulation key usable with KEM algorithms. Constructed
from either a DecapsulationKey
or raw bytes.
Implementations§
Source§impl<Id> EncapsulationKey<Id>where
Id: AlgorithmIdentifier,
impl<Id> EncapsulationKey<Id>where
Id: AlgorithmIdentifier,
Sourcepub fn algorithm(&self) -> &'static Algorithm<Id>
pub fn algorithm(&self) -> &'static Algorithm<Id>
Return the algorithm associated with the given KEM encapsulation key.
Sourcepub fn encapsulate(
&self,
) -> Result<(Ciphertext<'static>, SharedSecret), Unspecified>
pub fn encapsulate( &self, ) -> Result<(Ciphertext<'static>, SharedSecret), Unspecified>
Performs the encapsulate operation using this KEM encapsulation key, generating a ciphertext and associated shared secret.
§Errors
error::Unspecified
when operation fails due to internal error.
Sourcepub fn key_bytes(&self) -> Result<EncapsulationKeyBytes<'static>, Unspecified>
pub fn key_bytes(&self) -> Result<EncapsulationKeyBytes<'static>, Unspecified>
Returns the EnscapsulationKey
bytes.
§Errors
Unspecified
: Any failure to retrieve theEnscapsulationKey
bytes.
Sourcepub fn new(
alg: &'static Algorithm<Id>,
bytes: &[u8],
) -> Result<Self, KeyRejected>
pub fn new( alg: &'static Algorithm<Id>, bytes: &[u8], ) -> Result<Self, KeyRejected>
Creates a new KEM encapsulation key from raw bytes. This method MUST NOT be used to generate
a new encapsulation key, rather it MUST be used to construct EncapsulationKey
previously serialized
to raw bytes.
alg
is the Algorithm
to be associated with the generated EncapsulationKey
.
bytes
is a slice of raw bytes representing a EncapsulationKey
.
§Errors
error::KeyRejected
when operation fails during key creation.