OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 if (!dtls_->SetPeerCertificateDigest( | 260 if (!dtls_->SetPeerCertificateDigest( |
261 remote_fingerprint_algorithm_, | 261 remote_fingerprint_algorithm_, |
262 reinterpret_cast<unsigned char*>(remote_fingerprint_value_.data()), | 262 reinterpret_cast<unsigned char*>(remote_fingerprint_value_.data()), |
263 remote_fingerprint_value_.size())) { | 263 remote_fingerprint_value_.size())) { |
264 LOG_J(LS_ERROR, this) << "Couldn't set DTLS certificate digest."; | 264 LOG_J(LS_ERROR, this) << "Couldn't set DTLS certificate digest."; |
265 return false; | 265 return false; |
266 } | 266 } |
267 | 267 |
268 // Set up DTLS-SRTP, if it's been enabled. | 268 // Set up DTLS-SRTP, if it's been enabled. |
269 if (!srtp_ciphers_.empty()) { | 269 if (!srtp_ciphers_.empty()) { |
270 if (!dtls_->SetDtlsSrtpCryptoSuites(srtp_ciphers_)) { | 270 if (!dtls_->SetDtlsSrtpCiphers(srtp_ciphers_)) { |
271 LOG_J(LS_ERROR, this) << "Couldn't set DTLS-SRTP ciphers."; | 271 LOG_J(LS_ERROR, this) << "Couldn't set DTLS-SRTP ciphers."; |
272 return false; | 272 return false; |
273 } | 273 } |
274 } else { | 274 } else { |
275 LOG_J(LS_INFO, this) << "Not using DTLS-SRTP."; | 275 LOG_J(LS_INFO, this) << "Not using DTLS-SRTP."; |
276 } | 276 } |
277 | 277 |
278 LOG_J(LS_INFO, this) << "DTLS setup complete."; | 278 LOG_J(LS_INFO, this) << "DTLS setup complete."; |
279 return true; | 279 return true; |
280 } | 280 } |
281 | 281 |
282 bool DtlsTransportChannelWrapper::SetSrtpCryptoSuites( | 282 bool DtlsTransportChannelWrapper::SetSrtpCiphers( |
283 const std::vector<int>& ciphers) { | 283 const std::vector<std::string>& ciphers) { |
284 if (srtp_ciphers_ == ciphers) | 284 if (srtp_ciphers_ == ciphers) { |
285 return true; | 285 return true; |
| 286 } |
286 | 287 |
287 if (dtls_state() == DTLS_TRANSPORT_CONNECTING) { | 288 if (dtls_state() == DTLS_TRANSPORT_CONNECTING) { |
288 LOG(LS_WARNING) << "Ignoring new SRTP ciphers while DTLS is negotiating"; | 289 LOG(LS_WARNING) << "Ignoring new SRTP ciphers while DTLS is negotiating"; |
289 return true; | 290 return true; |
290 } | 291 } |
291 | 292 |
292 if (dtls_state() == DTLS_TRANSPORT_CONNECTED) { | 293 if (dtls_state() == DTLS_TRANSPORT_CONNECTED) { |
293 // We don't support DTLS renegotiation currently. If new set of srtp ciphers | 294 // We don't support DTLS renegotiation currently. If new set of srtp ciphers |
294 // are different than what's being used currently, we will not use it. | 295 // are different than what's being used currently, we will not use it. |
295 // So for now, let's be happy (or sad) with a warning message. | 296 // So for now, let's be happy (or sad) with a warning message. |
296 int current_srtp_cipher; | 297 std::string current_srtp_cipher; |
297 if (!dtls_->GetDtlsSrtpCryptoSuite(¤t_srtp_cipher)) { | 298 if (!dtls_->GetDtlsSrtpCipher(¤t_srtp_cipher)) { |
298 LOG(LS_ERROR) << "Failed to get the current SRTP cipher for DTLS channel"; | 299 LOG(LS_ERROR) << "Failed to get the current SRTP cipher for DTLS channel"; |
299 return false; | 300 return false; |
300 } | 301 } |
301 const std::vector<int>::const_iterator iter = | 302 const std::vector<std::string>::const_iterator iter = |
302 std::find(ciphers.begin(), ciphers.end(), current_srtp_cipher); | 303 std::find(ciphers.begin(), ciphers.end(), current_srtp_cipher); |
303 if (iter == ciphers.end()) { | 304 if (iter == ciphers.end()) { |
304 std::string requested_str; | 305 std::string requested_str; |
305 for (size_t i = 0; i < ciphers.size(); ++i) { | 306 for (size_t i = 0; i < ciphers.size(); ++i) { |
306 requested_str.append(" "); | 307 requested_str.append(" "); |
307 requested_str.append(rtc::SrtpCryptoSuiteToName(ciphers[i])); | 308 requested_str.append(ciphers[i]); |
308 requested_str.append(" "); | 309 requested_str.append(" "); |
309 } | 310 } |
310 LOG(LS_WARNING) << "Ignoring new set of SRTP ciphers, as DTLS " | 311 LOG(LS_WARNING) << "Ignoring new set of SRTP ciphers, as DTLS " |
311 << "renegotiation is not supported currently " | 312 << "renegotiation is not supported currently " |
312 << "current cipher = " << current_srtp_cipher << " and " | 313 << "current cipher = " << current_srtp_cipher << " and " |
313 << "requested = " << "[" << requested_str << "]"; | 314 << "requested = " << "[" << requested_str << "]"; |
314 } | 315 } |
315 return true; | 316 return true; |
316 } | 317 } |
317 | 318 |
318 if (!VERIFY(dtls_state() == DTLS_TRANSPORT_NEW)) { | 319 if (!VERIFY(dtls_state() == DTLS_TRANSPORT_NEW)) { |
319 return false; | 320 return false; |
320 } | 321 } |
321 | 322 |
322 srtp_ciphers_ = ciphers; | 323 srtp_ciphers_ = ciphers; |
323 return true; | 324 return true; |
324 } | 325 } |
325 | 326 |
326 bool DtlsTransportChannelWrapper::GetSrtpCryptoSuite(int* cipher) { | 327 bool DtlsTransportChannelWrapper::GetSrtpCryptoSuite(std::string* cipher) { |
327 if (dtls_state() != DTLS_TRANSPORT_CONNECTED) { | 328 if (dtls_state() != DTLS_TRANSPORT_CONNECTED) { |
328 return false; | 329 return false; |
329 } | 330 } |
330 | 331 |
331 return dtls_->GetDtlsSrtpCryptoSuite(cipher); | 332 return dtls_->GetDtlsSrtpCipher(cipher); |
332 } | 333 } |
333 | 334 |
334 | 335 |
335 // Called from upper layers to send a media packet. | 336 // Called from upper layers to send a media packet. |
336 int DtlsTransportChannelWrapper::SendPacket( | 337 int DtlsTransportChannelWrapper::SendPacket( |
337 const char* data, size_t size, | 338 const char* data, size_t size, |
338 const rtc::PacketOptions& options, int flags) { | 339 const rtc::PacketOptions& options, int flags) { |
339 if (!dtls_active_) { | 340 if (!dtls_active_) { |
340 // Not doing DTLS. | 341 // Not doing DTLS. |
341 return channel_->SendPacket(data, size, options); | 342 return channel_->SendPacket(data, size, options); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 SignalRouteChange(this, candidate); | 611 SignalRouteChange(this, candidate); |
611 } | 612 } |
612 | 613 |
613 void DtlsTransportChannelWrapper::OnConnectionRemoved( | 614 void DtlsTransportChannelWrapper::OnConnectionRemoved( |
614 TransportChannelImpl* channel) { | 615 TransportChannelImpl* channel) { |
615 ASSERT(channel == channel_); | 616 ASSERT(channel == channel_); |
616 SignalConnectionRemoved(this); | 617 SignalConnectionRemoved(this); |
617 } | 618 } |
618 | 619 |
619 } // namespace cricket | 620 } // namespace cricket |
OLD | NEW |