| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "net/cert/ct_signed_certificate_timestamp_log_param.h" | 5 #include "net/cert/ct_signed_certificate_timestamp_log_param.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // list is a dictionary created by SCTToDictionary. | 63 // list is a dictionary created by SCTToDictionary. |
| 64 std::unique_ptr<base::ListValue> SCTListToPrintableValues( | 64 std::unique_ptr<base::ListValue> SCTListToPrintableValues( |
| 65 const ct::SCTList& sct_list) { | 65 const ct::SCTList& sct_list) { |
| 66 std::unique_ptr<base::ListValue> output_scts(new base::ListValue()); | 66 std::unique_ptr<base::ListValue> output_scts(new base::ListValue()); |
| 67 for (const auto& sct : sct_list) | 67 for (const auto& sct : sct_list) |
| 68 output_scts->Append(SCTToDictionary(*(sct.get()))); | 68 output_scts->Append(SCTToDictionary(*(sct.get()))); |
| 69 | 69 |
| 70 return output_scts; | 70 return output_scts; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Given a list of SCTs and their status, return a ListValue instance where |
| 74 // each item in the list is a dictionary created by SCTToDictionary, only |
| 75 // if its status matches |match_status| |
| 76 std::unique_ptr<base::ListValue> SCTListAndStatusToPrintableValues( |
| 77 const ct::SCTAndStatusList& sct_status_list, |
| 78 ct::SCTVerifyStatus match_status) { |
| 79 std::unique_ptr<base::ListValue> output_scts(new base::ListValue()); |
| 80 for (const auto& sct_and_status : sct_status_list) |
| 81 if (sct_and_status.second == match_status) |
| 82 output_scts->Append(SCTToDictionary(*(sct_and_status.first.get()))); |
| 83 |
| 84 return output_scts; |
| 85 } |
| 86 |
| 73 } // namespace | 87 } // namespace |
| 74 | 88 |
| 75 std::unique_ptr<base::Value> NetLogSignedCertificateTimestampCallback( | 89 std::unique_ptr<base::Value> NetLogSignedCertificateTimestampCallback( |
| 76 const ct::CTVerifyResult* ct_result, | 90 const ct::CTVerifyResult* ct_result, |
| 77 NetLogCaptureMode capture_mode) { | 91 NetLogCaptureMode capture_mode) { |
| 78 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 92 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 79 | 93 |
| 80 dict->Set("verified_scts", | 94 dict->Set("verified_scts", |
| 81 SCTListToPrintableValues(ct_result->verified_scts)); | 95 SCTListToPrintableValues(ct_result->verified_scts)); |
| 82 | 96 |
| 83 dict->Set("invalid_scts", | 97 dict->Set("invalid_signature_scts", |
| 84 SCTListToPrintableValues(ct_result->invalid_scts)); | 98 SCTListAndStatusToPrintableValues( |
| 99 ct_result->invalid_scts, ct::SCT_STATUS_INVALID_SIGNATURE)); |
| 100 |
| 101 dict->Set("bad_timestamp_scts", |
| 102 SCTListAndStatusToPrintableValues( |
| 103 ct_result->invalid_scts, ct::SCT_STATUS_INVALID_TIMESTAMP)); |
| 85 | 104 |
| 86 dict->Set("unknown_logs_scts", | 105 dict->Set("unknown_logs_scts", |
| 87 SCTListToPrintableValues(ct_result->unknown_logs_scts)); | 106 SCTListToPrintableValues(ct_result->unknown_logs_scts)); |
| 88 | 107 |
| 89 return std::move(dict); | 108 return std::move(dict); |
| 90 } | 109 } |
| 91 | 110 |
| 92 std::unique_ptr<base::Value> NetLogRawSignedCertificateTimestampCallback( | 111 std::unique_ptr<base::Value> NetLogRawSignedCertificateTimestampCallback( |
| 93 const std::string* embedded_scts, | 112 const std::string* embedded_scts, |
| 94 const std::string* sct_list_from_ocsp, | 113 const std::string* sct_list_from_ocsp, |
| 95 const std::string* sct_list_from_tls_extension, | 114 const std::string* sct_list_from_tls_extension, |
| 96 NetLogCaptureMode capture_mode) { | 115 NetLogCaptureMode capture_mode) { |
| 97 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 116 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 98 | 117 |
| 99 SetBinaryData("embedded_scts", *embedded_scts, dict.get()); | 118 SetBinaryData("embedded_scts", *embedded_scts, dict.get()); |
| 100 SetBinaryData("scts_from_ocsp_response", *sct_list_from_ocsp, dict.get()); | 119 SetBinaryData("scts_from_ocsp_response", *sct_list_from_ocsp, dict.get()); |
| 101 SetBinaryData("scts_from_tls_extension", *sct_list_from_tls_extension, | 120 SetBinaryData("scts_from_tls_extension", *sct_list_from_tls_extension, |
| 102 dict.get()); | 121 dict.get()); |
| 103 | 122 |
| 104 return std::move(dict); | 123 return std::move(dict); |
| 105 } | 124 } |
| 106 | 125 |
| 107 } // namespace net | 126 } // namespace net |
| OLD | NEW |