added internal openpgp2sshfpr subcommand for keytrans
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Sat, 17 Apr 2010 19:57:47 +0000 (15:57 -0400)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Sat, 17 Apr 2010 19:57:47 +0000 (15:57 -0400)
src/share/keytrans

index 255a271c2cefd7f2dd446d5b69e9a275f8116ce5..ae887de2e8efee76610b208b82f79e9b36c0c3be 100755 (executable)
@@ -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";
       }