diff --git a/benches/benches.rs b/benches/benches.rs index 5a30904..3f7c34f 100644 --- a/benches/benches.rs +++ b/benches/benches.rs @@ -224,6 +224,11 @@ pub fn benches() { hpke::kdf::HkdfSha256, hpke::kem::X25519HkdfSha256, >("Non-NIST[seclevel=128]", &mut c); + + #[cfg(feature = "secp")] + bench_ciphersuite::( + "secp", &mut c, + ); } criterion_main!(benches); diff --git a/src/aead.rs b/src/aead.rs index ba4a6b9..2c334b0 100644 --- a/src/aead.rs +++ b/src/aead.rs @@ -794,6 +794,35 @@ mod test { ); } + #[cfg(all(feature = "secp", any(feature = "alloc", feature = "std")))] + mod secp_tests { + use super::*; + + test_export_idempotence!(test_export_idempotence_k256, crate::kem::DhP256HkdfSha256); + test_exportonly_panics!( + test_exportonly_panics_k256_seal, + test_exportonly_panics_k256_open, + crate::kem::DhK256HkdfSha256 + ); + test_overflow!(test_overflow_k256, crate::kem::DhK256HkdfSha256); + + test_ctx_correctness!( + test_ctx_correctness_aes128_k256, + AesGcm128, + crate::kem::DhK256HkdfSha256 + ); + test_ctx_correctness!( + test_ctx_correctness_aes256_k256, + AesGcm256, + crate::kem::DhK256HkdfSha256 + ); + test_ctx_correctness!( + test_ctx_correctness_chacha_k256, + ChaCha20Poly1305, + crate::kem::DhK256HkdfSha256 + ); + } + /// Tests that Serialize::write_exact() panics when given a buffer of incorrect length #[should_panic] #[test] diff --git a/src/lib.rs b/src/lib.rs index 6704ac4..9ee14a8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,19 +8,19 @@ //! //! ``` //! # #[cfg(any(feature = "alloc", feature = "std"))] { -//! # #[cfg(feature = "x25519")] +//! # #[cfg(feature = "secp")] //! # { //! # use rand::{rngs::StdRng, SeedableRng}; //! # use hpke::{ //! # aead::ChaCha20Poly1305, -//! # kdf::HkdfSha384, -//! # kem::X25519HkdfSha256, +//! # kdf::HkdfSha256, +//! # kem::SecpK256HkdfSha256, //! # Kem as KemTrait, OpModeR, OpModeS, setup_receiver, setup_sender, //! # }; //! // These types define the ciphersuite Alice and Bob will be using -//! type Kem = X25519HkdfSha256; +//! type Kem = SecpK256HkdfSha256; //! type Aead = ChaCha20Poly1305; -//! type Kdf = HkdfSha384; +//! type Kdf = HkdfSha256; //! //! let mut csprng = StdRng::from_entropy(); //! # let (bob_sk, bob_pk) = Kem::gen_keypair(&mut csprng);