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

Side by Side Diff: chrome/browser/signin/local_auth.cc

Issue 1223983002: Move WriteInto to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/signin/local_auth.h" 5 #include "chrome/browser/signin/local_auth.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 void LocalAuth::SetLocalAuthCredentialsWithEncoding(size_t info_index, 182 void LocalAuth::SetLocalAuthCredentialsWithEncoding(size_t info_index,
183 const std::string& password, 183 const std::string& password,
184 char encoding_version) { 184 char encoding_version) {
185 const HashEncoding& encoding = encodings[(encoding_version - '0') - 1]; 185 const HashEncoding& encoding = encodings[(encoding_version - '0') - 1];
186 186
187 // Salt should be random data, as long as the hash length, and different with 187 // Salt should be random data, as long as the hash length, and different with
188 // every save. 188 // every save.
189 std::string salt_str; 189 std::string salt_str;
190 crypto::RandBytes(WriteInto(&salt_str, encoding.hash_bytes + 1), 190 crypto::RandBytes(base::WriteInto(&salt_str, encoding.hash_bytes + 1),
191 encoding.hash_bytes); 191 encoding.hash_bytes);
192 192
193 // Perform secure hash of password for storage. 193 // Perform secure hash of password for storage.
194 std::string password_hash = CreateSecurePasswordHash( 194 std::string password_hash = CreateSecurePasswordHash(
195 salt_str, password, encoding); 195 salt_str, password, encoding);
196 196
197 // Group all fields into a single record for storage; 197 // Group all fields into a single record for storage;
198 std::string record; 198 std::string record;
199 record.append(salt_str); 199 record.append(salt_str);
200 record.append(password_hash); 200 record.append(password_hash);
201 201
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 if (passwords_match && (hash_encoding->version - '0') != NUM_HASH_ENCODINGS) 268 if (passwords_match && (hash_encoding->version - '0') != NUM_HASH_ENCODINGS)
269 SetLocalAuthCredentials(info_index, password); 269 SetLocalAuthCredentials(info_index, password);
270 return passwords_match; 270 return passwords_match;
271 } 271 }
272 272
273 bool LocalAuth::ValidateLocalAuthCredentials(const Profile* profile, 273 bool LocalAuth::ValidateLocalAuthCredentials(const Profile* profile,
274 const std::string& password) { 274 const std::string& password) {
275 return ValidateLocalAuthCredentials(GetProfileInfoIndexOfProfile(profile), 275 return ValidateLocalAuthCredentials(GetProfileInfoIndexOfProfile(profile),
276 password); 276 password);
277 } 277 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698