diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2021-10-07 13:47:07 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2021-10-07 14:12:24 +0900 |
commit | 16a9eaad5d1add3a95b1da6e037b074f18b094c7 (patch) | |
tree | e322d4961d887c05b53ff8bdd9301fe5fb7e45b1 /cipher/pubkey-util.c | |
parent | 9fc0d145278d46bb129660a57b7ca2f94577d461 (diff) | |
download | libgcrypt-16a9eaad5d1add3a95b1da6e037b074f18b094c7.tar.gz |
cipher:dsa,ecdsa: Support supplying K externally.
* cipher/dsa.c (sign): Add an argument K for DSA.
(test_keys, dsa_sign): Follow the change.
* cipher/ecc-common.h (_gcry_ecc_ecdsa_sign): Likewise for ECDSA.
* cipher/ecc-ecdsa.c (_gcry_ecc_ecdsa_sign): Likewise for ECDSA.
* cipher/ecc.c (test_keys, ecc_sign): Follow the change.
* cipher/pubkey-util.c (_gcry_pk_util_data_to_mpi): Support "label"
for K.
--
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'cipher/pubkey-util.c')
-rw-r--r-- | cipher/pubkey-util.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/cipher/pubkey-util.c b/cipher/pubkey-util.c index e3daf53b..68defea6 100644 --- a/cipher/pubkey-util.c +++ b/cipher/pubkey-util.c @@ -843,6 +843,31 @@ _gcry_pk_util_data_to_mpi (gcry_sexp_t input, gcry_mpi_t *ret_mpi, goto leave; } + /* Get optional LABEL. */ + list = sexp_find_token (ldata, "label", 0); + if (list) + { + s = sexp_nth_data (list, 1, &n); + if (!s) + rc = GPG_ERR_NO_OBJ; + else if (n > 0) + { + ctx->label = xtrymalloc (n); + if (!ctx->label) + rc = gpg_err_code_from_syserror (); + else + { + memcpy (ctx->label, s, n); + ctx->labellen = n; + } + } + else + rc = GPG_ERR_INV_ARG; + sexp_release (list); + if (rc) + goto leave; + } + if ( !(value=sexp_nth_buffer (lvalue, 1, &valuelen)) || !valuelen ) rc = GPG_ERR_INV_OBJ; else if ((valuelen * 8) < valuelen) @@ -855,6 +880,31 @@ _gcry_pk_util_data_to_mpi (gcry_sexp_t input, gcry_mpi_t *ret_mpi, } else if (lhash) { + /* Get optional LABEL. */ + list = sexp_find_token (ldata, "label", 0); + if (list) + { + s = sexp_nth_data (list, 1, &n); + if (!s) + rc = GPG_ERR_NO_OBJ; + else if (n > 0) + { + ctx->label = xtrymalloc (n); + if (!ctx->label) + rc = gpg_err_code_from_syserror (); + else + { + memcpy (ctx->label, s, n); + ctx->labellen = n; + } + } + else + rc = GPG_ERR_INV_ARG; + sexp_release (list); + if (rc) + goto leave; + } + if (sexp_length (lhash) != 3) rc = GPG_ERR_INV_OBJ; else if ( !(s=sexp_nth_data (lhash, 1, &n)) || !n ) |