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 <algorithm> | 5 #include <algorithm> |
6 #include <map> | 6 #include <map> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // Public resets always have full guids. | 90 // Public resets always have full guids. |
91 const size_t kPublicResetPacketNonceProofOffset = | 91 const size_t kPublicResetPacketNonceProofOffset = |
92 kGuidOffset + PACKET_8BYTE_GUID; | 92 kGuidOffset + PACKET_8BYTE_GUID; |
93 | 93 |
94 // Index into the rejected sequence number of the public reset packet. | 94 // Index into the rejected sequence number of the public reset packet. |
95 const size_t kPublicResetPacketRejectedSequenceNumberOffset = | 95 const size_t kPublicResetPacketRejectedSequenceNumberOffset = |
96 kPublicResetPacketNonceProofOffset + kPublicResetNonceSize; | 96 kPublicResetPacketNonceProofOffset + kPublicResetNonceSize; |
97 | 97 |
98 class TestEncrypter : public QuicEncrypter { | 98 class TestEncrypter : public QuicEncrypter { |
99 public: | 99 public: |
100 virtual ~TestEncrypter() {} | 100 virtual ~TestEncrypter() OVERRIDE {} |
101 virtual bool SetKey(StringPiece key) OVERRIDE { | 101 virtual bool SetKey(StringPiece key) OVERRIDE { |
102 return true; | 102 return true; |
103 } | 103 } |
104 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { | 104 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { |
105 return true; | 105 return true; |
106 } | 106 } |
107 virtual bool Encrypt(StringPiece nonce, | 107 virtual bool Encrypt(StringPiece nonce, |
108 StringPiece associated_data, | 108 StringPiece associated_data, |
109 StringPiece plaintext, | 109 StringPiece plaintext, |
110 unsigned char* output) OVERRIDE { | 110 unsigned char* output) OVERRIDE { |
(...skipping 26 matching lines...) Expand all Loading... |
137 virtual StringPiece GetNoncePrefix() const OVERRIDE { | 137 virtual StringPiece GetNoncePrefix() const OVERRIDE { |
138 return StringPiece(); | 138 return StringPiece(); |
139 } | 139 } |
140 QuicPacketSequenceNumber sequence_number_; | 140 QuicPacketSequenceNumber sequence_number_; |
141 string associated_data_; | 141 string associated_data_; |
142 string plaintext_; | 142 string plaintext_; |
143 }; | 143 }; |
144 | 144 |
145 class TestDecrypter : public QuicDecrypter { | 145 class TestDecrypter : public QuicDecrypter { |
146 public: | 146 public: |
147 virtual ~TestDecrypter() {} | 147 virtual ~TestDecrypter() OVERRIDE {} |
148 virtual bool SetKey(StringPiece key) OVERRIDE { | 148 virtual bool SetKey(StringPiece key) OVERRIDE { |
149 return true; | 149 return true; |
150 } | 150 } |
151 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { | 151 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { |
152 return true; | 152 return true; |
153 } | 153 } |
154 virtual bool Decrypt(StringPiece nonce, | 154 virtual bool Decrypt(StringPiece nonce, |
155 StringPiece associated_data, | 155 StringPiece associated_data, |
156 StringPiece ciphertext, | 156 StringPiece ciphertext, |
157 unsigned char* output, | 157 unsigned char* output, |
(...skipping 27 matching lines...) Expand all Loading... |
185 version_mismatch_(0), | 185 version_mismatch_(0), |
186 packet_count_(0), | 186 packet_count_(0), |
187 frame_count_(0), | 187 frame_count_(0), |
188 fec_count_(0), | 188 fec_count_(0), |
189 complete_packets_(0), | 189 complete_packets_(0), |
190 revived_packets_(0), | 190 revived_packets_(0), |
191 accept_packet_(true), | 191 accept_packet_(true), |
192 accept_public_header_(true) { | 192 accept_public_header_(true) { |
193 } | 193 } |
194 | 194 |
195 virtual ~TestQuicVisitor() { | 195 virtual ~TestQuicVisitor() OVERRIDE { |
196 STLDeleteElements(&stream_frames_); | 196 STLDeleteElements(&stream_frames_); |
197 STLDeleteElements(&ack_frames_); | 197 STLDeleteElements(&ack_frames_); |
198 STLDeleteElements(&congestion_feedback_frames_); | 198 STLDeleteElements(&congestion_feedback_frames_); |
199 STLDeleteElements(&fec_data_); | 199 STLDeleteElements(&fec_data_); |
200 } | 200 } |
201 | 201 |
202 virtual void OnError(QuicFramer* f) OVERRIDE { | 202 virtual void OnError(QuicFramer* f) OVERRIDE { |
203 DLOG(INFO) << "QuicFramer Error: " << QuicUtils::ErrorToString(f->error()) | 203 DLOG(INFO) << "QuicFramer Error: " << QuicUtils::ErrorToString(f->error()) |
204 << " (" << f->error() << ")"; | 204 << " (" << f->error() << ")"; |
205 error_count_++; | 205 error_count_++; |
(...skipping 3301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3507 EXPECT_CALL(visitor, OnPacketComplete()); | 3507 EXPECT_CALL(visitor, OnPacketComplete()); |
3508 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); | 3508 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); |
3509 | 3509 |
3510 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); | 3510 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); |
3511 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); | 3511 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); |
3512 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); | 3512 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); |
3513 } | 3513 } |
3514 | 3514 |
3515 } // namespace test | 3515 } // namespace test |
3516 } // namespace net | 3516 } // namespace net |
OLD | NEW |