summaryrefslogtreecommitdiff
path: root/tools/certtools.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/certtools.py')
-rw-r--r--tools/certtools.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/certtools.py b/tools/certtools.py
index e1ca57a..f6c1cd9 100644
--- a/tools/certtools.py
+++ b/tools/certtools.py
@@ -138,6 +138,10 @@ def get_entries(baseurl, start, end):
print "ERROR:", e.read()
sys.exit(1)
+def extract_precertificate(precert_chain_entry):
+ (precert, certchain) = unpack_tls_array(precert_chain_entry, 3)
+ return (precert, certchain)
+
def decode_certificate_chain(packed_certchain):
(unpacked_certchain, rest) = unpack_tls_array(packed_certchain, 3)
assert len(rest) == 0
@@ -235,8 +239,13 @@ def unpack_mtl(merkle_tree_leaf):
leaf_type = merkle_tree_leaf[1:2]
timestamped_entry = merkle_tree_leaf[2:]
(timestamp, entry_type) = struct.unpack(">QH", timestamped_entry[0:10])
- (leafcert, rest_entry) = unpack_tls_array(timestamped_entry[10:], 3)
- return (leafcert, timestamp)
+ if entry_type == 0:
+ issuer_key_hash = None
+ (leafcert, rest_entry) = unpack_tls_array(timestamped_entry[10:], 3)
+ elif entry_type == 1:
+ issuer_key_hash = timestamped_entry[10:42]
+ (leafcert, rest_entry) = unpack_tls_array(timestamped_entry[42:], 3)
+ return (leafcert, timestamp, issuer_key_hash)
def get_leaf_hash(merkle_tree_leaf):
leaf_hash = hashlib.sha256()