summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-02-23 13:14:21 +0100
committerLinus Nordberg <linus@nordberg.se>2015-02-27 02:45:49 +0100
commit777d5897ba93840675df2beb8737b08c2a551036 (patch)
tree4523a59de481e104075c4ec94a9b3f7e63f256d4 /tools
parentf3042ca10909fa6d97e30d1226072e158cf04161 (diff)
verifysct.py: Fetch fresh STH instead of using old
Diffstat (limited to 'tools')
-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)