diff options
author | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2010-01-18 01:06:50 -0500 |
---|---|---|
committer | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2010-01-18 01:06:50 -0500 |
commit | 585800f161f5cc09ffcb666426691714294cf95e (patch) | |
tree | 052cc9f51d81ae38aaffe59cd323a12c1fef105f | |
parent | c4b0a1e409cab69558aaa0fd47f7076ed6481e3e (diff) |
added non-public "keytrans listfprs" subcommand
-rwxr-xr-x | src/share/keytrans | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/share/keytrans b/src/share/keytrans index ae4fb09..0f2ba41 100755 --- a/src/share/keytrans +++ b/src/share/keytrans @@ -810,6 +810,40 @@ sub openpgp2rsa { return $data->{key}->{rsa}; } +sub findkeyfprs { + my $data = shift; + my $instr = shift; + my $tag = shift; + my $packetlen = shift; + + findkey($data, $instr, $tag, $packetlen); + if (defined($data->{key})) { + if (defined($data->{key}->{rsa}) && defined($data->{key}->{timestamp})) { + $data->{keys}->{fingerprint($data->{key}->{rsa}, $data->{key}->{timestamp})} = $data->{key}; + } else { + die "should have found some key here"; + } + undef($data->{key}); + } +}; + +sub getallprimarykeys { + my $instr = shift; + + my $subs = { $packet_types->{pubkey} => \&findkeyfprs, + $packet_types->{seckey} => \&findkeyfprs, + }; + my $data = {target => { } }; + + packetwalk($instr, $subs, $data); + + if (defined $data->{keys}) { + return $data->{keys}; + } else { + return {}; + } +} + sub adduserid { my $instr = shift; my $fpr = shift; @@ -1102,6 +1136,12 @@ for (basename($0)) { }); print $newuid; + } elsif (/^listfprs$/) { + my $instream; + open($instream,'-'); + binmode($instream, ":bytes"); + my $keys = getallprimarykeys($instream); + printf("%s\n", join("\n", map { uc(unpack('H*', $_)) } keys(%{$keys}))); } else { die "Unrecognized subcommand. keytrans subcommands are not a stable interface!\n"; } |