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

Side by Side Diff: webrtc/p2p/base/faketransportcontroller.h

Issue 1528843005: Add support for GCM cipher suites from RFC 7714. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added PeerConnection tests using GCM ciphers, fixed passing of flag through DtlsTransportChannel. Created 5 years 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
OLDNEW
1 /* 1 /*
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 return true; 304 return true;
305 } 305 }
306 306
307 void set_ssl_max_protocol_version(rtc::SSLProtocolVersion version) { 307 void set_ssl_max_protocol_version(rtc::SSLProtocolVersion version) {
308 ssl_max_version_ = version; 308 ssl_max_version_ = version;
309 } 309 }
310 rtc::SSLProtocolVersion ssl_max_protocol_version() const { 310 rtc::SSLProtocolVersion ssl_max_protocol_version() const {
311 return ssl_max_version_; 311 return ssl_max_version_;
312 } 312 }
313 313
314 void set_enable_gcm_ciphers(bool enable) {
315 enable_gcm_ciphers_ = enable;
316 }
317 bool IsEnableGcmCiphers() const override {
318 return enable_gcm_ciphers_;
319 }
320
314 private: 321 private:
315 enum State { STATE_INIT, STATE_CONNECTING, STATE_CONNECTED }; 322 enum State { STATE_INIT, STATE_CONNECTING, STATE_CONNECTED };
316 Transport* transport_; 323 Transport* transport_;
317 FakeTransportChannel* dest_ = nullptr; 324 FakeTransportChannel* dest_ = nullptr;
318 State state_ = STATE_INIT; 325 State state_ = STATE_INIT;
319 bool async_ = false; 326 bool async_ = false;
320 Candidates remote_candidates_; 327 Candidates remote_candidates_;
321 rtc::scoped_refptr<rtc::RTCCertificate> local_cert_; 328 rtc::scoped_refptr<rtc::RTCCertificate> local_cert_;
322 rtc::FakeSSLCertificate* remote_cert_ = nullptr; 329 rtc::FakeSSLCertificate* remote_cert_ = nullptr;
323 bool do_dtls_ = false; 330 bool do_dtls_ = false;
324 std::vector<int> srtp_ciphers_; 331 std::vector<int> srtp_ciphers_;
325 int chosen_crypto_suite_ = rtc::SRTP_INVALID_CRYPTO_SUITE; 332 int chosen_crypto_suite_ = rtc::SRTP_INVALID_CRYPTO_SUITE;
326 int receiving_timeout_ = -1; 333 int receiving_timeout_ = -1;
327 bool gather_continually_ = false; 334 bool gather_continually_ = false;
328 IceRole role_ = ICEROLE_UNKNOWN; 335 IceRole role_ = ICEROLE_UNKNOWN;
329 uint64_t tiebreaker_ = 0; 336 uint64_t tiebreaker_ = 0;
330 std::string ice_ufrag_; 337 std::string ice_ufrag_;
331 std::string ice_pwd_; 338 std::string ice_pwd_;
332 std::string remote_ice_ufrag_; 339 std::string remote_ice_ufrag_;
333 std::string remote_ice_pwd_; 340 std::string remote_ice_pwd_;
334 IceMode remote_ice_mode_ = ICEMODE_FULL; 341 IceMode remote_ice_mode_ = ICEMODE_FULL;
335 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_10; 342 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_10;
343 bool enable_gcm_ciphers_ = false;
336 rtc::SSLFingerprint dtls_fingerprint_; 344 rtc::SSLFingerprint dtls_fingerprint_;
337 rtc::SSLRole ssl_role_ = rtc::SSL_CLIENT; 345 rtc::SSLRole ssl_role_ = rtc::SSL_CLIENT;
338 size_t connection_count_ = 0; 346 size_t connection_count_ = 0;
339 IceGatheringState gathering_state_ = kIceGatheringNew; 347 IceGatheringState gathering_state_ = kIceGatheringNew;
340 bool had_connection_ = false; 348 bool had_connection_ = false;
341 }; 349 };
342 350
343 // Fake transport class, which can be passed to anything that needs a Transport. 351 // Fake transport class, which can be passed to anything that needs a Transport.
344 // Can be informed of another FakeTransport via SetDestination (low-tech way 352 // Can be informed of another FakeTransport via SetDestination (low-tech way
345 // of doing candidates) 353 // of doing candidates)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) override { 406 bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version) override {
399 ssl_max_version_ = version; 407 ssl_max_version_ = version;
400 for (const auto& kv : channels_) { 408 for (const auto& kv : channels_) {
401 kv.second->set_ssl_max_protocol_version(ssl_max_version_); 409 kv.second->set_ssl_max_protocol_version(ssl_max_version_);
402 } 410 }
403 return true; 411 return true;
404 } 412 }
405 rtc::SSLProtocolVersion ssl_max_protocol_version() const { 413 rtc::SSLProtocolVersion ssl_max_protocol_version() const {
406 return ssl_max_version_; 414 return ssl_max_version_;
407 } 415 }
416 bool SetEnableGcmCiphers(bool enable) override {
417 enable_gcm_ciphers_ = enable;
418 for (const auto& kv : channels_) {
419 kv.second->set_enable_gcm_ciphers(enable_gcm_ciphers_);
420 }
421 return true;
422 }
423 bool enable_gcm_ciphers() const {
424 return enable_gcm_ciphers_;
425 }
408 426
409 using Transport::local_description; 427 using Transport::local_description;
410 using Transport::remote_description; 428 using Transport::remote_description;
411 429
412 protected: 430 protected:
413 TransportChannelImpl* CreateTransportChannel(int component) override { 431 TransportChannelImpl* CreateTransportChannel(int component) override {
414 if (channels_.find(component) != channels_.end()) { 432 if (channels_.find(component) != channels_.end()) {
415 return nullptr; 433 return nullptr;
416 } 434 }
417 FakeTransportChannel* channel = 435 FakeTransportChannel* channel =
418 new FakeTransportChannel(this, name(), component); 436 new FakeTransportChannel(this, name(), component);
419 channel->set_ssl_max_protocol_version(ssl_max_version_); 437 channel->set_ssl_max_protocol_version(ssl_max_version_);
438 channel->set_enable_gcm_ciphers(enable_gcm_ciphers_);
420 channel->SetAsync(async_); 439 channel->SetAsync(async_);
421 SetChannelDestination(component, channel); 440 SetChannelDestination(component, channel);
422 channels_[component] = channel; 441 channels_[component] = channel;
423 return channel; 442 return channel;
424 } 443 }
425 444
426 void DestroyTransportChannel(TransportChannelImpl* channel) override { 445 void DestroyTransportChannel(TransportChannelImpl* channel) override {
427 channels_.erase(channel->component()); 446 channels_.erase(channel->component());
428 delete channel; 447 delete channel;
429 } 448 }
(...skipping 17 matching lines...) Expand all
447 466
448 // Note, this is distinct from the Channel map owned by Transport. 467 // Note, this is distinct from the Channel map owned by Transport.
449 // This map just tracks the FakeTransportChannels created by this class. 468 // This map just tracks the FakeTransportChannels created by this class.
450 // It's mainly needed so that we can access a FakeTransportChannel directly, 469 // It's mainly needed so that we can access a FakeTransportChannel directly,
451 // even if wrapped by a DtlsTransportChannelWrapper. 470 // even if wrapped by a DtlsTransportChannelWrapper.
452 ChannelMap channels_; 471 ChannelMap channels_;
453 FakeTransport* dest_ = nullptr; 472 FakeTransport* dest_ = nullptr;
454 bool async_ = false; 473 bool async_ = false;
455 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; 474 rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
456 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_10; 475 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_10;
476 bool enable_gcm_ciphers_ = false;
457 }; 477 };
458 478
459 // Fake TransportController class, which can be passed into a BaseChannel object 479 // Fake TransportController class, which can be passed into a BaseChannel object
460 // for test purposes. Can be connected to other FakeTransportControllers via 480 // for test purposes. Can be connected to other FakeTransportControllers via
461 // Connect(). 481 // Connect().
462 // 482 //
463 // This fake is unusual in that for the most part, it's implemented with the 483 // This fake is unusual in that for the most part, it's implemented with the
464 // real TransportController code, but with fake TransportChannels underneath. 484 // real TransportController code, but with fake TransportChannels underneath.
465 class FakeTransportController : public TransportController { 485 class FakeTransportController : public TransportController {
466 public: 486 public:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 554 }
535 } 555 }
536 556
537 private: 557 private:
538 bool fail_create_channel_; 558 bool fail_create_channel_;
539 }; 559 };
540 560
541 } // namespace cricket 561 } // namespace cricket
542 562
543 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ 563 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698