| 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::ValueAsStringUnsafe(std::string* out) const { | 192 bool X509NameAttribute::ValueAsStringUnsafe(std::string* out) const { |
| 180 switch (value_tag) { | 193 switch (value_tag) { |
| 181 case der::kIA5String: | 194 case der::kIA5String: |
| 182 case der::kPrintableString: | 195 case der::kPrintableString: |
| 183 case der::kTeletexString: | 196 case der::kTeletexString: |
| 184 case der::kUtf8String: | 197 case der::kUtf8String: |
| 185 *out = value.AsString(); | 198 *out = value.AsString(); |
| 186 return true; | 199 return true; |
| 187 case der::kUniversalString: | 200 case der::kUniversalString: |
| 188 return ConvertUniversalStringValue(value, out); | 201 return ConvertUniversalStringValue(value, out); |
| 189 case der::kBmpString: | 202 case der::kBmpString: |
| 190 return ConvertBmpStringValue(value, out); | 203 return ConvertBmpStringValue(value, out); |
| 191 default: | 204 default: |
| 192 NOTREACHED(); | 205 NOTREACHED(); |
| 193 return false; | 206 return false; |
| 194 } | 207 } |
| 195 } | 208 } |
| 196 | 209 |
| 197 bool X509NameAttribute::AsRFC2253String(std::string* out) const { | 210 bool X509NameAttribute::AsRFC2253String(std::string* out) const { |
| 198 std::string type_string; | 211 std::string type_string; |
| 199 std::string value_string; | 212 std::string value_string; |
| 213 // TODO(mattm): Add streetAddress and domainComponent here? |
| 200 if (type == TypeCommonNameOid()) { | 214 if (type == TypeCommonNameOid()) { |
| 201 type_string = "CN"; | 215 type_string = "CN"; |
| 202 } else if (type == TypeSurnameOid()) { | 216 } else if (type == TypeSurnameOid()) { |
| 203 type_string = "SN"; | 217 type_string = "SN"; |
| 204 } else if (type == TypeCountryNameOid()) { | 218 } else if (type == TypeCountryNameOid()) { |
| 205 type_string = "C"; | 219 type_string = "C"; |
| 206 } else if (type == TypeLocalityNameOid()) { | 220 } else if (type == TypeLocalityNameOid()) { |
| 207 type_string = "L"; | 221 type_string = "L"; |
| 208 } else if (type == TypeStateOrProvinceNameOid()) { | 222 } else if (type == TypeStateOrProvinceNameOid()) { |
| 209 type_string = "ST"; | 223 type_string = "ST"; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 if (!rdns_string.empty()) | 341 if (!rdns_string.empty()) |
| 328 rdns_string += ","; | 342 rdns_string += ","; |
| 329 rdns_string += rdn_string; | 343 rdns_string += rdn_string; |
| 330 } | 344 } |
| 331 | 345 |
| 332 *out = rdns_string; | 346 *out = rdns_string; |
| 333 return true; | 347 return true; |
| 334 } | 348 } |
| 335 | 349 |
| 336 } // namespace net | 350 } // namespace net |
| OLD | NEW |