pub struct DecapsulationKey<P>where
P: KemParams,{ /* private fields */ }Expand description
A DecapsulationKey provides the ability to generate a new key pair, and decapsulate an
encapsulated shared key.
Implementations§
Source§impl<P> DecapsulationKey<P>where
P: KemParams,
impl<P> DecapsulationKey<P>where
P: KemParams,
Sourcepub fn from_seed(seed: Seed) -> Self
pub fn from_seed(seed: Seed) -> Self
Create a DecapsulationKey instance from a 64-byte random seed value.
Sourcepub fn from_expanded(
enc: &ExpandedDecapsulationKey<P>,
) -> Result<Self, InvalidKey>
👎Deprecated since 0.3.0: use DecapsulationKey::from_seed instead
pub fn from_expanded( enc: &ExpandedDecapsulationKey<P>, ) -> Result<Self, InvalidKey>
use DecapsulationKey::from_seed instead
Initialize a DecapsulationKey from the serialized expanded key form.
Note that this form is deprecated in practice; prefer to use
DecapsulationKey::from_seed. See ExpandedKeyEncoding for more information.
§Errors
- Returns
InvalidKeyin the event the expanded key failed validation
Sourcepub fn to_seed(&self) -> Option<Seed>
pub fn to_seed(&self) -> Option<Seed>
Serialize the Seed value: 64-bytes which can be used to reconstruct the
DecapsulationKey.
This value is key material. Please treat it with care.
§Returns
Someif theDecapsulationKeywas initialized usingfrom_seedorgenerate.Noneif theDecapsulationKeywas initialized from the expanded form.
Sourcepub fn encapsulation_key(&self) -> &EncapsulationKey<P>
pub fn encapsulation_key(&self) -> &EncapsulationKey<P>
Get the EncapsulationKey which corresponds to this DecapsulationKey.
Trait Implementations§
Source§impl<P> ExpandedKeyEncoding for DecapsulationKey<P>where
P: KemParams,
impl<P> ExpandedKeyEncoding for DecapsulationKey<P>where
P: KemParams,
Source§type EncodedSize = <P as KemParams>::DecapsulationKeySize
type EncodedSize = <P as KemParams>::DecapsulationKeySize
use DecapsulationKey::from_seed instead
Source§fn from_expanded_bytes(
expanded: &ExpandedDecapsulationKey<P>,
) -> Result<Self, InvalidKey>
fn from_expanded_bytes( expanded: &ExpandedDecapsulationKey<P>, ) -> Result<Self, InvalidKey>
use DecapsulationKey::from_seed instead
DecapsulationKey from its legacy expanded form. Read moreSource§fn to_expanded_bytes(&self) -> ExpandedDecapsulationKey<P>
fn to_expanded_bytes(&self) -> ExpandedDecapsulationKey<P>
use DecapsulationKey::from_seed instead
DecapsulationKey to its legacy expanded form.Source§impl<P> AssociatedAlgorithmIdentifier for DecapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
Available on crate feature pkcs8 only.
impl<P> AssociatedAlgorithmIdentifier for DecapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
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
Source§impl<P> Clone for DecapsulationKey<P>where
P: KemParams + Clone,
impl<P> Clone for DecapsulationKey<P>where
P: KemParams + Clone,
Source§fn clone(&self) -> DecapsulationKey<P>
fn clone(&self) -> DecapsulationKey<P>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<P> Debug for DecapsulationKey<P>where
P: KemParams + Debug,
impl<P> Debug for DecapsulationKey<P>where
P: KemParams + Debug,
Source§impl<P> Decapsulate for DecapsulationKey<P>
impl<P> Decapsulate for DecapsulationKey<P>
Source§fn decapsulate(&self, encapsulated_key: &Ciphertext<P>) -> SharedKey
fn decapsulate(&self, encapsulated_key: &Ciphertext<P>) -> SharedKey
Ciphertext a.k.a. “encapsulated key”.Source§fn decapsulate_slice(
&self,
ct: &[u8],
) -> Result<Array<u8, <Self::Kem as Kem>::SharedKeySize>, TryFromSliceError>
fn decapsulate_slice( &self, ct: &[u8], ) -> Result<Array<u8, <Self::Kem as Kem>::SharedKeySize>, TryFromSliceError>
Ciphertext a.k.a. “encapsulated key”. Read moreSource§impl<P> Decapsulator for DecapsulationKey<P>
impl<P> Decapsulator for DecapsulationKey<P>
Source§fn encapsulation_key(&self) -> &EncapsulationKey<P>
fn encapsulation_key(&self) -> &EncapsulationKey<P>
Source§impl<P> Drop for DecapsulationKey<P>where
P: KemParams,
Available on crate feature zeroize only.
impl<P> Drop for DecapsulationKey<P>where
P: KemParams,
zeroize only.Source§impl<P> EncodePrivateKey for DecapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
Available on crate features pkcs8 and alloc only.
impl<P> EncodePrivateKey for DecapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
pkcs8 and alloc only.Source§fn to_pkcs8_der(&self) -> Result<SecretDocument>
fn to_pkcs8_der(&self) -> Result<SecretDocument>
Serialize the given DecapsulationKey into DER format.
Returns a SecretDocument which wraps the DER document in case of success.
Source§fn to_pkcs8_pem(
&self,
line_ending: LineEnding,
) -> Result<Zeroizing<String>, Error>
fn to_pkcs8_pem( &self, line_ending: LineEnding, ) -> Result<Zeroizing<String>, Error>
pem only.LineEnding. Read moreSource§impl<P> From<Array<u8, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for DecapsulationKey<P>where
P: KemParams,
impl<P> From<Array<u8, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for DecapsulationKey<P>where
P: KemParams,
Source§impl<P> Generate for DecapsulationKey<P>where
P: KemParams,
impl<P> Generate for DecapsulationKey<P>where
P: KemParams,
Source§fn try_generate_from_rng<R>(rng: &mut R) -> Result<Self, <R as TryRng>::Error>where
R: TryCryptoRng + ?Sized,
fn try_generate_from_rng<R>(rng: &mut R) -> Result<Self, <R as TryRng>::Error>where
R: TryCryptoRng + ?Sized,
TryCryptoRng. Read moreSource§fn generate_from_rng<R>(rng: &mut R) -> Self
fn generate_from_rng<R>(rng: &mut R) -> Self
CryptoRng.Source§impl<P> KeyExport for DecapsulationKey<P>where
P: KemParams,
Serialize the 64-byte Seed value used to initialize this DecapsulationKey.
impl<P> KeyExport for DecapsulationKey<P>where
P: KemParams,
Serialize the 64-byte Seed value used to initialize this DecapsulationKey.
§Panics
If this DecapsulationKey was initialized using legacy expanded key support
(see ExpandedKeyEncoding).
Source§impl<P> KeyInit for DecapsulationKey<P>where
P: KemParams,
Initialize DecapsulationKey from a 64-byte uniformly random Seed value.
impl<P> KeyInit for DecapsulationKey<P>where
P: KemParams,
Initialize DecapsulationKey from a 64-byte uniformly random Seed value.
Source§fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
Source§impl<P> KeySizeUser for DecapsulationKey<P>where
P: KemParams,
impl<P> KeySizeUser for DecapsulationKey<P>where
P: KemParams,
Source§impl<P> PartialEq for DecapsulationKey<P>where
P: KemParams,
impl<P> PartialEq for DecapsulationKey<P>where
P: KemParams,
Source§impl<P> TryFrom<PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>> for DecapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
Available on crate feature pkcs8 only.
impl<P> TryFrom<PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>> for DecapsulationKey<P>where
P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
pkcs8 only.impl<P> ZeroizeOnDrop for DecapsulationKey<P>where
P: KemParams,
zeroize only.Auto Trait Implementations§
impl<P> Freeze for DecapsulationKey<P>
impl<P> RefUnwindSafe for DecapsulationKey<P>
impl<P> Send for DecapsulationKey<P>
impl<P> Sync for DecapsulationKey<P>
impl<P> Unpin for DecapsulationKey<P>
impl<P> UnsafeUnpin for DecapsulationKey<P>
impl<P> UnwindSafe for DecapsulationKey<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DecodePrivateKey for Twhere
T: for<'a> TryFrom<PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>>, Error = Error>,
impl<T> DecodePrivateKey for Twhere
T: for<'a> TryFrom<PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>>, Error = Error>,
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 moreSource§impl<D> TryDecapsulate for Dwhere
D: Decapsulate + Decapsulator,
impl<D> TryDecapsulate for Dwhere
D: Decapsulate + Decapsulator,
Source§type Error = Infallible
type Error = Infallible
Source§fn try_decapsulate(
&self,
ct: &Array<u8, <<D as Decapsulator>::Kem as Kem>::CiphertextSize>,
) -> Result<Array<u8, <<D as Decapsulator>::Kem as Kem>::SharedKeySize>, Infallible>
fn try_decapsulate( &self, ct: &Array<u8, <<D as Decapsulator>::Kem as Kem>::CiphertextSize>, ) -> Result<Array<u8, <<D as Decapsulator>::Kem as Kem>::SharedKeySize>, Infallible>
Ciphertext a.k.a. “encapsulated key”.Source§fn try_decapsulate_slice(
&self,
ct: &[u8],
) -> Result<Array<u8, <Self::Kem as Kem>::SharedKeySize>, Self::Error>
fn try_decapsulate_slice( &self, ct: &[u8], ) -> Result<Array<u8, <Self::Kem as Kem>::SharedKeySize>, Self::Error>
Ciphertext a.k.a. “encapsulated key”. Read more