| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_COMMON_NET_X509_CERTIFICATE_MODEL_H_ | 5 #ifndef CHROME_COMMON_NET_X509_CERTIFICATE_MODEL_H_ |
| 6 #define CHROME_COMMON_NET_X509_CERTIFICATE_MODEL_H_ | 6 #define CHROME_COMMON_NET_X509_CERTIFICATE_MODEL_H_ |
| 7 | 7 |
| 8 #include "net/cert/cert_type.h" | 8 #include "net/cert/cert_type.h" |
| 9 #include "net/cert/x509_certificate.h" | 9 #include "net/cert/x509_certificate.h" |
| 10 | 10 |
| 11 // This namespace defines a set of functions to be used in UI-related bits of | 11 // This namespace defines a set of functions to be used in UI-related bits of |
| 12 // X509 certificates. It decouples the UI from the underlying crypto library | 12 // X509 certificates. It decouples the UI from the underlying crypto library |
| 13 // (currently NSS or OpenSSL - in development). | 13 // (currently NSS or OpenSSL - in development). |
| 14 // This is currently only used by linux, as mac / windows use their own native | 14 // This is currently only used by linux, as mac / windows use their own native |
| 15 // certificate viewers and crypto libraries. | 15 // certificate viewers and crypto libraries. |
| 16 namespace x509_certificate_model { | 16 namespace x509_certificate_model { |
| 17 | 17 |
| 18 std::string GetCertNameOrNickname( | 18 std::string GetCertNameOrNickname( |
| 19 net::X509Certificate::OSCertHandle cert_handle); | 19 net::X509Certificate::OSCertHandle cert_handle); |
| 20 | 20 |
| 21 std::string GetNickname(net::X509Certificate::OSCertHandle cert_handle); | |
| 22 | |
| 23 std::string GetTokenName(net::X509Certificate::OSCertHandle cert_handle); | 21 std::string GetTokenName(net::X509Certificate::OSCertHandle cert_handle); |
| 24 | 22 |
| 25 std::string GetVersion(net::X509Certificate::OSCertHandle cert_handle); | 23 std::string GetVersion(net::X509Certificate::OSCertHandle cert_handle); |
| 26 | 24 |
| 27 net::CertType GetType(net::X509Certificate::OSCertHandle cert_handle); | 25 net::CertType GetType(net::X509Certificate::OSCertHandle cert_handle); |
| 28 | 26 |
| 29 std::string GetEmailAddress(net::X509Certificate::OSCertHandle cert_handle); | |
| 30 | |
| 31 void GetUsageStrings( | 27 void GetUsageStrings( |
| 32 net::X509Certificate::OSCertHandle cert_handle, | 28 net::X509Certificate::OSCertHandle cert_handle, |
| 33 std::vector<std::string>* usages); | 29 std::vector<std::string>* usages); |
| 34 | 30 |
| 35 std::string GetKeyUsageString(net::X509Certificate::OSCertHandle cert_handle); | |
| 36 | |
| 37 std::string GetSerialNumberHexified( | 31 std::string GetSerialNumberHexified( |
| 38 net::X509Certificate::OSCertHandle cert_handle, | 32 net::X509Certificate::OSCertHandle cert_handle, |
| 39 const std::string& alternative_text); | 33 const std::string& alternative_text); |
| 40 | 34 |
| 41 std::string GetIssuerCommonName( | 35 std::string GetIssuerCommonName( |
| 42 net::X509Certificate::OSCertHandle cert_handle, | 36 net::X509Certificate::OSCertHandle cert_handle, |
| 43 const std::string& alternative_text); | 37 const std::string& alternative_text); |
| 44 | 38 |
| 45 std::string GetIssuerOrgName( | 39 std::string GetIssuerOrgName( |
| 46 net::X509Certificate::OSCertHandle cert_handle, | 40 net::X509Certificate::OSCertHandle cert_handle, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 62 net::X509Certificate::OSCertHandle cert_handle, | 56 net::X509Certificate::OSCertHandle cert_handle, |
| 63 const std::string& alternative_text); | 57 const std::string& alternative_text); |
| 64 | 58 |
| 65 bool GetTimes(net::X509Certificate::OSCertHandle cert_handle, | 59 bool GetTimes(net::X509Certificate::OSCertHandle cert_handle, |
| 66 base::Time* issued, base::Time* expires); | 60 base::Time* issued, base::Time* expires); |
| 67 | 61 |
| 68 std::string GetTitle(net::X509Certificate::OSCertHandle cert_handle); | 62 std::string GetTitle(net::X509Certificate::OSCertHandle cert_handle); |
| 69 std::string GetIssuerName(net::X509Certificate::OSCertHandle cert_handle); | 63 std::string GetIssuerName(net::X509Certificate::OSCertHandle cert_handle); |
| 70 std::string GetSubjectName(net::X509Certificate::OSCertHandle cert_handle); | 64 std::string GetSubjectName(net::X509Certificate::OSCertHandle cert_handle); |
| 71 | 65 |
| 72 void GetEmailAddresses(net::X509Certificate::OSCertHandle cert_handle, | |
| 73 std::vector<std::string>* email_addresses); | |
| 74 | |
| 75 void GetNicknameStringsFromCertList(const net::CertificateList& certs, | |
| 76 const std::string& cert_expired, | |
| 77 const std::string& cert_not_yet_valid, | |
| 78 std::vector<std::string>* nick_names); | |
| 79 | |
| 80 struct Extension { | 66 struct Extension { |
| 81 std::string name; | 67 std::string name; |
| 82 std::string value; | 68 std::string value; |
| 83 }; | 69 }; |
| 84 | 70 |
| 85 typedef std::vector<Extension> Extensions; | 71 typedef std::vector<Extension> Extensions; |
| 86 | 72 |
| 87 void GetExtensions( | 73 void GetExtensions( |
| 88 const std::string& critical_label, | 74 const std::string& critical_label, |
| 89 const std::string& non_critical_label, | 75 const std::string& non_critical_label, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 114 net::X509Certificate::OSCertHandle cert_handle); | 100 net::X509Certificate::OSCertHandle cert_handle); |
| 115 std::string ProcessSecAlgorithmSignatureWrap( | 101 std::string ProcessSecAlgorithmSignatureWrap( |
| 116 net::X509Certificate::OSCertHandle cert_handle); | 102 net::X509Certificate::OSCertHandle cert_handle); |
| 117 | 103 |
| 118 std::string ProcessSubjectPublicKeyInfo( | 104 std::string ProcessSubjectPublicKeyInfo( |
| 119 net::X509Certificate::OSCertHandle cert_handle); | 105 net::X509Certificate::OSCertHandle cert_handle); |
| 120 | 106 |
| 121 std::string ProcessRawBitsSignatureWrap( | 107 std::string ProcessRawBitsSignatureWrap( |
| 122 net::X509Certificate::OSCertHandle cert_handle); | 108 net::X509Certificate::OSCertHandle cert_handle); |
| 123 | 109 |
| 124 void RegisterDynamicOids(); | |
| 125 | |
| 126 // Format a buffer as |hex_separator| separated string, with 16 bytes on each | 110 // Format a buffer as |hex_separator| separated string, with 16 bytes on each |
| 127 // line separated using |line_separator|. | 111 // line separated using |line_separator|. |
| 128 std::string ProcessRawBytesWithSeparators(const unsigned char* data, | 112 std::string ProcessRawBytesWithSeparators(const unsigned char* data, |
| 129 size_t data_length, | 113 size_t data_length, |
| 130 char hex_separator, | 114 char hex_separator, |
| 131 char line_separator); | 115 char line_separator); |
| 132 | 116 |
| 133 // Format a buffer as a space separated string, with 16 bytes on each line. | 117 // Format a buffer as a space separated string, with 16 bytes on each line. |
| 134 std::string ProcessRawBytes(const unsigned char* data, | 118 std::string ProcessRawBytes(const unsigned char* data, |
| 135 size_t data_length); | 119 size_t data_length); |
| 136 | 120 |
| 137 #if defined(USE_NSS) | 121 #if defined(USE_NSS) |
| 138 // Format a buffer as a space separated string, with 16 bytes on each line. | 122 // Format a buffer as a space separated string, with 16 bytes on each line. |
| 139 // |data_length| is the length in bits. | 123 // |data_length| is the length in bits. |
| 140 std::string ProcessRawBits(const unsigned char* data, | 124 std::string ProcessRawBits(const unsigned char* data, |
| 141 size_t data_length); | 125 size_t data_length); |
| 142 #endif // USE_NSS | 126 #endif // USE_NSS |
| 143 | 127 |
| 144 } // namespace x509_certificate_model | 128 } // namespace x509_certificate_model |
| 145 | 129 |
| 146 #endif // CHROME_COMMON_NET_X509_CERTIFICATE_MODEL_H_ | 130 #endif // CHROME_COMMON_NET_X509_CERTIFICATE_MODEL_H_ |
| OLD | NEW |