From 985652be878b2ab55e5ce0140076dfc02a6b9db2 Mon Sep 17 00:00:00 2001 From: Seth Schoen Date: Mon, 20 Aug 2012 15:40:54 -0700 Subject: [PATCH] script to hash factorable moduli and store them in the blacklist --- .../import-factorable-blacklist.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 server-ca/blacklisting/import-factorable-blacklist.py diff --git a/server-ca/blacklisting/import-factorable-blacklist.py b/server-ca/blacklisting/import-factorable-blacklist.py new file mode 100644 index 000000000..6b87310c1 --- /dev/null +++ b/server-ca/blacklisting/import-factorable-blacklist.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +# This imports the factorable moduli blacklist file into the +# Redis set "factorable_moduli". Specify one or more files on the +# command line to import them. + +# E.g., +# python import-openssl-blacklist.py factorable_moduli.txt +# will import everything. This assumes that the input moduli are +# already hexadecimal. This script converts the moduli into the Debian +# blacklist format before inserting them into Redis. + +import sys, redis, hashlib + +r = redis.Redis() + +for f in sys.argv[1:]: + for line in list(open(f)): + m = line.upper().strip() + m2 = m.lstrip("0") # version without leading zeroes + h1 = hashlib.sha1("Modulus=%s\n" % m).hexdigest()[20:] + h2 = hashlib.sha1("Modulus=%s\n" % m2).hexdigest()[20:] + r.sadd("factorable_moduli", h1) + r.sadd("factorable_moduli", h2)