From b1a2e1904e0c694755f21b453e063173b4e474f5 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Thu, 28 Oct 2021 14:23:15 +0900 Subject: [PATCH] experiment: Fix exporting protecte secret key for new448. Signed-off-by: NIIBE Yutaka --- agent/cvt-openpgp.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/agent/cvt-openpgp.c b/agent/cvt-openpgp.c index 939b1d837..a8d11eb65 100644 --- a/agent/cvt-openpgp.c +++ b/agent/cvt-openpgp.c @@ -1477,6 +1477,27 @@ convert_to_openpgp (ctrl_t ctrl, gcry_sexp_t s_key, const char *passphrase, if (err) return err; + if (curve) + { + const char *curvename; + int pubkey_algo; + + curvename = gcry_sexp_nth_string (curve, 1); + + if (curvename && !strcmp (curvename, "Ed448")) + pubkey_algo = PUBKEY_ALGO_EDDSA; + else if (curvename && !strcmp (curvename, "X448")) + pubkey_algo = PUBKEY_ALGO_ECDH; + else + pubkey_algo = 0; + + if (pubkey_algo) + { + err = openpgp_fixup_key_448 (pubkey_algo, &array[0]); + err = openpgp_fixup_key_448 (pubkey_algo, &array[1]); + } + } + gcry_create_nonce (protect_iv, sizeof protect_iv); gcry_create_nonce (salt, sizeof salt); /* We need to use the encoded S2k count. It is not possible to