1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-24 15:17:02 +01:00

ecc-sos: Fix exporting secret key for SOS.

* g10/export.c (transfer_format_to_openpgp): Use SOS.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2020-05-19 11:17:02 +09:00
parent 37aa23c55c
commit 705954149b

View File

@ -978,15 +978,15 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk)
value = gcry_sexp_nth_data (list, ++idx, &valuelen); value = gcry_sexp_nth_data (list, ++idx, &valuelen);
if (!value || !valuelen) if (!value || !valuelen)
goto bad_seckey; goto bad_seckey;
if (is_enc) if (is_enc
|| pk->pubkey_algo == PUBKEY_ALGO_EDDSA
|| pk->pubkey_algo == PUBKEY_ALGO_ECDH)
{ {
void *p = xtrymalloc (valuelen); skey[skeyidx] = gcry_mpi_set_opaque_copy (NULL, value, valuelen*8);
if (!p)
goto outofmem;
memcpy (p, value, valuelen);
skey[skeyidx] = gcry_mpi_set_opaque (NULL, p, valuelen*8);
if (!skey[skeyidx]) if (!skey[skeyidx])
goto outofmem; goto outofmem;
if (is_enc)
gcry_mpi_set_flag (skey[skeyidx], GCRYMPI_FLAG_USER1);
} }
else else
{ {
@ -1144,7 +1144,7 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk)
/* Check that the first secret key parameter in SKEY is encrypted /* Check that the first secret key parameter in SKEY is encrypted
and that there are no more secret key parameters. The latter is and that there are no more secret key parameters. The latter is
guaranteed by the v4 packet format. */ guaranteed by the v4 packet format. */
if (!gcry_mpi_get_flag (skey[npkey], GCRYMPI_FLAG_OPAQUE)) if (!gcry_mpi_get_flag (skey[npkey], GCRYMPI_FLAG_USER1))
goto bad_seckey; goto bad_seckey;
if (npkey+1 < DIM (skey) && skey[npkey+1]) if (npkey+1 < DIM (skey) && skey[npkey+1])
goto bad_seckey; goto bad_seckey;