OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/cert/internal/parse_name.h" | 5 #include "net/cert/internal/parse_name.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversion_utils.h" | 10 #include "base/strings/utf_string_conversion_utils.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 static const uint8_t oid[] = {0x55, 0x04, 0x07}; | 127 static const uint8_t oid[] = {0x55, 0x04, 0x07}; |
128 return der::Input(oid); | 128 return der::Input(oid); |
129 } | 129 } |
130 | 130 |
131 der::Input TypeStateOrProvinceNameOid() { | 131 der::Input TypeStateOrProvinceNameOid() { |
132 // id-at-stateOrProvinceName: 2.5.4.8 (RFC 5280) | 132 // id-at-stateOrProvinceName: 2.5.4.8 (RFC 5280) |
133 static const uint8_t oid[] = {0x55, 0x04, 0x08}; | 133 static const uint8_t oid[] = {0x55, 0x04, 0x08}; |
134 return der::Input(oid); | 134 return der::Input(oid); |
135 } | 135 } |
136 | 136 |
| 137 der::Input TypeStreetAddressOid() { |
| 138 // street (streetAddress): 2.5.4.9 (RFC 4519) |
| 139 static const uint8_t oid[] = {0x55, 0x04, 0x09}; |
| 140 return der::Input(oid); |
| 141 } |
| 142 |
137 der::Input TypeOrganizationNameOid() { | 143 der::Input TypeOrganizationNameOid() { |
138 // id-at-organizationName: 2.5.4.10 (RFC 5280) | 144 // id-at-organizationName: 2.5.4.10 (RFC 5280) |
139 static const uint8_t oid[] = {0x55, 0x04, 0x0a}; | 145 static const uint8_t oid[] = {0x55, 0x04, 0x0a}; |
140 return der::Input(oid); | 146 return der::Input(oid); |
141 } | 147 } |
142 | 148 |
143 der::Input TypeOrganizationUnitNameOid() { | 149 der::Input TypeOrganizationUnitNameOid() { |
144 // id-at-organizationalUnitName: 2.5.4.11 (RFC 5280) | 150 // id-at-organizationalUnitName: 2.5.4.11 (RFC 5280) |
145 static const uint8_t oid[] = {0x55, 0x04, 0x0b}; | 151 static const uint8_t oid[] = {0x55, 0x04, 0x0b}; |
146 return der::Input(oid); | 152 return der::Input(oid); |
(...skipping 22 matching lines...) Expand all Loading... |
169 static const uint8_t oid[] = {0x55, 0x04, 0x2b}; | 175 static const uint8_t oid[] = {0x55, 0x04, 0x2b}; |
170 return der::Input(oid); | 176 return der::Input(oid); |
171 } | 177 } |
172 | 178 |
173 der::Input TypeGenerationQualifierOid() { | 179 der::Input TypeGenerationQualifierOid() { |
174 // id-at-generationQualifier: 2.5.4.44 (RFC 5280) | 180 // id-at-generationQualifier: 2.5.4.44 (RFC 5280) |
175 static const uint8_t oid[] = {0x55, 0x04, 0x2c}; | 181 static const uint8_t oid[] = {0x55, 0x04, 0x2c}; |
176 return der::Input(oid); | 182 return der::Input(oid); |
177 } | 183 } |
178 | 184 |
| 185 der::Input TypeDomainComponentOid() { |
| 186 // dc (domainComponent): 0.9.2342.19200300.100.1.25 (RFC 4519) |
| 187 static const uint8_t oid[] = {0x09, 0x92, 0x26, 0x89, 0x93, |
| 188 0xF2, 0x2C, 0x64, 0x01, 0x19}; |
| 189 return der::Input(oid); |
| 190 } |
| 191 |
179 bool X509NameAttribute::ValueAsString(std::string* out) const { | 192 bool X509NameAttribute::ValueAsString(std::string* out) const { |
180 switch (value_tag) { | 193 switch (value_tag) { |
181 case der::kTeletexString: | 194 case der::kTeletexString: |
182 for (char c : value.AsStringPiece()) { | 195 for (char c : value.AsStringPiece()) { |
183 if (c < 32 || c > 126) | 196 if (c < 32 || c > 126) |
184 return false; | 197 return false; |
185 } | 198 } |
186 *out = value.AsString(); | 199 *out = value.AsString(); |
187 return true; | 200 return true; |
188 case der::kIA5String: | 201 case der::kIA5String: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 return ConvertBmpStringValue(value, out); | 240 return ConvertBmpStringValue(value, out); |
228 default: | 241 default: |
229 NOTREACHED(); | 242 NOTREACHED(); |
230 return false; | 243 return false; |
231 } | 244 } |
232 } | 245 } |
233 | 246 |
234 bool X509NameAttribute::AsRFC2253String(std::string* out) const { | 247 bool X509NameAttribute::AsRFC2253String(std::string* out) const { |
235 std::string type_string; | 248 std::string type_string; |
236 std::string value_string; | 249 std::string value_string; |
| 250 // TODO(mattm): Add streetAddress and domainComponent here? |
237 if (type == TypeCommonNameOid()) { | 251 if (type == TypeCommonNameOid()) { |
238 type_string = "CN"; | 252 type_string = "CN"; |
239 } else if (type == TypeSurnameOid()) { | 253 } else if (type == TypeSurnameOid()) { |
240 type_string = "SN"; | 254 type_string = "SN"; |
241 } else if (type == TypeCountryNameOid()) { | 255 } else if (type == TypeCountryNameOid()) { |
242 type_string = "C"; | 256 type_string = "C"; |
243 } else if (type == TypeLocalityNameOid()) { | 257 } else if (type == TypeLocalityNameOid()) { |
244 type_string = "L"; | 258 type_string = "L"; |
245 } else if (type == TypeStateOrProvinceNameOid()) { | 259 } else if (type == TypeStateOrProvinceNameOid()) { |
246 type_string = "ST"; | 260 type_string = "ST"; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 if (!rdns_string.empty()) | 378 if (!rdns_string.empty()) |
365 rdns_string += ","; | 379 rdns_string += ","; |
366 rdns_string += rdn_string; | 380 rdns_string += rdn_string; |
367 } | 381 } |
368 | 382 |
369 *out = rdns_string; | 383 *out = rdns_string; |
370 return true; | 384 return true; |
371 } | 385 } |
372 | 386 |
373 } // namespace net | 387 } // namespace net |
OLD | NEW |