From 777d5897ba93840675df2beb8737b08c2a551036 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Mon, 23 Feb 2015 13:14:21 +0100 Subject: verifysct.py: Fetch fresh STH instead of using old --- tools/verifysct.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/verifysct.py b/tools/verifysct.py index 290d471..699a0ad 100755 --- a/tools/verifysct.py +++ b/tools/verifysct.py @@ -28,6 +28,8 @@ from multiprocessing import Pool baseurl = args.baseurl +sth = get_sth(baseurl) + def verifysct(sctentry): timing = timing_point() @@ -49,16 +51,19 @@ def verifysct(sctentry): leaf_hash = get_leaf_hash(merkle_tree_leaf) - proof = get_proof_by_hash(baseurl, leaf_hash, sctentry["sth"]["tree_size"]) + try: + proof = get_proof_by_hash(baseurl, leaf_hash, sth["tree_size"]) + except SystemExit: + return (None, None) #print proof leaf_index = proof["leaf_index"] inclusion_proof = [base64.b64decode(e) for e in proof["audit_path"]] - calc_root_hash = verify_inclusion_proof(inclusion_proof, leaf_index, sctentry["sth"]["tree_size"], leaf_hash) + calc_root_hash = verify_inclusion_proof(inclusion_proof, leaf_index, sth["tree_size"], leaf_hash) - root_hash = base64.b64decode(sctentry["sth"]["sha256_root_hash"]) + root_hash = base64.b64decode(sth["sha256_root_hash"]) if root_hash != calc_root_hash: print "sth" print base64.b16encode(root_hash) -- cgit v1.1