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

Side by Side Diff: chromeos/login/auth/cryptohome_authenticator.cc

Issue 526353002: Merge cryptohome::RetrievedKeyData with cryptohome::KeyDefinition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@d_2_367847_add_get_key_data_ex_to_mount_flow
Patch Set: Rebased. Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromeos/login/auth/cryptohome_authenticator.h" 5 #include "chromeos/login/auth/cryptohome_authenticator.h"
6 6
7 #include <vector>
8
7 #include "base/basictypes.h" 9 #include "base/basictypes.h"
8 #include "base/bind.h" 10 #include "base/bind.h"
9 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
10 #include "base/location.h" 12 #include "base/location.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "chromeos/cryptohome/async_method_caller.h" 14 #include "chromeos/cryptohome/async_method_caller.h"
13 #include "chromeos/cryptohome/cryptohome_parameters.h" 15 #include "chromeos/cryptohome/cryptohome_parameters.h"
14 #include "chromeos/cryptohome/homedir_methods.h" 16 #include "chromeos/cryptohome/homedir_methods.h"
15 #include "chromeos/cryptohome/system_salt_getter.h" 17 #include "chromeos/cryptohome/system_salt_getter.h"
16 #include "chromeos/dbus/cryptohome_client.h" 18 #include "chromeos/dbus/cryptohome_client.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 170 }
169 171
170 // Callback invoked when cryptohome's GetKeyDataEx() method has finished. 172 // Callback invoked when cryptohome's GetKeyDataEx() method has finished.
171 // * If GetKeyDataEx() returned metadata indicating the hashing algorithm and 173 // * If GetKeyDataEx() returned metadata indicating the hashing algorithm and
172 // salt that were used to generate the key for this user's cryptohome, 174 // salt that were used to generate the key for this user's cryptohome,
173 // transforms the key in |attempt->user_context| with the same parameters. 175 // transforms the key in |attempt->user_context| with the same parameters.
174 // * Otherwise, starts the retrieval of the system salt so that the key in 176 // * Otherwise, starts the retrieval of the system salt so that the key in
175 // |attempt->user_context| can be transformed with Chrome's default hashing 177 // |attempt->user_context| can be transformed with Chrome's default hashing
176 // algorithm and the system salt. 178 // algorithm and the system salt.
177 // The resulting key is then passed to cryptohome's MountEx(). 179 // The resulting key is then passed to cryptohome's MountEx().
178 void OnGetKeyDataEx(AuthAttemptState* attempt, 180 void OnGetKeyDataEx(
179 scoped_refptr<CryptohomeAuthenticator> resolver, 181 AuthAttemptState* attempt,
180 bool ephemeral, 182 scoped_refptr<CryptohomeAuthenticator> resolver,
181 bool create_if_nonexistent, 183 bool ephemeral,
182 bool success, 184 bool create_if_nonexistent,
183 cryptohome::MountError return_code, 185 bool success,
184 ScopedVector<cryptohome::RetrievedKeyData> key_data) { 186 cryptohome::MountError return_code,
187 const std::vector<cryptohome::KeyDefinition>& key_definitions) {
185 if (success) { 188 if (success) {
186 if (key_data.size() == 1) { 189 if (key_definitions.size() == 1) {
187 cryptohome::RetrievedKeyData* key_data_entry = key_data.front(); 190 const cryptohome::KeyDefinition& key_definition = key_definitions.front();
188 DCHECK_EQ(kCryptohomeGAIAKeyLabel, key_data_entry->label); 191 DCHECK_EQ(kCryptohomeGAIAKeyLabel, key_definition.label);
189 192
190 // Extract the key type and salt from |key_data|, if present. 193 // Extract the key type and salt from |key_definition|, if present.
191 scoped_ptr<int64> type; 194 scoped_ptr<int64> type;
192 scoped_ptr<std::string> salt; 195 scoped_ptr<std::string> salt;
193 for (ScopedVector<cryptohome::RetrievedKeyData::ProviderData>:: 196 for (std::vector<cryptohome::KeyDefinition::ProviderData>::
194 const_iterator it = key_data_entry->provider_data.begin(); 197 const_iterator it = key_definition.provider_data.begin();
195 it != key_data_entry->provider_data.end(); ++it) { 198 it != key_definition.provider_data.end(); ++it) {
196 if ((*it)->name == kKeyProviderDataTypeName) { 199 if (it->name == kKeyProviderDataTypeName) {
197 if ((*it)->number) 200 if (it->number)
198 type.reset(new int64(*(*it)->number)); 201 type.reset(new int64(*it->number));
199 else 202 else
200 NOTREACHED(); 203 NOTREACHED();
201 } else if ((*it)->name == kKeyProviderDataSaltName) { 204 } else if (it->name == kKeyProviderDataSaltName) {
202 if ((*it)->bytes) 205 if (it->bytes)
203 salt.reset(new std::string(*(*it)->bytes)); 206 salt.reset(new std::string(*it->bytes));
204 else 207 else
205 NOTREACHED(); 208 NOTREACHED();
206 } 209 }
207 } 210 }
208 211
209 if (type) { 212 if (type) {
210 if (*type < 0 || *type >= Key::KEY_TYPE_COUNT) { 213 if (*type < 0 || *type >= Key::KEY_TYPE_COUNT) {
211 LOG(ERROR) << "Invalid key type: " << *type; 214 LOG(ERROR) << "Invalid key type: " << *type;
212 RecordKeyErrorAndResolve(attempt, resolver); 215 RecordKeyErrorAndResolve(attempt, resolver);
213 return; 216 return;
214 } 217 }
215 218
216 if (!salt) { 219 if (!salt) {
217 LOG(ERROR) << "Missing salt."; 220 LOG(ERROR) << "Missing salt.";
218 RecordKeyErrorAndResolve(attempt, resolver); 221 RecordKeyErrorAndResolve(attempt, resolver);
219 return; 222 return;
220 } 223 }
221 224
222 attempt->user_context.GetKey()->Transform( 225 attempt->user_context.GetKey()->Transform(
223 static_cast<Key::KeyType>(*type), 226 static_cast<Key::KeyType>(*type),
224 *salt); 227 *salt);
225 DoMount(attempt, resolver, ephemeral, create_if_nonexistent); 228 DoMount(attempt, resolver, ephemeral, create_if_nonexistent);
226 return; 229 return;
227 } 230 }
228 } else { 231 } else {
229 LOG(ERROR) << "GetKeyDataEx() returned " << key_data.size() 232 LOG(ERROR) << "GetKeyDataEx() returned " << key_definitions.size()
230 << " entries."; 233 << " entries.";
231 } 234 }
232 } 235 }
233 236
234 SystemSaltGetter::Get()->GetSystemSalt(base::Bind(&OnGetSystemSalt, 237 SystemSaltGetter::Get()->GetSystemSalt(base::Bind(&OnGetSystemSalt,
235 attempt, 238 attempt,
236 resolver, 239 resolver,
237 ephemeral, 240 ephemeral,
238 create_if_nonexistent)); 241 create_if_nonexistent));
239 } 242 }
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 Resolve(); 921 Resolve();
919 } 922 }
920 923
921 void CryptohomeAuthenticator::SetOwnerState(bool owner_check_finished, 924 void CryptohomeAuthenticator::SetOwnerState(bool owner_check_finished,
922 bool check_result) { 925 bool check_result) {
923 owner_is_verified_ = owner_check_finished; 926 owner_is_verified_ = owner_check_finished;
924 user_can_login_ = check_result; 927 user_can_login_ = check_result;
925 } 928 }
926 929
927 } // namespace chromeos 930 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/cryptohome/mock_homedir_methods.cc ('k') | chromeos/login/auth/extended_authenticator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698