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 #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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return memcmp(lhs.data, rhs.data, sizeof(lhs.data)) < 0; | 44 return memcmp(lhs.data, rhs.data, sizeof(lhs.data)) < 0; |
45 } | 45 } |
46 }; | 46 }; |
47 | 47 |
48 // CertPrincipal represents the issuer or subject field of an X.509 certificate. | 48 // CertPrincipal represents the issuer or subject field of an X.509 certificate. |
49 struct NET_EXPORT CertPrincipal { | 49 struct NET_EXPORT CertPrincipal { |
50 CertPrincipal(); | 50 CertPrincipal(); |
51 explicit CertPrincipal(const std::string& name); | 51 explicit CertPrincipal(const std::string& name); |
52 ~CertPrincipal(); | 52 ~CertPrincipal(); |
53 | 53 |
54 #if defined(OS_MACOSX) | 54 #if defined(OS_MACOSX) || defined(OS_WIN) |
55 // Parses a BER-format DistinguishedName. | 55 // Parses a BER-format DistinguishedName. |
56 bool ParseDistinguishedName(const void* ber_name_data, size_t length); | 56 bool ParseDistinguishedName(const void* ber_name_data, size_t length); |
| 57 #endif |
57 | 58 |
| 59 #if defined(OS_MACOSX) |
58 // Compare this CertPrincipal with |against|, returning true if they're | 60 // Compare this CertPrincipal with |against|, returning true if they're |
59 // equal enough to be a possible match. This should NOT be used for any | 61 // equal enough to be a possible match. This should NOT be used for any |
60 // security relevant decisions. | 62 // security relevant decisions. |
61 // TODO(rsleevi): Remove once Mac client auth uses NSS for name comparison. | 63 // TODO(rsleevi): Remove once Mac client auth uses NSS for name comparison. |
62 bool Matches(const CertPrincipal& against) const; | 64 bool Matches(const CertPrincipal& against) const; |
63 #endif | 65 #endif |
64 | 66 |
65 // Returns a name that can be used to represent the issuer. It tries in this | 67 // Returns a name that can be used to represent the issuer. It tries in this |
66 // order: CN, O and OU and returns the first non-empty one found. | 68 // order: CN, O and OU and returns the first non-empty one found. |
67 std::string GetDisplayName() const; | 69 std::string GetDisplayName() const; |
68 | 70 |
69 // The different attributes for a principal. They may be "". | 71 // The different attributes for a principal, stored in UTF-8. They may be "". |
70 // Note that some of them can have several values. | 72 // Note that some of them can have several values. |
71 | 73 |
72 std::string common_name; | 74 std::string common_name; |
73 std::string locality_name; | 75 std::string locality_name; |
74 std::string state_or_province_name; | 76 std::string state_or_province_name; |
75 std::string country_name; | 77 std::string country_name; |
76 | 78 |
77 std::vector<std::string> street_addresses; | 79 std::vector<std::string> street_addresses; |
78 std::vector<std::string> organization_names; | 80 std::vector<std::string> organization_names; |
79 std::vector<std::string> organization_unit_names; | 81 std::vector<std::string> organization_unit_names; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // Attempts to parse |raw_date|, an ASN.1 date/time string encoded as | 145 // Attempts to parse |raw_date|, an ASN.1 date/time string encoded as |
144 // |format|, and writes the result into |*time|. If an invalid date is | 146 // |format|, and writes the result into |*time|. If an invalid date is |
145 // specified, or if parsing fails, returns false, and |*time| will not be | 147 // specified, or if parsing fails, returns false, and |*time| will not be |
146 // updated. | 148 // updated. |
147 bool ParseCertificateDate(const base::StringPiece& raw_date, | 149 bool ParseCertificateDate(const base::StringPiece& raw_date, |
148 CertDateFormat format, | 150 CertDateFormat format, |
149 base::Time* time); | 151 base::Time* time); |
150 } // namespace net | 152 } // namespace net |
151 | 153 |
152 #endif // NET_BASE_X509_CERT_TYPES_H_ | 154 #endif // NET_BASE_X509_CERT_TYPES_H_ |
OLD | NEW |