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

Side by Side Diff: net/quic/core/crypto/crypto_utils.cc

Issue 2460223002: Adds std:: to stl types (#049) (Closed)
Patch Set: remove dead using std::foo declarations. Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_utils.h" 5 #include "net/quic/core/crypto/crypto_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "crypto/hkdf.h" 9 #include "crypto/hkdf.h"
10 #include "crypto/secure_hash.h" 10 #include "crypto/secure_hash.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 StringPiece context, 184 StringPiece context,
185 size_t result_len, 185 size_t result_len,
186 string* result) { 186 string* result) {
187 for (size_t i = 0; i < label.length(); i++) { 187 for (size_t i = 0; i < label.length(); i++) {
188 if (label[i] == '\0') { 188 if (label[i] == '\0') {
189 LOG(ERROR) << "ExportKeyingMaterial label may not contain NULs"; 189 LOG(ERROR) << "ExportKeyingMaterial label may not contain NULs";
190 return false; 190 return false;
191 } 191 }
192 } 192 }
193 // Create HKDF info input: null-terminated label + length-prefixed context 193 // Create HKDF info input: null-terminated label + length-prefixed context
194 if (context.length() >= numeric_limits<uint32_t>::max()) { 194 if (context.length() >= std::numeric_limits<uint32_t>::max()) {
195 LOG(ERROR) << "Context value longer than 2^32"; 195 LOG(ERROR) << "Context value longer than 2^32";
196 return false; 196 return false;
197 } 197 }
198 uint32_t context_length = static_cast<uint32_t>(context.length()); 198 uint32_t context_length = static_cast<uint32_t>(context.length());
199 string info = label.as_string(); 199 string info = label.as_string();
200 info.push_back('\0'); 200 info.push_back('\0');
201 info.append(reinterpret_cast<char*>(&context_length), sizeof(context_length)); 201 info.append(reinterpret_cast<char*>(&context_length), sizeof(context_length));
202 info.append(context.data(), context.length()); 202 info.append(context.data(), context.length());
203 203
204 crypto::HKDF hkdf(subkey_secret, StringPiece() /* no salt */, info, 204 crypto::HKDF hkdf(subkey_secret, StringPiece() /* no salt */, info,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 const QuicData& serialized = message.GetSerialized(); 331 const QuicData& serialized = message.GetSerialized();
332 std::unique_ptr<crypto::SecureHash> hash( 332 std::unique_ptr<crypto::SecureHash> hash(
333 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); 333 crypto::SecureHash::Create(crypto::SecureHash::SHA256));
334 hash->Update(serialized.data(), serialized.length()); 334 hash->Update(serialized.data(), serialized.length());
335 uint8_t digest[32]; 335 uint8_t digest[32];
336 hash->Finish(digest, sizeof(digest)); 336 hash->Finish(digest, sizeof(digest));
337 output->assign(reinterpret_cast<const char*>(&digest), sizeof(digest)); 337 output->assign(reinterpret_cast<const char*>(&digest), sizeof(digest));
338 } 338 }
339 339
340 } // namespace net 340 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/crypto_server_test.cc ('k') | net/quic/core/crypto/quic_compressed_certs_cache_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698