]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test: support key options in the fake cipher provider
authorJakub Zelenka <jakub.zelenka@openssl.foundation>
Tue, 21 Jul 2026 22:11:24 +0000 (00:11 +0200)
committerNorbert Pocs <norbertp@openssl.org>
Mon, 27 Jul 2026 09:05:54 +0000 (11:05 +0200)
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 <paul.dale@oracle.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
MergeDate: Mon Jul 27 09:06:05 2026
(Merged from https://github.com/openssl/openssl/pull/32036)

test/fake_cipherprov.c

index ad28a6b94b7cb3b6754855facf4f4006312d4b2e..8f3a02e95bd7786213b336932e3414feecc85cff 100644 (file)
@@ -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
 };