summaryrefslogtreecommitdiff
path: root/tools/verifysecondary.py
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2015-04-23 23:24:11 +0200
committerLinus Nordberg <linus@nordberg.se>2015-04-23 23:24:11 +0200
commitcbb556663d8706138efb85a4e011c9fca349d33e (patch)
tree323328f3e5a01d3ccdc07a7921239ad8d0bcfbfe /tools/verifysecondary.py
parent5e93578d1f0f1908f70c0e77ed643e0b30cc3028 (diff)
parentf1630b6eb3dd525448aac8d722ccb9f8098e8593 (diff)
Merge branch 'mergesecondary'
Diffstat (limited to 'tools/verifysecondary.py')
-rwxr-xr-xtools/verifysecondary.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/verifysecondary.py b/tools/verifysecondary.py
new file mode 100755
index 0000000..9a36b32
--- /dev/null
+++ b/tools/verifysecondary.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2015, NORDUnet A/S.
+# See LICENSE for licensing information.
+
+import argparse
+import base64
+import sys
+import subprocess
+from certtools import build_merkle_tree
+from mergetools import *
+
+parser = argparse.ArgumentParser(description="")
+parser.add_argument('--mergedb', help="Merge database", required=True)
+parser.add_argument('--verifycert', help="Path to verifycert program", required=True)
+parser.add_argument('--knownroots', help="Path to knownroots directory", required=True)
+args = parser.parse_args()
+
+mergedb = args.mergedb
+chainsdir = mergedb + "/chains"
+logorderfile = mergedb + "/logorder"
+
+verifycert = subprocess.Popen([args.verifycert, args.knownroots],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+
+logorder = get_logorder(logorderfile)
+
+for hash in logorder:
+ entry = read_chain(chainsdir, hash)
+ verify_entry(verifycert, entry, hash)
+
+tree = build_merkle_tree(logorder)
+root_hash = tree[-1][0]
+
+print base64.b16encode(root_hash)