summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-02-23 13:14:21 +0100
committerMagnus Ahltorp <map@kth.se>2015-02-23 13:14:21 +0100
commitfad785c696ca5f85915e4fe68615bef21e908009 (patch)
treea3ba63fad29ee2a6e5513803e440db43ec873767
parent866d8e0614ad440eeb98d25152038f0dfd53c0fc (diff)
verifysct.py: Fetch fresh STH instead of using old
-rwxr-xr-xtools/verifysct.py11
1 files 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)