Path: blob/main/crypto/openssl/providers/nullprov.c
48150 views
/*1* Copyright 2020-2023 The OpenSSL Project Authors. All Rights Reserved.2*3* Licensed under the Apache License 2.0 (the "License"). You may not use4* this file except in compliance with the License. You can obtain a copy5* in the file LICENSE in the source distribution or at6* https://www.openssl.org/source/license.html7*/89#include <string.h>10#include <stdio.h>11#include <openssl/core.h>12#include <openssl/core_dispatch.h>13#include <openssl/core_names.h>14#include <openssl/params.h>15#include "prov/implementations.h"16#include "prov/providercommon.h"1718OSSL_provider_init_fn ossl_null_provider_init;1920/* Parameters we provide to the core */21static const OSSL_PARAM null_param_types[] = {22OSSL_PARAM_DEFN(OSSL_PROV_PARAM_NAME, OSSL_PARAM_UTF8_PTR, NULL, 0),23OSSL_PARAM_DEFN(OSSL_PROV_PARAM_VERSION, OSSL_PARAM_UTF8_PTR, NULL, 0),24OSSL_PARAM_DEFN(OSSL_PROV_PARAM_BUILDINFO, OSSL_PARAM_UTF8_PTR, NULL, 0),25OSSL_PARAM_DEFN(OSSL_PROV_PARAM_STATUS, OSSL_PARAM_INTEGER, NULL, 0),26OSSL_PARAM_END27};2829static const OSSL_PARAM *null_gettable_params(const OSSL_PROVIDER *prov)30{31return null_param_types;32}3334static int null_get_params(const OSSL_PROVIDER *provctx, OSSL_PARAM params[])35{36OSSL_PARAM *p;3738p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME);39if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL Null Provider"))40return 0;41p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_VERSION);42if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, OPENSSL_VERSION_STR))43return 0;44p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_BUILDINFO);45if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, OPENSSL_FULL_VERSION_STR))46return 0;47p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_STATUS);48if (p != NULL && !OSSL_PARAM_set_int(p, ossl_prov_is_running()))49return 0;50return 1;51}5253static const OSSL_ALGORITHM *null_query(OSSL_PROVIDER *prov,54int operation_id,55int *no_cache)56{57*no_cache = 0;58return NULL;59}6061/* Functions we provide to the core */62static const OSSL_DISPATCH null_dispatch_table[] = {63{ OSSL_FUNC_PROVIDER_GETTABLE_PARAMS, (void (*)(void))null_gettable_params },64{ OSSL_FUNC_PROVIDER_GET_PARAMS, (void (*)(void))null_get_params },65{ OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))null_query },66OSSL_DISPATCH_END67};6869int ossl_null_provider_init(const OSSL_CORE_HANDLE *handle,70const OSSL_DISPATCH *in,71const OSSL_DISPATCH **out,72void **provctx)73{74*out = null_dispatch_table;7576/* Could be anything - we don't use it */77*provctx = (void *)handle;78return 1;79}808182