| 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/base/x509_util.h" | 5 #include "net/base/x509_util.h" |
| 6 #include "net/base/x509_util_nss.h" | 6 #include "net/base/x509_util_nss.h" |
| 7 | 7 |
| 8 #include <cert.h> | 8 #include <cert.h> |
| 9 #include <cryptohi.h> | 9 #include <cryptohi.h> |
| 10 #include <nss.h> | 10 #include <nss.h> |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 247 |
| 248 DCHECK(cert->derCert.len); | 248 DCHECK(cert->derCert.len); |
| 249 // XXX copied from X509Certificate::GetDEREncoded | 249 // XXX copied from X509Certificate::GetDEREncoded |
| 250 der_cert->clear(); | 250 der_cert->clear(); |
| 251 der_cert->append(reinterpret_cast<char*>(cert->derCert.data), | 251 der_cert->append(reinterpret_cast<char*>(cert->derCert.data), |
| 252 cert->derCert.len); | 252 cert->derCert.len); |
| 253 CERT_DestroyCertificate(cert); | 253 CERT_DestroyCertificate(cert); |
| 254 return true; | 254 return true; |
| 255 } | 255 } |
| 256 | 256 |
| 257 #if defined(USE_NSS) || defined(OS_IOS) |
| 257 // Callback for CERT_DecodeCertPackage(), used in | 258 // Callback for CERT_DecodeCertPackage(), used in |
| 258 // CreateOSCertHandlesFromBytes(). | 259 // CreateOSCertHandlesFromBytes(). |
| 259 SECStatus PR_CALLBACK CollectCertsCallback(void* arg, | 260 SECStatus PR_CALLBACK CollectCertsCallback(void* arg, |
| 260 SECItem** certs, | 261 SECItem** certs, |
| 261 int num_certs) { | 262 int num_certs) { |
| 262 X509Certificate::OSCertHandles* results = | 263 X509Certificate::OSCertHandles* results = |
| 263 reinterpret_cast<X509Certificate::OSCertHandles*>(arg); | 264 reinterpret_cast<X509Certificate::OSCertHandles*>(arg); |
| 264 | 265 |
| 265 for (int i = 0; i < num_certs; ++i) { | 266 for (int i = 0; i < num_certs; ++i) { |
| 266 X509Certificate::OSCertHandle handle = | 267 X509Certificate::OSCertHandle handle = |
| 267 X509Certificate::CreateOSCertHandleFromBytes( | 268 X509Certificate::CreateOSCertHandleFromBytes( |
| 268 reinterpret_cast<char*>(certs[i]->data), certs[i]->len); | 269 reinterpret_cast<char*>(certs[i]->data), certs[i]->len); |
| 269 if (handle) | 270 if (handle) |
| 270 results->push_back(handle); | 271 results->push_back(handle); |
| 271 } | 272 } |
| 272 | 273 |
| 273 return SECSuccess; | 274 return SECSuccess; |
| 274 } | 275 } |
| 276 #endif // defined(USE_NSS) || defined(OS_IOS) |
| 275 | 277 |
| 276 } // namespace | 278 } // namespace |
| 277 | 279 |
| 278 namespace x509_util { | 280 namespace x509_util { |
| 279 | 281 |
| 280 CERTCertificate* CreateSelfSignedCert( | 282 CERTCertificate* CreateSelfSignedCert( |
| 281 SECKEYPublicKey* public_key, | 283 SECKEYPublicKey* public_key, |
| 282 SECKEYPrivateKey* private_key, | 284 SECKEYPrivateKey* private_key, |
| 283 const std::string& subject, | 285 const std::string& subject, |
| 284 uint32 serial_number, | 286 uint32 serial_number, |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 *type = X509Certificate::kPublicKeyTypeUnknown; | 525 *type = X509Certificate::kPublicKeyTypeUnknown; |
| 524 *size_bits = 0; | 526 *size_bits = 0; |
| 525 break; | 527 break; |
| 526 } | 528 } |
| 527 } | 529 } |
| 528 #endif // defined(USE_NSS) || defined(OS_IOS) | 530 #endif // defined(USE_NSS) || defined(OS_IOS) |
| 529 | 531 |
| 530 } // namespace x509_util | 532 } // namespace x509_util |
| 531 | 533 |
| 532 } // namespace net | 534 } // namespace net |
| OLD | NEW |