Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: net/quic/crypto/null_decrypter.cc

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/crypto/curve25519_key_exchange.cc ('k') | net/quic/crypto/p256_key_exchange.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "net/quic/quic_utils.h" 6 #include "net/quic/quic_utils.h"
7 #include "net/quic/quic_data_reader.h" 7 #include "net/quic/quic_data_reader.h"
8 8
9 using base::StringPiece; 9 using base::StringPiece;
10 using std::string; 10 using std::string;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 QuicData* NullDecrypter::DecryptPacket(QuicPacketSequenceNumber /*seq_number*/, 47 QuicData* NullDecrypter::DecryptPacket(QuicPacketSequenceNumber /*seq_number*/,
48 StringPiece associated_data, 48 StringPiece associated_data,
49 StringPiece ciphertext) { 49 StringPiece ciphertext) {
50 // It's worth duplicating |Decrypt|, above, in order to save a copy by using 50 // It's worth duplicating |Decrypt|, above, in order to save a copy by using
51 // the shared-data QuicData constructor directly. 51 // the shared-data QuicData constructor directly.
52 QuicDataReader reader(ciphertext.data(), ciphertext.length()); 52 QuicDataReader reader(ciphertext.data(), ciphertext.length());
53 53
54 uint128 hash; 54 uint128 hash;
55 if (!ReadHash(&reader, &hash)) { 55 if (!ReadHash(&reader, &hash)) {
56 return NULL; 56 return nullptr;
57 } 57 }
58 58
59 StringPiece plaintext = reader.ReadRemainingPayload(); 59 StringPiece plaintext = reader.ReadRemainingPayload();
60 60
61 // TODO(rch): avoid buffer copy here 61 // TODO(rch): avoid buffer copy here
62 string buffer = associated_data.as_string(); 62 string buffer = associated_data.as_string();
63 plaintext.AppendToString(&buffer); 63 plaintext.AppendToString(&buffer);
64 64
65 if (hash != ComputeHash(buffer)) { 65 if (hash != ComputeHash(buffer)) {
66 return NULL; 66 return nullptr;
67 } 67 }
68 return new QuicData(plaintext.data(), plaintext.length()); 68 return new QuicData(plaintext.data(), plaintext.length());
69 } 69 }
70 70
71 StringPiece NullDecrypter::GetKey() const { return StringPiece(); } 71 StringPiece NullDecrypter::GetKey() const { return StringPiece(); }
72 72
73 StringPiece NullDecrypter::GetNoncePrefix() const { return StringPiece(); } 73 StringPiece NullDecrypter::GetNoncePrefix() const { return StringPiece(); }
74 74
75 bool NullDecrypter::ReadHash(QuicDataReader* reader, uint128* hash) { 75 bool NullDecrypter::ReadHash(QuicDataReader* reader, uint128* hash) {
76 uint64 lo; 76 uint64 lo;
(...skipping 10 matching lines...) Expand all
87 87
88 uint128 NullDecrypter::ComputeHash(const string& data) const { 88 uint128 NullDecrypter::ComputeHash(const string& data) const {
89 uint128 correct_hash = QuicUtils::FNV1a_128_Hash(data.data(), data.length()); 89 uint128 correct_hash = QuicUtils::FNV1a_128_Hash(data.data(), data.length());
90 uint128 mask(GG_UINT64_C(0x0), GG_UINT64_C(0xffffffff)); 90 uint128 mask(GG_UINT64_C(0x0), GG_UINT64_C(0xffffffff));
91 mask <<= 96; 91 mask <<= 96;
92 correct_hash &= ~mask; 92 correct_hash &= ~mask;
93 return correct_hash; 93 return correct_hash;
94 } 94 }
95 95
96 } // namespace net 96 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/curve25519_key_exchange.cc ('k') | net/quic/crypto/p256_key_exchange.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698