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