3 # gpg-key2ps: convert a PGP/GnuPG key into paper slips.
10 USAGE
="Usage: $0 [-p papersize] [-r revoked-style] keyid-or-name"
29 PAPERSIZE
=`echo $1 | sed -e 's/^-p//'`
38 REVOKESTYLE
=`echo $1 | sed -e 's/^-r//'`
52 case "$REVOKESTYLE" in
53 grey|hide|note|show|strike
)
56 echo >&2 "Unknown style \"$REVOKESTYLE\". Please use one of"
57 echo >&2 " grey - Print text in grey"
58 echo >&2 " hide - Don't show revoked uids"
59 echo >&2 " note - Add \"(revoked)\""
60 echo >&2 " show - List revoked uids normally"
61 echo >&2 " strike - Strike through lines"
66 TMPFILE
=`mktemp -t gpg-key2ps.XXXXXX`
68 if ! gpg
--fingerprint --with-colons $KEYIDS 2>/dev
/null
>$TMPFILE; then
69 echo >&2 "Key not found. Try 'gpg --list-keys'"
74 NUMLINES
=$
((`wc -l <$TMPFILE` + `grep '^pub:' $TMPFILE | wc -l` - 1))
76 if test -x /usr
/bin
/paperconf
; then
87 %%BoundingBox: 0 0 $w $h
89 %%Creator: gpg-key2ps $VERSION
91 echo "%%CreationDate: `date`"
101 /Times-Roman findfont 9 scalefont setfont
109 w 2 div 30 sub y 3 add lineto stroke
114 /condhline { hline } def
122 << 1 (R) 2 (r) 3 (s) 16 (g) 20 (G) 17 (D) >> exch get
128 50 y moveto (pub) show
129 70 y moveto show showAlgorithm (/) show show
137 70 y moveto (Key fingerprint = ) show show
142 50 y moveto (uid) show
149 case "$REVOKESTYLE" in
158 echo "/revuid {} def"
162 echo " 50 y moveto (uid) show"
163 echo " 200 y moveto show ([revoked]) show"
168 echo "/revuid { uid } def"
173 echo " 45 y 9 add moveto h 2 div 45 sub y 18 add lineto stroke"
181 50 y moveto (sub) show
182 70 y moveto show showAlgorithm (/) show show
192 -e 's/^pub:[^:]*:\([^:]*\):\([0-9]*\):.\{8,8\}\(.\{8,8\}\):\([^:]*\):[^:]*:[^:]*:[^:]*:\([^:]*\):[^:]*:[^:]*:.*/ (\5) (\4) (\3) \2 (\1) pub/' \
193 -e 's/^fpr:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*/ (\1) fpr/' \
194 -e 's/(\(.\{16,16\}\)\(.\{16,16\}\)) fpr/(@split@\1@ @split@\2@) fpr/' \
195 -e 's/@split@\(.\{2,2\}\)\(.\{2,2\}\)\(.\{2,2\}\)\(.\{2,2\}\)\(.\{2,2\}\)\(.\{2,2\}\)\(.\{2,2\}\)\(.\{2,2\}\)@/\1 \2 \3 \4 \5 \6 \7 \8/g' \
196 -e 's/(\(.\{20,20\}\)\(.\{20,20\}\)) fpr/(@split@\1@ @split@\2@) fpr/' \
197 -e 's/@split@\(.\{4,4\}\)\(.\{4,4\}\)\(.\{4,4\}\)\(.\{4,4\}\)\(.\{4,4\}\)@/\1 \2 \3 \4 \5/g' \
198 -e 's/^uid:[^:r]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*/ (\1) uid/' \
199 -e 's/^uid:r[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\):.*/ (\1) revuid/' \
200 -e 's/^sub:[^:]*:\([^:]*\):\([0-9]*\):.\{8,8\}\(.\{8,8\}\):\([^:]*\):[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:.*/ (\4) (\3) \2 (\1) sbk/' \
206 echo "/numlines $(($NUMLINES + 1)) def"
208 /num w 16 sub 10 div numlines div def
214 0 0 h 2 div w rectclip
219 0 upper h 2 div upper h 2 div lower 0 lower 0 upper moveto lineto lineto lineto lineto stroke