diff options
author | Magnus Ahltorp <map@kth.se> | 2015-03-18 01:03:18 +0100 |
---|---|---|
committer | Magnus Ahltorp <map@kth.se> | 2015-03-18 01:03:18 +0100 |
commit | d68d59cfabddaa31ec0b92a8afe451d088cdcbd0 (patch) | |
tree | c6f753dd46e05773110dbdcdaba5dd37e98d5701 /tools/certtools.py | |
parent | 4c72a1d2cecbb427a240e868277b7e039008c43e (diff) |
Added validatestore.py
Diffstat (limited to 'tools/certtools.py')
-rw-r--r-- | tools/certtools.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/certtools.py b/tools/certtools.py index c6f6ee6..cda0b68 100644 --- a/tools/certtools.py +++ b/tools/certtools.py @@ -289,6 +289,18 @@ def pack_mtl(timestamp, leafcert): merkle_tree_leaf = version + leaf_type + timestamped_entry return merkle_tree_leaf +def pack_mtl_precert(timestamp, cleanedcert, issuer_key_hash): + entry_type = struct.pack(">H", 1) + extensions = "" + assert len(issuer_key_hash) == 32 + + timestamped_entry = struct.pack(">Q", timestamp) + entry_type + \ + issuer_key_hash + tls_array(cleanedcert, 3) + tls_array(extensions, 2) + version = struct.pack(">b", 0) + leaf_type = struct.pack(">b", 0) + merkle_tree_leaf = version + leaf_type + timestamped_entry + return merkle_tree_leaf + def unpack_mtl(merkle_tree_leaf): version = merkle_tree_leaf[0:1] leaf_type = merkle_tree_leaf[1:2] @@ -375,6 +387,14 @@ def get_hash_from_certfile(cert): return base64.b16decode(line[len("Leafhash: "):]) return None +def get_timestamp_from_certfile(cert): + for line in cert.split("\n"): + if line.startswith("-----"): + return None + if line.startswith("Timestamp: "): + return int(line[len("Timestamp: "):]) + return None + def get_proof(store, tree_size, n): hash = get_hash_from_certfile(get_one_cert(store, n)) return get_proof_by_hash(args.baseurl, hash, tree_size) |