| 1 | use ExtUtils::testlib; |
| 2 | use Catacomb; |
| 3 | |
| 4 | package Report; |
| 5 | |
| 6 | sub new { bless [], $_[0]; } |
| 7 | sub report { my ($me, @info) = @_; push(@$me, \@info); } |
| 8 | sub done { |
| 9 | my ($me) = @_; |
| 10 | if (@$me) { |
| 11 | print STDERR "Errors reading key file:\n"; |
| 12 | foreach my $i (@$me) { |
| 13 | printf STDERR " %s:%d: %s\n", @$i; |
| 14 | } |
| 15 | exit(1); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | package main; |
| 20 | |
| 21 | my $fn = shift || "keyring"; |
| 22 | my $rep = Report->new(); |
| 23 | $kf = Catacomb::Key::File->new($fn, KFILE_READ, $rep) |
| 24 | or die("error opening keyring: $!"); |
| 25 | $rep->done(); |
| 26 | $hcn = shift || "rmd160"; |
| 27 | $hc = Catacomb::HashClass->find($hcn) or die("no hash algorithm `$hcn'"); |
| 28 | $filt = Catacomb::Key::Filter->new("-secret"); |
| 29 | for (my $i = $kf->iterate(); my $k = $i->next(); ) { |
| 30 | $h = $hc->init(); |
| 31 | $fp = $k->fingerprint($h, $filt); |
| 32 | print unpack("H*", $h->done()), " ", $k->fulltag(), "\n"; |
| 33 | } |