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

Side by Side Diff: chrome/browser/chromeos/ownership/owner_settings_service_chromeos.cc

Issue 660343002: Look for Owner key in both private and public slots (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/settings/device_settings_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 5 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 void LoadPrivateKeyByPublicKey( 60 void LoadPrivateKeyByPublicKey(
61 const scoped_refptr<OwnerKeyUtil>& owner_key_util, 61 const scoped_refptr<OwnerKeyUtil>& owner_key_util,
62 scoped_refptr<PublicKey> public_key, 62 scoped_refptr<PublicKey> public_key,
63 const std::string& username_hash, 63 const std::string& username_hash,
64 const base::Callback<void(const scoped_refptr<PublicKey>& public_key, 64 const base::Callback<void(const scoped_refptr<PublicKey>& public_key,
65 const scoped_refptr<PrivateKey>& private_key)>& 65 const scoped_refptr<PrivateKey>& private_key)>&
66 callback) { 66 callback) {
67 crypto::EnsureNSSInit(); 67 crypto::EnsureNSSInit();
68 crypto::ScopedPK11Slot slot = 68 crypto::ScopedPK11Slot public_slot =
69 crypto::GetPublicSlotForChromeOSUser(username_hash); 69 crypto::GetPublicSlotForChromeOSUser(username_hash);
70 scoped_refptr<PrivateKey> private_key(new PrivateKey( 70 crypto::ScopedPK11Slot private_slot = crypto::GetPrivateSlotForChromeOSUser(
71 owner_key_util->FindPrivateKeyInSlot(public_key->data(), slot.get()))); 71 username_hash, base::Callback<void(crypto::ScopedPK11Slot)>());
72
73 // If private slot is already available, this will check it. If not,
74 // we'll get called again later when the TPM Token is ready, and the
75 // slot will be available then.
76 scoped_refptr<PrivateKey> private_key(
77 new PrivateKey(owner_key_util->FindPrivateKeyInSlot(public_key->data(),
78 private_slot.get())));
79 if (!private_key->key()) {
80 private_key = new PrivateKey(owner_key_util->FindPrivateKeyInSlot(
81 public_key->data(), public_slot.get()));
82 }
72 BrowserThread::PostTask(BrowserThread::UI, 83 BrowserThread::PostTask(BrowserThread::UI,
73 FROM_HERE, 84 FROM_HERE,
74 base::Bind(callback, public_key, private_key)); 85 base::Bind(callback, public_key, private_key));
75 } 86 }
76 87
77 void LoadPrivateKey( 88 void LoadPrivateKey(
78 const scoped_refptr<OwnerKeyUtil>& owner_key_util, 89 const scoped_refptr<OwnerKeyUtil>& owner_key_util,
79 const std::string username_hash, 90 const std::string username_hash,
80 const base::Callback<void(const scoped_refptr<PublicKey>& public_key, 91 const base::Callback<void(const scoped_refptr<PublicKey>& public_key,
81 const scoped_refptr<PrivateKey>& private_key)>& 92 const scoped_refptr<PrivateKey>& private_key)>&
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 service->OnSignAndStoreOperationCompleted(status); 328 service->OnSignAndStoreOperationCompleted(status);
318 if (!callback.is_null()) 329 if (!callback.is_null())
319 callback.Run(); 330 callback.Run();
320 331
321 pending_operations_.pop_front(); 332 pending_operations_.pop_front();
322 delete operation; 333 delete operation;
323 StartNextOperation(); 334 StartNextOperation();
324 } 335 }
325 336
326 } // namespace chromeos 337 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/settings/device_settings_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698