From 1c6645643d90cd724de9ffc43b33d0c51edc2eb3 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Thu, 30 Oct 2025 12:05:14 -0600 Subject: [PATCH] kem: add `KeyInit` support to `Decapsulator` This notably provides a common way to initialize KEM decapsulation keys along with a common way to do key generation --- Cargo.lock | 1 + kem/Cargo.toml | 1 + kem/src/lib.rs | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index c89e68ae7..4ffdcafcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -306,6 +306,7 @@ dependencies = [ name = "kem" version = "0.4.0-pre.0" dependencies = [ + "crypto-common", "rand_core", "zeroize", ] diff --git a/kem/Cargo.toml b/kem/Cargo.toml index d9920cb9b..29edabe65 100644 --- a/kem/Cargo.toml +++ b/kem/Cargo.toml @@ -13,6 +13,7 @@ categories = ["cryptography", "no-std"] description = "Traits for key encapsulation mechanisms" [dependencies] +crypto-common = { version = "0.2.0-rc.4", features = ["rand_core"], path = "../crypto-common" } rand_core = "0.9" zeroize = { version = "1.7", default-features = false } diff --git a/kem/src/lib.rs b/kem/src/lib.rs index efa26965d..96b6ddfba 100644 --- a/kem/src/lib.rs +++ b/kem/src/lib.rs @@ -8,6 +8,8 @@ #![forbid(unsafe_code)] #![warn(missing_docs, unused_qualifications, missing_debug_implementations)] +pub use crypto_common::{KeyInit, KeySizeUser}; + use core::fmt::Debug; use rand_core::TryCryptoRng; @@ -26,7 +28,7 @@ pub trait Encapsulate { /// /// Often, this will just be a secret key. But, as with [`Encapsulate`], it can be a bundle /// of secret keys, or it can include a sender's private key for authenticated encapsulation. -pub trait Decapsulate { +pub trait Decapsulate: KeyInit { /// Decapsulation error type Error: Debug;