Skip to main content

MlKem1024

Struct MlKem1024 

Source
pub struct MlKem1024;
Expand description

ML-KEM-1024 KEM marker type implementing [quantaegis_core::Kem].

Implementations§

Source§

impl MlKem1024

Source

pub fn keygen_into<R: CryptoRng + ?Sized>( rng: &mut R, ek_out: &mut EncapsulationKey, dk_out: &mut DecapsulationKey, ) -> Result<()>

Generates a fresh key pair directly into caller-owned storage without creating serialized stack copies of the decapsulation key (FIPS 203, Algorithm 19).

Source

pub fn encaps_into<R: CryptoRng + ?Sized>( ek: &EncapsulationKey, rng: &mut R, ct_out: &mut Ciphertext, ss_out: &mut SharedSecret, ) -> Result<()>

Encapsulates directly into caller-owned ct_out and ss_out without leaving an unwiped stack copy of the shared secret (FIPS 203, Algorithm 20).

Source

pub fn decaps_into( dk: &DecapsulationKey, ct: &Ciphertext, ss_out: &mut SharedSecret, ) -> Result<()>

Decapsulates directly into caller-owned ss_out without leaving an unwiped stack copy of the shared secret (FIPS 203, Algorithm 21).

Returns [Error::InvalidDecapsulationKey] if dk is an uninitialized or zeroized placeholder.

Trait Implementations§

Source§

impl Kem for MlKem1024

Source§

fn keygen<R: CryptoRng + ?Sized>( rng: &mut R, ) -> Result<(Self::EncapsulationKey, Self::DecapsulationKey)>

Generates a fresh key pair (FIPS 203, Algorithm 19: ML-KEM.KeyGen()).

Note: returning secret key material by value in safe Rust can leave an unzeroized copy in the callee’s return staging slot; FIPS/zeroization-critical callers should use keygen_into directly into caller-owned storage.

Source§

fn encaps<R: CryptoRng + ?Sized>( ek: &Self::EncapsulationKey, rng: &mut R, ) -> Result<(Self::Ciphertext, Self::SharedSecret)>

Encapsulates a shared secret to ek (FIPS 203, Algorithm 20: ML-KEM.Encaps()).

Note: returning SharedSecret by value in safe Rust can leave an unzeroized copy in the callee’s return staging slot; FIPS/zeroization-critical callers should use encaps_into directly into caller-owned storage.

Source§

fn decaps( dk: &Self::DecapsulationKey, ct: &Self::Ciphertext, ) -> Result<Self::SharedSecret>

Decapsulates ct using dk (FIPS 203, Algorithm 21: ML-KEM.Decaps()).

Note: returning SharedSecret by value in safe Rust can leave an unzeroized copy in the callee’s return staging slot; FIPS/zeroization-critical callers should use decaps_into directly into caller-owned storage.

Source§

type EncapsulationKey = EncapsulationKey

Public encapsulation key type.
Source§

type DecapsulationKey = DecapsulationKey

Private decapsulation key type (must zeroize on drop).
Source§

type Ciphertext = Ciphertext

Encapsulated ciphertext type.
Source§

type SharedSecret = SecretBytes<32>

Established shared secret type (must zeroize on drop).

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.