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/test/ct_test_util.h" | 5 #include "net/test/ct_test_util.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
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/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "net/cert/ct_serialization.h" | 16 #include "net/cert/ct_serialization.h" |
17 #include "net/cert/ct_verify_result.h" | 17 #include "net/cert/signed_certificate_timestamp.h" |
18 #include "net/cert/signed_tree_head.h" | 18 #include "net/cert/signed_tree_head.h" |
19 #include "net/cert/x509_certificate.h" | 19 #include "net/cert/x509_certificate.h" |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 namespace ct { | 23 namespace ct { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 std::string HexToBytes(const char* hex_data) { | 27 std::string HexToBytes(const char* hex_data) { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 consistency_proof_json += | 322 consistency_proof_json += |
323 base::StringPrintf("\"%s\"", proof_node_b64.c_str()); | 323 base::StringPrintf("\"%s\"", proof_node_b64.c_str()); |
324 if (it + 1 != raw_nodes.end()) | 324 if (it + 1 != raw_nodes.end()) |
325 consistency_proof_json += std::string(","); | 325 consistency_proof_json += std::string(","); |
326 } | 326 } |
327 consistency_proof_json += std::string("]}"); | 327 consistency_proof_json += std::string("]}"); |
328 | 328 |
329 return consistency_proof_json; | 329 return consistency_proof_json; |
330 } | 330 } |
331 | 331 |
332 std::string GetSCTListForTesting() { | |
333 const std::string sct = ct::GetTestSignedCertificateTimestamp(); | |
334 std::string sct_list; | |
335 ct::EncodeSCTListForTesting(sct, &sct_list); | |
336 return sct_list; | |
337 } | |
338 | |
339 std::string GetSCTListWithInvalidSCT() { | |
340 std::string sct(ct::GetTestSignedCertificateTimestamp()); | |
341 | |
342 // Change a byte inside the Log ID part of the SCT so it does not match the | |
343 // log used in the tests. | |
344 sct[15] = 't'; | |
345 | |
346 std::string sct_list; | |
347 ct::EncodeSCTListForTesting(sct, &sct_list); | |
348 return sct_list; | |
349 } | |
350 | |
351 bool CheckForSingleVerifiedSCTInResult(const ct::CTVerifyResult& result, | |
352 const std::string& log_description) { | |
353 return (result.verified_scts.size() == 1U) && result.invalid_scts.empty() && | |
354 result.unknown_logs_scts.empty() && | |
355 result.verified_scts[0]->log_description == log_description; | |
356 } | |
357 | |
358 bool CheckForSCTOrigin(const ct::CTVerifyResult& result, | |
359 ct::SignedCertificateTimestamp::Origin origin) { | |
360 return (result.verified_scts.size() > 0) && | |
361 (result.verified_scts[0]->origin == origin); | |
362 } | |
363 | |
364 } // namespace ct | 332 } // namespace ct |
365 | 333 |
366 } // namespace net | 334 } // namespace net |
OLD | NEW |