diff options
author | eranm <eranm@chromium.org> | 2015-11-08 00:24:35 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-08 08:25:08 +0000 |
commit | 77d031bd849afcf9474255610649c71addaafe2f (patch) | |
tree | 37cd347ddfefad4b4092f3fe4f3ccd6dc3931048 /net/test | |
parent | 1a435e6ca60cb178370dd15c4268ff20c5ddfa93 (diff) | |
download | chromium_src-77d031bd849afcf9474255610649c71addaafe2f.zip chromium_src-77d031bd849afcf9474255610649c71addaafe2f.tar.gz chromium_src-77d031bd849afcf9474255610649c71addaafe2f.tar.bz2 |
Certificate Transparency: Parse consistency proof JSON
Adding the ability to parse a consistency proof between two Signed Tree
Heads, as defined in http://tools.ietf.org/html/rfc6962#section-4.4.
BUG=506227
Review URL: https://codereview.chromium.org/1429163004
Cr-Commit-Position: refs/heads/master@{#358549}
Diffstat (limited to 'net/test')
-rw-r--r-- | net/test/ct_test_util.cc | 17 | ||||
-rw-r--r-- | net/test/ct_test_util.h | 5 |
2 files changed, 22 insertions, 0 deletions
diff --git a/net/test/ct_test_util.cc b/net/test/ct_test_util.cc index 65a8122..3bd30ff 100644 --- a/net/test/ct_test_util.cc +++ b/net/test/ct_test_util.cc @@ -312,6 +312,23 @@ std::string CreateSignedTreeHeadJsonString(size_t tree_size, return sth_json; } +std::string CreateConsistencyProofJsonString( + const std::vector<std::string>& raw_nodes) { + std::string consistency_proof_json = std::string("{\"consistency\":["); + + for (auto it = raw_nodes.begin(); it != raw_nodes.end(); ++it) { + std::string proof_node_b64; + base::Base64Encode(*it, &proof_node_b64); + consistency_proof_json += + base::StringPrintf("\"%s\"", proof_node_b64.c_str()); + if (it + 1 != raw_nodes.end()) + consistency_proof_json += std::string(","); + } + consistency_proof_json += std::string("]}"); + + return consistency_proof_json; +} + } // namespace ct } // namespace net diff --git a/net/test/ct_test_util.h b/net/test/ct_test_util.h index 5701a28..5bb2d7a 100644 --- a/net/test/ct_test_util.h +++ b/net/test/ct_test_util.h @@ -6,6 +6,7 @@ #define NET_CERT_CT_TEST_UTIL_H_ #include <string> +#include <vector> #include "base/memory/ref_counted.h" @@ -86,6 +87,10 @@ std::string CreateSignedTreeHeadJsonString(size_t tree_size, std::string sha256_root_hash, std::string tree_head_signature); +// Assembles, and returns, a sample consistency proof in JSON format using +// the provided raw nodes (i.e. the raw nodes will be base64-encoded). +std::string CreateConsistencyProofJsonString( + const std::vector<std::string>& raw_nodes); } // namespace ct } // namespace net |