pub struct EncapsulationKey<P>where
P: KemParams,{ /* private fields */ }Expand description
An EncapsulationKey provides the ability to encapsulate a shared key so that it can only be
decapsulated by the holder of the corresponding decapsulation key.
Implementations§
Source§impl<P> EncapsulationKey<P>
impl<P> EncapsulationKey<P>
Sourcepub fn new(encapsulation_key: &Key<Self>) -> Result<Self, InvalidKey>
pub fn new(encapsulation_key: &Key<Self>) -> Result<Self, InvalidKey>
Create a new EncapsulationKey from its serialized form.
§Errors
If the key failed validation during decoding.
Sourcepub fn encapsulate_deterministic(&self, m: &B32) -> (Ciphertext<P>, SharedKey)
pub fn encapsulate_deterministic(&self, m: &B32) -> (Ciphertext<P>, SharedKey)
Encapsulates with the given randomness. This is useful for testing against known vectors.
§Warning
Do NOT use this function unless you know what you’re doing. If you fail to use all uniform random bytes even once, you can have catastrophic security failure.
Trait Implementations§
Source§impl<P> AssociatedAlgorithmIdentifier for EncapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
Available on crate feature pkcs8 only.
impl<P> AssociatedAlgorithmIdentifier for EncapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
Available on crate feature
pkcs8 only.Source§const ALGORITHM_IDENTIFIER: AlgorithmIdentifier<Self::Params> = P::ALGORITHM_IDENTIFIER
const ALGORITHM_IDENTIFIER: AlgorithmIdentifier<Self::Params> = P::ALGORITHM_IDENTIFIER
AlgorithmIdentifier for this structure.Source§type Params = <P as AssociatedAlgorithmIdentifier>::Params
type Params = <P as AssociatedAlgorithmIdentifier>::Params
Algorithm parameters.
Source§impl<P> Clone for EncapsulationKey<P>where
P: KemParams + Clone,
impl<P> Clone for EncapsulationKey<P>where
P: KemParams + Clone,
Source§fn clone(&self) -> EncapsulationKey<P>
fn clone(&self) -> EncapsulationKey<P>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<P> Debug for EncapsulationKey<P>where
P: KemParams + Debug,
impl<P> Debug for EncapsulationKey<P>where
P: KemParams + Debug,
Source§impl<P> Encapsulate for EncapsulationKey<P>where
P: Kem + KemParams,
impl<P> Encapsulate for EncapsulationKey<P>where
P: Kem + KemParams,
Source§fn encapsulate_with_rng<R>(&self, rng: &mut R) -> (Ciphertext<P>, SharedKey)
fn encapsulate_with_rng<R>(&self, rng: &mut R) -> (Ciphertext<P>, SharedKey)
Encapsulates a fresh
SharedKey generated using the supplied random number
generator R.Source§fn encapsulate(
&self,
) -> (Array<u8, <Self::Kem as Kem>::CiphertextSize>, Array<u8, <Self::Kem as Kem>::SharedKeySize>)
fn encapsulate( &self, ) -> (Array<u8, <Self::Kem as Kem>::CiphertextSize>, Array<u8, <Self::Kem as Kem>::SharedKeySize>)
Available on crate feature
getrandom only.Encapsulate a fresh shared secret generated using the system’s secure RNG.
Source§impl<P> EncodePublicKey for EncapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
Available on crate features pkcs8 and alloc only.
impl<P> EncodePublicKey for EncapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
Available on crate features
pkcs8 and alloc only.Source§fn to_public_key_der(&self) -> Result<Document>
fn to_public_key_der(&self) -> Result<Document>
Serialize the given EncapsulationKey into DER format.
Returns a Document which wraps the DER document in case of success.
Source§fn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String, Error>
fn to_public_key_pem(&self, line_ending: LineEnding) -> Result<String, Error>
Available on crate feature
pem only.Serialize this public key as PEM-encoded SPKI with the given
LineEnding. Read moreSource§impl<P> KeyExport for EncapsulationKey<P>where
P: KemParams,
impl<P> KeyExport for EncapsulationKey<P>where
P: KemParams,
Source§impl<P> KeySizeUser for EncapsulationKey<P>where
P: KemParams,
impl<P> KeySizeUser for EncapsulationKey<P>where
P: KemParams,
Source§impl<P> PartialEq for EncapsulationKey<P>where
P: KemParams,
impl<P> PartialEq for EncapsulationKey<P>where
P: KemParams,
Source§impl<P> TryFrom<SubjectPublicKeyInfo<AnyRef<'_>, BitStringRef<'_>>> for EncapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
Available on crate feature pkcs8 only.
impl<P> TryFrom<SubjectPublicKeyInfo<AnyRef<'_>, BitStringRef<'_>>> for EncapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
Available on crate feature
pkcs8 only.Source§impl<P> TryKeyInit for EncapsulationKey<P>where
P: KemParams,
impl<P> TryKeyInit for EncapsulationKey<P>where
P: KemParams,
Source§fn new(encapsulation_key: &Key<Self>) -> Result<Self, InvalidKey>
fn new(encapsulation_key: &Key<Self>) -> Result<Self, InvalidKey>
Create new value from a fixed-size key. Read more
Source§fn new_from_slice(key: &[u8]) -> Result<Self, InvalidKey>
fn new_from_slice(key: &[u8]) -> Result<Self, InvalidKey>
Create new value from a variable size key. Read more
impl<P> Eq for EncapsulationKey<P>where
P: KemParams,
Auto Trait Implementations§
impl<P> Freeze for EncapsulationKey<P>
impl<P> RefUnwindSafe for EncapsulationKey<P>
impl<P> Send for EncapsulationKey<P>
impl<P> Sync for EncapsulationKey<P>
impl<P> Unpin for EncapsulationKey<P>
impl<P> UnsafeUnpin for EncapsulationKey<P>
impl<P> UnwindSafe for EncapsulationKey<P>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DecodePublicKey for T
impl<T> DecodePublicKey for T
Source§impl<T> DynAssociatedAlgorithmIdentifier for Twhere
T: AssociatedAlgorithmIdentifier,
impl<T> DynAssociatedAlgorithmIdentifier for Twhere
T: AssociatedAlgorithmIdentifier,
Source§fn algorithm_identifier(&self) -> Result<AlgorithmIdentifier<Any>, Error>
fn algorithm_identifier(&self) -> Result<AlgorithmIdentifier<Any>, Error>
AlgorithmIdentifier for this structure. Read more