Skip to content

Instantly share code, notes, and snippets.

@Mayeu
Created January 23, 2014 09:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Mayeu/8575504 to your computer and use it in GitHub Desktop.
Save Mayeu/8575504 to your computer and use it in GitHub Desktop.
(dirty dirty dirty) Vanity GPGkey generator. Lancer keygen.pl avec le nombre de gpg --gen-key à lancer en parallèle
gpg --gen-key --batch <<EOF
Key-Type: RSA
Key-Length: 4096
Subkey-Type: RSA
Subkey-Length: 4096
Name-Real: <ton_nom>
Name-Email: <ton_mail>
Expire-Date: 0
Passphrase: <ta_passphrase>
%pubring foo${1}.pub
%secring foo${1}.sec
# Do a commit here, so that we can later print "done" :-)
%commit
EOF
#! /usr/bin/env perl
use strict;
use warnings;
my $stop = 0;
# Get the "thread" number
my $number = shift @ARGV;
my $KEYRING_OPTS = "--no-default-keyring --secret-keyring ./foo$number.sec --keyring ./foo$number.pub" ;
until ($stop) {
# Generate a key
`bash keybatchgen.sh $number`;
# Get the key short ID
my $short_id = `gpg $KEYRING_OPTS --list-secret-keys | grep 'sec ' | cut -d ' ' -f 4`;
# Cut the 4096R part
$short_id =~ s/4096R\///;
chomp $short_id;
# Print it
#print $short_id ;
# Only export if it match a pattern
if ( $short_id =~
m/(FACE|C0FFEE|BAD|F00D|1CE|B00DDA|B00DA|CAFE|D00D|FEED|DEAD|BEAF|BEEF|C0DE|B00C|DEFACED|B00B|1DEA|DEFECA7E|D06|A55|CA7|CACA|B002E|B0A|B16|BABE|DAD|B10|B0D1|FA7|DEAF)/o
)
{
print "Export $short_id\n";
# Create the filename
my $base_name = '0x' . $short_id;
# export it
`gpg $KEYRING_OPTS --output $base_name.pub.gpg --armor --export $short_id`;
`gpg $KEYRING_OPTS --output $base_name.sec.gpg --armor --export-secret-key $short_id`;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment