diff options
Diffstat (limited to 'tools/josef_auditor.py')
-rwxr-xr-x | tools/josef_auditor.py | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/tools/josef_auditor.py b/tools/josef_auditor.py index 4e60f3c..38c0ba6 100755 --- a/tools/josef_auditor.py +++ b/tools/josef_auditor.py @@ -4,7 +4,7 @@ import time import base64 import argparse -from pympler.asizeof import asizeof +# from pympler.asizeof import asizeof from certtools import * @@ -31,14 +31,6 @@ parser.add_argument('--audit', action='store_true', help="run lightweight audito parser.add_argument('--build-sth', action='store_true', help="get all entries and construct STH") -# def reduce_leafs_to_root(layer0): -# if len(layer0) == 0: -# return [[hashlib.sha256().digest()]] -# current_layer = layer0 -# while len(current_layer) > 1: -# current_layer = next_merkle_layer(current_layer) -# return current_layer - def reduce_layer(layer): new_layer = [] while len(layer) > 1: @@ -77,9 +69,10 @@ def fetch_all_sth(): sths = {} for base_url in base_urls: try: - sths[base_url] = get_sth(base_url) + sths[base_url] = get_sth(base_url) except: print "Failed to retrieve STH from " + base_url + sths[base_url] = None continue try: @@ -92,7 +85,7 @@ def fetch_all_sth(): def verify_consistency(old, new): for url in old: - # try: + if old[url] is not None: if old[url]["tree_size"]!= new[url]["tree_size"]: consistency_proof = get_consistency_proof(url, old[url]["tree_size"], new[url]["tree_size"] ) decoded_consistency_proof = [] @@ -109,8 +102,6 @@ def verify_consistency(old, new): else: print time.strftime("%H:%M:%S", time.gmtime()) + " New STH from " + url + ", timestamp: " + str(new[url]["timestamp"]) + ", size: " + str(new[url]["tree_size"]) + "...OK." - # except: - # print "ERROR: Could not verify consistency for " + url def fetch_and_build_tree(old_sth, base_url): @@ -127,7 +118,7 @@ def fetch_and_build_tree(old_sth, base_url): for item in entries: new_leafs.append(get_leaf_hash(base64.b64decode(item["leaf_input"]))) idx += len(new_leafs) - print "Got entries " + str(pre_size) + " to " + str(idx) + " (tree size: " + str(asizeof(subtree)) + " B)" + print "Got entries " + str(pre_size) + " to " + str(idx) #+ " (tree size: " + str(asizeof(subtree)) + " B)" subtree = reduce_tree(new_leafs, subtree) root = base64.b64encode(reduce_subtree_to_root(subtree)[0]) @@ -146,7 +137,9 @@ def main(args): if args.build_sth: print "Building trees from entries. This may take a while, go get coffee or something..." - fetch_and_build_tree(old_sth, base_urls[2]) + # for url in base_urls: + # fetch_and_build_tree(old_sth, url) + fetch_and_build_tree(old_sth, base_urls[0]) if args.audit: print "Running auditor for " +str(len(base_urls)) + " logs..." |