From 0ff53efc990cf820b4708a1b3c87c087f5bb1a19 Mon Sep 17 00:00:00 2001 From: Pauli Date: Mon, 21 Jul 2025 09:48:16 +1000 Subject: [PATCH] seed: update to use generated param handling Reviewed-by: Paul Yang Reviewed-by: Shane Lontis Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/28143) --- providers/implementations/rands/seed_src.c.in | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/providers/implementations/rands/seed_src.c.in b/providers/implementations/rands/seed_src.c.in index 1faab39138d..134b9b4bd08 100644 --- a/providers/implementations/rands/seed_src.c.in +++ b/providers/implementations/rands/seed_src.c.in @@ -6,6 +6,9 @@ * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ +{- +use OpenSSL::paramnames qw(produce_param_decoder); +-} #include #include @@ -17,6 +20,7 @@ #include #include #include +#include "internal/common.h" #include "prov/implementations.h" #include "prov/provider_ctx.h" #include "crypto/rand.h" @@ -141,21 +145,27 @@ static int seed_src_reseed(void *vseed, return 1; } +{- produce_param_decoder('seed_src_get_ctx_params', + (['RAND_PARAM_STATE', 'state', 'int'], + ['RAND_PARAM_STRENGTH', 'str', 'uint'], + ['RAND_PARAM_MAX_REQUEST', 'maxreq', 'size_t'], + )); -} + static int seed_src_get_ctx_params(void *vseed, OSSL_PARAM params[]) { PROV_SEED_SRC *s = (PROV_SEED_SRC *)vseed; - OSSL_PARAM *p; + struct seed_src_get_ctx_params_st p; + + if (s == NULL || !seed_src_get_ctx_params_decoder(params, &p)) + return 0; - p = OSSL_PARAM_locate(params, OSSL_RAND_PARAM_STATE); - if (p != NULL && !OSSL_PARAM_set_int(p, s->state)) + if (p.state != NULL && !OSSL_PARAM_set_int(p.state, s->state)) return 0; - p = OSSL_PARAM_locate(params, OSSL_RAND_PARAM_STRENGTH); - if (p != NULL && !OSSL_PARAM_set_int(p, 1024)) + if (p.str != NULL && !OSSL_PARAM_set_uint(p.str, 1024)) return 0; - p = OSSL_PARAM_locate(params, OSSL_RAND_PARAM_MAX_REQUEST); - if (p != NULL && !OSSL_PARAM_set_size_t(p, 128)) + if (p.maxreq != NULL && !OSSL_PARAM_set_size_t(p.maxreq, 128)) return 0; return 1; } @@ -163,13 +173,7 @@ static int seed_src_get_ctx_params(void *vseed, OSSL_PARAM params[]) static const OSSL_PARAM *seed_src_gettable_ctx_params(ossl_unused void *vseed, ossl_unused void *provctx) { - static const OSSL_PARAM known_gettable_ctx_params[] = { - OSSL_PARAM_int(OSSL_RAND_PARAM_STATE, NULL), - OSSL_PARAM_uint(OSSL_RAND_PARAM_STRENGTH, NULL), - OSSL_PARAM_size_t(OSSL_RAND_PARAM_MAX_REQUEST, NULL), - OSSL_PARAM_END - }; - return known_gettable_ctx_params; + return seed_src_get_ctx_params_list; } static int seed_src_verify_zeroization(ossl_unused void *vseed) -- 2.47.3