Chromium Code Reviews| 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 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 23 #include <windows.h> | 23 #include <windows.h> |
| 24 #include <wincrypt.h> | 24 #include <wincrypt.h> |
| 25 #elif defined(OS_MACOSX) | 25 #elif defined(OS_MACOSX) |
| 26 #include <Security/x509defs.h> | 26 #include <Security/x509defs.h> |
| 27 #elif defined(USE_NSS) | 27 #elif defined(USE_NSS) |
| 28 // Forward declaration; real one in <cert.h> | 28 // Forward declaration; real one in <cert.h> |
| 29 struct CERTCertificateStr; | 29 struct CERTCertificateStr; |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 namespace base { | |
| 33 class Time; | |
| 34 class StringPiece; | |
| 35 } // namespace base | |
| 36 | |
| 32 namespace net { | 37 namespace net { |
| 33 | 38 |
| 34 class X509Certificate; | 39 class X509Certificate; |
| 35 | 40 |
| 36 // SHA-1 fingerprint (160 bits) of a certificate. | 41 // SHA-1 fingerprint (160 bits) of a certificate. |
| 37 struct SHA1Fingerprint { | 42 struct SHA1Fingerprint { |
| 38 bool Equals(const SHA1Fingerprint& other) const { | 43 bool Equals(const SHA1Fingerprint& other) const { |
| 39 return memcmp(data, other.data, sizeof(data)) == 0; | 44 return memcmp(data, other.data, sizeof(data)) == 0; |
| 40 } | 45 } |
| 41 | 46 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 }; | 137 }; |
| 133 | 138 |
| 134 #if defined(OS_MACOSX) | 139 #if defined(OS_MACOSX) |
| 135 // Compares two OIDs by value. | 140 // Compares two OIDs by value. |
| 136 inline bool CSSMOIDEqual(const CSSM_OID* oid1, const CSSM_OID* oid2) { | 141 inline bool CSSMOIDEqual(const CSSM_OID* oid1, const CSSM_OID* oid2) { |
| 137 return oid1->Length == oid2->Length && | 142 return oid1->Length == oid2->Length && |
| 138 (memcmp(oid1->Data, oid2->Data, oid1->Length) == 0); | 143 (memcmp(oid1->Data, oid2->Data, oid1->Length) == 0); |
| 139 } | 144 } |
| 140 #endif | 145 #endif |
| 141 | 146 |
| 147 // A list of ASN.1 date/time formats that ParseCertificateDate() supports, | |
| 148 // encoded in the canonical forms specified in RFC 2459/3280/5280. | |
| 149 enum CertificateDateFormat { | |
|
wtc
2010/11/11 01:33:52
Nit: probably should rename this enum CertDataForm
| |
| 150 // UTCTime: Format is YYMMDDHHMMSSZ | |
| 151 CERT_DATE_FORMAT_UTC_TIME, | |
| 152 | |
| 153 // GeneralizedTime: Format is YYYYMMDDHHMMSSZ | |
| 154 CERT_DATE_FORMAT_GENERALIZED_TIME, | |
| 155 }; | |
| 156 | |
| 157 // Attempts to parse |raw_date|, an ASN.1 date/time string encoded as | |
| 158 // |format|, and writes the result into |*time|. If an invalid date is | |
| 159 // specified, or if parsing fails, returns false, and |*time| will not be | |
| 160 // updated. | |
| 161 bool ParseCertificateDate(const base::StringPiece& raw_date, | |
| 162 CertificateDateFormat format, | |
| 163 base::Time* time); | |
| 142 } // namespace net | 164 } // namespace net |
| 143 | 165 |
| 144 #endif // NET_BASE_X509_CERT_TYPES_H_ | 166 #endif // NET_BASE_X509_CERT_TYPES_H_ |
| OLD | NEW |