1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

ecc-sos,gpg: Use sexp_extract_param_sos to get MPI.

* g10/export.c (sexp_extract_param_sos): Expose.
* g10/keygen.c (ecckey_from_sexp): Use it.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2020-06-04 18:16:27 +09:00
parent f71dff40ea
commit fb9e39dcc9
4 changed files with 10 additions and 16 deletions

View File

@ -63,7 +63,7 @@ fixup_when_ecc_private_key (unsigned char *buf, size_t *buflen_p)
s += n;
s0 = (unsigned char *)s;
n = snext (&s);
n0 = s - s0;
n0 = s - s0;
if (!n)
return gpg_error (GPG_ERR_INV_SEXP);
@ -78,7 +78,7 @@ fixup_when_ecc_private_key (unsigned char *buf, size_t *buflen_p)
buflen--;
numsize = snprintf (s0, s-s0+1, "%u:", (unsigned int)n);
memmove (s0+numsize, s+1, buflen - (s - buf));
memset (s0+numsize+buflen - (s - buf), 0, (n0 - numsize) + 1);
memset (s0+numsize+buflen - (s - buf), 0, (n0 - numsize) + 1);
buflen -= (n0 - numsize);
s = s0+numsize+n;
*buflen_p = buflen;

View File

@ -627,7 +627,7 @@ canon_pk_algo (enum gcry_pk_algos algo)
}
static gpg_error_t
gpg_error_t
sexp_extract_param_sos (gcry_sexp_t sexp, const char *param, gcry_mpi_t *r_sos)
{
gpg_error_t err;

View File

@ -1329,19 +1329,10 @@ ecckey_from_sexp (gcry_mpi_t *array, gcry_sexp_t sexp, int algo)
if (err)
goto leave;
l2 = gcry_sexp_find_token (list, "q", 0);
if (!l2)
{
err = gpg_error (GPG_ERR_NO_OBJ);
goto leave;
}
array[1] = gcry_sexp_nth_mpi (l2, 1, GCRYMPI_FMT_OPAQUE);
gcry_sexp_release (l2);
if (!array[1])
{
err = gpg_error (GPG_ERR_INV_OBJ);
goto leave;
}
err = sexp_extract_param_sos (list, "q", &array[1])
if (err)
goto leave;
gcry_sexp_release (list);
if (algo == PUBKEY_ALGO_ECDH)

View File

@ -415,6 +415,9 @@ void pop_export_filters (void);
int exact_subkey_match_p (KEYDB_SEARCH_DESC *desc, kbnode_t node);
gpg_error_t sexp_extract_param_sos (gcry_sexp_t sexp, const char *param,
gcry_mpi_t *r_sos);
int export_pubkeys (ctrl_t ctrl, strlist_t users, unsigned int options,
export_stats_t stats);
int export_seckeys (ctrl_t ctrl, strlist_t users, unsigned int options,