| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_CERT_UTIL_H_ |
| 6 #define NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_CERT_UTIL_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include "base/strings/string_piece.h" |
| 11 #include "third_party/boringssl/src/include/openssl/x509v3.h" |
| 12 |
| 13 namespace net { |
| 14 |
| 15 namespace transport_security_state { |
| 16 class SPKIHash; |
| 17 } // namespace transport_security_state |
| 18 |
| 19 } // namespace net |
| 20 |
| 21 // Decodes the PEM block in |pem_data| and attempts to parse the resulting |
| 22 // structure. Returns a pointer to a X509 instance if successful and NULL |
| 23 // otherwise. |
| 24 bssl::UniquePtr<X509> GetX509CertificateFromPEM(base::StringPiece pem_data); |
| 25 |
| 26 // Extracts the SubjectPublicKeyInfo from |*certificate| and copies its SHA256 |
| 27 // digest to |*out_hash|. Returns true on success and false on failure. |
| 28 bool CalculateSPKIHashFromCertificate( |
| 29 X509* certificate, |
| 30 net::transport_security_state::SPKIHash* out_hash); |
| 31 |
| 32 // Extracts the name from |*certificate| and copies the result to |*name|. |
| 33 // Returns true on success and false on failure. |
| 34 // On success |*name| will contain the Subject's CommonName if available or the |
| 35 // concatenation |OrganizationName| + " " + |OrganizationalUnitName| otherwise. |
| 36 bool ExtractSubjectNameFromCertificate(X509* certificate, std::string* name); |
| 37 |
| 38 // Decodes the PEM block in |pem_key| and sets |*out_hash| to the SHA256 digest |
| 39 // of the resulting structure. The encoded PEM block in |pem_key| is expected to |
| 40 // be a SubjectPublicKeyInfo structure. Returns true on success and false on |
| 41 // failure. |
| 42 bool CalculateSPKIHashFromKey( |
| 43 base::StringPiece pem_key, |
| 44 net::transport_security_state::SPKIHash* out_hash); |
| 45 |
| 46 #endif // NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_CERT_UTIL_H_ |
| OLD | NEW |