Coverage Report

Created: 2026-09-12 06:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl41/crypto/evp/kem.c
Line
Count
Source
1
/*
2
 * Copyright 2020-2026 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 <stdio.h>
11
#include <stdlib.h>
12
#include <openssl/objects.h>
13
#include <openssl/evp.h>
14
#include "internal/cryptlib.h"
15
#include "internal/provider.h"
16
#include "internal/core.h"
17
#include "crypto/evp.h"
18
#include "evp_local.h"
19
20
static void evp_kem_free(void *data)
21
60
{
22
60
    EVP_KEM *kem = (EVP_KEM *)data;
23
60
    int i;
24
25
60
    if (kem == NULL)
26
0
        return;
27
28
60
    CRYPTO_DOWN_REF(&kem->refcnt, &i);
29
60
    if (i > 0)
30
60
        return;
31
0
    OPENSSL_free(kem->type_name);
32
0
    ossl_provider_free(kem->prov);
33
0
    CRYPTO_FREE_REF(&kem->refcnt);
34
0
    OPENSSL_free(kem);
35
0
}
36
37
static int evp_kem_up_ref(void *data)
38
423
{
39
423
    EVP_KEM *kem = (EVP_KEM *)data;
40
423
    int ref = 0;
41
42
423
    return CRYPTO_UP_REF(&kem->refcnt, &ref);
43
423
}
44
45
static int evp_kem_init(EVP_PKEY_CTX *ctx, int operation,
46
    const OSSL_PARAM params[], EVP_PKEY *authkey)
47
368
{
48
368
    int ret = 0;
49
368
    EVP_KEM *kem = NULL;
50
368
    EVP_KEYMGMT *tmp_keymgmt = NULL;
51
368
    const OSSL_PROVIDER *tmp_prov = NULL;
52
368
    void *provkey = NULL, *provauthkey = NULL;
53
368
    const char *supported_kem = NULL;
54
368
    int iter;
55
56
368
    if (ctx == NULL || ctx->keytype == NULL) {
57
0
        ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
58
0
        return 0;
59
0
    }
60
61
368
    evp_pkey_ctx_free_old_ops(ctx);
62
368
    ctx->operation = operation;
63
64
368
    if (ctx->pkey == NULL) {
65
0
        ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
66
0
        goto err;
67
0
    }
68
368
    if (authkey != NULL && authkey->type != ctx->pkey->type) {
69
0
        ERR_raise(ERR_LIB_EVP, EVP_R_DIFFERENT_KEY_TYPES);
70
0
        return 0;
71
0
    }
72
    /*
73
     * Try to derive the supported kem from |ctx->keymgmt|.
74
     */
75
368
    if (!ossl_assert(ctx->pkey->keymgmt == NULL
76
368
            || ctx->pkey->keymgmt == ctx->keymgmt)) {
77
0
        ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
78
0
        goto err;
79
0
    }
80
368
    supported_kem = evp_keymgmt_util_query_operation_name(ctx->keymgmt,
81
368
        OSSL_OP_KEM);
82
368
    if (supported_kem == NULL) {
83
0
        ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
84
0
        goto err;
85
0
    }
86
87
    /*
88
     * Because we cleared out old ops, we shouldn't need to worry about
89
     * checking if kem is already there.
90
     * We perform two iterations:
91
     *
92
     * 1.  Do the normal kem fetch, using the fetching data given by
93
     *     the EVP_PKEY_CTX.
94
     * 2.  Do the provider specific kem fetch, from the same provider
95
     *     as |ctx->keymgmt|
96
     *
97
     * We then try to fetch the keymgmt from the same provider as the
98
     * kem, and try to export |ctx->pkey| to that keymgmt (when this
99
     * keymgmt happens to be the same as |ctx->keymgmt|, the export is
100
     * a no-op, but we call it anyway to not complicate the code even
101
     * more).
102
     * If the export call succeeds (returns a non-NULL provider key pointer),
103
     * we're done and can perform the operation itself.  If not, we perform
104
     * the second iteration, or jump to legacy.
105
     */
106
736
    for (iter = 1, provkey = NULL; iter < 3 && provkey == NULL; iter++) {
107
368
        EVP_KEYMGMT *tmp_keymgmt_tofree = NULL;
108
109
        /*
110
         * If we're on the second iteration, free the results from the first.
111
         * They are NULL on the first iteration, so no need to check what
112
         * iteration we're on.
113
         */
114
368
        EVP_KEM_free(kem);
115
368
        kem = NULL;
116
368
        EVP_KEYMGMT_free(tmp_keymgmt);
117
368
        tmp_keymgmt = NULL;
118
119
368
        switch (iter) {
120
368
        case 1:
121
368
            kem = EVP_KEM_fetch(ctx->libctx, supported_kem, ctx->propquery);
122
368
            if (kem != NULL)
123
368
                tmp_prov = EVP_KEM_get0_provider(kem);
124
368
            break;
125
0
        case 2:
126
0
            tmp_prov = EVP_KEYMGMT_get0_provider(ctx->keymgmt);
127
0
            kem = evp_kem_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
128
0
                supported_kem, ctx->propquery);
129
130
0
            if (kem == NULL) {
131
0
                ERR_raise(ERR_LIB_EVP,
132
0
                    EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
133
0
                ret = -2;
134
0
                goto err;
135
0
            }
136
368
        }
137
368
        if (kem == NULL)
138
0
            continue;
139
140
        /*
141
         * Ensure that the key is provided, either natively, or as a cached
142
         * export.  We start by fetching the keymgmt with the same name as
143
         * |ctx->pkey|, but from the provider of the kem method, using the
144
         * same property query as when fetching the kem method.
145
         * With the keymgmt we found (if we did), we try to export |ctx->pkey|
146
         * to it (evp_pkey_export_to_provider() is smart enough to only actually
147
         * export it if |tmp_keymgmt| is different from |ctx->pkey|'s keymgmt)
148
         */
149
368
        tmp_keymgmt_tofree = tmp_keymgmt = evp_keymgmt_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
150
368
            EVP_KEYMGMT_get0_name(ctx->keymgmt),
151
368
            ctx->propquery);
152
368
        if (tmp_keymgmt != NULL) {
153
368
            provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
154
368
                &tmp_keymgmt, ctx->propquery);
155
368
            if (provkey != NULL && authkey != NULL) {
156
0
                provauthkey = evp_pkey_export_to_provider(authkey, ctx->libctx,
157
0
                    &tmp_keymgmt,
158
0
                    ctx->propquery);
159
0
                if (provauthkey == NULL) {
160
0
                    EVP_KEM_free(kem);
161
0
                    ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
162
0
                    goto err;
163
0
                }
164
0
            }
165
368
        }
166
368
        if (tmp_keymgmt == NULL)
167
0
            EVP_KEYMGMT_free(tmp_keymgmt_tofree);
168
368
    }
169
170
368
    if (provkey == NULL) {
171
0
        EVP_KEM_free(kem);
172
0
        ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
173
0
        goto err;
174
0
    }
175
176
368
    ctx->op.encap.kem = kem;
177
368
    ctx->op.encap.algctx = kem->newctx(ossl_provider_ctx(kem->prov));
178
368
    if (ctx->op.encap.algctx == NULL) {
179
        /* The provider key can stay in the cache */
180
0
        ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
181
0
        goto err;
182
0
    }
183
184
368
    switch (operation) {
185
207
    case EVP_PKEY_OP_ENCAPSULATE:
186
207
        if (provauthkey != NULL && kem->auth_encapsulate_init != NULL) {
187
0
            ret = kem->auth_encapsulate_init(ctx->op.encap.algctx, provkey,
188
0
                provauthkey, params);
189
207
        } else if (provauthkey == NULL && kem->encapsulate_init != NULL) {
190
207
            ret = kem->encapsulate_init(ctx->op.encap.algctx, provkey, params);
191
207
        } else {
192
0
            ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
193
0
            ret = -2;
194
0
            goto err;
195
0
        }
196
207
        break;
197
207
    case EVP_PKEY_OP_DECAPSULATE:
198
161
        if (provauthkey != NULL && kem->auth_decapsulate_init != NULL) {
199
0
            ret = kem->auth_decapsulate_init(ctx->op.encap.algctx, provkey,
200
0
                provauthkey, params);
201
161
        } else if (provauthkey == NULL && kem->decapsulate_init != NULL) {
202
161
            ret = kem->decapsulate_init(ctx->op.encap.algctx, provkey, params);
203
161
        } else {
204
0
            ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
205
0
            ret = -2;
206
0
            goto err;
207
0
        }
208
161
        break;
209
161
    default:
210
0
        ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
211
0
        goto err;
212
368
    }
213
214
368
    EVP_KEYMGMT_free(tmp_keymgmt);
215
368
    tmp_keymgmt = NULL;
216
217
368
    if (ret > 0)
218
368
        return 1;
219
0
err:
220
0
    if (ret <= 0) {
221
0
        evp_pkey_ctx_free_old_ops(ctx);
222
0
        ctx->operation = EVP_PKEY_OP_UNDEFINED;
223
0
    }
224
0
    EVP_KEYMGMT_free(tmp_keymgmt);
225
0
    return ret;
226
368
}
227
228
int EVP_PKEY_auth_encapsulate_init(EVP_PKEY_CTX *ctx, EVP_PKEY *authpriv,
229
    const OSSL_PARAM params[])
230
0
{
231
0
    if (authpriv == NULL)
232
0
        return 0;
233
0
    return evp_kem_init(ctx, EVP_PKEY_OP_ENCAPSULATE, params, authpriv);
234
0
}
235
236
int EVP_PKEY_encapsulate_init(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
237
207
{
238
207
    return evp_kem_init(ctx, EVP_PKEY_OP_ENCAPSULATE, params, NULL);
239
207
}
240
241
int EVP_PKEY_encapsulate(EVP_PKEY_CTX *ctx,
242
    unsigned char *out, size_t *outlen,
243
    unsigned char *secret, size_t *secretlen)
244
231
{
245
231
    if (ctx == NULL)
246
0
        return 0;
247
248
231
    if (ctx->operation != EVP_PKEY_OP_ENCAPSULATE) {
249
0
        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_INITIALIZED);
250
0
        return -1;
251
0
    }
252
253
231
    if (ctx->op.encap.algctx == NULL) {
254
0
        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
255
0
        return -2;
256
0
    }
257
258
231
    if (out != NULL && secret == NULL)
259
0
        return 0;
260
261
231
    return ctx->op.encap.kem->encapsulate(ctx->op.encap.algctx,
262
231
        out, outlen, secret, secretlen);
263
231
}
264
265
int EVP_PKEY_decapsulate_init(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
266
161
{
267
161
    return evp_kem_init(ctx, EVP_PKEY_OP_DECAPSULATE, params, NULL);
268
161
}
269
270
int EVP_PKEY_auth_decapsulate_init(EVP_PKEY_CTX *ctx, EVP_PKEY *authpub,
271
    const OSSL_PARAM params[])
272
0
{
273
0
    if (authpub == NULL)
274
0
        return 0;
275
0
    return evp_kem_init(ctx, EVP_PKEY_OP_DECAPSULATE, params, authpub);
276
0
}
277
278
int EVP_PKEY_decapsulate(EVP_PKEY_CTX *ctx,
279
    unsigned char *secret, size_t *secretlen,
280
    const unsigned char *in, size_t inlen)
281
163
{
282
163
    if (ctx == NULL
283
163
        || (in == NULL || inlen == 0)
284
163
        || (secret == NULL && secretlen == NULL))
285
0
        return 0;
286
287
163
    if (ctx->operation != EVP_PKEY_OP_DECAPSULATE) {
288
0
        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_INITIALIZED);
289
0
        return -1;
290
0
    }
291
292
163
    if (ctx->op.encap.algctx == NULL) {
293
0
        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
294
0
        return -2;
295
0
    }
296
163
    return ctx->op.encap.kem->decapsulate(ctx->op.encap.algctx,
297
163
        secret, secretlen, in, inlen);
298
163
}
299
300
static EVP_KEM *evp_kem_new(OSSL_PROVIDER *prov)
301
173
{
302
173
    EVP_KEM *kem = OPENSSL_zalloc(sizeof(EVP_KEM));
303
304
173
    if (kem == NULL)
305
0
        return NULL;
306
307
173
    if (!CRYPTO_NEW_REF(&kem->refcnt, 1)
308
173
        || !ossl_provider_up_ref(prov)) {
309
0
        CRYPTO_FREE_REF(&kem->refcnt);
310
0
        OPENSSL_free(kem);
311
0
        return NULL;
312
0
    }
313
173
    kem->prov = prov;
314
315
173
    return kem;
316
173
}
317
318
static void *evp_kem_from_algorithm(int name_id, const OSSL_ALGORITHM *algodef,
319
    OSSL_PROVIDER *prov, int no_store)
320
181
{
321
181
    const OSSL_DISPATCH *fns = algodef->implementation;
322
181
    EVP_KEM *kem = NULL;
323
181
    int ctxfncnt = 0, encfncnt = 0, decfncnt = 0;
324
181
    int gparamfncnt = 0, sparamfncnt = 0;
325
326
181
    if ((kem = evp_kem_new(prov)) == NULL) {
327
0
        ERR_raise(ERR_LIB_EVP, ERR_R_EVP_LIB);
328
0
        goto err;
329
0
    }
330
331
181
    kem->name_id = name_id;
332
181
    kem->no_store = no_store;
333
334
181
    if ((kem->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL)
335
0
        goto err;
336
181
    kem->description = algodef->algorithm_description;
337
338
1.78k
    for (; fns->function_id != 0; fns++) {
339
1.60k
        switch (fns->function_id) {
340
181
        case OSSL_FUNC_KEM_NEWCTX:
341
181
            if (kem->newctx != NULL)
342
0
                break;
343
181
            kem->newctx = OSSL_FUNC_kem_newctx(fns);
344
181
            ctxfncnt++;
345
181
            break;
346
181
        case OSSL_FUNC_KEM_ENCAPSULATE_INIT:
347
181
            if (kem->encapsulate_init != NULL)
348
0
                break;
349
181
            kem->encapsulate_init = OSSL_FUNC_kem_encapsulate_init(fns);
350
181
            encfncnt++;
351
181
            break;
352
51
        case OSSL_FUNC_KEM_AUTH_ENCAPSULATE_INIT:
353
51
            if (kem->auth_encapsulate_init != NULL)
354
0
                break;
355
51
            kem->auth_encapsulate_init = OSSL_FUNC_kem_auth_encapsulate_init(fns);
356
51
            encfncnt++;
357
51
            break;
358
181
        case OSSL_FUNC_KEM_ENCAPSULATE:
359
181
            if (kem->encapsulate != NULL)
360
0
                break;
361
181
            kem->encapsulate = OSSL_FUNC_kem_encapsulate(fns);
362
181
            encfncnt++;
363
181
            break;
364
181
        case OSSL_FUNC_KEM_DECAPSULATE_INIT:
365
181
            if (kem->decapsulate_init != NULL)
366
0
                break;
367
181
            kem->decapsulate_init = OSSL_FUNC_kem_decapsulate_init(fns);
368
181
            decfncnt++;
369
181
            break;
370
51
        case OSSL_FUNC_KEM_AUTH_DECAPSULATE_INIT:
371
51
            if (kem->auth_decapsulate_init != NULL)
372
0
                break;
373
51
            kem->auth_decapsulate_init = OSSL_FUNC_kem_auth_decapsulate_init(fns);
374
51
            decfncnt++;
375
51
            break;
376
181
        case OSSL_FUNC_KEM_DECAPSULATE:
377
181
            if (kem->decapsulate != NULL)
378
0
                break;
379
181
            kem->decapsulate = OSSL_FUNC_kem_decapsulate(fns);
380
181
            decfncnt++;
381
181
            break;
382
181
        case OSSL_FUNC_KEM_FREECTX:
383
181
            if (kem->freectx != NULL)
384
0
                break;
385
181
            kem->freectx = OSSL_FUNC_kem_freectx(fns);
386
181
            ctxfncnt++;
387
181
            break;
388
17
        case OSSL_FUNC_KEM_DUPCTX:
389
17
            if (kem->dupctx != NULL)
390
0
                break;
391
17
            kem->dupctx = OSSL_FUNC_kem_dupctx(fns);
392
17
            break;
393
17
        case OSSL_FUNC_KEM_GET_CTX_PARAMS:
394
17
            if (kem->get_ctx_params != NULL)
395
0
                break;
396
17
            kem->get_ctx_params
397
17
                = OSSL_FUNC_kem_get_ctx_params(fns);
398
17
            gparamfncnt++;
399
17
            break;
400
17
        case OSSL_FUNC_KEM_GETTABLE_CTX_PARAMS:
401
17
            if (kem->gettable_ctx_params != NULL)
402
0
                break;
403
17
            kem->gettable_ctx_params
404
17
                = OSSL_FUNC_kem_gettable_ctx_params(fns);
405
17
            gparamfncnt++;
406
17
            break;
407
181
        case OSSL_FUNC_KEM_SET_CTX_PARAMS:
408
181
            if (kem->set_ctx_params != NULL)
409
0
                break;
410
181
            kem->set_ctx_params
411
181
                = OSSL_FUNC_kem_set_ctx_params(fns);
412
181
            sparamfncnt++;
413
181
            break;
414
181
        case OSSL_FUNC_KEM_SETTABLE_CTX_PARAMS:
415
181
            if (kem->settable_ctx_params != NULL)
416
0
                break;
417
181
            kem->settable_ctx_params
418
181
                = OSSL_FUNC_kem_settable_ctx_params(fns);
419
181
            sparamfncnt++;
420
181
            break;
421
1.60k
        }
422
1.60k
    }
423
181
    if (ctxfncnt != 2
424
181
        || (encfncnt != 0 && encfncnt != 2 && encfncnt != 3)
425
181
        || (decfncnt != 0 && decfncnt != 2 && decfncnt != 3)
426
181
        || (encfncnt != decfncnt)
427
181
        || (gparamfncnt != 0 && gparamfncnt != 2)
428
181
        || (sparamfncnt != 0 && sparamfncnt != 2)) {
429
        /*
430
         * In order to be a consistent set of functions we must have at least
431
         * a set of context functions (newctx and freectx) as well as a pair
432
         * (or triplet) of "kem" functions:
433
         * (encapsulate_init, (and/or auth_encapsulate_init), encapsulate) or
434
         * (decapsulate_init, (and/or auth_decapsulate_init), decapsulate).
435
         * set_ctx_params and settable_ctx_params are optional, but if one of
436
         * them is present then the other one must also be present. The same
437
         * applies to get_ctx_params and gettable_ctx_params.
438
         * The dupctx function is optional.
439
         */
440
0
        ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_PROVIDER_FUNCTIONS);
441
0
        goto err;
442
0
    }
443
444
181
    return kem;
445
0
err:
446
0
    evp_kem_free(kem);
447
0
    return NULL;
448
181
}
449
450
void EVP_KEM_free(EVP_KEM *kem)
451
276
{
452
#ifdef OPENSSL_NO_CACHED_FETCH
453
    evp_kem_free(kem);
454
#else
455
276
    if (kem != NULL && (kem->no_store != 0))
456
0
        evp_kem_free(kem);
457
276
#endif
458
276
}
459
460
int EVP_KEM_up_ref(EVP_KEM *kem)
461
36
{
462
#ifdef OPENSSL_NO_CACHED_FETCH
463
    return evp_kem_up_ref(kem);
464
#else
465
36
    if (kem->no_store != 0)
466
0
        return evp_kem_up_ref(kem);
467
36
    return 1;
468
36
#endif
469
36
}
470
471
OSSL_PROVIDER *EVP_KEM_get0_provider(const EVP_KEM *kem)
472
545
{
473
545
    return kem->prov;
474
545
}
475
476
EVP_KEM *EVP_KEM_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
477
    const char *properties)
478
368
{
479
368
    return evp_generic_fetch(ctx, OSSL_OP_KEM, algorithm, properties,
480
368
        evp_kem_from_algorithm,
481
368
        evp_kem_up_ref,
482
368
        evp_kem_free);
483
368
}
484
485
EVP_KEM *evp_kem_fetch_from_prov(OSSL_PROVIDER *prov, const char *algorithm,
486
    const char *properties)
487
0
{
488
0
    return evp_generic_fetch_from_prov(prov, OSSL_OP_KEM, algorithm, properties,
489
0
        evp_kem_from_algorithm,
490
0
        evp_kem_up_ref,
491
0
        evp_kem_free);
492
0
}
493
494
int EVP_KEM_is_a(const EVP_KEM *kem, const char *name)
495
0
{
496
0
    return kem != NULL && evp_is_a(kem->prov, kem->name_id, NULL, name);
497
0
}
498
499
int evp_kem_get_number(const EVP_KEM *kem)
500
0
{
501
0
    return kem->name_id;
502
0
}
503
504
const char *EVP_KEM_get0_name(const EVP_KEM *kem)
505
0
{
506
0
    return kem->type_name;
507
0
}
508
509
const char *EVP_KEM_get0_description(const EVP_KEM *kem)
510
0
{
511
0
    return kem->description;
512
0
}
513
514
void EVP_KEM_do_all_provided(OSSL_LIB_CTX *libctx,
515
    void (*fn)(EVP_KEM *kem, void *arg),
516
    void *arg)
517
11
{
518
11
    struct EVP_KEM_do_all_provided_thunk t;
519
520
11
    t.fn = fn;
521
11
    t.arg = arg;
522
11
    evp_generic_do_all(libctx, OSSL_OP_KEM, EVP_KEM_do_all_provided_thunk, &t,
523
11
        evp_kem_from_algorithm,
524
11
        evp_kem_up_ref,
525
11
        evp_kem_free);
526
11
}
527
528
int EVP_KEM_names_do_all(const EVP_KEM *kem,
529
    void (*fn)(const char *name, void *data),
530
    void *data)
531
0
{
532
0
    if (kem->prov != NULL)
533
0
        return evp_names_do_all(kem->prov, kem->name_id, fn, data);
534
535
0
    return 1;
536
0
}
537
538
const OSSL_PARAM *EVP_KEM_gettable_ctx_params(const EVP_KEM *kem)
539
0
{
540
0
    void *provctx;
541
542
0
    if (kem == NULL || kem->gettable_ctx_params == NULL)
543
0
        return NULL;
544
545
0
    provctx = ossl_provider_ctx(EVP_KEM_get0_provider(kem));
546
0
    return kem->gettable_ctx_params(NULL, provctx);
547
0
}
548
549
const OSSL_PARAM *EVP_KEM_settable_ctx_params(const EVP_KEM *kem)
550
67
{
551
67
    void *provctx;
552
553
67
    if (kem == NULL || kem->settable_ctx_params == NULL)
554
0
        return NULL;
555
556
67
    provctx = ossl_provider_ctx(EVP_KEM_get0_provider(kem));
557
    return kem->settable_ctx_params(NULL, provctx);
558
67
}