| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/test_tools/mock_crypto_client_stream.h" | 5 #include "net/quic/test_tools/mock_crypto_client_stream.h" |
| 6 | 6 |
| 7 #include "net/quic/crypto/quic_decrypter.h" | 7 #include "net/quic/crypto/quic_decrypter.h" |
| 8 #include "net/quic/crypto/quic_encrypter.h" | 8 #include "net/quic/crypto/quic_encrypter.h" |
| 9 #include "net/quic/quic_client_session_base.h" | 9 #include "net/quic/quic_client_session_base.h" |
| 10 #include "net/quic/quic_server_id.h" | 10 #include "net/quic/quic_server_id.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 using std::string; | 13 using std::string; |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 MockCryptoClientStream::MockCryptoClientStream( | 17 MockCryptoClientStream::MockCryptoClientStream( |
| 18 const QuicServerId& server_id, | 18 const QuicServerId& server_id, |
| 19 QuicClientSessionBase* session, | 19 QuicClientSessionBase* session, |
| 20 ProofVerifyContext* verify_context, | 20 ProofVerifyContext* verify_context, |
| 21 QuicCryptoClientConfig* crypto_config, | 21 QuicCryptoClientConfig* crypto_config, |
| 22 HandshakeMode handshake_mode, | 22 HandshakeMode handshake_mode, |
| 23 const ProofVerifyDetails* proof_verify_details) | 23 const ProofVerifyDetailsChromium* proof_verify_details) |
| 24 : QuicCryptoClientStream(server_id, | 24 : QuicCryptoClientStream(server_id, |
| 25 session, | 25 session, |
| 26 verify_context, | 26 verify_context, |
| 27 crypto_config, | 27 crypto_config, |
| 28 session), | 28 session), |
| 29 handshake_mode_(handshake_mode), | 29 handshake_mode_(handshake_mode), |
| 30 server_id_(server_id), |
| 30 proof_verify_details_(proof_verify_details) {} | 31 proof_verify_details_(proof_verify_details) {} |
| 31 | 32 |
| 32 MockCryptoClientStream::~MockCryptoClientStream() {} | 33 MockCryptoClientStream::~MockCryptoClientStream() {} |
| 33 | 34 |
| 34 void MockCryptoClientStream::OnHandshakeMessage( | 35 void MockCryptoClientStream::OnHandshakeMessage( |
| 35 const CryptoHandshakeMessage& message) { | 36 const CryptoHandshakeMessage& message) { |
| 36 CloseConnectionWithDetails(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE, | 37 CloseConnectionWithDetails(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE, |
| 37 "Forced mock failure"); | 38 "Forced mock failure"); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void MockCryptoClientStream::CryptoConnect() { | 41 void MockCryptoClientStream::CryptoConnect() { |
| 42 if (proof_verify_details_) { |
| 43 bool unused = false; |
| 44 if (!proof_verify_details_->cert_verify_result.verified_cert |
| 45 ->VerifyNameMatch(server_id_.host(), &unused)) { |
| 46 handshake_confirmed_ = false; |
| 47 encryption_established_ = false; |
| 48 session()->connection()->CloseConnection(QUIC_PROOF_INVALID, false); |
| 49 return; |
| 50 } |
| 51 } |
| 52 |
| 41 switch (handshake_mode_) { | 53 switch (handshake_mode_) { |
| 42 case ZERO_RTT: { | 54 case ZERO_RTT: { |
| 43 encryption_established_ = true; | 55 encryption_established_ = true; |
| 44 handshake_confirmed_ = false; | 56 handshake_confirmed_ = false; |
| 45 crypto_negotiated_params_.key_exchange = kC255; | 57 crypto_negotiated_params_.key_exchange = kC255; |
| 46 crypto_negotiated_params_.aead = kAESG; | 58 crypto_negotiated_params_.aead = kAESG; |
| 47 if (proof_verify_details_) { | 59 if (proof_verify_details_) { |
| 48 reinterpret_cast<QuicClientSessionBase*>(session()) | 60 reinterpret_cast<QuicClientSessionBase*>(session()) |
| 49 ->OnProofVerifyDetailsAvailable(*proof_verify_details_); | 61 ->OnProofVerifyDetailsAvailable(*proof_verify_details_); |
| 50 } | 62 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 config.ToHandshakeMessage(&msg); | 128 config.ToHandshakeMessage(&msg); |
| 117 string error_details; | 129 string error_details; |
| 118 const QuicErrorCode error = | 130 const QuicErrorCode error = |
| 119 session()->config()->ProcessPeerHello(msg, CLIENT, &error_details); | 131 session()->config()->ProcessPeerHello(msg, CLIENT, &error_details); |
| 120 ASSERT_EQ(QUIC_NO_ERROR, error); | 132 ASSERT_EQ(QUIC_NO_ERROR, error); |
| 121 ASSERT_TRUE(session()->config()->negotiated()); | 133 ASSERT_TRUE(session()->config()->negotiated()); |
| 122 session()->OnConfigNegotiated(); | 134 session()->OnConfigNegotiated(); |
| 123 } | 135 } |
| 124 | 136 |
| 125 } // namespace net | 137 } // namespace net |
| OLD | NEW |