summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2013-01-18 15:22:54 -0500
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2013-01-18 15:22:54 -0500
commitcd03ac0a10a43efa3ebf4a8d48a759e26f2e0f0a (patch)
tree526b1adf116ed2e8ea88b969711521471d0ab7f5
parent8fe76e1bb054e843aa57715d01ab629953eaa419 (diff)
enable openpgp2pem as well from keytrans
-rw-r--r--Changelog3
-rwxr-xr-xMakefile2
-rw-r--r--man/man1/openpgp2ssh.110
-rwxr-xr-xsrc/share/keytrans16
4 files changed, 27 insertions, 4 deletions
diff --git a/Changelog b/Changelog
index 48956dd..5702022 100644
--- a/Changelog
+++ b/Changelog
@@ -4,8 +4,9 @@ monkeysphere (0.36~pre) unstable; urgency=low
#2682)
* fetch all available keys from keyserver instead of first 5 (closes MS
#1046)
+ * enable openpgp2pem for keytrans (Closes: #698383)
- -- Daniel Kahn Gillmor <dkg@fifthhorseman.net> Tue, 11 Sep 2012 15:45:51 -0400
+ -- Daniel Kahn Gillmor <dkg@fifthhorseman.net> Fri, 18 Jan 2013 15:21:36 -0500
monkeysphere (0.35) upstream;
diff --git a/Makefile b/Makefile
index 767cd6c..d281bcb 100755
--- a/Makefile
+++ b/Makefile
@@ -56,6 +56,7 @@ install: all installman
install -m 0755 src/share/keytrans $(DESTDIR)$(PREFIX)/share/monkeysphere
ln -sf ../share/monkeysphere/keytrans $(DESTDIR)$(PREFIX)/bin/pem2openpgp
ln -sf ../share/monkeysphere/keytrans $(DESTDIR)$(PREFIX)/bin/openpgp2ssh
+ ln -sf ../share/monkeysphere/keytrans $(DESTDIR)$(PREFIX)/bin/openpgp2pem
install -m 0744 src/transitions/* $(DESTDIR)$(PREFIX)/share/monkeysphere/transitions
sed -i 's:__SYSSHAREDIR_PREFIX__:$(PREFIX):' $(DESTDIR)$(PREFIX)/share/monkeysphere/transitions/0.23
sed -i 's:__SYSSHAREDIR_PREFIX__:$(PREFIX):' $(DESTDIR)$(PREFIX)/share/monkeysphere/transitions/0.28
@@ -76,6 +77,7 @@ installman:
install man/man1/* $(DESTDIR)$(MANPREFIX)/man1
install man/man7/* $(DESTDIR)$(MANPREFIX)/man7
install man/man8/* $(DESTDIR)$(MANPREFIX)/man8
+ ln -s openpgp2ssh.1.gz $(DESTDIR)$(MANPREFIX)/man1/openpgp2pem.1.gz
gzip -d man/*/*
gzip -d $(DESTDIR)$(MANPREFIX)/man1/monkeysphere.1.gz
sed -i 's:__SYSCONFDIR_PREFIX__:$(ETCPREFIX):' $(DESTDIR)$(MANPREFIX)/man1/monkeysphere.1
diff --git a/man/man1/openpgp2ssh.1 b/man/man1/openpgp2ssh.1
index 304a442..6ac8f92 100644
--- a/man/man1/openpgp2ssh.1
+++ b/man/man1/openpgp2ssh.1
@@ -1,5 +1,5 @@
.\" -*- nroff -*-
-.Dd $Mdocdate: March 1, 2009 $
+.Dd $Mdocdate: January 18, 2013 $
.Dt OPENPGP2SSH 1
.Os
.Sh NAME
@@ -10,12 +10,14 @@ openpgp2ssh
.Pp
.Nm gpg \-\-export $KEYID | openpgp2ssh $KEYID
.Pp
+.Nm gpg \-\-export $KEYID | openpgp2pem $KEYID
+.Pp
.Nm gpg \-\-export\-secret\-key $KEYID | openpgp2ssh $KEYID
.Sh DESCRIPTION
.Nm
takes an OpenPGP-formatted primary key and associated
subkeys on standard input, and spits out the requested equivalent
-SSH-style key on standard output.
+SSH-style (or PEM-encoded) key on standard output.
.Pp
If the data on standard input contains no subkeys, you can invoke
.Nm
@@ -31,7 +33,9 @@ ID.
If the input contains an OpenPGP RSA public key, it will be converted
to the OpenSSH-style single-line keystring, prefixed with the key type
(`ssh\-rsa'). This format is suitable (with minor alterations) for
-insertion into known_hosts files and authorized_keys files.
+insertion into known_hosts files and authorized_keys files. If
+invoked as `openpgp2pem', a PEM-encoded public key will be emitted
+instead.
.Pp
If the input contains an OpenPGP RSA secret key, it will be converted
to the equivalent PEM-encoded private key.
diff --git a/src/share/keytrans b/src/share/keytrans
index c09f664..19419e3 100755
--- a/src/share/keytrans
+++ b/src/share/keytrans
@@ -1123,6 +1123,22 @@ for (basename($0)) {
die "No matching key found.\n";
}
}
+ elsif (/^openpgp2pem$/) {
+ my $fpr = shift;
+ my $instream;
+ open($instream,'-');
+ binmode($instream, ":bytes");
+ my $key = openpgp2rsa($instream, $fpr);
+ if (defined($key)) {
+ if ($key->is_private()) {
+ print $key->get_private_key_string();
+ } else {
+ print $key->get_public_key_string();
+ }
+ } else {
+ die "No matching key found.\n";
+ }
+ }
elsif (/^keytrans$/) {
# subcommands when keytrans is invoked directly are UNSUPPORTED,
# UNDOCUMENTED, and WILL NOT BE MAINTAINED.