| 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/tools/domain_security_preload_generator/cert_util.h" | 5 #include "net/tools/transport_security_state_generator/cert_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "net/tools/domain_security_preload_generator/spki_hash.h" | 13 #include "net/tools/transport_security_state_generator/spki_hash.h" |
| 14 #include "third_party/boringssl/src/include/openssl/crypto.h" | 14 #include "third_party/boringssl/src/include/openssl/crypto.h" |
| 15 | 15 |
| 16 using net::transport_security_state::SPKIHash; | 16 using net::transport_security_state::SPKIHash; |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 static const char kPEMBeginBlock[] = "-----BEGIN %s-----"; | 20 static const char kPEMBeginBlock[] = "-----BEGIN %s-----"; |
| 21 static const char kPEMEndBlock[] = "-----END %s-----"; | 21 static const char kPEMEndBlock[] = "-----END %s-----"; |
| 22 | 22 |
| 23 // Tries to extract the BASE64 encoded DER structure from |pem_input| by looking | 23 // Tries to extract the BASE64 encoded DER structure from |pem_input| by looking |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 std::string der; | 146 std::string der; |
| 147 bool result = ParsePEM(pem_key, "PUBLIC KEY", &der); | 147 bool result = ParsePEM(pem_key, "PUBLIC KEY", &der); |
| 148 if (!result) { | 148 if (!result) { |
| 149 return false; | 149 return false; |
| 150 } | 150 } |
| 151 | 151 |
| 152 out_hash->CalculateFromBytes(reinterpret_cast<const uint8_t*>(der.data()), | 152 out_hash->CalculateFromBytes(reinterpret_cast<const uint8_t*>(der.data()), |
| 153 der.size()); | 153 der.size()); |
| 154 return true; | 154 return true; |
| 155 } | 155 } |
| OLD | NEW |