OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/base/cert_database.h" | 5 #include "net/base/cert_database.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <certdb.h> | 8 #include <certdb.h> |
9 #include <keyhi.h> | 9 #include <keyhi.h> |
10 #include <pk11pub.h> | 10 #include <pk11pub.h> |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 !CERT_LIST_END(node, cert_list); | 102 !CERT_LIST_END(node, cert_list); |
103 node = CERT_LIST_NEXT(node)) { | 103 node = CERT_LIST_NEXT(node)) { |
104 certs->push_back(X509Certificate::CreateFromHandle( | 104 certs->push_back(X509Certificate::CreateFromHandle( |
105 node->cert, | 105 node->cert, |
106 X509Certificate::SOURCE_LONE_CERT_IMPORT, | 106 X509Certificate::SOURCE_LONE_CERT_IMPORT, |
107 X509Certificate::OSCertHandles())); | 107 X509Certificate::OSCertHandles())); |
108 } | 108 } |
109 CERT_DestroyCertList(cert_list); | 109 CERT_DestroyCertList(cert_list); |
110 } | 110 } |
111 | 111 |
112 CryptoModule* CertDatabase::GetDefaultModule() const { | 112 CryptoModule* CertDatabase::GetPublicModule() const { |
113 CryptoModule* module = | 113 CryptoModule* module = |
114 CryptoModule::CreateFromHandle(base::GetDefaultNSSKeySlot()); | 114 CryptoModule::CreateFromHandle(base::GetPublicNSSKeySlot()); |
115 // The module is already referenced when returned from GetDefaultNSSKeymodule, | 115 // The module is already referenced when returned from |
116 // so we need to deref it once. | 116 // GetPublicNSSKeySlot, so we need to deref it once. |
117 PK11_FreeSlot(module->os_module_handle()); | 117 PK11_FreeSlot(module->os_module_handle()); |
118 | 118 |
119 return module; | 119 return module; |
| 120 } |
| 121 |
| 122 CryptoModule* CertDatabase::GetPrivateModule() const { |
| 123 CryptoModule* module = |
| 124 CryptoModule::CreateFromHandle(base::GetPrivateNSSKeySlot()); |
| 125 // The module is already referenced when returned from |
| 126 // GetPrivateNSSKeySlot, so we need to deref it once. |
| 127 PK11_FreeSlot(module->os_module_handle()); |
| 128 |
| 129 return module; |
120 } | 130 } |
121 | 131 |
122 void CertDatabase::ListModules(CryptoModuleList* modules, bool need_rw) const { | 132 void CertDatabase::ListModules(CryptoModuleList* modules, bool need_rw) const { |
123 modules->clear(); | 133 modules->clear(); |
124 | 134 |
125 PK11SlotList* slot_list = NULL; | 135 PK11SlotList* slot_list = NULL; |
126 // The wincx arg is unused since we don't call PK11_SetIsLoggedInFunc. | 136 // The wincx arg is unused since we don't call PK11_SetIsLoggedInFunc. |
127 slot_list = PK11_GetAllTokens(CKM_INVALID_MECHANISM, | 137 slot_list = PK11_GetAllTokens(CKM_INVALID_MECHANISM, |
128 need_rw ? PR_TRUE : PR_FALSE, // needRW | 138 need_rw ? PR_TRUE : PR_FALSE, // needRW |
129 PR_TRUE, // loadCerts (unused) | 139 PR_TRUE, // loadCerts (unused) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 254 } |
245 return true; | 255 return true; |
246 } | 256 } |
247 | 257 |
248 bool CertDatabase::IsReadOnly(const X509Certificate* cert) const { | 258 bool CertDatabase::IsReadOnly(const X509Certificate* cert) const { |
249 PK11SlotInfo* slot = cert->os_cert_handle()->slot; | 259 PK11SlotInfo* slot = cert->os_cert_handle()->slot; |
250 return slot && PK11_IsReadOnly(slot); | 260 return slot && PK11_IsReadOnly(slot); |
251 } | 261 } |
252 | 262 |
253 } // namespace net | 263 } // namespace net |
OLD | NEW |