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_data_reader.h" | 9 #include "net/quic/quic_data_reader.h" |
10 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 StringPiece NullDecrypter::GetNoncePrefix() const { | 58 StringPiece NullDecrypter::GetNoncePrefix() const { |
59 return StringPiece(); | 59 return StringPiece(); |
60 } | 60 } |
61 | 61 |
62 const char* NullDecrypter::cipher_name() const { | 62 const char* NullDecrypter::cipher_name() const { |
63 return "NULL"; | 63 return "NULL"; |
64 } | 64 } |
65 | 65 |
66 uint32 NullDecrypter::cipher_id() const { | 66 uint32_t NullDecrypter::cipher_id() const { |
67 return 0; | 67 return 0; |
68 } | 68 } |
69 | 69 |
70 bool NullDecrypter::ReadHash(QuicDataReader* reader, uint128* hash) { | 70 bool NullDecrypter::ReadHash(QuicDataReader* reader, uint128* hash) { |
71 uint64 lo; | 71 uint64_t lo; |
72 uint32 hi; | 72 uint32_t hi; |
73 if (!reader->ReadUInt64(&lo) || !reader->ReadUInt32(&hi)) { | 73 if (!reader->ReadUInt64(&lo) || !reader->ReadUInt32(&hi)) { |
74 return false; | 74 return false; |
75 } | 75 } |
76 *hash = hi; | 76 *hash = hi; |
77 *hash <<= 64; | 77 *hash <<= 64; |
78 *hash += lo; | 78 *hash += lo; |
79 return true; | 79 return true; |
80 } | 80 } |
81 | 81 |
82 uint128 NullDecrypter::ComputeHash(const StringPiece data1, | 82 uint128 NullDecrypter::ComputeHash(const StringPiece data1, |
83 const StringPiece data2) const { | 83 const StringPiece data2) const { |
84 uint128 correct_hash = QuicUtils::FNV1a_128_Hash_Two( | 84 uint128 correct_hash = QuicUtils::FNV1a_128_Hash_Two( |
85 data1.data(), data1.length(), data2.data(), data2.length()); | 85 data1.data(), data1.length(), data2.data(), data2.length()); |
86 uint128 mask(UINT64_C(0x0), UINT64_C(0xffffffff)); | 86 uint128 mask(UINT64_C(0x0), UINT64_C(0xffffffff)); |
87 mask <<= 96; | 87 mask <<= 96; |
88 correct_hash &= ~mask; | 88 correct_hash &= ~mask; |
89 return correct_hash; | 89 return correct_hash; |
90 } | 90 } |
91 | 91 |
92 } // namespace net | 92 } // namespace net |
OLD | NEW |