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

Side by Side 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: Addresses review comments from eranm Created 4 years, 6 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
« no previous file with comments | « net/cert/merkle_audit_proof.h ('k') | net/cert/merkle_audit_proof_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/cert/merkle_audit_proof.h"
6
7 #include "base/logging.h"
8
9 namespace net {
10 namespace ct {
11
12 uint64_t CalculateAuditPathLength(uint64_t leaf_index, uint64_t tree_size) {
13 // Algorithm taken from
14 // https://github.com/google/certificate-transparency-rfcs/blob/c8844de6bd0b5d 3d16bac79865e6edef533d760b/dns/draft-ct-over-dns.md#retrieve-merkle-audit-proof- from-log-by-leaf-hash.
Eran Messeri 2016/05/25 09:59:55 Nit: The ct-over-dns is what you may call a living
Rob Percival 2016/05/25 10:14:07 Done.
15 // RFC6962, section 2.1.1, describes audit paths.
16 DCHECK_LT(leaf_index, tree_size);
17 uint64_t length = 0;
18 uint64_t index = leaf_index;
19 uint64_t last_node = tree_size - 1;
20
21 while (last_node != 0) {
22 if ((index % 2 != 0) || index != last_node)
23 ++length;
24 index /= 2;
25 last_node /= 2;
26 }
27
28 return length;
29 }
30
31 MerkleAuditProof::MerkleAuditProof() {}
32
33 MerkleAuditProof::MerkleAuditProof(const std::string& log_id,
34 uint64_t leaf_index,
35 const std::vector<std::string>& audit_path)
36 : log_id(log_id), leaf_index(leaf_index), nodes(audit_path) {}
37
38 MerkleAuditProof::~MerkleAuditProof() {}
39
40 } // namespace ct
41 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/merkle_audit_proof.h ('k') | net/cert/merkle_audit_proof_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698