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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 bool Encrypt(StringPiece nonce, | 80 bool Encrypt(StringPiece nonce, |
81 StringPiece associated_data, | 81 StringPiece associated_data, |
82 StringPiece plaintext, | 82 StringPiece plaintext, |
83 unsigned char* output) override { | 83 unsigned char* output) override { |
84 memcpy(output, plaintext.data(), plaintext.size()); | 84 memcpy(output, plaintext.data(), plaintext.size()); |
85 output += plaintext.size(); | 85 output += plaintext.size(); |
86 memset(output, tag_, kTagSize); | 86 memset(output, tag_, kTagSize); |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
90 QuicData* EncryptPacket(QuicPacketSequenceNumber sequence_number, | 90 bool EncryptPacket(QuicPacketSequenceNumber sequence_number, |
91 StringPiece associated_data, | 91 StringPiece associated_data, |
92 StringPiece plaintext) override { | 92 StringPiece plaintext, |
| 93 char* output, |
| 94 size_t* output_length, |
| 95 size_t max_output_length) override { |
93 const size_t len = plaintext.size() + kTagSize; | 96 const size_t len = plaintext.size() + kTagSize; |
94 uint8* buffer = new uint8[len]; | 97 if (max_output_length < len) { |
95 Encrypt(StringPiece(), associated_data, plaintext, buffer); | 98 return false; |
96 return new QuicData(reinterpret_cast<char*>(buffer), len, true); | 99 } |
| 100 Encrypt(StringPiece(), associated_data, plaintext, |
| 101 reinterpret_cast<unsigned char*>(output)); |
| 102 *output_length = len; |
| 103 return true; |
97 } | 104 } |
98 | 105 |
99 size_t GetKeySize() const override { return 0; } | 106 size_t GetKeySize() const override { return 0; } |
100 size_t GetNoncePrefixSize() const override { return 0; } | 107 size_t GetNoncePrefixSize() const override { return 0; } |
101 | 108 |
102 size_t GetMaxPlaintextSize(size_t ciphertext_size) const override { | 109 size_t GetMaxPlaintextSize(size_t ciphertext_size) const override { |
103 return ciphertext_size - kTagSize; | 110 return ciphertext_size - kTagSize; |
104 } | 111 } |
105 | 112 |
106 size_t GetCiphertextSize(size_t plaintext_size) const override { | 113 size_t GetCiphertextSize(size_t plaintext_size) const override { |
(...skipping 4290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4397 // Regression test for b/18594622 | 4404 // Regression test for b/18594622 |
4398 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); | 4405 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); |
4399 EXPECT_DFATAL( | 4406 EXPECT_DFATAL( |
4400 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), | 4407 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), |
4401 "Attempt to send empty stream frame"); | 4408 "Attempt to send empty stream frame"); |
4402 } | 4409 } |
4403 | 4410 |
4404 } // namespace | 4411 } // namespace |
4405 } // namespace test | 4412 } // namespace test |
4406 } // namespace net | 4413 } // namespace net |
OLD | NEW |