Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: net/cert/ct_signed_certificate_timestamp_log_param.cc

Issue 2604513002: Optimize CT & OCSP handling code (Closed)
Patch Set: Actually optimize for OCSP Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 9 #include <utility>
10 10
11 #include "base/base64.h" 11 #include "base/base64.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "net/cert/ct_sct_to_string.h" 14 #include "net/cert/ct_sct_to_string.h"
15 #include "net/cert/signed_certificate_timestamp.h" 15 #include "net/cert/signed_certificate_timestamp.h"
16 #include "net/log/net_log_capture_mode.h" 16 #include "net/log/net_log_capture_mode.h"
17 17
18 namespace net { 18 namespace net {
19 19
20 namespace { 20 namespace {
21 21
22 // Base64 encode the given |value| string and put it in |dict| with the 22 // Base64 encode the given |value| string and put it in |dict| with the
23 // description |key|. 23 // description |key|.
24 void SetBinaryData( 24 void SetBinaryData(const char* key,
25 const char* key, 25 base::StringPiece value,
26 const std::string& value, 26 base::DictionaryValue* dict) {
27 base::DictionaryValue* dict) {
28 std::string b64_value; 27 std::string b64_value;
29 base::Base64Encode(value, &b64_value); 28 base::Base64Encode(value, &b64_value);
30 29
31 dict->SetString(key, b64_value); 30 dict->SetString(key, b64_value);
32 } 31 }
33 32
34 // Returns a dictionary where each key is a field of the SCT and its value 33 // Returns a dictionary where each key is a field of the SCT and its value
35 // is this field's value in the SCT. This dictionary is meant to be used for 34 // is this field's value in the SCT. This dictionary is meant to be used for
36 // outputting a de-serialized SCT to the NetLog. 35 // outputting a de-serialized SCT to the NetLog.
37 std::unique_ptr<base::DictionaryValue> SCTToDictionary( 36 std::unique_ptr<base::DictionaryValue> SCTToDictionary(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 const SignedCertificateTimestampAndStatusList* scts, 76 const SignedCertificateTimestampAndStatusList* scts,
78 NetLogCaptureMode capture_mode) { 77 NetLogCaptureMode capture_mode) {
79 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 78 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
80 79
81 dict->Set("scts", SCTListToPrintableValues(*scts)); 80 dict->Set("scts", SCTListToPrintableValues(*scts));
82 81
83 return std::move(dict); 82 return std::move(dict);
84 } 83 }
85 84
86 std::unique_ptr<base::Value> NetLogRawSignedCertificateTimestampCallback( 85 std::unique_ptr<base::Value> NetLogRawSignedCertificateTimestampCallback(
87 const std::string* embedded_scts, 86 base::StringPiece embedded_scts,
88 const std::string* sct_list_from_ocsp, 87 base::StringPiece sct_list_from_ocsp,
89 const std::string* sct_list_from_tls_extension, 88 base::StringPiece sct_list_from_tls_extension,
90 NetLogCaptureMode capture_mode) { 89 NetLogCaptureMode capture_mode) {
91 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 90 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
92 91
93 SetBinaryData("embedded_scts", *embedded_scts, dict.get()); 92 SetBinaryData("embedded_scts", embedded_scts, dict.get());
94 SetBinaryData("scts_from_ocsp_response", *sct_list_from_ocsp, dict.get()); 93 SetBinaryData("scts_from_ocsp_response", sct_list_from_ocsp, dict.get());
95 SetBinaryData("scts_from_tls_extension", *sct_list_from_tls_extension, 94 SetBinaryData("scts_from_tls_extension", sct_list_from_tls_extension,
96 dict.get()); 95 dict.get());
97 96
98 return std::move(dict); 97 return std::move(dict);
99 } 98 }
100 99
101 } // namespace net 100 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698