pub struct HybridPublicKeyEncryption { /* private fields */ }
Expand description
ML-KEM/AES Hybrid Public Key Encryption system
Provides the missing public key encryption capability using ML-KEM for key encapsulation and AES-256-GCM for symmetric encryption.
Implementations§
Source§impl HybridPublicKeyEncryption
impl HybridPublicKeyEncryption
Sourcepub fn encrypt(
&self,
recipient_public_key: &MlKemPublicKey,
plaintext: &[u8],
associated_data: &[u8],
) -> PqcResult<EncryptedMessage>
pub fn encrypt( &self, recipient_public_key: &MlKemPublicKey, plaintext: &[u8], associated_data: &[u8], ) -> PqcResult<EncryptedMessage>
Encrypt data using ML-KEM/AES hybrid scheme
§Arguments
recipient_public_key
- ML-KEM public key of the recipientplaintext
- Data to encryptassociated_data
- Additional authenticated data (AAD)
§Returns
Encrypted message containing ML-KEM ciphertext and AES-GCM ciphertext
§Security
- Uses ML-KEM-768 for quantum-resistant key encapsulation
- Derives AES key using HKDF-SHA256 with proper salt and info
- AES-256-GCM provides confidentiality and authenticity
- Associated data is authenticated but not encrypted
Sourcepub fn decrypt(
&self,
private_key: &MlKemSecretKey,
encrypted_message: &EncryptedMessage,
associated_data: &[u8],
) -> PqcResult<Vec<u8>>
pub fn decrypt( &self, private_key: &MlKemSecretKey, encrypted_message: &EncryptedMessage, associated_data: &[u8], ) -> PqcResult<Vec<u8>>
Decrypt data using ML-KEM/AES hybrid scheme
§Arguments
private_key
- ML-KEM secret key for decapsulationencrypted_message
- Encrypted message to decryptassociated_data
- Associated authenticated data (must match encryption)
§Returns
Decrypted plaintext data
§Security
- Verifies associated data integrity before decryption
- Uses constant-time operations where possible
- Properly handles authentication failures
Sourcepub fn clear_key_cache(&mut self)
pub fn clear_key_cache(&mut self)
Clear sensitive key cache (should be called periodically)
Sourcepub const fn algorithm_name() -> &'static str
pub const fn algorithm_name() -> &'static str
Get the algorithm identifier
Sourcepub const fn security_level() -> &'static str
pub const fn security_level() -> &'static str
Get the security level description
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HybridPublicKeyEncryption
impl RefUnwindSafe for HybridPublicKeyEncryption
impl Send for HybridPublicKeyEncryption
impl Sync for HybridPublicKeyEncryption
impl Unpin for HybridPublicKeyEncryption
impl UnwindSafe for HybridPublicKeyEncryption
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