1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-10 23:49:50 +02:00

agent: fix ECC key handling.

* agent/cvt-openpgp.c (get_keygrip, convert_secret_key)
(convert_transfer_key): CURVE is the name of curve.
This commit is contained in:
NIIBE Yutaka 2015-08-10 19:13:13 +09:00
parent c80643c5ec
commit 8704c70108

View File

@ -87,16 +87,10 @@ get_keygrip (int pubkey_algo, const char *curve, gcry_mpi_t *pkey,
{ {
const char *format; const char *format;
if (!strcmp (curve, openpgp_curve_to_oid ("Ed25519", NULL))) if (!strcmp (curve, "Ed25519"))
{ format = "(public-key(ecc(curve %s)(flags eddsa)(q%m)))";
format = "(public-key(ecc(curve %s)(flags eddsa)(q%m)))"; else if (!strcmp (curve, "Curve25519"))
curve = "Ed25519"; format = "(public-key(ecc(curve %s)(flags djb-tweak)(q%m)))";
}
else if (!strcmp (curve, openpgp_curve_to_oid ("Curve25519", NULL)))
{
format = "(public-key(ecc(curve %s)(flags djb-tweak)(q%m)))";
curve = "Curve25519";
}
else else
format = "(public-key(ecc(curve %s)(q%m)))"; format = "(public-key(ecc(curve %s)(q%m)))";
@ -161,18 +155,12 @@ convert_secret_key (gcry_sexp_t *r_key, int pubkey_algo, gcry_mpi_t *skey,
{ {
const char *format; const char *format;
if (!strcmp (curve, openpgp_curve_to_oid ("Ed25519", NULL))) if (!strcmp (curve, "Ed25519"))
{ /* Do not store the OID as name but the real name and the
/* Do not store the OID as name but the real name and the EdDSA flag. */
EdDSA flag. */ format = "(private-key(ecc(curve %s)(flags eddsa)(q%m)(d%m)))";
format = "(private-key(ecc(curve %s)(flags eddsa)(q%m)(d%m)))"; else if (!strcmp (curve, "Curve25519"))
curve = "Ed25519"; format = "(private-key(ecc(curve %s)(flags djb-tweak)(q%m)(d%m)))";
}
else if (!strcmp (curve, openpgp_curve_to_oid ("Curve25519", NULL)))
{
format = "(private-key(ecc(curve %s)(flags djb-tweak)(q%m)(d%m)))";
curve = "Curve25519";
}
else else
format = "(private-key(ecc(curve %s)(q%m)(d%m)))"; format = "(private-key(ecc(curve %s)(q%m)(d%m)))";
@ -239,23 +227,17 @@ convert_transfer_key (gcry_sexp_t *r_key, int pubkey_algo, gcry_mpi_t *skey,
{ {
const char *format; const char *format;
if (!strcmp (curve, openpgp_curve_to_oid ("Ed25519", NULL))) if (!strcmp (curve, "Ed25519"))
{ /* Do not store the OID as name but the real name and the
/* Do not store the OID as name but the real name and the EdDSA flag. */
EdDSA flag. */ format = "(protected-private-key(ecc(curve %s)(flags eddsa)(q%m)"
format = "(protected-private-key(ecc(curve %s)(flags eddsa)(q%m)" "(protected openpgp-native%S)))";
"(protected openpgp-native%S)))"; else if (!strcmp (curve, "Curve25519"))
curve = "Ed25519"; format = "(protected-private-key(ecc(curve %s)(flags djb-tweak)(q%m)"
} "(protected openpgp-native%S)))";
else if (!strcmp (curve, openpgp_curve_to_oid ("Curve25519", NULL)))
{
format = "(protected-private-key(ecc(curve %s)(flags djb-tweak)(q%m)"
"(protected openpgp-native%S)))";
curve = "Curve25519";
}
else else
format = "(protected-private-key(ecc(curve %s)(q%m)" format = "(protected-private-key(ecc(curve %s)(q%m)"
"(protected openpgp-native%S)))"; "(protected openpgp-native%S)))";
err = gcry_sexp_build (&s_skey, NULL, format, curve, skey[0], transfer_key); err = gcry_sexp_build (&s_skey, NULL, format, curve, skey[0], transfer_key);
} }