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

Unified Diff: chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc

Issue 2761353003: Call OwnerKeyUtil::FindPrivateKeyInSlot() in the blocking pool. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc
diff --git a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc
index 29b91ffb7be7255fee5d61f82100c73c5a2433b0..bbaa1120bbea9b77b01f320bc9c55e9a16e595ac 100644
--- a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc
+++ b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc
@@ -65,19 +65,14 @@ bool IsOwnerInTests(const std::string& user_id) {
return static_cast<const base::Value*>(value)->GetString() == user_id;
}
-void LoadPrivateKeyByPublicKey(
+void LoadPrivateKeyByPublicKeyOnWorkerThread(
const scoped_refptr<OwnerKeyUtil>& owner_key_util,
scoped_refptr<PublicKey> public_key,
- const std::string& username_hash,
+ crypto::ScopedPK11Slot public_slot,
+ crypto::ScopedPK11Slot private_slot,
const base::Callback<void(const scoped_refptr<PublicKey>& public_key,
const scoped_refptr<PrivateKey>& private_key)>&
callback) {
Daniel Erat 2017/03/22 14:47:18 can you DCHECK that this is running on the right t
Shuhei Takahashi 2017/03/23 05:04:11 Done.
- crypto::EnsureNSSInit();
- crypto::ScopedPK11Slot public_slot =
- crypto::GetPublicSlotForChromeOSUser(username_hash);
- crypto::ScopedPK11Slot private_slot = crypto::GetPrivateSlotForChromeOSUser(
- username_hash, base::Callback<void(crypto::ScopedPK11Slot)>());
-
// If private slot is already available, this will check it. If not, we'll get
// called again later when the TPM Token is ready, and the slot will be
// available then. FindPrivateKeyInSlot internally checks for a null slot if
@@ -98,6 +93,32 @@ void LoadPrivateKeyByPublicKey(
base::Bind(callback, public_key, private_key));
}
+void LoadPrivateKeyByPublicKey(
+ const scoped_refptr<OwnerKeyUtil>& owner_key_util,
+ scoped_refptr<PublicKey> public_key,
+ const std::string& username_hash,
+ const base::Callback<void(const scoped_refptr<PublicKey>& public_key,
+ const scoped_refptr<PrivateKey>& private_key)>&
+ callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ crypto::EnsureNSSInit();
+ crypto::ScopedPK11Slot public_slot =
+ crypto::GetPublicSlotForChromeOSUser(username_hash);
+ crypto::ScopedPK11Slot private_slot = crypto::GetPrivateSlotForChromeOSUser(
+ username_hash, base::Callback<void(crypto::ScopedPK11Slot)>());
+
+ // This task interacts with the TPM, so use the blocking pool.
+ scoped_refptr<base::TaskRunner> task_runner =
+ BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
+ task_runner->PostTask(
+ FROM_HERE,
+ base::Bind(&LoadPrivateKeyByPublicKeyOnWorkerThread, owner_key_util,
+ public_key, base::Passed(std::move(public_slot)),
+ base::Passed(std::move(private_slot)), callback));
+}
+
void LoadPrivateKey(
const scoped_refptr<OwnerKeyUtil>& owner_key_util,
const std::string username_hash,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698