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_certificate.h" | 5 #include "net/base/x509_certificate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 if (!cert_handle) | 317 if (!cert_handle) |
318 return NULL; | 318 return NULL; |
319 | 319 |
320 X509Certificate* cert = CreateFromHandle(cert_handle, OSCertHandles()); | 320 X509Certificate* cert = CreateFromHandle(cert_handle, OSCertHandles()); |
321 FreeOSCertHandle(cert_handle); | 321 FreeOSCertHandle(cert_handle); |
322 return cert; | 322 return cert; |
323 } | 323 } |
324 | 324 |
325 // static | 325 // static |
326 X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle, | 326 X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle, |
327 void** pickle_iter, | 327 PickleIterator* pickle_iter, |
328 PickleType type) { | 328 PickleType type) { |
329 OSCertHandle cert_handle = ReadOSCertHandleFromPickle(pickle, pickle_iter); | 329 OSCertHandle cert_handle = ReadOSCertHandleFromPickle(pickle, pickle_iter); |
330 if (!cert_handle) | 330 if (!cert_handle) |
331 return NULL; | 331 return NULL; |
332 | 332 |
333 OSCertHandles intermediates; | 333 OSCertHandles intermediates; |
334 size_t num_intermediates = 0; | 334 size_t num_intermediates = 0; |
335 if (type == PICKLETYPE_CERTIFICATE_CHAIN) { | 335 if (type == PICKLETYPE_CERTIFICATE_CHAIN) { |
336 if (!pickle.ReadSize(pickle_iter, &num_intermediates)) { | 336 if (!pickle.ReadSize(pickle_iter, &num_intermediates)) { |
337 FreeOSCertHandle(cert_handle); | 337 FreeOSCertHandle(cert_handle); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash, | 857 bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash, |
858 const uint8* array, | 858 const uint8* array, |
859 size_t array_byte_len) { | 859 size_t array_byte_len) { |
860 DCHECK_EQ(0u, array_byte_len % base::kSHA1Length); | 860 DCHECK_EQ(0u, array_byte_len % base::kSHA1Length); |
861 const size_t arraylen = array_byte_len / base::kSHA1Length; | 861 const size_t arraylen = array_byte_len / base::kSHA1Length; |
862 return NULL != bsearch(hash.data, array, arraylen, base::kSHA1Length, | 862 return NULL != bsearch(hash.data, array, arraylen, base::kSHA1Length, |
863 CompareSHA1Hashes); | 863 CompareSHA1Hashes); |
864 } | 864 } |
865 | 865 |
866 } // namespace net | 866 } // namespace net |
OLD | NEW |