diff --git a/Cargo.lock b/Cargo.lock index 936ab2f..2100195 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -192,7 +192,7 @@ version = "0.5.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd4ef774202f1749465fc7cf88d70fc30620e8cacd5429268f4bff7d003bd976" dependencies = [ - "crypto-common", + "crypto-common 0.2.0-rc.4 (registry+https://github.com/rust-lang/crates.io-index)", "inout", ] @@ -357,6 +357,15 @@ dependencies = [ "hybrid-array", ] +[[package]] +name = "crypto-common" +version = "0.2.0-rc.4" +source = "git+https://github.com/RustCrypto/traits#0ba3c983654a31077b0f1da3a3233e58f4a2230a" +dependencies = [ + "hybrid-array", + "rand_core", +] + [[package]] name = "cstr_core" version = "0.2.6" @@ -437,7 +446,7 @@ checksum = "dac89f8a64533a9b0eaa73a68e424db0fb1fd6271c74cc0125336a05f090568d" dependencies = [ "block-buffer", "const-oid", - "crypto-common", + "crypto-common 0.2.0-rc.4 (registry+https://github.com/rust-lang/crates.io-index)", "subtle", ] @@ -791,9 +800,9 @@ dependencies = [ [[package]] name = "kem" version = "0.4.0-pre.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ec5336e2804a5746a2cf0575537afae902c0a29e82c542918b4c5adf392456" +source = "git+https://github.com/RustCrypto/traits#0ba3c983654a31077b0f1da3a3233e58f4a2230a" dependencies = [ + "crypto-common 0.2.0-rc.4 (git+https://github.com/RustCrypto/traits)", "rand_core", "zeroize", ] diff --git a/Cargo.toml b/Cargo.toml index c01e6f8..3fbdc81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,3 +12,5 @@ debug = true [patch.crates-io] ml-kem = { path = "./ml-kem" } + +kem = { git = "https://github.com/RustCrypto/traits" } diff --git a/ml-kem/src/kem.rs b/ml-kem/src/kem.rs index 5386467..f63f3e2 100644 --- a/ml-kem/src/kem.rs +++ b/ml-kem/src/kem.rs @@ -1,6 +1,6 @@ use core::convert::Infallible; use core::marker::PhantomData; -use hybrid_array::typenum::U32; +use hybrid_array::typenum::{U32, U64}; use rand_core::{CryptoRng, TryCryptoRng}; use subtle::{ConditionallySelectable, ConstantTimeEq}; @@ -98,6 +98,23 @@ where } } +impl

::kem::KeySizeUser for DecapsulationKey

+where + P: KemParams, +{ + type KeySize = U64; +} + +impl

::kem::KeyInit for DecapsulationKey

+where + P: KemParams, +{ + #[inline] + fn new(seed: &Seed) -> Self { + Self::from_seed(*seed) + } +} + impl

::kem::Decapsulate, SharedKey> for DecapsulationKey

where P: KemParams, diff --git a/x-wing/src/lib.rs b/x-wing/src/lib.rs index 5735ed4..8a6e85a 100644 --- a/x-wing/src/lib.rs +++ b/x-wing/src/lib.rs @@ -29,7 +29,7 @@ pub use kem::{self, Decapsulate, Encapsulate}; use core::convert::Infallible; -use ml_kem::array::ArrayN; +use ml_kem::array::{ArrayN, typenum::consts::U32}; use ml_kem::{B32, EncodedSizeUser, KemCore, MlKem768, MlKem768Params}; use rand_core::{CryptoRng, TryCryptoRng}; #[cfg(feature = "os_rng")] @@ -145,6 +145,16 @@ impl Decapsulate for DecapsulationKey { } } +impl ::kem::KeySizeUser for DecapsulationKey { + type KeySize = U32; +} + +impl ::kem::KeyInit for DecapsulationKey { + fn new(key: &ArrayN) -> Self { + Self { sk: key.0 } + } +} + impl DecapsulationKey { /// Generate a new `DecapsulationKey` using `OsRng`. #[cfg(feature = "os_rng")]