if ((fnciphcnt != 0 && fnciphcnt != 3 && fnciphcnt != 4)
|| (fnciphcnt == 0 && cipher->ccipher == NULL && fnpipecnt == 0)
|| (fnpipecnt != 0 && (fnpipecnt < 3 || cipher->p_cupdate == NULL || cipher->p_cfinal == NULL))
- || fnctxcnt != 2) {
+ || fnctxcnt != 2
+ || cipher->get_params == NULL) {
/*
* In order to be a consistent set of functions we must have at least
* a complete set of "encrypt" functions, or a complete set of "decrypt"
- * functions, or a single "cipher" function. In all cases we need both
- * the "newctx" and "freectx" functions.
+ * functions, or a single "cipher" function.
*/
ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_PROVIDER_FUNCTIONS);
goto err;
=head1 COPYRIGHT
-Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2019-2026 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
INCLUDE[evp_libctx_test]=../include ../apps/include
DEPEND[evp_libctx_test]=../libcrypto.a libtestutil.a
- SOURCE[evp_fetch_prov_test]=evp_fetch_prov_test.c
+ SOURCE[evp_fetch_prov_test]=evp_fetch_prov_test.c fake_cipherprov.c
INCLUDE[evp_fetch_prov_test]=../include ../apps/include
DEPEND[evp_fetch_prov_test]=../libcrypto libtestutil.a
#include <openssl/provider.h>
#include "internal/sizes.h"
#include "testutil.h"
+#include "fake_cipherprov.h"
static char *config_file = NULL;
static char *alg = "digest";
return test_explicit_EVP_CIPHER_fetch("AES-128-CBC");
}
+/*
+ * Test that a provider cipher without get_params fails to fetch.
+ */
+static int test_cipher_no_getparams(void)
+{
+ int ret = 0;
+ OSSL_LIB_CTX *ctx = NULL;
+ OSSL_PROVIDER *fake_prov = NULL;
+ EVP_CIPHER *cipher = NULL;
+
+ ctx = OSSL_LIB_CTX_new();
+ if (!TEST_ptr(ctx))
+ return 0;
+
+ if (!TEST_ptr(fake_prov = fake_cipher_start(ctx)))
+ goto end;
+
+ /* Fetch must fail for a cipher that has no get_params */
+ cipher = EVP_CIPHER_fetch(ctx, FAKE_CIPHER_NO_GETPARAMS, FAKE_CIPHER_FETCH_PROPS);
+ if (!TEST_ptr_null(cipher))
+ goto end;
+
+ ret = 1;
+end:
+ EVP_CIPHER_free(cipher);
+ fake_cipher_finish(fake_prov);
+ OSSL_LIB_CTX_free(ctx);
+ return ret;
+}
+
/*
* idx 0: Allow names from OBJ_obj2txt()
* idx 1: Force an OID in text form from OBJ_obj2txt()
} else {
ADD_TEST(test_implicit_EVP_CIPHER_fetch);
ADD_TEST(test_explicit_EVP_CIPHER_fetch_by_name);
+ ADD_TEST(test_cipher_no_getparams);
ADD_ALL_TESTS_NOSUBTEST(test_explicit_EVP_CIPHER_fetch_by_X509_ALGOR, 2);
}
return 1;
/*
- * Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2024-2026 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
/*
- * Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2024-2026 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License");
* you may not use this file except in compliance with the License.
OSSL_DISPATCH_END
};
+static const OSSL_DISPATCH ossl_fake_no_getparams_functions[] = {
+ { OSSL_FUNC_CIPHER_NEWCTX,
+ (void (*)(void))fake_newctx },
+ { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))fake_freectx },
+ { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))fake_cipher },
+ OSSL_DISPATCH_END
+};
+
static const OSSL_ALGORITHM fake_cipher_algs[] = {
{ "fake_cipher", FAKE_CIPHER_FETCH_PROPS, ossl_fake_functions },
+ { FAKE_CIPHER_NO_GETPARAMS, FAKE_CIPHER_FETCH_PROPS,
+ ossl_fake_no_getparams_functions },
{ NULL, NULL, NULL }
};
/*
- * Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2024-2026 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
#define FAKE_PROV_NAME "fake-cipher"
#define FAKE_CIPHER_FETCH_PROPS "provider=fake-cipher"
+#define FAKE_CIPHER_NO_GETPARAMS "fake_cipher_no_getparams"
#define FAKE_CIPHER_PARAM_KEY_NAME "key_name"