From: Jakub Zelenka Date: Tue, 21 Jul 2026 22:11:24 +0000 (+0200) Subject: test: support key options in the fake cipher provider X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=22f58fd9cce68d32deb8a08ba54fcf2d2eaf0135;p=thirdparty%2Fopenssl.git test: support key options in the fake cipher provider The fake cipher key management accepted a key name and raw key bytes on generation and import, but did not advertise them as settable parameters, so applications converting opt:value strings with OSSL_PARAM_allocate_from_text() had nothing to look them up in. Add the settable parameter table for both generation and import, and report the key name as the key id, so that setting it has an observable effect. Assisted-by: Claude:claude-opus-4-8 Reviewed-by: Paul Dale Reviewed-by: Dmitry Belyavskiy Reviewed-by: Daniel Kubec MergeDate: Mon Jul 27 09:06:05 2026 (Merged from https://github.com/openssl/openssl/pull/32036) --- diff --git a/test/fake_cipherprov.c b/test/fake_cipherprov.c index ad28a6b94b7..8f3a02e95bd 100644 --- a/test/fake_cipherprov.c +++ b/test/fake_cipherprov.c @@ -96,6 +96,27 @@ static void *fake_skeymgmt_generate(void *provctx, const OSSL_PARAM *params) return ctx; } +static const char *fake_skeymgmt_get_key_id(void *keydata) +{ + PROV_CIPHER_FAKE_CTX *ctx = (PROV_CIPHER_FAKE_CTX *)keydata; + + if (ctx == NULL || ctx->key_name[0] == '\0') + return NULL; + + return ctx->key_name; +} + +static const OSSL_PARAM fake_skeymgmt_known_settable_params[] = { + OSSL_PARAM_utf8_string(FAKE_CIPHER_PARAM_KEY_NAME, NULL, 0), + OSSL_PARAM_octet_string(OSSL_SKEY_PARAM_RAW_BYTES, NULL, 0), + OSSL_PARAM_END +}; + +static const OSSL_PARAM *fake_skeymgmt_settable_params(ossl_unused void *provctx) +{ + return fake_skeymgmt_known_settable_params; +} + static int fake_skeymgmt_export(void *keydata, int selection, OSSL_CALLBACK *param_callback, void *cbarg) { @@ -126,6 +147,11 @@ static const OSSL_DISPATCH fake_skeymgmt_funcs[] = { { OSSL_FUNC_SKEYMGMT_GENERATE, (void (*)(void))fake_skeymgmt_generate }, { OSSL_FUNC_SKEYMGMT_IMPORT, (void (*)(void))fake_skeymgmt_import }, { OSSL_FUNC_SKEYMGMT_EXPORT, (void (*)(void))fake_skeymgmt_export }, + { OSSL_FUNC_SKEYMGMT_GET_KEY_ID, (void (*)(void))fake_skeymgmt_get_key_id }, + { OSSL_FUNC_SKEYMGMT_IMP_SETTABLE_PARAMS, + (void (*)(void))fake_skeymgmt_settable_params }, + { OSSL_FUNC_SKEYMGMT_GEN_SETTABLE_PARAMS, + (void (*)(void))fake_skeymgmt_settable_params }, OSSL_DISPATCH_END };