| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef NET_BASE_X509_CERT_TYPES_H_ | 5 #ifndef NET_BASE_X509_CERT_TYPES_H_ |
| 6 #define NET_BASE_X509_CERT_TYPES_H_ | 6 #define NET_BASE_X509_CERT_TYPES_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 | 16 |
| 17 #if defined(OS_MACOSX) | 17 #if defined(OS_MACOSX) |
| 18 #include <Security/x509defs.h> | 18 #include <Security/x509defs.h> |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 namespace base { |
| 22 class Time; |
| 23 class StringPiece; |
| 24 } // namespace base |
| 25 |
| 21 namespace net { | 26 namespace net { |
| 22 | 27 |
| 23 class X509Certificate; | 28 class X509Certificate; |
| 24 | 29 |
| 25 // SHA-1 fingerprint (160 bits) of a certificate. | 30 // SHA-1 fingerprint (160 bits) of a certificate. |
| 26 struct SHA1Fingerprint { | 31 struct SHA1Fingerprint { |
| 27 bool Equals(const SHA1Fingerprint& other) const { | 32 bool Equals(const SHA1Fingerprint& other) const { |
| 28 return memcmp(data, other.data, sizeof(data)) == 0; | 33 return memcmp(data, other.data, sizeof(data)) == 0; |
| 29 } | 34 } |
| 30 | 35 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 }; | 125 }; |
| 121 | 126 |
| 122 #if defined(OS_MACOSX) | 127 #if defined(OS_MACOSX) |
| 123 // Compares two OIDs by value. | 128 // Compares two OIDs by value. |
| 124 inline bool CSSMOIDEqual(const CSSM_OID* oid1, const CSSM_OID* oid2) { | 129 inline bool CSSMOIDEqual(const CSSM_OID* oid1, const CSSM_OID* oid2) { |
| 125 return oid1->Length == oid2->Length && | 130 return oid1->Length == oid2->Length && |
| 126 (memcmp(oid1->Data, oid2->Data, oid1->Length) == 0); | 131 (memcmp(oid1->Data, oid2->Data, oid1->Length) == 0); |
| 127 } | 132 } |
| 128 #endif | 133 #endif |
| 129 | 134 |
| 135 // A list of ASN.1 date/time formats that ParseCertificateDate() supports, |
| 136 // encoded in the canonical forms specified in RFC 2459/3280/5280. |
| 137 enum CertDateFormat { |
| 138 // UTCTime: Format is YYMMDDHHMMSSZ |
| 139 CERT_DATE_FORMAT_UTC_TIME, |
| 140 |
| 141 // GeneralizedTime: Format is YYYYMMDDHHMMSSZ |
| 142 CERT_DATE_FORMAT_GENERALIZED_TIME, |
| 143 }; |
| 144 |
| 145 // Attempts to parse |raw_date|, an ASN.1 date/time string encoded as |
| 146 // |format|, and writes the result into |*time|. If an invalid date is |
| 147 // specified, or if parsing fails, returns false, and |*time| will not be |
| 148 // updated. |
| 149 bool ParseCertificateDate(const base::StringPiece& raw_date, |
| 150 CertDateFormat format, |
| 151 base::Time* time); |
| 130 } // namespace net | 152 } // namespace net |
| 131 | 153 |
| 132 #endif // NET_BASE_X509_CERT_TYPES_H_ | 154 #endif // NET_BASE_X509_CERT_TYPES_H_ |
| OLD | NEW |