use super::schedule::HashAlg;
use crate::tls::codec::CipherSuite;
#[derive(Copy, Clone, PartialEq, Eq)]
pub(crate) enum AeadAlg {
Aes128Gcm,
Aes256Gcm,
ChaCha20Poly1305,
}
#[derive(Copy, Clone)]
pub(crate) struct SuiteParams {
pub(crate) suite: CipherSuite,
pub(crate) hash: HashAlg,
pub(crate) key_len: usize,
pub(crate) aead: AeadAlg,
}
pub(crate) const SUPPORTED: [SuiteParams; 3] = [
SuiteParams {
suite: CipherSuite::AES_128_GCM_SHA256,
hash: HashAlg::Sha256,
key_len: 16,
aead: AeadAlg::Aes128Gcm,
},
SuiteParams {
suite: CipherSuite::AES_256_GCM_SHA384,
hash: HashAlg::Sha384,
key_len: 32,
aead: AeadAlg::Aes256Gcm,
},
SuiteParams {
suite: CipherSuite::CHACHA20_POLY1305_SHA256,
hash: HashAlg::Sha256,
key_len: 32,
aead: AeadAlg::ChaCha20Poly1305,
},
];
pub(crate) fn lookup(suite: CipherSuite) -> Option<SuiteParams> {
SUPPORTED.iter().copied().find(|s| s.suite == suite)
}
pub(crate) fn supported() -> &'static [SuiteParams] {
&SUPPORTED
}