OLD | NEW |
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 Loading... |
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 // If parameters are being set for the first time, we should create new SRTP | 177 CreateSrtpSessions(); |
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 | |
188 send_session_->SetEncryptedHeaderExtensionIds( | 178 send_session_->SetEncryptedHeaderExtensionIds( |
189 send_encrypted_header_extension_ids_); | 179 send_encrypted_header_extension_ids_); |
190 if (external_auth_enabled_) { | 180 if (external_auth_enabled_) { |
191 send_session_->EnableExternalAuth(); | 181 send_session_->EnableExternalAuth(); |
192 } | 182 } |
193 bool ret = new_sessions | 183 if (!send_session_->SetSend(send_cs, send_key, send_key_len)) { |
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) { | |
197 ResetParams(); | 184 ResetParams(); |
198 return false; | 185 return false; |
199 } | 186 } |
200 | 187 |
201 recv_session_->SetEncryptedHeaderExtensionIds( | 188 recv_session_->SetEncryptedHeaderExtensionIds( |
202 recv_encrypted_header_extension_ids_); | 189 recv_encrypted_header_extension_ids_); |
203 ret = new_sessions | 190 if (!recv_session_->SetRecv(recv_cs, recv_key, recv_key_len)) { |
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) { | |
207 ResetParams(); | 191 ResetParams(); |
208 return false; | 192 return false; |
209 } | 193 } |
210 | 194 |
211 LOG(LS_INFO) << "SRTP " << (new_sessions ? "updated" : "activated") | 195 LOG(LS_INFO) << "SRTP activated with negotiated parameters:" |
212 << " with negotiated parameters:" | |
213 << " send cipher_suite " << send_cs << " recv cipher_suite " | 196 << " send cipher_suite " << send_cs << " recv cipher_suite " |
214 << recv_cs; | 197 << recv_cs; |
215 return true; | 198 return true; |
216 } | 199 } |
217 | 200 |
218 bool SrtpTransport::SetRtcpParams(int send_cs, | 201 bool SrtpTransport::SetRtcpParams(int send_cs, |
219 const uint8_t* send_key, | 202 const uint8_t* send_key, |
220 int send_key_len, | 203 int send_key_len, |
221 int recv_cs, | 204 int recv_cs, |
222 const uint8_t* recv_key, | 205 const uint8_t* recv_key, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 if (!IsActive()) { | 355 if (!IsActive()) { |
373 LOG(LS_WARNING) << "Failed to check IsExternalAuthActive: SRTP not active"; | 356 LOG(LS_WARNING) << "Failed to check IsExternalAuthActive: SRTP not active"; |
374 return false; | 357 return false; |
375 } | 358 } |
376 | 359 |
377 RTC_CHECK(send_session_); | 360 RTC_CHECK(send_session_); |
378 return send_session_->IsExternalAuthActive(); | 361 return send_session_->IsExternalAuthActive(); |
379 } | 362 } |
380 | 363 |
381 } // namespace webrtc | 364 } // namespace webrtc |
OLD | NEW |