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

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

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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/quic_crypto_stream.h ('k') | net/quic/quic_crypto_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/quic/quic_crypto_stream.h"
6
7 #include <string>
8
9 #include "base/strings/string_piece.h"
10 #include "net/quic/crypto/crypto_handshake.h"
11 #include "net/quic/crypto/crypto_utils.h"
12 #include "net/quic/quic_connection.h"
13 #include "net/quic/quic_session.h"
14 #include "net/quic/quic_utils.h"
15
16 using std::string;
17 using base::StringPiece;
18
19 namespace net {
20
21 #define ENDPOINT (session()->is_server() ? "Server: " : " Client: ")
22
23 QuicCryptoStream::QuicCryptoStream(QuicSession* session)
24 : ReliableQuicStream(kCryptoStreamId, session),
25 encryption_established_(false),
26 handshake_confirmed_(false) {
27 crypto_framer_.set_visitor(this);
28 // The crypto stream is exempt from connection level flow control.
29 DisableConnectionFlowControlForThisStream();
30 }
31
32 void QuicCryptoStream::OnError(CryptoFramer* framer) {
33 DLOG(WARNING) << "Error processing crypto data: "
34 << QuicUtils::ErrorToString(framer->error());
35 }
36
37 void QuicCryptoStream::OnHandshakeMessage(
38 const CryptoHandshakeMessage& message) {
39 DVLOG(1) << ENDPOINT << "Received " << message.DebugString();
40 session()->OnCryptoHandshakeMessageReceived(message);
41 }
42
43 uint32 QuicCryptoStream::ProcessRawData(const char* data,
44 uint32 data_len) {
45 if (!crypto_framer_.ProcessInput(StringPiece(data, data_len))) {
46 CloseConnection(crypto_framer_.error());
47 return 0;
48 }
49 return data_len;
50 }
51
52 QuicPriority QuicCryptoStream::EffectivePriority() const {
53 return QuicUtils::HighestPriority();
54 }
55
56 void QuicCryptoStream::SendHandshakeMessage(
57 const CryptoHandshakeMessage& message) {
58 SendHandshakeMessage(message, nullptr);
59 }
60
61 void QuicCryptoStream::SendHandshakeMessage(
62 const CryptoHandshakeMessage& message,
63 QuicAckNotifier::DelegateInterface* delegate) {
64 DVLOG(1) << ENDPOINT << "Sending " << message.DebugString();
65 session()->OnCryptoHandshakeMessageSent(message);
66 const QuicData& data = message.GetSerialized();
67 // TODO(wtc): check the return value.
68 WriteOrBufferData(string(data.data(), data.length()), false, delegate);
69 }
70
71 bool QuicCryptoStream::ExportKeyingMaterial(
72 StringPiece label,
73 StringPiece context,
74 size_t result_len,
75 string* result) const {
76 if (!handshake_confirmed()) {
77 DLOG(ERROR) << "ExportKeyingMaterial was called before forward-secure"
78 << "encryption was established.";
79 return false;
80 }
81 return CryptoUtils::ExportKeyingMaterial(
82 crypto_negotiated_params_.subkey_secret,
83 label,
84 context,
85 result_len,
86 result);
87 }
88
89 const QuicCryptoNegotiatedParameters&
90 QuicCryptoStream::crypto_negotiated_params() const {
91 return crypto_negotiated_params_;
92 }
93
94 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_stream.h ('k') | net/quic/quic_crypto_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698