[PATCH 2/2] cipher: Support random-override with PUBKEY_FLAG_BYTE_STRING.
NIIBE Yutaka via Gcrypt-devel <[email protected]> Wed, 18 Jun 2025 16:39:11 +0900
| Newsgroups | gmane.comp.encryption.gpg.libgcrypt.devel |
|---|---|
| Message-ID | <085d6540a6dd2a1a5d2cfb64a0ef7c655a37b259.1750232293.git.gniibe@fsij.org> |
* cipher/pubkey-util.c (_gcry_pk_util_init_encoding_ctx): Initialize RND and RNDLEN field. (_gcry_pk_util_free_encoding_ctx): Release memory by RND field. (_gcry_pk_util_data_to_mpi): Support optional "random-override". * src/cipher.h (struct pk_encoding_ctx): Add RND and RNDLEN. -- Signed-off-by: NIIBE Yutaka <[email protected]> --- cipher/pubkey-util.c | 13 +++++++++++++ src/cipher.h | 4 ++++ 2 files changed, 17 insertions(+) _______________________________________________ Gcrypt-devel mailing list [email protected] https://lists.gnupg.org/mailman/listinfo/gcrypt-devel
0002-cipher-Support-random-override-with-PUBKEY_FLAG_BYTE.patch
(text/x-patch, 1.5 KB)
diff --git a/cipher/pubkey-util.c b/cipher/pubkey-util.c
index e9d98c35..71f4c508 100644
--- a/cipher/pubkey-util.c
+++ b/cipher/pubkey-util.c
@@ -650,6 +650,8 @@ _gcry_pk_util_init_encoding_ctx (struct pk_encoding_ctx *ctx,
}
ctx->label = NULL;
ctx->labellen = 0;
+ ctx->rnd = NULL;
+ ctx->rndlen = 0;
ctx->saltlen = 20;
ctx->verify_cmp = NULL;
ctx->verify_arg = NULL;
@@ -660,6 +662,7 @@ void
_gcry_pk_util_free_encoding_ctx (struct pk_encoding_ctx *ctx)
{
xfree (ctx->label);
+ xfree (ctx->rnd);
}
@@ -759,6 +762,14 @@ _gcry_pk_util_data_to_mpi (gcry_sexp_t input, gcry_mpi_t *ret_mpi,
sexp_release (list);
}
+ /* Get optional RANDOM-OVERRIDE. */
+ list = sexp_find_token (ldata, "random-override", 0);
+ if (list)
+ {
+ ctx->rnd = sexp_nth_buffer (list, 1, &ctx->rndlen);
+ sexp_release (list);
+ }
+
/* Get VALUE. */
value = sexp_nth_buffer (lvalue, 1, &valuelen);
if (!value)
@@ -1409,6 +1420,8 @@ _gcry_pk_util_data_to_mpi (gcry_sexp_t input, gcry_mpi_t *ret_mpi,
{
xfree (ctx->label);
ctx->label = NULL;
+ xfree (ctx->rnd);
+ ctx->rnd = NULL;
}
return rc;
diff --git a/src/cipher.h b/src/cipher.h
index dfcc9121..83c5c532 100644
--- a/src/cipher.h
+++ b/src/cipher.h
@@ -87,6 +87,10 @@ struct pk_encoding_ctx
/* for PSS */
size_t saltlen;
+ /* for deterministic signature */
+ unsigned char *rnd;
+ size_t rndlen;
+
int (* verify_cmp) (void *opaque, gcry_mpi_t tmp);
void *verify_arg;
};