Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Side by Side Diff: net/quic/core/quic_crypto_stream.cc

Issue 2611613003: Add quic_logging (Closed)
Patch Set: fix failed test? Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/core/quic_crypto_server_stream_test.cc ('k') | net/quic/core/quic_data_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/core/quic_crypto_stream.h" 5 #include "net/quic/core/quic_crypto_stream.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "net/quic/core/crypto/crypto_handshake.h" 10 #include "net/quic/core/crypto/crypto_handshake.h"
11 #include "net/quic/core/crypto/crypto_utils.h" 11 #include "net/quic/core/crypto/crypto_utils.h"
12 #include "net/quic/core/quic_connection.h" 12 #include "net/quic/core/quic_connection.h"
13 #include "net/quic/core/quic_flags.h" 13 #include "net/quic/core/quic_flags.h"
14 #include "net/quic/core/quic_session.h" 14 #include "net/quic/core/quic_session.h"
15 #include "net/quic/core/quic_utils.h" 15 #include "net/quic/core/quic_utils.h"
16 #include "net/quic/platform/api/quic_logging.h"
16 17
17 using std::string; 18 using std::string;
18 using base::StringPiece; 19 using base::StringPiece;
19 using net::SpdyPriority; 20 using net::SpdyPriority;
20 21
21 namespace net { 22 namespace net {
22 23
23 #define ENDPOINT \ 24 #define ENDPOINT \
24 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ 25 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \
25 " ") 26 " ")
(...skipping 15 matching lines...) Expand all
41 QuicVersion version) { 42 QuicVersion version) {
42 return QuicPacketCreator::StreamFramePacketOverhead( 43 return QuicPacketCreator::StreamFramePacketOverhead(
43 version, PACKET_8BYTE_CONNECTION_ID, 44 version, PACKET_8BYTE_CONNECTION_ID,
44 /*include_version=*/true, 45 /*include_version=*/true,
45 /*include_path_id=*/true, 46 /*include_path_id=*/true,
46 /*include_diversification_nonce=*/true, PACKET_1BYTE_PACKET_NUMBER, 47 /*include_diversification_nonce=*/true, PACKET_1BYTE_PACKET_NUMBER,
47 /*offset=*/0); 48 /*offset=*/0);
48 } 49 }
49 50
50 void QuicCryptoStream::OnError(CryptoFramer* framer) { 51 void QuicCryptoStream::OnError(CryptoFramer* framer) {
51 DLOG(WARNING) << "Error processing crypto data: " 52 QUIC_DLOG(WARNING) << "Error processing crypto data: "
52 << QuicErrorCodeToString(framer->error()); 53 << QuicErrorCodeToString(framer->error());
53 } 54 }
54 55
55 void QuicCryptoStream::OnHandshakeMessage( 56 void QuicCryptoStream::OnHandshakeMessage(
56 const CryptoHandshakeMessage& message) { 57 const CryptoHandshakeMessage& message) {
57 DVLOG(1) << ENDPOINT << "Received " << message.DebugString(); 58 QUIC_DVLOG(1) << ENDPOINT << "Received " << message.DebugString();
58 session()->OnCryptoHandshakeMessageReceived(message); 59 session()->OnCryptoHandshakeMessageReceived(message);
59 } 60 }
60 61
61 void QuicCryptoStream::OnDataAvailable() { 62 void QuicCryptoStream::OnDataAvailable() {
62 struct iovec iov; 63 struct iovec iov;
63 while (true) { 64 while (true) {
64 if (sequencer()->GetReadableRegions(&iov, 1) != 1) { 65 if (sequencer()->GetReadableRegions(&iov, 1) != 1) {
65 // No more data to read. 66 // No more data to read.
66 break; 67 break;
67 } 68 }
68 StringPiece data(static_cast<char*>(iov.iov_base), iov.iov_len); 69 StringPiece data(static_cast<char*>(iov.iov_base), iov.iov_len);
69 if (!crypto_framer_.ProcessInput(data)) { 70 if (!crypto_framer_.ProcessInput(data)) {
70 CloseConnectionWithDetails(crypto_framer_.error(), 71 CloseConnectionWithDetails(crypto_framer_.error(),
71 crypto_framer_.error_detail()); 72 crypto_framer_.error_detail());
72 return; 73 return;
73 } 74 }
74 sequencer()->MarkConsumed(iov.iov_len); 75 sequencer()->MarkConsumed(iov.iov_len);
75 if (handshake_confirmed_ && crypto_framer_.InputBytesRemaining() == 0 && 76 if (handshake_confirmed_ && crypto_framer_.InputBytesRemaining() == 0 &&
76 FLAGS_quic_reloadable_flag_quic_release_crypto_stream_buffer) { 77 FLAGS_quic_reloadable_flag_quic_release_crypto_stream_buffer) {
77 // If the handshake is complete and the current message has been fully 78 // If the handshake is complete and the current message has been fully
78 // processed then no more handshake messages are likely to arrive soon 79 // processed then no more handshake messages are likely to arrive soon
79 // so release the memory in the stream sequencer. 80 // so release the memory in the stream sequencer.
80 sequencer()->ReleaseBufferIfEmpty(); 81 sequencer()->ReleaseBufferIfEmpty();
81 } 82 }
82 } 83 }
83 } 84 }
84 85
85 void QuicCryptoStream::SendHandshakeMessage( 86 void QuicCryptoStream::SendHandshakeMessage(
86 const CryptoHandshakeMessage& message) { 87 const CryptoHandshakeMessage& message) {
87 DVLOG(1) << ENDPOINT << "Sending " << message.DebugString(); 88 QUIC_DVLOG(1) << ENDPOINT << "Sending " << message.DebugString();
88 session()->connection()->NeuterUnencryptedPackets(); 89 session()->connection()->NeuterUnencryptedPackets();
89 session()->OnCryptoHandshakeMessageSent(message); 90 session()->OnCryptoHandshakeMessageSent(message);
90 const QuicData& data = message.GetSerialized(); 91 const QuicData& data = message.GetSerialized();
91 WriteOrBufferData(StringPiece(data.data(), data.length()), false, nullptr); 92 WriteOrBufferData(StringPiece(data.data(), data.length()), false, nullptr);
92 } 93 }
93 94
94 bool QuicCryptoStream::ExportKeyingMaterial(StringPiece label, 95 bool QuicCryptoStream::ExportKeyingMaterial(StringPiece label,
95 StringPiece context, 96 StringPiece context,
96 size_t result_len, 97 size_t result_len,
97 string* result) const { 98 string* result) const {
98 if (!handshake_confirmed()) { 99 if (!handshake_confirmed()) {
99 DLOG(ERROR) << "ExportKeyingMaterial was called before forward-secure" 100 QUIC_DLOG(ERROR) << "ExportKeyingMaterial was called before forward-secure"
100 << "encryption was established."; 101 << "encryption was established.";
101 return false; 102 return false;
102 } 103 }
103 return CryptoUtils::ExportKeyingMaterial( 104 return CryptoUtils::ExportKeyingMaterial(
104 crypto_negotiated_params_->subkey_secret, label, context, result_len, 105 crypto_negotiated_params_->subkey_secret, label, context, result_len,
105 result); 106 result);
106 } 107 }
107 108
108 bool QuicCryptoStream::ExportTokenBindingKeyingMaterial(string* result) const { 109 bool QuicCryptoStream::ExportTokenBindingKeyingMaterial(string* result) const {
109 if (!encryption_established()) { 110 if (!encryption_established()) {
110 QUIC_BUG << "ExportTokenBindingKeyingMaterial was called before initial" 111 QUIC_BUG << "ExportTokenBindingKeyingMaterial was called before initial"
111 << "encryption was established."; 112 << "encryption was established.";
112 return false; 113 return false;
113 } 114 }
114 return CryptoUtils::ExportKeyingMaterial( 115 return CryptoUtils::ExportKeyingMaterial(
115 crypto_negotiated_params_->initial_subkey_secret, 116 crypto_negotiated_params_->initial_subkey_secret,
116 "EXPORTER-Token-Binding", 117 "EXPORTER-Token-Binding",
117 /* context= */ "", 32, result); 118 /* context= */ "", 32, result);
118 } 119 }
119 120
120 const QuicCryptoNegotiatedParameters& 121 const QuicCryptoNegotiatedParameters&
121 QuicCryptoStream::crypto_negotiated_params() const { 122 QuicCryptoStream::crypto_negotiated_params() const {
122 return *crypto_negotiated_params_; 123 return *crypto_negotiated_params_;
123 } 124 }
124 125
125 } // namespace net 126 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_crypto_server_stream_test.cc ('k') | net/quic/core/quic_data_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698