Skip to content

Commit

Permalink
Add missing k256 kat_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Aug 13, 2024
1 parent 1c14d38 commit 04fe179
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/kat_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::{
aead::{Aead, AesGcm128, AesGcm256, ChaCha20Poly1305, ExportOnlyAead},
kdf::{HkdfSha256, HkdfSha384, HkdfSha512, Kdf as KdfTrait},
kem::{
self, DhP256HkdfSha256, DhP384HkdfSha384, DhP521HkdfSha512, Kem as KemTrait, SharedSecret,
X25519HkdfSha256,
self, DhK256HkdfSha256, DhP256HkdfSha256, DhP384HkdfSha384, DhP521HkdfSha512,
Kem as KemTrait, SharedSecret, X25519HkdfSha256,
},
op_mode::{OpModeR, PskBundle},
setup::setup_receiver,
Expand Down Expand Up @@ -88,6 +88,18 @@ impl TestableKem for DhP521HkdfSha512 {
}
}

impl TestableKem for DhK256HkdfSha256 {
type EphemeralKey = <DhK256HkdfSha256 as KemTrait>::PrivateKey;

fn encap_with_eph(
pk_recip: &Self::PublicKey,
sender_id_keypair: Option<(&Self::PrivateKey, &Self::PublicKey)>,
sk_eph: Self::EphemeralKey,
) -> Result<(SharedSecret<Self>, Self::EncappedKey), HpkeError> {
kem::dhk256_hkdfsha256::encap_with_eph(pk_recip, sender_id_keypair, sk_eph)
}
}

/// Asserts that the given serializable values are equal
macro_rules! assert_serializable_eq {
($a:expr, $b:expr, $args:tt) => {
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ pub(crate) use alloc::vec::Vec;
feature = "x25519",
feature = "p256",
feature = "p384",
feature = "p521"
feature = "p521",
feature = "k256"
))]
mod kat_tests;

Expand Down

0 comments on commit 04fe179

Please sign in to comment.