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

Unified Diff: net/cert/merkle_audit_proof.cc

Issue 2004843002: Adds a MerkleAuditProof struct to net/cert. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/cert/merkle_audit_proof.cc
diff --git a/net/cert/merkle_audit_proof.cc b/net/cert/merkle_audit_proof.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e206a46c79c987d2047342d77a75e588776c9a23
--- /dev/null
+++ b/net/cert/merkle_audit_proof.cc
@@ -0,0 +1,36 @@
+// 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/merkle_audit_proof.h"
+
+namespace net {
+namespace ct {
+
+uint64_t CalculateAuditPathLength(uint64_t leaf_index, uint64_t tree_size) {
+ // As described in RFC6962, section 4.5
Eran Messeri 2016/05/23 13:10:51 The length calculation is not described in this se
Rob Percival 2016/05/24 17:10:04 Fixed to point to the CT over DNS draft RFC.
+ uint64_t length = 0;
+ uint64_t ln = tree_size - 1;
Eran Messeri 2016/05/23 13:10:51 Can you think of more informative names to describ
Rob Percival 2016/05/24 17:10:04 Done.
+ uint64_t li = leaf_index;
+
+ while (ln != 0) {
+ if ((li & 1) || li < ln)
Eran Messeri 2016/05/23 13:10:51 (1) Better documentation (copy from the DNS I-D if
Rob Percival 2016/05/24 17:10:04 1. The DNS I-D doesn't really document this, it ju
+ ++length;
+ li >>= 1;
+ ln >>= 1;
+ }
+
+ return length;
+}
+
+MerkleAuditProof::MerkleAuditProof() {}
+
+MerkleAuditProof::MerkleAuditProof(const std::string& log_id,
+ uint64_t leaf_index,
+ const std::vector<std::string>& audit_path)
+ : log_id(log_id), leaf_index(leaf_index), nodes(audit_path) {}
+
+MerkleAuditProof::~MerkleAuditProof() {}
+
+} // namespace ct
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698