Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/chromeos/login/auth/extended_authenticator.h" | 5 #include "chromeos/login/auth/extended_authenticator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/browser/chromeos/boot_times_loader.h" | |
| 11 #include "chromeos/cryptohome/async_method_caller.h" | 10 #include "chromeos/cryptohome/async_method_caller.h" |
| 12 #include "chromeos/cryptohome/cryptohome_parameters.h" | 11 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 13 #include "chromeos/cryptohome/homedir_methods.h" | 12 #include "chromeos/cryptohome/homedir_methods.h" |
| 14 #include "chromeos/cryptohome/system_salt_getter.h" | 13 #include "chromeos/cryptohome/system_salt_getter.h" |
| 15 #include "chromeos/dbus/cryptohome_client.h" | 14 #include "chromeos/dbus/cryptohome_client.h" |
| 16 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
| 17 #include "chromeos/login/auth/auth_status_consumer.h" | 16 #include "chromeos/login/auth/auth_status_consumer.h" |
| 18 #include "chromeos/login/auth/key.h" | 17 #include "chromeos/login/auth/key.h" |
| 19 #include "chromeos/login/auth/user_context.h" | 18 #include "chromeos/login/auth/user_context.h" |
| 19 #include "chromeos/login_event_recorder.h" | |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
|
stevenjb
2014/07/22 16:38:43
Layering violation.
Denis Kuznetsov (DE-MUC)
2014/07/23 17:34:11
Done.
| |
| 21 #include "crypto/sha2.h" | 21 #include "crypto/sha2.h" |
| 22 #include "google_apis/gaia/gaia_auth_util.h" | 22 #include "google_apis/gaia/gaia_auth_util.h" |
| 23 #include "third_party/cros_system_api/dbus/service_constants.h" | 23 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 24 | 24 |
| 25 using content::BrowserThread; | 25 using content::BrowserThread; |
| 26 | 26 |
| 27 namespace chromeos { | 27 namespace chromeos { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 void RecordStartMarker(const std::string& marker) { | 31 void RecordStartMarker(const std::string& marker) { |
| 32 std::string full_marker = "Cryptohome-"; | 32 std::string full_marker = "Cryptohome-"; |
| 33 full_marker.append(marker); | 33 full_marker.append(marker); |
| 34 full_marker.append("-Start"); | 34 full_marker.append("-Start"); |
| 35 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(full_marker, false); | 35 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker(full_marker, false); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void RecordEndMarker(const std::string& marker) { | 38 void RecordEndMarker(const std::string& marker) { |
| 39 std::string full_marker = "Cryptohome-"; | 39 std::string full_marker = "Cryptohome-"; |
| 40 full_marker.append(marker); | 40 full_marker.append(marker); |
| 41 full_marker.append("-End"); | 41 full_marker.append("-End"); |
| 42 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(full_marker, false); | 42 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker(full_marker, false); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 ExtendedAuthenticator::ExtendedAuthenticator(NewAuthStatusConsumer* consumer) | 47 ExtendedAuthenticator::ExtendedAuthenticator(NewAuthStatusConsumer* consumer) |
| 48 : salt_obtained_(false), consumer_(consumer), old_consumer_(NULL) { | 48 : salt_obtained_(false), consumer_(consumer), old_consumer_(NULL) { |
| 49 SystemSaltGetter::Get()->GetSystemSalt( | 49 SystemSaltGetter::Get()->GetSystemSalt( |
| 50 base::Bind(&ExtendedAuthenticator::OnSaltObtained, this)); | 50 base::Bind(&ExtendedAuthenticator::OnSaltObtained, this)); |
| 51 } | 51 } |
| 52 | 52 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 | 151 |
| 152 void ExtendedAuthenticator::TransformKeyIfNeeded( | 152 void ExtendedAuthenticator::TransformKeyIfNeeded( |
| 153 const UserContext& user_context, | 153 const UserContext& user_context, |
| 154 const ContextCallback& callback) { | 154 const ContextCallback& callback) { |
| 155 if (user_context.GetKey()->GetKeyType() != Key::KEY_TYPE_PASSWORD_PLAIN) { | 155 if (user_context.GetKey()->GetKeyType() != Key::KEY_TYPE_PASSWORD_PLAIN) { |
| 156 callback.Run(user_context); | 156 callback.Run(user_context); |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 | 159 |
| 160 if (!salt_obtained_) { | 160 if (!salt_obtained_) { |
| 161 system_salt_callbacks_.push_back(base::Bind( | 161 system_salt_callbacks_.push_back( |
| 162 &ExtendedAuthenticator::TransformKeyIfNeeded, | 162 base::Bind(&ExtendedAuthenticator::TransformKeyIfNeeded, |
| 163 this, | 163 this, |
| 164 user_context, | 164 user_context, |
| 165 callback)); | 165 callback)); |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 | 168 |
| 169 UserContext transformed_context = user_context; | 169 UserContext transformed_context = user_context; |
| 170 transformed_context.GetKey()->Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, | 170 transformed_context.GetKey()->Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, |
| 171 system_salt_); | 171 system_salt_); |
| 172 callback.Run(transformed_context); | 172 callback.Run(transformed_context); |
| 173 } | 173 } |
| 174 | 174 |
| 175 ExtendedAuthenticator::~ExtendedAuthenticator() { | 175 ExtendedAuthenticator::~ExtendedAuthenticator() { |
| 176 } | 176 } |
| 177 | 177 |
| 178 void ExtendedAuthenticator::OnSaltObtained(const std::string& system_salt) { | 178 void ExtendedAuthenticator::OnSaltObtained(const std::string& system_salt) { |
| 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 180 | 180 |
| 181 salt_obtained_ = true; | 181 salt_obtained_ = true; |
| 182 system_salt_ = system_salt; | 182 system_salt_ = system_salt; |
| 183 for (std::vector<base::Closure>::const_iterator it = | 183 for (std::vector<base::Closure>::const_iterator it = |
| 184 system_salt_callbacks_.begin(); | 184 system_salt_callbacks_.begin(); |
| 185 it != system_salt_callbacks_.end(); ++it) { | 185 it != system_salt_callbacks_.end(); |
| 186 ++it) { | |
| 186 it->Run(); | 187 it->Run(); |
| 187 } | 188 } |
| 188 system_salt_callbacks_.clear(); | 189 system_salt_callbacks_.clear(); |
| 189 } | 190 } |
| 190 | 191 |
| 191 void ExtendedAuthenticator::DoAuthenticateToMount( | 192 void ExtendedAuthenticator::DoAuthenticateToMount( |
| 192 const ResultCallback& success_callback, | 193 const ResultCallback& success_callback, |
| 193 const UserContext& user_context) { | 194 const UserContext& user_context) { |
| 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 195 | 196 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 if (consumer_) | 375 if (consumer_) |
| 375 consumer_->OnAuthenticationFailure(state); | 376 consumer_->OnAuthenticationFailure(state); |
| 376 | 377 |
| 377 if (old_consumer_) { | 378 if (old_consumer_) { |
| 378 AuthFailure failure(AuthFailure::UNLOCK_FAILED); | 379 AuthFailure failure(AuthFailure::UNLOCK_FAILED); |
| 379 old_consumer_->OnAuthFailure(failure); | 380 old_consumer_->OnAuthFailure(failure); |
| 380 } | 381 } |
| 381 } | 382 } |
| 382 | 383 |
| 383 } // namespace chromeos | 384 } // namespace chromeos |
| OLD | NEW |