| 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/crypto/null_decrypter.h" | 5 #include "net/quic/crypto/null_decrypter.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "net/quic/quic_bug_tracker.h" | 9 #include "net/quic/quic_bug_tracker.h" |
| 10 #include "net/quic/quic_data_reader.h" | 10 #include "net/quic/quic_data_reader.h" |
| 11 #include "net/quic/quic_utils.h" | 11 #include "net/quic/quic_utils.h" |
| 12 | 12 |
| 13 using base::StringPiece; | 13 using base::StringPiece; |
| 14 using std::string; | 14 using std::string; |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 NullDecrypter::NullDecrypter() {} | 18 NullDecrypter::NullDecrypter() {} |
| 19 | 19 |
| 20 bool NullDecrypter::SetKey(StringPiece key) { | 20 bool NullDecrypter::SetKey(StringPiece key) { |
| 21 return key.empty(); | 21 return key.empty(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool NullDecrypter::SetNoncePrefix(StringPiece nonce_prefix) { | 24 bool NullDecrypter::SetNoncePrefix(StringPiece nonce_prefix) { |
| 25 return nonce_prefix.empty(); | 25 return nonce_prefix.empty(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool NullDecrypter::DecryptPacket(QuicPathId /*path_id*/, | 28 bool NullDecrypter::DecryptPacket(QuicPathId /*path_id*/, |
| 29 QuicPacketNumber /*packet_number*/, | 29 QuicPacketNumber /*packet_number*/, |
| 30 const StringPiece& associated_data, | 30 StringPiece associated_data, |
| 31 const StringPiece& ciphertext, | 31 StringPiece ciphertext, |
| 32 char* output, | 32 char* output, |
| 33 size_t* output_length, | 33 size_t* output_length, |
| 34 size_t max_output_length) { | 34 size_t max_output_length) { |
| 35 QuicDataReader reader(ciphertext.data(), ciphertext.length()); | 35 QuicDataReader reader(ciphertext.data(), ciphertext.length()); |
| 36 uint128 hash; | 36 uint128 hash; |
| 37 | 37 |
| 38 if (!ReadHash(&reader, &hash)) { | 38 if (!ReadHash(&reader, &hash)) { |
| 39 return false; | 39 return false; |
| 40 } | 40 } |
| 41 | 41 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 const StringPiece data2) const { | 85 const StringPiece data2) const { |
| 86 uint128 correct_hash = QuicUtils::FNV1a_128_Hash_Two( | 86 uint128 correct_hash = QuicUtils::FNV1a_128_Hash_Two( |
| 87 data1.data(), data1.length(), data2.data(), data2.length()); | 87 data1.data(), data1.length(), data2.data(), data2.length()); |
| 88 uint128 mask(UINT64_C(0x0), UINT64_C(0xffffffff)); | 88 uint128 mask(UINT64_C(0x0), UINT64_C(0xffffffff)); |
| 89 mask <<= 96; | 89 mask <<= 96; |
| 90 correct_hash &= ~mask; | 90 correct_hash &= ~mask; |
| 91 return correct_hash; | 91 return correct_hash; |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace net | 94 } // namespace net |
| OLD | NEW |