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 14 matching lines...) Expand all Loading... |
25 #include "net/base/cert_status_flags.h" | 25 #include "net/base/cert_status_flags.h" |
26 #include "net/base/cert_verify_result.h" | 26 #include "net/base/cert_verify_result.h" |
27 #include "net/base/net_errors.h" | 27 #include "net/base/net_errors.h" |
28 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
29 #include "net/base/pem_tokenizer.h" | 29 #include "net/base/pem_tokenizer.h" |
30 | 30 |
31 namespace net { | 31 namespace net { |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 // Returns true if this cert fingerprint is the null (all zero) fingerprint. | |
36 // We use this as a bogus fingerprint value. | |
37 bool IsNullFingerprint(const SHA1Fingerprint& fingerprint) { | |
38 for (size_t i = 0; i < arraysize(fingerprint.data); ++i) { | |
39 if (fingerprint.data[i] != 0) | |
40 return false; | |
41 } | |
42 return true; | |
43 } | |
44 | |
45 // Indicates the order to use when trying to decode binary data, which is | 35 // Indicates the order to use when trying to decode binary data, which is |
46 // based on (speculation) as to what will be most common -> least common | 36 // based on (speculation) as to what will be most common -> least common |
47 const X509Certificate::Format kFormatDecodePriority[] = { | 37 const X509Certificate::Format kFormatDecodePriority[] = { |
48 X509Certificate::FORMAT_SINGLE_CERTIFICATE, | 38 X509Certificate::FORMAT_SINGLE_CERTIFICATE, |
49 X509Certificate::FORMAT_PKCS7 | 39 X509Certificate::FORMAT_PKCS7 |
50 }; | 40 }; |
51 | 41 |
52 // The PEM block header used for DER certificates | 42 // The PEM block header used for DER certificates |
53 const char kCertificateHeader[] = "CERTIFICATE"; | 43 const char kCertificateHeader[] = "CERTIFICATE"; |
54 // The PEM block header used for PKCS#7 data | 44 // The PEM block header used for PKCS#7 data |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash, | 692 bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash, |
703 const uint8* array, | 693 const uint8* array, |
704 size_t array_byte_len) { | 694 size_t array_byte_len) { |
705 DCHECK_EQ(0u, array_byte_len % base::SHA1_LENGTH); | 695 DCHECK_EQ(0u, array_byte_len % base::SHA1_LENGTH); |
706 const unsigned arraylen = array_byte_len / base::SHA1_LENGTH; | 696 const unsigned arraylen = array_byte_len / base::SHA1_LENGTH; |
707 return NULL != bsearch(hash.data, array, arraylen, base::SHA1_LENGTH, | 697 return NULL != bsearch(hash.data, array, arraylen, base::SHA1_LENGTH, |
708 CompareSHA1Hashes); | 698 CompareSHA1Hashes); |
709 } | 699 } |
710 | 700 |
711 } // namespace net | 701 } // namespace net |
OLD | NEW |