DecapsulationKey

Struct DecapsulationKey 

Source
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,

Source

pub fn from_seed(seed: Seed) -> Self

Create a DecapsulationKey instance from a 64-byte random seed value.

Source

pub fn to_seed(&self) -> Option<Seed>

Serialize the Seed value: 64-bytes which can be used to reconstruct the DecapsulationKey.

§⚠️Warning!

This value is key material. Please treat it with care.

§Returns
Source

pub fn encapsulation_key(&self) -> &EncapsulationKey<P>

Get the EncapsulationKey which corresponds to this DecapsulationKey.

Trait Implementations§

Source§

impl<P> AssociatedAlgorithmIdentifier for DecapsulationKey<P>
where P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,

Available on crate feature pkcs8 only.
Source§

const ALGORITHM_IDENTIFIER: AlgorithmIdentifier<Self::Params> = P::ALGORITHM_IDENTIFIER

AlgorithmIdentifier for this structure.
Source§

type Params = <P as AssociatedAlgorithmIdentifier>::Params

Algorithm parameters.
Source§

impl<P> Clone for DecapsulationKey<P>
where P: KemParams + Clone,

Source§

fn clone(&self) -> DecapsulationKey<P>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P> Debug for DecapsulationKey<P>
where P: KemParams + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P> Decapsulate<Array<u8, <P as PkeParams>::CiphertextSize>, Array<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>> for DecapsulationKey<P>
where P: KemParams,

Source§

type Encapsulator = EncapsulationKey<P>

Encapsulator which corresponds to this decapsulator.
Source§

type Error = Infallible

Decapsulation error
Source§

fn decapsulate( &self, encapsulated_key: &Array<u8, <P as PkeParams>::CiphertextSize>, ) -> Result<B32, Self::Error>

Decapsulates the given encapsulated key
Source§

fn encapsulator(&self) -> EncapsulationKey<P>

Retrieve the encapsulator associated with this decapsulator.
Source§

impl<P> Drop for DecapsulationKey<P>
where P: KemParams,

Available on crate feature zeroize only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<P> EncodePrivateKey for DecapsulationKey<P>
where P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,

Available on crate features pkcs8 and alloc only.
Source§

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>

Serialize this private key as PEM-encoded PKCS#8 with the given LineEnding.
Source§

impl<P> EncodedSizeUser for DecapsulationKey<P>
where P: KemParams,

Source§

type EncodedSize = <P as KemParams>::DecapsulationKeySize

The size of an encoded object
Source§

fn from_bytes(enc: &Encoded<Self>) -> Self

Parse an object from its encoded form
Source§

fn as_bytes(&self) -> Encoded<Self>

Serialize an object to its encoded form
Source§

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§

fn from(seed: Seed) -> Self

Converts to this type from the input type.
Source§

impl<P> KeyInit for DecapsulationKey<P>
where P: KemParams,

Source§

fn new(seed: &Seed) -> Self

Create new value from fixed size key.
Source§

fn weak_key_test(_key: &Array<u8, Self::KeySize>) -> Result<(), WeakKeyError>

Check if the key might be considered weak.
Source§

fn new_checked(key: &Array<u8, Self::KeySize>) -> Result<Self, WeakKeyError>

Create new value from fixed size key after checking it for weakness.
Source§

fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>

Create new value from variable size key.
Source§

fn generate_key_with_rng<R>(rng: &mut R) -> Array<u8, Self::KeySize>
where R: CryptoRng + ?Sized,

Generate random key using the provided CryptoRng.
Source§

fn try_generate_key_with_rng<R>( rng: &mut R, ) -> Result<Array<u8, Self::KeySize>, <R as TryRngCore>::Error>
where R: TryCryptoRng + ?Sized,

Generate random key using the provided TryCryptoRng.
Source§

impl<P> KeySizeUser for DecapsulationKey<P>
where P: KemParams,

Source§

type KeySize = UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>

Key size in bytes.
Source§

fn key_size() -> usize

Return key size in bytes.
Source§

impl<P> PartialEq for DecapsulationKey<P>
where P: KemParams,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P> TryFrom<PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>> for DecapsulationKey<P>
where P: KemParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,

Available on crate feature pkcs8 only.
Source§

fn try_from( private_key_info_ref: PrivateKeyInfoRef<'_>, ) -> Result<Self, Self::Error>

Deserialize the decapsulation key from DER format found in spki.private_key. Returns a DecapsulationKey containing dk_{pke}, ek, and z in case of success.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

impl<P> ZeroizeOnDrop for DecapsulationKey<P>
where P: KemParams,

Available on crate feature zeroize only.

Auto Trait Implementations§

§

impl<P> Freeze for DecapsulationKey<P>
where <<P as ParameterSet>::K as ArraySize>::ArrayType<NttPolynomial>: Freeze,

§

impl<P> RefUnwindSafe for DecapsulationKey<P>
where <<P as ParameterSet>::K as ArraySize>::ArrayType<NttPolynomial>: RefUnwindSafe,

§

impl<P> Send for DecapsulationKey<P>

§

impl<P> Sync for DecapsulationKey<P>

§

impl<P> Unpin for DecapsulationKey<P>
where <<P as ParameterSet>::K as ArraySize>::ArrayType<NttPolynomial>: Unpin,

§

impl<P> UnwindSafe for DecapsulationKey<P>
where <<P as ParameterSet>::K as ArraySize>::ArrayType<NttPolynomial>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DecodePrivateKey for T
where T: for<'a> TryFrom<PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>>, Error = Error>,

Source§

fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>

Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format).
Source§

fn from_pkcs8_pem(s: &str) -> Result<Self, Error>

Deserialize PKCS#8-encoded private key from PEM. Read more
Source§

impl<T> DynAssociatedAlgorithmIdentifier for T

Source§

fn algorithm_identifier(&self) -> Result<AlgorithmIdentifier<Any>, Error>

AlgorithmIdentifier for this structure.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.