Coverage Report

Created: 2026-06-08 06:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/crypto/evp/asymcipher.c
Line
Count
Source
1
/*
2
 * Copyright 2006-2025 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_asym_cipher_free(void *data)
21
0
{
22
0
    EVP_ASYM_CIPHER_free(data);
23
0
}
24
25
static int evp_asym_cipher_up_ref(void *data)
26
0
{
27
0
    return EVP_ASYM_CIPHER_up_ref(data);
28
0
}
29
30
static int evp_pkey_asym_cipher_init(EVP_PKEY_CTX *ctx, int operation,
31
    const OSSL_PARAM params[])
32
0
{
33
0
    int ret = 0;
34
0
    void *provkey = NULL;
35
0
    EVP_ASYM_CIPHER *cipher = NULL;
36
0
    const char *desc;
37
0
    EVP_KEYMGMT *tmp_keymgmt = NULL;
38
0
    const OSSL_PROVIDER *tmp_prov = NULL;
39
0
    const char *supported_ciph = NULL;
40
0
    int iter;
41
42
0
    if (ctx == NULL) {
43
0
        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
44
0
        return -2;
45
0
    }
46
47
0
    evp_pkey_ctx_free_old_ops(ctx);
48
0
    ctx->operation = operation;
49
50
0
    ERR_set_mark();
51
52
0
    if (evp_pkey_ctx_is_legacy(ctx))
53
0
        goto err;
54
55
0
    if (ctx->pkey == NULL) {
56
0
        ERR_clear_last_mark();
57
0
        ERR_raise(ERR_LIB_EVP, EVP_R_NO_KEY_SET);
58
0
        goto err;
59
0
    }
60
61
    /*
62
     * Try to derive the supported asym cipher from |ctx->keymgmt|.
63
     */
64
0
    if (!ossl_assert(ctx->pkey->keymgmt == NULL
65
0
            || ctx->pkey->keymgmt == ctx->keymgmt)) {
66
0
        ERR_clear_last_mark();
67
0
        ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
68
0
        goto err;
69
0
    }
70
0
    supported_ciph
71
0
        = evp_keymgmt_util_query_operation_name(ctx->keymgmt,
72
0
            OSSL_OP_ASYM_CIPHER);
73
0
    if (supported_ciph == NULL) {
74
0
        ERR_clear_last_mark();
75
0
        ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
76
0
        goto err;
77
0
    }
78
79
    /*
80
     * We perform two iterations:
81
     *
82
     * 1.  Do the normal asym cipher fetch, using the fetching data given by
83
     *     the EVP_PKEY_CTX.
84
     * 2.  Do the provider specific asym cipher fetch, from the same provider
85
     *     as |ctx->keymgmt|
86
     *
87
     * We then try to fetch the keymgmt from the same provider as the
88
     * asym cipher, and try to export |ctx->pkey| to that keymgmt (when
89
     * this keymgmt happens to be the same as |ctx->keymgmt|, the export
90
     * is a no-op, but we call it anyway to not complicate the code even
91
     * more).
92
     * If the export call succeeds (returns a non-NULL provider key pointer),
93
     * we're done and can perform the operation itself.  If not, we perform
94
     * the second iteration, or jump to legacy.
95
     */
96
0
    for (iter = 1, provkey = NULL; iter < 3 && provkey == NULL; iter++) {
97
0
        EVP_KEYMGMT *tmp_keymgmt_tofree;
98
99
        /*
100
         * If we're on the second iteration, free the results from the first.
101
         * They are NULL on the first iteration, so no need to check what
102
         * iteration we're on.
103
         */
104
0
        EVP_ASYM_CIPHER_free(cipher);
105
0
        cipher = NULL;
106
0
        EVP_KEYMGMT_free(tmp_keymgmt);
107
0
        tmp_keymgmt = NULL;
108
109
0
        switch (iter) {
110
0
        case 1:
111
0
            cipher = EVP_ASYM_CIPHER_fetch(ctx->libctx, supported_ciph,
112
0
                ctx->propquery);
113
0
            if (cipher != NULL)
114
0
                tmp_prov = EVP_ASYM_CIPHER_get0_provider(cipher);
115
0
            break;
116
0
        case 2:
117
0
            tmp_prov = EVP_KEYMGMT_get0_provider(ctx->keymgmt);
118
0
            cipher = evp_asym_cipher_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
119
0
                supported_ciph, ctx->propquery);
120
0
            if (cipher == NULL)
121
0
                goto err;
122
0
            break;
123
0
        }
124
0
        if (cipher == NULL)
125
0
            continue;
126
127
        /*
128
         * Ensure that the key is provided, either natively, or as a cached
129
         * export.  We start by fetching the keymgmt with the same name as
130
         * |ctx->pkey|, but from the provider of the asym cipher method, using
131
         * the same property query as when fetching the asym cipher method.
132
         * With the keymgmt we found (if we did), we try to export |ctx->pkey|
133
         * to it (evp_pkey_export_to_provider() is smart enough to only actually
134
         * export it if |tmp_keymgmt| is different from |ctx->pkey|'s keymgmt)
135
         */
136
0
        tmp_keymgmt_tofree = tmp_keymgmt
137
0
            = evp_keymgmt_fetch_from_prov((OSSL_PROVIDER *)tmp_prov,
138
0
                EVP_KEYMGMT_get0_name(ctx->keymgmt),
139
0
                ctx->propquery);
140
0
        if (tmp_keymgmt != NULL)
141
0
            provkey = evp_pkey_export_to_provider(ctx->pkey, ctx->libctx,
142
0
                &tmp_keymgmt, ctx->propquery);
143
0
        if (tmp_keymgmt == NULL)
144
0
            EVP_KEYMGMT_free(tmp_keymgmt_tofree);
145
0
    }
146
147
0
    if (provkey == NULL) {
148
0
        EVP_ASYM_CIPHER_free(cipher);
149
0
        goto err;
150
0
    }
151
152
0
    ERR_pop_to_mark();
153
154
    /* No more legacy from here down to legacy: */
155
156
0
    ctx->op.ciph.cipher = cipher;
157
0
    ctx->op.ciph.algctx = cipher->newctx(ossl_provider_ctx(cipher->prov));
158
0
    if (ctx->op.ciph.algctx == NULL) {
159
        /* The provider key can stay in the cache */
160
0
        ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
161
0
        goto err;
162
0
    }
163
164
0
    desc = cipher->description != NULL ? cipher->description : "";
165
0
    switch (operation) {
166
0
    case EVP_PKEY_OP_ENCRYPT:
167
0
        if (cipher->encrypt_init == NULL) {
168
0
            ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_ASYM_CIPHER_NOT_SUPPORTED,
169
0
                "%s encrypt_init:%s", cipher->type_name, desc);
170
0
            ret = -2;
171
0
            goto err;
172
0
        }
173
0
        ret = cipher->encrypt_init(ctx->op.ciph.algctx, provkey, params);
174
0
        break;
175
0
    case EVP_PKEY_OP_DECRYPT:
176
0
        if (cipher->decrypt_init == NULL) {
177
0
            ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_ASYM_CIPHER_NOT_SUPPORTED,
178
0
                "%s decrypt_init:%s", cipher->type_name, desc);
179
0
            ret = -2;
180
0
            goto err;
181
0
        }
182
0
        ret = cipher->decrypt_init(ctx->op.ciph.algctx, provkey, params);
183
0
        break;
184
0
    default:
185
0
        ERR_raise(ERR_LIB_EVP, EVP_R_INITIALIZATION_ERROR);
186
0
        goto err;
187
0
    }
188
189
0
    if (ret <= 0)
190
0
        goto err;
191
0
    EVP_KEYMGMT_free(tmp_keymgmt);
192
0
    return 1;
193
194
0
err:
195
0
    if (ret <= 0) {
196
0
        evp_pkey_ctx_free_old_ops(ctx);
197
0
        ctx->operation = EVP_PKEY_OP_UNDEFINED;
198
0
    }
199
0
    EVP_KEYMGMT_free(tmp_keymgmt);
200
0
    return ret;
201
0
}
202
203
int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx)
204
0
{
205
0
    return evp_pkey_asym_cipher_init(ctx, EVP_PKEY_OP_ENCRYPT, NULL);
206
0
}
207
208
int EVP_PKEY_encrypt_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
209
0
{
210
0
    return evp_pkey_asym_cipher_init(ctx, EVP_PKEY_OP_ENCRYPT, params);
211
0
}
212
213
int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
214
    unsigned char *out, size_t *outlen,
215
    const unsigned char *in, size_t inlen)
216
0
{
217
0
    EVP_ASYM_CIPHER *cipher;
218
0
    const char *desc;
219
0
    int ret;
220
221
0
    if (ctx == NULL) {
222
0
        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
223
0
        return -2;
224
0
    }
225
226
0
    if (ctx->operation != EVP_PKEY_OP_ENCRYPT) {
227
0
        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_INITIALIZED);
228
0
        return -1;
229
0
    }
230
231
0
    if (ctx->op.ciph.algctx == NULL) {
232
0
        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
233
0
        return -2;
234
0
    }
235
0
    cipher = ctx->op.ciph.cipher;
236
0
    desc = cipher->description != NULL ? cipher->description : "";
237
0
    ERR_set_mark();
238
0
    ret = cipher->encrypt(ctx->op.ciph.algctx, out, outlen, (out == NULL ? 0 : *outlen), in, inlen);
239
0
    if (ret <= 0 && ERR_count_to_mark() == 0)
240
0
        ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_ASYM_CIPHER_FAILURE,
241
0
            "%s encrypt:%s", cipher->type_name, desc);
242
0
    ERR_clear_last_mark();
243
0
    return ret;
244
0
}
245
246
int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx)
247
0
{
248
0
    return evp_pkey_asym_cipher_init(ctx, EVP_PKEY_OP_DECRYPT, NULL);
249
0
}
250
251
int EVP_PKEY_decrypt_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[])
252
0
{
253
0
    return evp_pkey_asym_cipher_init(ctx, EVP_PKEY_OP_DECRYPT, params);
254
0
}
255
256
int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,
257
    unsigned char *out, size_t *outlen,
258
    const unsigned char *in, size_t inlen)
259
0
{
260
0
    EVP_ASYM_CIPHER *cipher;
261
0
    const char *desc;
262
0
    int ret;
263
264
0
    if (ctx == NULL) {
265
0
        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
266
0
        return -2;
267
0
    }
268
269
0
    if (ctx->operation != EVP_PKEY_OP_DECRYPT) {
270
0
        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_INITIALIZED);
271
0
        return -1;
272
0
    }
273
274
0
    if (ctx->op.ciph.algctx == NULL) {
275
0
        ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
276
0
        return -2;
277
0
    }
278
279
0
    cipher = ctx->op.ciph.cipher;
280
0
    desc = cipher->description != NULL ? cipher->description : "";
281
0
    ERR_set_mark();
282
0
    ret = cipher->decrypt(ctx->op.ciph.algctx, out, outlen, (out == NULL ? 0 : *outlen), in, inlen);
283
0
    if (ret <= 0 && ERR_count_to_mark() == 0)
284
0
        ERR_raise_data(ERR_LIB_EVP, EVP_R_PROVIDER_ASYM_CIPHER_FAILURE,
285
0
            "%s decrypt:%s", cipher->type_name, desc);
286
0
    ERR_clear_last_mark();
287
288
0
    return ret;
289
0
}
290
291
/* decrypt to new buffer of dynamic size, checking any pre-determined size */
292
int evp_pkey_decrypt_alloc(EVP_PKEY_CTX *ctx, unsigned char **outp,
293
    size_t *outlenp, size_t expected_outlen,
294
    const unsigned char *in, size_t inlen)
295
0
{
296
0
    if (EVP_PKEY_decrypt(ctx, NULL, outlenp, in, inlen) <= 0
297
0
        || (*outp = OPENSSL_malloc(*outlenp)) == NULL)
298
0
        return -1;
299
0
    if (EVP_PKEY_decrypt(ctx, *outp, outlenp, in, inlen) <= 0
300
0
        || *outlenp == 0
301
0
        || (expected_outlen != 0 && *outlenp != expected_outlen)) {
302
0
        ERR_raise(ERR_LIB_EVP, ERR_R_EVP_LIB);
303
0
        OPENSSL_clear_free(*outp, *outlenp);
304
0
        *outp = NULL;
305
0
        return 0;
306
0
    }
307
0
    return 1;
308
0
}
309
310
static EVP_ASYM_CIPHER *evp_asym_cipher_new(OSSL_PROVIDER *prov)
311
0
{
312
0
    EVP_ASYM_CIPHER *cipher = OPENSSL_zalloc(sizeof(EVP_ASYM_CIPHER));
313
314
0
    if (cipher == NULL)
315
0
        return NULL;
316
317
0
    if (!CRYPTO_NEW_REF(&cipher->refcnt, 1)
318
0
        || !ossl_provider_up_ref(prov)) {
319
0
        CRYPTO_FREE_REF(&cipher->refcnt);
320
0
        OPENSSL_free(cipher);
321
0
        return NULL;
322
0
    }
323
0
    cipher->prov = prov;
324
325
0
    return cipher;
326
0
}
327
328
static void *evp_asym_cipher_from_algorithm(int name_id,
329
    const OSSL_ALGORITHM *algodef,
330
    OSSL_PROVIDER *prov)
331
0
{
332
0
    const OSSL_DISPATCH *fns = algodef->implementation;
333
0
    EVP_ASYM_CIPHER *cipher = NULL;
334
0
    int ctxfncnt = 0, encfncnt = 0, decfncnt = 0;
335
0
    int gparamfncnt = 0, sparamfncnt = 0;
336
337
0
    if ((cipher = evp_asym_cipher_new(prov)) == NULL) {
338
0
        ERR_raise(ERR_LIB_EVP, ERR_R_EVP_LIB);
339
0
        goto err;
340
0
    }
341
342
0
    cipher->name_id = name_id;
343
0
    if ((cipher->type_name = ossl_algorithm_get1_first_name(algodef)) == NULL)
344
0
        goto err;
345
0
    cipher->description = algodef->algorithm_description;
346
347
0
    for (; fns->function_id != 0; fns++) {
348
0
        switch (fns->function_id) {
349
0
        case OSSL_FUNC_ASYM_CIPHER_NEWCTX:
350
0
            if (cipher->newctx != NULL)
351
0
                break;
352
0
            cipher->newctx = OSSL_FUNC_asym_cipher_newctx(fns);
353
0
            ctxfncnt++;
354
0
            break;
355
0
        case OSSL_FUNC_ASYM_CIPHER_ENCRYPT_INIT:
356
0
            if (cipher->encrypt_init != NULL)
357
0
                break;
358
0
            cipher->encrypt_init = OSSL_FUNC_asym_cipher_encrypt_init(fns);
359
0
            encfncnt++;
360
0
            break;
361
0
        case OSSL_FUNC_ASYM_CIPHER_ENCRYPT:
362
0
            if (cipher->encrypt != NULL)
363
0
                break;
364
0
            cipher->encrypt = OSSL_FUNC_asym_cipher_encrypt(fns);
365
0
            encfncnt++;
366
0
            break;
367
0
        case OSSL_FUNC_ASYM_CIPHER_DECRYPT_INIT:
368
0
            if (cipher->decrypt_init != NULL)
369
0
                break;
370
0
            cipher->decrypt_init = OSSL_FUNC_asym_cipher_decrypt_init(fns);
371
0
            decfncnt++;
372
0
            break;
373
0
        case OSSL_FUNC_ASYM_CIPHER_DECRYPT:
374
0
            if (cipher->decrypt != NULL)
375
0
                break;
376
0
            cipher->decrypt = OSSL_FUNC_asym_cipher_decrypt(fns);
377
0
            decfncnt++;
378
0
            break;
379
0
        case OSSL_FUNC_ASYM_CIPHER_FREECTX:
380
0
            if (cipher->freectx != NULL)
381
0
                break;
382
0
            cipher->freectx = OSSL_FUNC_asym_cipher_freectx(fns);
383
0
            ctxfncnt++;
384
0
            break;
385
0
        case OSSL_FUNC_ASYM_CIPHER_DUPCTX:
386
0
            if (cipher->dupctx != NULL)
387
0
                break;
388
0
            cipher->dupctx = OSSL_FUNC_asym_cipher_dupctx(fns);
389
0
            break;
390
0
        case OSSL_FUNC_ASYM_CIPHER_GET_CTX_PARAMS:
391
0
            if (cipher->get_ctx_params != NULL)
392
0
                break;
393
0
            cipher->get_ctx_params
394
0
                = OSSL_FUNC_asym_cipher_get_ctx_params(fns);
395
0
            gparamfncnt++;
396
0
            break;
397
0
        case OSSL_FUNC_ASYM_CIPHER_GETTABLE_CTX_PARAMS:
398
0
            if (cipher->gettable_ctx_params != NULL)
399
0
                break;
400
0
            cipher->gettable_ctx_params
401
0
                = OSSL_FUNC_asym_cipher_gettable_ctx_params(fns);
402
0
            gparamfncnt++;
403
0
            break;
404
0
        case OSSL_FUNC_ASYM_CIPHER_SET_CTX_PARAMS:
405
0
            if (cipher->set_ctx_params != NULL)
406
0
                break;
407
0
            cipher->set_ctx_params
408
0
                = OSSL_FUNC_asym_cipher_set_ctx_params(fns);
409
0
            sparamfncnt++;
410
0
            break;
411
0
        case OSSL_FUNC_ASYM_CIPHER_SETTABLE_CTX_PARAMS:
412
0
            if (cipher->settable_ctx_params != NULL)
413
0
                break;
414
0
            cipher->settable_ctx_params
415
0
                = OSSL_FUNC_asym_cipher_settable_ctx_params(fns);
416
0
            sparamfncnt++;
417
0
            break;
418
0
        }
419
0
    }
420
0
    if (ctxfncnt != 2
421
0
        || (encfncnt != 0 && encfncnt != 2)
422
0
        || (decfncnt != 0 && decfncnt != 2)
423
0
        || (encfncnt != 2 && decfncnt != 2)
424
0
        || (gparamfncnt != 0 && gparamfncnt != 2)
425
0
        || (sparamfncnt != 0 && sparamfncnt != 2)) {
426
        /*
427
         * In order to be a consistent set of functions we must have at least
428
         * a set of context functions (newctx and freectx) as well as a pair of
429
         * "cipher" functions: (encrypt_init, encrypt) or
430
         * (decrypt_init decrypt). set_ctx_params and settable_ctx_params are
431
         * optional, but if one of them is present then the other one must also
432
         * be present. The same applies to get_ctx_params and
433
         * gettable_ctx_params. The dupctx function is optional.
434
         */
435
0
        ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_PROVIDER_FUNCTIONS);
436
0
        goto err;
437
0
    }
438
439
0
    return cipher;
440
0
err:
441
0
    EVP_ASYM_CIPHER_free(cipher);
442
0
    return NULL;
443
0
}
444
445
void EVP_ASYM_CIPHER_free(EVP_ASYM_CIPHER *cipher)
446
0
{
447
0
    int i;
448
449
0
    if (cipher == NULL)
450
0
        return;
451
0
    CRYPTO_DOWN_REF(&cipher->refcnt, &i);
452
0
    if (i > 0)
453
0
        return;
454
0
    OPENSSL_free(cipher->type_name);
455
0
    ossl_provider_free(cipher->prov);
456
0
    CRYPTO_FREE_REF(&cipher->refcnt);
457
0
    OPENSSL_free(cipher);
458
0
}
459
460
int EVP_ASYM_CIPHER_up_ref(EVP_ASYM_CIPHER *cipher)
461
0
{
462
0
    int ref = 0;
463
464
0
    CRYPTO_UP_REF(&cipher->refcnt, &ref);
465
0
    return 1;
466
0
}
467
468
OSSL_PROVIDER *EVP_ASYM_CIPHER_get0_provider(const EVP_ASYM_CIPHER *cipher)
469
0
{
470
0
    return cipher->prov;
471
0
}
472
473
EVP_ASYM_CIPHER *EVP_ASYM_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
474
    const char *properties)
475
0
{
476
0
    return evp_generic_fetch(ctx, OSSL_OP_ASYM_CIPHER, algorithm, properties,
477
0
        evp_asym_cipher_from_algorithm,
478
0
        evp_asym_cipher_up_ref,
479
0
        evp_asym_cipher_free);
480
0
}
481
482
EVP_ASYM_CIPHER *evp_asym_cipher_fetch_from_prov(OSSL_PROVIDER *prov,
483
    const char *algorithm,
484
    const char *properties)
485
0
{
486
0
    return evp_generic_fetch_from_prov(prov, OSSL_OP_ASYM_CIPHER,
487
0
        algorithm, properties,
488
0
        evp_asym_cipher_from_algorithm,
489
0
        evp_asym_cipher_up_ref,
490
0
        evp_asym_cipher_free);
491
0
}
492
493
int EVP_ASYM_CIPHER_is_a(const EVP_ASYM_CIPHER *cipher, const char *name)
494
0
{
495
0
    return evp_is_a(cipher->prov, cipher->name_id, NULL, name);
496
0
}
497
498
int evp_asym_cipher_get_number(const EVP_ASYM_CIPHER *cipher)
499
0
{
500
0
    return cipher->name_id;
501
0
}
502
503
const char *EVP_ASYM_CIPHER_get0_name(const EVP_ASYM_CIPHER *cipher)
504
0
{
505
0
    return cipher->type_name;
506
0
}
507
508
const char *EVP_ASYM_CIPHER_get0_description(const EVP_ASYM_CIPHER *cipher)
509
0
{
510
0
    return cipher->description;
511
0
}
512
513
void EVP_ASYM_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx,
514
    void (*fn)(EVP_ASYM_CIPHER *cipher,
515
        void *arg),
516
    void *arg)
517
0
{
518
0
    struct EVP_ASYM_CIPHER_do_all_provided_thunk t;
519
520
0
    t.fn = fn;
521
0
    t.arg = arg;
522
0
    evp_generic_do_all(libctx, OSSL_OP_ASYM_CIPHER,
523
0
        EVP_ASYM_CIPHER_do_all_provided_thunk, &t,
524
0
        evp_asym_cipher_from_algorithm,
525
0
        evp_asym_cipher_up_ref,
526
0
        evp_asym_cipher_free);
527
0
}
528
529
int EVP_ASYM_CIPHER_names_do_all(const EVP_ASYM_CIPHER *cipher,
530
    void (*fn)(const char *name, void *data),
531
    void *data)
532
0
{
533
0
    if (cipher->prov != NULL)
534
0
        return evp_names_do_all(cipher->prov, cipher->name_id, fn, data);
535
536
0
    return 1;
537
0
}
538
539
const OSSL_PARAM *EVP_ASYM_CIPHER_gettable_ctx_params(const EVP_ASYM_CIPHER *cip)
540
0
{
541
0
    void *provctx;
542
543
0
    if (cip == NULL || cip->gettable_ctx_params == NULL)
544
0
        return NULL;
545
546
0
    provctx = ossl_provider_ctx(EVP_ASYM_CIPHER_get0_provider(cip));
547
0
    return cip->gettable_ctx_params(NULL, provctx);
548
0
}
549
550
const OSSL_PARAM *EVP_ASYM_CIPHER_settable_ctx_params(const EVP_ASYM_CIPHER *cip)
551
0
{
552
0
    void *provctx;
553
554
0
    if (cip == NULL || cip->settable_ctx_params == NULL)
555
0
        return NULL;
556
557
0
    provctx = ossl_provider_ctx(EVP_ASYM_CIPHER_get0_provider(cip));
558
    return cip->settable_ctx_params(NULL, provctx);
559
0
}