Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Unified Diff: webrtc/pc/channel.cc

Issue 1528843005: Add support for GCM cipher suites from RFC 7714. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Disable GCM if ENABLE_EXTERNAL_AUTH is defined. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/pc/channel.h ('k') | webrtc/pc/channel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/pc/channel.cc
diff --git a/webrtc/pc/channel.cc b/webrtc/pc/channel.cc
index c1909a2829c8f5a810d75a6c321fe8386bfdd6e1..081600fc9d0899a4fc9660dfc74136356452d87b 100644
--- a/webrtc/pc/channel.cc
+++ b/webrtc/pc/channel.cc
@@ -555,6 +555,11 @@ int BaseChannel::SetOption_n(SocketType type,
return channel ? channel->SetOption(opt, value) : -1;
}
+bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) {
+ crypto_options_ = crypto_options;
+ return true;
+}
+
void BaseChannel::OnWritableState(TransportChannel* channel) {
RTC_DCHECK(channel == transport_channel_ ||
channel == rtcp_transport_channel_);
@@ -964,7 +969,7 @@ bool BaseChannel::SetDtlsSrtpCryptoSuites_n(TransportChannel* tc, bool rtcp) {
if (!rtcp) {
GetSrtpCryptoSuites_n(&crypto_suites);
} else {
- GetDefaultSrtpCryptoSuites(&crypto_suites);
+ GetDefaultSrtpCryptoSuites(crypto_options(), &crypto_suites);
}
return tc->SetSrtpCryptoSuites(crypto_suites);
}
@@ -996,9 +1001,16 @@ bool BaseChannel::SetupDtlsSrtp_n(bool rtcp_channel) {
<< content_name() << " "
<< PacketType(rtcp_channel);
+ int key_len;
+ int salt_len;
+ if (!rtc::GetSrtpKeyAndSaltLengths(selected_crypto_suite, &key_len,
+ &salt_len)) {
+ LOG(LS_ERROR) << "Unknown DTLS-SRTP crypto suite" << selected_crypto_suite;
+ return false;
+ }
+
// OK, we're now doing DTLS (RFC 5764)
- std::vector<unsigned char> dtls_buffer(SRTP_MASTER_KEY_KEY_LEN * 2 +
- SRTP_MASTER_KEY_SALT_LEN * 2);
+ std::vector<unsigned char> dtls_buffer(key_len * 2 + salt_len * 2);
// RFC 5705 exporter using the RFC 5764 parameters
if (!channel->ExportKeyingMaterial(
@@ -1011,22 +1023,16 @@ bool BaseChannel::SetupDtlsSrtp_n(bool rtcp_channel) {
}
// Sync up the keys with the DTLS-SRTP interface
- std::vector<unsigned char> client_write_key(SRTP_MASTER_KEY_KEY_LEN +
- SRTP_MASTER_KEY_SALT_LEN);
- std::vector<unsigned char> server_write_key(SRTP_MASTER_KEY_KEY_LEN +
- SRTP_MASTER_KEY_SALT_LEN);
+ std::vector<unsigned char> client_write_key(key_len + salt_len);
+ std::vector<unsigned char> server_write_key(key_len + salt_len);
size_t offset = 0;
- memcpy(&client_write_key[0], &dtls_buffer[offset],
- SRTP_MASTER_KEY_KEY_LEN);
- offset += SRTP_MASTER_KEY_KEY_LEN;
- memcpy(&server_write_key[0], &dtls_buffer[offset],
- SRTP_MASTER_KEY_KEY_LEN);
- offset += SRTP_MASTER_KEY_KEY_LEN;
- memcpy(&client_write_key[SRTP_MASTER_KEY_KEY_LEN],
- &dtls_buffer[offset], SRTP_MASTER_KEY_SALT_LEN);
- offset += SRTP_MASTER_KEY_SALT_LEN;
- memcpy(&server_write_key[SRTP_MASTER_KEY_KEY_LEN],
- &dtls_buffer[offset], SRTP_MASTER_KEY_SALT_LEN);
+ memcpy(&client_write_key[0], &dtls_buffer[offset], key_len);
+ offset += key_len;
+ memcpy(&server_write_key[0], &dtls_buffer[offset], key_len);
+ offset += key_len;
+ memcpy(&client_write_key[key_len], &dtls_buffer[offset], salt_len);
+ offset += salt_len;
+ memcpy(&server_write_key[key_len], &dtls_buffer[offset], salt_len);
std::vector<unsigned char> *send_key, *recv_key;
rtc::SSLRole role;
@@ -1846,7 +1852,7 @@ void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor,
void VoiceChannel::GetSrtpCryptoSuites_n(
std::vector<int>* crypto_suites) const {
- GetSupportedAudioCryptoSuites(crypto_suites);
+ GetSupportedAudioCryptoSuites(crypto_options(), crypto_suites);
}
VideoChannel::VideoChannel(rtc::Thread* worker_thread,
@@ -2107,7 +2113,7 @@ void VideoChannel::OnMediaMonitorUpdate(
void VideoChannel::GetSrtpCryptoSuites_n(
std::vector<int>* crypto_suites) const {
- GetSupportedVideoCryptoSuites(crypto_suites);
+ GetSupportedVideoCryptoSuites(crypto_options(), crypto_suites);
}
DataChannel::DataChannel(rtc::Thread* worker_thread,
@@ -2420,7 +2426,7 @@ void DataChannel::OnDataChannelReadyToSend(bool writable) {
}
void DataChannel::GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const {
- GetSupportedDataCryptoSuites(crypto_suites);
+ GetSupportedDataCryptoSuites(crypto_options(), crypto_suites);
}
bool DataChannel::ShouldSetupDtlsSrtp_n() const {
« no previous file with comments | « webrtc/pc/channel.h ('k') | webrtc/pc/channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698