summaryrefslogtreecommitdiffstats
path: root/chrome/common/net/x509_certificate_model.h
diff options
context:
space:
mode:
authorbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-08 12:44:40 +0000
committerbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-08 12:44:40 +0000
commitb1c2a554239ab3be950f0d19581945eb115e7a6c (patch)
tree5688a12bb881cd14c5ed80d0ccbdf2208248f45c /chrome/common/net/x509_certificate_model.h
parent2a73485bfae7e697df34e6640b1593ccafe2cf53 (diff)
downloadchromium_src-b1c2a554239ab3be950f0d19581945eb115e7a6c.zip
chromium_src-b1c2a554239ab3be950f0d19581945eb115e7a6c.tar.gz
chromium_src-b1c2a554239ab3be950f0d19581945eb115e7a6c.tar.bz2
Decouples certificates viewers from NSS to prepare support for OpenSSL.
This change is a pre-requisite for http://codereview.chromium.org/3529008/show There are no functional changes, it's only refactoring existing code. BUG=None TEST=Go to an https:// page and check the certificate info. Review URL: http://codereview.chromium.org/3565006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61944 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/net/x509_certificate_model.h')
-rw-r--r--chrome/common/net/x509_certificate_model.h128
1 files changed, 128 insertions, 0 deletions
diff --git a/chrome/common/net/x509_certificate_model.h b/chrome/common/net/x509_certificate_model.h
new file mode 100644
index 0000000..351f489
--- /dev/null
+++ b/chrome/common/net/x509_certificate_model.h
@@ -0,0 +1,128 @@
+// Copyright (c) 2010 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_BASE_X509_CERTIFICATE_MODEL_H_
+#define NET_BASE_X509_CERTIFICATE_MODEL_H_
+#pragma once
+
+#include "net/base/cert_database.h"
+#include "net/base/cert_type.h"
+#include "net/base/x509_certificate.h"
+
+// This namespace defines a set of functions to be used in UI-related bits of
+// X509 certificates. It decouples the UI from the underlying crypto library
+// (currently NSS or OpenSSL - in development).
+// This is currently only used by linux, as mac / windows use their own native
+// certificate viewers and crypto libraries.
+namespace x509_certificate_model {
+
+std::string GetCertNameOrNickname(
+ net::X509Certificate::OSCertHandle cert_handle);
+
+std::string GetTokenName(net::X509Certificate::OSCertHandle cert_handle);
+
+std::string GetVersion(net::X509Certificate::OSCertHandle cert_handle);
+
+net::CertType GetType(net::X509Certificate::OSCertHandle cert_handle);
+
+std::string GetEmailAddress(net::X509Certificate::OSCertHandle cert_handle);
+
+void GetUsageStrings(
+ net::X509Certificate::OSCertHandle cert_handle,
+ std::vector<std::string>* usages);
+
+std::string GetKeyUsageString(net::X509Certificate::OSCertHandle cert_handle);
+
+std::string GetSerialNumberHexified(
+ net::X509Certificate::OSCertHandle cert_handle,
+ const std::string& alternative_text);
+
+std::string GetIssuerCommonName(
+ net::X509Certificate::OSCertHandle cert_handle,
+ const std::string& alternative_text);
+
+std::string GetIssuerOrgName(
+ net::X509Certificate::OSCertHandle cert_handle,
+ const std::string& alternative_text);
+
+std::string GetIssuerOrgUnitName(
+ net::X509Certificate::OSCertHandle cert_handle,
+ const std::string& alternative_text);
+
+std::string GetSubjectOrgName(
+ net::X509Certificate::OSCertHandle cert_handle,
+ const std::string& alternative_text);
+
+std::string GetSubjectOrgUnitName(
+ net::X509Certificate::OSCertHandle cert_handle,
+ const std::string& alternative_text);
+
+std::string GetSubjectCommonName(
+ net::X509Certificate::OSCertHandle cert_handle,
+ const std::string& alternative_text);
+
+bool GetTimes(net::X509Certificate::OSCertHandle cert_handle,
+ base::Time* issued, base::Time* expires);
+
+std::string GetTitle(net::X509Certificate::OSCertHandle cert_handle);
+std::string GetIssuerName(net::X509Certificate::OSCertHandle cert_handle);
+std::string GetSubjectName(net::X509Certificate::OSCertHandle cert_handle);
+
+void GetEmailAddresses(net::X509Certificate::OSCertHandle cert_handle,
+ std::vector<std::string>* email_addresses);
+
+void GetNicknameStringsFromCertList(const net::CertificateList& certs,
+ const std::string& cert_expired,
+ const std::string& cert_not_yet_valid,
+ std::vector<std::string>* nick_names);
+
+struct Extension {
+ std::string name;
+ std::string value;
+};
+
+typedef std::vector<Extension> Extensions;
+
+void GetExtensions(
+ const std::string& critical_label,
+ const std::string& non_critical_label,
+ net::X509Certificate::OSCertHandle cert_handle,
+ Extensions* extensions);
+
+// Hash a certificate using the given algorithm, return the result as a
+// colon-seperated hex string.
+std::string HashCertSHA256(net::X509Certificate::OSCertHandle cert_handle);
+std::string HashCertSHA1(net::X509Certificate::OSCertHandle cert_handle);
+
+// For host values, if they contain IDN Punycode-encoded A-labels, this will
+// return a string suitable for display that contains both the original and the
+// decoded U-label form. Otherwise, the string will be returned as is.
+std::string ProcessIDN(const std::string& input);
+
+void GetCertChainFromCert(net::X509Certificate::OSCertHandle cert_handle,
+ net::X509Certificate::OSCertHandles* cert_handles);
+void DestroyCertChain(net::X509Certificate::OSCertHandles* cert_handles);
+
+std::string GetDerString(net::X509Certificate::OSCertHandle cert_handle);
+std::string GetCMSString(const net::X509Certificate::OSCertHandles& cert_chain,
+ size_t start, size_t end);
+
+std::string ProcessSecAlgorithmSignature(
+ net::X509Certificate::OSCertHandle cert_handle);
+std::string ProcessSecAlgorithmSubjectPublicKey(
+ net::X509Certificate::OSCertHandle cert_handle);
+std::string ProcessSecAlgorithmSignatureWrap(
+ net::X509Certificate::OSCertHandle cert_handle);
+
+std::string ProcessSubjectPublicKeyInfo(
+ net::X509Certificate::OSCertHandle cert_handle);
+
+std::string ProcessRawBitsSignatureWrap(
+ net::X509Certificate::OSCertHandle cert_handle);
+
+void RegisterDynamicOids();
+
+} // namespace x509_certificate_model
+
+#endif // NET_BASE_X509_CERTIFICATE_MODEL_H_