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

Side by Side Diff: pc/srtptransport.cc

Issue 3019443002: If SRTP sessions exist, don't create new ones when applying answer. (Closed)
Patch Set: Created 3 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 packet->SetSize(len); 167 packet->SetSize(len);
168 SignalPacketReceived(rtcp, packet, packet_time); 168 SignalPacketReceived(rtcp, packet, packet_time);
169 } 169 }
170 170
171 bool SrtpTransport::SetRtpParams(int send_cs, 171 bool SrtpTransport::SetRtpParams(int send_cs,
172 const uint8_t* send_key, 172 const uint8_t* send_key,
173 int send_key_len, 173 int send_key_len,
174 int recv_cs, 174 int recv_cs,
175 const uint8_t* recv_key, 175 const uint8_t* recv_key,
176 int recv_key_len) { 176 int recv_key_len) {
177 CreateSrtpSessions(); 177 // If parameters are being set for the first time, we should create new SRTP
178 // sessions and call "SetSend/SetRecv". Otherwise we should call
179 // "UpdateSend"/"UpdateRecv" on the existing sessions, which will internally
180 // call "srtp_update".
181 bool new_sessions = false;
182 if (!send_session_) {
183 RTC_DCHECK(!recv_session_);
184 CreateSrtpSessions();
185 new_sessions = true;
186 }
187
178 send_session_->SetEncryptedHeaderExtensionIds( 188 send_session_->SetEncryptedHeaderExtensionIds(
179 send_encrypted_header_extension_ids_); 189 send_encrypted_header_extension_ids_);
180 if (external_auth_enabled_) { 190 if (external_auth_enabled_) {
181 send_session_->EnableExternalAuth(); 191 send_session_->EnableExternalAuth();
182 } 192 }
183 if (!send_session_->SetSend(send_cs, send_key, send_key_len)) { 193 bool ret = new_sessions
194 ? send_session_->SetSend(send_cs, send_key, send_key_len)
195 : send_session_->UpdateSend(send_cs, send_key, send_key_len);
196 if (!ret) {
184 ResetParams(); 197 ResetParams();
185 return false; 198 return false;
186 } 199 }
187 200
188 recv_session_->SetEncryptedHeaderExtensionIds( 201 recv_session_->SetEncryptedHeaderExtensionIds(
189 recv_encrypted_header_extension_ids_); 202 recv_encrypted_header_extension_ids_);
190 if (!recv_session_->SetRecv(recv_cs, recv_key, recv_key_len)) { 203 ret = new_sessions
204 ? recv_session_->SetRecv(recv_cs, recv_key, recv_key_len)
205 : recv_session_->UpdateRecv(recv_cs, recv_key, recv_key_len);
206 if (!ret) {
191 ResetParams(); 207 ResetParams();
192 return false; 208 return false;
193 } 209 }
194 210
195 LOG(LS_INFO) << "SRTP activated with negotiated parameters:" 211 LOG(LS_INFO) << "SRTP " << (new_sessions ? "updated" : "activated")
212 << " with negotiated parameters:"
196 << " send cipher_suite " << send_cs << " recv cipher_suite " 213 << " send cipher_suite " << send_cs << " recv cipher_suite "
197 << recv_cs; 214 << recv_cs;
198 return true; 215 return true;
199 } 216 }
200 217
201 bool SrtpTransport::SetRtcpParams(int send_cs, 218 bool SrtpTransport::SetRtcpParams(int send_cs,
202 const uint8_t* send_key, 219 const uint8_t* send_key,
203 int send_key_len, 220 int send_key_len,
204 int recv_cs, 221 int recv_cs,
205 const uint8_t* recv_key, 222 const uint8_t* recv_key,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 if (!IsActive()) { 372 if (!IsActive()) {
356 LOG(LS_WARNING) << "Failed to check IsExternalAuthActive: SRTP not active"; 373 LOG(LS_WARNING) << "Failed to check IsExternalAuthActive: SRTP not active";
357 return false; 374 return false;
358 } 375 }
359 376
360 RTC_CHECK(send_session_); 377 RTC_CHECK(send_session_);
361 return send_session_->IsExternalAuthActive(); 378 return send_session_->IsExternalAuthActive();
362 } 379 }
363 380
364 } // namespace webrtc 381 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698