From: Daniel Kahn Gillmor Date: Sat, 17 Apr 2010 19:57:47 +0000 (-0400) Subject: added internal openpgp2sshfpr subcommand for keytrans X-Git-Tag: monkeysphere_0.30~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=056ccb1b87edac25d29736f9835a4e29be6e3205;p=monkeysphere.git added internal openpgp2sshfpr subcommand for keytrans --- diff --git a/src/share/keytrans b/src/share/keytrans index 255a271..ae887de 100755 --- a/src/share/keytrans +++ b/src/share/keytrans @@ -1144,6 +1144,19 @@ for (basename($0)) { binmode($instream, ":bytes"); my $keys = getallprimarykeys($instream); printf("%s\n", join("\n", map { uc(unpack('H*', $_)) } keys(%{$keys}))); + } elsif (/^openpgp2sshfpr$/) { + my $fpr = shift; + my $instream; + open($instream,'-'); + binmode($instream, ":bytes"); + my $key = openpgp2rsa($instream, $fpr); + if (defined($key)) { + # openssh uses MD5 for key fingerprints: + use Digest::MD5; + printf("%s\n", join(':', map({unpack("H*", $_)} split(//, Digest::MD5::md5(openssh_pubkey_pack($key)))))); + } else { + die "No matching key found.\n"; + } } else { die "Unrecognized subcommand. keytrans subcommands are not a stable interface!\n"; }