OLD | NEW |
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* vim: set ts=2 et sw=2 tw=80: */ | 2 /* vim: set ts=2 et sw=2 tw=80: */ |
3 /* This Source Code Form is subject to the terms of the Mozilla Public | 3 /* This Source Code Form is subject to the terms of the Mozilla Public |
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, | 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ | 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | 6 |
7 #include "ssl.h" | 7 #include "ssl.h" |
8 #include "sslerr.h" | 8 #include "sslerr.h" |
9 #include "sslproto.h" | 9 #include "sslproto.h" |
10 #include <memory> | 10 #include <memory> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 if (!parser.Read(&named_curve, 2)) { | 79 if (!parser.Read(&named_curve, 2)) { |
80 return false; | 80 return false; |
81 } | 81 } |
82 | 82 |
83 return parser.ReadVariable(&public_key_, 1); | 83 return parser.ReadVariable(&public_key_, 1); |
84 } | 84 } |
85 | 85 |
86 DataBuffer public_key_; | 86 DataBuffer public_key_; |
87 }; | 87 }; |
88 | 88 |
| 89 class TlsChaCha20Poly1305Test : public TlsConnectTls12 { |
| 90 public: |
| 91 void ConnectSendReceive(int16_t cipher_suite) |
| 92 { |
| 93 // Disable all ciphers. |
| 94 client_->DisableCiphersByKeyExchange(ssl_kea_rsa); |
| 95 client_->DisableCiphersByKeyExchange(ssl_kea_dh); |
| 96 client_->DisableCiphersByKeyExchange(ssl_kea_ecdh); |
| 97 |
| 98 // Re-enable ChaCha20/Poly1305. |
| 99 SECStatus rv = SSL_CipherPrefSet(client_->ssl_fd(), cipher_suite, PR_TRUE); |
| 100 EXPECT_EQ(SECSuccess, rv); |
| 101 |
| 102 Connect(); |
| 103 SendReceive(); |
| 104 |
| 105 // Check that we used the right cipher suite. |
| 106 int16_t actual; |
| 107 EXPECT_TRUE(client_->cipher_suite(&actual) && actual == cipher_suite); |
| 108 EXPECT_TRUE(server_->cipher_suite(&actual) && actual == cipher_suite); |
| 109 } |
| 110 }; |
| 111 |
89 TEST_P(TlsConnectGeneric, SetupOnly) {} | 112 TEST_P(TlsConnectGeneric, SetupOnly) {} |
90 | 113 |
91 TEST_P(TlsConnectGeneric, Connect) { | 114 TEST_P(TlsConnectGeneric, Connect) { |
92 SetExpectedVersion(std::get<1>(GetParam())); | 115 SetExpectedVersion(std::get<1>(GetParam())); |
93 Connect(); | 116 Connect(); |
94 client_->CheckAuthType(ssl_auth_rsa); | 117 client_->CheckAuthType(ssl_auth_rsa); |
95 } | 118 } |
96 | 119 |
97 TEST_P(TlsConnectGeneric, ConnectEcdsa) { | 120 TEST_P(TlsConnectGeneric, ConnectEcdsa) { |
98 SetExpectedVersion(std::get<1>(GetParam())); | 121 SetExpectedVersion(std::get<1>(GetParam())); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 EXPECT_FALSE((dhe1.public_key_.len() == dhe2.public_key_.len()) && | 501 EXPECT_FALSE((dhe1.public_key_.len() == dhe2.public_key_.len()) && |
479 (!memcmp(dhe1.public_key_.data(), dhe2.public_key_.data(), | 502 (!memcmp(dhe1.public_key_.data(), dhe2.public_key_.data(), |
480 dhe1.public_key_.len()))); | 503 dhe1.public_key_.len()))); |
481 } | 504 } |
482 | 505 |
483 TEST_P(TlsConnectGeneric, ConnectSendReceive) { | 506 TEST_P(TlsConnectGeneric, ConnectSendReceive) { |
484 Connect(); | 507 Connect(); |
485 SendReceive(); | 508 SendReceive(); |
486 } | 509 } |
487 | 510 |
| 511 TEST_P(TlsChaCha20Poly1305Test, SendReceiveChaCha20Poly1305DheRsa) { |
| 512 ConnectSendReceive(TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256); |
| 513 } |
| 514 |
| 515 TEST_P(TlsChaCha20Poly1305Test, SendReceiveChaCha20Poly1305EcdheRsa) { |
| 516 ConnectSendReceive(TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256); |
| 517 } |
| 518 |
| 519 TEST_P(TlsChaCha20Poly1305Test, SendReceiveChaCha20Poly1305EcdheEcdsa) { |
| 520 ResetEcdsa(); |
| 521 ConnectSendReceive(TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256); |
| 522 } |
| 523 |
488 // The next two tests takes advantage of the fact that we | 524 // The next two tests takes advantage of the fact that we |
489 // automatically read the first 1024 bytes, so if | 525 // automatically read the first 1024 bytes, so if |
490 // we provide 1200 bytes, they overrun the read buffer | 526 // we provide 1200 bytes, they overrun the read buffer |
491 // provided by the calling test. | 527 // provided by the calling test. |
492 | 528 |
493 // DTLS should return an error. | 529 // DTLS should return an error. |
494 TEST_P(TlsConnectDatagram, ShortRead) { | 530 TEST_P(TlsConnectDatagram, ShortRead) { |
495 Connect(); | 531 Connect(); |
496 client_->SetExpectedReadError(true); | 532 client_->SetExpectedReadError(true); |
497 server_->SendData(1200, 1200); | 533 server_->SendData(1200, 1200); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 INSTANTIATE_TEST_CASE_P(Pre12All, TlsConnectPre12, | 696 INSTANTIATE_TEST_CASE_P(Pre12All, TlsConnectPre12, |
661 ::testing::Combine( | 697 ::testing::Combine( |
662 TlsConnectTestBase::kTlsModesAll, | 698 TlsConnectTestBase::kTlsModesAll, |
663 TlsConnectTestBase::kTlsV11)); | 699 TlsConnectTestBase::kTlsV11)); |
664 INSTANTIATE_TEST_CASE_P(VersionsStream10, TlsConnectStream, | 700 INSTANTIATE_TEST_CASE_P(VersionsStream10, TlsConnectStream, |
665 TlsConnectTestBase::kTlsV10); | 701 TlsConnectTestBase::kTlsV10); |
666 INSTANTIATE_TEST_CASE_P(VersionsStream, TlsConnectStream, | 702 INSTANTIATE_TEST_CASE_P(VersionsStream, TlsConnectStream, |
667 TlsConnectTestBase::kTlsV11V12); | 703 TlsConnectTestBase::kTlsV11V12); |
668 | 704 |
669 } // namespace nspr_test | 705 } // namespace nspr_test |
OLD | NEW |