mod ext;
use spideroak_crypto::{
hash,
hpke::{HpkeAead, HpkeKdf, HpkeKem},
mac,
oid::Identified,
signer,
typenum::U32,
};
pub(crate) use crate::ciphersuite::ext::CipherSuiteExt;
pub use crate::ciphersuite::ext::Oids;
pub trait Aead: HpkeAead + Identified {}
impl<A: HpkeAead + Identified> Aead for A {}
pub trait Hash: hash::Hash + Identified {}
impl<H: hash::Hash + Identified> Hash for H {}
pub trait Kdf: HpkeKdf + Identified {}
impl<K: HpkeKdf + Identified> Kdf for K {}
pub trait Kem: HpkeKem + Identified {}
impl<K: HpkeKem + Identified> Kem for K {}
pub trait Mac: mac::Mac + Identified {}
impl<M: mac::Mac + Identified> Mac for M {}
pub trait Signer: signer::Signer + Identified {}
impl<S: signer::Signer + Identified> Signer for S {}
pub trait CipherSuite {
const OIDS: Oids<Self> = Oids::new();
type Aead: Aead;
type Hash: Hash<DigestSize = U32>;
type Kdf: Kdf;
type Kem: Kem;
type Mac: Mac;
type Signer: Signer;
}
#[cfg(test)]
mod tests {
mod rust {
use spideroak_crypto::{
oid::consts::DHKEM_P256_HKDF_SHA256,
rust::{self, Aes256Gcm, HkdfSha256, HkdfSha384, HmacSha512, P256, P384, Sha256},
};
use crate::{
kem_with_oid,
test_util::{TestCs, test_ciphersuite},
};
kem_with_oid! {
#[derive(Debug)]
struct DhKemP256HkdfSha256(rust::DhKemP256HkdfSha256) => DHKEM_P256_HKDF_SHA256
}
test_ciphersuite!(p256, TestCs<
Aes256Gcm,
Sha256,
HkdfSha256,
DhKemP256HkdfSha256,
HmacSha512,
P256,
>);
test_ciphersuite!(p384, TestCs<
Aes256Gcm,
Sha256,
HkdfSha384,
DhKemP256HkdfSha256, HmacSha512,
P384,
>);
}
}