rtc_srtp/
protection_profile.rs1#[derive(Default, Debug, Clone, Copy)]
3#[repr(u8)]
4pub enum ProtectionProfile {
5 #[default]
6 Aes128CmHmacSha1_80 = 0x0001,
10 Aes128CmHmacSha1_32 = 0x0002,
13 Aes256CmHmacSha1_80 = 0x0003,
15 Aes256CmHmacSha1_32 = 0x0004,
17 AeadAes128Gcm = 0x0007,
20 AeadAes256Gcm = 0x0008,
22}
23
24impl ProtectionProfile {
25 pub fn key_len(&self) -> usize {
27 match *self {
28 ProtectionProfile::Aes128CmHmacSha1_32
29 | ProtectionProfile::Aes128CmHmacSha1_80
30 | ProtectionProfile::AeadAes128Gcm => 16,
31 ProtectionProfile::Aes256CmHmacSha1_32 | ProtectionProfile::Aes256CmHmacSha1_80 => 32,
32 ProtectionProfile::AeadAes256Gcm => 32,
33 }
34 }
35
36 pub fn salt_len(&self) -> usize {
38 match *self {
39 ProtectionProfile::Aes128CmHmacSha1_32
40 | ProtectionProfile::Aes128CmHmacSha1_80
41 | ProtectionProfile::Aes256CmHmacSha1_32
42 | ProtectionProfile::Aes256CmHmacSha1_80 => 14,
43 ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 12,
44 }
45 }
46
47 pub fn rtp_auth_tag_len(&self) -> usize {
49 match *self {
50 ProtectionProfile::Aes128CmHmacSha1_80 | ProtectionProfile::Aes256CmHmacSha1_80 => 10,
51 ProtectionProfile::Aes128CmHmacSha1_32 | ProtectionProfile::Aes256CmHmacSha1_32 => 4,
52 ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 0,
53 }
54 }
55
56 pub fn rtcp_auth_tag_len(&self) -> usize {
58 match *self {
59 ProtectionProfile::Aes128CmHmacSha1_80
60 | ProtectionProfile::Aes128CmHmacSha1_32
61 | ProtectionProfile::Aes256CmHmacSha1_80
62 | ProtectionProfile::Aes256CmHmacSha1_32 => 10,
63 ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 0,
64 }
65 }
66
67 pub fn aead_auth_tag_len(&self) -> usize {
69 match *self {
70 ProtectionProfile::Aes128CmHmacSha1_80
71 | ProtectionProfile::Aes128CmHmacSha1_32
72 | ProtectionProfile::Aes256CmHmacSha1_80
73 | ProtectionProfile::Aes256CmHmacSha1_32 => 0,
74 ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 16,
75 }
76 }
77
78 pub fn auth_key_len(&self) -> usize {
81 match *self {
82 ProtectionProfile::Aes128CmHmacSha1_80
83 | ProtectionProfile::Aes128CmHmacSha1_32
84 | ProtectionProfile::Aes256CmHmacSha1_80
85 | ProtectionProfile::Aes256CmHmacSha1_32 => 20,
86 ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 0,
87 }
88 }
89}