| 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_connection.h" | 5 #include "net/quic/quic_connection.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 DISALLOW_COPY_AND_ASSIGN(TestReceiveAlgorithm); | 85 DISALLOW_COPY_AND_ASSIGN(TestReceiveAlgorithm); |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 // TaggingEncrypter appends kTagSize bytes of |tag| to the end of each message. | 88 // TaggingEncrypter appends kTagSize bytes of |tag| to the end of each message. |
| 89 class TaggingEncrypter : public QuicEncrypter { | 89 class TaggingEncrypter : public QuicEncrypter { |
| 90 public: | 90 public: |
| 91 explicit TaggingEncrypter(uint8 tag) | 91 explicit TaggingEncrypter(uint8 tag) |
| 92 : tag_(tag) { | 92 : tag_(tag) { |
| 93 } | 93 } |
| 94 | 94 |
| 95 virtual ~TaggingEncrypter() {} | 95 virtual ~TaggingEncrypter() OVERRIDE {} |
| 96 | 96 |
| 97 // QuicEncrypter interface. | 97 // QuicEncrypter interface. |
| 98 virtual bool SetKey(StringPiece key) OVERRIDE { return true; } | 98 virtual bool SetKey(StringPiece key) OVERRIDE { return true; } |
| 99 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { | 99 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { |
| 100 return true; | 100 return true; |
| 101 } | 101 } |
| 102 | 102 |
| 103 virtual bool Encrypt(StringPiece nonce, | 103 virtual bool Encrypt(StringPiece nonce, |
| 104 StringPiece associated_data, | 104 StringPiece associated_data, |
| 105 StringPiece plaintext, | 105 StringPiece plaintext, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 kTagSize = 12, | 143 kTagSize = 12, |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 const uint8 tag_; | 146 const uint8 tag_; |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 // TaggingDecrypter ensures that the final kTagSize bytes of the message all | 149 // TaggingDecrypter ensures that the final kTagSize bytes of the message all |
| 150 // have the same value and then removes them. | 150 // have the same value and then removes them. |
| 151 class TaggingDecrypter : public QuicDecrypter { | 151 class TaggingDecrypter : public QuicDecrypter { |
| 152 public: | 152 public: |
| 153 virtual ~TaggingDecrypter() {} | 153 virtual ~TaggingDecrypter() OVERRIDE {} |
| 154 | 154 |
| 155 // QuicDecrypter interface | 155 // QuicDecrypter interface |
| 156 virtual bool SetKey(StringPiece key) OVERRIDE { return true; } | 156 virtual bool SetKey(StringPiece key) OVERRIDE { return true; } |
| 157 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { | 157 virtual bool SetNoncePrefix(StringPiece nonce_prefix) OVERRIDE { |
| 158 return true; | 158 return true; |
| 159 } | 159 } |
| 160 | 160 |
| 161 virtual bool Decrypt(StringPiece nonce, | 161 virtual bool Decrypt(StringPiece nonce, |
| 162 StringPiece associated_data, | 162 StringPiece associated_data, |
| 163 StringPiece ciphertext, | 163 StringPiece ciphertext, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 return true; | 213 return true; |
| 214 } | 214 } |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 // StringTaggingDecrypter ensures that the final kTagSize bytes of the message | 217 // StringTaggingDecrypter ensures that the final kTagSize bytes of the message |
| 218 // match the expected value. | 218 // match the expected value. |
| 219 class StrictTaggingDecrypter : public TaggingDecrypter { | 219 class StrictTaggingDecrypter : public TaggingDecrypter { |
| 220 public: | 220 public: |
| 221 explicit StrictTaggingDecrypter(uint8 tag) : tag_(tag) {} | 221 explicit StrictTaggingDecrypter(uint8 tag) : tag_(tag) {} |
| 222 virtual ~StrictTaggingDecrypter() {} | 222 virtual ~StrictTaggingDecrypter() OVERRIDE {} |
| 223 | 223 |
| 224 // TaggingQuicDecrypter | 224 // TaggingQuicDecrypter |
| 225 virtual uint8 GetTag(StringPiece ciphertext) OVERRIDE { | 225 virtual uint8 GetTag(StringPiece ciphertext) OVERRIDE { |
| 226 return tag_; | 226 return tag_; |
| 227 } | 227 } |
| 228 | 228 |
| 229 private: | 229 private: |
| 230 const uint8 tag_; | 230 const uint8 tag_; |
| 231 }; | 231 }; |
| 232 | 232 |
| (...skipping 3122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3355 true); | 3355 true); |
| 3356 TestConnection client(guid_, IPEndPoint(), helper_.get(), writer_.get(), | 3356 TestConnection client(guid_, IPEndPoint(), helper_.get(), writer_.get(), |
| 3357 false); | 3357 false); |
| 3358 EXPECT_TRUE(client.sent_packet_manager().using_pacing()); | 3358 EXPECT_TRUE(client.sent_packet_manager().using_pacing()); |
| 3359 EXPECT_FALSE(server.sent_packet_manager().using_pacing()); | 3359 EXPECT_FALSE(server.sent_packet_manager().using_pacing()); |
| 3360 } | 3360 } |
| 3361 | 3361 |
| 3362 } // namespace | 3362 } // namespace |
| 3363 } // namespace test | 3363 } // namespace test |
| 3364 } // namespace net | 3364 } // namespace net |
| OLD | NEW |