| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/x509_certificate.h" | 5 #include "net/base/x509_certificate.h" |
| 6 | 6 |
| 7 #include <openssl/asn1.h> | 7 #include <openssl/asn1.h> |
| 8 #include <openssl/crypto.h> | 8 #include <openssl/crypto.h> |
| 9 #include <openssl/obj_mac.h> | 9 #include <openssl/obj_mac.h> |
| 10 #include <openssl/pem.h> | 10 #include <openssl/pem.h> |
| 11 #include <openssl/pkcs7.h> | 11 #include <openssl/pkcs7.h> |
| 12 #include <openssl/sha.h> | 12 #include <openssl/sha.h> |
| 13 #include <openssl/ssl.h> | 13 #include <openssl/ssl.h> |
| 14 #include <openssl/x509v3.h> | 14 #include <openssl/x509v3.h> |
| 15 | 15 |
| 16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
| 17 #include "base/pickle.h" | 17 #include "base/pickle.h" |
| 18 #include "base/sha1.h" | 18 #include "base/sha1.h" |
| 19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "crypto/openssl_util.h" | 21 #include "crypto/openssl_util.h" |
| 22 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 23 #include "net/base/net_util.h" |
| 23 #include "net/base/x509_util_openssl.h" | 24 #include "net/base/x509_util_openssl.h" |
| 24 | 25 |
| 25 #if defined(OS_ANDROID) | 26 #if defined(OS_ANDROID) |
| 26 #include "base/logging.h" | 27 #include "base/logging.h" |
| 27 #include "net/android/network_library.h" | 28 #include "net/android/network_library.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 namespace net { | 31 namespace net { |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 if (!dns_name) | 117 if (!dns_name) |
| 117 continue; | 118 continue; |
| 118 int dns_name_len = ASN1_STRING_length(name->d.dNSName); | 119 int dns_name_len = ASN1_STRING_length(name->d.dNSName); |
| 119 dns_names->push_back( | 120 dns_names->push_back( |
| 120 std::string(reinterpret_cast<const char*>(dns_name), dns_name_len)); | 121 std::string(reinterpret_cast<const char*>(dns_name), dns_name_len)); |
| 121 } else if (name->type == GEN_IPADD && ip_addresses) { | 122 } else if (name->type == GEN_IPADD && ip_addresses) { |
| 122 const unsigned char* ip_addr = name->d.iPAddress->data; | 123 const unsigned char* ip_addr = name->d.iPAddress->data; |
| 123 if (!ip_addr) | 124 if (!ip_addr) |
| 124 continue; | 125 continue; |
| 125 int ip_addr_len = name->d.iPAddress->length; | 126 int ip_addr_len = name->d.iPAddress->length; |
| 126 if (ip_addr_len != 4 && ip_addr_len != 8) { | 127 if (ip_addr_len != static_cast<int>(kIPv4AddressSize) && |
| 128 ip_addr_len != static_cast<int>(kIPv6AddressSize)) { |
| 127 // http://www.ietf.org/rfc/rfc3280.txt requires subjectAltName iPAddress | 129 // http://www.ietf.org/rfc/rfc3280.txt requires subjectAltName iPAddress |
| 128 // to have 4 or 16 bytes, whereas in a name constraint it includes a | 130 // to have 4 or 16 bytes, whereas in a name constraint it includes a |
| 129 // net mask hence 8 or 32 bytes. Logging to help diagnose any mixup. | 131 // net mask hence 8 or 32 bytes. Logging to help diagnose any mixup. |
| 130 LOG(WARNING) << "Bad sized IP Address in cert: " << ip_addr_len; | 132 LOG(WARNING) << "Bad sized IP Address in cert: " << ip_addr_len; |
| 131 continue; | 133 continue; |
| 132 } | 134 } |
| 133 ip_addresses->push_back( | 135 ip_addresses->push_back( |
| 134 std::string(reinterpret_cast<const char*>(ip_addr), ip_addr_len)); | 136 std::string(reinterpret_cast<const char*>(ip_addr), ip_addr_len)); |
| 135 } | 137 } |
| 136 } | 138 } |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 *size_bits = EVP_PKEY_size(key) * 8; | 463 *size_bits = EVP_PKEY_size(key) * 8; |
| 462 break; | 464 break; |
| 463 default: | 465 default: |
| 464 *type = kPublicKeyTypeUnknown; | 466 *type = kPublicKeyTypeUnknown; |
| 465 *size_bits = 0; | 467 *size_bits = 0; |
| 466 break; | 468 break; |
| 467 } | 469 } |
| 468 } | 470 } |
| 469 | 471 |
| 470 } // namespace net | 472 } // namespace net |
| OLD | NEW |