Skip to content

Commit 4fbad4a

Browse files
author
yngrtc
committed
add Aes128CmHmacSha1_32 support
1 parent ffaee7f commit 4fbad4a

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

srtp/src/cipher/cipher_aead_aes_gcm.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ impl Cipher for CipherAeadAesGcm {
146146

147147
impl CipherAeadAesGcm {
148148
/// Create a new AEAD instance.
149-
pub(crate) fn new(profile: ProtectionProfile, master_key: &[u8], master_salt: &[u8]) -> Result<CipherAeadAesGcm> {
149+
pub(crate) fn new(
150+
profile: ProtectionProfile,
151+
master_key: &[u8],
152+
master_salt: &[u8],
153+
) -> Result<CipherAeadAesGcm> {
150154
let srtp_session_key = aes_cm_key_derivation(
151155
LABEL_SRTP_ENCRYPTION,
152156
master_key,

srtp/src/cipher/cipher_aes_cm_hmac_sha1/ctrcipher.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ impl Cipher for CipherAesCmHmacSha1 {
205205
let cipher_text = &encrypted[..encrypted_len - self.rtcp_auth_tag_len()];
206206

207207
// Generate the auth tag we expect to see from the ciphertext.
208-
let expected_tag = &self.inner.generate_srtcp_auth_tag(cipher_text)[..self.rtcp_auth_tag_len()];
208+
let expected_tag =
209+
&self.inner.generate_srtcp_auth_tag(cipher_text)[..self.rtcp_auth_tag_len()];
209210

210211
// See if the auth tag actually matches.
211212
// We use a constant time comparison to prevent timing attacks.

srtp/src/cipher/cipher_aes_cm_hmac_sha1/opensslcipher.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ use subtle::ConstantTimeEq;
55
use util::marshal::*;
66

77
use super::{Cipher, CipherInner};
8+
use crate::protection_profile::ProtectionProfile;
89
use crate::{
910
error::{Error, Result},
1011
key_derivation::*,
1112
};
12-
use crate::protection_profile::ProtectionProfile;
1313

1414
pub(crate) struct CipherAesCmHmacSha1 {
1515
inner: CipherInner,
@@ -167,7 +167,8 @@ impl Cipher for CipherAesCmHmacSha1 {
167167
fn encrypt_rtcp(&mut self, decrypted: &[u8], srtcp_index: usize, ssrc: u32) -> Result<Bytes> {
168168
let decrypted_len = decrypted.len();
169169

170-
let mut writer = Vec::with_capacity(decrypted_len + SRTCP_INDEX_SIZE + self.rtcp_auth_tag_len());
170+
let mut writer =
171+
Vec::with_capacity(decrypted_len + SRTCP_INDEX_SIZE + self.rtcp_auth_tag_len());
171172

172173
// Write the decrypted to the destination buffer.
173174
writer.extend_from_slice(&decrypted[..HEADER_LENGTH + SSRC_LENGTH]);
@@ -238,7 +239,8 @@ impl Cipher for CipherAesCmHmacSha1 {
238239
let cipher_text = &encrypted[..encrypted_len - self.rtcp_auth_tag_len()];
239240

240241
// Generate the auth tag we expect to see from the ciphertext.
241-
let expected_tag = &self.inner.generate_srtcp_auth_tag(cipher_text)[..self.rtcp_auth_tag_len()];
242+
let expected_tag =
243+
&self.inner.generate_srtcp_auth_tag(cipher_text)[..self.rtcp_auth_tag_len()];
242244

243245
// See if the auth tag actually matches.
244246
// We use a constant time comparison to prevent timing attacks.

webrtc/src/dtls_transport/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub(crate) fn default_srtp_protection_profiles() -> Vec<SrtpProtectionProfile> {
4646
SrtpProtectionProfile::Srtp_Aead_Aes_128_Gcm,
4747
SrtpProtectionProfile::Srtp_Aead_Aes_256_Gcm,
4848
SrtpProtectionProfile::Srtp_Aes128_Cm_Hmac_Sha1_80,
49+
SrtpProtectionProfile::Srtp_Aes128_Cm_Hmac_Sha1_32,
4950
]
5051
}
5152

@@ -421,6 +422,9 @@ impl RTCDtlsTransport {
421422
dtls::extension::extension_use_srtp::SrtpProtectionProfile::Srtp_Aes128_Cm_Hmac_Sha1_80 => {
422423
srtp::protection_profile::ProtectionProfile::Aes128CmHmacSha1_80
423424
}
425+
dtls::extension::extension_use_srtp::SrtpProtectionProfile::Srtp_Aes128_Cm_Hmac_Sha1_32 => {
426+
srtp::protection_profile::ProtectionProfile::Aes128CmHmacSha1_32
427+
}
424428
_ => {
425429
if let Err(err) = dtls_conn.close().await {
426430
log::error!("{}", err);

0 commit comments

Comments
 (0)