| Index: talk/session/media/channel.cc
|
| diff --git a/talk/session/media/channel.cc b/talk/session/media/channel.cc
|
| index a59c3f82b771848b79f88fa949e781d77c5f5a07..71c96d74ea2b84bf6dfaa66cb581adb6a8080414 100644
|
| --- a/talk/session/media/channel.cc
|
| +++ b/talk/session/media/channel.cc
|
| @@ -487,6 +487,11 @@ int BaseChannel::SetOption(SocketType type, rtc::Socket::Option opt,
|
| 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) {
|
| ASSERT(channel == transport_channel_ || channel == rtcp_transport_channel_);
|
| UpdateWritableState_w();
|
| @@ -855,9 +860,9 @@ bool BaseChannel::SetDtlsSrtpCryptoSuites(TransportChannel* tc, bool rtcp) {
|
| // We always use the default SRTP crypto suites for RTCP, but we may use
|
| // different crypto suites for RTP depending on the media type.
|
| if (!rtcp) {
|
| - GetSrtpCryptoSuites(&crypto_suites);
|
| + GetSrtpCryptoSuites(crypto_options_, &crypto_suites);
|
| } else {
|
| - GetDefaultSrtpCryptoSuites(&crypto_suites);
|
| + GetDefaultSrtpCryptoSuites(crypto_options_, &crypto_suites);
|
| }
|
| return tc->SetSrtpCryptoSuites(crypto_suites);
|
| }
|
| @@ -888,9 +893,16 @@ bool BaseChannel::SetupDtlsSrtp(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(
|
| @@ -903,22 +915,16 @@ bool BaseChannel::SetupDtlsSrtp(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;
|
| @@ -1636,8 +1642,9 @@ void VoiceChannel::OnAudioMonitorUpdate(AudioMonitor* monitor,
|
| SignalAudioMonitor(this, info);
|
| }
|
|
|
| -void VoiceChannel::GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const {
|
| - GetSupportedAudioCryptoSuites(crypto_suites);
|
| +void VoiceChannel::GetSrtpCryptoSuites(const rtc::CryptoOptions& crypto_options,
|
| + std::vector<int>* crypto_suites) const {
|
| + GetSupportedAudioCryptoSuites(crypto_options, crypto_suites);
|
| }
|
|
|
| VideoChannel::VideoChannel(rtc::Thread* thread,
|
| @@ -2001,8 +2008,9 @@ bool VideoChannel::GetLocalSsrc(const VideoCapturer* capturer, uint32_t* ssrc) {
|
| return false;
|
| }
|
|
|
| -void VideoChannel::GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const {
|
| - GetSupportedVideoCryptoSuites(crypto_suites);
|
| +void VideoChannel::GetSrtpCryptoSuites(const rtc::CryptoOptions& crypto_options,
|
| + std::vector<int>* crypto_suites) const {
|
| + GetSupportedVideoCryptoSuites(crypto_options, crypto_suites);
|
| }
|
|
|
| DataChannel::DataChannel(rtc::Thread* thread,
|
| @@ -2310,8 +2318,9 @@ void DataChannel::OnDataChannelReadyToSend(bool writable) {
|
| new DataChannelReadyToSendMessageData(writable));
|
| }
|
|
|
| -void DataChannel::GetSrtpCryptoSuites(std::vector<int>* crypto_suites) const {
|
| - GetSupportedDataCryptoSuites(crypto_suites);
|
| +void DataChannel::GetSrtpCryptoSuites(const rtc::CryptoOptions& crypto_options,
|
| + std::vector<int>* crypto_suites) const {
|
| + GetSupportedDataCryptoSuites(crypto_options, crypto_suites);
|
| }
|
|
|
| bool DataChannel::ShouldSetupDtlsSrtp() const {
|
|
|