Skip to content

Commit

Permalink
Code golf with HpkeKeypair::test* functions (#3290)
Browse files Browse the repository at this point in the history
  • Loading branch information
inahga committed Jul 9, 2024
1 parent e9d7ee0 commit 22f581b
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions core/src/hpke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,23 +327,18 @@ impl Arbitrary for HpkeCiphersuite {
#[cfg_attr(docsrs, doc(cfg(feature = "test-util")))]
impl HpkeKeypair {
pub fn test() -> Self {
Self::generate(
HpkeConfigId::from(random::<u8>()),
HpkeKemId::X25519HkdfSha256,
HpkeKdfId::HkdfSha256,
HpkeAeadId::Aes128Gcm,
)
.unwrap()
Self::test_with_id(random())
}

pub fn test_with_id(id: u8) -> Self {
Self::generate(
HpkeConfigId::from(id),
HpkeKemId::X25519HkdfSha256,
HpkeKdfId::HkdfSha256,
HpkeAeadId::Aes128Gcm,
Self::test_with_ciphersuite(
id,
HpkeCiphersuite::new(
HpkeKemId::X25519HkdfSha256,
HpkeKdfId::HkdfSha256,
HpkeAeadId::Aes128Gcm,
),
)
.unwrap()
}

pub fn test_with_ciphersuite(id: u8, ciphersuite: HpkeCiphersuite) -> Self {
Expand Down

0 comments on commit 22f581b

Please sign in to comment.