Allow configuration of the authentication algorithm used in rfc3711

Only one algorithm is currently implemented. This is mainly for
future-proofing.
dtls-srtp
Jonas Herzig 2018-11-08 13:58:48 +01:00
parent 5ac9928255
commit 2cce4ef3bb
1 changed files with 14 additions and 0 deletions

View File

@ -24,6 +24,16 @@ impl Default for EncryptionAlgorithm {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AuthenticationAlgorithm {
HmacSha1,
}
impl Default for AuthenticationAlgorithm {
fn default() -> Self {
AuthenticationAlgorithm::HmacSha1
}
}
// https://tools.ietf.org/html/rfc3711#section-3.2
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SrtpContext {
@ -33,6 +43,7 @@ pub struct SrtpContext {
pub rollover_counter: u32,
pub highest_recv_seq_num: u16,
pub encryption: EncryptionAlgorithm,
pub authentication: AuthenticationAlgorithm,
pub replay_list: SplaySet<PacketIndex>,
pub session_encr_key: Vec<u8>,
pub session_salt_key: Vec<u8>,
@ -48,6 +59,7 @@ impl SrtpContext {
rollover_counter: 0,
highest_recv_seq_num: 0,
encryption: EncryptionAlgorithm::default(),
authentication: AuthenticationAlgorithm::default(),
replay_list: SplaySet::new(),
session_encr_key: vec![0; 128 / 8],
session_salt_key: vec![0; 112 / 8],
@ -127,6 +139,7 @@ pub struct SrtcpContext {
pub master_salt: Vec<u8>,
pub highest_recv_index: PacketIndex, // NOTE: 47-bits
pub encryption: EncryptionAlgorithm,
pub authentication: AuthenticationAlgorithm,
pub replay_list: SplaySet<PacketIndex>,
pub session_encr_key: Vec<u8>,
pub session_salt_key: Vec<u8>,
@ -141,6 +154,7 @@ impl SrtcpContext {
master_salt: Vec::from(master_salt),
highest_recv_index: 0,
encryption: EncryptionAlgorithm::default(),
authentication: AuthenticationAlgorithm::default(),
replay_list: SplaySet::new(),
session_encr_key: vec![0; 128 / 8],
session_salt_key: vec![0; 112 / 8],