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

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: 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,
185 if (success && key_data.size() == 1) { 187 const std::vector<cryptohome::KeyDefinition>& key_definitions) {
186 cryptohome::RetrievedKeyData* key_data_entry = key_data.front(); 188 if (success && key_definitions.size() == 1) {
187 DCHECK_EQ(kCryptohomeGAIAKeyLabel, key_data_entry->label); 189 const cryptohome::KeyDefinition& key_definition = key_definitions.front();
190 DCHECK_EQ(kCryptohomeGAIAKeyLabel, key_definition.label);
188 191
189 // Extract the key type and salt from |key_data|, if present. 192 // Extract the key type and salt from |key_definition|, if present.
190 scoped_ptr<int64> type; 193 scoped_ptr<int64> type;
191 scoped_ptr<std::string> salt; 194 scoped_ptr<std::string> salt;
192 for (ScopedVector<cryptohome::RetrievedKeyData::ProviderData>:: 195 for (std::vector<cryptohome::KeyDefinition::ProviderData>::
193 const_iterator it = key_data_entry->provider_data.begin(); 196 const_iterator it = key_definition.provider_data.begin();
194 it != key_data_entry->provider_data.end(); ++it) { 197 it != key_definition.provider_data.end(); ++it) {
195 if ((*it)->name == kKeyProviderDataTypeName) { 198 if (it->name == kKeyProviderDataTypeName) {
196 if ((*it)->number) 199 if (it->number)
197 type.reset(new int64(*(*it)->number)); 200 type.reset(new int64(*it->number));
198 else 201 else
199 NOTREACHED(); 202 NOTREACHED();
200 } else if ((*it)->name == kKeyProviderDataSaltName) { 203 } else if (it->name == kKeyProviderDataSaltName) {
201 if ((*it)->bytes) 204 if (it->bytes)
202 salt.reset(new std::string(*(*it)->bytes)); 205 salt.reset(new std::string(*it->bytes));
203 else 206 else
204 NOTREACHED(); 207 NOTREACHED();
205 } 208 }
206 } 209 }
207 210
208 if (type) { 211 if (type) {
209 if (*type < 0 || *type >= Key::KEY_TYPE_COUNT) { 212 if (*type < 0 || *type >= Key::KEY_TYPE_COUNT) {
210 LOG(ERROR) << "Invalid key type: " << *type; 213 LOG(ERROR) << "Invalid key type: " << *type;
211 RecordKeyErrorAndResolve(attempt, resolver); 214 RecordKeyErrorAndResolve(attempt, resolver);
212 return; 215 return;
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 Resolve(); 916 Resolve();
914 } 917 }
915 918
916 void CryptohomeAuthenticator::SetOwnerState(bool owner_check_finished, 919 void CryptohomeAuthenticator::SetOwnerState(bool owner_check_finished,
917 bool check_result) { 920 bool check_result) {
918 owner_is_verified_ = owner_check_finished; 921 owner_is_verified_ = owner_check_finished;
919 user_can_login_ = check_result; 922 user_can_login_ = check_result;
920 } 923 }
921 924
922 } // namespace chromeos 925 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698