Coverage Report

Created: 2025-12-31 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl30/providers/implementations/encode_decode/encode_key2any.c
Line
Count
Source
1
/*
2
 * Copyright 2020-2024 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
/*
11
 * Low level APIs are deprecated for public use, but still ok for internal use.
12
 */
13
#include "internal/deprecated.h"
14
15
#include <openssl/core.h>
16
#include <openssl/core_dispatch.h>
17
#include <openssl/core_names.h>
18
#include <openssl/crypto.h>
19
#include <openssl/params.h>
20
#include <openssl/asn1.h>
21
#include <openssl/err.h>
22
#include <openssl/pem.h>
23
#include <openssl/x509.h>
24
#include <openssl/pkcs12.h> /* PKCS8_encrypt() */
25
#include <openssl/dh.h>
26
#include <openssl/dsa.h>
27
#include <openssl/ec.h>
28
#include <openssl/proverr.h>
29
#include "internal/passphrase.h"
30
#include "internal/cryptlib.h"
31
#include "crypto/ecx.h"
32
#include "crypto/rsa.h"
33
#include "prov/implementations.h"
34
#include "prov/bio.h"
35
#include "prov/provider_ctx.h"
36
#include "prov/der_rsa.h"
37
#include "endecoder_local.h"
38
39
#if defined(OPENSSL_NO_DH) && defined(OPENSSL_NO_DSA) && defined(OPENSSL_NO_EC)
40
#define OPENSSL_NO_KEYPARAMS
41
#endif
42
43
struct key2any_ctx_st {
44
    PROV_CTX *provctx;
45
46
    /* Set to 0 if parameters should not be saved (dsa only) */
47
    int save_parameters;
48
49
    /* Set to 1 if intending to encrypt/decrypt, otherwise 0 */
50
    int cipher_intent;
51
52
    EVP_CIPHER *cipher;
53
54
    struct ossl_passphrase_data_st pwdata;
55
};
56
57
typedef int check_key_type_fn(const void *key, int nid);
58
typedef int key_to_paramstring_fn(const void *key, int nid, int save,
59
    void **str, int *strtype);
60
typedef int key_to_der_fn(BIO *out, const void *key,
61
    int key_nid, const char *pemname,
62
    key_to_paramstring_fn *p2s, i2d_of_void *k2d,
63
    struct key2any_ctx_st *ctx);
64
typedef int write_bio_of_void_fn(BIO *bp, const void *x);
65
66
/* Free the blob allocated during key_to_paramstring_fn */
67
static void free_asn1_data(int type, void *data)
68
1.44k
{
69
1.44k
    switch (type) {
70
1.18k
    case V_ASN1_OBJECT:
71
1.18k
        ASN1_OBJECT_free(data);
72
1.18k
        break;
73
260
    case V_ASN1_SEQUENCE:
74
260
        ASN1_STRING_free(data);
75
260
        break;
76
1.44k
    }
77
1.44k
}
78
79
static PKCS8_PRIV_KEY_INFO *key_to_p8info(const void *key, int key_nid,
80
    void *params, int params_type,
81
    i2d_of_void *k2d)
82
1.74k
{
83
    /* der, derlen store the key DER output and its length */
84
1.74k
    unsigned char *der = NULL;
85
1.74k
    int derlen;
86
    /* The final PKCS#8 info */
87
1.74k
    PKCS8_PRIV_KEY_INFO *p8info = NULL;
88
89
1.74k
    if ((p8info = PKCS8_PRIV_KEY_INFO_new()) == NULL
90
1.74k
        || (derlen = k2d(key, &der)) <= 0
91
300
        || !PKCS8_pkey_set0(p8info, OBJ_nid2obj(key_nid), 0,
92
1.44k
            params_type, params, der, derlen)) {
93
1.44k
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
94
1.44k
        PKCS8_PRIV_KEY_INFO_free(p8info);
95
1.44k
        OPENSSL_free(der);
96
1.44k
        p8info = NULL;
97
1.44k
    }
98
99
1.74k
    return p8info;
100
1.74k
}
101
102
static X509_SIG *p8info_to_encp8(PKCS8_PRIV_KEY_INFO *p8info,
103
    struct key2any_ctx_st *ctx)
104
0
{
105
0
    X509_SIG *p8 = NULL;
106
0
    char kstr[PEM_BUFSIZE];
107
0
    size_t klen = 0;
108
0
    OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(ctx->provctx);
109
110
0
    if (ctx->cipher == NULL)
111
0
        return NULL;
112
113
0
    if (!ossl_pw_get_passphrase(kstr, sizeof(kstr), &klen, NULL, 1,
114
0
            &ctx->pwdata)) {
115
0
        ERR_raise(ERR_LIB_PROV, PROV_R_UNABLE_TO_GET_PASSPHRASE);
116
0
        return NULL;
117
0
    }
118
    /* First argument == -1 means "standard" */
119
0
    p8 = PKCS8_encrypt_ex(-1, ctx->cipher, kstr, klen, NULL, 0, 0, p8info, libctx, NULL);
120
0
    OPENSSL_cleanse(kstr, klen);
121
0
    return p8;
122
0
}
123
124
static X509_SIG *key_to_encp8(const void *key, int key_nid,
125
    void *params, int params_type,
126
    i2d_of_void *k2d, struct key2any_ctx_st *ctx)
127
0
{
128
0
    PKCS8_PRIV_KEY_INFO *p8info = key_to_p8info(key, key_nid, params, params_type, k2d);
129
0
    X509_SIG *p8 = NULL;
130
131
0
    if (p8info == NULL) {
132
0
        free_asn1_data(params_type, params);
133
0
    } else {
134
0
        p8 = p8info_to_encp8(p8info, ctx);
135
0
        PKCS8_PRIV_KEY_INFO_free(p8info);
136
0
    }
137
0
    return p8;
138
0
}
139
140
static X509_PUBKEY *key_to_pubkey(const void *key, int key_nid,
141
    void *params, int params_type,
142
    i2d_of_void k2d)
143
0
{
144
    /* der, derlen store the key DER output and its length */
145
0
    unsigned char *der = NULL;
146
0
    int derlen;
147
    /* The final X509_PUBKEY */
148
0
    X509_PUBKEY *xpk = NULL;
149
150
0
    if ((xpk = X509_PUBKEY_new()) == NULL
151
0
        || (derlen = k2d(key, &der)) <= 0
152
0
        || !X509_PUBKEY_set0_param(xpk, OBJ_nid2obj(key_nid),
153
0
            params_type, params, der, derlen)) {
154
0
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
155
0
        X509_PUBKEY_free(xpk);
156
0
        OPENSSL_free(der);
157
0
        xpk = NULL;
158
0
    }
159
160
0
    return xpk;
161
0
}
162
163
/*
164
 * key_to_epki_* produce encoded output with the private key data in a
165
 * EncryptedPrivateKeyInfo structure (defined by PKCS#8).  They require
166
 * that there's an intent to encrypt, anything else is an error.
167
 *
168
 * key_to_pki_* primarly produce encoded output with the private key data
169
 * in a PrivateKeyInfo structure (also defined by PKCS#8).  However, if
170
 * there is an intent to encrypt the data, the corresponding key_to_epki_*
171
 * function is used instead.
172
 *
173
 * key_to_spki_* produce encoded output with the public key data in an
174
 * X.509 SubjectPublicKeyInfo.
175
 *
176
 * Key parameters don't have any defined envelopment of this kind, but are
177
 * included in some manner in the output from the functions described above,
178
 * either in the AlgorithmIdentifier's parameter field, or as part of the
179
 * key data itself.
180
 */
181
182
static int key_to_epki_der_priv_bio(BIO *out, const void *key,
183
    int key_nid,
184
    ossl_unused const char *pemname,
185
    key_to_paramstring_fn *p2s,
186
    i2d_of_void *k2d,
187
    struct key2any_ctx_st *ctx)
188
0
{
189
0
    int ret = 0;
190
0
    void *str = NULL;
191
0
    int strtype = V_ASN1_UNDEF;
192
0
    X509_SIG *p8;
193
194
0
    if (!ctx->cipher_intent)
195
0
        return 0;
196
197
0
    if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters, &str, &strtype))
198
0
        return 0;
199
200
0
    p8 = key_to_encp8(key, key_nid, str, strtype, k2d, ctx);
201
0
    if (p8 != NULL)
202
0
        ret = i2d_PKCS8_bio(out, p8);
203
204
0
    X509_SIG_free(p8);
205
206
0
    return ret;
207
0
}
208
209
static int key_to_epki_pem_priv_bio(BIO *out, const void *key,
210
    int key_nid,
211
    ossl_unused const char *pemname,
212
    key_to_paramstring_fn *p2s,
213
    i2d_of_void *k2d,
214
    struct key2any_ctx_st *ctx)
215
0
{
216
0
    int ret = 0;
217
0
    void *str = NULL;
218
0
    int strtype = V_ASN1_UNDEF;
219
0
    X509_SIG *p8;
220
221
0
    if (!ctx->cipher_intent)
222
0
        return 0;
223
224
0
    if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters, &str, &strtype))
225
0
        return 0;
226
227
0
    p8 = key_to_encp8(key, key_nid, str, strtype, k2d, ctx);
228
0
    if (p8 != NULL)
229
0
        ret = PEM_write_bio_PKCS8(out, p8);
230
231
0
    X509_SIG_free(p8);
232
233
0
    return ret;
234
0
}
235
236
static int key_to_pki_der_priv_bio(BIO *out, const void *key,
237
    int key_nid,
238
    ossl_unused const char *pemname,
239
    key_to_paramstring_fn *p2s,
240
    i2d_of_void *k2d,
241
    struct key2any_ctx_st *ctx)
242
1.74k
{
243
1.74k
    int ret = 0;
244
1.74k
    void *str = NULL;
245
1.74k
    int strtype = V_ASN1_UNDEF;
246
1.74k
    PKCS8_PRIV_KEY_INFO *p8info;
247
248
1.74k
    if (ctx->cipher_intent)
249
0
        return key_to_epki_der_priv_bio(out, key, key_nid, pemname,
250
0
            p2s, k2d, ctx);
251
252
1.74k
    if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters, &str, &strtype))
253
0
        return 0;
254
255
1.74k
    p8info = key_to_p8info(key, key_nid, str, strtype, k2d);
256
257
1.74k
    if (p8info != NULL)
258
300
        ret = i2d_PKCS8_PRIV_KEY_INFO_bio(out, p8info);
259
1.44k
    else
260
1.44k
        free_asn1_data(strtype, str);
261
262
1.74k
    PKCS8_PRIV_KEY_INFO_free(p8info);
263
264
1.74k
    return ret;
265
1.74k
}
266
267
static int key_to_pki_pem_priv_bio(BIO *out, const void *key,
268
    int key_nid,
269
    ossl_unused const char *pemname,
270
    key_to_paramstring_fn *p2s,
271
    i2d_of_void *k2d,
272
    struct key2any_ctx_st *ctx)
273
0
{
274
0
    int ret = 0;
275
0
    void *str = NULL;
276
0
    int strtype = V_ASN1_UNDEF;
277
0
    PKCS8_PRIV_KEY_INFO *p8info;
278
279
0
    if (ctx->cipher_intent)
280
0
        return key_to_epki_pem_priv_bio(out, key, key_nid, pemname,
281
0
            p2s, k2d, ctx);
282
283
0
    if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters, &str, &strtype))
284
0
        return 0;
285
286
0
    p8info = key_to_p8info(key, key_nid, str, strtype, k2d);
287
288
0
    if (p8info != NULL)
289
0
        ret = PEM_write_bio_PKCS8_PRIV_KEY_INFO(out, p8info);
290
0
    else
291
0
        free_asn1_data(strtype, str);
292
293
0
    PKCS8_PRIV_KEY_INFO_free(p8info);
294
295
0
    return ret;
296
0
}
297
298
static int key_to_spki_der_pub_bio(BIO *out, const void *key,
299
    int key_nid,
300
    ossl_unused const char *pemname,
301
    key_to_paramstring_fn *p2s,
302
    i2d_of_void *k2d,
303
    struct key2any_ctx_st *ctx)
304
0
{
305
0
    int ret = 0;
306
0
    void *str = NULL;
307
0
    int strtype = V_ASN1_UNDEF;
308
0
    X509_PUBKEY *xpk = NULL;
309
310
0
    if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters, &str, &strtype))
311
0
        return 0;
312
313
0
    xpk = key_to_pubkey(key, key_nid, str, strtype, k2d);
314
315
0
    if (xpk != NULL)
316
0
        ret = i2d_X509_PUBKEY_bio(out, xpk);
317
318
    /* Also frees |str| */
319
0
    X509_PUBKEY_free(xpk);
320
0
    return ret;
321
0
}
322
323
static int key_to_spki_pem_pub_bio(BIO *out, const void *key,
324
    int key_nid,
325
    ossl_unused const char *pemname,
326
    key_to_paramstring_fn *p2s,
327
    i2d_of_void *k2d,
328
    struct key2any_ctx_st *ctx)
329
0
{
330
0
    int ret = 0;
331
0
    void *str = NULL;
332
0
    int strtype = V_ASN1_UNDEF;
333
0
    X509_PUBKEY *xpk = NULL;
334
335
0
    if (p2s != NULL && !p2s(key, key_nid, ctx->save_parameters, &str, &strtype))
336
0
        return 0;
337
338
0
    xpk = key_to_pubkey(key, key_nid, str, strtype, k2d);
339
340
0
    if (xpk != NULL)
341
0
        ret = PEM_write_bio_X509_PUBKEY(out, xpk);
342
0
    else
343
0
        free_asn1_data(strtype, str);
344
345
    /* Also frees |str| */
346
0
    X509_PUBKEY_free(xpk);
347
0
    return ret;
348
0
}
349
350
/*
351
 * key_to_type_specific_* produce encoded output with type specific key data,
352
 * no envelopment; the same kind of output as the type specific i2d_ and
353
 * PEM_write_ functions, which is often a simple SEQUENCE of INTEGER.
354
 *
355
 * OpenSSL tries to discourage production of new keys in this form, because
356
 * of the ambiguity when trying to recognise them, but can't deny that PKCS#1
357
 * et al still are live standards.
358
 *
359
 * Note that these functions completely ignore p2s, and rather rely entirely
360
 * on k2d to do the complete work.
361
 */
362
static int key_to_type_specific_der_bio(BIO *out, const void *key,
363
    int key_nid,
364
    ossl_unused const char *pemname,
365
    key_to_paramstring_fn *p2s,
366
    i2d_of_void *k2d,
367
    struct key2any_ctx_st *ctx)
368
9.29k
{
369
9.29k
    unsigned char *der = NULL;
370
9.29k
    int derlen;
371
9.29k
    int ret;
372
373
9.29k
    if ((derlen = k2d(key, &der)) <= 0) {
374
1.44k
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
375
1.44k
        return 0;
376
1.44k
    }
377
378
7.85k
    ret = BIO_write(out, der, derlen);
379
7.85k
    OPENSSL_free(der);
380
7.85k
    return ret > 0;
381
9.29k
}
382
9.29k
#define key_to_type_specific_der_priv_bio key_to_type_specific_der_bio
383
0
#define key_to_type_specific_der_pub_bio key_to_type_specific_der_bio
384
0
#define key_to_type_specific_der_param_bio key_to_type_specific_der_bio
385
386
static int key_to_type_specific_pem_bio_cb(BIO *out, const void *key,
387
    int key_nid, const char *pemname,
388
    key_to_paramstring_fn *p2s,
389
    i2d_of_void *k2d,
390
    struct key2any_ctx_st *ctx,
391
    pem_password_cb *cb, void *cbarg)
392
0
{
393
0
    return PEM_ASN1_write_bio(k2d, pemname, out, key, ctx->cipher,
394
0
               NULL, 0, cb, cbarg)
395
0
        > 0;
396
0
}
397
398
static int key_to_type_specific_pem_priv_bio(BIO *out, const void *key,
399
    int key_nid, const char *pemname,
400
    key_to_paramstring_fn *p2s,
401
    i2d_of_void *k2d,
402
    struct key2any_ctx_st *ctx)
403
0
{
404
0
    return key_to_type_specific_pem_bio_cb(out, key, key_nid, pemname,
405
0
        p2s, k2d, ctx,
406
0
        ossl_pw_pem_password, &ctx->pwdata);
407
0
}
408
409
static int key_to_type_specific_pem_pub_bio(BIO *out, const void *key,
410
    int key_nid, const char *pemname,
411
    key_to_paramstring_fn *p2s,
412
    i2d_of_void *k2d,
413
    struct key2any_ctx_st *ctx)
414
0
{
415
0
    return key_to_type_specific_pem_bio_cb(out, key, key_nid, pemname,
416
0
        p2s, k2d, ctx, NULL, NULL);
417
0
}
418
419
#ifndef OPENSSL_NO_KEYPARAMS
420
static int key_to_type_specific_pem_param_bio(BIO *out, const void *key,
421
    int key_nid, const char *pemname,
422
    key_to_paramstring_fn *p2s,
423
    i2d_of_void *k2d,
424
    struct key2any_ctx_st *ctx)
425
0
{
426
0
    return key_to_type_specific_pem_bio_cb(out, key, key_nid, pemname,
427
0
        p2s, k2d, ctx, NULL, NULL);
428
0
}
429
#endif
430
431
/* ---------------------------------------------------------------------- */
432
433
#ifndef OPENSSL_NO_DH
434
static int prepare_dh_params(const void *dh, int nid, int save,
435
    void **pstr, int *pstrtype)
436
105
{
437
105
    ASN1_STRING *params = ASN1_STRING_new();
438
439
105
    if (params == NULL) {
440
0
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
441
0
        return 0;
442
0
    }
443
444
105
    if (nid == EVP_PKEY_DHX)
445
105
        params->length = i2d_DHxparams(dh, &params->data);
446
0
    else
447
0
        params->length = i2d_DHparams(dh, &params->data);
448
449
105
    if (params->length <= 0) {
450
0
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
451
0
        ASN1_STRING_free(params);
452
0
        return 0;
453
0
    }
454
105
    params->type = V_ASN1_SEQUENCE;
455
456
105
    *pstr = params;
457
105
    *pstrtype = V_ASN1_SEQUENCE;
458
105
    return 1;
459
105
}
460
461
static int dh_spki_pub_to_der(const void *dh, unsigned char **pder)
462
0
{
463
0
    const BIGNUM *bn = NULL;
464
0
    ASN1_INTEGER *pub_key = NULL;
465
0
    int ret;
466
467
0
    if ((bn = DH_get0_pub_key(dh)) == NULL) {
468
0
        ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);
469
0
        return 0;
470
0
    }
471
0
    if ((pub_key = BN_to_ASN1_INTEGER(bn, NULL)) == NULL) {
472
0
        ERR_raise(ERR_LIB_PROV, PROV_R_BN_ERROR);
473
0
        return 0;
474
0
    }
475
476
0
    ret = i2d_ASN1_INTEGER(pub_key, pder);
477
478
0
    ASN1_STRING_clear_free(pub_key);
479
0
    return ret;
480
0
}
481
482
static int dh_pki_priv_to_der(const void *dh, unsigned char **pder)
483
105
{
484
105
    const BIGNUM *bn = NULL;
485
105
    ASN1_INTEGER *priv_key = NULL;
486
105
    int ret;
487
488
105
    if ((bn = DH_get0_priv_key(dh)) == NULL) {
489
0
        ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);
490
0
        return 0;
491
0
    }
492
105
    if ((priv_key = BN_to_ASN1_INTEGER(bn, NULL)) == NULL) {
493
0
        ERR_raise(ERR_LIB_PROV, PROV_R_BN_ERROR);
494
0
        return 0;
495
0
    }
496
497
105
    ret = i2d_ASN1_INTEGER(priv_key, pder);
498
499
105
    ASN1_STRING_clear_free(priv_key);
500
105
    return ret;
501
105
}
502
503
0
#define dh_epki_priv_to_der dh_pki_priv_to_der
504
505
static int dh_type_specific_params_to_der(const void *dh, unsigned char **pder)
506
0
{
507
0
    if (DH_test_flags(dh, DH_FLAG_TYPE_DHX))
508
0
        return i2d_DHxparams(dh, pder);
509
0
    return i2d_DHparams(dh, pder);
510
0
}
511
512
/*
513
 * DH doesn't have i2d_DHPrivateKey or i2d_DHPublicKey, so we can't make
514
 * corresponding functions here.
515
 */
516
#define dh_type_specific_priv_to_der NULL
517
#define dh_type_specific_pub_to_der NULL
518
519
static int dh_check_key_type(const void *dh, int expected_type)
520
105
{
521
105
    int type = DH_test_flags(dh, DH_FLAG_TYPE_DHX) ? EVP_PKEY_DHX : EVP_PKEY_DH;
522
523
105
    return type == expected_type;
524
105
}
525
526
0
#define dh_evp_type EVP_PKEY_DH
527
105
#define dhx_evp_type EVP_PKEY_DHX
528
#define dh_input_type "DH"
529
#define dhx_input_type "DHX"
530
0
#define dh_pem_type "DH"
531
105
#define dhx_pem_type "X9.42 DH"
532
#endif
533
534
/* ---------------------------------------------------------------------- */
535
536
#ifndef OPENSSL_NO_DSA
537
static int encode_dsa_params(const void *dsa, int nid,
538
    void **pstr, int *pstrtype)
539
0
{
540
0
    ASN1_STRING *params = ASN1_STRING_new();
541
542
0
    if (params == NULL) {
543
0
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
544
0
        return 0;
545
0
    }
546
547
0
    params->length = i2d_DSAparams(dsa, &params->data);
548
549
0
    if (params->length <= 0) {
550
0
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
551
0
        ASN1_STRING_free(params);
552
0
        return 0;
553
0
    }
554
555
0
    *pstrtype = V_ASN1_SEQUENCE;
556
0
    *pstr = params;
557
0
    return 1;
558
0
}
559
560
static int prepare_dsa_params(const void *dsa, int nid, int save,
561
    void **pstr, int *pstrtype)
562
0
{
563
0
    const BIGNUM *p = DSA_get0_p(dsa);
564
0
    const BIGNUM *q = DSA_get0_q(dsa);
565
0
    const BIGNUM *g = DSA_get0_g(dsa);
566
567
0
    if (save && p != NULL && q != NULL && g != NULL)
568
0
        return encode_dsa_params(dsa, nid, pstr, pstrtype);
569
570
0
    *pstr = NULL;
571
0
    *pstrtype = V_ASN1_UNDEF;
572
0
    return 1;
573
0
}
574
575
static int dsa_spki_pub_to_der(const void *dsa, unsigned char **pder)
576
0
{
577
0
    const BIGNUM *bn = NULL;
578
0
    ASN1_INTEGER *pub_key = NULL;
579
0
    int ret;
580
581
0
    if ((bn = DSA_get0_pub_key(dsa)) == NULL) {
582
0
        ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);
583
0
        return 0;
584
0
    }
585
0
    if ((pub_key = BN_to_ASN1_INTEGER(bn, NULL)) == NULL) {
586
0
        ERR_raise(ERR_LIB_PROV, PROV_R_BN_ERROR);
587
0
        return 0;
588
0
    }
589
590
0
    ret = i2d_ASN1_INTEGER(pub_key, pder);
591
592
0
    ASN1_STRING_clear_free(pub_key);
593
0
    return ret;
594
0
}
595
596
static int dsa_pki_priv_to_der(const void *dsa, unsigned char **pder)
597
0
{
598
0
    const BIGNUM *bn = NULL;
599
0
    ASN1_INTEGER *priv_key = NULL;
600
0
    int ret;
601
602
0
    if ((bn = DSA_get0_priv_key(dsa)) == NULL) {
603
0
        ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);
604
0
        return 0;
605
0
    }
606
0
    if ((priv_key = BN_to_ASN1_INTEGER(bn, NULL)) == NULL) {
607
0
        ERR_raise(ERR_LIB_PROV, PROV_R_BN_ERROR);
608
0
        return 0;
609
0
    }
610
611
0
    ret = i2d_ASN1_INTEGER(priv_key, pder);
612
613
0
    ASN1_STRING_clear_free(priv_key);
614
0
    return ret;
615
0
}
616
617
0
#define dsa_epki_priv_to_der dsa_pki_priv_to_der
618
619
3.21k
#define dsa_type_specific_priv_to_der (i2d_of_void *)i2d_DSAPrivateKey
620
0
#define dsa_type_specific_pub_to_der (i2d_of_void *)i2d_DSAPublicKey
621
0
#define dsa_type_specific_params_to_der (i2d_of_void *)i2d_DSAparams
622
623
3.21k
#define dsa_check_key_type NULL
624
3.21k
#define dsa_evp_type EVP_PKEY_DSA
625
#define dsa_input_type "DSA"
626
3.21k
#define dsa_pem_type "DSA"
627
#endif
628
629
/* ---------------------------------------------------------------------- */
630
631
#ifndef OPENSSL_NO_EC
632
static int prepare_ec_explicit_params(const void *eckey,
633
    void **pstr, int *pstrtype)
634
260
{
635
260
    ASN1_STRING *params = ASN1_STRING_new();
636
637
260
    if (params == NULL) {
638
0
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
639
0
        return 0;
640
0
    }
641
642
260
    params->length = i2d_ECParameters(eckey, &params->data);
643
260
    if (params->length <= 0) {
644
0
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
645
0
        ASN1_STRING_free(params);
646
0
        return 0;
647
0
    }
648
649
260
    *pstrtype = V_ASN1_SEQUENCE;
650
260
    *pstr = params;
651
260
    return 1;
652
260
}
653
654
/*
655
 * This implements EcpkParameters, where the CHOICE is based on whether there
656
 * is a curve name (curve nid) to be found or not.  See RFC 3279 for details.
657
 */
658
static int prepare_ec_params(const void *eckey, int nid, int save,
659
    void **pstr, int *pstrtype)
660
1.44k
{
661
1.44k
    int curve_nid;
662
1.44k
    const EC_GROUP *group = EC_KEY_get0_group(eckey);
663
1.44k
    ASN1_OBJECT *params = NULL;
664
665
1.44k
    if (group == NULL)
666
0
        return 0;
667
1.44k
    curve_nid = EC_GROUP_get_curve_name(group);
668
1.44k
    if (curve_nid != NID_undef) {
669
1.18k
        params = OBJ_nid2obj(curve_nid);
670
1.18k
        if (params == NULL)
671
0
            return 0;
672
1.18k
    }
673
674
1.44k
    if (curve_nid != NID_undef
675
1.18k
        && (EC_GROUP_get_asn1_flag(group) & OPENSSL_EC_NAMED_CURVE)) {
676
        /* The CHOICE came to namedCurve */
677
1.18k
        if (OBJ_length(params) == 0) {
678
            /* Some curves might not have an associated OID */
679
0
            ERR_raise(ERR_LIB_PROV, PROV_R_MISSING_OID);
680
0
            ASN1_OBJECT_free(params);
681
0
            return 0;
682
0
        }
683
1.18k
        *pstr = params;
684
1.18k
        *pstrtype = V_ASN1_OBJECT;
685
1.18k
        return 1;
686
1.18k
    } else {
687
        /* The CHOICE came to ecParameters */
688
260
        return prepare_ec_explicit_params(eckey, pstr, pstrtype);
689
260
    }
690
1.44k
}
691
692
static int ec_spki_pub_to_der(const void *eckey, unsigned char **pder)
693
0
{
694
0
    if (EC_KEY_get0_public_key(eckey) == NULL) {
695
0
        ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);
696
0
        return 0;
697
0
    }
698
0
    return i2o_ECPublicKey(eckey, pder);
699
0
}
700
701
static int ec_pki_priv_to_der(const void *veckey, unsigned char **pder)
702
1.44k
{
703
1.44k
    EC_KEY *eckey = (EC_KEY *)veckey;
704
1.44k
    unsigned int old_flags;
705
1.44k
    int ret = 0;
706
707
    /*
708
     * For PKCS8 the curve name appears in the PKCS8_PRIV_KEY_INFO object
709
     * as the pkeyalg->parameter field. (For a named curve this is an OID)
710
     * The pkey field is an octet string that holds the encoded
711
     * ECPrivateKey SEQUENCE with the optional parameters field omitted.
712
     * We omit this by setting the EC_PKEY_NO_PARAMETERS flag.
713
     */
714
1.44k
    old_flags = EC_KEY_get_enc_flags(eckey); /* save old flags */
715
1.44k
    EC_KEY_set_enc_flags(eckey, old_flags | EC_PKEY_NO_PARAMETERS);
716
1.44k
    ret = i2d_ECPrivateKey(eckey, pder);
717
1.44k
    EC_KEY_set_enc_flags(eckey, old_flags); /* restore old flags */
718
1.44k
    return ret; /* return the length of the der encoded data */
719
1.44k
}
720
721
0
#define ec_epki_priv_to_der ec_pki_priv_to_der
722
723
0
#define ec_type_specific_params_to_der (i2d_of_void *)i2d_ECParameters
724
/* No ec_type_specific_pub_to_der, there simply is no such thing */
725
4.99k
#define ec_type_specific_priv_to_der (i2d_of_void *)i2d_ECPrivateKey
726
727
6.43k
#define ec_check_key_type NULL
728
6.43k
#define ec_evp_type EVP_PKEY_EC
729
#define ec_input_type "EC"
730
6.40k
#define ec_pem_type "EC"
731
732
#ifndef OPENSSL_NO_SM2
733
/*
734
 * Albeit SM2 is a slightly different algorithm than ECDSA, the key type
735
 * encoding (in all places where an AlgorithmIdentifier is produced, such
736
 * as PrivateKeyInfo and SubjectPublicKeyInfo) is the same as for ECC keys
737
 * according to the example in GM/T 0015-2012, appendix D.2.
738
 * This leaves the distinction of SM2 keys to the EC group (which is found
739
 * in AlgorithmIdentified.params).
740
 */
741
34
#define sm2_evp_type ec_evp_type
742
#define sm2_input_type "SM2"
743
34
#define sm2_pem_type "SM2"
744
#endif
745
#endif
746
747
/* ---------------------------------------------------------------------- */
748
749
#ifndef OPENSSL_NO_EC
750
26
#define prepare_ecx_params NULL
751
752
static int ecx_spki_pub_to_der(const void *vecxkey, unsigned char **pder)
753
0
{
754
0
    const ECX_KEY *ecxkey = vecxkey;
755
0
    unsigned char *keyblob;
756
757
0
    if (ecxkey == NULL) {
758
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
759
0
        return 0;
760
0
    }
761
762
0
    keyblob = OPENSSL_memdup(ecxkey->pubkey, ecxkey->keylen);
763
0
    if (keyblob == NULL) {
764
0
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
765
0
        return 0;
766
0
    }
767
768
0
    *pder = keyblob;
769
0
    return ecxkey->keylen;
770
0
}
771
772
static int ecx_pki_priv_to_der(const void *vecxkey, unsigned char **pder)
773
26
{
774
26
    const ECX_KEY *ecxkey = vecxkey;
775
26
    ASN1_OCTET_STRING oct;
776
26
    int keybloblen;
777
778
26
    if (ecxkey == NULL || ecxkey->privkey == NULL) {
779
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
780
0
        return 0;
781
0
    }
782
783
26
    oct.data = ecxkey->privkey;
784
26
    oct.length = ecxkey->keylen;
785
26
    oct.flags = 0;
786
787
26
    keybloblen = i2d_ASN1_OCTET_STRING(&oct, pder);
788
26
    if (keybloblen < 0) {
789
0
        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
790
0
        return 0;
791
0
    }
792
793
26
    return keybloblen;
794
26
}
795
796
0
#define ecx_epki_priv_to_der ecx_pki_priv_to_der
797
798
/*
799
 * ED25519, ED448, X25519 and X448 only has PKCS#8 / SubjectPublicKeyInfo
800
 * representation, so we don't define ecx_type_specific_[priv,pub,params]_to_der.
801
 */
802
803
26
#define ecx_check_key_type NULL
804
805
7
#define ed25519_evp_type EVP_PKEY_ED25519
806
4
#define ed448_evp_type EVP_PKEY_ED448
807
9
#define x25519_evp_type EVP_PKEY_X25519
808
6
#define x448_evp_type EVP_PKEY_X448
809
#define ed25519_input_type "ED25519"
810
#define ed448_input_type "ED448"
811
#define x25519_input_type "X25519"
812
#define x448_input_type "X448"
813
7
#define ed25519_pem_type "ED25519"
814
4
#define ed448_pem_type "ED448"
815
9
#define x25519_pem_type "X25519"
816
6
#define x448_pem_type "X448"
817
#endif
818
819
/* ---------------------------------------------------------------------- */
820
821
/*
822
 * Helper functions to prepare RSA-PSS params for encoding.  We would
823
 * have simply written the whole AlgorithmIdentifier, but existing libcrypto
824
 * functionality doesn't allow that.
825
 */
826
827
static int prepare_rsa_params(const void *rsa, int nid, int save,
828
    void **pstr, int *pstrtype)
829
8
{
830
8
    const RSA_PSS_PARAMS_30 *pss = ossl_rsa_get0_pss_params_30((RSA *)rsa);
831
832
8
    *pstr = NULL;
833
834
8
    switch (RSA_test_flags(rsa, RSA_FLAG_TYPE_MASK)) {
835
0
    case RSA_FLAG_TYPE_RSA:
836
        /* If plain RSA, the parameters shall be NULL */
837
0
        *pstrtype = V_ASN1_NULL;
838
0
        return 1;
839
8
    case RSA_FLAG_TYPE_RSASSAPSS:
840
8
        if (ossl_rsa_pss_params_30_is_unrestricted(pss)) {
841
0
            *pstrtype = V_ASN1_UNDEF;
842
0
            return 1;
843
8
        } else {
844
8
            ASN1_STRING *astr = NULL;
845
8
            WPACKET pkt;
846
8
            unsigned char *str = NULL;
847
8
            size_t str_sz = 0;
848
8
            int i;
849
850
24
            for (i = 0; i < 2; i++) {
851
16
                switch (i) {
852
8
                case 0:
853
8
                    if (!WPACKET_init_null_der(&pkt))
854
0
                        goto err;
855
8
                    break;
856
8
                case 1:
857
8
                    if ((str = OPENSSL_malloc(str_sz)) == NULL
858
8
                        || !WPACKET_init_der(&pkt, str, str_sz)) {
859
0
                        WPACKET_cleanup(&pkt);
860
0
                        goto err;
861
0
                    }
862
8
                    break;
863
16
                }
864
16
                if (!ossl_DER_w_RSASSA_PSS_params(&pkt, -1, pss)
865
16
                    || !WPACKET_finish(&pkt)
866
16
                    || !WPACKET_get_total_written(&pkt, &str_sz)) {
867
0
                    WPACKET_cleanup(&pkt);
868
0
                    goto err;
869
0
                }
870
16
                WPACKET_cleanup(&pkt);
871
872
                /*
873
                 * If no PSS parameters are going to be written, there's no
874
                 * point going for another iteration.
875
                 * This saves us from getting |str| allocated just to have it
876
                 * immediately de-allocated.
877
                 */
878
16
                if (str_sz == 0)
879
0
                    break;
880
16
            }
881
882
8
            if ((astr = ASN1_STRING_new()) == NULL)
883
0
                goto err;
884
8
            *pstrtype = V_ASN1_SEQUENCE;
885
8
            ASN1_STRING_set0(astr, str, (int)str_sz);
886
8
            *pstr = astr;
887
888
8
            return 1;
889
0
        err:
890
0
            OPENSSL_free(str);
891
0
            return 0;
892
8
        }
893
8
    }
894
895
    /* Currently unsupported RSA key type */
896
0
    return 0;
897
8
}
898
899
/*
900
 * RSA is extremely simple, as PKCS#1 is used for the PKCS#8 |privateKey|
901
 * field as well as the SubjectPublicKeyInfo |subjectPublicKey| field.
902
 */
903
8
#define rsa_pki_priv_to_der rsa_type_specific_priv_to_der
904
0
#define rsa_epki_priv_to_der rsa_type_specific_priv_to_der
905
0
#define rsa_spki_pub_to_der rsa_type_specific_pub_to_der
906
1.09k
#define rsa_type_specific_priv_to_der (i2d_of_void *)i2d_RSAPrivateKey
907
0
#define rsa_type_specific_pub_to_der (i2d_of_void *)i2d_RSAPublicKey
908
#define rsa_type_specific_params_to_der NULL
909
910
static int rsa_check_key_type(const void *rsa, int expected_type)
911
1.09k
{
912
1.09k
    switch (RSA_test_flags(rsa, RSA_FLAG_TYPE_MASK)) {
913
1.08k
    case RSA_FLAG_TYPE_RSA:
914
1.08k
        return expected_type == EVP_PKEY_RSA;
915
8
    case RSA_FLAG_TYPE_RSASSAPSS:
916
8
        return expected_type == EVP_PKEY_RSA_PSS;
917
1.09k
    }
918
919
    /* Currently unsupported RSA key type */
920
0
    return EVP_PKEY_NONE;
921
1.09k
}
922
923
1.08k
#define rsa_evp_type EVP_PKEY_RSA
924
8
#define rsapss_evp_type EVP_PKEY_RSA_PSS
925
#define rsa_input_type "RSA"
926
#define rsapss_input_type "RSA-PSS"
927
1.08k
#define rsa_pem_type "RSA"
928
8
#define rsapss_pem_type "RSA-PSS"
929
930
/* ---------------------------------------------------------------------- */
931
932
static OSSL_FUNC_decoder_newctx_fn key2any_newctx;
933
static OSSL_FUNC_decoder_freectx_fn key2any_freectx;
934
935
static void *key2any_newctx(void *provctx)
936
566k
{
937
566k
    struct key2any_ctx_st *ctx = OPENSSL_zalloc(sizeof(*ctx));
938
939
566k
    if (ctx != NULL) {
940
566k
        ctx->provctx = provctx;
941
566k
        ctx->save_parameters = 1;
942
566k
    }
943
944
566k
    return ctx;
945
566k
}
946
947
static void key2any_freectx(void *vctx)
948
566k
{
949
566k
    struct key2any_ctx_st *ctx = vctx;
950
951
566k
    ossl_pw_clear_passphrase_data(&ctx->pwdata);
952
566k
    EVP_CIPHER_free(ctx->cipher);
953
566k
    OPENSSL_free(ctx);
954
566k
}
955
956
static const OSSL_PARAM *key2any_settable_ctx_params(ossl_unused void *provctx)
957
0
{
958
0
    static const OSSL_PARAM settables[] = {
959
0
        OSSL_PARAM_utf8_string(OSSL_ENCODER_PARAM_CIPHER, NULL, 0),
960
0
        OSSL_PARAM_utf8_string(OSSL_ENCODER_PARAM_PROPERTIES, NULL, 0),
961
0
        OSSL_PARAM_END,
962
0
    };
963
964
0
    return settables;
965
0
}
966
967
static int key2any_set_ctx_params(void *vctx, const OSSL_PARAM params[])
968
366k
{
969
366k
    struct key2any_ctx_st *ctx = vctx;
970
366k
    OSSL_LIB_CTX *libctx = ossl_prov_ctx_get0_libctx(ctx->provctx);
971
366k
    const OSSL_PARAM *cipherp = OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_CIPHER);
972
366k
    const OSSL_PARAM *propsp = OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_PROPERTIES);
973
366k
    const OSSL_PARAM *save_paramsp = OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_SAVE_PARAMETERS);
974
975
366k
    if (cipherp != NULL) {
976
0
        const char *ciphername = NULL;
977
0
        const char *props = NULL;
978
979
0
        if (!OSSL_PARAM_get_utf8_string_ptr(cipherp, &ciphername))
980
0
            return 0;
981
0
        if (propsp != NULL && !OSSL_PARAM_get_utf8_string_ptr(propsp, &props))
982
0
            return 0;
983
984
0
        EVP_CIPHER_free(ctx->cipher);
985
0
        ctx->cipher = NULL;
986
0
        ctx->cipher_intent = ciphername != NULL;
987
0
        if (ciphername != NULL
988
0
            && ((ctx->cipher = EVP_CIPHER_fetch(libctx, ciphername, props)) == NULL))
989
0
            return 0;
990
0
    }
991
992
366k
    if (save_paramsp != NULL) {
993
366k
        if (!OSSL_PARAM_get_int(save_paramsp, &ctx->save_parameters))
994
0
            return 0;
995
366k
    }
996
366k
    return 1;
997
366k
}
998
999
static int key2any_check_selection(int selection, int selection_mask)
1000
2.53M
{
1001
    /*
1002
     * The selections are kinda sorta "levels", i.e. each selection given
1003
     * here is assumed to include those following.
1004
     */
1005
2.53M
    int checks[] = {
1006
2.53M
        OSSL_KEYMGMT_SELECT_PRIVATE_KEY,
1007
2.53M
        OSSL_KEYMGMT_SELECT_PUBLIC_KEY,
1008
2.53M
        OSSL_KEYMGMT_SELECT_ALL_PARAMETERS
1009
2.53M
    };
1010
2.53M
    size_t i;
1011
1012
    /* The decoder implementations made here support guessing */
1013
2.53M
    if (selection == 0)
1014
0
        return 1;
1015
1016
4.87M
    for (i = 0; i < OSSL_NELEM(checks); i++) {
1017
4.87M
        int check1 = (selection & checks[i]) != 0;
1018
4.87M
        int check2 = (selection_mask & checks[i]) != 0;
1019
1020
        /*
1021
         * If the caller asked for the currently checked bit(s), return
1022
         * whether the decoder description says it's supported.
1023
         */
1024
4.87M
        if (check1)
1025
2.53M
            return check2;
1026
4.87M
    }
1027
1028
    /* This should be dead code, but just to be safe... */
1029
0
    return 0;
1030
2.53M
}
1031
1032
static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout,
1033
    const void *key, int type, const char *pemname,
1034
    check_key_type_fn *checker,
1035
    key_to_der_fn *writer,
1036
    OSSL_PASSPHRASE_CALLBACK *pwcb, void *pwcbarg,
1037
    key_to_paramstring_fn *key2paramstring,
1038
    i2d_of_void *key2der)
1039
11.0k
{
1040
11.0k
    int ret = 0;
1041
1042
11.0k
    if (key == NULL) {
1043
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
1044
11.0k
    } else if (writer != NULL
1045
11.0k
        && (checker == NULL || checker(key, type))) {
1046
11.0k
        BIO *out = ossl_bio_new_from_core_bio(ctx->provctx, cout);
1047
1048
11.0k
        if (out != NULL
1049
11.0k
            && (pwcb == NULL
1050
11.0k
                || ossl_pw_set_ossl_passphrase_cb(&ctx->pwdata, pwcb, pwcbarg)))
1051
11.0k
            ret = writer(out, key, type, pemname, key2paramstring, key2der, ctx);
1052
1053
11.0k
        BIO_free(out);
1054
11.0k
    } else {
1055
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
1056
0
    }
1057
11.0k
    return ret;
1058
11.0k
}
1059
1060
1.51M
#define DO_PRIVATE_KEY_selection_mask OSSL_KEYMGMT_SELECT_PRIVATE_KEY
1061
#define DO_PRIVATE_KEY(impl, type, kind, output)               \
1062
10.8k
    if ((selection & DO_PRIVATE_KEY_selection_mask) != 0)      \
1063
10.8k
        return key2any_encode(ctx, cout, key, impl##_evp_type, \
1064
10.8k
            impl##_pem_type " PRIVATE KEY",                    \
1065
10.8k
            type##_check_key_type,                             \
1066
10.8k
            key_to_##kind##_##output##_priv_bio,               \
1067
10.8k
            cb, cbarg, prepare_##type##_params,                \
1068
10.8k
            type##_##kind##_priv_to_der);
1069
1070
861k
#define DO_PUBLIC_KEY_selection_mask OSSL_KEYMGMT_SELECT_PUBLIC_KEY
1071
#define DO_PUBLIC_KEY(impl, type, kind, output)                \
1072
0
    if ((selection & DO_PUBLIC_KEY_selection_mask) != 0)       \
1073
0
        return key2any_encode(ctx, cout, key, impl##_evp_type, \
1074
0
            impl##_pem_type " PUBLIC KEY",                     \
1075
0
            type##_check_key_type,                             \
1076
0
            key_to_##kind##_##output##_pub_bio,                \
1077
0
            cb, cbarg, prepare_##type##_params,                \
1078
0
            type##_##kind##_pub_to_der);
1079
1080
737k
#define DO_PARAMETERS_selection_mask OSSL_KEYMGMT_SELECT_ALL_PARAMETERS
1081
#define DO_PARAMETERS(impl, type, kind, output)                \
1082
0
    if ((selection & DO_PARAMETERS_selection_mask) != 0)       \
1083
0
        return key2any_encode(ctx, cout, key, impl##_evp_type, \
1084
0
            impl##_pem_type " PARAMETERS",                     \
1085
0
            type##_check_key_type,                             \
1086
0
            key_to_##kind##_##output##_param_bio,              \
1087
0
            NULL, NULL, NULL,                                  \
1088
0
            type##_##kind##_params_to_der);
1089
1090
/*-
1091
 * Implement the kinds of output structure that can be produced.  They are
1092
 * referred to by name, and for each name, the following macros are defined
1093
 * (braces not included):
1094
 *
1095
 * DO_{kind}_selection_mask
1096
 *
1097
 *      A mask of selection bits that must not be zero.  This is used as a
1098
 *      selection criterion for each implementation.
1099
 *      This mask must never be zero.
1100
 *
1101
 * DO_{kind}
1102
 *
1103
 *      The performing macro.  It must use the DO_ macros defined above,
1104
 *      always in this order:
1105
 *
1106
 *      - DO_PRIVATE_KEY
1107
 *      - DO_PUBLIC_KEY
1108
 *      - DO_PARAMETERS
1109
 *
1110
 *      Any of those may be omitted, but the relative order must still be
1111
 *      the same.
1112
 */
1113
1114
/*
1115
 * PKCS#8 defines two structures for private keys only:
1116
 * - PrivateKeyInfo             (raw unencrypted form)
1117
 * - EncryptedPrivateKeyInfo    (encrypted wrapping)
1118
 *
1119
 * To allow a certain amount of flexibility, we allow the routines
1120
 * for PrivateKeyInfo to also produce EncryptedPrivateKeyInfo if a
1121
 * passphrase callback has been passed to them.
1122
 */
1123
496k
#define DO_PrivateKeyInfo_selection_mask DO_PRIVATE_KEY_selection_mask
1124
#define DO_PrivateKeyInfo(impl, type, output) \
1125
1.58k
    DO_PRIVATE_KEY(impl, type, pki, output)
1126
1127
496k
#define DO_EncryptedPrivateKeyInfo_selection_mask DO_PRIVATE_KEY_selection_mask
1128
#define DO_EncryptedPrivateKeyInfo(impl, type, output) \
1129
0
    DO_PRIVATE_KEY(impl, type, epki, output)
1130
1131
/* SubjectPublicKeyInfo is a structure for public keys only */
1132
602k
#define DO_SubjectPublicKeyInfo_selection_mask DO_PUBLIC_KEY_selection_mask
1133
#define DO_SubjectPublicKeyInfo(impl, type, output) \
1134
0
    DO_PUBLIC_KEY(impl, type, spki, output)
1135
1136
/*
1137
 * "type-specific" is a uniform name for key type specific output for private
1138
 * and public keys as well as key parameters.  This is used internally in
1139
 * libcrypto so it doesn't have to have special knowledge about select key
1140
 * types, but also when no better name has been found.  If there are more
1141
 * expressive DO_ names above, those are preferred.
1142
 *
1143
 * Three forms exist:
1144
 *
1145
 * - type_specific_keypair              Only supports private and public key
1146
 * - type_specific_params               Only supports parameters
1147
 * - type_specific                      Supports all parts of an EVP_PKEY
1148
 * - type_specific_no_pub               Supports all parts of an EVP_PKEY
1149
 *                                      except public key
1150
 */
1151
484k
#define DO_type_specific_params_selection_mask DO_PARAMETERS_selection_mask
1152
#define DO_type_specific_params(impl, type, output) \
1153
0
    DO_PARAMETERS(impl, type, type_specific, output)
1154
#define DO_type_specific_keypair_selection_mask \
1155
258k
    (DO_PRIVATE_KEY_selection_mask | DO_PUBLIC_KEY_selection_mask)
1156
#define DO_type_specific_keypair(impl, type, output)  \
1157
4.30k
    DO_PRIVATE_KEY(impl, type, type_specific, output) \
1158
4.30k
    DO_PUBLIC_KEY(impl, type, type_specific, output)
1159
#define DO_type_specific_selection_mask      \
1160
70.7k
    (DO_type_specific_keypair_selection_mask \
1161
70.7k
        | DO_type_specific_params_selection_mask)
1162
#define DO_type_specific(impl, type, output)     \
1163
3.21k
    DO_type_specific_keypair(impl, type, output) \
1164
0
        DO_type_specific_params(impl, type, output)
1165
#define DO_type_specific_no_pub_selection_mask \
1166
253k
    (DO_PRIVATE_KEY_selection_mask | DO_PARAMETERS_selection_mask)
1167
#define DO_type_specific_no_pub(impl, type, output)   \
1168
4.99k
    DO_PRIVATE_KEY(impl, type, type_specific, output) \
1169
4.99k
    DO_type_specific_params(impl, type, output)
1170
1171
/*
1172
 * Type specific aliases for the cases where we need to refer to them by
1173
 * type name.
1174
 * This only covers key types that are represented with i2d_{TYPE}PrivateKey,
1175
 * i2d_{TYPE}PublicKey and i2d_{TYPE}params / i2d_{TYPE}Parameters.
1176
 */
1177
125k
#define DO_RSA_selection_mask DO_type_specific_keypair_selection_mask
1178
0
#define DO_RSA(impl, type, output) DO_type_specific_keypair(impl, type, output)
1179
1180
68.0k
#define DO_DH_selection_mask DO_type_specific_params_selection_mask
1181
0
#define DO_DH(impl, type, output) DO_type_specific_params(impl, type, output)
1182
1183
207k
#define DO_DHX_selection_mask DO_type_specific_params_selection_mask
1184
0
#define DO_DHX(impl, type, output) DO_type_specific_params(impl, type, output)
1185
1186
35.3k
#define DO_DSA_selection_mask DO_type_specific_selection_mask
1187
0
#define DO_DSA(impl, type, output) DO_type_specific(impl, type, output)
1188
1189
168k
#define DO_EC_selection_mask DO_type_specific_no_pub_selection_mask
1190
0
#define DO_EC(impl, type, output) DO_type_specific_no_pub(impl, type, output)
1191
1192
0
#define DO_SM2_selection_mask DO_type_specific_no_pub_selection_mask
1193
0
#define DO_SM2(impl, type, output) DO_type_specific_no_pub(impl, type, output)
1194
1195
/* PKCS#1 defines a structure for RSA private and public keys */
1196
63.3k
#define DO_PKCS1_selection_mask DO_RSA_selection_mask
1197
0
#define DO_PKCS1(impl, type, output) DO_RSA(impl, type, output)
1198
1199
/* PKCS#3 defines a structure for DH parameters */
1200
34.0k
#define DO_PKCS3_selection_mask DO_DH_selection_mask
1201
0
#define DO_PKCS3(impl, type, output) DO_DH(impl, type, output)
1202
/* X9.42 defines a structure for DHx parameters */
1203
103k
#define DO_X9_42_selection_mask DO_DHX_selection_mask
1204
0
#define DO_X9_42(impl, type, output) DO_DHX(impl, type, output)
1205
1206
/* X9.62 defines a structure for EC keys and parameters */
1207
84.2k
#define DO_X9_62_selection_mask DO_EC_selection_mask
1208
0
#define DO_X9_62(impl, type, output) DO_EC(impl, type, output)
1209
1210
/*
1211
 * MAKE_ENCODER is the single driver for creating OSSL_DISPATCH tables.
1212
 * It takes the following arguments:
1213
 *
1214
 * impl         This is the key type name that's being implemented.
1215
 * type         This is the type name for the set of functions that implement
1216
 *              the key type.  For example, ed25519, ed448, x25519 and x448
1217
 *              are all implemented with the exact same set of functions.
1218
 * evp_type     The corresponding EVP_PKEY_xxx type macro for each key.
1219
 *              Necessary because we currently use EVP_PKEY with legacy
1220
 *              native keys internally.  This will need to be refactored
1221
 *              when that legacy support goes away.
1222
 * kind         What kind of support to implement.  These translate into
1223
 *              the DO_##kind macros above.
1224
 * output       The output type to implement.  may be der or pem.
1225
 *
1226
 * The resulting OSSL_DISPATCH array gets the following name (expressed in
1227
 * C preprocessor terms) from those arguments:
1228
 *
1229
 * ossl_##impl##_to_##kind##_##output##_encoder_functions
1230
 */
1231
#define MAKE_ENCODER(impl, type, evp_type, kind, output)                          \
1232
    static OSSL_FUNC_encoder_import_object_fn                                     \
1233
        impl##_to_##kind##_##output##_import_object;                              \
1234
    static OSSL_FUNC_encoder_free_object_fn                                       \
1235
        impl##_to_##kind##_##output##_free_object;                                \
1236
    static OSSL_FUNC_encoder_encode_fn                                            \
1237
        impl##_to_##kind##_##output##_encode;                                     \
1238
                                                                                  \
1239
    static void *                                                                 \
1240
    impl##_to_##kind##_##output##_import_object(void *vctx, int selection,        \
1241
        const OSSL_PARAM params[])                                                \
1242
0
    {                                                                             \
1243
0
        struct key2any_ctx_st *ctx = vctx;                                        \
1244
0
                                                                                  \
1245
0
        return ossl_prov_import_key(ossl_##impl##_keymgmt_functions,              \
1246
0
            ctx->provctx, selection, params);                                     \
1247
0
    }                                                                             \
Unexecuted instantiation: encode_key2any.c:rsa_to_type_specific_keypair_der_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_type_specific_params_der_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_type_specific_params_der_import_object
Unexecuted instantiation: encode_key2any.c:dsa_to_type_specific_der_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_type_specific_no_pub_der_import_object
Unexecuted instantiation: encode_key2any.c:sm2_to_type_specific_no_pub_der_import_object
Unexecuted instantiation: encode_key2any.c:rsa_to_type_specific_keypair_pem_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_type_specific_params_pem_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_type_specific_params_pem_import_object
Unexecuted instantiation: encode_key2any.c:dsa_to_type_specific_pem_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_type_specific_no_pub_pem_import_object
Unexecuted instantiation: encode_key2any.c:sm2_to_type_specific_no_pub_pem_import_object
Unexecuted instantiation: encode_key2any.c:rsa_to_EncryptedPrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:rsa_to_EncryptedPrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:rsa_to_PrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:rsa_to_PrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:rsa_to_SubjectPublicKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:rsa_to_SubjectPublicKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_EncryptedPrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_EncryptedPrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_PrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_PrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_SubjectPublicKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_SubjectPublicKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_EncryptedPrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_EncryptedPrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_PrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_PrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_SubjectPublicKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_SubjectPublicKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_EncryptedPrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_EncryptedPrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_PrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_PrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_SubjectPublicKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_SubjectPublicKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:dsa_to_EncryptedPrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:dsa_to_EncryptedPrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:dsa_to_PrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:dsa_to_PrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:dsa_to_SubjectPublicKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:dsa_to_SubjectPublicKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_EncryptedPrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_EncryptedPrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_PrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_PrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_SubjectPublicKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_SubjectPublicKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:sm2_to_EncryptedPrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:sm2_to_EncryptedPrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:sm2_to_PrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:sm2_to_PrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:sm2_to_SubjectPublicKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:sm2_to_SubjectPublicKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_EncryptedPrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_EncryptedPrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_PrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_PrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_SubjectPublicKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_SubjectPublicKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:ed448_to_EncryptedPrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:ed448_to_EncryptedPrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:ed448_to_PrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:ed448_to_PrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:ed448_to_SubjectPublicKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:ed448_to_SubjectPublicKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:x25519_to_EncryptedPrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:x25519_to_EncryptedPrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:x25519_to_PrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:x25519_to_PrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:x25519_to_SubjectPublicKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:x25519_to_SubjectPublicKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:x448_to_EncryptedPrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:x448_to_EncryptedPrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:x448_to_PrivateKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:x448_to_PrivateKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:x448_to_SubjectPublicKeyInfo_der_import_object
Unexecuted instantiation: encode_key2any.c:x448_to_SubjectPublicKeyInfo_pem_import_object
Unexecuted instantiation: encode_key2any.c:rsa_to_RSA_der_import_object
Unexecuted instantiation: encode_key2any.c:rsa_to_RSA_pem_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_DH_der_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_DH_pem_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_DHX_der_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_DHX_pem_import_object
Unexecuted instantiation: encode_key2any.c:dsa_to_DSA_der_import_object
Unexecuted instantiation: encode_key2any.c:dsa_to_DSA_pem_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_EC_der_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_EC_pem_import_object
Unexecuted instantiation: encode_key2any.c:sm2_to_SM2_der_import_object
Unexecuted instantiation: encode_key2any.c:sm2_to_SM2_pem_import_object
Unexecuted instantiation: encode_key2any.c:rsa_to_PKCS1_der_import_object
Unexecuted instantiation: encode_key2any.c:rsa_to_PKCS1_pem_import_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_PKCS1_der_import_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_PKCS1_pem_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_PKCS3_der_import_object
Unexecuted instantiation: encode_key2any.c:dh_to_PKCS3_pem_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_X9_42_der_import_object
Unexecuted instantiation: encode_key2any.c:dhx_to_X9_42_pem_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_X9_62_der_import_object
Unexecuted instantiation: encode_key2any.c:ec_to_X9_62_pem_import_object
1248
    static void impl##_to_##kind##_##output##_free_object(void *key)              \
1249
0
    {                                                                             \
1250
0
        ossl_prov_free_key(ossl_##impl##_keymgmt_functions, key);                 \
1251
0
    }                                                                             \
Unexecuted instantiation: encode_key2any.c:rsa_to_type_specific_keypair_der_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_type_specific_params_der_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_type_specific_params_der_free_object
Unexecuted instantiation: encode_key2any.c:dsa_to_type_specific_der_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_type_specific_no_pub_der_free_object
Unexecuted instantiation: encode_key2any.c:sm2_to_type_specific_no_pub_der_free_object
Unexecuted instantiation: encode_key2any.c:rsa_to_type_specific_keypair_pem_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_type_specific_params_pem_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_type_specific_params_pem_free_object
Unexecuted instantiation: encode_key2any.c:dsa_to_type_specific_pem_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_type_specific_no_pub_pem_free_object
Unexecuted instantiation: encode_key2any.c:sm2_to_type_specific_no_pub_pem_free_object
Unexecuted instantiation: encode_key2any.c:rsa_to_EncryptedPrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:rsa_to_EncryptedPrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:rsa_to_PrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:rsa_to_PrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:rsa_to_SubjectPublicKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:rsa_to_SubjectPublicKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_EncryptedPrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_EncryptedPrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_PrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_PrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_SubjectPublicKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_SubjectPublicKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_EncryptedPrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_EncryptedPrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_PrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_PrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_SubjectPublicKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_SubjectPublicKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_EncryptedPrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_EncryptedPrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_PrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_PrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_SubjectPublicKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_SubjectPublicKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:dsa_to_EncryptedPrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:dsa_to_EncryptedPrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:dsa_to_PrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:dsa_to_PrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:dsa_to_SubjectPublicKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:dsa_to_SubjectPublicKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_EncryptedPrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_EncryptedPrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_PrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_PrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_SubjectPublicKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_SubjectPublicKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:sm2_to_EncryptedPrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:sm2_to_EncryptedPrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:sm2_to_PrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:sm2_to_PrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:sm2_to_SubjectPublicKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:sm2_to_SubjectPublicKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_EncryptedPrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_EncryptedPrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_PrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_PrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_SubjectPublicKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:ed25519_to_SubjectPublicKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:ed448_to_EncryptedPrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:ed448_to_EncryptedPrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:ed448_to_PrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:ed448_to_PrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:ed448_to_SubjectPublicKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:ed448_to_SubjectPublicKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:x25519_to_EncryptedPrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:x25519_to_EncryptedPrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:x25519_to_PrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:x25519_to_PrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:x25519_to_SubjectPublicKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:x25519_to_SubjectPublicKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:x448_to_EncryptedPrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:x448_to_EncryptedPrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:x448_to_PrivateKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:x448_to_PrivateKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:x448_to_SubjectPublicKeyInfo_der_free_object
Unexecuted instantiation: encode_key2any.c:x448_to_SubjectPublicKeyInfo_pem_free_object
Unexecuted instantiation: encode_key2any.c:rsa_to_RSA_der_free_object
Unexecuted instantiation: encode_key2any.c:rsa_to_RSA_pem_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_DH_der_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_DH_pem_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_DHX_der_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_DHX_pem_free_object
Unexecuted instantiation: encode_key2any.c:dsa_to_DSA_der_free_object
Unexecuted instantiation: encode_key2any.c:dsa_to_DSA_pem_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_EC_der_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_EC_pem_free_object
Unexecuted instantiation: encode_key2any.c:sm2_to_SM2_der_free_object
Unexecuted instantiation: encode_key2any.c:sm2_to_SM2_pem_free_object
Unexecuted instantiation: encode_key2any.c:rsa_to_PKCS1_der_free_object
Unexecuted instantiation: encode_key2any.c:rsa_to_PKCS1_pem_free_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_PKCS1_der_free_object
Unexecuted instantiation: encode_key2any.c:rsapss_to_PKCS1_pem_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_PKCS3_der_free_object
Unexecuted instantiation: encode_key2any.c:dh_to_PKCS3_pem_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_X9_42_der_free_object
Unexecuted instantiation: encode_key2any.c:dhx_to_X9_42_pem_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_X9_62_der_free_object
Unexecuted instantiation: encode_key2any.c:ec_to_X9_62_pem_free_object
1252
    static int impl##_to_##kind##_##output##_does_selection(void *ctx,            \
1253
        int selection)                                                            \
1254
2.52M
    {                                                                             \
1255
2.52M
        return key2any_check_selection(selection,                                 \
1256
2.52M
            DO_##kind##_selection_mask);                                          \
1257
2.52M
    }                                                                             \
encode_key2any.c:rsa_to_type_specific_keypair_der_does_selection
Line
Count
Source
1254
31.2k
    {                                                                             \
1255
31.2k
        return key2any_check_selection(selection,                                 \
1256
31.2k
            DO_##kind##_selection_mask);                                          \
1257
31.2k
    }                                                                             \
encode_key2any.c:dh_to_type_specific_params_der_does_selection
Line
Count
Source
1254
17.0k
    {                                                                             \
1255
17.0k
        return key2any_check_selection(selection,                                 \
1256
17.0k
            DO_##kind##_selection_mask);                                          \
1257
17.0k
    }                                                                             \
encode_key2any.c:dhx_to_type_specific_params_der_does_selection
Line
Count
Source
1254
51.9k
    {                                                                             \
1255
51.9k
        return key2any_check_selection(selection,                                 \
1256
51.9k
            DO_##kind##_selection_mask);                                          \
1257
51.9k
    }                                                                             \
encode_key2any.c:dsa_to_type_specific_der_does_selection
Line
Count
Source
1254
17.6k
    {                                                                             \
1255
17.6k
        return key2any_check_selection(selection,                                 \
1256
17.6k
            DO_##kind##_selection_mask);                                          \
1257
17.6k
    }                                                                             \
encode_key2any.c:ec_to_type_specific_no_pub_der_does_selection
Line
Count
Source
1254
42.1k
    {                                                                             \
1255
42.1k
        return key2any_check_selection(selection,                                 \
1256
42.1k
            DO_##kind##_selection_mask);                                          \
1257
42.1k
    }                                                                             \
encode_key2any.c:sm2_to_type_specific_no_pub_der_does_selection
Line
Count
Source
1254
288
    {                                                                             \
1255
288
        return key2any_check_selection(selection,                                 \
1256
288
            DO_##kind##_selection_mask);                                          \
1257
288
    }                                                                             \
encode_key2any.c:rsa_to_type_specific_keypair_pem_does_selection
Line
Count
Source
1254
31.2k
    {                                                                             \
1255
31.2k
        return key2any_check_selection(selection,                                 \
1256
31.2k
            DO_##kind##_selection_mask);                                          \
1257
31.2k
    }                                                                             \
encode_key2any.c:dh_to_type_specific_params_pem_does_selection
Line
Count
Source
1254
17.0k
    {                                                                             \
1255
17.0k
        return key2any_check_selection(selection,                                 \
1256
17.0k
            DO_##kind##_selection_mask);                                          \
1257
17.0k
    }                                                                             \
encode_key2any.c:dhx_to_type_specific_params_pem_does_selection
Line
Count
Source
1254
51.9k
    {                                                                             \
1255
51.9k
        return key2any_check_selection(selection,                                 \
1256
51.9k
            DO_##kind##_selection_mask);                                          \
1257
51.9k
    }                                                                             \
encode_key2any.c:dsa_to_type_specific_pem_does_selection
Line
Count
Source
1254
17.6k
    {                                                                             \
1255
17.6k
        return key2any_check_selection(selection,                                 \
1256
17.6k
            DO_##kind##_selection_mask);                                          \
1257
17.6k
    }                                                                             \
encode_key2any.c:ec_to_type_specific_no_pub_pem_does_selection
Line
Count
Source
1254
42.1k
    {                                                                             \
1255
42.1k
        return key2any_check_selection(selection,                                 \
1256
42.1k
            DO_##kind##_selection_mask);                                          \
1257
42.1k
    }                                                                             \
encode_key2any.c:sm2_to_type_specific_no_pub_pem_does_selection
Line
Count
Source
1254
288
    {                                                                             \
1255
288
        return key2any_check_selection(selection,                                 \
1256
288
            DO_##kind##_selection_mask);                                          \
1257
288
    }                                                                             \
encode_key2any.c:rsa_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1254
60.8k
    {                                                                             \
1255
60.8k
        return key2any_check_selection(selection,                                 \
1256
60.8k
            DO_##kind##_selection_mask);                                          \
1257
60.8k
    }                                                                             \
encode_key2any.c:rsa_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
60.8k
    {                                                                             \
1255
60.8k
        return key2any_check_selection(selection,                                 \
1256
60.8k
            DO_##kind##_selection_mask);                                          \
1257
60.8k
    }                                                                             \
encode_key2any.c:rsa_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1254
60.8k
    {                                                                             \
1255
60.8k
        return key2any_check_selection(selection,                                 \
1256
60.8k
            DO_##kind##_selection_mask);                                          \
1257
60.8k
    }                                                                             \
encode_key2any.c:rsa_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
60.8k
    {                                                                             \
1255
60.8k
        return key2any_check_selection(selection,                                 \
1256
60.8k
            DO_##kind##_selection_mask);                                          \
1257
60.8k
    }                                                                             \
encode_key2any.c:rsa_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1254
49.2k
    {                                                                             \
1255
49.2k
        return key2any_check_selection(selection,                                 \
1256
49.2k
            DO_##kind##_selection_mask);                                          \
1257
49.2k
    }                                                                             \
encode_key2any.c:rsa_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1254
49.2k
    {                                                                             \
1255
49.2k
        return key2any_check_selection(selection,                                 \
1256
49.2k
            DO_##kind##_selection_mask);                                          \
1257
49.2k
    }                                                                             \
encode_key2any.c:rsapss_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1254
1.47k
    {                                                                             \
1255
1.47k
        return key2any_check_selection(selection,                                 \
1256
1.47k
            DO_##kind##_selection_mask);                                          \
1257
1.47k
    }                                                                             \
encode_key2any.c:rsapss_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
1.47k
    {                                                                             \
1255
1.47k
        return key2any_check_selection(selection,                                 \
1256
1.47k
            DO_##kind##_selection_mask);                                          \
1257
1.47k
    }                                                                             \
encode_key2any.c:rsapss_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1254
1.47k
    {                                                                             \
1255
1.47k
        return key2any_check_selection(selection,                                 \
1256
1.47k
            DO_##kind##_selection_mask);                                          \
1257
1.47k
    }                                                                             \
encode_key2any.c:rsapss_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
1.47k
    {                                                                             \
1255
1.47k
        return key2any_check_selection(selection,                                 \
1256
1.47k
            DO_##kind##_selection_mask);                                          \
1257
1.47k
    }                                                                             \
encode_key2any.c:rsapss_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1254
574
    {                                                                             \
1255
574
        return key2any_check_selection(selection,                                 \
1256
574
            DO_##kind##_selection_mask);                                          \
1257
574
    }                                                                             \
encode_key2any.c:rsapss_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1254
574
    {                                                                             \
1255
574
        return key2any_check_selection(selection,                                 \
1256
574
            DO_##kind##_selection_mask);                                          \
1257
574
    }                                                                             \
encode_key2any.c:dh_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1254
17.0k
    {                                                                             \
1255
17.0k
        return key2any_check_selection(selection,                                 \
1256
17.0k
            DO_##kind##_selection_mask);                                          \
1257
17.0k
    }                                                                             \
encode_key2any.c:dh_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
17.0k
    {                                                                             \
1255
17.0k
        return key2any_check_selection(selection,                                 \
1256
17.0k
            DO_##kind##_selection_mask);                                          \
1257
17.0k
    }                                                                             \
encode_key2any.c:dh_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1254
17.0k
    {                                                                             \
1255
17.0k
        return key2any_check_selection(selection,                                 \
1256
17.0k
            DO_##kind##_selection_mask);                                          \
1257
17.0k
    }                                                                             \
encode_key2any.c:dh_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
17.0k
    {                                                                             \
1255
17.0k
        return key2any_check_selection(selection,                                 \
1256
17.0k
            DO_##kind##_selection_mask);                                          \
1257
17.0k
    }                                                                             \
encode_key2any.c:dh_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1254
15.4k
    {                                                                             \
1255
15.4k
        return key2any_check_selection(selection,                                 \
1256
15.4k
            DO_##kind##_selection_mask);                                          \
1257
15.4k
    }                                                                             \
encode_key2any.c:dh_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1254
15.4k
    {                                                                             \
1255
15.4k
        return key2any_check_selection(selection,                                 \
1256
15.4k
            DO_##kind##_selection_mask);                                          \
1257
15.4k
    }                                                                             \
encode_key2any.c:dhx_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1254
51.0k
    {                                                                             \
1255
51.0k
        return key2any_check_selection(selection,                                 \
1256
51.0k
            DO_##kind##_selection_mask);                                          \
1257
51.0k
    }                                                                             \
encode_key2any.c:dhx_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
51.0k
    {                                                                             \
1255
51.0k
        return key2any_check_selection(selection,                                 \
1256
51.0k
            DO_##kind##_selection_mask);                                          \
1257
51.0k
    }                                                                             \
encode_key2any.c:dhx_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1254
51.0k
    {                                                                             \
1255
51.0k
        return key2any_check_selection(selection,                                 \
1256
51.0k
            DO_##kind##_selection_mask);                                          \
1257
51.0k
    }                                                                             \
encode_key2any.c:dhx_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
51.0k
    {                                                                             \
1255
51.0k
        return key2any_check_selection(selection,                                 \
1256
51.0k
            DO_##kind##_selection_mask);                                          \
1257
51.0k
    }                                                                             \
encode_key2any.c:dhx_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1254
51.7k
    {                                                                             \
1255
51.7k
        return key2any_check_selection(selection,                                 \
1256
51.7k
            DO_##kind##_selection_mask);                                          \
1257
51.7k
    }                                                                             \
encode_key2any.c:dhx_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1254
51.7k
    {                                                                             \
1255
51.7k
        return key2any_check_selection(selection,                                 \
1256
51.7k
            DO_##kind##_selection_mask);                                          \
1257
51.7k
    }                                                                             \
encode_key2any.c:dsa_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1254
64.5k
    {                                                                             \
1255
64.5k
        return key2any_check_selection(selection,                                 \
1256
64.5k
            DO_##kind##_selection_mask);                                          \
1257
64.5k
    }                                                                             \
encode_key2any.c:dsa_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
64.5k
    {                                                                             \
1255
64.5k
        return key2any_check_selection(selection,                                 \
1256
64.5k
            DO_##kind##_selection_mask);                                          \
1257
64.5k
    }                                                                             \
encode_key2any.c:dsa_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1254
64.5k
    {                                                                             \
1255
64.5k
        return key2any_check_selection(selection,                                 \
1256
64.5k
            DO_##kind##_selection_mask);                                          \
1257
64.5k
    }                                                                             \
encode_key2any.c:dsa_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
64.5k
    {                                                                             \
1255
64.5k
        return key2any_check_selection(selection,                                 \
1256
64.5k
            DO_##kind##_selection_mask);                                          \
1257
64.5k
    }                                                                             \
encode_key2any.c:dsa_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1254
112k
    {                                                                             \
1255
112k
        return key2any_check_selection(selection,                                 \
1256
112k
            DO_##kind##_selection_mask);                                          \
1257
112k
    }                                                                             \
encode_key2any.c:dsa_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1254
112k
    {                                                                             \
1255
112k
        return key2any_check_selection(selection,                                 \
1256
112k
            DO_##kind##_selection_mask);                                          \
1257
112k
    }                                                                             \
encode_key2any.c:ec_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1254
51.9k
    {                                                                             \
1255
51.9k
        return key2any_check_selection(selection,                                 \
1256
51.9k
            DO_##kind##_selection_mask);                                          \
1257
51.9k
    }                                                                             \
encode_key2any.c:ec_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
51.9k
    {                                                                             \
1255
51.9k
        return key2any_check_selection(selection,                                 \
1256
51.9k
            DO_##kind##_selection_mask);                                          \
1257
51.9k
    }                                                                             \
encode_key2any.c:ec_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1254
51.9k
    {                                                                             \
1255
51.9k
        return key2any_check_selection(selection,                                 \
1256
51.9k
            DO_##kind##_selection_mask);                                          \
1257
51.9k
    }                                                                             \
encode_key2any.c:ec_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
51.9k
    {                                                                             \
1255
51.9k
        return key2any_check_selection(selection,                                 \
1256
51.9k
            DO_##kind##_selection_mask);                                          \
1257
51.9k
    }                                                                             \
encode_key2any.c:ec_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1254
70.6k
    {                                                                             \
1255
70.6k
        return key2any_check_selection(selection,                                 \
1256
70.6k
            DO_##kind##_selection_mask);                                          \
1257
70.6k
    }                                                                             \
encode_key2any.c:ec_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1254
70.6k
    {                                                                             \
1255
70.6k
        return key2any_check_selection(selection,                                 \
1256
70.6k
            DO_##kind##_selection_mask);                                          \
1257
70.6k
    }                                                                             \
encode_key2any.c:sm2_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1254
331
    {                                                                             \
1255
331
        return key2any_check_selection(selection,                                 \
1256
331
            DO_##kind##_selection_mask);                                          \
1257
331
    }                                                                             \
encode_key2any.c:sm2_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
331
    {                                                                             \
1255
331
        return key2any_check_selection(selection,                                 \
1256
331
            DO_##kind##_selection_mask);                                          \
1257
331
    }                                                                             \
encode_key2any.c:sm2_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1254
331
    {                                                                             \
1255
331
        return key2any_check_selection(selection,                                 \
1256
331
            DO_##kind##_selection_mask);                                          \
1257
331
    }                                                                             \
encode_key2any.c:sm2_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
331
    {                                                                             \
1255
331
        return key2any_check_selection(selection,                                 \
1256
331
            DO_##kind##_selection_mask);                                          \
1257
331
    }                                                                             \
encode_key2any.c:sm2_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1254
363
    {                                                                             \
1255
363
        return key2any_check_selection(selection,                                 \
1256
363
            DO_##kind##_selection_mask);                                          \
1257
363
    }                                                                             \
encode_key2any.c:sm2_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1254
363
    {                                                                             \
1255
363
        return key2any_check_selection(selection,                                 \
1256
363
            DO_##kind##_selection_mask);                                          \
1257
363
    }                                                                             \
encode_key2any.c:ed25519_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1254
384
    {                                                                             \
1255
384
        return key2any_check_selection(selection,                                 \
1256
384
            DO_##kind##_selection_mask);                                          \
1257
384
    }                                                                             \
encode_key2any.c:ed25519_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
384
    {                                                                             \
1255
384
        return key2any_check_selection(selection,                                 \
1256
384
            DO_##kind##_selection_mask);                                          \
1257
384
    }                                                                             \
encode_key2any.c:ed25519_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1254
384
    {                                                                             \
1255
384
        return key2any_check_selection(selection,                                 \
1256
384
            DO_##kind##_selection_mask);                                          \
1257
384
    }                                                                             \
encode_key2any.c:ed25519_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
384
    {                                                                             \
1255
384
        return key2any_check_selection(selection,                                 \
1256
384
            DO_##kind##_selection_mask);                                          \
1257
384
    }                                                                             \
encode_key2any.c:ed25519_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1254
246
    {                                                                             \
1255
246
        return key2any_check_selection(selection,                                 \
1256
246
            DO_##kind##_selection_mask);                                          \
1257
246
    }                                                                             \
encode_key2any.c:ed25519_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1254
246
    {                                                                             \
1255
246
        return key2any_check_selection(selection,                                 \
1256
246
            DO_##kind##_selection_mask);                                          \
1257
246
    }                                                                             \
encode_key2any.c:ed448_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1254
233
    {                                                                             \
1255
233
        return key2any_check_selection(selection,                                 \
1256
233
            DO_##kind##_selection_mask);                                          \
1257
233
    }                                                                             \
encode_key2any.c:ed448_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
233
    {                                                                             \
1255
233
        return key2any_check_selection(selection,                                 \
1256
233
            DO_##kind##_selection_mask);                                          \
1257
233
    }                                                                             \
encode_key2any.c:ed448_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1254
233
    {                                                                             \
1255
233
        return key2any_check_selection(selection,                                 \
1256
233
            DO_##kind##_selection_mask);                                          \
1257
233
    }                                                                             \
encode_key2any.c:ed448_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
233
    {                                                                             \
1255
233
        return key2any_check_selection(selection,                                 \
1256
233
            DO_##kind##_selection_mask);                                          \
1257
233
    }                                                                             \
encode_key2any.c:ed448_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1254
167
    {                                                                             \
1255
167
        return key2any_check_selection(selection,                                 \
1256
167
            DO_##kind##_selection_mask);                                          \
1257
167
    }                                                                             \
encode_key2any.c:ed448_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1254
167
    {                                                                             \
1255
167
        return key2any_check_selection(selection,                                 \
1256
167
            DO_##kind##_selection_mask);                                          \
1257
167
    }                                                                             \
encode_key2any.c:x25519_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1254
136
    {                                                                             \
1255
136
        return key2any_check_selection(selection,                                 \
1256
136
            DO_##kind##_selection_mask);                                          \
1257
136
    }                                                                             \
encode_key2any.c:x25519_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
136
    {                                                                             \
1255
136
        return key2any_check_selection(selection,                                 \
1256
136
            DO_##kind##_selection_mask);                                          \
1257
136
    }                                                                             \
encode_key2any.c:x25519_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1254
136
    {                                                                             \
1255
136
        return key2any_check_selection(selection,                                 \
1256
136
            DO_##kind##_selection_mask);                                          \
1257
136
    }                                                                             \
encode_key2any.c:x25519_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
136
    {                                                                             \
1255
136
        return key2any_check_selection(selection,                                 \
1256
136
            DO_##kind##_selection_mask);                                          \
1257
136
    }                                                                             \
encode_key2any.c:x25519_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1254
131
    {                                                                             \
1255
131
        return key2any_check_selection(selection,                                 \
1256
131
            DO_##kind##_selection_mask);                                          \
1257
131
    }                                                                             \
encode_key2any.c:x25519_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1254
131
    {                                                                             \
1255
131
        return key2any_check_selection(selection,                                 \
1256
131
            DO_##kind##_selection_mask);                                          \
1257
131
    }                                                                             \
encode_key2any.c:x448_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1254
126
    {                                                                             \
1255
126
        return key2any_check_selection(selection,                                 \
1256
126
            DO_##kind##_selection_mask);                                          \
1257
126
    }                                                                             \
encode_key2any.c:x448_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
126
    {                                                                             \
1255
126
        return key2any_check_selection(selection,                                 \
1256
126
            DO_##kind##_selection_mask);                                          \
1257
126
    }                                                                             \
encode_key2any.c:x448_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1254
126
    {                                                                             \
1255
126
        return key2any_check_selection(selection,                                 \
1256
126
            DO_##kind##_selection_mask);                                          \
1257
126
    }                                                                             \
encode_key2any.c:x448_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1254
126
    {                                                                             \
1255
126
        return key2any_check_selection(selection,                                 \
1256
126
            DO_##kind##_selection_mask);                                          \
1257
126
    }                                                                             \
encode_key2any.c:x448_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1254
115
    {                                                                             \
1255
115
        return key2any_check_selection(selection,                                 \
1256
115
            DO_##kind##_selection_mask);                                          \
1257
115
    }                                                                             \
encode_key2any.c:x448_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1254
115
    {                                                                             \
1255
115
        return key2any_check_selection(selection,                                 \
1256
115
            DO_##kind##_selection_mask);                                          \
1257
115
    }                                                                             \
encode_key2any.c:rsa_to_RSA_der_does_selection
Line
Count
Source
1254
31.2k
    {                                                                             \
1255
31.2k
        return key2any_check_selection(selection,                                 \
1256
31.2k
            DO_##kind##_selection_mask);                                          \
1257
31.2k
    }                                                                             \
encode_key2any.c:rsa_to_RSA_pem_does_selection
Line
Count
Source
1254
31.2k
    {                                                                             \
1255
31.2k
        return key2any_check_selection(selection,                                 \
1256
31.2k
            DO_##kind##_selection_mask);                                          \
1257
31.2k
    }                                                                             \
encode_key2any.c:dh_to_DH_der_does_selection
Line
Count
Source
1254
17.0k
    {                                                                             \
1255
17.0k
        return key2any_check_selection(selection,                                 \
1256
17.0k
            DO_##kind##_selection_mask);                                          \
1257
17.0k
    }                                                                             \
encode_key2any.c:dh_to_DH_pem_does_selection
Line
Count
Source
1254
17.0k
    {                                                                             \
1255
17.0k
        return key2any_check_selection(selection,                                 \
1256
17.0k
            DO_##kind##_selection_mask);                                          \
1257
17.0k
    }                                                                             \
encode_key2any.c:dhx_to_DHX_der_does_selection
Line
Count
Source
1254
51.9k
    {                                                                             \
1255
51.9k
        return key2any_check_selection(selection,                                 \
1256
51.9k
            DO_##kind##_selection_mask);                                          \
1257
51.9k
    }                                                                             \
encode_key2any.c:dhx_to_DHX_pem_does_selection
Line
Count
Source
1254
51.9k
    {                                                                             \
1255
51.9k
        return key2any_check_selection(selection,                                 \
1256
51.9k
            DO_##kind##_selection_mask);                                          \
1257
51.9k
    }                                                                             \
encode_key2any.c:dsa_to_DSA_der_does_selection
Line
Count
Source
1254
17.6k
    {                                                                             \
1255
17.6k
        return key2any_check_selection(selection,                                 \
1256
17.6k
            DO_##kind##_selection_mask);                                          \
1257
17.6k
    }                                                                             \
encode_key2any.c:dsa_to_DSA_pem_does_selection
Line
Count
Source
1254
17.6k
    {                                                                             \
1255
17.6k
        return key2any_check_selection(selection,                                 \
1256
17.6k
            DO_##kind##_selection_mask);                                          \
1257
17.6k
    }                                                                             \
encode_key2any.c:ec_to_EC_der_does_selection
Line
Count
Source
1254
42.1k
    {                                                                             \
1255
42.1k
        return key2any_check_selection(selection,                                 \
1256
42.1k
            DO_##kind##_selection_mask);                                          \
1257
42.1k
    }                                                                             \
encode_key2any.c:ec_to_EC_pem_does_selection
Line
Count
Source
1254
42.1k
    {                                                                             \
1255
42.1k
        return key2any_check_selection(selection,                                 \
1256
42.1k
            DO_##kind##_selection_mask);                                          \
1257
42.1k
    }                                                                             \
Unexecuted instantiation: encode_key2any.c:sm2_to_SM2_der_does_selection
Unexecuted instantiation: encode_key2any.c:sm2_to_SM2_pem_does_selection
encode_key2any.c:rsa_to_PKCS1_der_does_selection
Line
Count
Source
1254
31.2k
    {                                                                             \
1255
31.2k
        return key2any_check_selection(selection,                                 \
1256
31.2k
            DO_##kind##_selection_mask);                                          \
1257
31.2k
    }                                                                             \
encode_key2any.c:rsa_to_PKCS1_pem_does_selection
Line
Count
Source
1254
31.2k
    {                                                                             \
1255
31.2k
        return key2any_check_selection(selection,                                 \
1256
31.2k
            DO_##kind##_selection_mask);                                          \
1257
31.2k
    }                                                                             \
encode_key2any.c:rsapss_to_PKCS1_der_does_selection
Line
Count
Source
1254
451
    {                                                                             \
1255
451
        return key2any_check_selection(selection,                                 \
1256
451
            DO_##kind##_selection_mask);                                          \
1257
451
    }                                                                             \
encode_key2any.c:rsapss_to_PKCS1_pem_does_selection
Line
Count
Source
1254
451
    {                                                                             \
1255
451
        return key2any_check_selection(selection,                                 \
1256
451
            DO_##kind##_selection_mask);                                          \
1257
451
    }                                                                             \
encode_key2any.c:dh_to_PKCS3_der_does_selection
Line
Count
Source
1254
17.0k
    {                                                                             \
1255
17.0k
        return key2any_check_selection(selection,                                 \
1256
17.0k
            DO_##kind##_selection_mask);                                          \
1257
17.0k
    }                                                                             \
encode_key2any.c:dh_to_PKCS3_pem_does_selection
Line
Count
Source
1254
17.0k
    {                                                                             \
1255
17.0k
        return key2any_check_selection(selection,                                 \
1256
17.0k
            DO_##kind##_selection_mask);                                          \
1257
17.0k
    }                                                                             \
encode_key2any.c:dhx_to_X9_42_der_does_selection
Line
Count
Source
1254
51.9k
    {                                                                             \
1255
51.9k
        return key2any_check_selection(selection,                                 \
1256
51.9k
            DO_##kind##_selection_mask);                                          \
1257
51.9k
    }                                                                             \
encode_key2any.c:dhx_to_X9_42_pem_does_selection
Line
Count
Source
1254
51.9k
    {                                                                             \
1255
51.9k
        return key2any_check_selection(selection,                                 \
1256
51.9k
            DO_##kind##_selection_mask);                                          \
1257
51.9k
    }                                                                             \
encode_key2any.c:ec_to_X9_62_der_does_selection
Line
Count
Source
1254
42.1k
    {                                                                             \
1255
42.1k
        return key2any_check_selection(selection,                                 \
1256
42.1k
            DO_##kind##_selection_mask);                                          \
1257
42.1k
    }                                                                             \
encode_key2any.c:ec_to_X9_62_pem_does_selection
Line
Count
Source
1254
42.1k
    {                                                                             \
1255
42.1k
        return key2any_check_selection(selection,                                 \
1256
42.1k
            DO_##kind##_selection_mask);                                          \
1257
42.1k
    }                                                                             \
1258
    static int                                                                    \
1259
    impl##_to_##kind##_##output##_encode(void *ctx, OSSL_CORE_BIO *cout,          \
1260
        const void *key,                                                          \
1261
        const OSSL_PARAM key_abstract[],                                          \
1262
        int selection,                                                            \
1263
        OSSL_PASSPHRASE_CALLBACK *cb,                                             \
1264
        void *cbarg)                                                              \
1265
10.8k
    {                                                                             \
1266
10.8k
        /* We don't deal with abstract objects */                                 \
1267
10.8k
        if (key_abstract != NULL) {                                               \
1268
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);               \
1269
0
            return 0;                                                             \
1270
0
        }                                                                         \
1271
10.8k
        DO_##kind(impl, type, output)                                             \
1272
10.8k
                                                                                  \
1273
10.8k
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);               \
1274
0
        return 0;                                                                 \
1275
10.8k
    }                                                                             \
1276
    const OSSL_DISPATCH                                                           \
1277
        ossl_##impl##_to_##kind##_##output##_encoder_functions[]                  \
1278
        = {                                                                       \
1279
              { OSSL_FUNC_ENCODER_NEWCTX,                                         \
1280
                  (void (*)(void))key2any_newctx },                               \
1281
              { OSSL_FUNC_ENCODER_FREECTX,                                        \
1282
                  (void (*)(void))key2any_freectx },                              \
1283
              { OSSL_FUNC_ENCODER_SETTABLE_CTX_PARAMS,                            \
1284
                  (void (*)(void))key2any_settable_ctx_params },                  \
1285
              { OSSL_FUNC_ENCODER_SET_CTX_PARAMS,                                 \
1286
                  (void (*)(void))key2any_set_ctx_params },                       \
1287
              { OSSL_FUNC_ENCODER_DOES_SELECTION,                                 \
1288
                  (void (*)(void))impl##_to_##kind##_##output##_does_selection }, \
1289
              { OSSL_FUNC_ENCODER_IMPORT_OBJECT,                                  \
1290
                  (void (*)(void))impl##_to_##kind##_##output##_import_object },  \
1291
              { OSSL_FUNC_ENCODER_FREE_OBJECT,                                    \
1292
                  (void (*)(void))impl##_to_##kind##_##output##_free_object },    \
1293
              { OSSL_FUNC_ENCODER_ENCODE,                                         \
1294
                  (void (*)(void))impl##_to_##kind##_##output##_encode },         \
1295
              { 0, NULL }                                                         \
1296
          }
1297
1298
/*
1299
 * Replacements for i2d_{TYPE}PrivateKey, i2d_{TYPE}PublicKey,
1300
 * i2d_{TYPE}params, as they exist.
1301
 */
1302
1.08k
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, type_specific_keypair, der);
1303
#ifndef OPENSSL_NO_DH
1304
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, type_specific_params, der);
1305
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, type_specific_params, der);
1306
#endif
1307
#ifndef OPENSSL_NO_DSA
1308
3.21k
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, type_specific, der);
1309
#endif
1310
#ifndef OPENSSL_NO_EC
1311
4.96k
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, type_specific_no_pub, der);
1312
#ifndef OPENSSL_NO_SM2
1313
26
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, type_specific_no_pub, der);
1314
#endif
1315
#endif
1316
1317
/*
1318
 * Replacements for PEM_write_bio_{TYPE}PrivateKey,
1319
 * PEM_write_bio_{TYPE}PublicKey, PEM_write_bio_{TYPE}params, as they exist.
1320
 */
1321
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, type_specific_keypair, pem);
1322
#ifndef OPENSSL_NO_DH
1323
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, type_specific_params, pem);
1324
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, type_specific_params, pem);
1325
#endif
1326
#ifndef OPENSSL_NO_DSA
1327
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, type_specific, pem);
1328
#endif
1329
#ifndef OPENSSL_NO_EC
1330
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, type_specific_no_pub, pem);
1331
#ifndef OPENSSL_NO_SM2
1332
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, type_specific_no_pub, pem);
1333
#endif
1334
#endif
1335
1336
/*
1337
 * PKCS#8 and SubjectPublicKeyInfo support.  This may duplicate some of the
1338
 * implementations specified above, but are more specific.
1339
 * The SubjectPublicKeyInfo implementations also replace the
1340
 * PEM_write_bio_{TYPE}_PUBKEY functions.
1341
 * For PEM, these are expected to be used by PEM_write_bio_PrivateKey(),
1342
 * PEM_write_bio_PUBKEY() and PEM_write_bio_Parameters().
1343
 */
1344
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, EncryptedPrivateKeyInfo, der);
1345
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, EncryptedPrivateKeyInfo, pem);
1346
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, PrivateKeyInfo, der);
1347
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, PrivateKeyInfo, pem);
1348
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, SubjectPublicKeyInfo, der);
1349
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, SubjectPublicKeyInfo, pem);
1350
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, EncryptedPrivateKeyInfo, der);
1351
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, EncryptedPrivateKeyInfo, pem);
1352
8
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, PrivateKeyInfo, der);
1353
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, PrivateKeyInfo, pem);
1354
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, SubjectPublicKeyInfo, der);
1355
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, SubjectPublicKeyInfo, pem);
1356
#ifndef OPENSSL_NO_DH
1357
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, EncryptedPrivateKeyInfo, der);
1358
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, EncryptedPrivateKeyInfo, pem);
1359
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, PrivateKeyInfo, der);
1360
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, PrivateKeyInfo, pem);
1361
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, SubjectPublicKeyInfo, der);
1362
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, SubjectPublicKeyInfo, pem);
1363
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, EncryptedPrivateKeyInfo, der);
1364
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, EncryptedPrivateKeyInfo, pem);
1365
105
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, PrivateKeyInfo, der);
1366
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, PrivateKeyInfo, pem);
1367
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, SubjectPublicKeyInfo, der);
1368
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, SubjectPublicKeyInfo, pem);
1369
#endif
1370
#ifndef OPENSSL_NO_DSA
1371
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, EncryptedPrivateKeyInfo, der);
1372
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, EncryptedPrivateKeyInfo, pem);
1373
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, PrivateKeyInfo, der);
1374
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, PrivateKeyInfo, pem);
1375
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, SubjectPublicKeyInfo, der);
1376
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, SubjectPublicKeyInfo, pem);
1377
#endif
1378
#ifndef OPENSSL_NO_EC
1379
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, EncryptedPrivateKeyInfo, der);
1380
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, EncryptedPrivateKeyInfo, pem);
1381
1.43k
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, PrivateKeyInfo, der);
1382
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, PrivateKeyInfo, pem);
1383
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, SubjectPublicKeyInfo, der);
1384
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, SubjectPublicKeyInfo, pem);
1385
#ifndef OPENSSL_NO_SM2
1386
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, EncryptedPrivateKeyInfo, der);
1387
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, EncryptedPrivateKeyInfo, pem);
1388
8
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, PrivateKeyInfo, der);
1389
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, PrivateKeyInfo, pem);
1390
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, SubjectPublicKeyInfo, der);
1391
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, SubjectPublicKeyInfo, pem);
1392
#endif
1393
0
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, EncryptedPrivateKeyInfo, der);
1394
0
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, EncryptedPrivateKeyInfo, pem);
1395
7
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, PrivateKeyInfo, der);
1396
0
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, PrivateKeyInfo, pem);
1397
0
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, SubjectPublicKeyInfo, der);
1398
0
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, SubjectPublicKeyInfo, pem);
1399
0
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, EncryptedPrivateKeyInfo, der);
1400
0
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, EncryptedPrivateKeyInfo, pem);
1401
4
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, PrivateKeyInfo, der);
1402
0
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, PrivateKeyInfo, pem);
1403
0
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, SubjectPublicKeyInfo, der);
1404
0
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, SubjectPublicKeyInfo, pem);
1405
0
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, EncryptedPrivateKeyInfo, der);
1406
0
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, EncryptedPrivateKeyInfo, pem);
1407
9
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, PrivateKeyInfo, der);
1408
0
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, PrivateKeyInfo, pem);
1409
0
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, SubjectPublicKeyInfo, der);
1410
0
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, SubjectPublicKeyInfo, pem);
1411
0
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, EncryptedPrivateKeyInfo, der);
1412
0
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, EncryptedPrivateKeyInfo, pem);
1413
6
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, PrivateKeyInfo, der);
1414
0
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, PrivateKeyInfo, pem);
1415
0
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, SubjectPublicKeyInfo, der);
1416
0
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, SubjectPublicKeyInfo, pem);
1417
#endif
1418
1419
/*
1420
 * Support for key type specific output formats.  Not all key types have
1421
 * this, we only aim to duplicate what is available in 1.1.1 as
1422
 * i2d_TYPEPrivateKey(), i2d_TYPEPublicKey() and i2d_TYPEparams().
1423
 * For example, there are no publicly available i2d_ function for
1424
 * ED25519, ED448, X25519 or X448, and they therefore only have PKCS#8
1425
 * and SubjectPublicKeyInfo implementations as implemented above.
1426
 */
1427
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, RSA, der);
1428
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, RSA, pem);
1429
#ifndef OPENSSL_NO_DH
1430
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, DH, der);
1431
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, DH, pem);
1432
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, DHX, der);
1433
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, DHX, pem);
1434
#endif
1435
#ifndef OPENSSL_NO_DSA
1436
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, DSA, der);
1437
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, DSA, pem);
1438
#endif
1439
#ifndef OPENSSL_NO_EC
1440
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, EC, der);
1441
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, EC, pem);
1442
#ifndef OPENSSL_NO_SM2
1443
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, SM2, der);
1444
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, SM2, pem);
1445
#endif
1446
#endif
1447
1448
/* Convenience structure names */
1449
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, PKCS1, der);
1450
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, PKCS1, pem);
1451
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, PKCS1, der);
1452
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, PKCS1, pem);
1453
#ifndef OPENSSL_NO_DH
1454
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, PKCS3, der); /* parameters only */
1455
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, PKCS3, pem); /* parameters only */
1456
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, X9_42, der); /* parameters only */
1457
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, X9_42, pem); /* parameters only */
1458
#endif
1459
#ifndef OPENSSL_NO_EC
1460
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, X9_62, der);
1461
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, X9_62, pem);
1462
#endif