a61b5ba369317eb8a367007fa96cd3f87f0e7dd8
[monkeysphere.git] / website / bugs / handle-passphrase-locked-secret-keys.mdwn
1 [[meta title="MonkeySphere needs to be able to cleanly export passphrase-locked secret keys from the GPG keyring"]]
2
3 At the moment, the only tool we have to export passphrase-locked
4 secret keys from the GPG keyring is `gpg` itself (and `gpg2`, which
5 has roughly the same behavior).
6
7 As a result, we have the `seckey2sshagent` hack, which is unfriendly
8 and awkward to use.
9
10 Ideally, `openpgp2ssh` would be able to convert passphrase-locked
11 secret keys into clean subkeys.  However, i've tried to do this via
12 GnuTLS, and that library is not ready for this.
13
14 OpenCDK, which is the component of GnuTLS which reads OpenPGP-style
15 keys, cannot cope with encrypted secret key material.  I have had
16 [some
17 success](http://lists.gnu.org/archive/html/gnutls-devel/2008-06/msg00092.html)
18 in getting GnuTLS's OpenCDK to accept the existence of encrypted
19 secret key packets, [i learned that OpenCDK as included in GnuTLS is
20 incapable of dealing with the encrypted packets
21 themselves](http://lists.gnu.org/archive/html/gnutls-devel/2008-07/msg00012.html).
22
23
24 Some possible resolutions:
25
26 ---------
27
28 If we can assume that the passphrase-encrypted key we want to use is
29 actually a subkey, and if we could fix GnuTLS to ignore the use of the
30 "gnu-dummy S2K" produced by `gpg --export-secret-subkeys` for the
31 primary key, then something like the following script should actually
32 work for reasonable values of `$KEYID`:
33
34         TMPDIR=$(mktemp -d)
35         uname 077
36         mkfifo "$TMPDIR/passphrase"
37         kname="MonkeySphere Key $KEYID"
38         mkfifo "$TMPDIR/$kname"
39         ssh-agent "Please enter the passphrase for MonkeySphere key $KEYID" >"$TMPDIR/passphrase" &
40         gpg  --passphrase-fd 3 3<"$TMPDIR/passphrase" --export-options export-reset-subkey-passwd,export-minimal,no-export-attributes --export-secret-subkeys "$KEYID"\! | openpgp2ssh "$KEYID" > "$TMPDIR/$kname"
41         (cd "$TMPDIR" && ssh-add -c "$kname")
42         rm -rf "$TMPDIR"        
43
44 ---------
45
46 Ben Laurie and Rachel Willmer's
47 [OpenPGPSDK](http://openpgp.nominet.org.uk) is a candidate: this is a
48 C-based library that intends to implement RFC 4880 functionality.
49
50 We could potentially re-write `openpgp2ssh` using this library, and it
51 *should* be able to handle everything we need from the OpenPGP side
52 (though it might need to be re-linked to OpenSSL to handle PEM-encoded
53 exports.
54
55 Concerns:
56
57 * OpenPGPSDK is not in debian yet, and doesn't currently (2008-08-13)
58   build with gcc 4.2 or 4.3.
59
60 * OpenPGPSDK uses the apache license and appears to link to OpenSSL,
61   which has a GPL-incompatible license.  I think this would mean that
62   `openpgp2ssh` could not remain GPL (though the rest of the
63   monkeysphere could).
64
65 ---------
66
67 We could try to use perl.  The last time i checked, the pure-perl
68 OpenPGP implementations all depended on Math::PARI, which [is not in
69 debian](http://bugs.debian.org/440527).  The most likely candidate is
70 [Crypt::OpenPGP](http://search.cpan.org/~btrott/Crypt-OpenPGP),
71 despite [some
72 bugginess](http://cpanratings.perl.org/dist/Crypt-OpenPGP).  
73
74 Concerns:
75
76 * the aforementioned buggy reviews
77
78 * there's a lot of dependency chasing to get anything like this
79   available in debian.
80
81 ---------
82
83 Other alternatives?