pub struct EncapsulationKey<P>where
P: KemParams,{
ek_pke: MaybeBox<EncryptionKey<P>>,
h: B32,
}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.
Fields§
§ek_pke: MaybeBox<EncryptionKey<P>>§h: B32Implementations§
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(crate) fn from_encryption_key(ek_pke: EncryptionKey<P>) -> Self
pub(crate) fn from_encryption_key(ek_pke: EncryptionKey<P>) -> Self
Convert from an EncryptionKey.
Sourcepub(crate) fn ek_pke(&self) -> &EncryptionKey<P>
pub(crate) fn ek_pke(&self) -> &EncryptionKey<P>
Borrow the encryption key.
Trait Implementations§
Source§impl<P> AssociatedAlgorithmIdentifier for EncapsulationKey<P>
impl<P> AssociatedAlgorithmIdentifier for EncapsulationKey<P>
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>
impl<P> Clone for EncapsulationKey<P>
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>
impl<P> Debug for EncapsulationKey<P>
Source§impl<P> Encapsulate for EncapsulationKey<P>
impl<P> Encapsulate for EncapsulationKey<P>
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>)
Encapsulate a fresh shared secret generated using the system’s secure RNG.
Source§impl<P> EncodePublicKey for EncapsulationKey<P>
Available on crate feature alloc only.
impl<P> EncodePublicKey for EncapsulationKey<P>
Available on crate feature
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>
Serialize this public key as PEM-encoded SPKI with the given
LineEnding. Read moreSource§fn write_public_key_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
fn write_public_key_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Write ASN.1 DER-encoded public key to the given path. Read more
Source§fn write_public_key_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding,
) -> Result<(), Error>
fn write_public_key_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>
Write ASN.1 PEM-encoded public key to the given path. Read more
Source§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>
impl<P> TryFrom<SubjectPublicKeyInfo<AnyRef<'_>, BitStringRef<'_>>> for EncapsulationKey<P>
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§fn from_public_key_der(bytes: &[u8]) -> Result<T, Error>
fn from_public_key_der(bytes: &[u8]) -> Result<T, Error>
Deserialize object from ASN.1 DER-encoded [
SubjectPublicKeyInfo]
(binary format). Read moreSource§fn from_public_key_pem(s: &str) -> Result<Self, Error>
fn from_public_key_pem(s: &str) -> Result<Self, Error>
Deserialize PEM-encoded [
SubjectPublicKeyInfo]. Read moreSource§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