Some checks failed
GitHub CI / external-tests-oqs-provider (push) Has been cancelled
GitHub CI / out-of-readonly-source-and-install-ubuntu (push) Has been cancelled
GitHub CI / out-of-readonly-source-and-install-macos (push) Has been cancelled
GitHub CI / check_update (push) Has been cancelled
GitHub CI / check_docs (push) Has been cancelled
GitHub CI / check-c99 (push) Has been cancelled
GitHub CI / basic_gcc (push) Has been cancelled
GitHub CI / basic_clang (push) Has been cancelled
GitHub CI / linux-arm64 (push) Has been cancelled
GitHub CI / linux-x86 (push) Has been cancelled
GitHub CI / freebsd-x86_64 (push) Has been cancelled
GitHub CI / minimal (push) Has been cancelled
GitHub CI / no-deprecated (push) Has been cancelled
GitHub CI / no-shared-ubuntu (push) Has been cancelled
GitHub CI / no-shared-macos (push) Has been cancelled
GitHub CI / non-caching (push) Has been cancelled
GitHub CI / address_ub_sanitizer (push) Has been cancelled
GitHub CI / fuzz_tests (push) Has been cancelled
GitHub CI / memory_sanitizer (push) Has been cancelled
GitHub CI / external-tests-misc (push) Has been cancelled
GitHub CI / threads_sanitizer (push) Has been cancelled
GitHub CI / enable_non-default_options (push) Has been cancelled
GitHub CI / full_featured (push) Has been cancelled
GitHub CI / no-legacy (push) Has been cancelled
GitHub CI / legacy (push) Has been cancelled
GitHub CI / external-tests-pkcs11-provider (push) Has been cancelled
GitHub CI / external-tests-pyca (3.9) (push) Has been cancelled
Compiler Zoo CI / gcc (gcc-10) (push) Has been cancelled
Compiler Zoo CI / gcc (gcc-11) (push) Has been cancelled
Compiler Zoo CI / gcc (gcc-12) (push) Has been cancelled
Compiler Zoo CI / gcc (gcc-13) (push) Has been cancelled
Compiler Zoo CI / gcc (gcc-14) (push) Has been cancelled
Compiler Zoo CI / gcc (gcc-9) (push) Has been cancelled
Compiler Zoo CI / clang (clang-11) (push) Has been cancelled
Compiler Zoo CI / clang (clang-12) (push) Has been cancelled
Compiler Zoo CI / clang (clang-13) (push) Has been cancelled
Compiler Zoo CI / clang (clang-14) (push) Has been cancelled
Compiler Zoo CI / clang (clang-15) (push) Has been cancelled
Compiler Zoo CI / clang (clang-16) (push) Has been cancelled
Compiler Zoo CI / clang (clang-17) (push) Has been cancelled
Compiler Zoo CI / clang (clang-18) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:alpha-linux-gnu fips:no libs:libc6.1-dev-alpha-cross target:linux-alpha-gcc]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:arm-linux-gnueabi fips:no libs:libc6-dev-armel-cross target:linux-armv4 tests:-test_includes -test_store -test_x509_store]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:i386-pc-msdosdjgpp libs:libc-djgpp-dev libwatt-djgpp-dev djgpp-utils ppa:jwt27/djgpp-toolchain target:no-threads 386 DJGPP tests:none]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:m68k-linux-gnu fips:no libs:libc6-dev-m68k-cross target:-static -m68040 linux-latomic -Wno-stringop-overflow tests:-test_includes -test_store -test_x509_store]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:m68k-linux-gnu libs:libc6-dev-m68k-cross target:-mcfv4e -mxgot linux-latomic -Wno-stringop-overflow no-quic tests:none]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:mips-linux-gnu fips:no libs:libc6-dev-mips-cross target:-static linux-mips32 tests:-test_includes -test_store -test_x509_store]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:mips-linux-gnu libs:libc6-dev-mips-cross target:linux-mips32 tests:none]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:mips64-linux-gnuabi64 fips:no libs:libc6-dev-mips64-cross target:-static linux64-mips64]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:mips64-linux-gnuabi64 libs:libc6-dev-mips64-cross target:linux64-mips64 tests:none]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:mipsel-linux-gnu fips:no libs:libc6-dev-mipsel-cross target:linux-mips32 tests:-test_includes -test_store -test_x509_store]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:powerpc64le-linux-gnu fips:no libs:libc6-dev-ppc64el-cross target:linux-ppc64le]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:sparc64-linux-gnu libs:libc6-dev-sparc64-cross target:linux64-sparcv9 tests:none]) (push) Has been cancelled
Fuzz-checker CI / fuzz-checker (map[cc:clang-18 config:enable-fuzz-libfuzzer enable-asan enable-ubsan -fno-sanitize=function install:libfuzzer-18-dev libs:--with-fuzzer-lib=/usr/lib/llvm-18/lib/libFuzzer.a --with-fuzzer-include=/usr/include/clang/18/include/fuzzer linke… (push) Has been cancelled
Perl-minimal-checker CI / perl-minimal-checker (push) Has been cancelled
Compiler Zoo CI / clang (clang-19) (push) Has been cancelled
Compiler Zoo CI / clang (clang-20) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:aarch64-linux-gnu fips:no libs:libc6-dev-arm64-cross target:linux-aarch64]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:arm-linux-gnueabihf fips:no libs:libc6-dev-armhf-cross target:linux-armv4 tests:-test_includes -test_store -test_x509_store]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:hppa-linux-gnu fips:no libs:libc6-dev-hppa-cross target:-static -O1 linux-generic32 tests:-test_includes -test_store -test_x509_store]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:hppa-linux-gnu libs:libc6-dev-hppa-cross target:linux-generic32 tests:none]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:riscv64-linux-gnu fips:no libs:libc6-dev-riscv64-cross target:linux64-riscv64]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:s390x-linux-gnu fips:no libs:libc6-dev-s390x-cross target:linux64-s390x]) (push) Has been cancelled
Cross Compile / cross-compilation (map[arch:sh4-linux-gnu fips:no libs:libc6-dev-sh4-cross target:no-async linux-latomic tests:-test_includes -test_store -test_x509_store]) (push) Has been cancelled
Fuzz-checker CI / fuzz-checker (map[cc:afl-clang-fast config:enable-fuzz-afl no-module install:afl++ name:AFL]) (push) Has been cancelled
Fuzz-checker CI / fuzz-checker (map[cc:clang-18 config:enable-fuzz-libfuzzer enable-asan enable-ubsan -fno-sanitize=function -fsanitize-coverage=trace-cmp -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION extra:enable-fips enable-lms enable-ec_nistp_64_gcc_128 -fno-sanitize=al… (push) Has been cancelled
Cross Compile for RISC-V Extensions / cross-compilation-riscv (map[arch:riscv64-linux-gnu fips:no libs:libc6-dev-riscv64-cross opensslcaps:rv64gc_inlineasm opensslcapsname:riscvcap qemucpu:rv64,zbb=true,zbkb=true,zknh=true,zksh=true target:-march=rv64gc_zbb_zbkb_zknh_zksh linux64-riscv64]) (push) Has been cancelled
Cross Compile for RISC-V Extensions / cross-compilation-riscv (map[arch:riscv64-linux-gnu fips:no libs:libc6-dev-riscv64-cross opensslcaps:rv64gc_v_zbb opensslcapsname:riscvcap qemucpu:rv64,v=true,vlen=128,zbb=true,zvbb=false,zvkb=false target:linux64-riscv64]) (push) Has been cancelled
Cross Compile for RISC-V Extensions / cross-compilation-riscv (map[arch:riscv64-linux-gnu fips:no libs:libc6-dev-riscv64-cross opensslcaps:rv64gc_v_zvkb_zvbc opensslcapsname:riscvcap qemucpu:rv64,v=true,vlen=128,zvbb=true,zvbc=true,zvkg=false target:linux64-riscv64]) (push) Has been cancelled
Cross Compile for RISC-V Extensions / cross-compilation-riscv (map[arch:riscv64-linux-gnu fips:no libs:libc6-dev-riscv64-cross opensslcaps:rv64gc_v_zvkg opensslcapsname:riscvcap qemucpu:rv64,v=true,vlen=128,zvkg=true,zvbb=false target:linux64-riscv64]) (push) Has been cancelled
Cross Compile for RISC-V Extensions / cross-compilation-riscv (map[arch:riscv64-linux-gnu fips:no libs:libc6-dev-riscv64-cross opensslcaps:rv64gc_v_zvkned opensslcapsname:riscvcap qemucpu:rv64,v=true,vlen=128,zvkned=true,zvbb=false,zvkb=false,zvkg=false target:linux64-riscv64]) (push) Has been cancelled
Run-checker CI / run-checker (enable-trace enable-fips) (push) Has been cancelled
Cross Compile for RISC-V Extensions / cross-compilation-riscv (map[arch:riscv64-linux-gnu fips:no libs:libc6-dev-riscv64-cross opensslcaps:rv64gc_zba_zbb_zbc_zbs_zbkb_zbkc_zbkx_zknd_zkne_zknh_zksed_zksh_zkr_zkt_v_zvbb_zvbc_zvkb_zvkg_zvkned_zvknha_zvknhb_zvksed_zvksh opensslcapsname:riscvca… (push) Has been cancelled
Cross Compile for RISC-V Extensions / cross-compilation-riscv (map[arch:riscv64-linux-gnu fips:no libs:libc6-dev-riscv64-cross opensslcaps:rv64gc_zbb_zbc_zbkb_zknd_zkne opensslcapsname:riscvcap qemucpu:rv64,zbb=true,zbc=true,zbkb=true,zknd=true,zkne=true target:linux64-riscv64]) (push) Has been cancelled
Cross Compile for RISC-V Extensions / cross-compilation-riscv (map[arch:riscv64-linux-gnu fips:no libs:libc6-dev-riscv64-cross opensslcaps:rv64gc_zbc opensslcapsname:riscvcap qemucpu:rv64,zbc=true,zbb=false,zbkb=false target:linux64-riscv64]) (push) Has been cancelled
Cross Compile for RISC-V Extensions / cross-compilation-riscv (map[arch:riscv64-linux-gnu fips:no libs:libc6-dev-riscv64-cross opensslcaps:rv64gc_zbc_zbb opensslcapsname:riscvcap qemucpu:rv64,zbc=true,zbb=true,zbkb=false target:linux64-riscv64]) (push) Has been cancelled
Run-checker CI / run-checker (no-dh) (push) Has been cancelled
Run-checker CI / run-checker (no-sm2) (push) Has been cancelled
Run-checker CI / run-checker (no-sock) (push) Has been cancelled
Run-checker CI / run-checker (no-stdio) (push) Has been cancelled
Run-checker CI / run-checker (no-thread-pool) (push) Has been cancelled
Run-checker merge / run-checker (enable-ubsan no-asm -DOPENSSL_SMALL_FOOTPRINT -fno-sanitize=function) (push) Has been cancelled
Run-checker merge / run-checker (enable-weak-ssl-ciphers) (push) Has been cancelled
Run-checker merge / run-checker (enable-zlib) (push) Has been cancelled
Run-checker CI / run-checker (no-cmp) (push) Has been cancelled
Run-checker CI / run-checker (no-cms) (push) Has been cancelled
Run-checker CI / run-checker (no-default-thread-pool) (push) Has been cancelled
Run-checker CI / run-checker (no-dgram) (push) Has been cancelled
Run-checker CI / run-checker (no-dtls) (push) Has been cancelled
Run-checker CI / run-checker (no-ec) (push) Has been cancelled
Run-checker CI / run-checker (no-ecx) (push) Has been cancelled
Run-checker CI / run-checker (no-http) (push) Has been cancelled
Run-checker CI / run-checker (no-legacy) (push) Has been cancelled
Run-checker CI / run-checker (no-ml-dsa) (push) Has been cancelled
Run-checker CI / run-checker (no-ml-kem) (push) Has been cancelled
Run-checker CI / run-checker (no-quic) (push) Has been cancelled
Run-checker CI / run-checker (no-threads) (push) Has been cancelled
Run-checker CI / run-checker (no-tls) (push) Has been cancelled
Run-checker CI / run-checker (no-tls1_2) (push) Has been cancelled
Run-checker CI / run-checker (no-tls1_3) (push) Has been cancelled
Run-checker CI / run-checker (no-ui) (push) Has been cancelled
Run-checker merge / run-checker (enable-asan enable-ubsan no-shared no-asm -DOPENSSL_SMALL_FOOTPRINT -fno-sanitize=function) (push) Has been cancelled
Run-checker merge / run-checker (enable-pie) (push) Has been cancelled
Run-checker merge / run-checker (no-dso) (push) Has been cancelled
Run-checker merge / run-checker (no-ec2m enable-fips) (push) Has been cancelled
Run-checker merge / run-checker (no-err) (push) Has been cancelled
Run-checker merge / run-checker (no-filenames) (push) Has been cancelled
Run-checker merge / run-checker (no-integrity-only-ciphers) (push) Has been cancelled
Run-checker merge / run-checker (no-module) (push) Has been cancelled
Run-checker merge / run-checker (no-ocsp) (push) Has been cancelled
Run-checker merge / run-checker (no-pinshared) (push) Has been cancelled
Run-checker merge / run-checker (no-shared) (push) Has been cancelled
Run-checker merge / run-checker (no-srp) (push) Has been cancelled
Run-checker merge / run-checker (no-srtp) (push) Has been cancelled
Run-checker merge / run-checker (no-ts) (push) Has been cancelled
Run-checker merge / jitter (push) Has been cancelled
Run-checker merge / threads_sanitizer_atomic_fallback (push) Has been cancelled
Windows GitHub CI / shared (map[arch:amd64 config:enable-lms enable-fips no-thread-pool no-quic os:windows-2025 vcvars:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat]) (push) Has been cancelled
Windows GitHub CI / shared (map[arch:amd64 config:enable-lms enable-fips os:windows-2022 vcvars:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat]) (push) Has been cancelled
Windows GitHub CI / shared (map[arch:x86 config:no-fips enable-lms os:windows-2022 vcvars:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat]) (push) Has been cancelled
Windows GitHub CI / plain (push) Has been cancelled
Windows GitHub CI / minimal (push) Has been cancelled
Windows GitHub CI / cygwin (windows-2022, map[arch:win64 config:-DCMAKE_C_COMPILER=gcc --strict-warnings enable-demos no-fips]) (push) Has been cancelled
Windows Compression GitHub CI / zstd (push) Has been cancelled
Windows Compression GitHub CI / brotli (push) Has been cancelled
Reviewed-by: Saša Nedvědický <sashan@openssl.org> Reviewed-by: Neil Horman <nhorman@openssl.org> Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org> (Merged from https://github.com/openssl/openssl/pull/29242)
297 lines
7.8 KiB
C
297 lines
7.8 KiB
C
/*
|
|
* Copyright 2021-2023 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
|
|
* in the file LICENSE in the source distribution or at
|
|
* https://www.openssl.org/source/license.html
|
|
*/
|
|
|
|
#include <openssl/crypto.h>
|
|
#include <openssl/provider.h>
|
|
#include <openssl/decoder.h>
|
|
#include <openssl/encoder.h>
|
|
#include <openssl/store.h>
|
|
#include <openssl/rand.h>
|
|
#include <openssl/core_names.h>
|
|
#include "testutil.h"
|
|
|
|
static int dummy_decoder_decode(void *ctx, OSSL_CORE_BIO *cin, int selection,
|
|
OSSL_CALLBACK *object_cb, void *object_cbarg,
|
|
OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static const OSSL_DISPATCH dummy_decoder_functions[] = {
|
|
{ OSSL_FUNC_DECODER_DECODE, (void (*)(void))dummy_decoder_decode },
|
|
OSSL_DISPATCH_END
|
|
};
|
|
|
|
static const OSSL_ALGORITHM dummy_decoders[] = {
|
|
{ "DUMMY", "provider=dummy,input=pem", dummy_decoder_functions },
|
|
{ NULL, NULL, NULL }
|
|
};
|
|
|
|
static int dummy_encoder_encode(void *ctx, OSSL_CORE_BIO *out,
|
|
const void *obj_raw,
|
|
const OSSL_PARAM obj_abstract[], int selection,
|
|
OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static const OSSL_DISPATCH dummy_encoder_functions[] = {
|
|
{ OSSL_FUNC_DECODER_DECODE, (void (*)(void))dummy_encoder_encode },
|
|
OSSL_DISPATCH_END
|
|
};
|
|
|
|
static const OSSL_ALGORITHM dummy_encoders[] = {
|
|
{ "DUMMY", "provider=dummy,output=pem", dummy_encoder_functions },
|
|
{ NULL, NULL, NULL }
|
|
};
|
|
|
|
static void *dummy_store_open(void *provctx, const char *uri)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static int dummy_store_load(void *loaderctx, OSSL_CALLBACK *object_cb,
|
|
void *object_cbarg, OSSL_PASSPHRASE_CALLBACK *pw_cb,
|
|
void *pw_cbarg)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int dumm_store_eof(void *loaderctx)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int dummy_store_close(void *loaderctx)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static const OSSL_DISPATCH dummy_store_functions[] = {
|
|
{ OSSL_FUNC_STORE_OPEN, (void (*)(void))dummy_store_open },
|
|
{ OSSL_FUNC_STORE_LOAD, (void (*)(void))dummy_store_load },
|
|
{ OSSL_FUNC_STORE_EOF, (void (*)(void))dumm_store_eof },
|
|
{ OSSL_FUNC_STORE_CLOSE, (void (*)(void))dummy_store_close },
|
|
OSSL_DISPATCH_END
|
|
};
|
|
|
|
static const OSSL_ALGORITHM dummy_store[] = {
|
|
{ "DUMMY", "provider=dummy", dummy_store_functions },
|
|
{ NULL, NULL, NULL }
|
|
};
|
|
|
|
static void *dummy_rand_newctx(void *provctx, void *parent,
|
|
const OSSL_DISPATCH *parent_calls)
|
|
{
|
|
return provctx;
|
|
}
|
|
|
|
static void dummy_rand_freectx(void *vctx)
|
|
{
|
|
}
|
|
|
|
static int dummy_rand_instantiate(void *vdrbg, unsigned int strength,
|
|
int prediction_resistance,
|
|
const unsigned char *pstr, size_t pstr_len,
|
|
const OSSL_PARAM params[])
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
static int dummy_rand_uninstantiate(void *vdrbg)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
static int dummy_rand_generate(void *vctx, unsigned char *out, size_t outlen,
|
|
unsigned int strength, int prediction_resistance,
|
|
const unsigned char *addin, size_t addin_len)
|
|
{
|
|
size_t i;
|
|
|
|
for (i = 0; i < outlen; i++)
|
|
out[i] = (unsigned char)(i & 0xff);
|
|
|
|
return 1;
|
|
}
|
|
|
|
static const OSSL_PARAM *dummy_rand_gettable_ctx_params(void *vctx, void *provctx)
|
|
{
|
|
static const OSSL_PARAM known_gettable_ctx_params[] = {
|
|
OSSL_PARAM_size_t(OSSL_RAND_PARAM_MAX_REQUEST, NULL),
|
|
OSSL_PARAM_END
|
|
};
|
|
return known_gettable_ctx_params;
|
|
}
|
|
|
|
static int dummy_rand_get_ctx_params(void *vctx, OSSL_PARAM params[])
|
|
{
|
|
OSSL_PARAM *p;
|
|
|
|
p = OSSL_PARAM_locate(params, OSSL_RAND_PARAM_MAX_REQUEST);
|
|
if (p != NULL && !OSSL_PARAM_set_size_t(p, INT_MAX))
|
|
return 0;
|
|
|
|
return 1;
|
|
}
|
|
|
|
static int dummy_rand_enable_locking(void *vtest)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
static int dummy_rand_lock(void *vtest)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
static void dummy_rand_unlock(void *vtest)
|
|
{
|
|
}
|
|
|
|
static const OSSL_DISPATCH dummy_rand_functions[] = {
|
|
{ OSSL_FUNC_RAND_NEWCTX, (void (*)(void))dummy_rand_newctx },
|
|
{ OSSL_FUNC_RAND_FREECTX, (void (*)(void))dummy_rand_freectx },
|
|
{ OSSL_FUNC_RAND_INSTANTIATE, (void (*)(void))dummy_rand_instantiate },
|
|
{ OSSL_FUNC_RAND_UNINSTANTIATE, (void (*)(void))dummy_rand_uninstantiate },
|
|
{ OSSL_FUNC_RAND_GENERATE, (void (*)(void))dummy_rand_generate },
|
|
{ OSSL_FUNC_RAND_GETTABLE_CTX_PARAMS,
|
|
(void (*)(void))dummy_rand_gettable_ctx_params },
|
|
{ OSSL_FUNC_RAND_GET_CTX_PARAMS, (void (*)(void))dummy_rand_get_ctx_params },
|
|
{ OSSL_FUNC_RAND_ENABLE_LOCKING, (void (*)(void))dummy_rand_enable_locking },
|
|
{ OSSL_FUNC_RAND_LOCK, (void (*)(void))dummy_rand_lock },
|
|
{ OSSL_FUNC_RAND_UNLOCK, (void (*)(void))dummy_rand_unlock },
|
|
OSSL_DISPATCH_END
|
|
};
|
|
|
|
static const OSSL_ALGORITHM dummy_rand[] = {
|
|
{ "DUMMY", "provider=dummy", dummy_rand_functions },
|
|
{ NULL, NULL, NULL }
|
|
};
|
|
|
|
static const OSSL_ALGORITHM *dummy_query(void *provctx, int operation_id,
|
|
int *no_cache)
|
|
{
|
|
*no_cache = 0;
|
|
switch (operation_id) {
|
|
case OSSL_OP_DECODER:
|
|
return dummy_decoders;
|
|
case OSSL_OP_ENCODER:
|
|
return dummy_encoders;
|
|
case OSSL_OP_STORE:
|
|
return dummy_store;
|
|
case OSSL_OP_RAND:
|
|
return dummy_rand;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
static const OSSL_DISPATCH dummy_dispatch_table[] = {
|
|
{ OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))dummy_query },
|
|
{ OSSL_FUNC_PROVIDER_TEARDOWN, (void (*)(void))OSSL_LIB_CTX_free },
|
|
OSSL_DISPATCH_END
|
|
};
|
|
|
|
static int dummy_provider_init(const OSSL_CORE_HANDLE *handle,
|
|
const OSSL_DISPATCH *in,
|
|
const OSSL_DISPATCH **out,
|
|
void **provctx)
|
|
{
|
|
OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new_child(handle, in);
|
|
unsigned char buf[32];
|
|
|
|
*provctx = (void *)libctx;
|
|
*out = dummy_dispatch_table;
|
|
|
|
/*
|
|
* Do some work using the child libctx, to make sure this is possible from
|
|
* inside the init function.
|
|
*/
|
|
if (RAND_bytes_ex(libctx, buf, sizeof(buf), 0) <= 0)
|
|
return 0;
|
|
|
|
return 1;
|
|
}
|
|
|
|
/*
|
|
* Try fetching and freeing various things.
|
|
* Test 0: Decoder
|
|
* Test 1: Encoder
|
|
* Test 2: Store loader
|
|
* Test 3: EVP_RAND
|
|
* Test 4-7: As above, but additionally with a query string
|
|
*/
|
|
static int fetch_test(int tst)
|
|
{
|
|
OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new();
|
|
OSSL_PROVIDER *dummyprov = NULL;
|
|
OSSL_PROVIDER *nullprov = NULL;
|
|
OSSL_DECODER *decoder = NULL;
|
|
OSSL_ENCODER *encoder = NULL;
|
|
OSSL_STORE_LOADER *loader = NULL;
|
|
int testresult = 0;
|
|
unsigned char buf[32];
|
|
int query = tst > 3;
|
|
|
|
if (!TEST_ptr(libctx))
|
|
goto err;
|
|
|
|
if (!TEST_true(OSSL_PROVIDER_add_builtin(libctx, "dummy-prov",
|
|
dummy_provider_init))
|
|
|| !TEST_ptr(nullprov = OSSL_PROVIDER_load(libctx, "default"))
|
|
|| !TEST_ptr(dummyprov = OSSL_PROVIDER_load(libctx, "dummy-prov")))
|
|
goto err;
|
|
|
|
switch (tst % 4) {
|
|
case 0:
|
|
decoder = OSSL_DECODER_fetch(libctx, "DUMMY",
|
|
query ? "provider=dummy" : NULL);
|
|
if (!TEST_ptr(decoder))
|
|
goto err;
|
|
break;
|
|
case 1:
|
|
encoder = OSSL_ENCODER_fetch(libctx, "DUMMY",
|
|
query ? "provider=dummy" : NULL);
|
|
if (!TEST_ptr(encoder))
|
|
goto err;
|
|
break;
|
|
case 2:
|
|
loader = OSSL_STORE_LOADER_fetch(libctx, "DUMMY",
|
|
query ? "provider=dummy" : NULL);
|
|
if (!TEST_ptr(loader))
|
|
goto err;
|
|
break;
|
|
case 3:
|
|
if (!TEST_true(RAND_set_DRBG_type(libctx, "DUMMY",
|
|
query ? "provider=dummy" : NULL,
|
|
NULL, NULL))
|
|
|| !TEST_int_ge(RAND_bytes_ex(libctx, buf, sizeof(buf), 0), 1))
|
|
goto err;
|
|
break;
|
|
default:
|
|
goto err;
|
|
}
|
|
|
|
testresult = 1;
|
|
err:
|
|
OSSL_DECODER_free(decoder);
|
|
OSSL_ENCODER_free(encoder);
|
|
OSSL_STORE_LOADER_free(loader);
|
|
OSSL_PROVIDER_unload(dummyprov);
|
|
OSSL_PROVIDER_unload(nullprov);
|
|
OSSL_LIB_CTX_free(libctx);
|
|
return testresult;
|
|
}
|
|
|
|
int setup_tests(void)
|
|
{
|
|
ADD_ALL_TESTS(fetch_test, 8);
|
|
|
|
return 1;
|
|
}
|