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
This commit is contained in:
JohnE 2026-11-16 03:46:46 -05:00
parent ec3db2efac
commit 6e8f51d23f
5 changed files with 86 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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());
}

View File

@ -54,7 +54,10 @@ pub fn generate_keypair(algo: KemAlgorithm) -> Result<KemKeyPair, CryptoError> {
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<KemEncapResu
KemAlgorithm::ClassicMcEliece460896f => 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),
}
}

View File

@ -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());
}

View File

@ -26,8 +26,10 @@ pub fn generate_keypair(algo: KemAlgorithm) -> Result<KemKeyPair, CryptoError> {
)),
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(),
)),
}
}