Chromium Code Reviews| Index: net/cert/ct_signed_certificate_timestamp_log_param.cc |
| diff --git a/net/cert/ct_signed_certificate_timestamp_log_param.cc b/net/cert/ct_signed_certificate_timestamp_log_param.cc |
| index 6d5b864a3b28923344f2480abae7f22b0f42c4f3..d3a2f09516b019b6a181c687117bd141303568c1 100644 |
| --- a/net/cert/ct_signed_certificate_timestamp_log_param.cc |
| +++ b/net/cert/ct_signed_certificate_timestamp_log_param.cc |
| @@ -13,6 +13,7 @@ |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/values.h" |
| +#include "net/cert/ct_sct_to_string.h" |
| #include "net/cert/ct_verify_result.h" |
| #include "net/cert/signed_certificate_timestamp.h" |
| @@ -20,62 +21,6 @@ namespace net { |
| namespace { |
| -// Converts a numeric |origin| to text describing the SCT's origin |
| -const char* OriginToString(ct::SignedCertificateTimestamp::Origin origin) { |
| - switch (origin) { |
| - case ct::SignedCertificateTimestamp::SCT_EMBEDDED: |
| - return "embedded_in_certificate"; |
| - case ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION: |
| - return "tls_extension"; |
| - case ct::SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE: |
| - return "ocsp"; |
| - case ct::SignedCertificateTimestamp::SCT_ORIGIN_MAX: |
| - break; |
| - } |
| - |
| - return "unknown"; |
| -} |
| - |
| -// Converts a numeric |hash_algorithm| to its textual representation |
| -const char* HashAlgorithmToString( |
| - ct::DigitallySigned::HashAlgorithm hash_algorithm) { |
| - switch (hash_algorithm) { |
| - case ct::DigitallySigned::HASH_ALGO_NONE: |
| - return "NONE"; |
| - case ct::DigitallySigned::HASH_ALGO_MD5: |
| - return "MD5"; |
| - case ct::DigitallySigned::HASH_ALGO_SHA1: |
| - return "SHA1"; |
| - case ct::DigitallySigned::HASH_ALGO_SHA224: |
| - return "SHA224"; |
| - case ct::DigitallySigned::HASH_ALGO_SHA256: |
| - return "SHA256"; |
| - case ct::DigitallySigned::HASH_ALGO_SHA384: |
| - return "SHA384"; |
| - case ct::DigitallySigned::HASH_ALGO_SHA512: |
| - return "SHA512"; |
| - } |
| - |
| - return "unknown"; |
| -} |
| - |
| -// Converts a numeric |signature_algorithm| to its textual representation |
| -const char* SignatureAlgorithmToString( |
| - ct::DigitallySigned::SignatureAlgorithm signature_algorithm) { |
| - switch (signature_algorithm) { |
| - case ct::DigitallySigned::SIG_ALGO_ANONYMOUS: |
| - return "ANONYMOUS"; |
| - case ct::DigitallySigned::SIG_ALGO_RSA: |
| - return "RSA"; |
| - case ct::DigitallySigned::SIG_ALGO_DSA: |
| - return "DSA"; |
| - case ct::DigitallySigned::SIG_ALGO_ECDSA: |
| - return "ECDSA"; |
| - } |
| - |
| - return "unknown"; |
| -} |
| - |
| // Base64 encode the given |value| string and put it in |dict| with the |
| // description |key|. |
| void SetBinaryData( |
| @@ -95,7 +40,14 @@ std::unique_ptr<base::DictionaryValue> SCTToDictionary( |
| const ct::SignedCertificateTimestamp& sct) { |
| std::unique_ptr<base::DictionaryValue> out(new base::DictionaryValue()); |
| - out->SetString("origin", OriginToString(sct.origin)); |
| + // Transform capital letters to lowercase, and replace spaces with underscores |
| + // to conform with SIGNED_CERTIFICATE_TIMESTAMPS_CHECKED in |
| + // net/log/net_log_event_type_list.h. |
| + std::string origin = OriginToString(sct.origin); |
| + std::transform(origin.begin(), origin.end(), origin.begin(), ::tolower); |
| + std::replace(origin.begin(), origin.end(), ' ', '_'); |
| + out->SetString("origin", origin); |
|
davidben
2016/06/14 15:47:37
I suppose this is fine, but you also may as well j
dwaxweiler
2016/06/14 16:57:02
At least one check of the tests in net/cert/multi_
davidben
2016/06/14 18:39:26
*shrug* I have a minor preference for updating the
|
| + |
| out->SetInteger("version", sct.version); |
| SetBinaryData("log_id", sct.log_id, out.get()); |