X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-perl/blobdiff_plain/f9952aec1cf6c64a5681308eea817b6113a37433..fcd15e0b7a3d0f0ca2f30953573f8d1f6b8e8bd2:/finger.pl diff --git a/finger.pl b/finger.pl new file mode 100644 index 0000000..11c8fb2 --- /dev/null +++ b/finger.pl @@ -0,0 +1,33 @@ +use ExtUtils::testlib; +use Catacomb; + +package Report; + +sub new { bless [], $_[0]; } +sub report { my ($me, @info) = @_; push(@$me, \@info); } +sub done { + my ($me) = @_; + if (@$me) { + print STDERR "Errors reading key file:\n"; + foreach my $i (@$me) { + printf STDERR " %s:%d: %s\n", @$i; + } + exit(1); + } +} + +package main; + +my $fn = shift || "keyring"; +my $rep = Report->new(); +$kf = Catacomb::Key::File->new($fn, KFILE_READ, $rep) + or die("error opening keyring: $!"); +$rep->done(); +$hcn = shift || "rmd160"; +$hc = Catacomb::HashClass->find($hcn) or die("no hash algorithm `$hcn'"); +$filt = Catacomb::Key::Filter->new("-secret"); +for (my $i = $kf->iterate(); my $k = $i->next(); ) { + $h = $hc->init(); + $fp = $k->fingerprint($h, $filt); + print unpack("H*", $h->done()), " ", $k->fulltag(), "\n"; +}