[PATCH] agent: Fix registering SSH Key of Ed25519
NIIBE Yutaka
gniibe at fsij.org
Tue Sep 15 10:02:43 CEST 2015
Hello,
GnuPG 2.1.7 was broken for OpenPGP authentication key of Ed25519 when
it is used for SSH. I fixed this by removing the first byte.
This fix itself is correct. However, there is another code path which
we need to fix for SSH with Ed25519 key. That is, we need to fix the
code of registering SSH key by ssh-agent feature of gpg-agent (through
ssh-add).
Since released version of libgcrypt puts prefix 0x40 to the Ed25519
key, we should follow this format.
Here is the change.
This fixes: https://bugs.gnupg.org/gnupg/issue2096
Possibly, also, http://bugs.debian.org/798956
diff --git a/agent/command-ssh.c b/agent/command-ssh.c
index 8868620..8be1255 100644
--- a/agent/command-ssh.c
+++ b/agent/command-ssh.c
@@ -580,8 +580,9 @@ stream_read_string (estream_t stream, unsigned int secure,
/* Read a binary string from STREAM and store it as an opaque MPI at
- R_MPI. Depending on SECURE use secure memory. If the string is
- too large for key material return an error. */
+ R_MPI, adding 0x40 (this is the prefix for EdDSA key in OpenPGP).
+ Depending on SECURE use secure memory. If the string is too large
+ for key material return an error. */
static gpg_error_t
stream_read_blob (estream_t stream, unsigned int secure, gcry_mpi_t *r_mpi)
{
@@ -607,9 +608,9 @@ stream_read_blob (estream_t stream, unsigned int secure, gcry_mpi_t *r_mpi)
/* Allocate space. */
if (secure)
- buffer = xtrymalloc_secure (length? length:1);
+ buffer = xtrymalloc_secure (length+1);
else
- buffer = xtrymalloc (length?length:1);
+ buffer = xtrymalloc (length+1);
if (!buffer)
{
err = gpg_error_from_syserror ();
@@ -617,11 +618,12 @@ stream_read_blob (estream_t stream, unsigned int secure, gcry_mpi_t *r_mpi)
}
/* Read data. */
- err = stream_read_data (stream, buffer, length);
+ err = stream_read_data (stream, buffer + 1, length);
if (err)
goto leave;
- *r_mpi = gcry_mpi_set_opaque (NULL, buffer, 8*length);
+ buffer[0] = 0x40;
+ *r_mpi = gcry_mpi_set_opaque (NULL, buffer, 8*(length+1));
buffer = NULL;
leave:
--
More information about the Gnupg-devel
mailing list