OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/x509_certificate.h" | 5 #include "net/cert/x509_certificate.h" |
6 | 6 |
7 #include "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/stl_util.h" |
9 #include "crypto/openssl_util.h" | 10 #include "crypto/openssl_util.h" |
10 #include "net/base/ip_address.h" | 11 #include "net/base/ip_address.h" |
11 #include "net/cert/asn1_util.h" | 12 #include "net/cert/asn1_util.h" |
12 #include "net/cert/internal/cert_errors.h" | 13 #include "net/cert/internal/cert_errors.h" |
13 #include "net/cert/internal/name_constraints.h" | 14 #include "net/cert/internal/name_constraints.h" |
14 #include "net/cert/internal/parse_name.h" | 15 #include "net/cert/internal/parse_name.h" |
15 #include "net/cert/internal/parsed_certificate.h" | 16 #include "net/cert/internal/parsed_certificate.h" |
16 #include "net/cert/internal/signature_policy.h" | 17 #include "net/cert/internal/signature_policy.h" |
17 #include "net/cert/internal/verify_name_match.h" | 18 #include "net/cert/internal/verify_name_match.h" |
18 #include "net/cert/internal/verify_signed_data.h" | 19 #include "net/cert/internal/verify_signed_data.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 if (!GetSequenceValue(der::Input(&raw_issuer), &issuer_value) || | 257 if (!GetSequenceValue(der::Input(&raw_issuer), &issuer_value) || |
257 !NormalizeName(issuer_value, &normalized_issuer)) { | 258 !NormalizeName(issuer_value, &normalized_issuer)) { |
258 continue; | 259 continue; |
259 } | 260 } |
260 normalized_issuers.push_back(std::move(normalized_issuer)); | 261 normalized_issuers.push_back(std::move(normalized_issuer)); |
261 } | 262 } |
262 | 263 |
263 std::string normalized_cert_issuer; | 264 std::string normalized_cert_issuer; |
264 if (!GetNormalizedCertIssuer(cert_handle_, &normalized_cert_issuer)) | 265 if (!GetNormalizedCertIssuer(cert_handle_, &normalized_cert_issuer)) |
265 return false; | 266 return false; |
266 if (std::find(normalized_issuers.begin(), normalized_issuers.end(), | 267 if (base::ContainsValue(normalized_issuers, normalized_cert_issuer)) |
267 normalized_cert_issuer) != normalized_issuers.end()) | |
268 return true; | 268 return true; |
269 | 269 |
270 for (CRYPTO_BUFFER* intermediate : intermediate_ca_certs_) { | 270 for (CRYPTO_BUFFER* intermediate : intermediate_ca_certs_) { |
271 if (!GetNormalizedCertIssuer(intermediate, &normalized_cert_issuer)) | 271 if (!GetNormalizedCertIssuer(intermediate, &normalized_cert_issuer)) |
272 return false; | 272 return false; |
273 if (std::find(normalized_issuers.begin(), normalized_issuers.end(), | 273 if (base::ContainsValue(normalized_issuers, normalized_cert_issuer)) |
274 normalized_cert_issuer) != normalized_issuers.end()) | |
275 return true; | 274 return true; |
276 } | 275 } |
277 return false; | 276 return false; |
278 } | 277 } |
279 | 278 |
280 // static | 279 // static |
281 bool X509Certificate::GetDEREncoded(X509Certificate::OSCertHandle cert_handle, | 280 bool X509Certificate::GetDEREncoded(X509Certificate::OSCertHandle cert_handle, |
282 std::string* encoded) { | 281 std::string* encoded) { |
283 if (!cert_handle) | 282 if (!cert_handle) |
284 return false; | 283 return false; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 482 |
484 // static | 483 // static |
485 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, | 484 bool X509Certificate::WriteOSCertHandleToPickle(OSCertHandle cert_handle, |
486 base::Pickle* pickle) { | 485 base::Pickle* pickle) { |
487 return pickle->WriteData( | 486 return pickle->WriteData( |
488 reinterpret_cast<const char*>(CRYPTO_BUFFER_data(cert_handle)), | 487 reinterpret_cast<const char*>(CRYPTO_BUFFER_data(cert_handle)), |
489 CRYPTO_BUFFER_len(cert_handle)); | 488 CRYPTO_BUFFER_len(cert_handle)); |
490 } | 489 } |
491 | 490 |
492 } // namespace net | 491 } // namespace net |
OLD | NEW |