Coverage Report

Created: 2025-12-31 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl33/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_ASN1_LIB);
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_X509_LIB);
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_* primarily 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_PROV_LIB);
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_ASN1_LIB);
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_ASN1_LIB);
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_ASN1_LIB);
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_ASN1_LIB);
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_ASN1_LIB);
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_ASN1_LIB);
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_ECX
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
        return 0;
765
766
0
    *pder = keyblob;
767
0
    return ecxkey->keylen;
768
0
}
769
770
static int ecx_pki_priv_to_der(const void *vecxkey, unsigned char **pder)
771
26
{
772
26
    const ECX_KEY *ecxkey = vecxkey;
773
26
    ASN1_OCTET_STRING oct;
774
26
    int keybloblen;
775
776
26
    if (ecxkey == NULL || ecxkey->privkey == NULL) {
777
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
778
0
        return 0;
779
0
    }
780
781
26
    oct.data = ecxkey->privkey;
782
26
    oct.length = ecxkey->keylen;
783
26
    oct.flags = 0;
784
785
26
    keybloblen = i2d_ASN1_OCTET_STRING(&oct, pder);
786
26
    if (keybloblen < 0) {
787
0
        ERR_raise(ERR_LIB_PROV, ERR_R_ASN1_LIB);
788
0
        return 0;
789
0
    }
790
791
26
    return keybloblen;
792
26
}
793
794
0
#define ecx_epki_priv_to_der ecx_pki_priv_to_der
795
796
/*
797
 * ED25519, ED448, X25519 and X448 only has PKCS#8 / SubjectPublicKeyInfo
798
 * representation, so we don't define ecx_type_specific_[priv,pub,params]_to_der.
799
 */
800
801
26
#define ecx_check_key_type NULL
802
803
7
#define ed25519_evp_type EVP_PKEY_ED25519
804
4
#define ed448_evp_type EVP_PKEY_ED448
805
9
#define x25519_evp_type EVP_PKEY_X25519
806
6
#define x448_evp_type EVP_PKEY_X448
807
#define ed25519_input_type "ED25519"
808
#define ed448_input_type "ED448"
809
#define x25519_input_type "X25519"
810
#define x448_input_type "X448"
811
7
#define ed25519_pem_type "ED25519"
812
4
#define ed448_pem_type "ED448"
813
9
#define x25519_pem_type "X25519"
814
6
#define x448_pem_type "X448"
815
#endif
816
817
/* ---------------------------------------------------------------------- */
818
819
/*
820
 * Helper functions to prepare RSA-PSS params for encoding.  We would
821
 * have simply written the whole AlgorithmIdentifier, but existing libcrypto
822
 * functionality doesn't allow that.
823
 */
824
825
static int prepare_rsa_params(const void *rsa, int nid, int save,
826
    void **pstr, int *pstrtype)
827
8
{
828
8
    const RSA_PSS_PARAMS_30 *pss = ossl_rsa_get0_pss_params_30((RSA *)rsa);
829
830
8
    *pstr = NULL;
831
832
8
    switch (RSA_test_flags(rsa, RSA_FLAG_TYPE_MASK)) {
833
0
    case RSA_FLAG_TYPE_RSA:
834
        /* If plain RSA, the parameters shall be NULL */
835
0
        *pstrtype = V_ASN1_NULL;
836
0
        return 1;
837
8
    case RSA_FLAG_TYPE_RSASSAPSS:
838
8
        if (ossl_rsa_pss_params_30_is_unrestricted(pss)) {
839
0
            *pstrtype = V_ASN1_UNDEF;
840
0
            return 1;
841
8
        } else {
842
8
            ASN1_STRING *astr = NULL;
843
8
            WPACKET pkt;
844
8
            unsigned char *str = NULL;
845
8
            size_t str_sz = 0;
846
8
            int i;
847
848
24
            for (i = 0; i < 2; i++) {
849
16
                switch (i) {
850
8
                case 0:
851
8
                    if (!WPACKET_init_null_der(&pkt))
852
0
                        goto err;
853
8
                    break;
854
8
                case 1:
855
8
                    if ((str = OPENSSL_malloc(str_sz)) == NULL
856
8
                        || !WPACKET_init_der(&pkt, str, str_sz)) {
857
0
                        WPACKET_cleanup(&pkt);
858
0
                        goto err;
859
0
                    }
860
8
                    break;
861
16
                }
862
16
                if (!ossl_DER_w_RSASSA_PSS_params(&pkt, -1, pss)
863
16
                    || !WPACKET_finish(&pkt)
864
16
                    || !WPACKET_get_total_written(&pkt, &str_sz)) {
865
0
                    WPACKET_cleanup(&pkt);
866
0
                    goto err;
867
0
                }
868
16
                WPACKET_cleanup(&pkt);
869
870
                /*
871
                 * If no PSS parameters are going to be written, there's no
872
                 * point going for another iteration.
873
                 * This saves us from getting |str| allocated just to have it
874
                 * immediately de-allocated.
875
                 */
876
16
                if (str_sz == 0)
877
0
                    break;
878
16
            }
879
880
8
            if ((astr = ASN1_STRING_new()) == NULL)
881
0
                goto err;
882
8
            *pstrtype = V_ASN1_SEQUENCE;
883
8
            ASN1_STRING_set0(astr, str, (int)str_sz);
884
8
            *pstr = astr;
885
886
8
            return 1;
887
0
        err:
888
0
            OPENSSL_free(str);
889
0
            return 0;
890
8
        }
891
8
    }
892
893
    /* Currently unsupported RSA key type */
894
0
    return 0;
895
8
}
896
897
/*
898
 * RSA is extremely simple, as PKCS#1 is used for the PKCS#8 |privateKey|
899
 * field as well as the SubjectPublicKeyInfo |subjectPublicKey| field.
900
 */
901
8
#define rsa_pki_priv_to_der rsa_type_specific_priv_to_der
902
0
#define rsa_epki_priv_to_der rsa_type_specific_priv_to_der
903
0
#define rsa_spki_pub_to_der rsa_type_specific_pub_to_der
904
1.09k
#define rsa_type_specific_priv_to_der (i2d_of_void *)i2d_RSAPrivateKey
905
0
#define rsa_type_specific_pub_to_der (i2d_of_void *)i2d_RSAPublicKey
906
#define rsa_type_specific_params_to_der NULL
907
908
static int rsa_check_key_type(const void *rsa, int expected_type)
909
1.09k
{
910
1.09k
    switch (RSA_test_flags(rsa, RSA_FLAG_TYPE_MASK)) {
911
1.08k
    case RSA_FLAG_TYPE_RSA:
912
1.08k
        return expected_type == EVP_PKEY_RSA;
913
8
    case RSA_FLAG_TYPE_RSASSAPSS:
914
8
        return expected_type == EVP_PKEY_RSA_PSS;
915
1.09k
    }
916
917
    /* Currently unsupported RSA key type */
918
0
    return EVP_PKEY_NONE;
919
1.09k
}
920
921
1.08k
#define rsa_evp_type EVP_PKEY_RSA
922
8
#define rsapss_evp_type EVP_PKEY_RSA_PSS
923
#define rsa_input_type "RSA"
924
#define rsapss_input_type "RSA-PSS"
925
1.08k
#define rsa_pem_type "RSA"
926
8
#define rsapss_pem_type "RSA-PSS"
927
928
/* ---------------------------------------------------------------------- */
929
930
static OSSL_FUNC_decoder_newctx_fn key2any_newctx;
931
static OSSL_FUNC_decoder_freectx_fn key2any_freectx;
932
933
static void *key2any_newctx(void *provctx)
934
566k
{
935
566k
    struct key2any_ctx_st *ctx = OPENSSL_zalloc(sizeof(*ctx));
936
937
566k
    if (ctx != NULL) {
938
566k
        ctx->provctx = provctx;
939
566k
        ctx->save_parameters = 1;
940
566k
    }
941
942
566k
    return ctx;
943
566k
}
944
945
static void key2any_freectx(void *vctx)
946
566k
{
947
566k
    struct key2any_ctx_st *ctx = vctx;
948
949
566k
    ossl_pw_clear_passphrase_data(&ctx->pwdata);
950
566k
    EVP_CIPHER_free(ctx->cipher);
951
566k
    OPENSSL_free(ctx);
952
566k
}
953
954
static const OSSL_PARAM *key2any_settable_ctx_params(ossl_unused void *provctx)
955
0
{
956
0
    static const OSSL_PARAM settables[] = {
957
0
        OSSL_PARAM_utf8_string(OSSL_ENCODER_PARAM_CIPHER, NULL, 0),
958
0
        OSSL_PARAM_utf8_string(OSSL_ENCODER_PARAM_PROPERTIES, NULL, 0),
959
0
        OSSL_PARAM_END,
960
0
    };
961
962
0
    return settables;
963
0
}
964
965
static int key2any_set_ctx_params(void *vctx, const OSSL_PARAM params[])
966
366k
{
967
366k
    struct key2any_ctx_st *ctx = vctx;
968
366k
    OSSL_LIB_CTX *libctx = ossl_prov_ctx_get0_libctx(ctx->provctx);
969
366k
    const OSSL_PARAM *cipherp = OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_CIPHER);
970
366k
    const OSSL_PARAM *propsp = OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_PROPERTIES);
971
366k
    const OSSL_PARAM *save_paramsp = OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_SAVE_PARAMETERS);
972
973
366k
    if (cipherp != NULL) {
974
0
        const char *ciphername = NULL;
975
0
        const char *props = NULL;
976
977
0
        if (!OSSL_PARAM_get_utf8_string_ptr(cipherp, &ciphername))
978
0
            return 0;
979
0
        if (propsp != NULL && !OSSL_PARAM_get_utf8_string_ptr(propsp, &props))
980
0
            return 0;
981
982
0
        EVP_CIPHER_free(ctx->cipher);
983
0
        ctx->cipher = NULL;
984
0
        ctx->cipher_intent = ciphername != NULL;
985
0
        if (ciphername != NULL
986
0
            && ((ctx->cipher = EVP_CIPHER_fetch(libctx, ciphername, props)) == NULL))
987
0
            return 0;
988
0
    }
989
990
366k
    if (save_paramsp != NULL) {
991
366k
        if (!OSSL_PARAM_get_int(save_paramsp, &ctx->save_parameters))
992
0
            return 0;
993
366k
    }
994
366k
    return 1;
995
366k
}
996
997
static int key2any_check_selection(int selection, int selection_mask)
998
2.53M
{
999
    /*
1000
     * The selections are kinda sorta "levels", i.e. each selection given
1001
     * here is assumed to include those following.
1002
     */
1003
2.53M
    int checks[] = {
1004
2.53M
        OSSL_KEYMGMT_SELECT_PRIVATE_KEY,
1005
2.53M
        OSSL_KEYMGMT_SELECT_PUBLIC_KEY,
1006
2.53M
        OSSL_KEYMGMT_SELECT_ALL_PARAMETERS
1007
2.53M
    };
1008
2.53M
    size_t i;
1009
1010
    /* The decoder implementations made here support guessing */
1011
2.53M
    if (selection == 0)
1012
0
        return 1;
1013
1014
4.87M
    for (i = 0; i < OSSL_NELEM(checks); i++) {
1015
4.87M
        int check1 = (selection & checks[i]) != 0;
1016
4.87M
        int check2 = (selection_mask & checks[i]) != 0;
1017
1018
        /*
1019
         * If the caller asked for the currently checked bit(s), return
1020
         * whether the decoder description says it's supported.
1021
         */
1022
4.87M
        if (check1)
1023
2.53M
            return check2;
1024
4.87M
    }
1025
1026
    /* This should be dead code, but just to be safe... */
1027
0
    return 0;
1028
2.53M
}
1029
1030
static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout,
1031
    const void *key, int type, const char *pemname,
1032
    check_key_type_fn *checker,
1033
    key_to_der_fn *writer,
1034
    OSSL_PASSPHRASE_CALLBACK *pwcb, void *pwcbarg,
1035
    key_to_paramstring_fn *key2paramstring,
1036
    i2d_of_void *key2der)
1037
11.0k
{
1038
11.0k
    int ret = 0;
1039
1040
11.0k
    if (key == NULL) {
1041
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
1042
11.0k
    } else if (writer != NULL
1043
11.0k
        && (checker == NULL || checker(key, type))) {
1044
11.0k
        BIO *out = ossl_bio_new_from_core_bio(ctx->provctx, cout);
1045
1046
11.0k
        if (out != NULL
1047
11.0k
            && (pwcb == NULL
1048
11.0k
                || ossl_pw_set_ossl_passphrase_cb(&ctx->pwdata, pwcb, pwcbarg)))
1049
11.0k
            ret = writer(out, key, type, pemname, key2paramstring, key2der, ctx);
1050
1051
11.0k
        BIO_free(out);
1052
11.0k
    } else {
1053
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
1054
0
    }
1055
11.0k
    return ret;
1056
11.0k
}
1057
1058
1.51M
#define DO_PRIVATE_KEY_selection_mask OSSL_KEYMGMT_SELECT_PRIVATE_KEY
1059
#define DO_PRIVATE_KEY(impl, type, kind, output)               \
1060
10.8k
    if ((selection & DO_PRIVATE_KEY_selection_mask) != 0)      \
1061
10.8k
        return key2any_encode(ctx, cout, key, impl##_evp_type, \
1062
10.8k
            impl##_pem_type " PRIVATE KEY",                    \
1063
10.8k
            type##_check_key_type,                             \
1064
10.8k
            key_to_##kind##_##output##_priv_bio,               \
1065
10.8k
            cb, cbarg, prepare_##type##_params,                \
1066
10.8k
            type##_##kind##_priv_to_der);
1067
1068
861k
#define DO_PUBLIC_KEY_selection_mask OSSL_KEYMGMT_SELECT_PUBLIC_KEY
1069
#define DO_PUBLIC_KEY(impl, type, kind, output)                \
1070
0
    if ((selection & DO_PUBLIC_KEY_selection_mask) != 0)       \
1071
0
        return key2any_encode(ctx, cout, key, impl##_evp_type, \
1072
0
            impl##_pem_type " PUBLIC KEY",                     \
1073
0
            type##_check_key_type,                             \
1074
0
            key_to_##kind##_##output##_pub_bio,                \
1075
0
            cb, cbarg, prepare_##type##_params,                \
1076
0
            type##_##kind##_pub_to_der);
1077
1078
737k
#define DO_PARAMETERS_selection_mask OSSL_KEYMGMT_SELECT_ALL_PARAMETERS
1079
#define DO_PARAMETERS(impl, type, kind, output)                \
1080
0
    if ((selection & DO_PARAMETERS_selection_mask) != 0)       \
1081
0
        return key2any_encode(ctx, cout, key, impl##_evp_type, \
1082
0
            impl##_pem_type " PARAMETERS",                     \
1083
0
            type##_check_key_type,                             \
1084
0
            key_to_##kind##_##output##_param_bio,              \
1085
0
            NULL, NULL, NULL,                                  \
1086
0
            type##_##kind##_params_to_der);
1087
1088
/*-
1089
 * Implement the kinds of output structure that can be produced.  They are
1090
 * referred to by name, and for each name, the following macros are defined
1091
 * (braces not included):
1092
 *
1093
 * DO_{kind}_selection_mask
1094
 *
1095
 *      A mask of selection bits that must not be zero.  This is used as a
1096
 *      selection criterion for each implementation.
1097
 *      This mask must never be zero.
1098
 *
1099
 * DO_{kind}
1100
 *
1101
 *      The performing macro.  It must use the DO_ macros defined above,
1102
 *      always in this order:
1103
 *
1104
 *      - DO_PRIVATE_KEY
1105
 *      - DO_PUBLIC_KEY
1106
 *      - DO_PARAMETERS
1107
 *
1108
 *      Any of those may be omitted, but the relative order must still be
1109
 *      the same.
1110
 */
1111
1112
/*
1113
 * PKCS#8 defines two structures for private keys only:
1114
 * - PrivateKeyInfo             (raw unencrypted form)
1115
 * - EncryptedPrivateKeyInfo    (encrypted wrapping)
1116
 *
1117
 * To allow a certain amount of flexibility, we allow the routines
1118
 * for PrivateKeyInfo to also produce EncryptedPrivateKeyInfo if a
1119
 * passphrase callback has been passed to them.
1120
 */
1121
496k
#define DO_PrivateKeyInfo_selection_mask DO_PRIVATE_KEY_selection_mask
1122
#define DO_PrivateKeyInfo(impl, type, output) \
1123
1.58k
    DO_PRIVATE_KEY(impl, type, pki, output)
1124
1125
496k
#define DO_EncryptedPrivateKeyInfo_selection_mask DO_PRIVATE_KEY_selection_mask
1126
#define DO_EncryptedPrivateKeyInfo(impl, type, output) \
1127
0
    DO_PRIVATE_KEY(impl, type, epki, output)
1128
1129
/* SubjectPublicKeyInfo is a structure for public keys only */
1130
602k
#define DO_SubjectPublicKeyInfo_selection_mask DO_PUBLIC_KEY_selection_mask
1131
#define DO_SubjectPublicKeyInfo(impl, type, output) \
1132
0
    DO_PUBLIC_KEY(impl, type, spki, output)
1133
1134
/*
1135
 * "type-specific" is a uniform name for key type specific output for private
1136
 * and public keys as well as key parameters.  This is used internally in
1137
 * libcrypto so it doesn't have to have special knowledge about select key
1138
 * types, but also when no better name has been found.  If there are more
1139
 * expressive DO_ names above, those are preferred.
1140
 *
1141
 * Three forms exist:
1142
 *
1143
 * - type_specific_keypair              Only supports private and public key
1144
 * - type_specific_params               Only supports parameters
1145
 * - type_specific                      Supports all parts of an EVP_PKEY
1146
 * - type_specific_no_pub               Supports all parts of an EVP_PKEY
1147
 *                                      except public key
1148
 */
1149
484k
#define DO_type_specific_params_selection_mask DO_PARAMETERS_selection_mask
1150
#define DO_type_specific_params(impl, type, output) \
1151
0
    DO_PARAMETERS(impl, type, type_specific, output)
1152
#define DO_type_specific_keypair_selection_mask \
1153
258k
    (DO_PRIVATE_KEY_selection_mask | DO_PUBLIC_KEY_selection_mask)
1154
#define DO_type_specific_keypair(impl, type, output)  \
1155
4.30k
    DO_PRIVATE_KEY(impl, type, type_specific, output) \
1156
4.30k
    DO_PUBLIC_KEY(impl, type, type_specific, output)
1157
#define DO_type_specific_selection_mask      \
1158
70.7k
    (DO_type_specific_keypair_selection_mask \
1159
70.7k
        | DO_type_specific_params_selection_mask)
1160
#define DO_type_specific(impl, type, output)     \
1161
3.21k
    DO_type_specific_keypair(impl, type, output) \
1162
0
        DO_type_specific_params(impl, type, output)
1163
#define DO_type_specific_no_pub_selection_mask \
1164
253k
    (DO_PRIVATE_KEY_selection_mask | DO_PARAMETERS_selection_mask)
1165
#define DO_type_specific_no_pub(impl, type, output)   \
1166
4.99k
    DO_PRIVATE_KEY(impl, type, type_specific, output) \
1167
4.99k
    DO_type_specific_params(impl, type, output)
1168
1169
/*
1170
 * Type specific aliases for the cases where we need to refer to them by
1171
 * type name.
1172
 * This only covers key types that are represented with i2d_{TYPE}PrivateKey,
1173
 * i2d_{TYPE}PublicKey and i2d_{TYPE}params / i2d_{TYPE}Parameters.
1174
 */
1175
125k
#define DO_RSA_selection_mask DO_type_specific_keypair_selection_mask
1176
0
#define DO_RSA(impl, type, output) DO_type_specific_keypair(impl, type, output)
1177
1178
68.0k
#define DO_DH_selection_mask DO_type_specific_params_selection_mask
1179
0
#define DO_DH(impl, type, output) DO_type_specific_params(impl, type, output)
1180
1181
207k
#define DO_DHX_selection_mask DO_type_specific_params_selection_mask
1182
0
#define DO_DHX(impl, type, output) DO_type_specific_params(impl, type, output)
1183
1184
35.3k
#define DO_DSA_selection_mask DO_type_specific_selection_mask
1185
0
#define DO_DSA(impl, type, output) DO_type_specific(impl, type, output)
1186
1187
168k
#define DO_EC_selection_mask DO_type_specific_no_pub_selection_mask
1188
0
#define DO_EC(impl, type, output) DO_type_specific_no_pub(impl, type, output)
1189
1190
0
#define DO_SM2_selection_mask DO_type_specific_no_pub_selection_mask
1191
0
#define DO_SM2(impl, type, output) DO_type_specific_no_pub(impl, type, output)
1192
1193
/* PKCS#1 defines a structure for RSA private and public keys */
1194
63.3k
#define DO_PKCS1_selection_mask DO_RSA_selection_mask
1195
0
#define DO_PKCS1(impl, type, output) DO_RSA(impl, type, output)
1196
1197
/* PKCS#3 defines a structure for DH parameters */
1198
34.0k
#define DO_PKCS3_selection_mask DO_DH_selection_mask
1199
0
#define DO_PKCS3(impl, type, output) DO_DH(impl, type, output)
1200
/* X9.42 defines a structure for DHx parameters */
1201
103k
#define DO_X9_42_selection_mask DO_DHX_selection_mask
1202
0
#define DO_X9_42(impl, type, output) DO_DHX(impl, type, output)
1203
1204
/* X9.62 defines a structure for EC keys and parameters */
1205
84.2k
#define DO_X9_62_selection_mask DO_EC_selection_mask
1206
0
#define DO_X9_62(impl, type, output) DO_EC(impl, type, output)
1207
1208
/*
1209
 * MAKE_ENCODER is the single driver for creating OSSL_DISPATCH tables.
1210
 * It takes the following arguments:
1211
 *
1212
 * impl         This is the key type name that's being implemented.
1213
 * type         This is the type name for the set of functions that implement
1214
 *              the key type.  For example, ed25519, ed448, x25519 and x448
1215
 *              are all implemented with the exact same set of functions.
1216
 * evp_type     The corresponding EVP_PKEY_xxx type macro for each key.
1217
 *              Necessary because we currently use EVP_PKEY with legacy
1218
 *              native keys internally.  This will need to be refactored
1219
 *              when that legacy support goes away.
1220
 * kind         What kind of support to implement.  These translate into
1221
 *              the DO_##kind macros above.
1222
 * output       The output type to implement.  may be der or pem.
1223
 *
1224
 * The resulting OSSL_DISPATCH array gets the following name (expressed in
1225
 * C preprocessor terms) from those arguments:
1226
 *
1227
 * ossl_##impl##_to_##kind##_##output##_encoder_functions
1228
 */
1229
#define MAKE_ENCODER(impl, type, evp_type, kind, output)                          \
1230
    static OSSL_FUNC_encoder_import_object_fn                                     \
1231
        impl##_to_##kind##_##output##_import_object;                              \
1232
    static OSSL_FUNC_encoder_free_object_fn                                       \
1233
        impl##_to_##kind##_##output##_free_object;                                \
1234
    static OSSL_FUNC_encoder_encode_fn                                            \
1235
        impl##_to_##kind##_##output##_encode;                                     \
1236
                                                                                  \
1237
    static void *                                                                 \
1238
    impl##_to_##kind##_##output##_import_object(void *vctx, int selection,        \
1239
        const OSSL_PARAM params[])                                                \
1240
0
    {                                                                             \
1241
0
        struct key2any_ctx_st *ctx = vctx;                                        \
1242
0
                                                                                  \
1243
0
        return ossl_prov_import_key(ossl_##impl##_keymgmt_functions,              \
1244
0
            ctx->provctx, selection, params);                                     \
1245
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
1246
    static void impl##_to_##kind##_##output##_free_object(void *key)              \
1247
0
    {                                                                             \
1248
0
        ossl_prov_free_key(ossl_##impl##_keymgmt_functions, key);                 \
1249
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
1250
    static int impl##_to_##kind##_##output##_does_selection(void *ctx,            \
1251
        int selection)                                                            \
1252
2.52M
    {                                                                             \
1253
2.52M
        return key2any_check_selection(selection,                                 \
1254
2.52M
            DO_##kind##_selection_mask);                                          \
1255
2.52M
    }                                                                             \
encode_key2any.c:rsa_to_type_specific_keypair_der_does_selection
Line
Count
Source
1252
31.2k
    {                                                                             \
1253
31.2k
        return key2any_check_selection(selection,                                 \
1254
31.2k
            DO_##kind##_selection_mask);                                          \
1255
31.2k
    }                                                                             \
encode_key2any.c:dh_to_type_specific_params_der_does_selection
Line
Count
Source
1252
17.0k
    {                                                                             \
1253
17.0k
        return key2any_check_selection(selection,                                 \
1254
17.0k
            DO_##kind##_selection_mask);                                          \
1255
17.0k
    }                                                                             \
encode_key2any.c:dhx_to_type_specific_params_der_does_selection
Line
Count
Source
1252
51.9k
    {                                                                             \
1253
51.9k
        return key2any_check_selection(selection,                                 \
1254
51.9k
            DO_##kind##_selection_mask);                                          \
1255
51.9k
    }                                                                             \
encode_key2any.c:dsa_to_type_specific_der_does_selection
Line
Count
Source
1252
17.6k
    {                                                                             \
1253
17.6k
        return key2any_check_selection(selection,                                 \
1254
17.6k
            DO_##kind##_selection_mask);                                          \
1255
17.6k
    }                                                                             \
encode_key2any.c:ec_to_type_specific_no_pub_der_does_selection
Line
Count
Source
1252
42.1k
    {                                                                             \
1253
42.1k
        return key2any_check_selection(selection,                                 \
1254
42.1k
            DO_##kind##_selection_mask);                                          \
1255
42.1k
    }                                                                             \
encode_key2any.c:sm2_to_type_specific_no_pub_der_does_selection
Line
Count
Source
1252
288
    {                                                                             \
1253
288
        return key2any_check_selection(selection,                                 \
1254
288
            DO_##kind##_selection_mask);                                          \
1255
288
    }                                                                             \
encode_key2any.c:rsa_to_type_specific_keypair_pem_does_selection
Line
Count
Source
1252
31.2k
    {                                                                             \
1253
31.2k
        return key2any_check_selection(selection,                                 \
1254
31.2k
            DO_##kind##_selection_mask);                                          \
1255
31.2k
    }                                                                             \
encode_key2any.c:dh_to_type_specific_params_pem_does_selection
Line
Count
Source
1252
17.0k
    {                                                                             \
1253
17.0k
        return key2any_check_selection(selection,                                 \
1254
17.0k
            DO_##kind##_selection_mask);                                          \
1255
17.0k
    }                                                                             \
encode_key2any.c:dhx_to_type_specific_params_pem_does_selection
Line
Count
Source
1252
51.9k
    {                                                                             \
1253
51.9k
        return key2any_check_selection(selection,                                 \
1254
51.9k
            DO_##kind##_selection_mask);                                          \
1255
51.9k
    }                                                                             \
encode_key2any.c:dsa_to_type_specific_pem_does_selection
Line
Count
Source
1252
17.6k
    {                                                                             \
1253
17.6k
        return key2any_check_selection(selection,                                 \
1254
17.6k
            DO_##kind##_selection_mask);                                          \
1255
17.6k
    }                                                                             \
encode_key2any.c:ec_to_type_specific_no_pub_pem_does_selection
Line
Count
Source
1252
42.1k
    {                                                                             \
1253
42.1k
        return key2any_check_selection(selection,                                 \
1254
42.1k
            DO_##kind##_selection_mask);                                          \
1255
42.1k
    }                                                                             \
encode_key2any.c:sm2_to_type_specific_no_pub_pem_does_selection
Line
Count
Source
1252
288
    {                                                                             \
1253
288
        return key2any_check_selection(selection,                                 \
1254
288
            DO_##kind##_selection_mask);                                          \
1255
288
    }                                                                             \
encode_key2any.c:rsa_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1252
60.8k
    {                                                                             \
1253
60.8k
        return key2any_check_selection(selection,                                 \
1254
60.8k
            DO_##kind##_selection_mask);                                          \
1255
60.8k
    }                                                                             \
encode_key2any.c:rsa_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
60.8k
    {                                                                             \
1253
60.8k
        return key2any_check_selection(selection,                                 \
1254
60.8k
            DO_##kind##_selection_mask);                                          \
1255
60.8k
    }                                                                             \
encode_key2any.c:rsa_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1252
60.8k
    {                                                                             \
1253
60.8k
        return key2any_check_selection(selection,                                 \
1254
60.8k
            DO_##kind##_selection_mask);                                          \
1255
60.8k
    }                                                                             \
encode_key2any.c:rsa_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
60.8k
    {                                                                             \
1253
60.8k
        return key2any_check_selection(selection,                                 \
1254
60.8k
            DO_##kind##_selection_mask);                                          \
1255
60.8k
    }                                                                             \
encode_key2any.c:rsa_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1252
49.2k
    {                                                                             \
1253
49.2k
        return key2any_check_selection(selection,                                 \
1254
49.2k
            DO_##kind##_selection_mask);                                          \
1255
49.2k
    }                                                                             \
encode_key2any.c:rsa_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1252
49.2k
    {                                                                             \
1253
49.2k
        return key2any_check_selection(selection,                                 \
1254
49.2k
            DO_##kind##_selection_mask);                                          \
1255
49.2k
    }                                                                             \
encode_key2any.c:rsapss_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1252
1.47k
    {                                                                             \
1253
1.47k
        return key2any_check_selection(selection,                                 \
1254
1.47k
            DO_##kind##_selection_mask);                                          \
1255
1.47k
    }                                                                             \
encode_key2any.c:rsapss_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
1.47k
    {                                                                             \
1253
1.47k
        return key2any_check_selection(selection,                                 \
1254
1.47k
            DO_##kind##_selection_mask);                                          \
1255
1.47k
    }                                                                             \
encode_key2any.c:rsapss_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1252
1.47k
    {                                                                             \
1253
1.47k
        return key2any_check_selection(selection,                                 \
1254
1.47k
            DO_##kind##_selection_mask);                                          \
1255
1.47k
    }                                                                             \
encode_key2any.c:rsapss_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
1.47k
    {                                                                             \
1253
1.47k
        return key2any_check_selection(selection,                                 \
1254
1.47k
            DO_##kind##_selection_mask);                                          \
1255
1.47k
    }                                                                             \
encode_key2any.c:rsapss_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1252
574
    {                                                                             \
1253
574
        return key2any_check_selection(selection,                                 \
1254
574
            DO_##kind##_selection_mask);                                          \
1255
574
    }                                                                             \
encode_key2any.c:rsapss_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1252
574
    {                                                                             \
1253
574
        return key2any_check_selection(selection,                                 \
1254
574
            DO_##kind##_selection_mask);                                          \
1255
574
    }                                                                             \
encode_key2any.c:dh_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1252
17.0k
    {                                                                             \
1253
17.0k
        return key2any_check_selection(selection,                                 \
1254
17.0k
            DO_##kind##_selection_mask);                                          \
1255
17.0k
    }                                                                             \
encode_key2any.c:dh_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
17.0k
    {                                                                             \
1253
17.0k
        return key2any_check_selection(selection,                                 \
1254
17.0k
            DO_##kind##_selection_mask);                                          \
1255
17.0k
    }                                                                             \
encode_key2any.c:dh_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1252
17.0k
    {                                                                             \
1253
17.0k
        return key2any_check_selection(selection,                                 \
1254
17.0k
            DO_##kind##_selection_mask);                                          \
1255
17.0k
    }                                                                             \
encode_key2any.c:dh_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
17.0k
    {                                                                             \
1253
17.0k
        return key2any_check_selection(selection,                                 \
1254
17.0k
            DO_##kind##_selection_mask);                                          \
1255
17.0k
    }                                                                             \
encode_key2any.c:dh_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1252
15.4k
    {                                                                             \
1253
15.4k
        return key2any_check_selection(selection,                                 \
1254
15.4k
            DO_##kind##_selection_mask);                                          \
1255
15.4k
    }                                                                             \
encode_key2any.c:dh_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1252
15.4k
    {                                                                             \
1253
15.4k
        return key2any_check_selection(selection,                                 \
1254
15.4k
            DO_##kind##_selection_mask);                                          \
1255
15.4k
    }                                                                             \
encode_key2any.c:dhx_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1252
51.0k
    {                                                                             \
1253
51.0k
        return key2any_check_selection(selection,                                 \
1254
51.0k
            DO_##kind##_selection_mask);                                          \
1255
51.0k
    }                                                                             \
encode_key2any.c:dhx_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
51.0k
    {                                                                             \
1253
51.0k
        return key2any_check_selection(selection,                                 \
1254
51.0k
            DO_##kind##_selection_mask);                                          \
1255
51.0k
    }                                                                             \
encode_key2any.c:dhx_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1252
51.0k
    {                                                                             \
1253
51.0k
        return key2any_check_selection(selection,                                 \
1254
51.0k
            DO_##kind##_selection_mask);                                          \
1255
51.0k
    }                                                                             \
encode_key2any.c:dhx_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
51.0k
    {                                                                             \
1253
51.0k
        return key2any_check_selection(selection,                                 \
1254
51.0k
            DO_##kind##_selection_mask);                                          \
1255
51.0k
    }                                                                             \
encode_key2any.c:dhx_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1252
51.7k
    {                                                                             \
1253
51.7k
        return key2any_check_selection(selection,                                 \
1254
51.7k
            DO_##kind##_selection_mask);                                          \
1255
51.7k
    }                                                                             \
encode_key2any.c:dhx_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1252
51.7k
    {                                                                             \
1253
51.7k
        return key2any_check_selection(selection,                                 \
1254
51.7k
            DO_##kind##_selection_mask);                                          \
1255
51.7k
    }                                                                             \
encode_key2any.c:dsa_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1252
64.5k
    {                                                                             \
1253
64.5k
        return key2any_check_selection(selection,                                 \
1254
64.5k
            DO_##kind##_selection_mask);                                          \
1255
64.5k
    }                                                                             \
encode_key2any.c:dsa_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
64.5k
    {                                                                             \
1253
64.5k
        return key2any_check_selection(selection,                                 \
1254
64.5k
            DO_##kind##_selection_mask);                                          \
1255
64.5k
    }                                                                             \
encode_key2any.c:dsa_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1252
64.5k
    {                                                                             \
1253
64.5k
        return key2any_check_selection(selection,                                 \
1254
64.5k
            DO_##kind##_selection_mask);                                          \
1255
64.5k
    }                                                                             \
encode_key2any.c:dsa_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
64.5k
    {                                                                             \
1253
64.5k
        return key2any_check_selection(selection,                                 \
1254
64.5k
            DO_##kind##_selection_mask);                                          \
1255
64.5k
    }                                                                             \
encode_key2any.c:dsa_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1252
112k
    {                                                                             \
1253
112k
        return key2any_check_selection(selection,                                 \
1254
112k
            DO_##kind##_selection_mask);                                          \
1255
112k
    }                                                                             \
encode_key2any.c:dsa_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1252
112k
    {                                                                             \
1253
112k
        return key2any_check_selection(selection,                                 \
1254
112k
            DO_##kind##_selection_mask);                                          \
1255
112k
    }                                                                             \
encode_key2any.c:ec_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1252
51.9k
    {                                                                             \
1253
51.9k
        return key2any_check_selection(selection,                                 \
1254
51.9k
            DO_##kind##_selection_mask);                                          \
1255
51.9k
    }                                                                             \
encode_key2any.c:ec_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
51.9k
    {                                                                             \
1253
51.9k
        return key2any_check_selection(selection,                                 \
1254
51.9k
            DO_##kind##_selection_mask);                                          \
1255
51.9k
    }                                                                             \
encode_key2any.c:ec_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1252
51.9k
    {                                                                             \
1253
51.9k
        return key2any_check_selection(selection,                                 \
1254
51.9k
            DO_##kind##_selection_mask);                                          \
1255
51.9k
    }                                                                             \
encode_key2any.c:ec_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
51.9k
    {                                                                             \
1253
51.9k
        return key2any_check_selection(selection,                                 \
1254
51.9k
            DO_##kind##_selection_mask);                                          \
1255
51.9k
    }                                                                             \
encode_key2any.c:ec_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1252
70.6k
    {                                                                             \
1253
70.6k
        return key2any_check_selection(selection,                                 \
1254
70.6k
            DO_##kind##_selection_mask);                                          \
1255
70.6k
    }                                                                             \
encode_key2any.c:ec_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1252
70.6k
    {                                                                             \
1253
70.6k
        return key2any_check_selection(selection,                                 \
1254
70.6k
            DO_##kind##_selection_mask);                                          \
1255
70.6k
    }                                                                             \
encode_key2any.c:sm2_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1252
331
    {                                                                             \
1253
331
        return key2any_check_selection(selection,                                 \
1254
331
            DO_##kind##_selection_mask);                                          \
1255
331
    }                                                                             \
encode_key2any.c:sm2_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
331
    {                                                                             \
1253
331
        return key2any_check_selection(selection,                                 \
1254
331
            DO_##kind##_selection_mask);                                          \
1255
331
    }                                                                             \
encode_key2any.c:sm2_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1252
331
    {                                                                             \
1253
331
        return key2any_check_selection(selection,                                 \
1254
331
            DO_##kind##_selection_mask);                                          \
1255
331
    }                                                                             \
encode_key2any.c:sm2_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
331
    {                                                                             \
1253
331
        return key2any_check_selection(selection,                                 \
1254
331
            DO_##kind##_selection_mask);                                          \
1255
331
    }                                                                             \
encode_key2any.c:sm2_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1252
363
    {                                                                             \
1253
363
        return key2any_check_selection(selection,                                 \
1254
363
            DO_##kind##_selection_mask);                                          \
1255
363
    }                                                                             \
encode_key2any.c:sm2_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1252
363
    {                                                                             \
1253
363
        return key2any_check_selection(selection,                                 \
1254
363
            DO_##kind##_selection_mask);                                          \
1255
363
    }                                                                             \
encode_key2any.c:ed25519_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1252
384
    {                                                                             \
1253
384
        return key2any_check_selection(selection,                                 \
1254
384
            DO_##kind##_selection_mask);                                          \
1255
384
    }                                                                             \
encode_key2any.c:ed25519_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
384
    {                                                                             \
1253
384
        return key2any_check_selection(selection,                                 \
1254
384
            DO_##kind##_selection_mask);                                          \
1255
384
    }                                                                             \
encode_key2any.c:ed25519_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1252
384
    {                                                                             \
1253
384
        return key2any_check_selection(selection,                                 \
1254
384
            DO_##kind##_selection_mask);                                          \
1255
384
    }                                                                             \
encode_key2any.c:ed25519_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
384
    {                                                                             \
1253
384
        return key2any_check_selection(selection,                                 \
1254
384
            DO_##kind##_selection_mask);                                          \
1255
384
    }                                                                             \
encode_key2any.c:ed25519_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1252
246
    {                                                                             \
1253
246
        return key2any_check_selection(selection,                                 \
1254
246
            DO_##kind##_selection_mask);                                          \
1255
246
    }                                                                             \
encode_key2any.c:ed25519_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1252
246
    {                                                                             \
1253
246
        return key2any_check_selection(selection,                                 \
1254
246
            DO_##kind##_selection_mask);                                          \
1255
246
    }                                                                             \
encode_key2any.c:ed448_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1252
233
    {                                                                             \
1253
233
        return key2any_check_selection(selection,                                 \
1254
233
            DO_##kind##_selection_mask);                                          \
1255
233
    }                                                                             \
encode_key2any.c:ed448_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
233
    {                                                                             \
1253
233
        return key2any_check_selection(selection,                                 \
1254
233
            DO_##kind##_selection_mask);                                          \
1255
233
    }                                                                             \
encode_key2any.c:ed448_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1252
233
    {                                                                             \
1253
233
        return key2any_check_selection(selection,                                 \
1254
233
            DO_##kind##_selection_mask);                                          \
1255
233
    }                                                                             \
encode_key2any.c:ed448_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
233
    {                                                                             \
1253
233
        return key2any_check_selection(selection,                                 \
1254
233
            DO_##kind##_selection_mask);                                          \
1255
233
    }                                                                             \
encode_key2any.c:ed448_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1252
167
    {                                                                             \
1253
167
        return key2any_check_selection(selection,                                 \
1254
167
            DO_##kind##_selection_mask);                                          \
1255
167
    }                                                                             \
encode_key2any.c:ed448_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1252
167
    {                                                                             \
1253
167
        return key2any_check_selection(selection,                                 \
1254
167
            DO_##kind##_selection_mask);                                          \
1255
167
    }                                                                             \
encode_key2any.c:x25519_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1252
136
    {                                                                             \
1253
136
        return key2any_check_selection(selection,                                 \
1254
136
            DO_##kind##_selection_mask);                                          \
1255
136
    }                                                                             \
encode_key2any.c:x25519_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
136
    {                                                                             \
1253
136
        return key2any_check_selection(selection,                                 \
1254
136
            DO_##kind##_selection_mask);                                          \
1255
136
    }                                                                             \
encode_key2any.c:x25519_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1252
136
    {                                                                             \
1253
136
        return key2any_check_selection(selection,                                 \
1254
136
            DO_##kind##_selection_mask);                                          \
1255
136
    }                                                                             \
encode_key2any.c:x25519_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
136
    {                                                                             \
1253
136
        return key2any_check_selection(selection,                                 \
1254
136
            DO_##kind##_selection_mask);                                          \
1255
136
    }                                                                             \
encode_key2any.c:x25519_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1252
131
    {                                                                             \
1253
131
        return key2any_check_selection(selection,                                 \
1254
131
            DO_##kind##_selection_mask);                                          \
1255
131
    }                                                                             \
encode_key2any.c:x25519_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1252
131
    {                                                                             \
1253
131
        return key2any_check_selection(selection,                                 \
1254
131
            DO_##kind##_selection_mask);                                          \
1255
131
    }                                                                             \
encode_key2any.c:x448_to_EncryptedPrivateKeyInfo_der_does_selection
Line
Count
Source
1252
126
    {                                                                             \
1253
126
        return key2any_check_selection(selection,                                 \
1254
126
            DO_##kind##_selection_mask);                                          \
1255
126
    }                                                                             \
encode_key2any.c:x448_to_EncryptedPrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
126
    {                                                                             \
1253
126
        return key2any_check_selection(selection,                                 \
1254
126
            DO_##kind##_selection_mask);                                          \
1255
126
    }                                                                             \
encode_key2any.c:x448_to_PrivateKeyInfo_der_does_selection
Line
Count
Source
1252
126
    {                                                                             \
1253
126
        return key2any_check_selection(selection,                                 \
1254
126
            DO_##kind##_selection_mask);                                          \
1255
126
    }                                                                             \
encode_key2any.c:x448_to_PrivateKeyInfo_pem_does_selection
Line
Count
Source
1252
126
    {                                                                             \
1253
126
        return key2any_check_selection(selection,                                 \
1254
126
            DO_##kind##_selection_mask);                                          \
1255
126
    }                                                                             \
encode_key2any.c:x448_to_SubjectPublicKeyInfo_der_does_selection
Line
Count
Source
1252
115
    {                                                                             \
1253
115
        return key2any_check_selection(selection,                                 \
1254
115
            DO_##kind##_selection_mask);                                          \
1255
115
    }                                                                             \
encode_key2any.c:x448_to_SubjectPublicKeyInfo_pem_does_selection
Line
Count
Source
1252
115
    {                                                                             \
1253
115
        return key2any_check_selection(selection,                                 \
1254
115
            DO_##kind##_selection_mask);                                          \
1255
115
    }                                                                             \
encode_key2any.c:rsa_to_RSA_der_does_selection
Line
Count
Source
1252
31.2k
    {                                                                             \
1253
31.2k
        return key2any_check_selection(selection,                                 \
1254
31.2k
            DO_##kind##_selection_mask);                                          \
1255
31.2k
    }                                                                             \
encode_key2any.c:rsa_to_RSA_pem_does_selection
Line
Count
Source
1252
31.2k
    {                                                                             \
1253
31.2k
        return key2any_check_selection(selection,                                 \
1254
31.2k
            DO_##kind##_selection_mask);                                          \
1255
31.2k
    }                                                                             \
encode_key2any.c:dh_to_DH_der_does_selection
Line
Count
Source
1252
17.0k
    {                                                                             \
1253
17.0k
        return key2any_check_selection(selection,                                 \
1254
17.0k
            DO_##kind##_selection_mask);                                          \
1255
17.0k
    }                                                                             \
encode_key2any.c:dh_to_DH_pem_does_selection
Line
Count
Source
1252
17.0k
    {                                                                             \
1253
17.0k
        return key2any_check_selection(selection,                                 \
1254
17.0k
            DO_##kind##_selection_mask);                                          \
1255
17.0k
    }                                                                             \
encode_key2any.c:dhx_to_DHX_der_does_selection
Line
Count
Source
1252
51.9k
    {                                                                             \
1253
51.9k
        return key2any_check_selection(selection,                                 \
1254
51.9k
            DO_##kind##_selection_mask);                                          \
1255
51.9k
    }                                                                             \
encode_key2any.c:dhx_to_DHX_pem_does_selection
Line
Count
Source
1252
51.9k
    {                                                                             \
1253
51.9k
        return key2any_check_selection(selection,                                 \
1254
51.9k
            DO_##kind##_selection_mask);                                          \
1255
51.9k
    }                                                                             \
encode_key2any.c:dsa_to_DSA_der_does_selection
Line
Count
Source
1252
17.6k
    {                                                                             \
1253
17.6k
        return key2any_check_selection(selection,                                 \
1254
17.6k
            DO_##kind##_selection_mask);                                          \
1255
17.6k
    }                                                                             \
encode_key2any.c:dsa_to_DSA_pem_does_selection
Line
Count
Source
1252
17.6k
    {                                                                             \
1253
17.6k
        return key2any_check_selection(selection,                                 \
1254
17.6k
            DO_##kind##_selection_mask);                                          \
1255
17.6k
    }                                                                             \
encode_key2any.c:ec_to_EC_der_does_selection
Line
Count
Source
1252
42.1k
    {                                                                             \
1253
42.1k
        return key2any_check_selection(selection,                                 \
1254
42.1k
            DO_##kind##_selection_mask);                                          \
1255
42.1k
    }                                                                             \
encode_key2any.c:ec_to_EC_pem_does_selection
Line
Count
Source
1252
42.1k
    {                                                                             \
1253
42.1k
        return key2any_check_selection(selection,                                 \
1254
42.1k
            DO_##kind##_selection_mask);                                          \
1255
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
1252
31.2k
    {                                                                             \
1253
31.2k
        return key2any_check_selection(selection,                                 \
1254
31.2k
            DO_##kind##_selection_mask);                                          \
1255
31.2k
    }                                                                             \
encode_key2any.c:rsa_to_PKCS1_pem_does_selection
Line
Count
Source
1252
31.2k
    {                                                                             \
1253
31.2k
        return key2any_check_selection(selection,                                 \
1254
31.2k
            DO_##kind##_selection_mask);                                          \
1255
31.2k
    }                                                                             \
encode_key2any.c:rsapss_to_PKCS1_der_does_selection
Line
Count
Source
1252
451
    {                                                                             \
1253
451
        return key2any_check_selection(selection,                                 \
1254
451
            DO_##kind##_selection_mask);                                          \
1255
451
    }                                                                             \
encode_key2any.c:rsapss_to_PKCS1_pem_does_selection
Line
Count
Source
1252
451
    {                                                                             \
1253
451
        return key2any_check_selection(selection,                                 \
1254
451
            DO_##kind##_selection_mask);                                          \
1255
451
    }                                                                             \
encode_key2any.c:dh_to_PKCS3_der_does_selection
Line
Count
Source
1252
17.0k
    {                                                                             \
1253
17.0k
        return key2any_check_selection(selection,                                 \
1254
17.0k
            DO_##kind##_selection_mask);                                          \
1255
17.0k
    }                                                                             \
encode_key2any.c:dh_to_PKCS3_pem_does_selection
Line
Count
Source
1252
17.0k
    {                                                                             \
1253
17.0k
        return key2any_check_selection(selection,                                 \
1254
17.0k
            DO_##kind##_selection_mask);                                          \
1255
17.0k
    }                                                                             \
encode_key2any.c:dhx_to_X9_42_der_does_selection
Line
Count
Source
1252
51.9k
    {                                                                             \
1253
51.9k
        return key2any_check_selection(selection,                                 \
1254
51.9k
            DO_##kind##_selection_mask);                                          \
1255
51.9k
    }                                                                             \
encode_key2any.c:dhx_to_X9_42_pem_does_selection
Line
Count
Source
1252
51.9k
    {                                                                             \
1253
51.9k
        return key2any_check_selection(selection,                                 \
1254
51.9k
            DO_##kind##_selection_mask);                                          \
1255
51.9k
    }                                                                             \
encode_key2any.c:ec_to_X9_62_der_does_selection
Line
Count
Source
1252
42.1k
    {                                                                             \
1253
42.1k
        return key2any_check_selection(selection,                                 \
1254
42.1k
            DO_##kind##_selection_mask);                                          \
1255
42.1k
    }                                                                             \
encode_key2any.c:ec_to_X9_62_pem_does_selection
Line
Count
Source
1252
42.1k
    {                                                                             \
1253
42.1k
        return key2any_check_selection(selection,                                 \
1254
42.1k
            DO_##kind##_selection_mask);                                          \
1255
42.1k
    }                                                                             \
1256
    static int                                                                    \
1257
    impl##_to_##kind##_##output##_encode(void *ctx, OSSL_CORE_BIO *cout,          \
1258
        const void *key,                                                          \
1259
        const OSSL_PARAM key_abstract[],                                          \
1260
        int selection,                                                            \
1261
        OSSL_PASSPHRASE_CALLBACK *cb,                                             \
1262
        void *cbarg)                                                              \
1263
10.8k
    {                                                                             \
1264
10.8k
        /* We don't deal with abstract objects */                                 \
1265
10.8k
        if (key_abstract != NULL) {                                               \
1266
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);               \
1267
0
            return 0;                                                             \
1268
0
        }                                                                         \
1269
10.8k
        DO_##kind(impl, type, output)                                             \
1270
10.8k
                                                                                  \
1271
10.8k
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);               \
1272
0
        return 0;                                                                 \
1273
10.8k
    }                                                                             \
1274
    const OSSL_DISPATCH                                                           \
1275
        ossl_##impl##_to_##kind##_##output##_encoder_functions[]                  \
1276
        = {                                                                       \
1277
              { OSSL_FUNC_ENCODER_NEWCTX,                                         \
1278
                  (void (*)(void))key2any_newctx },                               \
1279
              { OSSL_FUNC_ENCODER_FREECTX,                                        \
1280
                  (void (*)(void))key2any_freectx },                              \
1281
              { OSSL_FUNC_ENCODER_SETTABLE_CTX_PARAMS,                            \
1282
                  (void (*)(void))key2any_settable_ctx_params },                  \
1283
              { OSSL_FUNC_ENCODER_SET_CTX_PARAMS,                                 \
1284
                  (void (*)(void))key2any_set_ctx_params },                       \
1285
              { OSSL_FUNC_ENCODER_DOES_SELECTION,                                 \
1286
                  (void (*)(void))impl##_to_##kind##_##output##_does_selection }, \
1287
              { OSSL_FUNC_ENCODER_IMPORT_OBJECT,                                  \
1288
                  (void (*)(void))impl##_to_##kind##_##output##_import_object },  \
1289
              { OSSL_FUNC_ENCODER_FREE_OBJECT,                                    \
1290
                  (void (*)(void))impl##_to_##kind##_##output##_free_object },    \
1291
              { OSSL_FUNC_ENCODER_ENCODE,                                         \
1292
                  (void (*)(void))impl##_to_##kind##_##output##_encode },         \
1293
              OSSL_DISPATCH_END                                                   \
1294
          }
1295
1296
/*
1297
 * Replacements for i2d_{TYPE}PrivateKey, i2d_{TYPE}PublicKey,
1298
 * i2d_{TYPE}params, as they exist.
1299
 */
1300
1.08k
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, type_specific_keypair, der);
1301
#ifndef OPENSSL_NO_DH
1302
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, type_specific_params, der);
1303
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, type_specific_params, der);
1304
#endif
1305
#ifndef OPENSSL_NO_DSA
1306
3.21k
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, type_specific, der);
1307
#endif
1308
#ifndef OPENSSL_NO_EC
1309
4.96k
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, type_specific_no_pub, der);
1310
#ifndef OPENSSL_NO_SM2
1311
26
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, type_specific_no_pub, der);
1312
#endif
1313
#endif
1314
1315
/*
1316
 * Replacements for PEM_write_bio_{TYPE}PrivateKey,
1317
 * PEM_write_bio_{TYPE}PublicKey, PEM_write_bio_{TYPE}params, as they exist.
1318
 */
1319
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, type_specific_keypair, pem);
1320
#ifndef OPENSSL_NO_DH
1321
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, type_specific_params, pem);
1322
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, type_specific_params, pem);
1323
#endif
1324
#ifndef OPENSSL_NO_DSA
1325
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, type_specific, pem);
1326
#endif
1327
#ifndef OPENSSL_NO_EC
1328
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, type_specific_no_pub, pem);
1329
#ifndef OPENSSL_NO_SM2
1330
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, type_specific_no_pub, pem);
1331
#endif
1332
#endif
1333
1334
/*
1335
 * PKCS#8 and SubjectPublicKeyInfo support.  This may duplicate some of the
1336
 * implementations specified above, but are more specific.
1337
 * The SubjectPublicKeyInfo implementations also replace the
1338
 * PEM_write_bio_{TYPE}_PUBKEY functions.
1339
 * For PEM, these are expected to be used by PEM_write_bio_PrivateKey(),
1340
 * PEM_write_bio_PUBKEY() and PEM_write_bio_Parameters().
1341
 */
1342
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, EncryptedPrivateKeyInfo, der);
1343
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, EncryptedPrivateKeyInfo, pem);
1344
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, PrivateKeyInfo, der);
1345
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, PrivateKeyInfo, pem);
1346
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, SubjectPublicKeyInfo, der);
1347
0
MAKE_ENCODER(rsa, rsa, EVP_PKEY_RSA, SubjectPublicKeyInfo, pem);
1348
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, EncryptedPrivateKeyInfo, der);
1349
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, EncryptedPrivateKeyInfo, pem);
1350
8
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, PrivateKeyInfo, der);
1351
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, PrivateKeyInfo, pem);
1352
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, SubjectPublicKeyInfo, der);
1353
0
MAKE_ENCODER(rsapss, rsa, EVP_PKEY_RSA_PSS, SubjectPublicKeyInfo, pem);
1354
#ifndef OPENSSL_NO_DH
1355
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, EncryptedPrivateKeyInfo, der);
1356
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, EncryptedPrivateKeyInfo, pem);
1357
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, PrivateKeyInfo, der);
1358
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, PrivateKeyInfo, pem);
1359
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, SubjectPublicKeyInfo, der);
1360
0
MAKE_ENCODER(dh, dh, EVP_PKEY_DH, SubjectPublicKeyInfo, pem);
1361
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, EncryptedPrivateKeyInfo, der);
1362
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, EncryptedPrivateKeyInfo, pem);
1363
105
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, PrivateKeyInfo, der);
1364
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, PrivateKeyInfo, pem);
1365
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, SubjectPublicKeyInfo, der);
1366
0
MAKE_ENCODER(dhx, dh, EVP_PKEY_DHX, SubjectPublicKeyInfo, pem);
1367
#endif
1368
#ifndef OPENSSL_NO_DSA
1369
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, EncryptedPrivateKeyInfo, der);
1370
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, EncryptedPrivateKeyInfo, pem);
1371
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, PrivateKeyInfo, der);
1372
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, PrivateKeyInfo, pem);
1373
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, SubjectPublicKeyInfo, der);
1374
0
MAKE_ENCODER(dsa, dsa, EVP_PKEY_DSA, SubjectPublicKeyInfo, pem);
1375
#endif
1376
#ifndef OPENSSL_NO_EC
1377
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, EncryptedPrivateKeyInfo, der);
1378
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, EncryptedPrivateKeyInfo, pem);
1379
1.43k
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, PrivateKeyInfo, der);
1380
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, PrivateKeyInfo, pem);
1381
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, SubjectPublicKeyInfo, der);
1382
0
MAKE_ENCODER(ec, ec, EVP_PKEY_EC, SubjectPublicKeyInfo, pem);
1383
#ifndef OPENSSL_NO_SM2
1384
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, EncryptedPrivateKeyInfo, der);
1385
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, EncryptedPrivateKeyInfo, pem);
1386
8
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, PrivateKeyInfo, der);
1387
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, PrivateKeyInfo, pem);
1388
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, SubjectPublicKeyInfo, der);
1389
0
MAKE_ENCODER(sm2, ec, EVP_PKEY_EC, SubjectPublicKeyInfo, pem);
1390
#endif
1391
#ifndef OPENSSL_NO_ECX
1392
0
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, EncryptedPrivateKeyInfo, der);
1393
0
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, EncryptedPrivateKeyInfo, pem);
1394
7
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, PrivateKeyInfo, der);
1395
0
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, PrivateKeyInfo, pem);
1396
0
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, SubjectPublicKeyInfo, der);
1397
0
MAKE_ENCODER(ed25519, ecx, EVP_PKEY_ED25519, SubjectPublicKeyInfo, pem);
1398
0
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, EncryptedPrivateKeyInfo, der);
1399
0
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, EncryptedPrivateKeyInfo, pem);
1400
4
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, PrivateKeyInfo, der);
1401
0
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, PrivateKeyInfo, pem);
1402
0
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, SubjectPublicKeyInfo, der);
1403
0
MAKE_ENCODER(ed448, ecx, EVP_PKEY_ED448, SubjectPublicKeyInfo, pem);
1404
0
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, EncryptedPrivateKeyInfo, der);
1405
0
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, EncryptedPrivateKeyInfo, pem);
1406
9
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, PrivateKeyInfo, der);
1407
0
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, PrivateKeyInfo, pem);
1408
0
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, SubjectPublicKeyInfo, der);
1409
0
MAKE_ENCODER(x25519, ecx, EVP_PKEY_X25519, SubjectPublicKeyInfo, pem);
1410
0
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, EncryptedPrivateKeyInfo, der);
1411
0
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, EncryptedPrivateKeyInfo, pem);
1412
6
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, PrivateKeyInfo, der);
1413
0
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, PrivateKeyInfo, pem);
1414
0
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, SubjectPublicKeyInfo, der);
1415
0
MAKE_ENCODER(x448, ecx, EVP_PKEY_ED448, SubjectPublicKeyInfo, pem);
1416
#endif
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