OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 int length) { | 298 int length) { |
299 OSCertHandle cert_handle = CreateOSCertHandleFromBytes(data, length); | 299 OSCertHandle cert_handle = CreateOSCertHandleFromBytes(data, length); |
300 if (!cert_handle) | 300 if (!cert_handle) |
301 return NULL; | 301 return NULL; |
302 | 302 |
303 X509Certificate* cert = CreateFromHandle(cert_handle, OSCertHandles()); | 303 X509Certificate* cert = CreateFromHandle(cert_handle, OSCertHandles()); |
304 FreeOSCertHandle(cert_handle); | 304 FreeOSCertHandle(cert_handle); |
305 return cert; | 305 return cert; |
306 } | 306 } |
307 | 307 |
308 #if defined(USE_NSS) | |
309 // static | |
310 X509Certificate* X509Certificate::CreateFromBytesWithNickname( | |
wtc
2011/11/29 23:13:57
This probably should be moved to x509_certificate_
Greg Spencer (Chromium)
2011/12/02 18:50:07
Ahh, good point. I moved it there.
| |
311 const char* data, | |
312 int length, | |
313 const char* nickname) { | |
314 OSCertHandle cert_handle = CreateOSCertHandleFromBytesWithNickname(data, | |
315 length, | |
316 nickname); | |
317 if (!cert_handle) | |
318 return NULL; | |
319 | |
320 X509Certificate* cert = CreateFromHandle(cert_handle, OSCertHandles()); | |
321 FreeOSCertHandle(cert_handle); | |
322 return cert; | |
323 } | |
324 #endif | |
325 | |
308 // static | 326 // static |
309 X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle, | 327 X509Certificate* X509Certificate::CreateFromPickle(const Pickle& pickle, |
310 void** pickle_iter, | 328 void** pickle_iter, |
311 PickleType type) { | 329 PickleType type) { |
312 OSCertHandle cert_handle = ReadOSCertHandleFromPickle(pickle, pickle_iter); | 330 OSCertHandle cert_handle = ReadOSCertHandleFromPickle(pickle, pickle_iter); |
313 if (!cert_handle) | 331 if (!cert_handle) |
314 return NULL; | 332 return NULL; |
315 | 333 |
316 OSCertHandles intermediates; | 334 OSCertHandles intermediates; |
317 size_t num_intermediates = 0; | 335 size_t num_intermediates = 0; |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
798 bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash, | 816 bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash, |
799 const uint8* array, | 817 const uint8* array, |
800 size_t array_byte_len) { | 818 size_t array_byte_len) { |
801 DCHECK_EQ(0u, array_byte_len % base::kSHA1Length); | 819 DCHECK_EQ(0u, array_byte_len % base::kSHA1Length); |
802 const size_t arraylen = array_byte_len / base::kSHA1Length; | 820 const size_t arraylen = array_byte_len / base::kSHA1Length; |
803 return NULL != bsearch(hash.data, array, arraylen, base::kSHA1Length, | 821 return NULL != bsearch(hash.data, array, arraylen, base::kSHA1Length, |
804 CompareSHA1Hashes); | 822 CompareSHA1Hashes); |
805 } | 823 } |
806 | 824 |
807 } // namespace net | 825 } // namespace net |
OLD | NEW |