summaryrefslogtreecommitdiff
path: root/tools/josef_experimental_auditor.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/josef_experimental_auditor.py')
-rwxr-xr-xtools/josef_experimental_auditor.py26
1 files changed, 4 insertions, 22 deletions
diff --git a/tools/josef_experimental_auditor.py b/tools/josef_experimental_auditor.py
index 7efd2dc..e40e77e 100755
--- a/tools/josef_experimental_auditor.py
+++ b/tools/josef_experimental_auditor.py
@@ -6,6 +6,7 @@ import datetime
import base64
import argparse
import errno
+from copy import deepcopy
from certtools import *
NAGIOS_OK = 0
@@ -208,12 +209,9 @@ def check_domain(raw_entry, log=None):
def fetch_and_increment_subtree(old_sth, new_sth_in, subtree, base_url):
try:
- print "Initial hash:", hash(str(subtree))
sth = old_sth[base_url]
new_sth = new_sth_in[base_url]
idx = sth["tree_size"]
- tmp_tree = list(subtree)
- print "tmp hash:", hash(str(tmp_tree))
while idx < new_sth["tree_size"]:
pre_size = idx
@@ -227,18 +225,10 @@ def fetch_and_increment_subtree(old_sth, new_sth_in, subtree, base_url):
idx += len(new_leafs)
print time.strftime('%H:%M:%S') + " Got entries " + str(pre_size) + " to " \
+ str(idx -1) + " (" + str(len(new_leafs)) +" entries) from " + base_url
-
- print "Before reduction:", hash(str(tmp_tree))
- res_tree = reduce_tree(new_leafs, tmp_tree)
- print "After reduction:", hash(str(res_tree))
-
+ subtree = reduce_tree(new_leafs, subtree)
except:
print "Failed to build subtree :("
-
- if subtree == res_tree:
- print "Final subtree hash", hash(str(subtree))
- print "Final restree hash", hash(str(res_tree))
- return res_tree
+ return subtree
def fetch_and_build_subtree(old_sth, base_url):
try:
@@ -268,7 +258,7 @@ def fetch_and_build_subtree(old_sth, base_url):
def verify_subtree(old_sth, subtree, base_url):
try:
sth = old_sth[base_url]
- tmp = list(subtree)
+ tmp = deepcopy(subtree)
root = base64.b64encode(reduce_subtree_to_root(tmp)[0])
if root == sth["sha256_root_hash"]:
@@ -276,11 +266,8 @@ def verify_subtree(old_sth, subtree, base_url):
else:
print time.strftime('%H:%M:%S') + " ERROR: Failed to verify root hashes! STH root: " \
+ sth["sha256_root_hash"] + ", Tree root: " + root
- # errors.append(time.strftime('%H:%M:%S') + " ERROR: Failed to verify root hash for "
- # + base_url + ", tre size " + sth["tree_size"])
except:
print time.strftime('%H:%M:%S') + " ERROR: Failed to build STH for " + base_url
- # errors.append(time.strftime('%H:%M:%S') + " ERROR: Failed to build STH for " + base_url)
def verify_inclusion_by_hash(base_url, leaf_hash):
try:
@@ -456,13 +443,8 @@ def main(args):
new_sth = fetch_all_sth()
for url in base_urls:
if url in sth and url in new_sth and sth[url]["tree_size"] != new_sth[url]["tree_size"]:
- # print "Len before:", len(all_subtrees[url])
all_subtrees[url] = fetch_and_increment_subtree(sth, new_sth, all_subtrees[url], url)
- # print "Len between:", len(all_subtrees[url])
verify_subtree(new_sth, all_subtrees[url], url)
- # print "Len after:", len(all_subtrees[url])
- print "Old sth:", sth[url]["sha256_root_hash"]
- print "New sth:", new_sth[url]["sha256_root_hash"]
sth = new_sth