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

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

Issue 1106103003: Don't use RSAPrivateKey in NSS integration code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ocsp-refactor
Patch Set: pneubeck comments Created 5 years, 7 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 "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 5 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
6 6
7 #include <keyhi.h>
8
7 #include <algorithm> 9 #include <algorithm>
8 #include <string> 10 #include <string>
9 11
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
12 #include "base/callback.h" 14 #include "base/callback.h"
13 #include "base/command_line.h" 15 #include "base/command_line.h"
14 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
15 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
16 #include "chrome/browser/chrome_notification_types.h" 18 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h" 19 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h"
18 #include "chrome/browser/chromeos/profiles/profile_helper.h" 20 #include "chrome/browser/chromeos/profiles/profile_helper.h"
19 #include "chrome/browser/chromeos/settings/cros_settings.h" 21 #include "chrome/browser/chromeos/settings/cros_settings.h"
20 #include "chrome/browser/chromeos/settings/device_settings_provider.h" 22 #include "chrome/browser/chromeos/settings/device_settings_provider.h"
21 #include "chrome/browser/chromeos/settings/session_manager_operation.h" 23 #include "chrome/browser/chromeos/settings/session_manager_operation.h"
22 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
23 #include "chromeos/dbus/dbus_thread_manager.h" 25 #include "chromeos/dbus/dbus_thread_manager.h"
24 #include "chromeos/tpm/tpm_token_loader.h" 26 #include "chromeos/tpm/tpm_token_loader.h"
25 #include "components/ownership/owner_key_util.h" 27 #include "components/ownership/owner_key_util.h"
26 #include "components/user_manager/user.h" 28 #include "components/user_manager/user.h"
27 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/notification_details.h" 30 #include "content/public/browser/notification_details.h"
29 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/notification_source.h" 32 #include "content/public/browser/notification_source.h"
31 #include "content/public/common/content_switches.h" 33 #include "content/public/common/content_switches.h"
34 #include "crypto/nss_key_util.h"
32 #include "crypto/nss_util.h" 35 #include "crypto/nss_util.h"
33 #include "crypto/nss_util_internal.h" 36 #include "crypto/nss_util_internal.h"
34 #include "crypto/rsa_private_key.h"
35 #include "crypto/scoped_nss_types.h" 37 #include "crypto/scoped_nss_types.h"
36 #include "crypto/signature_creator.h" 38 #include "crypto/signature_creator.h"
37 39
38 namespace em = enterprise_management; 40 namespace em = enterprise_management;
39 41
40 using content::BrowserThread; 42 using content::BrowserThread;
41 using ownership::OwnerKeyUtil; 43 using ownership::OwnerKeyUtil;
42 using ownership::PrivateKey; 44 using ownership::PrivateKey;
43 using ownership::PublicKey; 45 using ownership::PublicKey;
44 46
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 LoadPrivateKeyByPublicKey( 119 LoadPrivateKeyByPublicKey(
118 owner_key_util, public_key, username_hash, callback); 120 owner_key_util, public_key, username_hash, callback);
119 } 121 }
120 } 122 }
121 123
122 bool DoesPrivateKeyExistAsyncHelper( 124 bool DoesPrivateKeyExistAsyncHelper(
123 const scoped_refptr<OwnerKeyUtil>& owner_key_util) { 125 const scoped_refptr<OwnerKeyUtil>& owner_key_util) {
124 std::vector<uint8> public_key; 126 std::vector<uint8> public_key;
125 if (!owner_key_util->ImportPublicKey(&public_key)) 127 if (!owner_key_util->ImportPublicKey(&public_key))
126 return false; 128 return false;
127 scoped_ptr<crypto::RSAPrivateKey> key( 129 crypto::ScopedSECKEYPrivateKey key =
128 crypto::RSAPrivateKey::FindFromPublicKeyInfo(public_key)); 130 crypto::FindNSSKeyFromPublicKeyInfo(public_key);
129 bool is_owner = key.get() != NULL; 131 return key && SECKEY_GetPrivateKeyType(key.get()) == rsaKey;
130 return is_owner;
131 } 132 }
132 133
133 // Checks whether NSS slots with private key are mounted or 134 // Checks whether NSS slots with private key are mounted or
134 // not. Responds via |callback|. 135 // not. Responds via |callback|.
135 void DoesPrivateKeyExistAsync( 136 void DoesPrivateKeyExistAsync(
136 const scoped_refptr<OwnerKeyUtil>& owner_key_util, 137 const scoped_refptr<OwnerKeyUtil>& owner_key_util,
137 const OwnerSettingsServiceChromeOS::IsOwnerCallback& callback) { 138 const OwnerSettingsServiceChromeOS::IsOwnerCallback& callback) {
138 if (!owner_key_util.get()) { 139 if (!owner_key_util.get()) {
139 callback.Run(false); 140 callback.Run(false);
140 return; 141 return;
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 std::vector<OnManagementSettingsSetCallback> callbacks; 804 std::vector<OnManagementSettingsSetCallback> callbacks;
804 pending_management_settings_callbacks_.swap(callbacks); 805 pending_management_settings_callbacks_.swap(callbacks);
805 for (const auto& callback : callbacks) { 806 for (const auto& callback : callbacks) {
806 if (!callback.is_null()) 807 if (!callback.is_null())
807 callback.Run(success); 808 callback.Run(success);
808 } 809 }
809 StorePendingChanges(); 810 StorePendingChanges();
810 } 811 }
811 812
812 } // namespace chromeos 813 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698