use openmls_traits::types::AeadType;
use tls_codec::{TlsDeserialize, TlsSerialize, TlsSize};
#[derive(Debug, Clone, PartialEq, Copy, TlsDeserialize, TlsSerialize, TlsSize)]
#[repr(u8)]
#[allow(non_camel_case_types)]
pub enum LongTermSecretCiphersuite {
PANDA10_AES128GCM = 0x01,
PANDA10_AES256GCM = 0x02,
PANDA10_CHACHA20POLY1305 = 0x03,
}
impl Default for LongTermSecretCiphersuite {
fn default() -> Self {
Self::PANDA10_AES256GCM
}
}
impl LongTermSecretCiphersuite {
pub fn supported_ciphersuites() -> Vec<LongTermSecretCiphersuite> {
vec![
LongTermSecretCiphersuite::PANDA10_AES128GCM,
LongTermSecretCiphersuite::PANDA10_AES256GCM,
LongTermSecretCiphersuite::PANDA10_CHACHA20POLY1305,
]
}
pub fn aead_key_length(&self) -> usize {
match self {
LongTermSecretCiphersuite::PANDA10_AES128GCM => 16,
LongTermSecretCiphersuite::PANDA10_AES256GCM => 32,
LongTermSecretCiphersuite::PANDA10_CHACHA20POLY1305 => 32,
}
}
pub fn aead_nonce_length(&self) -> usize {
match self {
LongTermSecretCiphersuite::PANDA10_AES128GCM
| LongTermSecretCiphersuite::PANDA10_AES256GCM
| LongTermSecretCiphersuite::PANDA10_CHACHA20POLY1305 => 12,
}
}
pub(crate) fn mls_aead_type(&self) -> AeadType {
match self {
LongTermSecretCiphersuite::PANDA10_AES128GCM => AeadType::Aes128Gcm,
LongTermSecretCiphersuite::PANDA10_AES256GCM => AeadType::Aes256Gcm,
LongTermSecretCiphersuite::PANDA10_CHACHA20POLY1305 => AeadType::ChaCha20Poly1305,
}
}
}