]>
git.sthu.org Git - pgp-tools.git/blob - gpgsigs/gpgsigs
3 # See the pod documentation at the end of this file for author,
4 # copyright, and licence information.
7 # libintl-perl (Locale::Recode)
8 # OR libtext-iconv-perl (Text::Iconv),
9 # OR the "recode" binary
14 # * use the user's normal keyring to find signatures
15 # * support for multiple user keys
16 # * better charset conversion
31 gpgsigs $VERSION - http://pgp-tools.alioth.debian.org/
32 (c) 2004 Uli Martens <uli\@youam.net>
33 (c) 2004 Peter Palfrader <peter\@palfrader.org>
34 (c) 2004, 2005 Christoph Berg <cb\@df7cb.de>
43 Usage: $PROGRAM_NAME [-r] [-t <charset>] <keyid> <keytxt> [<outfile>]
45 keyid is a long or short keyid (e.g. DE7AAF6E94C09C7F or 94C09C7F)
46 separate multiple keyids with ','
47 -r call gpg --recv-keys before proceeding
48 -f <charset> convert <keytxt> from charset
49 -t <charset> convert UIDs to charset in output
55 my ($fromcharset, $charset, $recv_keys);
60 help
=> sub { usage
(0); },
61 version
=> sub { version
(); exit 0;},
66 $fromcharset ||= "ISO-8859-1";
67 $charset ||= $ENV{LC_ALL
} || $ENV{LC_CTYPE
} || $ENV{LANG
} || "ISO-8859-1";
68 $charset = "ISO-8859-1" unless $charset =~ /[\.-]/;
72 my ($rf, $rt, $if, $it);
73 if (eval "require Locale::Recode") {
74 $rf = Locale
::Recode
->new (from
=> $fromcharset, to
=> $charset) if $fromcharset;
75 $rt = Locale
::Recode
->new (from
=> 'UTF-8', to
=> $charset);
76 } elsif (eval "require Text::Iconv") {
77 $if = Text
::Iconv
->new($fromcharset, $charset) if $fromcharset;
78 $it = Text
::Iconv
->new("UTF-8", $charset);
87 } elsif (defined $if) {
88 return $if->convert($text);
90 my $pid = open3
(\
*WTRFH
, \
*RDRFH
, \
*ERRFH
, 'recode', "$fromcharset..$charset");
98 die ("'recode' failed, is it installed?\n") unless defined $result;
109 } elsif (defined $it) {
110 return $it->convert($text);
112 my $pid = open3
(\
*WTRFH
, \
*RDRFH
, \
*ERRFH
, 'recode', "utf8..$charset");
116 my $result = <RDRFH
>;
120 die ("'recode' failed, is it installed?\n") unless defined $result;
127 my $mykey = uc(shift @ARGV);
128 my $keytxt = (shift @ARGV) || usage
(1);
129 my $outfile = (shift @ARGV) || '-';
131 my @mykeys = split /,/, $mykey;
132 map { s/^0x//i; } @mykeys;
134 if (!@mykeys || scalar @ARGV) {
137 if (!grep { /^([0-9A-F]{16,16}|[0-9A-F]{8,8})$/ } @mykeys) {
138 print STDERR
"Invalid keyid given\n";
142 -r
$keytxt or die ("$keytxt does not exist\n");
145 # get list of keys in file
147 open (TXT
, $keytxt) or die ("Cannot open $keytxt\n");
149 if ( m/^pub +(?:\d+)[DR]\/([0-9A
-F
]{8}) [0-9]{4}-[0-9]{2}-[0-9]{2} *(.*)/ ) {
156 # get all known signatures
158 print STDERR
"Requesting keys from keyserver\n";
159 system "gpg --recv-keys @keys";
162 print STDERR
"Running --list-sigs, this will take a while ";
163 open SIGS
, "gpg --fixed-list-mode --with-colons --list-sigs @keys 2>/dev/null |"
164 or die "can't get gpg listing";
166 my ($key, $uid, $sigs);
168 if ( m/^pub:(?:.*?:){3,3}([0-9A-F]{16,16}):/ ) {
173 if ( m/^uid:(?:.*?:){8,8}(.*):/s ) {
177 if ( m/^sig:(?:.*?:){3,3}([0-9A-F]{8})([0-9A-F]{8}):(?:.*?:){3,3}(.*):.*?:/ ) {
178 $sigs->{$key}->{$uid}->{$1.$2} = $3;
179 $sigs->{$key}->{$uid}->{$2} = $3;
186 next if ( m/^(rev|sub|tru):/ );
187 warn "unknown value: '$_', key: ".(defined $key ?
$key :'none')."\n";
192 for my $k ( keys %{$sigs} ) {
193 if ( $k =~ m/^[0-9A-F]{8}([0-9A-F]{8})$/ ) {
194 $sigs->{$1} = $sigs->{$k};
200 open MD
, "gpg --print-md md5 $keytxt|" or warn "can't get gpg md5";
203 open MD
, "gpg --print-md sha1 $keytxt|" or warn "can't get gpg sha1";
209 my $metatxt = quotemeta($keytxt);
210 $MD5 =~ s/^$metatxt:\s*//;
211 $SHA1 =~ s/^$metatxt:\s*//;
217 my ($key, $uid) = @_;
218 if (! defined $sigs->{$key}->{$uid}) {
219 warn "uid '$uid' not found on key $key";
223 foreach my $mykey (@mykeys) {
224 $r .= defined $sigs->{$key}->{$uid}->{$mykey} ?
"S" : " ";
230 print STDERR
"Annotating $keytxt, writing into $outfile\n";
231 open (TXT
, $keytxt) or die ("Cannot open $keytxt\n");
232 open (WRITE
, '>'.$outfile) or die ("Cannot open $outfile for writing\n");
234 $_ = myfromrecode
($_);
235 if (/^MD5 Checksum:/ && defined $MD5) {
238 if (/^SHA1 Checksum:/ && defined $SHA1) {
241 if ( m/^pub +(?:\d+)[DR]\/([0-9A
-F
]{8}) [0-9]{4}-[0-9]{2}-[0-9]{2} *(.*)/ ) {
244 if ($uid) { # in gpg 1.2, the first uid is here
245 print WRITE print_tag
($key, $uid) . " $_";
249 if ( m/^uid +(.*)$/ ) {
251 print WRITE print_tag
($key, $uid) . " $_";
257 print WRITE
"Legend:\n";
258 foreach my $i (0 .. @mykeys - 1) {
259 print WRITE
'('. ' 'x
$i . 'S' . ' 'x
(@mykeys-$i-1) . ") signed with $mykeys[$i]\n";
267 B<gpgsigs> - annotate list of GnuPG keys with already done signatures
271 B<gpgsigs> [-r] [-f I<charset>] [-t I<charset>] I<keyid> F<keytxt> [F<outfile>]
275 B<gpgsigs> was written to assist the user in signing keys during a keysigning
276 party. It takes as input a file containing keys in C<gpg --list-keys> format
277 and prepends every line with a tag indicating if the user has already signed
278 that uid. When the file contains C<MD5 Checksum:> or C<SHA1 Checksum:> lines
279 and placeholders (C<__ __>), the checksum is inserted.
287 Call I<gpg --recv-keys> before creating the output.
291 Convert F<keytxt> from I<charset>. The default is ISO-8859-1.
295 Convert UIDs to I<charset>. The default is derived from LC_ALL, LC_CTYPE, and
296 LANG, and if all these are unset, the default is ISO-8859-1.
300 Use this keyid (8 or 16 byte) for annotation. Multiple keyids can be separated
305 Read input from F<keytxt>.
309 Write output to F<outfile>. Default is stdout.
315 The following key signing parties are using B<gpgsigs>:
317 http://www.palfrader.org/ksp-lt2k4.html
319 http://www.palfrader.org/ksp-lt2k5.html
323 B<GnuPG> is known to change its output format quite often. This version has
324 been tested with gpg 1.2.5 and gpg 1.4.1. YMMV.
330 http://pgp-tools.alioth.debian.org/
332 =head1 AUTHORS AND COPYRIGHT
334 (c) 2004 Uli Martens <uli@youam.net>
336 (c) 2004 Peter Palfrader <peter@palfrader.org>
338 (c) 2004, 2005 Christoph Berg <cb@df7cb.de>
344 Redistribution and use in source and binary forms, with or without
345 modification, are permitted provided that the following conditions
348 1. Redistributions of source code must retain the above copyright
349 notice, this list of conditions and the following disclaimer.
351 2. Redistributions in binary form must reproduce the above copyright
352 notice, this list of conditions and the following disclaimer in the
353 documentation and/or other materials provided with the distribution.
355 3. The name of the author may not be used to endorse or promote products
356 derived from this software without specific prior written permission.
358 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
359 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
360 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
361 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
362 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
363 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
364 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
365 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
366 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
367 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.