OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quic_crypto_client_stream.h" | 5 #include "net/quic/quic_crypto_client_stream.h" |
6 | 6 |
7 #include "net/quic/crypto/crypto_protocol.h" | 7 #include "net/quic/crypto/crypto_protocol.h" |
8 #include "net/quic/crypto/crypto_utils.h" | 8 #include "net/quic/crypto/crypto_utils.h" |
9 #include "net/quic/quic_protocol.h" | 9 #include "net/quic/quic_protocol.h" |
10 #include "net/quic/quic_session.h" | 10 #include "net/quic/quic_session.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 QuicCryptoClientStream::QuicCryptoClientStream(QuicSession* session, | 14 QuicCryptoClientStream::QuicCryptoClientStream(QuicSession* session, |
15 const string& server_hostname) | 15 const string& server_hostname) |
16 : QuicCryptoStream(session), | 16 : QuicCryptoStream(session), |
17 server_hostname_(server_hostname) { | 17 server_hostname_(server_hostname) { |
18 config_.SetDefaults(); | 18 config_.SetDefaults(); |
| 19 |
| 20 QuicGuid guid = session->connection()->guid(); |
| 21 crypto_config_.hkdf_info.append(reinterpret_cast<char*>(&guid), |
| 22 sizeof(guid)); |
19 } | 23 } |
20 | 24 |
21 QuicCryptoClientStream::~QuicCryptoClientStream() { | 25 QuicCryptoClientStream::~QuicCryptoClientStream() { |
22 } | 26 } |
23 | 27 |
24 void QuicCryptoClientStream::OnHandshakeMessage( | 28 void QuicCryptoClientStream::OnHandshakeMessage( |
25 const CryptoHandshakeMessage& message) { | 29 const CryptoHandshakeMessage& message) { |
26 // Do not process handshake messages after the handshake is complete. | 30 // Do not process handshake messages after the handshake is complete. |
27 if (handshake_complete()) { | 31 if (handshake_complete()) { |
28 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); | 32 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); |
(...skipping 10 matching lines...) Expand all Loading... |
39 message, | 43 message, |
40 CryptoUtils::PEER_PRIORITY, | 44 CryptoUtils::PEER_PRIORITY, |
41 &negotiated_params_, | 45 &negotiated_params_, |
42 &error_details); | 46 &error_details); |
43 if (error != QUIC_NO_ERROR) { | 47 if (error != QUIC_NO_ERROR) { |
44 CloseConnectionWithDetails(error, error_details); | 48 CloseConnectionWithDetails(error, error_details); |
45 return; | 49 return; |
46 } | 50 } |
47 | 51 |
48 QuicErrorCode err = crypto_config_.ProcessServerHello( | 52 QuicErrorCode err = crypto_config_.ProcessServerHello( |
49 message, &crypto_negotiated_params_, &error_details); | 53 message, nonce_, &crypto_negotiated_params_, &error_details); |
50 if (err != QUIC_NO_ERROR) { | 54 if (err != QUIC_NO_ERROR) { |
51 CloseConnectionWithDetails(err, error_details); | 55 CloseConnectionWithDetails(err, error_details); |
52 return; | 56 return; |
53 } | 57 } |
54 | 58 |
55 SetHandshakeComplete(QUIC_NO_ERROR); | 59 SetHandshakeComplete(QUIC_NO_ERROR); |
56 return; | 60 return; |
57 } | 61 } |
58 | 62 |
59 bool QuicCryptoClientStream::CryptoConnect() { | 63 bool QuicCryptoClientStream::CryptoConnect() { |
60 crypto_config_.SetDefaults(session()->connection()->random_generator()); | 64 crypto_config_.SetDefaults(session()->connection()->random_generator()); |
61 CryptoUtils::GenerateNonce(session()->connection()->clock(), | 65 CryptoUtils::GenerateNonce(session()->connection()->clock(), |
62 session()->connection()->random_generator(), | 66 session()->connection()->random_generator(), |
63 &nonce_); | 67 &nonce_); |
64 CryptoHandshakeMessage message; | 68 CryptoHandshakeMessage message; |
65 crypto_config_.FillClientHello(nonce_, server_hostname_, &message); | 69 crypto_config_.FillClientHello(nonce_, server_hostname_, &message); |
66 config_.ToHandshakeMessage(&message); | 70 config_.ToHandshakeMessage(&message); |
| 71 const QuicData& data = message.GetSerialized(); |
| 72 crypto_config_.hkdf_info.append(data.data(), data.length()); |
67 SendHandshakeMessage(message); | 73 SendHandshakeMessage(message); |
68 return true; | 74 return true; |
69 } | 75 } |
70 | 76 |
71 } // namespace net | 77 } // namespace net |
OLD | NEW |