Index: talk/session/media/srtpfilter.cc |
diff --git a/talk/session/media/srtpfilter.cc b/talk/session/media/srtpfilter.cc |
index 4a54740cef2be0433e8f0fda07344f7a49667409..382c644ede2f460ced2966f0508b881f15654548 100644 |
--- a/talk/session/media/srtpfilter.cc |
+++ b/talk/session/media/srtpfilter.cc |
@@ -73,10 +73,6 @@ extern "C" debug_module_t mod_aes_hmac; |
namespace cricket { |
-const int SRTP_MASTER_KEY_BASE64_LEN = SRTP_MASTER_KEY_LEN * 4 / 3; |
-const int SRTP_MASTER_KEY_KEY_LEN = 16; |
-const int SRTP_MASTER_KEY_SALT_LEN = 14; |
- |
#ifndef HAVE_SRTP |
// This helper function is used on systems that don't (yet) have SRTP, |
@@ -674,19 +670,34 @@ bool SrtpSession::SetKey(int type, int cs, const uint8_t* key, int len) { |
srtp_policy_t policy; |
memset(&policy, 0, sizeof(policy)); |
+ int expected_key_len; |
if (cs == rtc::SRTP_AES128_CM_SHA1_80) { |
crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtp); |
crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtcp); |
+ // Master key is 128 bits key + 112 bits salt. |
+ expected_key_len = 16 + 14; |
} else if (cs == rtc::SRTP_AES128_CM_SHA1_32) { |
crypto_policy_set_aes_cm_128_hmac_sha1_32(&policy.rtp); // rtp is 32, |
crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtcp); // rtcp still 80 |
+ // Master key is 128 bits key + 112 bits salt. |
+ expected_key_len = 16 + 14; |
+ } else if (cs == rtc::SRTP_AEAD_AES_128_GCM) { |
+ crypto_policy_set_aes_gcm_128_16_auth(&policy.rtp); |
+ crypto_policy_set_aes_gcm_128_16_auth(&policy.rtcp); |
+ // Master key is 128 bits key + 96 bits salt. |
+ expected_key_len = 16 + 12; |
+ } else if (cs == rtc::SRTP_AEAD_AES_256_GCM) { |
+ crypto_policy_set_aes_gcm_256_16_auth(&policy.rtp); |
+ crypto_policy_set_aes_gcm_256_16_auth(&policy.rtcp); |
+ // Master key is 256 bits key + 96 bits salt. |
+ expected_key_len = 32 + 12; |
pthatcher1
2015/12/18 20:31:32
This seems duplicative with the new SrtpCryptoSuit
joachim
2015/12/19 15:26:23
Right, I wrote that code before adding the new fun
|
} else { |
LOG(LS_WARNING) << "Failed to create SRTP session: unsupported" |
<< " cipher_suite " << cs; |
return false; |
} |
- if (!key || len != SRTP_MASTER_KEY_LEN) { |
+ if (!key || len != expected_key_len) { |
LOG(LS_WARNING) << "Failed to create SRTP session: invalid key"; |
return false; |
} |
@@ -716,7 +727,6 @@ bool SrtpSession::SetKey(int type, int cs, const uint8_t* key, int len) { |
return false; |
} |
- |
rtp_auth_tag_len_ = policy.rtp.auth_tag_len; |
rtcp_auth_tag_len_ = policy.rtcp.auth_tag_len; |
return true; |