| 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_util_openssl.h" | 5 #include "net/cert/x509_util_openssl.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 base::StringPiece str_date(reinterpret_cast<const char*>(x509_time->data), | 279 base::StringPiece str_date(reinterpret_cast<const char*>(x509_time->data), |
| 280 x509_time->length); | 280 x509_time->length); |
| 281 | 281 |
| 282 CertDateFormat format = x509_time->type == V_ASN1_UTCTIME ? | 282 CertDateFormat format = x509_time->type == V_ASN1_UTCTIME ? |
| 283 CERT_DATE_FORMAT_UTC_TIME : CERT_DATE_FORMAT_GENERALIZED_TIME; | 283 CERT_DATE_FORMAT_UTC_TIME : CERT_DATE_FORMAT_GENERALIZED_TIME; |
| 284 return ParseCertificateDate(str_date, format, time); | 284 return ParseCertificateDate(str_date, format, time); |
| 285 } | 285 } |
| 286 | 286 |
| 287 // Returns true if |der_cache| points to valid data, false otherwise. | 287 // Returns true if |der_cache| points to valid data, false otherwise. |
| 288 // (note: the DER-encoded data in |der_cache| is owned by |cert|, callers should | 288 // (note: the DER-encoded data in |der_cache| is owned by |x509|, callers should |
| 289 // not free it). | 289 // not free it). |
| 290 bool GetDER(X509* x509, base::StringPiece* der_cache) { | 290 bool GetDER(X509* x509, base::StringPiece* der_cache) { |
| 291 if (x509->buf) { |
| 292 *der_cache = base::StringPiece( |
| 293 reinterpret_cast<const char*>(CRYPTO_BUFFER_data(x509->buf)), |
| 294 CRYPTO_BUFFER_len(x509->buf)); |
| 295 return true; |
| 296 } |
| 297 |
| 291 int x509_der_cache_index = | 298 int x509_der_cache_index = |
| 292 g_der_cache_singleton.Get().der_cache_ex_index(); | 299 g_der_cache_singleton.Get().der_cache_ex_index(); |
| 293 | 300 |
| 294 // Re-encoding the DER data via i2d_X509 is an expensive operation, | 301 // Re-encoding the DER data via i2d_X509 is an expensive operation, |
| 295 // but it's necessary for comparing two certificates. Re-encode at | 302 // but it's necessary for comparing two certificates. Re-encode at |
| 296 // most once per certificate and cache the data within the X509 cert | 303 // most once per certificate and cache the data within the X509 cert |
| 297 // using X509_set_ex_data. | 304 // using X509_set_ex_data. |
| 298 DERCache* internal_cache = static_cast<DERCache*>( | 305 DERCache* internal_cache = static_cast<DERCache*>( |
| 299 X509_get_ex_data(x509, x509_der_cache_index)); | 306 X509_get_ex_data(x509, x509_der_cache_index)); |
| 300 if (!internal_cache) { | 307 if (!internal_cache) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 return true; | 368 return true; |
| 362 } | 369 } |
| 363 | 370 |
| 364 CRYPTO_BUFFER_POOL* GetBufferPool() { | 371 CRYPTO_BUFFER_POOL* GetBufferPool() { |
| 365 return g_buffer_pool_singleton.Get().pool(); | 372 return g_buffer_pool_singleton.Get().pool(); |
| 366 } | 373 } |
| 367 | 374 |
| 368 } // namespace x509_util | 375 } // namespace x509_util |
| 369 | 376 |
| 370 } // namespace net | 377 } // namespace net |
| OLD | NEW |