#[repr(u32)]pub enum MLKEM {
MLKEM512 = 512,
MLKEM768 = 768,
MLKEM1024 = 1_024,
}Expand description
Security levels for the ML-KEM post-quantum key encapsulation mechanism.
ML-KEM (Module Lattice-based Key Encapsulation Mechanism) is a post-quantum key encapsulation mechanism standardized by NIST. It provides resistance against attacks from both classical and quantum computers.
Each security level offers different trade-offs between security, performance, and key/ciphertext sizes:
MLKEM512: NIST security level 1 (roughly equivalent to AES-128)MLKEM768: NIST security level 3 (roughly equivalent to AES-192)MLKEM1024: NIST security level 5 (roughly equivalent to AES-256)
The numeric values (512, 768, 1024) correspond to the parameter sets and are used in CBOR serialization.
Variants§
MLKEM512 = 512
ML-KEM-512 (NIST security level 1, roughly equivalent to AES-128)
MLKEM768 = 768
ML-KEM-768 (NIST security level 3, roughly equivalent to AES-192)
MLKEM1024 = 1_024
ML-KEM-1024 (NIST security level 5, roughly equivalent to AES-256)
Implementations§
Source§impl MLKEM
impl MLKEM
Sourcepub const SHARED_SECRET_SIZE: usize = 32usize
pub const SHARED_SECRET_SIZE: usize = 32usize
The size of a shared secret in bytes (32 bytes for all security levels).
Sourcepub fn keypair(self) -> (MLKEMPrivateKey, MLKEMPublicKey)
pub fn keypair(self) -> (MLKEMPrivateKey, MLKEMPublicKey)
Sourcepub fn private_key_size(&self) -> usize
pub fn private_key_size(&self) -> usize
Returns the size of a private key in bytes for this security level.
§Returns
MLKEM512: 1632 bytesMLKEM768: 2400 bytesMLKEM1024: 3168 bytes
Sourcepub fn public_key_size(&self) -> usize
pub fn public_key_size(&self) -> usize
Returns the size of a public key in bytes for this security level.
§Returns
MLKEM512: 800 bytesMLKEM768: 1184 bytesMLKEM1024: 1568 bytes
Returns the size of a shared secret in bytes for this security level.
This is 32 bytes for all security levels.
Sourcepub fn ciphertext_size(&self) -> usize
pub fn ciphertext_size(&self) -> usize
Returns the size of a ciphertext in bytes for this security level.
§Returns
MLKEM512: 768 bytesMLKEM768: 1088 bytesMLKEM1024: 1568 bytes
Trait Implementations§
impl Copy for MLKEM
impl Eq for MLKEM
impl StructuralPartialEq for MLKEM
Auto Trait Implementations§
impl Freeze for MLKEM
impl RefUnwindSafe for MLKEM
impl Send for MLKEM
impl Sync for MLKEM
impl Unpin for MLKEM
impl UnwindSafe for MLKEM
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CBOREncodable for T
impl<T> CBOREncodable for T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)