summaryrefslogtreecommitdiffstats
path: root/net/cert
diff options
context:
space:
mode:
authoreranm <eranm@chromium.org>2016-02-25 05:53:07 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-25 13:54:28 +0000
commit16a89247346d7538159bb1a47845fbdc74e2d8bf (patch)
treee421ddf22ee9cd40f72b67692ee4186a6820ab9d /net/cert
parentfc46cca44ad986d502116d4a248ed2b7011e18cd (diff)
downloadchromium_src-16a89247346d7538159bb1a47845fbdc74e2d8bf.zip
chromium_src-16a89247346d7538159bb1a47845fbdc74e2d8bf.tar.gz
chromium_src-16a89247346d7538159bb1a47845fbdc74e2d8bf.tar.bz2
Certificate Transparency: Add log ID to Signed Tree Head
A small change adding the Log ID to the SignedTreeHead class, so it is easier to identify which log it belongs to. Also added an ostream output operator for easier debugging. BUG=506227 Review URL: https://codereview.chromium.org/1731883002 Cr-Commit-Position: refs/heads/master@{#377566}
Diffstat (limited to 'net/cert')
-rw-r--r--net/cert/signed_tree_head.cc46
-rw-r--r--net/cert/signed_tree_head.h17
2 files changed, 63 insertions, 0 deletions
diff --git a/net/cert/signed_tree_head.cc b/net/cert/signed_tree_head.cc
new file mode 100644
index 0000000..ef1ab70
--- /dev/null
+++ b/net/cert/signed_tree_head.cc
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/cert/signed_tree_head.h"
+
+#include <string.h>
+
+#include "base/strings/string_number_conversions.h"
+
+namespace net {
+namespace ct {
+
+SignedTreeHead::SignedTreeHead() {}
+
+SignedTreeHead::SignedTreeHead(Version version,
+ const base::Time& timestamp,
+ uint64_t tree_size,
+ const char sha256_root_hash[kSthRootHashLength],
+ const DigitallySigned& signature,
+ const std::string& log_id)
+ : version(version),
+ timestamp(timestamp),
+ tree_size(tree_size),
+ signature(signature),
+ log_id(log_id) {
+ memcpy(this->sha256_root_hash, sha256_root_hash, kSthRootHashLength);
+}
+
+SignedTreeHead::~SignedTreeHead() {}
+
+std::ostream& operator<<(std::ostream& stream, const SignedTreeHead& sth) {
+ return stream << "{\n"
+ << "\t\"version\": " << sth.version << ",\n"
+ << "\t\"timestamp\": " << sth.timestamp << ",\n"
+ << "\t\"tree_size\": " << sth.tree_size << ",\n"
+ << "\t\"sha256_root_hash\": \""
+ << base::HexEncode(sth.sha256_root_hash, kSthRootHashLength)
+ << "\",\n\t\"log_id\": \""
+ << base::HexEncode(sth.log_id.data(), sth.log_id.size())
+ << "\"\n"
+ << "}";
+}
+
+} // namespace ct
+} // namespace net
diff --git a/net/cert/signed_tree_head.h b/net/cert/signed_tree_head.h
index 1613736..6ff93b0 100644
--- a/net/cert/signed_tree_head.h
+++ b/net/cert/signed_tree_head.h
@@ -7,6 +7,7 @@
#include <stdint.h>
+#include <iosfwd>
#include <string>
#include <vector>
@@ -28,13 +29,29 @@ struct NET_EXPORT SignedTreeHead {
// RFC6962-bis to use separate versions, so using a separate scheme here.
enum Version { V1 = 0, };
+ SignedTreeHead();
+ SignedTreeHead(Version version,
+ const base::Time& timestamp,
+ uint64_t tree_size,
+ const char sha256_root_hash[kSthRootHashLength],
+ const DigitallySigned& signature,
+ const std::string& log_id);
+ ~SignedTreeHead();
+
Version version;
base::Time timestamp;
uint64_t tree_size;
char sha256_root_hash[kSthRootHashLength];
DigitallySigned signature;
+
+ // Added in RFC6962-bis, Appendix A. Needed to identify which log
+ // this STH belongs to.
+ std::string log_id;
};
+NET_EXPORT std::ostream& operator<<(std::ostream& stream,
+ const SignedTreeHead& sth);
+
} // namespace ct
} // namespace net