| 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" | |
| 9 #include "net/quic/quic_client_session_base.h" | 8 #include "net/quic/quic_client_session_base.h" |
| 10 #include "net/quic/quic_server_id.h" | 9 #include "net/quic/quic_server_id.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 11 |
| 13 using std::string; | 12 using std::string; |
| 14 | 13 |
| 15 namespace net { | 14 namespace net { |
| 16 | 15 |
| 17 MockCryptoClientStream::MockCryptoClientStream( | 16 MockCryptoClientStream::MockCryptoClientStream( |
| 18 const QuicServerId& server_id, | 17 const QuicServerId& server_id, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 34 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); | 33 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); |
| 35 } | 34 } |
| 36 | 35 |
| 37 void MockCryptoClientStream::CryptoConnect() { | 36 void MockCryptoClientStream::CryptoConnect() { |
| 38 switch (handshake_mode_) { | 37 switch (handshake_mode_) { |
| 39 case ZERO_RTT: { | 38 case ZERO_RTT: { |
| 40 encryption_established_ = true; | 39 encryption_established_ = true; |
| 41 handshake_confirmed_ = false; | 40 handshake_confirmed_ = false; |
| 42 session()->connection()->SetDecrypter(ENCRYPTION_INITIAL, | 41 session()->connection()->SetDecrypter(ENCRYPTION_INITIAL, |
| 43 QuicDecrypter::Create(kNULL)); | 42 QuicDecrypter::Create(kNULL)); |
| 44 session()->connection()->SetEncrypter(ENCRYPTION_INITIAL, | |
| 45 QuicEncrypter::Create(kNULL)); | |
| 46 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); | |
| 47 session()->OnCryptoHandshakeEvent( | 43 session()->OnCryptoHandshakeEvent( |
| 48 QuicSession::ENCRYPTION_FIRST_ESTABLISHED); | 44 QuicSession::ENCRYPTION_FIRST_ESTABLISHED); |
| 49 break; | 45 break; |
| 50 } | 46 } |
| 51 | 47 |
| 52 case CONFIRM_HANDSHAKE: { | 48 case CONFIRM_HANDSHAKE: { |
| 53 encryption_established_ = true; | 49 encryption_established_ = true; |
| 54 handshake_confirmed_ = true; | 50 handshake_confirmed_ = true; |
| 55 crypto_negotiated_params_.key_exchange = kC255; | 51 crypto_negotiated_params_.key_exchange = kC255; |
| 56 crypto_negotiated_params_.aead = kAESG; | 52 crypto_negotiated_params_.aead = kAESG; |
| 57 if (proof_verify_details_) { | 53 if (proof_verify_details_) { |
| 58 client_session()->OnProofVerifyDetailsAvailable(*proof_verify_details_); | 54 client_session()->OnProofVerifyDetailsAvailable(*proof_verify_details_); |
| 59 } | 55 } |
| 60 SetConfigNegotiated(); | 56 SetConfigNegotiated(); |
| 61 session()->connection()->SetDecrypter(ENCRYPTION_FORWARD_SECURE, | 57 session()->connection()->SetDecrypter(ENCRYPTION_FORWARD_SECURE, |
| 62 QuicDecrypter::Create(kNULL)); | 58 QuicDecrypter::Create(kNULL)); |
| 63 session()->connection()->SetEncrypter(ENCRYPTION_FORWARD_SECURE, | |
| 64 QuicEncrypter::Create(kNULL)); | |
| 65 session()->connection()->SetDefaultEncryptionLevel( | |
| 66 ENCRYPTION_FORWARD_SECURE); | |
| 67 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); | 59 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); |
| 68 break; | 60 break; |
| 69 } | 61 } |
| 70 | 62 |
| 71 case COLD_START: { | 63 case COLD_START: { |
| 72 handshake_confirmed_ = false; | 64 handshake_confirmed_ = false; |
| 73 encryption_established_ = false; | 65 encryption_established_ = false; |
| 74 break; | 66 break; |
| 75 } | 67 } |
| 76 } | 68 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 ASSERT_EQ(QUIC_NO_ERROR, error); | 102 ASSERT_EQ(QUIC_NO_ERROR, error); |
| 111 ASSERT_TRUE(session()->config()->negotiated()); | 103 ASSERT_TRUE(session()->config()->negotiated()); |
| 112 session()->OnConfigNegotiated(); | 104 session()->OnConfigNegotiated(); |
| 113 } | 105 } |
| 114 | 106 |
| 115 QuicClientSessionBase* MockCryptoClientStream::client_session() { | 107 QuicClientSessionBase* MockCryptoClientStream::client_session() { |
| 116 return reinterpret_cast<QuicClientSessionBase*>(session()); | 108 return reinterpret_cast<QuicClientSessionBase*>(session()); |
| 117 } | 109 } |
| 118 | 110 |
| 119 } // namespace net | 111 } // namespace net |
| OLD | NEW |