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