webrtc_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 AeadAes128Gcm = 0x0007,
9 AeadAes256Gcm = 0x0008,
10}
11
12impl ProtectionProfile {
13 pub fn key_len(&self) -> usize {
14 match *self {
15 ProtectionProfile::Aes128CmHmacSha1_32
16 | ProtectionProfile::Aes128CmHmacSha1_80
17 | ProtectionProfile::AeadAes128Gcm => 16,
18 ProtectionProfile::AeadAes256Gcm => 32,
19 }
20 }
21
22 pub fn salt_len(&self) -> usize {
23 match *self {
24 ProtectionProfile::Aes128CmHmacSha1_32 | ProtectionProfile::Aes128CmHmacSha1_80 => 14,
25 ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 12,
26 }
27 }
28
29 pub fn rtp_auth_tag_len(&self) -> usize {
30 match *self {
31 ProtectionProfile::Aes128CmHmacSha1_80 => 10,
32 ProtectionProfile::Aes128CmHmacSha1_32 => 4,
33 ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 0,
34 }
35 }
36
37 pub fn rtcp_auth_tag_len(&self) -> usize {
38 match *self {
39 ProtectionProfile::Aes128CmHmacSha1_80 | ProtectionProfile::Aes128CmHmacSha1_32 => 10,
40 ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 0,
41 }
42 }
43
44 pub fn aead_auth_tag_len(&self) -> usize {
45 match *self {
46 ProtectionProfile::Aes128CmHmacSha1_80 | ProtectionProfile::Aes128CmHmacSha1_32 => 0,
47 ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 16,
48 }
49 }
50
51 pub fn auth_key_len(&self) -> usize {
52 match *self {
53 ProtectionProfile::Aes128CmHmacSha1_80 | ProtectionProfile::Aes128CmHmacSha1_32 => 20,
54 ProtectionProfile::AeadAes128Gcm | ProtectionProfile::AeadAes256Gcm => 0,
55 }
56 }
57}