| 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/supervised/supervised_user_authenticator
.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_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_recorder.h" | 10 #include "chrome/browser/chromeos/boot_times_recorder.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 scoped_refptr<SupervisedUserAuthenticator> resolver, | 63 scoped_refptr<SupervisedUserAuthenticator> resolver, |
| 64 int flags, | 64 int flags, |
| 65 const std::string& system_salt) { | 65 const std::string& system_salt) { |
| 66 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 66 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 67 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( | 67 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( |
| 68 "CryptohomeMount-LMU-Start", false); | 68 "CryptohomeMount-LMU-Start", false); |
| 69 | 69 |
| 70 Key key(attempt->password); | 70 Key key(attempt->password); |
| 71 key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); | 71 key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
| 72 const AccountId account_id = user_manager::known_user::GetAccountId( | 72 const AccountId account_id = user_manager::known_user::GetAccountId( |
| 73 attempt->username, std::string() /* id */, AccountType::UNKNOWN); | 73 attempt->username, std::string() /* gaia_id */); |
| 74 const cryptohome::Identification cryptohome_id(account_id); | 74 const cryptohome::Identification cryptohome_id(account_id); |
| 75 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMount( | 75 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMount( |
| 76 cryptohome_id, key.GetSecret(), flags, | 76 cryptohome_id, key.GetSecret(), flags, |
| 77 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeMount-LMU-End", | 77 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeMount-LMU-End", |
| 78 attempt, resolver)); | 78 attempt, resolver)); |
| 79 | 79 |
| 80 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( | 80 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( |
| 81 cryptohome_id, base::Bind(&TriggerResolveResult, attempt, resolver)); | 81 cryptohome_id, base::Bind(&TriggerResolveResult, attempt, resolver)); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Calls cryptohome's addKey method. | 84 // Calls cryptohome's addKey method. |
| 85 void AddKey(SupervisedUserAuthenticator::AuthAttempt* attempt, | 85 void AddKey(SupervisedUserAuthenticator::AuthAttempt* attempt, |
| 86 scoped_refptr<SupervisedUserAuthenticator> resolver, | 86 scoped_refptr<SupervisedUserAuthenticator> resolver, |
| 87 const std::string& plain_text_master_key, | 87 const std::string& plain_text_master_key, |
| 88 const std::string& system_salt) { | 88 const std::string& system_salt) { |
| 89 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 89 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 90 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( | 90 chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( |
| 91 "CryptohomeAddKey-LMU-Start", false); | 91 "CryptohomeAddKey-LMU-Start", false); |
| 92 | 92 |
| 93 Key user_key(attempt->password); | 93 Key user_key(attempt->password); |
| 94 user_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); | 94 user_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
| 95 Key master_key(plain_text_master_key); | 95 Key master_key(plain_text_master_key); |
| 96 master_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); | 96 master_key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); |
| 97 const AccountId account_id = user_manager::known_user::GetAccountId( | 97 const AccountId account_id = user_manager::known_user::GetAccountId( |
| 98 attempt->username, std::string() /* id */, AccountType::UNKNOWN); | 98 attempt->username, std::string() /* gaia_id */); |
| 99 cryptohome::AsyncMethodCaller::GetInstance()->AsyncAddKey( | 99 cryptohome::AsyncMethodCaller::GetInstance()->AsyncAddKey( |
| 100 cryptohome::Identification(account_id), user_key.GetSecret(), | 100 cryptohome::Identification(account_id), user_key.GetSecret(), |
| 101 master_key.GetSecret(), | 101 master_key.GetSecret(), |
| 102 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeAddKey-LMU-End", | 102 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeAddKey-LMU-End", |
| 103 attempt, resolver)); | 103 attempt, resolver)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace | 106 } // namespace |
| 107 | 107 |
| 108 SupervisedUserAuthenticator::SupervisedUserAuthenticator( | 108 SupervisedUserAuthenticator::SupervisedUserAuthenticator( |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 336 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 337 return hash_obtained_; | 337 return hash_obtained_; |
| 338 } | 338 } |
| 339 | 339 |
| 340 std::string SupervisedUserAuthenticator::AuthAttempt::hash() { | 340 std::string SupervisedUserAuthenticator::AuthAttempt::hash() { |
| 341 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 341 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 342 return hash_; | 342 return hash_; |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace chromeos | 345 } // namespace chromeos |
| OLD | NEW |