3 # gpg-key2ps: convert a PGP/GnuPG key into paper slips.
8 $version =~ s/\$Rev:\s*(\d+)\s*\$/$1/;
9 $usage = "Usage: $0 [-p papersize] [-r revoked-style] keyid-or-name\n";
20 if ( $opts{r
} ) { $revokestyle = $opts{'r'}; }
21 if ( $opts{p
} ) { $ENV{'PAPERSIZE'} = $opts{'p'}; }
22 foreach (@ARGV) { $keyids .= $_ . " "; }
24 if ( $revokestyle !~ /^(grey|hide|note|show|strike)$/ ) {
25 print STDERR
"Unknown style \"$revokestyle\". Please use one of\n";
26 print STDERR
" grey - Print text in grey\n";
27 print STDERR
" hide - Don't show revoked uids\n";
28 print STDERR
" note - Add \"(revoked)\"\n";
29 print STDERR
" show - List revoked uids normally\n";
30 print STDERR
" strike - Strike through lines\n";
34 if ( -x
"/usr/bin/paperconf" ) {
45 open(GPG
, "gpg --fingerprint --with-colons $keyids |");
49 %%BoundingBox: 0 0 $w $h
51 %%Creator: gpg-key2ps $version
53 print "%%CreationDate: " . scalar(localtime) . "\n";
63 /Times-Roman findfont 9 scalefont setfont
71 w 2 div 30 sub y 3 add lineto stroke
76 /condhline { hline } def
84 << 1 (R) 2 (r) 3 (s) 16 (g) 20 (G) 17 (D) >> exch get
90 50 y moveto (pub) show
91 70 y moveto show showAlgorithm (/) show show
99 70 y moveto (Key fingerprint = ) show show
104 50 y moveto (uid) show
111 if ( $revokestyle eq "grey" ) {
113 print " .5 setgray\n";
115 print " 0 setgray\n";
117 } elsif ( $revokestyle eq "hide" ) {
118 print "/revuid {} def\n";
119 } elsif ( $revokestyle eq "note" ) {
121 print " 50 y moveto (uid) show\n";
122 print " 200 y moveto show ([revoked]) show\n";
125 } elsif ( $revokestyle eq "show" ) {
126 print "/revuid { uid } def\n";
127 } elsif ( $revokestyle eq "strike" ) {
130 print " 45 y 9 add moveto h 2 div 45 sub y 18 add lineto stroke\n";
137 50 y moveto (sub) show
138 70 y moveto show showAlgorithm (/) show show
149 if ( /^(tru|uat):/ ) { next; }
150 if ( /^pub:/ ) { $numlines++; }
151 s/^pub:[^:]*:([^:]*):([0-9]*):.{8,8}(.{8,8}):([^:]*):[^:]*:[^:]*:[^:]*:([^:]*):[^:]*:[^:]*:.*/ ($5) ($4) ($3) $2 ($1) pub/;
152 if ( /^fpr:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:([^:]*):.*/ ) {
155 $fpr =~ s/(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})(\w{4})/$1 $2 $3 $4 $5 $6 $7 $8 $9 $10/;
157 $fpr =~ s/(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})/$1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16/g;
158 $_ = " ($fpr) fpr\n";
160 s/^uid:[^:r]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:([^:]*):.*/ ($1) uid/;
161 s/^uid:[^:r]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:([^:]*):.*/ ($1) uid/;
162 s/^uid:r[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:([^:]*):.*/ ($1) revuid/;
163 s/^sub:[^:]*:([^:]*):([0-9]*):.{8,8}(.{8,8}):([^:]*):[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:.*/ ($4) ($3) $2 ($1) sbk/;
175 print "/numlines $numlines def\n";
177 /num w 16 sub 10 div numlines div def
183 0 0 h 2 div w rectclip
188 0 upper h 2 div upper h 2 div lower 0 lower 0 upper moveto lineto lineto lineto lineto stroke