You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
3.0 KiB

#!/usr/bin/env python
I started writing this, and then quickly realized it would take a really long
to actually download the whole strong set this way. Then I began searching for
how to sync from key servers, which lead me to regular static key server dumps: - Generated every Wednesday - Generated every Monday - Generated every Friday (anonymous) - Generated every Friday - Generated every Sunday
Right now this script is in a semi-broken state, but I decided to leave it
here anyway.
import sys, time, subprocess
cwd = sys.path[0]
import gnupg
class TrollWoT_DownloadWoT:
def __init__(self, gpg, keyserver = ''):
self.gpg = gpg
self.keyserver = keyserver
self.imported_keyids = []
keys = self.gpg.list_keys()
fingerprints = []
for key in keys:
print 'already have {0} keys in keyring'.format(len(self.imported_keyids))
def download(self, keyids):
keyids_to_recv = []
for keyid in keyids:
if keyid not in self.imported_keyids:
print '* downloading {0} keyids: {1}'.format(len(keyids_to_recv), keyids_to_recv)
res = self.gpg.recv_keys(self.keyserver, ''.join(keyids_to_recv))
sig_keyids = self.list_sigs(res.fingerprints)
if len(sig_keyids) > 0:
def add_keyids(self, fingerprints):
for fp in fingerprints:
keyid = fp[-16:]
if keyid not in self.imported_keyids:
def list_sigs(self, fingerprints):
keyids = []
for fp in fingerprints:
keyids = ' '.join(keyids)
sig_keyids = []
gpg_output = subprocess.check_output('gpg --homedir {0} --with-colons --fixed-list-mode --list-sigs {1}'.format(self.gpg.homedir, keyids), shell=True)
for line in gpg_output.split('\n'):
if line[0:4] == 'sig:':
parts = line.split(':')
keyid = parts[4]
userid = parts[8]
if userid != '[User ID not found]':
return sig_keyids
if __name__ == '__main__':
start_time = time.time()
print 'Download the strong set, starting with 5C17616361BD9F92422AC08BB4D25A1E99999697'
gpg = gnupg.GPG(homedir=cwd+'/homedir_download_strong_set', verbose=False)
download_wot = TrollWoT_DownloadWoT(gpg)['5C17616361BD9F92422AC08BB4D25A1E99999697'])
end_time = time.time()
time_diff = int(end_time - start_time)
print '{0} keys imported, took {1} seconds'.format(len(download_wot.imported_keyids), time_diff)