1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-25 15:27:03 +01:00

agent: SSH clean up.

* agent/command-ssh.c (ssh_receive_key): Use sexp_key_construct for
EdDSA.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2020-05-26 11:53:56 +09:00
parent cbf30c1da9
commit f3d07c634e

View File

@ -2123,6 +2123,9 @@ ssh_receive_key (estream_t stream, gcry_sexp_t *key_new, int secret,
* we only want the real 32 byte private key - Libgcrypt expects * we only want the real 32 byte private key - Libgcrypt expects
* this. * this.
*/ */
/* For now, it's only ed25519 */
curve_name = "Ed25519";
mpi_list = xtrycalloc (3, sizeof *mpi_list); mpi_list = xtrycalloc (3, sizeof *mpi_list);
if (!mpi_list) if (!mpi_list)
{ {
@ -2229,38 +2232,14 @@ ssh_receive_key (estream_t stream, gcry_sexp_t *key_new, int secret,
goto out; goto out;
} }
if ((spec.flags & SPEC_FLAG_IS_EdDSA)) err = sexp_key_construct (&key, spec, secret, curve_name, mpi_list,
comment? comment:"");
if (!err)
{ {
if (secret) if (key_spec)
{ *key_spec = spec;
err = gcry_sexp_build (&key, NULL, *key_new = key;
"(private-key(ecc(curve \"Ed25519\")"
"(flags eddsa)(q %m)(d %m))"
"(comment%s))",
mpi_list[0], mpi_list[1],
comment? comment:"");
}
else
{
err = gcry_sexp_build (&key, NULL,
"(public-key(ecc(curve \"Ed25519\")"
"(flags eddsa)(q %m))"
"(comment%s))",
mpi_list[0],
comment? comment:"");
}
} }
else
{
err = sexp_key_construct (&key, spec, secret, curve_name, mpi_list,
comment? comment:"");
if (err)
goto out;
}
if (key_spec)
*key_spec = spec;
*key_new = key;
out: out:
es_fclose (cert); es_fclose (cert);