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

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

Issue 912163002: Change the QuicEncrypter to accept a pre-allocated buffer instead of (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Change_QuicPacketCreator_85897935
Patch Set: Reverting logging changes Created 5 years, 10 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_framer.cc ('k') | no next file » | 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/quic_framer.h" 5 #include "net/quic/quic_framer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ~TestEncrypter() override {} 106 ~TestEncrypter() override {}
107 bool SetKey(StringPiece key) override { return true; } 107 bool SetKey(StringPiece key) override { return true; }
108 bool SetNoncePrefix(StringPiece nonce_prefix) override { return true; } 108 bool SetNoncePrefix(StringPiece nonce_prefix) override { return true; }
109 bool Encrypt(StringPiece nonce, 109 bool Encrypt(StringPiece nonce,
110 StringPiece associated_data, 110 StringPiece associated_data,
111 StringPiece plaintext, 111 StringPiece plaintext,
112 unsigned char* output) override { 112 unsigned char* output) override {
113 CHECK(false) << "Not implemented"; 113 CHECK(false) << "Not implemented";
114 return false; 114 return false;
115 } 115 }
116 QuicData* EncryptPacket(QuicPacketSequenceNumber sequence_number, 116 bool EncryptPacket(QuicPacketSequenceNumber sequence_number,
117 StringPiece associated_data, 117 StringPiece associated_data,
118 StringPiece plaintext) override { 118 StringPiece plaintext,
119 char* output,
120 size_t* output_length,
121 size_t max_output_length) override {
119 sequence_number_ = sequence_number; 122 sequence_number_ = sequence_number;
120 associated_data_ = associated_data.as_string(); 123 associated_data_ = associated_data.as_string();
121 plaintext_ = plaintext.as_string(); 124 plaintext_ = plaintext.as_string();
122 return new QuicData(plaintext.data(), plaintext.length()); 125 memcpy(output, plaintext.data(), plaintext.length());
126 *output_length = plaintext.length();
127 return true;
123 } 128 }
124 size_t GetKeySize() const override { return 0; } 129 size_t GetKeySize() const override { return 0; }
125 size_t GetNoncePrefixSize() const override { return 0; } 130 size_t GetNoncePrefixSize() const override { return 0; }
126 size_t GetMaxPlaintextSize(size_t ciphertext_size) const override { 131 size_t GetMaxPlaintextSize(size_t ciphertext_size) const override {
127 return ciphertext_size; 132 return ciphertext_size;
128 } 133 }
129 size_t GetCiphertextSize(size_t plaintext_size) const override { 134 size_t GetCiphertextSize(size_t plaintext_size) const override {
130 return plaintext_size; 135 return plaintext_size;
131 } 136 }
132 StringPiece GetKey() const override { return StringPiece(); } 137 StringPiece GetKey() const override { return StringPiece(); }
(...skipping 4121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4254 EXPECT_CALL(visitor, OnPacketComplete()); 4259 EXPECT_CALL(visitor, OnPacketComplete());
4255 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); 4260 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true));
4256 4261
4257 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 4262 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
4258 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 4263 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
4259 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 4264 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
4260 } 4265 }
4261 4266
4262 } // namespace test 4267 } // namespace test
4263 } // namespace net 4268 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698