| Index: talk/session/media/srtpfilter.cc
|
| diff --git a/talk/session/media/srtpfilter.cc b/talk/session/media/srtpfilter.cc
|
| index a200a3c4c2c798dd6e834ed4c05213ed78d28229..9f5755d4b3b583f7a1c86ff49e7be19b4e0ff46e 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,
|
| @@ -677,20 +673,35 @@ bool SrtpSession::SetKey(int type, int cs, const uint8_t* key, int len) {
|
|
|
| srtp_policy_t policy;
|
| memset(&policy, 0, sizeof(policy));
|
| -
|
| 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);
|
| } 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
|
| + } 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);
|
| + } 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);
|
| } else {
|
| LOG(LS_WARNING) << "Failed to create SRTP session: unsupported"
|
| << " cipher_suite " << cs;
|
| return false;
|
| }
|
|
|
| - if (!key || len != SRTP_MASTER_KEY_LEN) {
|
| + int expected_key_len;
|
| + int expected_salt_len;
|
| + if (!rtc::GetSrtpKeyAndSaltLengths(cs, &expected_key_len,
|
| + &expected_salt_len)) {
|
| + // This should never happen.
|
| + LOG(LS_WARNING) << "Failed to create SRTP session: unsupported"
|
| + << " cipher_suite without length information" << cs;
|
| + return false;
|
| + }
|
| +
|
| + if (!key || len != (expected_key_len + expected_salt_len)) {
|
| LOG(LS_WARNING) << "Failed to create SRTP session: invalid key";
|
| return false;
|
| }
|
| @@ -720,7 +731,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;
|
|
|