| 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/core/crypto/null_decrypter.h" | 7 #include "net/quic/core/crypto/null_decrypter.h" |
| 8 #include "net/quic/core/crypto/null_encrypter.h" | 8 #include "net/quic/core/crypto/null_encrypter.h" |
| 9 #include "net/quic/core/crypto/quic_decrypter.h" | 9 #include "net/quic/core/crypto/quic_decrypter.h" |
| 10 #include "net/quic/core/crypto/quic_encrypter.h" | 10 #include "net/quic/core/crypto/quic_encrypter.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 config_(config) {} | 35 config_(config) {} |
| 36 | 36 |
| 37 MockCryptoClientStream::~MockCryptoClientStream() {} | 37 MockCryptoClientStream::~MockCryptoClientStream() {} |
| 38 | 38 |
| 39 void MockCryptoClientStream::OnHandshakeMessage( | 39 void MockCryptoClientStream::OnHandshakeMessage( |
| 40 const CryptoHandshakeMessage& message) { | 40 const CryptoHandshakeMessage& message) { |
| 41 CloseConnectionWithDetails(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE, | 41 CloseConnectionWithDetails(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE, |
| 42 "Forced mock failure"); | 42 "Forced mock failure"); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void MockCryptoClientStream::CryptoConnect() { | 45 bool MockCryptoClientStream::CryptoConnect() { |
| 46 if (proof_verify_details_) { | 46 if (proof_verify_details_) { |
| 47 if (!proof_verify_details_->cert_verify_result.verified_cert | 47 if (!proof_verify_details_->cert_verify_result.verified_cert |
| 48 ->VerifyNameMatch(server_id_.host(), false)) { | 48 ->VerifyNameMatch(server_id_.host(), false)) { |
| 49 handshake_confirmed_ = false; | 49 handshake_confirmed_ = false; |
| 50 encryption_established_ = false; | 50 encryption_established_ = false; |
| 51 session()->connection()->CloseConnection( | 51 session()->connection()->CloseConnection( |
| 52 QUIC_PROOF_INVALID, "proof invalid", | 52 QUIC_PROOF_INVALID, "proof invalid", |
| 53 ConnectionCloseBehavior::SILENT_CLOSE); | 53 ConnectionCloseBehavior::SILENT_CLOSE); |
| 54 return; | 54 return false; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 switch (handshake_mode_) { | 58 switch (handshake_mode_) { |
| 59 case ZERO_RTT: { | 59 case ZERO_RTT: { |
| 60 encryption_established_ = true; | 60 encryption_established_ = true; |
| 61 handshake_confirmed_ = false; | 61 handshake_confirmed_ = false; |
| 62 crypto_negotiated_params_->key_exchange = kC255; | 62 crypto_negotiated_params_->key_exchange = kC255; |
| 63 crypto_negotiated_params_->aead = kAESG; | 63 crypto_negotiated_params_->aead = kAESG; |
| 64 if (proof_verify_details_) { | 64 if (proof_verify_details_) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 handshake_confirmed_ = false; | 99 handshake_confirmed_ = false; |
| 100 encryption_established_ = false; | 100 encryption_established_ = false; |
| 101 break; | 101 break; |
| 102 } | 102 } |
| 103 | 103 |
| 104 case USE_DEFAULT_CRYPTO_STREAM: { | 104 case USE_DEFAULT_CRYPTO_STREAM: { |
| 105 NOTREACHED(); | 105 NOTREACHED(); |
| 106 break; | 106 break; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 |
| 110 return session()->connection()->connected(); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void MockCryptoClientStream::SendOnCryptoHandshakeEvent( | 113 void MockCryptoClientStream::SendOnCryptoHandshakeEvent( |
| 112 QuicSession::CryptoHandshakeEvent event) { | 114 QuicSession::CryptoHandshakeEvent event) { |
| 113 encryption_established_ = true; | 115 encryption_established_ = true; |
| 114 if (event == QuicSession::HANDSHAKE_CONFIRMED) { | 116 if (event == QuicSession::HANDSHAKE_CONFIRMED) { |
| 115 handshake_confirmed_ = true; | 117 handshake_confirmed_ = true; |
| 116 SetConfigNegotiated(); | 118 SetConfigNegotiated(); |
| 117 session()->connection()->SetDecrypter( | 119 session()->connection()->SetDecrypter( |
| 118 ENCRYPTION_FORWARD_SECURE, new NullDecrypter(Perspective::IS_CLIENT)); | 120 ENCRYPTION_FORWARD_SECURE, new NullDecrypter(Perspective::IS_CLIENT)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 146 config.ToHandshakeMessage(&msg); | 148 config.ToHandshakeMessage(&msg); |
| 147 string error_details; | 149 string error_details; |
| 148 const QuicErrorCode error = | 150 const QuicErrorCode error = |
| 149 session()->config()->ProcessPeerHello(msg, CLIENT, &error_details); | 151 session()->config()->ProcessPeerHello(msg, CLIENT, &error_details); |
| 150 ASSERT_EQ(QUIC_NO_ERROR, error); | 152 ASSERT_EQ(QUIC_NO_ERROR, error); |
| 151 ASSERT_TRUE(session()->config()->negotiated()); | 153 ASSERT_TRUE(session()->config()->negotiated()); |
| 152 session()->OnConfigNegotiated(); | 154 session()->OnConfigNegotiated(); |
| 153 } | 155 } |
| 154 | 156 |
| 155 } // namespace net | 157 } // namespace net |
| OLD | NEW |