* cipher/pubkey-util.c (_gcry_pk_util_data_to_mpi): Add support for PUBKEY_FLAG_BYTE_STRING. * src/cipher.h (PUBKEY_FLAG_BYTE_STRING): New.
Signed-off-by: NIIBE Yutaka <gni...@fsij.org> --- cipher/pubkey-util.c | 33 ++++++++++++++++++++++++++++++++- src/cipher.h | 1 + 2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/cipher/pubkey-util.c b/cipher/pubkey-util.c index 37a9f05b..e9d98c35 100644 --- a/cipher/pubkey-util.c +++ b/cipher/pubkey-util.c @@ -687,7 +687,7 @@ _gcry_pk_util_free_encoding_ctx (struct pk_encoding_ctx *ctx) HASH-ALGO is specific to OAEP, PSS and EDDSA. - LABEL is specific to OAEP. + LABEL is used for OAEP, RAW or RFC6979. SALT-LENGTH is for PSS, it is limited to 16384 bytes. @@ -738,6 +738,37 @@ _gcry_pk_util_data_to_mpi (gcry_sexp_t input, gcry_mpi_t *ret_mpi, rc = GPG_ERR_INV_OBJ; /* none or both given */ else if (unknown_flag) rc = GPG_ERR_INV_FLAG; + else if (ctx->encoding == PUBKEY_ENC_RAW + && (ctx->flags & PUBKEY_FLAG_BYTE_STRING)) + { + gcry_sexp_t list; + void *value; + size_t valuelen; + + if (!lvalue) + { + rc = GPG_ERR_INV_OBJ; + goto leave; + } + + /* Get optional LABEL. */ + list = sexp_find_token (ldata, "label", 0); + if (list) + { + ctx->label = sexp_nth_buffer (list, 1, &ctx->labellen); + sexp_release (list); + } + + /* Get VALUE. */ + value = sexp_nth_buffer (lvalue, 1, &valuelen); + if (!value) + rc = GPG_ERR_INV_OBJ; + if (rc) + goto leave; + + /* Note that mpi_set_opaque takes ownership of VALUE. */ + *ret_mpi = mpi_set_opaque (NULL, value, valuelen*8); + } else if (ctx->encoding == PUBKEY_ENC_RAW && ((parsed_flags & PUBKEY_FLAG_EDDSA) || (ctx->flags & PUBKEY_FLAG_EDDSA))) diff --git a/src/cipher.h b/src/cipher.h index 652bdd6f..dfcc9121 100644 --- a/src/cipher.h +++ b/src/cipher.h @@ -44,6 +44,7 @@ #define PUBKEY_FLAG_DJB_TWEAK (1 << 15) #define PUBKEY_FLAG_SM2 (1 << 16) #define PUBKEY_FLAG_PREHASH (1 << 17) +#define PUBKEY_FLAG_BYTE_STRING (1 << 18) /* * The internal flag to select least leak implementation for ECC. * It needs to be a distinct value not covered by PUBKEY_* above.
_______________________________________________ Gcrypt-devel mailing list Gcrypt-devel@gnupg.org https://lists.gnupg.org/mailman/listinfo/gcrypt-devel