| 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/core/crypto/crypto_framer.h" | 5 #include "net/quic/core/crypto/crypto_framer.h" |
| 6 | 6 |
| 7 #include "net/quic/core/crypto/crypto_protocol.h" | 7 #include "net/quic/core/crypto/crypto_protocol.h" |
| 8 #include "net/quic/core/quic_data_reader.h" | 8 #include "net/quic/core/quic_data_reader.h" |
| 9 #include "net/quic/core/quic_data_writer.h" | 9 #include "net/quic/core/quic_data_writer.h" |
| 10 #include "net/quic/core/quic_packets.h" | 10 #include "net/quic/core/quic_packets.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 pad_length = delta - overhead; | 101 pad_length = delta - overhead; |
| 102 } | 102 } |
| 103 len += overhead + pad_length; | 103 len += overhead + pad_length; |
| 104 } | 104 } |
| 105 | 105 |
| 106 if (num_entries > kMaxEntries) { | 106 if (num_entries > kMaxEntries) { |
| 107 return nullptr; | 107 return nullptr; |
| 108 } | 108 } |
| 109 | 109 |
| 110 std::unique_ptr<char[]> buffer(new char[len]); | 110 std::unique_ptr<char[]> buffer(new char[len]); |
| 111 QuicDataWriter writer(len, buffer.get(), perspective); | 111 QuicDataWriter writer(len, buffer.get(), perspective, HOST_BYTE_ORDER); |
| 112 if (!writer.WriteTag(message.tag())) { | 112 if (!writer.WriteTag(message.tag())) { |
| 113 DCHECK(false) << "Failed to write message tag."; | 113 DCHECK(false) << "Failed to write message tag."; |
| 114 return nullptr; | 114 return nullptr; |
| 115 } | 115 } |
| 116 if (!writer.WriteUInt16(static_cast<uint16_t>(num_entries))) { | 116 if (!writer.WriteUInt16(static_cast<uint16_t>(num_entries))) { |
| 117 DCHECK(false) << "Failed to write size."; | 117 DCHECK(false) << "Failed to write size."; |
| 118 return nullptr; | 118 return nullptr; |
| 119 } | 119 } |
| 120 if (!writer.WriteUInt16(0)) { | 120 if (!writer.WriteUInt16(0)) { |
| 121 DCHECK(false) << "Failed to write padding."; | 121 DCHECK(false) << "Failed to write padding."; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 tags_and_lengths_.clear(); | 190 tags_and_lengths_.clear(); |
| 191 error_ = QUIC_NO_ERROR; | 191 error_ = QUIC_NO_ERROR; |
| 192 error_detail_ = ""; | 192 error_detail_ = ""; |
| 193 state_ = STATE_READING_TAG; | 193 state_ = STATE_READING_TAG; |
| 194 } | 194 } |
| 195 | 195 |
| 196 QuicErrorCode CryptoFramer::Process(QuicStringPiece input, | 196 QuicErrorCode CryptoFramer::Process(QuicStringPiece input, |
| 197 Perspective perspective) { | 197 Perspective perspective) { |
| 198 // Add this data to the buffer. | 198 // Add this data to the buffer. |
| 199 buffer_.append(input.data(), input.length()); | 199 buffer_.append(input.data(), input.length()); |
| 200 QuicDataReader reader(buffer_.data(), buffer_.length(), perspective); | 200 QuicDataReader reader(buffer_.data(), buffer_.length(), perspective, |
| 201 HOST_BYTE_ORDER); |
| 201 | 202 |
| 202 switch (state_) { | 203 switch (state_) { |
| 203 case STATE_READING_TAG: | 204 case STATE_READING_TAG: |
| 204 if (reader.BytesRemaining() < kQuicTagSize) { | 205 if (reader.BytesRemaining() < kQuicTagSize) { |
| 205 break; | 206 break; |
| 206 } | 207 } |
| 207 QuicTag message_tag; | 208 QuicTag message_tag; |
| 208 reader.ReadTag(&message_tag); | 209 reader.ReadTag(&message_tag); |
| 209 message_.set_tag(message_tag); | 210 message_.set_tag(message_tag); |
| 210 state_ = STATE_READING_NUM_ENTRIES; | 211 state_ = STATE_READING_NUM_ENTRIES; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 } | 287 } |
| 287 *end_offset += pad_length; | 288 *end_offset += pad_length; |
| 288 if (!writer->WriteUInt32(*end_offset)) { | 289 if (!writer->WriteUInt32(*end_offset)) { |
| 289 DCHECK(false) << "Failed to write end offset."; | 290 DCHECK(false) << "Failed to write end offset."; |
| 290 return false; | 291 return false; |
| 291 } | 292 } |
| 292 return true; | 293 return true; |
| 293 } | 294 } |
| 294 | 295 |
| 295 } // namespace net | 296 } // namespace net |
| OLD | NEW |