OLD | NEW |
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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 const std::string& password, | 101 const std::string& password, |
102 const HashEncoding& encoding) { | 102 const HashEncoding& encoding) { |
103 DCHECK_EQ(encoding.hash_bytes, salt.length()); | 103 DCHECK_EQ(encoding.hash_bytes, salt.length()); |
104 base::Time start_time = base::Time::Now(); | 104 base::Time start_time = base::Time::Now(); |
105 | 105 |
106 // Library call to create secure password hash as SymmetricKey (uses PBKDF2). | 106 // Library call to create secure password hash as SymmetricKey (uses PBKDF2). |
107 std::unique_ptr<crypto::SymmetricKey> password_key( | 107 std::unique_ptr<crypto::SymmetricKey> password_key( |
108 crypto::SymmetricKey::DeriveKeyFromPassword( | 108 crypto::SymmetricKey::DeriveKeyFromPassword( |
109 crypto::SymmetricKey::AES, password, salt, encoding.iteration_count, | 109 crypto::SymmetricKey::AES, password, salt, encoding.iteration_count, |
110 encoding.hash_bits)); | 110 encoding.hash_bits)); |
111 std::string password_hash; | 111 std::string password_hash = password_key->key(); |
112 const bool success = password_key->GetRawKey(&password_hash); | |
113 DCHECK(success); | |
114 DCHECK_EQ(encoding.hash_bytes, password_hash.length()); | 112 DCHECK_EQ(encoding.hash_bytes, password_hash.length()); |
115 | 113 |
116 UMA_HISTOGRAM_TIMES("PasswordHash.CreateTime", | 114 UMA_HISTOGRAM_TIMES("PasswordHash.CreateTime", |
117 base::Time::Now() - start_time); | 115 base::Time::Now() - start_time); |
118 | 116 |
119 if (encoding.stored_bits) { | 117 if (encoding.stored_bits) { |
120 password_hash = TruncateStringByBits(password_hash, encoding.stored_bits); | 118 password_hash = TruncateStringByBits(password_hash, encoding.stored_bits); |
121 DCHECK_EQ(encoding.stored_bytes, password_hash.length()); | 119 DCHECK_EQ(encoding.stored_bytes, password_hash.length()); |
122 } | 120 } |
123 DCHECK_EQ(encoding.stored_bytes ? encoding.stored_bytes : encoding.hash_bytes, | 121 DCHECK_EQ(encoding.stored_bytes ? encoding.stored_bytes : encoding.hash_bytes, |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 ProfileAttributesEntry* entry; | 264 ProfileAttributesEntry* entry; |
267 | 265 |
268 if (!g_browser_process->profile_manager()->GetProfileAttributesStorage(). | 266 if (!g_browser_process->profile_manager()->GetProfileAttributesStorage(). |
269 GetProfileAttributesWithPath(profile->GetPath(), &entry)) { | 267 GetProfileAttributesWithPath(profile->GetPath(), &entry)) { |
270 NOTREACHED(); | 268 NOTREACHED(); |
271 return false; | 269 return false; |
272 } | 270 } |
273 | 271 |
274 return ValidateLocalAuthCredentials(entry, password); | 272 return ValidateLocalAuthCredentials(entry, password); |
275 } | 273 } |
OLD | NEW |