mirror of
https://github.com/certbot/certbot.git
synced 2026-01-26 07:41:33 +03:00
script to hash factorable moduli and store them in the blacklist
This commit is contained in:
24
server-ca/blacklisting/import-factorable-blacklist.py
Normal file
24
server-ca/blacklisting/import-factorable-blacklist.py
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user