/src/openssl31/providers/nullprov.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2020 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the Apache License 2.0 (the "License"). You may not use |
5 | | * this file except in compliance with the License. You can obtain a copy |
6 | | * in the file LICENSE in the source distribution or at |
7 | | * https://www.openssl.org/source/license.html |
8 | | */ |
9 | | |
10 | | #include <string.h> |
11 | | #include <stdio.h> |
12 | | #include <openssl/core.h> |
13 | | #include <openssl/core_dispatch.h> |
14 | | #include <openssl/core_names.h> |
15 | | #include <openssl/params.h> |
16 | | #include "prov/implementations.h" |
17 | | #include "prov/providercommon.h" |
18 | | |
19 | | OSSL_provider_init_fn ossl_null_provider_init; |
20 | | |
21 | | /* Parameters we provide to the core */ |
22 | | static const OSSL_PARAM null_param_types[] = { |
23 | | OSSL_PARAM_DEFN(OSSL_PROV_PARAM_NAME, OSSL_PARAM_UTF8_PTR, NULL, 0), |
24 | | OSSL_PARAM_DEFN(OSSL_PROV_PARAM_VERSION, OSSL_PARAM_UTF8_PTR, NULL, 0), |
25 | | OSSL_PARAM_DEFN(OSSL_PROV_PARAM_BUILDINFO, OSSL_PARAM_UTF8_PTR, NULL, 0), |
26 | | OSSL_PARAM_DEFN(OSSL_PROV_PARAM_STATUS, OSSL_PARAM_INTEGER, NULL, 0), |
27 | | OSSL_PARAM_END |
28 | | }; |
29 | | |
30 | | static const OSSL_PARAM *null_gettable_params(const OSSL_PROVIDER *prov) |
31 | 0 | { |
32 | 0 | return null_param_types; |
33 | 0 | } |
34 | | |
35 | | static int null_get_params(const OSSL_PROVIDER *provctx, OSSL_PARAM params[]) |
36 | 0 | { |
37 | 0 | OSSL_PARAM *p; |
38 | |
|
39 | 0 | p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME); |
40 | 0 | if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL Null Provider")) |
41 | 0 | return 0; |
42 | 0 | p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_VERSION); |
43 | 0 | if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, OPENSSL_VERSION_STR)) |
44 | 0 | return 0; |
45 | 0 | p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_BUILDINFO); |
46 | 0 | if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, OPENSSL_FULL_VERSION_STR)) |
47 | 0 | return 0; |
48 | 0 | p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_STATUS); |
49 | 0 | if (p != NULL && !OSSL_PARAM_set_int(p, ossl_prov_is_running())) |
50 | 0 | return 0; |
51 | 0 | return 1; |
52 | 0 | } |
53 | | |
54 | | static const OSSL_ALGORITHM *null_query(OSSL_PROVIDER *prov, |
55 | | int operation_id, |
56 | | int *no_cache) |
57 | 0 | { |
58 | 0 | *no_cache = 0; |
59 | 0 | return NULL; |
60 | 0 | } |
61 | | |
62 | | /* Functions we provide to the core */ |
63 | | static const OSSL_DISPATCH null_dispatch_table[] = { |
64 | | { OSSL_FUNC_PROVIDER_GETTABLE_PARAMS, (void (*)(void))null_gettable_params }, |
65 | | { OSSL_FUNC_PROVIDER_GET_PARAMS, (void (*)(void))null_get_params }, |
66 | | { OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))null_query }, |
67 | | { 0, NULL } |
68 | | }; |
69 | | |
70 | | int ossl_null_provider_init(const OSSL_CORE_HANDLE *handle, |
71 | | const OSSL_DISPATCH *in, |
72 | | const OSSL_DISPATCH **out, |
73 | | void **provctx) |
74 | 0 | { |
75 | 0 | *out = null_dispatch_table; |
76 | | |
77 | | /* Could be anything - we don't use it */ |
78 | 0 | *provctx = (void *)handle; |
79 | 0 | return 1; |
80 | 0 | } |