diff options
author | Josef Gustafsson <josef.gson@gmail.com> | 2015-09-10 11:53:26 +0200 |
---|---|---|
committer | Josef Gustafsson <josef.gson@gmail.com> | 2015-09-10 11:53:26 +0200 |
commit | dbee1f90fc8e49c008bb9032c94eb8be6612c1de (patch) | |
tree | 6f313501ff4277ca5b02e3ea9a8fb04262254a51 /tools/josef_experimental.py | |
parent | f6ab7792f3ec3fa173f597c2219bc32f64e86783 (diff) |
adding experimental support for leveldb
Diffstat (limited to 'tools/josef_experimental.py')
-rwxr-xr-x | tools/josef_experimental.py | 179 |
1 files changed, 0 insertions, 179 deletions
diff --git a/tools/josef_experimental.py b/tools/josef_experimental.py deleted file mode 100755 index 7f27945..0000000 --- a/tools/josef_experimental.py +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -import time -import base64 -import urllib -import urllib2 -import sys -import subprocess - -# from pympler.asizeof import asizeof -from certtools import * -from Crypto.Signature import PKCS1_v1_5 - -def reduce_leafs_to_root(layer0): - if len(layer0) == 0: - return [[hashlib.sha256().digest()]] - current_layer = layer0 - while len(current_layer) > 1: - current_layer = next_merkle_layer(current_layer) - return current_layer - -def reduce_layer(layer): - new_layer = [] - while len(layer) > 1: - e1 = layer.pop(0) - e2 = layer.pop(0) - new_layer.append(internal_hash((e1,e2))) - return new_layer - -def reduce_tree(entries, layers): - if len(entries) == 0 and layers is []: - return [[hashlib.sha256().digest()]] - - layer_idx = 0 - layers[layer_idx] += entries - - while len(layers[layer_idx]) > 1: - if len(layers) == layer_idx + 1: - layers.append([]) - - layers[layer_idx + 1] += reduce_layer(layers[layer_idx]) - layer_idx += 1 - return layers - -def reduce_subtree_to_root(layers): - while len(layers) > 1: - layers[1] += next_merkle_layer(layers[0]) - del layers[0] - - if len(layers[0]) > 1: - return next_merkle_layer(layers[0]) - return layers[0] - -def get_proof_by_index(baseurl, index, tree_size): - try: - params = urllib.urlencode({"leaf_index":index, - "tree_size":tree_size}) - result = \ - urlopen(baseurl + "ct/v1/get-entry-and-proof?" + params).read() - return json.loads(result) - except urllib2.HTTPError, e: - print "ERROR:", e.read() - sys.exit(1) - -def my_get_cert_info(s): - p = subprocess.Popen( - ["openssl", "x509", "-fingerprint", "-text", "-noout", "-inform", "der"], - # ["openssl", "x509", "-noout", "-subject", "-issuer", "-inform", "der"], - stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - parsed = p.communicate(s) - if parsed[1]: - print "ERROR:", parsed[1] - sys.exit(1) - # result = [] - result = {} - prev = "" - for line in parsed[0].split("\n"): - if "Subject:" in line: - result["subject"] = line.split("Subject: ")[1] - # print line.split("Subject: ")[1] - if "Issuer:" in line: - result["issuer"] = line.split("Issuer: ")[1] - # print line.split("Issuer: ")[1] - if "Subject Alternative Name" in prev: - result["SAN"] = line.lstrip() - # print line.lstrip() - if "Not After" in line: - result["not_after"] = line.split(": ")[1] - if "Not Before" in line: - result["not_before"] = line.split(": ")[1] - prev = line - return result - -def read_sth(fn): - try: - f = open(fn) - except IOError, e: - if e.errno == errno.ENOENT: - return None - raise e - return json.loads(f.read()) - -base_urls = [ - "https://plausible.ct.nordu.net/", - # "https://ct1.digicert-ct.com/log/", - # "https://ct.izenpe.com/", - # "https://log.certly.io/", - # "https://ctlog.api.venafi.com/", - # "https://ct.googleapis.com/aviator/", - # "https://ct.googleapis.com/pilot/", - # "https://ct.googleapis.com/rocketeer/", - # "https://ct.ws.symantec.com/", - ] - -logkeys = {} -logkeys["https://plausible.ct.nordu.net/"] = get_public_key_from_file("../../plausible-logkey.pem") -logkeys["https://ct.googleapis.com/rocketeer/"] = get_public_key_from_file("../../rocketeer-logkey.pem") -logkeys["https://ct.googleapis.com/aviator/"] = get_public_key_from_file("../../aviator-logkey.pem") -logkeys["https://ct.googleapis.com/pilot/"] = get_public_key_from_file("../../pilot-logkey.pem") -logkeys["https://log.certly.io/"] = get_public_key_from_file("../../certly-logkey.pem") -logkeys["https://ct.izenpe.com/"] = get_public_key_from_file("../../izenpe-logkey.pem") -logkeys["https://ct1.digicert-ct.com/log/"] = get_public_key_from_file("../../digicert-logkey.pem") -logkeys["https://ctlog.api.venafi.com/"] = get_public_key_from_file("../../venafi-logkey.pem") - - -import Crypto.PublicKey.RSA as RSA -from Crypto.Hash import SHA256 - -monitored_domains = [ - "google.com", - "preishelden.de", - "liu.se", - "nordu.net", - "symantec.com", -] - -data = [] -# data = read_sth("cert_data.json") -f = open("cert_data.json") -for line in f: - data.append(json.loads(line)) -ss = [] -for item in data: - try: - s = item["subject"].split("CN=")[1] - print s - except: - # if not item["subject"] in ss: - # print item["subject"] - # ss.append(item["subject"]) - pass - -print "\nTotal entries: " + str(len(data)) - -# base_url = base_urls[0] - -# entries = get_entries(base_url, 11, 11)["entries"] -# for item in entries: -# orig_entry = extract_original_entry(item) -# cert_info = my_get_cert_info(orig_entry[0][0]) - # prev = "" - # res = {} - # for line in cert_info: - # if "Subject:" in line: - # res["subject"] = line.split("Subject: ")[1] - # # print line.split("Subject: ")[1] - # if "Issuer:" in line: - # res["issuer"] = line.split("Issuer: ")[1] - # # print line.split("Issuer: ")[1] - # if "Subject Alternative Name" in prev: - # res["SAN"] = line.lstrip() - # # print line.lstrip() - # if "Not After" in line: - # res["not_after"] = line.split(": ")[1] - - # prev = line - # print cert_info |