OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cert/nss_cert_database.h" | 5 #include "net/cert/nss_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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 crypto::ScopedPK11Slot NSSCertDatabase::GetPublicSlot() const { | 138 crypto::ScopedPK11Slot NSSCertDatabase::GetPublicSlot() const { |
139 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(public_slot_.get())); | 139 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(public_slot_.get())); |
140 } | 140 } |
141 | 141 |
142 crypto::ScopedPK11Slot NSSCertDatabase::GetPrivateSlot() const { | 142 crypto::ScopedPK11Slot NSSCertDatabase::GetPrivateSlot() const { |
143 if (!private_slot_) | 143 if (!private_slot_) |
144 return crypto::ScopedPK11Slot(); | 144 return crypto::ScopedPK11Slot(); |
145 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(private_slot_.get())); | 145 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(private_slot_.get())); |
146 } | 146 } |
147 | 147 |
148 void NSSCertDatabase::ListModules(CryptoModuleList* modules, | 148 void NSSCertDatabase::ListModules(std::vector<crypto::ScopedPK11Slot>* modules, |
149 bool need_rw) const { | 149 bool need_rw) const { |
150 modules->clear(); | 150 modules->clear(); |
151 | 151 |
152 // The wincx arg is unused since we don't call PK11_SetIsLoggedInFunc. | 152 // The wincx arg is unused since we don't call PK11_SetIsLoggedInFunc. |
153 crypto::ScopedPK11SlotList slot_list( | 153 crypto::ScopedPK11SlotList slot_list( |
154 PK11_GetAllTokens(CKM_INVALID_MECHANISM, | 154 PK11_GetAllTokens(CKM_INVALID_MECHANISM, |
155 need_rw ? PR_TRUE : PR_FALSE, // needRW | 155 need_rw ? PR_TRUE : PR_FALSE, // needRW |
156 PR_TRUE, // loadCerts (unused) | 156 PR_TRUE, // loadCerts (unused) |
157 NULL)); // wincx | 157 NULL)); // wincx |
158 if (!slot_list) { | 158 if (!slot_list) { |
159 LOG(ERROR) << "PK11_GetAllTokens failed: " << PORT_GetError(); | 159 LOG(ERROR) << "PK11_GetAllTokens failed: " << PORT_GetError(); |
160 return; | 160 return; |
161 } | 161 } |
162 | 162 |
163 PK11SlotListElement* slot_element = PK11_GetFirstSafe(slot_list.get()); | 163 PK11SlotListElement* slot_element = PK11_GetFirstSafe(slot_list.get()); |
164 while (slot_element) { | 164 while (slot_element) { |
165 modules->push_back(CryptoModule::CreateFromHandle(slot_element->slot)); | 165 modules->push_back( |
| 166 crypto::ScopedPK11Slot(PK11_ReferenceSlot(slot_element->slot))); |
166 slot_element = PK11_GetNextSafe(slot_list.get(), slot_element, | 167 slot_element = PK11_GetNextSafe(slot_list.get(), slot_element, |
167 PR_FALSE); // restart | 168 PR_FALSE); // restart |
168 } | 169 } |
169 } | 170 } |
170 | 171 |
171 int NSSCertDatabase::ImportFromPKCS12(PK11SlotInfo* slot_info, | 172 int NSSCertDatabase::ImportFromPKCS12(PK11SlotInfo* slot_info, |
172 const std::string& data, | 173 const std::string& data, |
173 const base::string16& password, | 174 const base::string16& password, |
174 bool is_extractable, | 175 bool is_extractable, |
175 CertificateList* imported_certs) { | 176 CertificateList* imported_certs) { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } else { | 460 } else { |
460 if (SEC_DeletePermCertificate(cert->os_cert_handle())) { | 461 if (SEC_DeletePermCertificate(cert->os_cert_handle())) { |
461 LOG(ERROR) << "SEC_DeletePermCertificate failed: " << PORT_GetError(); | 462 LOG(ERROR) << "SEC_DeletePermCertificate failed: " << PORT_GetError(); |
462 return false; | 463 return false; |
463 } | 464 } |
464 } | 465 } |
465 return true; | 466 return true; |
466 } | 467 } |
467 | 468 |
468 } // namespace net | 469 } // namespace net |
OLD | NEW |