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 |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 #include <memory> | 13 #include <memory> |
14 #include <set> | 14 #include <set> |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "webrtc/base/bufferqueue.h" | 17 #include "webrtc/base/bufferqueue.h" |
| 18 #include "webrtc/base/checks.h" |
18 #include "webrtc/base/gunit.h" | 19 #include "webrtc/base/gunit.h" |
19 #include "webrtc/base/helpers.h" | 20 #include "webrtc/base/helpers.h" |
20 #include "webrtc/base/ssladapter.h" | 21 #include "webrtc/base/ssladapter.h" |
21 #include "webrtc/base/sslconfig.h" | 22 #include "webrtc/base/sslconfig.h" |
22 #include "webrtc/base/sslidentity.h" | 23 #include "webrtc/base/sslidentity.h" |
23 #include "webrtc/base/sslstreamadapter.h" | 24 #include "webrtc/base/sslstreamadapter.h" |
24 #include "webrtc/base/stream.h" | 25 #include "webrtc/base/stream.h" |
25 | 26 |
26 using ::testing::WithParamInterface; | 27 using ::testing::WithParamInterface; |
27 using ::testing::Values; | 28 using ::testing::Values; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 void TestHandshake(bool expect_success = true) { | 377 void TestHandshake(bool expect_success = true) { |
377 server_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : | 378 server_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : |
378 rtc::SSL_MODE_TLS); | 379 rtc::SSL_MODE_TLS); |
379 client_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : | 380 client_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : |
380 rtc::SSL_MODE_TLS); | 381 rtc::SSL_MODE_TLS); |
381 | 382 |
382 if (!dtls_) { | 383 if (!dtls_) { |
383 // Make sure we simulate a reliable network for TLS. | 384 // Make sure we simulate a reliable network for TLS. |
384 // This is just a check to make sure that people don't write wrong | 385 // This is just a check to make sure that people don't write wrong |
385 // tests. | 386 // tests. |
386 ASSERT((mtu_ == 1460) && (loss_ == 0) && (lose_first_packet_ == 0)); | 387 RTC_CHECK((mtu_ == 1460) && (loss_ == 0) && (lose_first_packet_ == 0)); |
387 } | 388 } |
388 | 389 |
389 if (!identities_set_) | 390 if (!identities_set_) |
390 SetPeerIdentitiesByDigest(true, true); | 391 SetPeerIdentitiesByDigest(true, true); |
391 | 392 |
392 // Start the handshake | 393 // Start the handshake |
393 int rv; | 394 int rv; |
394 | 395 |
395 server_ssl_->SetServerRole(); | 396 server_ssl_->SetServerRole(); |
396 rv = server_ssl_->StartSSL(); | 397 rv = server_ssl_->StartSSL(); |
(...skipping 16 matching lines...) Expand all Loading... |
413 // This tests that the handshake can complete before the identity is | 414 // This tests that the handshake can complete before the identity is |
414 // verified, and the identity will be verified after the fact. | 415 // verified, and the identity will be verified after the fact. |
415 void TestHandshakeWithDelayedIdentity(bool valid_identity) { | 416 void TestHandshakeWithDelayedIdentity(bool valid_identity) { |
416 server_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : rtc::SSL_MODE_TLS); | 417 server_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : rtc::SSL_MODE_TLS); |
417 client_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : rtc::SSL_MODE_TLS); | 418 client_ssl_->SetMode(dtls_ ? rtc::SSL_MODE_DTLS : rtc::SSL_MODE_TLS); |
418 | 419 |
419 if (!dtls_) { | 420 if (!dtls_) { |
420 // Make sure we simulate a reliable network for TLS. | 421 // Make sure we simulate a reliable network for TLS. |
421 // This is just a check to make sure that people don't write wrong | 422 // This is just a check to make sure that people don't write wrong |
422 // tests. | 423 // tests. |
423 ASSERT((mtu_ == 1460) && (loss_ == 0) && (lose_first_packet_ == 0)); | 424 RTC_CHECK((mtu_ == 1460) && (loss_ == 0) && (lose_first_packet_ == 0)); |
424 } | 425 } |
425 | 426 |
426 // Start the handshake | 427 // Start the handshake |
427 int rv; | 428 int rv; |
428 | 429 |
429 server_ssl_->SetServerRole(); | 430 server_ssl_->SetServerRole(); |
430 rv = server_ssl_->StartSSL(); | 431 rv = server_ssl_->StartSSL(); |
431 ASSERT_EQ(0, rv); | 432 ASSERT_EQ(0, rv); |
432 | 433 |
433 rv = client_ssl_->StartSSL(); | 434 rv = client_ssl_->StartSSL(); |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); | 1371 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); |
1371 INSTANTIATE_TEST_CASE_P( | 1372 INSTANTIATE_TEST_CASE_P( |
1372 SSLStreamAdapterTestsDTLS, | 1373 SSLStreamAdapterTestsDTLS, |
1373 SSLStreamAdapterTestDTLS, | 1374 SSLStreamAdapterTestDTLS, |
1374 Combine(Values(rtc::KeyParams::RSA(1024, 65537), | 1375 Combine(Values(rtc::KeyParams::RSA(1024, 65537), |
1375 rtc::KeyParams::RSA(1152, 65537), | 1376 rtc::KeyParams::RSA(1152, 65537), |
1376 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)), | 1377 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)), |
1377 Values(rtc::KeyParams::RSA(1024, 65537), | 1378 Values(rtc::KeyParams::RSA(1024, 65537), |
1378 rtc::KeyParams::RSA(1152, 65537), | 1379 rtc::KeyParams::RSA(1152, 65537), |
1379 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); | 1380 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); |
OLD | NEW |