Coverage Report

Created: 2026-10-28 06:28

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
104
{
22
104
    EVP_KEM *kem = (EVP_KEM *)data;
23
104
    int i;
24
25
104
    if (kem == NULL)
26
0
        return;
27
28
104
    CRYPTO_DOWN_REF(&kem->refcnt, &i);
29
104
    if (i > 0)
30
104
        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
447
{
39
447
    EVP_KEM *kem = (EVP_KEM *)data;
40
447
    int ref = 0;
41
42
447
    return CRYPTO_UP_REF(&kem->refcnt, &ref);
43
447
}
44
45
static int evp_kem_init(EVP_PKEY_CTX *ctx, int operation,
46
    const OSSL_PARAM params[], EVP_PKEY *authkey)
47
432
{
48
432
    int ret = 0;
49
432
    EVP_KEM *kem = NULL;
50
432
    EVP_KEYMGMT *tmp_keymgmt = NULL;
51
432
    const OSSL_PROVIDER *tmp_prov = NULL;
52
432
    void *provkey = NULL, *provauthkey = NULL;
53
432
    const char *supported_kem = NULL;
54
432
    int iter;
55
56
432
    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
432
    evp_pkey_ctx_free_old_ops(ctx);
62
432
    ctx->operation = operation;
63
64
432
    if (ctx->pkey == NULL) {
65
0
        ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
66
0
        goto err;
67
0
    }
68
432
    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
432
    if (!ossl_assert(ctx->pkey->keymgmt == NULL
76
432
            || ctx->pkey->keymgmt == ctx->keymgmt)) {
77
0
        ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
78
0
        goto err;
79
0
    }
80
432
    supported_kem = evp_keymgmt_util_query_operation_name(ctx->keymgmt,
81
432
        OSSL_OP_KEM);
82
432
    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
864
    for (iter = 1, provkey = NULL; iter < 3 && provkey == NULL; iter++) {
107
432
        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
432
        EVP_KEM_free(kem);
115
432
        kem = NULL;
116
432
        EVP_KEYMGMT_free(tmp_keymgmt);
117
432
        tmp_keymgmt = NULL;
118
119
432
        switch (iter) {
120
432
        case 1:
121
432
            kem = EVP_KEM_fetch(ctx->libctx, supported_kem, ctx->propquery);
122
432
            if (kem != NULL)
123
432
                tmp_prov = EVP_KEM_get0_provider(kem);
124
432
            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
432
        }
137
432
        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
432
        tmp_keymgmt_tofree = tmp_keymgmt = evp_keymgmt_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
150
432
            EVP_KEYMGMT_get0_name(ctx->keymgmt),
151
432
            ctx->propquery);
152
432
        if (tmp_keymgmt != NULL) {
153
432
            provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
154
432
                &tmp_keymgmt, ctx->propquery);
155
432
            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
432
        }
166
432
        if (tmp_keymgmt == NULL)
167
0
            EVP_KEYMGMT_free(tmp_keymgmt_tofree);
168
432
    }
169
170
432
    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
432
    ctx->op.encap.kem = kem;
177
432
    ctx->op.encap.algctx = kem->newctx(ossl_provider_ctx(kem->prov));
178
432
    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
432
    switch (operation) {
185
202
    case EVP_PKEY_OP_ENCAPSULATE:
186
202
        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
202
        } else if (provauthkey == NULL && kem->encapsulate_init != NULL) {
190
202
            ret = kem->encapsulate_init(ctx->op.encap.algctx, provkey, params);
191
202
        } 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
202
        break;
197
230
    case EVP_PKEY_OP_DECAPSULATE:
198
230
        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
230
        } else if (provauthkey == NULL && kem->decapsulate_init != NULL) {
202
230
            ret = kem->decapsulate_init(ctx->op.encap.algctx, provkey, params);
203
230
        } 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
230
        break;
209
230
    default:
210
0
        ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
211
0
        goto err;
212
432
    }
213
214
432
    EVP_KEYMGMT_free(tmp_keymgmt);
215
432
    tmp_keymgmt = NULL;
216
217
432
    if (ret > 0)
218
432
        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
432
}
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
202
{
238
202
    return evp_kem_init(ctx, EVP_PKEY_OP_ENCAPSULATE, params, NULL);
239
202
}
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
220
{
245
220
    if (ctx == NULL)
246
0
        return 0;
247
248
220
    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
220
    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
220
    if (out != NULL && secret == NULL)
259
0
        return 0;
260
261
220
    return ctx->op.encap.kem->encapsulate(ctx->op.encap.algctx,
262
220
        out, outlen, secret, secretlen);
263
220
}
264
265
int EVP_PKEY_decapsulate_init(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
266
230
{
267
230
    return evp_kem_init(ctx, EVP_PKEY_OP_DECAPSULATE, params, NULL);
268
230
}
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
263
{
282
263
    if (ctx == NULL
283
263
        || (in == NULL || inlen == 0)
284
263
        || (secret == NULL && secretlen == NULL))
285
0
        return 0;
286
287
263
    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
263
    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
263
    return ctx->op.encap.kem->decapsulate(ctx->op.encap.algctx,
297
263
        secret, secretlen, in, inlen);
298
263
}
299
300
static EVP_KEM *evp_kem_new(OSSL_PROVIDER *prov)
301
217
{
302
217
    EVP_KEM *kem = OPENSSL_zalloc(sizeof(EVP_KEM));
303
304
217
    if (kem == NULL)
305
0
        return NULL;
306
307
217
    if (!CRYPTO_NEW_REF(&kem->refcnt, 1)
308
217
        || !ossl_provider_up_ref(prov)) {
309
0
        CRYPTO_FREE_REF(&kem->refcnt);
310
0
        OPENSSL_free(kem);
311
0
        return NULL;
312
0
    }
313
217
    kem->prov = prov;
314
315
217
    return kem;
316
217
}
317
318
static void *evp_kem_from_algorithm(int name_id, const OSSL_ALGORITHM *algodef,
319
    OSSL_PROVIDER *prov, int no_store)
320
225
{
321
225
    const OSSL_DISPATCH *fns = algodef->implementation;
322
225
    EVP_KEM *kem = NULL;
323
225
    int ctxfncnt = 0, encfncnt = 0, decfncnt = 0;
324
225
    int gparamfncnt = 0, sparamfncnt = 0;
325
326
225
    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
225
    kem->name_id = name_id;
332
225
    kem->no_store = no_store;
333
334
225
    if ((kem->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL)
335
0
        goto err;
336
225
    kem->description = algodef->algorithm_description;
337
338
2.20k
    for (; fns->function_id != 0; fns++) {
339
1.98k
        switch (fns->function_id) {
340
225
        case OSSL_FUNC_KEM_NEWCTX:
341
225
            if (kem->newctx != NULL)
342
0
                break;
343
225
            kem->newctx = OSSL_FUNC_kem_newctx(fns);
344
225
            ctxfncnt++;
345
225
            break;
346
225
        case OSSL_FUNC_KEM_ENCAPSULATE_INIT:
347
225
            if (kem->encapsulate_init != NULL)
348
0
                break;
349
225
            kem->encapsulate_init = OSSL_FUNC_kem_encapsulate_init(fns);
350
225
            encfncnt++;
351
225
            break;
352
60
        case OSSL_FUNC_KEM_AUTH_ENCAPSULATE_INIT:
353
60
            if (kem->auth_encapsulate_init != NULL)
354
0
                break;
355
60
            kem->auth_encapsulate_init = OSSL_FUNC_kem_auth_encapsulate_init(fns);
356
60
            encfncnt++;
357
60
            break;
358
225
        case OSSL_FUNC_KEM_ENCAPSULATE:
359
225
            if (kem->encapsulate != NULL)
360
0
                break;
361
225
            kem->encapsulate = OSSL_FUNC_kem_encapsulate(fns);
362
225
            encfncnt++;
363
225
            break;
364
225
        case OSSL_FUNC_KEM_DECAPSULATE_INIT:
365
225
            if (kem->decapsulate_init != NULL)
366
0
                break;
367
225
            kem->decapsulate_init = OSSL_FUNC_kem_decapsulate_init(fns);
368
225
            decfncnt++;
369
225
            break;
370
60
        case OSSL_FUNC_KEM_AUTH_DECAPSULATE_INIT:
371
60
            if (kem->auth_decapsulate_init != NULL)
372
0
                break;
373
60
            kem->auth_decapsulate_init = OSSL_FUNC_kem_auth_decapsulate_init(fns);
374
60
            decfncnt++;
375
60
            break;
376
225
        case OSSL_FUNC_KEM_DECAPSULATE:
377
225
            if (kem->decapsulate != NULL)
378
0
                break;
379
225
            kem->decapsulate = OSSL_FUNC_kem_decapsulate(fns);
380
225
            decfncnt++;
381
225
            break;
382
225
        case OSSL_FUNC_KEM_FREECTX:
383
225
            if (kem->freectx != NULL)
384
0
                break;
385
225
            kem->freectx = OSSL_FUNC_kem_freectx(fns);
386
225
            ctxfncnt++;
387
225
            break;
388
20
        case OSSL_FUNC_KEM_DUPCTX:
389
20
            if (kem->dupctx != NULL)
390
0
                break;
391
20
            kem->dupctx = OSSL_FUNC_kem_dupctx(fns);
392
20
            break;
393
20
        case OSSL_FUNC_KEM_GET_CTX_PARAMS:
394
20
            if (kem->get_ctx_params != NULL)
395
0
                break;
396
20
            kem->get_ctx_params
397
20
                = OSSL_FUNC_kem_get_ctx_params(fns);
398
20
            gparamfncnt++;
399
20
            break;
400
20
        case OSSL_FUNC_KEM_GETTABLE_CTX_PARAMS:
401
20
            if (kem->gettable_ctx_params != NULL)
402
0
                break;
403
20
            kem->gettable_ctx_params
404
20
                = OSSL_FUNC_kem_gettable_ctx_params(fns);
405
20
            gparamfncnt++;
406
20
            break;
407
225
        case OSSL_FUNC_KEM_SET_CTX_PARAMS:
408
225
            if (kem->set_ctx_params != NULL)
409
0
                break;
410
225
            kem->set_ctx_params
411
225
                = OSSL_FUNC_kem_set_ctx_params(fns);
412
225
            sparamfncnt++;
413
225
            break;
414
225
        case OSSL_FUNC_KEM_SETTABLE_CTX_PARAMS:
415
225
            if (kem->settable_ctx_params != NULL)
416
0
                break;
417
225
            kem->settable_ctx_params
418
225
                = OSSL_FUNC_kem_settable_ctx_params(fns);
419
225
            sparamfncnt++;
420
225
            break;
421
1.98k
        }
422
1.98k
    }
423
225
    if (ctxfncnt != 2
424
225
        || (encfncnt != 0 && encfncnt != 2 && encfncnt != 3)
425
225
        || (decfncnt != 0 && decfncnt != 2 && decfncnt != 3)
426
225
        || (encfncnt != decfncnt)
427
225
        || (gparamfncnt != 0 && gparamfncnt != 2)
428
225
        || (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
225
    return kem;
445
0
err:
446
0
    evp_kem_free(kem);
447
0
    return NULL;
448
225
}
449
450
void EVP_KEM_free(EVP_KEM *kem)
451
464
{
452
#ifdef OPENSSL_NO_CACHED_FETCH
453
    evp_kem_free(kem);
454
#else
455
464
    if (kem != NULL && (kem->no_store != 0))
456
0
        evp_kem_free(kem);
457
464
#endif
458
464
}
459
460
int EVP_KEM_up_ref(EVP_KEM *kem)
461
52
{
462
#ifdef OPENSSL_NO_CACHED_FETCH
463
    return evp_kem_up_ref(kem);
464
#else
465
52
    if (kem->no_store != 0)
466
0
        return evp_kem_up_ref(kem);
467
52
    return 1;
468
52
#endif
469
52
}
470
471
OSSL_PROVIDER *EVP_KEM_get0_provider(const EVP_KEM *kem)
472
659
{
473
659
    return kem->prov;
474
659
}
475
476
EVP_KEM *EVP_KEM_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
477
    const char *properties)
478
432
{
479
432
    return evp_generic_fetch(ctx, OSSL_OP_KEM, algorithm, properties,
480
432
        evp_kem_from_algorithm,
481
432
        evp_kem_up_ref,
482
432
        evp_kem_free);
483
432
}
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
12
{
518
12
    struct EVP_KEM_do_all_provided_thunk t;
519
520
12
    t.fn = fn;
521
12
    t.arg = arg;
522
12
    evp_generic_do_all(libctx, OSSL_OP_KEM, EVP_KEM_do_all_provided_thunk, &t,
523
12
        evp_kem_from_algorithm,
524
12
        evp_kem_up_ref,
525
12
        evp_kem_free);
526
12
}
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
87
{
551
87
    void *provctx;
552
553
87
    if (kem == NULL || kem->settable_ctx_params == NULL)
554
0
        return NULL;
555
556
87
    provctx = ossl_provider_ctx(EVP_KEM_get0_provider(kem));
557
    return kem->settable_ctx_params(NULL, provctx);
558
87
}