Skip to content

Conversation

@lbaquerofierro
Copy link
Contributor

Adds safe Rust wrappers around BoringSSL's ML-KEM (FIPS 203) key encapsulation, covering both ML-KEM-768 and ML-KEM-1024 parameter sets.

  • Key generation, encapsulation, and decapsulation
  • Seed-based private key storage and restoration
  • Public key derivation, serialization, and validation
  • Wipes private key material from memory on drop
  • Tests for roundtrip, implicit rejection, debug redaction, and validation

@bwesterb bwesterb changed the title Add safe Rust wrappers for ML-KEM-268 and ML-KEM-1020 Add safe Rust wrappers for ML-KEM-768 and ML-KEM-1024 Jan 28, 2026
@bwesterb bwesterb self-requested a review January 28, 2026 14:14
Copy link
Collaborator

@cjpatton cjpatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to deduplicate this code using traits.

pub trait Kem {
    /// Note: SEED_BYTES and SHARED_SECRET_BYTES are the same for all ML-KEM parameters
    const PUBLIC_KEY_BYTES: usize;
    const CIPHERTEXT_BYTES: usize;
    type PublicKey;
    type PrivateKey;
}

pub trait KemOps: Kem {
    fn generate() -> (Kem::PublicKey, Kem::PrivateKey) { ... }
    fn encapsulate .. 
    fn decapsulate ...
}

Adds safe Rust wrappers around BoringSSL's ML-KEM (FIPS 203) key
encapsulation, covering both ML-KEM-768 and ML-KEM-1024 parameter sets.

- Key generation, encapsulation, and decapsulation
- Seed-based private key storage and restoration
- Public key derivation, serialization, and validation
- Wipes private key material from memory on drop
- Tests for roundtrip, implicit rejection, debug redaction, and validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants