| 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/x509_certificate.h" | 5 #include "net/cert/x509_certificate.h" |
| 6 | 6 |
| 7 #include <openssl/asn1.h> | 7 #include <openssl/asn1.h> |
| 8 #include <openssl/bytestring.h> | 8 #include <openssl/bytestring.h> |
| 9 #include <openssl/crypto.h> | 9 #include <openssl/crypto.h> |
| 10 #include <openssl/obj_mac.h> | 10 #include <openssl/obj_mac.h> |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 void sk_X509_NAME_free_all(STACK_OF(X509_NAME)* sk) { | 234 void sk_X509_NAME_free_all(STACK_OF(X509_NAME)* sk) { |
| 235 sk_X509_NAME_pop_free(sk, X509_NAME_free); | 235 sk_X509_NAME_pop_free(sk, X509_NAME_free); |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace | 238 } // namespace |
| 239 | 239 |
| 240 // static | 240 // static |
| 241 X509Certificate::OSCertHandle X509Certificate::DupOSCertHandle( | 241 X509Certificate::OSCertHandle X509Certificate::DupOSCertHandle( |
| 242 OSCertHandle cert_handle) { | 242 OSCertHandle cert_handle) { |
| 243 DCHECK(cert_handle); | 243 DCHECK(cert_handle); |
| 244 // Using X509_dup causes the entire certificate to be reparsed. This | 244 return X509_up_ref(cert_handle); |
| 245 // conversion, besides being non-trivial, drops any associated | |
| 246 // application-specific data set by X509_set_ex_data. Using CRYPTO_add | |
| 247 // just bumps up the ref-count for the cert, without causing any allocations | |
| 248 // or deallocations. | |
| 249 CRYPTO_add(&cert_handle->references, 1, CRYPTO_LOCK_X509); | |
| 250 return cert_handle; | |
| 251 } | 245 } |
| 252 | 246 |
| 253 // static | 247 // static |
| 254 void X509Certificate::FreeOSCertHandle(OSCertHandle cert_handle) { | 248 void X509Certificate::FreeOSCertHandle(OSCertHandle cert_handle) { |
| 255 // Decrement the ref-count for the cert and, if all references are gone, | 249 // Decrement the ref-count for the cert and, if all references are gone, |
| 256 // free the memory and any application-specific data associated with the | 250 // free the memory and any application-specific data associated with the |
| 257 // certificate. | 251 // certificate. |
| 258 X509_free(cert_handle); | 252 X509_free(cert_handle); |
| 259 } | 253 } |
| 260 | 254 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 if (X509_NAME_cmp(issuer, cert_names[n]) == 0) { | 501 if (X509_NAME_cmp(issuer, cert_names[n]) == 0) { |
| 508 return true; | 502 return true; |
| 509 } | 503 } |
| 510 } | 504 } |
| 511 } | 505 } |
| 512 | 506 |
| 513 return false; | 507 return false; |
| 514 } | 508 } |
| 515 | 509 |
| 516 } // namespace net | 510 } // namespace net |
| OLD | NEW |