summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-03-08 00:03:36 +0100
committerMagnus Ahltorp <map@kth.se>2015-03-08 00:03:36 +0100
commit8a7bcb91f440502b24d92842e0c89f2fcdf90c04 (patch)
tree5eadbcf94f2363fe6efb401b319578e3a4a36af4 /tools
parente0f11a58033d52c70bc76b4b5611cb88485d4653 (diff)
merge.py: Store certs in hashed directory structure
Diffstat (limited to 'tools')
-rwxr-xr-xtools/merge.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/merge.py b/tools/merge.py
index c137f4b..1b94581 100755
--- a/tools/merge.py
+++ b/tools/merge.py
@@ -14,6 +14,7 @@ import time
import ecdsa
import hashlib
import urlparse
+import os
from certtools import build_merkle_tree, create_sth_signature, check_sth_signature, get_eckey_from_file, timing_point, http_request
parser = argparse.ArgumentParser(description="")
@@ -36,6 +37,8 @@ logorderfile = args.mergedb + "/logorder"
own_key = (args.own_keyname, args.own_keyfile)
+hashed_dir = True
+
def parselogrow(row):
return base64.b16decode(row)
@@ -44,12 +47,26 @@ def get_logorder():
return [parselogrow(row.rstrip()) for row in f]
def write_chain(key, value):
- f = open(chainsdir + "/" + base64.b16encode(key), "w")
+ filename = base64.b16encode(key)
+ if hashed_dir:
+ path = chainsdir + "/" + filename[0:2] + "/" + filename[2:4] + "/" + filename[4:6]
+ try:
+ os.makedirs(path)
+ except Exception, e:
+ print e
+ else:
+ path = chainsdir
+ f = open(path + "/" + filename, "w")
f.write(value)
f.close()
def read_chain(key):
- f = open(chainsdir + "/" + base64.b16encode(key), "r")
+ filename = base64.b16encode(key)
+ path = chainsdir + "/" + filename[0:2] + "/" + filename[2:4] + "/" + filename[4:6]
+ try:
+ f = open(path + "/" + filename, "r")
+ except IOError, e:
+ f = open(chainsdir + "/" + filename, "r")
value = f.read()
f.close()
return value