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/null_decrypter.h" | 5 #include "net/quic/core/crypto/null_decrypter.h" |
6 | 6 |
7 #include <cstdint> | 7 #include <cstdint> |
8 | 8 |
9 #include "net/base/int128.h" | 9 #include "net/base/int128.h" |
10 #include "net/quic/core/quic_data_reader.h" | 10 #include "net/quic/core/quic_data_reader.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 return true; | 36 return true; |
37 } | 37 } |
38 | 38 |
39 bool NullDecrypter::DecryptPacket(QuicVersion version, | 39 bool NullDecrypter::DecryptPacket(QuicVersion version, |
40 QuicPacketNumber /*packet_number*/, | 40 QuicPacketNumber /*packet_number*/, |
41 QuicStringPiece associated_data, | 41 QuicStringPiece associated_data, |
42 QuicStringPiece ciphertext, | 42 QuicStringPiece ciphertext, |
43 char* output, | 43 char* output, |
44 size_t* output_length, | 44 size_t* output_length, |
45 size_t max_output_length) { | 45 size_t max_output_length) { |
46 QuicDataReader reader(ciphertext.data(), ciphertext.length(), perspective_); | 46 QuicDataReader reader(ciphertext.data(), ciphertext.length(), perspective_, |
| 47 HOST_BYTE_ORDER); |
47 uint128 hash; | 48 uint128 hash; |
48 | 49 |
49 if (!ReadHash(&reader, &hash)) { | 50 if (!ReadHash(&reader, &hash)) { |
50 return false; | 51 return false; |
51 } | 52 } |
52 | 53 |
53 QuicStringPiece plaintext = reader.ReadRemainingPayload(); | 54 QuicStringPiece plaintext = reader.ReadRemainingPayload(); |
54 if (plaintext.length() > max_output_length) { | 55 if (plaintext.length() > max_output_length) { |
55 QUIC_BUG << "Output buffer must be larger than the plaintext."; | 56 QUIC_BUG << "Output buffer must be larger than the plaintext."; |
56 return false; | 57 return false; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } else { | 107 } else { |
107 correct_hash = QuicUtils::FNV1a_128_Hash_Two(data1, data2); | 108 correct_hash = QuicUtils::FNV1a_128_Hash_Two(data1, data2); |
108 } | 109 } |
109 uint128 mask = MakeUint128(UINT64_C(0x0), UINT64_C(0xffffffff)); | 110 uint128 mask = MakeUint128(UINT64_C(0x0), UINT64_C(0xffffffff)); |
110 mask <<= 96; | 111 mask <<= 96; |
111 correct_hash &= ~mask; | 112 correct_hash &= ~mask; |
112 return correct_hash; | 113 return correct_hash; |
113 } | 114 } |
114 | 115 |
115 } // namespace net | 116 } // namespace net |
OLD | NEW |