From 5c51876fc45efafe4b9d918553c7b32a854ed8ed Mon Sep 17 00:00:00 2001 From: "bulach@chromium.org" Date: Mon, 25 Oct 2010 12:59:54 +0000 Subject: More UI-related OpenSSL support. Refactors a few functions from nsNSSCertHelper into common. (no functional change when using NSS). Implements some of the x509_certificate_model functions for OpenSSL. BUG=none TEST=Compile w/ use_openssl=1, check that the fields in certificate viewer are displayed. Review URL: http://codereview.chromium.org/3815012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63723 0039d316-1c4b-4281-b951-d872f2087c98 --- .../mozilla_security_manager/nsNSSCertHelper.cpp | 36 +++++----------------- .../mozilla_security_manager/nsNSSCertHelper.h | 6 ---- 2 files changed, 7 insertions(+), 35 deletions(-) (limited to 'chrome/third_party') diff --git a/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.cpp b/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.cpp index 6fceac8..6e8b54d 100644 --- a/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.cpp +++ b/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.cpp @@ -88,6 +88,11 @@ SECOidTag RegisterDynamicOid(const char* oid_string) { return rv; } +// Format a SECItem as a space separated string, with 16 bytes on each line. +std::string ProcessRawBytes(SECItem* data) { + return x509_certificate_model::ProcessRawBytes(data->data, data->len); +} + } // namespace namespace mozilla_security_manager { @@ -141,34 +146,6 @@ void RegisterDynamicOids() { "2.16.840.1.113730.4.1"); } -std::string ProcessRawBytes(SECItem* data) { - static const char kHexChars[] = "0123456789ABCDEF"; - - // Each input byte creates two output hex characters + a space or newline, - // except for the last byte. - std::string ret(std::max(0u, data->len * 3 - 1), '\0'); - - for (size_t i = 0; i < data->len; ++i) { - unsigned char b = data->data[i]; - ret[i * 3] = kHexChars[(b >> 4) & 0xf]; - ret[i * 3 + 1] = kHexChars[b & 0xf]; - if (i + 1 < data->len) { - if ((i + 1) % 16 == 0) - ret[i * 3 + 2] = '\n'; - else - ret[i * 3 + 2] = ' '; - } - } - return ret; -} - -std::string ProcessRawBits(SECItem* data) { - SECItem bytedata; - bytedata.data = data->data; - bytedata.len = data->len / 8; - return ProcessRawBytes(&bytedata); -} - std::string DumpOidString(SECItem* oid) { char* pr_string = CERT_GetOidString(oid); if (pr_string) { @@ -1045,7 +1022,8 @@ std::string ProcessSubjectPublicKeyInfo(CERTSubjectPublicKeyInfo* spki) { break; } default: - rv = ProcessRawBits(&spki->subjectPublicKey); + rv = x509_certificate_model::ProcessRawBits( + spki->subjectPublicKey.data, spki->subjectPublicKey.len); break; } SECKEY_DestroyPublicKey(key); diff --git a/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h b/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h index 0022a5da..2c4253c 100644 --- a/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h +++ b/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h @@ -65,12 +65,6 @@ extern SECOidTag ms_ntds_replication; void RegisterDynamicOids(); -// Format a SECItem as a space separated string, with 16 bytes on each line. -std::string ProcessRawBytes(SECItem* data); - -// For fields which have the length specified in bits, rather than bytes. -std::string ProcessRawBits(SECItem* data); - std::string DumpOidString(SECItem* oid); std::string GetOIDText(SECItem* oid); -- cgit v1.1