use std::ops::Deref;
pub struct KeyingMaterial(Vec<u8>);
impl KeyingMaterial {
pub fn new(m: &[u8]) -> Self {
KeyingMaterial(m.to_vec())
}
}
impl Deref for KeyingMaterial {
type Target = [u8];
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl std::fmt::Debug for KeyingMaterial {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "KeyingMaterial")
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(non_camel_case_types)]
#[non_exhaustive]
pub enum SrtpProfile {
AES128_CM_SHA1_80,
AEAD_AES_128_GCM,
AEAD_AES_256_GCM,
}
impl SrtpProfile {
pub const ALL: &'static [SrtpProfile] = &[
SrtpProfile::AEAD_AES_256_GCM,
SrtpProfile::AEAD_AES_128_GCM,
SrtpProfile::AES128_CM_SHA1_80,
];
#[rustfmt::skip]
pub fn keying_material_len(&self) -> usize {
match self {
SrtpProfile::AES128_CM_SHA1_80 => 16 * 2 + 14 * 2,
SrtpProfile::AEAD_AES_128_GCM => 16 * 2 + 12 * 2,
SrtpProfile::AEAD_AES_256_GCM => 32 * 2 + 12 * 2,
}
}
}
impl std::fmt::Display for SrtpProfile {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
SrtpProfile::AES128_CM_SHA1_80 => write!(f, "SRTP_AES128_CM_SHA1_80"),
SrtpProfile::AEAD_AES_128_GCM => write!(f, "SRTP_AEAD_AES_128_GCM"),
SrtpProfile::AEAD_AES_256_GCM => write!(f, "SRTP_AEAD_AES_256_GCM"),
}
}
}