From 6e8f51d23f40bf1827fda1647a26200a70dd41b6 Mon Sep 17 00:00:00 2001 From: JohnE Date: Mon, 16 Nov 2026 03:46:46 -0500 Subject: [PATCH] core: add HQC-192 and FrodoKEM-976 IDs and KEM tiers The oqs provider needs IDs for them, and the policy checks need a tier per KEM like the AEADs have. Refs: R3-5 --- crates/ccc-crypto-core/src/algorithms.rs | 61 +++++++++++++++++++ .../ccc-crypto-rustcrypto/src/capabilities.rs | 2 + crates/ccc-crypto-rustcrypto/src/kem.rs | 15 ++++- crates/ccc-crypto-wolfssl/src/capabilities.rs | 2 + crates/ccc-crypto-wolfssl/src/kem.rs | 12 +++- 5 files changed, 86 insertions(+), 6 deletions(-) diff --git a/crates/ccc-crypto-core/src/algorithms.rs b/crates/ccc-crypto-core/src/algorithms.rs index fb7d65b..b0bc0ac 100644 --- a/crates/ccc-crypto-core/src/algorithms.rs +++ b/crates/ccc-crypto-core/src/algorithms.rs @@ -323,6 +323,11 @@ pub enum KemAlgorithm { /// conservative KEM layer (U2). Same key and ciphertext format as 460896; /// the "f" variant only makes key generation steady. ClassicMcEliece460896f = 56, + /// HQC-192 (code-based, NIST level 3), as liboqs 0.13 implements it (the + /// round-4 submission; FIPS 207 is not final, so the bytes may change). + Hqc192 = 57, + /// FrodoKEM-976-SHAKE (plain LWE, NIST level 3). + FrodoKem976Shake = 58, } impl KemAlgorithm { @@ -336,6 +341,8 @@ impl KemAlgorithm { 54 => Some(Self::ClassicMcEliece460896), 55 => Some(Self::XWing), 56 => Some(Self::ClassicMcEliece460896f), + 57 => Some(Self::Hqc192), + 58 => Some(Self::FrodoKem976Shake), _ => None, } } @@ -350,8 +357,46 @@ impl KemAlgorithm { Self::ClassicMcEliece460896 => "Classic-McEliece-460896", Self::XWing => "X-Wing", Self::ClassicMcEliece460896f => "Classic-McEliece-460896f", + Self::Hqc192 => "HQC-192", + Self::FrodoKem976Shake => "FrodoKEM-976-SHAKE", } } + + /// The algorithm's tier (design: "Algorithm tiers"). + /// + /// - Vetted: X25519 and X448 (RFC 7748), ML-KEM (FIPS 203) and X-Wing, + /// whose two halves are both vetted and whose combiner has a proof. + /// - Conservative: Classic McEliece (code-based, unbroken since 1978 and + /// the Ultra U2 layer) and HQC (code-based, selected by NIST in 2025). + /// Both rest on a different hard problem than ML-KEM, which is the + /// point of an extra KEM layer. + /// - Experimental: FrodoKEM. Its plain-LWE design is conservative, but + /// NIST dropped it after round 3 and the ISO text is not final, so we + /// have no standard to pin its bytes to. It is additive only. + pub fn tier(self) -> Tier { + match self { + Self::X25519 | Self::X448 | Self::MlKem768 | Self::MlKem1024 | Self::XWing => { + Tier::Vetted + } + Self::ClassicMcEliece460896 + | Self::ClassicMcEliece460896f + | Self::Hqc192 => Tier::Conservative, + Self::FrodoKem976Shake => Tier::Experimental, + } + } + + /// Every KEM ID, for capability probes and conformance tests. + pub const ALL: [KemAlgorithm; 9] = [ + Self::X25519, + Self::X448, + Self::MlKem768, + Self::MlKem1024, + Self::ClassicMcEliece460896, + Self::XWing, + Self::ClassicMcEliece460896f, + Self::Hqc192, + Self::FrodoKem976Shake, + ]; } #[cfg(test)] @@ -368,4 +413,20 @@ mod tests { Some(KemAlgorithm::ClassicMcEliece460896) ); } + + #[test] + fn kem_ids_round_trip() { + for algo in KemAlgorithm::ALL { + assert_eq!(KemAlgorithm::from_u32(algo as u32), Some(algo)); + } + assert_eq!(KemAlgorithm::from_u32(59), None); + } + + #[test] + fn kem_tiers() { + assert_eq!(KemAlgorithm::MlKem768.tier(), Tier::Vetted); + assert_eq!(KemAlgorithm::ClassicMcEliece460896f.tier(), Tier::Conservative); + assert_eq!(KemAlgorithm::Hqc192.tier(), Tier::Conservative); + assert_eq!(KemAlgorithm::FrodoKem976Shake.tier(), Tier::Experimental); + } } diff --git a/crates/ccc-crypto-rustcrypto/src/capabilities.rs b/crates/ccc-crypto-rustcrypto/src/capabilities.rs index 56e6799..50cb86f 100644 --- a/crates/ccc-crypto-rustcrypto/src/capabilities.rs +++ b/crates/ccc-crypto-rustcrypto/src/capabilities.rs @@ -155,6 +155,8 @@ pub fn probe_capabilities( KemAlgorithm::ClassicMcEliece460896, #[cfg(not(feature = "mceliece"))] KemAlgorithm::ClassicMcEliece460896f, + KemAlgorithm::Hqc192, + KemAlgorithm::FrodoKem976Shake, ] { caps = caps.with_kem(algo, AlgorithmCapability::unavailable()); } diff --git a/crates/ccc-crypto-rustcrypto/src/kem.rs b/crates/ccc-crypto-rustcrypto/src/kem.rs index d51f666..c431c85 100644 --- a/crates/ccc-crypto-rustcrypto/src/kem.rs +++ b/crates/ccc-crypto-rustcrypto/src/kem.rs @@ -54,7 +54,10 @@ pub fn generate_keypair(algo: KemAlgorithm) -> Result { KemAlgorithm::ClassicMcEliece460896f => crate::mceliece::generate(), #[cfg(not(feature = "mceliece"))] KemAlgorithm::ClassicMcEliece460896f => not_compiled(algo), - KemAlgorithm::X448 | KemAlgorithm::ClassicMcEliece460896 => not_compiled(algo), + KemAlgorithm::X448 + | KemAlgorithm::ClassicMcEliece460896 + | KemAlgorithm::Hqc192 + | KemAlgorithm::FrodoKem976Shake => not_compiled(algo), } } @@ -72,7 +75,10 @@ pub fn encapsulate(algo: KemAlgorithm, public_key: &[u8]) -> Result crate::mceliece::encapsulate(public_key), #[cfg(not(feature = "mceliece"))] KemAlgorithm::ClassicMcEliece460896f => not_compiled(algo), - KemAlgorithm::X448 | KemAlgorithm::ClassicMcEliece460896 => not_compiled(algo), + KemAlgorithm::X448 + | KemAlgorithm::ClassicMcEliece460896 + | KemAlgorithm::Hqc192 + | KemAlgorithm::FrodoKem976Shake => not_compiled(algo), } } @@ -91,7 +97,10 @@ pub fn decapsulate( KemAlgorithm::ClassicMcEliece460896f => crate::mceliece::decapsulate(private_key, ciphertext), #[cfg(not(feature = "mceliece"))] KemAlgorithm::ClassicMcEliece460896f => not_compiled(algo), - KemAlgorithm::X448 | KemAlgorithm::ClassicMcEliece460896 => not_compiled(algo), + KemAlgorithm::X448 + | KemAlgorithm::ClassicMcEliece460896 + | KemAlgorithm::Hqc192 + | KemAlgorithm::FrodoKem976Shake => not_compiled(algo), } } diff --git a/crates/ccc-crypto-wolfssl/src/capabilities.rs b/crates/ccc-crypto-wolfssl/src/capabilities.rs index b078b5c..262daf3 100644 --- a/crates/ccc-crypto-wolfssl/src/capabilities.rs +++ b/crates/ccc-crypto-wolfssl/src/capabilities.rs @@ -175,6 +175,8 @@ pub fn probe_capabilities(benchmarks: Option<&BenchmarkReport>) -> ProviderCapab KemAlgorithm::MlKem1024, KemAlgorithm::ClassicMcEliece460896, KemAlgorithm::ClassicMcEliece460896f, + KemAlgorithm::Hqc192, + KemAlgorithm::FrodoKem976Shake, ] { caps = caps.with_kem(algo, AlgorithmCapability::unavailable()); } diff --git a/crates/ccc-crypto-wolfssl/src/kem.rs b/crates/ccc-crypto-wolfssl/src/kem.rs index 63fcaec..9d1ca19 100644 --- a/crates/ccc-crypto-wolfssl/src/kem.rs +++ b/crates/ccc-crypto-wolfssl/src/kem.rs @@ -26,8 +26,10 @@ pub fn generate_keypair(algo: KemAlgorithm) -> Result { )), KemAlgorithm::ClassicMcEliece460896 | KemAlgorithm::ClassicMcEliece460896f + | KemAlgorithm::Hqc192 + | KemAlgorithm::FrodoKem976Shake | KemAlgorithm::XWing => Err(CryptoError::FeatureNotCompiled( - "Classic-McEliece is deferred to Phase 5".into(), + "Classic-McEliece, HQC, FrodoKEM and X-Wing are not offered by wolfCrypt".into(), )), } } @@ -50,8 +52,10 @@ pub fn encapsulate( )), KemAlgorithm::ClassicMcEliece460896 | KemAlgorithm::ClassicMcEliece460896f + | KemAlgorithm::Hqc192 + | KemAlgorithm::FrodoKem976Shake | KemAlgorithm::XWing => Err(CryptoError::FeatureNotCompiled( - "Classic-McEliece is deferred to Phase 5".into(), + "Classic-McEliece, HQC, FrodoKEM and X-Wing are not offered by wolfCrypt".into(), )), } } @@ -71,8 +75,10 @@ pub fn decapsulate( )), KemAlgorithm::ClassicMcEliece460896 | KemAlgorithm::ClassicMcEliece460896f + | KemAlgorithm::Hqc192 + | KemAlgorithm::FrodoKem976Shake | KemAlgorithm::XWing => Err(CryptoError::FeatureNotCompiled( - "Classic-McEliece is deferred to Phase 5".into(), + "Classic-McEliece, HQC, FrodoKEM and X-Wing are not offered by wolfCrypt".into(), )), } }