Commit 9ac98f68df for openssl.org

commit 9ac98f68df716fa85604be6b8fa623d00529e407
Author: Paul Dale <paul.dale@oracle.com>
Date:   Mon Nov 16 14:26:57 2026 +1100

    test: cover shared parameter names and both decoding paths

    Exercise cipher context getters and setters with both literal and shared
    parameter names. Check the default padding value, disable padding and read
    it back so ignored parameters cannot pass.

    Check shared name pointers and the public range predicate, including NULL,
    interior pointers, terminating NUL bytes and external copies.

    Assisted-by: ChatGPT:gpt-6-Sol
    Reviewed-by: Neil Horman <nhorman@openssl.org>
    Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
    Merge-date: Tue Nov 24 21:10:15 2026
    Merged-from: https://github.com/openssl/openssl/pull/33655

diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c
index d5dfcdb45a..a44683c059 100644
--- a/test/evp_extra_test.c
+++ b/test/evp_extra_test.c
@@ -7379,6 +7379,42 @@ err:
     return res;
 }

+static int test_cipher_param_decoding(int idx)
+{
+    EVP_CIPHER *cipher = NULL;
+    EVP_CIPHER_CTX *ctx = NULL;
+    unsigned int padding = 0;
+    const char *name = idx == 0 ? OSSL_CIPHER_PARAM_PADDING
+                                : OSSL_CIPHER_PARAM_padding;
+    OSSL_PARAM params[] = {
+        OSSL_PARAM_uint(name, &padding),
+        OSSL_PARAM_END
+    };
+    int ret = 0;
+
+    if (!TEST_ptr(cipher = EVP_CIPHER_fetch(testctx, "AES-128-CBC", testpropq))
+        || !TEST_ptr(ctx = EVP_CIPHER_CTX_new())
+        || !TEST_true(EVP_EncryptInit_ex2(ctx, cipher, NULL, NULL, NULL))
+        || !TEST_true(EVP_CIPHER_CTX_get_params(ctx, params))
+        || !TEST_uint_eq(padding, 1))
+        goto end;
+
+    padding = 0;
+    if (!TEST_true(EVP_CIPHER_CTX_set_params(ctx, params)))
+        goto end;
+
+    padding = 1;
+    if (!TEST_true(EVP_CIPHER_CTX_get_params(ctx, params))
+        || !TEST_uint_eq(padding, 0))
+        goto end;
+
+    ret = 1;
+end:
+    EVP_CIPHER_CTX_free(ctx);
+    EVP_CIPHER_free(cipher);
+    return ret;
+}
+
 enum cipher_param_list_type {
     CIPHER_ALGORITHM_PARAMS,
     CIPHER_GETTABLE_CTX_PARAMS,
@@ -9713,6 +9749,7 @@ int setup_tests(void)
     ADD_ALL_TESTS(test_iv_reuse, OSSL_NELEM(iv_state_ciphers));
     if (OSSL_NELEM(keylen_change_ciphers) - 1 > 0)
         ADD_ALL_TESTS(test_keylen_change, OSSL_NELEM(keylen_change_ciphers) - 1);
+    ADD_ALL_TESTS(test_cipher_param_decoding, 2);
     ADD_ALL_TESTS(test_cipher_param_types, OSSL_NELEM(cipher_param_tests));
 #if !defined(OPENSSL_NO_MULTIBLOCK)
     ADD_TEST(test_aes_cbc_hmac_sha_short_multiblock_aad);
diff --git a/test/params_api_test.c b/test/params_api_test.c
index 11565ac3e5..ddf3dd38c3 100644
--- a/test/params_api_test.c
+++ b/test/params_api_test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2026 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright (c) 2019, Oracle and/or its affiliates.  All rights reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
@@ -14,6 +14,7 @@
 #include "internal/endian.h"
 #include <openssl/params.h>
 #include <openssl/bn.h>
+#include <openssl/core_names.h>

 /* The maximum size of the static buffers used to test most things */
 #define MAX_LEN 20
@@ -919,6 +920,26 @@ err:
     return ret;
 }

+static int test_param_name_pointers(void)
+{
+    const char *const *padding = &OSSL_CIPHER_PARAM_padding;
+    const char *const *keylen = &OSSL_CIPHER_PARAM_keylen;
+    char padding_copy[] = OSSL_CIPHER_PARAM_PADDING;
+
+    return TEST_size_t_eq(sizeof(OSSL_CIPHER_PARAM_padding), sizeof(char *))
+        && TEST_str_eq(*padding, OSSL_CIPHER_PARAM_PADDING)
+        && TEST_str_eq(*keylen, OSSL_CIPHER_PARAM_KEYLEN)
+        && TEST_true(OSSL_PARAM_is_internal_name(*padding))
+        && TEST_true(OSSL_PARAM_is_internal_name(*keylen))
+        && TEST_true(OSSL_PARAM_is_internal_name(*padding + 1))
+        && TEST_true(OSSL_PARAM_is_internal_name(*padding + strlen(*padding)))
+        && TEST_false(OSSL_PARAM_is_internal_name(NULL))
+        && TEST_false(OSSL_PARAM_is_internal_name(padding_copy))
+        && TEST_false(OSSL_PARAM_is_internal_name(OSSL_CIPHER_PARAM_PADDING))
+        && TEST_ptr_eq(OSSL_ASYM_CIPHER_PARAM_digest,
+            OSSL_PKEY_PARAM_digest);
+}
+
 int setup_tests(void)
 {
     ADD_ALL_TESTS(test_param_int, OSSL_NELEM(raw_values));
@@ -939,5 +960,6 @@ int setup_tests(void)
     ADD_TEST(test_param_copy_null);
     ADD_TEST(test_param_merge);
     ADD_TEST(test_param_clear_free);
+    ADD_TEST(test_param_name_pointers);
     return 1;
 }