core: add Classic McEliece 460896f KEM ID

Ultra U2 uses the f variant for steady keygen; ID 54 stays as is.
Providers report it as not compiled until they implement it.

Refs: R3-9
This commit is contained in:
JohnE 2026-11-16 03:42:55 -05:00
parent 92c75616ef
commit 3e0481901c
5 changed files with 46 additions and 7 deletions

View File

@ -319,6 +319,10 @@ pub enum KemAlgorithm {
ClassicMcEliece460896 = 54,
/// X-Wing hybrid KEM (ML-KEM-768 + X25519), the LGP receive and ingest key.
XWing = 55,
/// Classic McEliece 460896f (NIST level 3, "f" key generation), the Ultra
/// conservative KEM layer (U2). Same key and ciphertext format as 460896;
/// the "f" variant only makes key generation steady.
ClassicMcEliece460896f = 56,
}
impl KemAlgorithm {
@ -331,6 +335,7 @@ impl KemAlgorithm {
53 => Some(Self::MlKem1024),
54 => Some(Self::ClassicMcEliece460896),
55 => Some(Self::XWing),
56 => Some(Self::ClassicMcEliece460896f),
_ => None,
}
}
@ -344,6 +349,23 @@ impl KemAlgorithm {
Self::MlKem1024 => "ML-KEM-1024",
Self::ClassicMcEliece460896 => "Classic-McEliece-460896",
Self::XWing => "X-Wing",
Self::ClassicMcEliece460896f => "Classic-McEliece-460896f",
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn mceliece_ids_are_distinct() {
let f = KemAlgorithm::from_u32(56).unwrap();
assert_eq!(f, KemAlgorithm::ClassicMcEliece460896f);
assert_eq!(f.name(), "Classic-McEliece-460896f");
assert_eq!(
KemAlgorithm::from_u32(54),
Some(KemAlgorithm::ClassicMcEliece460896)
);
}
}

View File

@ -143,7 +143,11 @@ pub fn probe_capabilities(
// Key generation and encapsulation are randomised.
caps = caps.with_kem(algo, cap(ok, false, 80));
}
for algo in [KemAlgorithm::X448, KemAlgorithm::ClassicMcEliece460896] {
for algo in [
KemAlgorithm::X448,
KemAlgorithm::ClassicMcEliece460896,
KemAlgorithm::ClassicMcEliece460896f,
] {
caps = caps.with_kem(algo, AlgorithmCapability::unavailable());
}
caps

View File

@ -48,7 +48,9 @@ pub fn generate_keypair(algo: KemAlgorithm) -> Result<KemKeyPair, CryptoError> {
private_key: seed.to_vec(),
})
}
KemAlgorithm::X448 | KemAlgorithm::ClassicMcEliece460896 => not_compiled(algo),
KemAlgorithm::X448
| KemAlgorithm::ClassicMcEliece460896
| KemAlgorithm::ClassicMcEliece460896f => not_compiled(algo),
}
}
@ -62,7 +64,9 @@ pub fn encapsulate(algo: KemAlgorithm, public_key: &[u8]) -> Result<KemEncapResu
KemAlgorithm::MlKem768 => mlkem768::encapsulate_deterministic(public_key, &*random()?),
KemAlgorithm::MlKem1024 => mlkem1024::encapsulate_deterministic(public_key, &*random()?),
KemAlgorithm::XWing => xwing_encapsulate_deterministic(public_key, &*random()?),
KemAlgorithm::X448 | KemAlgorithm::ClassicMcEliece460896 => not_compiled(algo),
KemAlgorithm::X448
| KemAlgorithm::ClassicMcEliece460896
| KemAlgorithm::ClassicMcEliece460896f => not_compiled(algo),
}
}
@ -77,7 +81,9 @@ pub fn decapsulate(
KemAlgorithm::MlKem768 => mlkem768::decapsulate(private_key, ciphertext),
KemAlgorithm::MlKem1024 => mlkem1024::decapsulate(private_key, ciphertext),
KemAlgorithm::XWing => xwing_decapsulate(private_key, ciphertext),
KemAlgorithm::X448 | KemAlgorithm::ClassicMcEliece460896 => not_compiled(algo),
KemAlgorithm::X448
| KemAlgorithm::ClassicMcEliece460896
| KemAlgorithm::ClassicMcEliece460896f => not_compiled(algo),
}
}

View File

@ -174,6 +174,7 @@ pub fn probe_capabilities(benchmarks: Option<&BenchmarkReport>) -> ProviderCapab
KemAlgorithm::MlKem768,
KemAlgorithm::MlKem1024,
KemAlgorithm::ClassicMcEliece460896,
KemAlgorithm::ClassicMcEliece460896f,
] {
caps = caps.with_kem(algo, AlgorithmCapability::unavailable());
}

View File

@ -24,7 +24,9 @@ pub fn generate_keypair(algo: KemAlgorithm) -> Result<KemKeyPair, CryptoError> {
KemAlgorithm::MlKem768 | KemAlgorithm::MlKem1024 => Err(CryptoError::FeatureNotCompiled(
"ML-KEM is deferred to Phase 5 (requires wolfSSL PQ build)".into(),
)),
KemAlgorithm::ClassicMcEliece460896 | KemAlgorithm::XWing => Err(CryptoError::FeatureNotCompiled(
KemAlgorithm::ClassicMcEliece460896
| KemAlgorithm::ClassicMcEliece460896f
| KemAlgorithm::XWing => Err(CryptoError::FeatureNotCompiled(
"Classic-McEliece is deferred to Phase 5".into(),
)),
}
@ -46,7 +48,9 @@ pub fn encapsulate(
KemAlgorithm::MlKem768 | KemAlgorithm::MlKem1024 => Err(CryptoError::FeatureNotCompiled(
"ML-KEM is deferred to Phase 5".into(),
)),
KemAlgorithm::ClassicMcEliece460896 | KemAlgorithm::XWing => Err(CryptoError::FeatureNotCompiled(
KemAlgorithm::ClassicMcEliece460896
| KemAlgorithm::ClassicMcEliece460896f
| KemAlgorithm::XWing => Err(CryptoError::FeatureNotCompiled(
"Classic-McEliece is deferred to Phase 5".into(),
)),
}
@ -65,7 +69,9 @@ pub fn decapsulate(
KemAlgorithm::MlKem768 | KemAlgorithm::MlKem1024 => Err(CryptoError::FeatureNotCompiled(
"ML-KEM is deferred to Phase 5".into(),
)),
KemAlgorithm::ClassicMcEliece460896 | KemAlgorithm::XWing => Err(CryptoError::FeatureNotCompiled(
KemAlgorithm::ClassicMcEliece460896
| KemAlgorithm::ClassicMcEliece460896f
| KemAlgorithm::XWing => Err(CryptoError::FeatureNotCompiled(
"Classic-McEliece is deferred to Phase 5".into(),
)),
}