Coverage Report

Created: 2023-09-25 06:45

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