-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpgpgen
executable file
·44 lines (36 loc) · 1.07 KB
/
pgpgen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
if [ $# != 1 ]; then
echo >&2 "Usage: $0 hexadecimal"
echo >&2 "Example: $0 DEADBEEF"
exit 1
fi
abk=$(echo -ne "$(echo $1 | sed -e 's/../\\x&/g')")
mkdir --mode 700 -p gpg
# rinse and repeat
while true; do
# delete the old key (if any)
rm -f input.pub input.sec
# use gpg to generate a new key (we better have LOADS of entropy available!)
gpg --homedir ./gpg --batch --gen-key <<- EOF
%echo Generating a basic OpenPGP key
%no-protection
Key-Type: RSA
Key-Length: 4096
Subkey-Type: RSA
Subkey-Length: 1024
Name-Real: this uid will be gone anyways
Name-Email: x.y@z
Expire-Date: 0
%pubring input.pub
%secring input.sec
# Do a commit here, so that we can later print "done" :-)
%commit
%echo done
EOF
echo abc | gpg --homedir ./gpg --keyring ./input.pub --export-secret-keys --yes --batch --passphrase-fd 0 > ./input.sec
# vanity~
./vanity input.pub input.sec 1262300400 $abk && break
done
gpg --homedir ./gpg --allow-non-selfsigned-uid --import result.sec
gpg --home ./gpg --armor --export-secret-keys >> private.key
rm -rf ./gpg