Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Unified Diff: net/tools/domain_security_preload_generator/cert_util.h

Issue 2551153003: Add static domain security state generator tool. (Closed)
Patch Set: Fix iOS? Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/tools/domain_security_preload_generator/cert_util.h
diff --git a/net/tools/domain_security_preload_generator/cert_util.h b/net/tools/domain_security_preload_generator/cert_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..6d0a3f4f579e76c3a0387e42d15428b3b60c9ea8
--- /dev/null
+++ b/net/tools/domain_security_preload_generator/cert_util.h
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_CERT_UTIL_H_
+#define NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_CERT_UTIL_H_
+
+#include <stdint.h>
+
+#include "base/strings/string_piece.h"
+#include "third_party/boringssl/src/include/openssl/x509v3.h"
+
+namespace net {
+
+namespace transport_security_state {
+class SPKIHash;
+} // namespace transport_security_state
+
+} // namespace net
+
+// Decodes the PEM block in |pem_data| and attempts to parse the resulting
+// structure. Returns a pointer to a X509 instance if successful and NULL
+// otherwise.
+bssl::UniquePtr<X509> GetX509CertificateFromPEM(base::StringPiece pem_data);
+
+// Extracts the SubjectPublicKeyInfo from |*certificate| and copies its SHA256
+// digest to |*out_hash|. Returns true on success and false on failure.
+bool CalculateSPKIHashFromCertificate(
+ X509* certificate,
+ net::transport_security_state::SPKIHash* out_hash);
+
+// Extracts the name from |*certificate| and copies the result to |*name|.
+// Returns true on success and false on failure.
+// On success |*name| will contain the Subject's CommonName if available or the
+// concatenation |OrganizationName| + " " + |OrganizationalUnitName| otherwise.
+bool ExtractSubjectNameFromCertificate(X509* certificate, std::string* name);
+
+// Decodes the PEM block in |pem_key| and sets |*out_hash| to the SHA256 digest
+// of the resulting structure. The encoded PEM block in |pem_key| is expected to
+// be a SubjectPublicKeyInfo structure. Returns true on success and false on
+// failure.
+bool CalculateSPKIHashFromKey(
+ base::StringPiece pem_key,
+ net::transport_security_state::SPKIHash* out_hash);
+
+#endif // NET_TOOLS_DOMAIN_SECURITY_PRELOAD_GENERATOR_CERT_UTIL_H_
« no previous file with comments | « net/tools/domain_security_preload_generator/bit_writer.cc ('k') | net/tools/domain_security_preload_generator/cert_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698