summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2020-06-05 02:13:52 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2020-06-05 02:13:52 +0200
commit2e988546c59ba25bf9e63521112c0c3c73b012f1 (patch)
tree59f9af79358687bc59e0224d3adeb4462664e408
parentagent: Clean up do_encode_md. (diff)
downloadgnupg2-2e988546c59ba25bf9e63521112c0c3c73b012f1.tar.xz
gnupg2-2e988546c59ba25bf9e63521112c0c3c73b012f1.zip
agent: Remove duplicated code for EdDSA.
* agent/command-ssh.c (ssh_receive_key): Curve is "Ed25519". Use sexp_key_construct always. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r--agent/command-ssh.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/agent/command-ssh.c b/agent/command-ssh.c
index 881f9372a..fc52de2f1 100644
--- a/agent/command-ssh.c
+++ b/agent/command-ssh.c
@@ -2123,6 +2123,10 @@ ssh_receive_key (estream_t stream, gcry_sexp_t *key_new, int secret,
* we only want the real 32 byte private key - Libgcrypt expects
* this.
*/
+
+ /* For now, it's only Ed25519. In future, Ed448 will come. */
+ curve_name = "Ed25519";
+
mpi_list = xtrycalloc (3, sizeof *mpi_list);
if (!mpi_list)
{
@@ -2229,39 +2233,15 @@ ssh_receive_key (estream_t stream, gcry_sexp_t *key_new, int secret,
goto out;
}
- if ((spec.flags & SPEC_FLAG_IS_EdDSA))
- {
- if (secret)
- {
- err = gcry_sexp_build (&key, NULL,
- "(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)
{
- 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;
}
- if (key_spec)
- *key_spec = spec;
- *key_new = key;
-
out:
es_fclose (cert);
mpint_list_free (mpi_list);