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

Side by Side Diff: webrtc/p2p/base/dtlstransportchannel_unittest.cc

Issue 1774583002: Add IsAcceptableCipher, use instead of GetDefaultCipher. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Address feedback Created 4 years, 9 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 | « webrtc/base/sslstreamadapter_unittest.cc ('k') | 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 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if (negotiated_dtls_ && expected_crypto_suite) { 222 if (negotiated_dtls_ && expected_crypto_suite) {
223 ASSERT_TRUE(rv); 223 ASSERT_TRUE(rv);
224 224
225 ASSERT_EQ(crypto_suite, expected_crypto_suite); 225 ASSERT_EQ(crypto_suite, expected_crypto_suite);
226 } else { 226 } else {
227 ASSERT_FALSE(rv); 227 ASSERT_FALSE(rv);
228 } 228 }
229 } 229 }
230 } 230 }
231 231
232 void CheckSsl(int expected_cipher) { 232 void CheckSsl() {
233 for (std::vector<cricket::DtlsTransportChannelWrapper*>::iterator it = 233 for (std::vector<cricket::DtlsTransportChannelWrapper*>::iterator it =
234 channels_.begin(); it != channels_.end(); ++it) { 234 channels_.begin(); it != channels_.end(); ++it) {
235 int cipher; 235 int cipher;
236 236
237 bool rv = (*it)->GetSslCipherSuite(&cipher); 237 bool rv = (*it)->GetSslCipherSuite(&cipher);
238 if (negotiated_dtls_ && expected_cipher) { 238 if (negotiated_dtls_) {
239 ASSERT_TRUE(rv); 239 ASSERT_TRUE(rv);
240 240
241 ASSERT_EQ(cipher, expected_cipher); 241 EXPECT_TRUE(
242 rtc::SSLStreamAdapter::IsAcceptableCipher(cipher, rtc::KT_DEFAULT));
242 } else { 243 } else {
243 ASSERT_FALSE(rv); 244 ASSERT_FALSE(rv);
244 } 245 }
245 } 246 }
246 } 247 }
247 248
248 void SendPackets(size_t channel, size_t size, size_t count, bool srtp) { 249 void SendPackets(size_t channel, size_t size, size_t count, bool srtp) {
249 ASSERT(channel < channels_.size()); 250 ASSERT(channel < channels_.size());
250 rtc::scoped_ptr<char[]> packet(new char[size]); 251 rtc::scoped_ptr<char[]> packet(new char[size]);
251 size_t sent = 0; 252 size_t sent = 0;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 } 467 }
467 468
468 // Check that we negotiated the right ciphers. 469 // Check that we negotiated the right ciphers.
469 if (use_dtls_srtp_) { 470 if (use_dtls_srtp_) {
470 client1_.CheckSrtp(rtc::SRTP_AES128_CM_SHA1_80); 471 client1_.CheckSrtp(rtc::SRTP_AES128_CM_SHA1_80);
471 client2_.CheckSrtp(rtc::SRTP_AES128_CM_SHA1_80); 472 client2_.CheckSrtp(rtc::SRTP_AES128_CM_SHA1_80);
472 } else { 473 } else {
473 client1_.CheckSrtp(rtc::SRTP_INVALID_CRYPTO_SUITE); 474 client1_.CheckSrtp(rtc::SRTP_INVALID_CRYPTO_SUITE);
474 client2_.CheckSrtp(rtc::SRTP_INVALID_CRYPTO_SUITE); 475 client2_.CheckSrtp(rtc::SRTP_INVALID_CRYPTO_SUITE);
475 } 476 }
476 client1_.CheckSsl(rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( 477
477 ssl_expected_version_, rtc::KT_DEFAULT)); 478 client1_.CheckSsl();
478 client2_.CheckSsl(rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( 479 client2_.CheckSsl();
479 ssl_expected_version_, rtc::KT_DEFAULT));
480 480
481 return true; 481 return true;
482 } 482 }
483 483
484 bool Connect() { 484 bool Connect() {
485 // By default, Client1 will be Server and Client2 will be Client. 485 // By default, Client1 will be Server and Client2 will be Client.
486 return Connect(cricket::CONNECTIONROLE_ACTPASS, 486 return Connect(cricket::CONNECTIONROLE_ACTPASS,
487 cricket::CONNECTIONROLE_ACTIVE); 487 cricket::CONNECTIONROLE_ACTIVE);
488 } 488 }
489 489
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 625 }
626 626
627 // Connect with B doing DTLS and A not, and transfer some data. 627 // Connect with B doing DTLS and A not, and transfer some data.
628 TEST_F(DtlsTransportChannelTest, TestTransferDtlsNotOffered) { 628 TEST_F(DtlsTransportChannelTest, TestTransferDtlsNotOffered) {
629 PrepareDtls(false, true, rtc::KT_DEFAULT); 629 PrepareDtls(false, true, rtc::KT_DEFAULT);
630 ASSERT_TRUE(Connect()); 630 ASSERT_TRUE(Connect());
631 TestTransfer(0, 1000, 100, false); 631 TestTransfer(0, 1000, 100, false);
632 } 632 }
633 633
634 // Create two channels with DTLS 1.0 and check ciphers. 634 // Create two channels with DTLS 1.0 and check ciphers.
635 // Disabled due to new BoringSSLL version, see webrtc:5634 635 TEST_F(DtlsTransportChannelTest, TestDtls12None) {
636 TEST_F(DtlsTransportChannelTest, DISABLED_TestDtls12None) {
637 MAYBE_SKIP_TEST(HaveDtls); 636 MAYBE_SKIP_TEST(HaveDtls);
638 SetChannelCount(2); 637 SetChannelCount(2);
639 PrepareDtls(true, true, rtc::KT_DEFAULT); 638 PrepareDtls(true, true, rtc::KT_DEFAULT);
640 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); 639 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10);
641 ASSERT_TRUE(Connect()); 640 ASSERT_TRUE(Connect());
642 } 641 }
643 642
644 // Create two channels with DTLS 1.2 and check ciphers. 643 // Create two channels with DTLS 1.2 and check ciphers.
645 TEST_F(DtlsTransportChannelTest, TestDtls12Both) { 644 TEST_F(DtlsTransportChannelTest, TestDtls12Both) {
646 MAYBE_SKIP_TEST(HaveDtls); 645 MAYBE_SKIP_TEST(HaveDtls);
647 SetChannelCount(2); 646 SetChannelCount(2);
648 PrepareDtls(true, true, rtc::KT_DEFAULT); 647 PrepareDtls(true, true, rtc::KT_DEFAULT);
649 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12); 648 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12);
650 ASSERT_TRUE(Connect()); 649 ASSERT_TRUE(Connect());
651 } 650 }
652 651
653 // Create two channels with DTLS 1.0 / DTLS 1.2 and check ciphers. 652 // Create two channels with DTLS 1.0 / DTLS 1.2 and check ciphers.
654 // Disabled due to new BoringSSLL version, see webrtc:5634 653 TEST_F(DtlsTransportChannelTest, TestDtls12Client1) {
655 TEST_F(DtlsTransportChannelTest, DISABLED_TestDtls12Client1) {
656 MAYBE_SKIP_TEST(HaveDtls); 654 MAYBE_SKIP_TEST(HaveDtls);
657 SetChannelCount(2); 655 SetChannelCount(2);
658 PrepareDtls(true, true, rtc::KT_DEFAULT); 656 PrepareDtls(true, true, rtc::KT_DEFAULT);
659 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10); 657 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10);
660 ASSERT_TRUE(Connect()); 658 ASSERT_TRUE(Connect());
661 } 659 }
662 660
663 // Create two channels with DTLS 1.2 / DTLS 1.0 and check ciphers. 661 // Create two channels with DTLS 1.2 / DTLS 1.0 and check ciphers.
664 // Disabled due to new BoringSSLL version, see webrtc:5634 662 TEST_F(DtlsTransportChannelTest, TestDtls12Client2) {
665 TEST_F(DtlsTransportChannelTest, DISABLED_TestDtls12Client2) {
666 MAYBE_SKIP_TEST(HaveDtls); 663 MAYBE_SKIP_TEST(HaveDtls);
667 SetChannelCount(2); 664 SetChannelCount(2);
668 PrepareDtls(true, true, rtc::KT_DEFAULT); 665 PrepareDtls(true, true, rtc::KT_DEFAULT);
669 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); 666 SetMaxProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12);
670 ASSERT_TRUE(Connect()); 667 ASSERT_TRUE(Connect());
671 } 668 }
672 669
673 // Connect with DTLS, negotiate DTLS-SRTP, and transfer SRTP using bypass. 670 // Connect with DTLS, negotiate DTLS-SRTP, and transfer SRTP using bypass.
674 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtp) { 671 TEST_F(DtlsTransportChannelTest, TestTransferDtlsSrtp) {
675 MAYBE_SKIP_TEST(HaveDtlsSrtp); 672 MAYBE_SKIP_TEST(HaveDtlsSrtp);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 // Each side's remote certificate is the other side's local certificate. 883 // Each side's remote certificate is the other side's local certificate.
887 ASSERT_TRUE( 884 ASSERT_TRUE(
888 client1_.transport()->GetRemoteSSLCertificate(remote_cert1.accept())); 885 client1_.transport()->GetRemoteSSLCertificate(remote_cert1.accept()));
889 ASSERT_EQ(remote_cert1->ToPEMString(), 886 ASSERT_EQ(remote_cert1->ToPEMString(),
890 certificate2->ssl_certificate().ToPEMString()); 887 certificate2->ssl_certificate().ToPEMString());
891 ASSERT_TRUE( 888 ASSERT_TRUE(
892 client2_.transport()->GetRemoteSSLCertificate(remote_cert2.accept())); 889 client2_.transport()->GetRemoteSSLCertificate(remote_cert2.accept()));
893 ASSERT_EQ(remote_cert2->ToPEMString(), 890 ASSERT_EQ(remote_cert2->ToPEMString(),
894 certificate1->ssl_certificate().ToPEMString()); 891 certificate1->ssl_certificate().ToPEMString());
895 } 892 }
OLDNEW
« no previous file with comments | « webrtc/base/sslstreamadapter_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698