Coverage Report

Created: 2025-08-28 07:07

/src/openssl32/providers/implementations/encode_decode/encode_key2text.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 <ctype.h>
16
17
#include <openssl/core.h>
18
#include <openssl/core_dispatch.h>
19
#include <openssl/core_names.h>
20
#include <openssl/bn.h>
21
#include <openssl/err.h>
22
#include <openssl/safestack.h>
23
#include <openssl/proverr.h>
24
#include "internal/ffc.h"
25
#include "crypto/bn.h"           /* bn_get_words() */
26
#include "crypto/dh.h"           /* ossl_dh_get0_params() */
27
#include "crypto/dsa.h"          /* ossl_dsa_get0_params() */
28
#include "crypto/ec.h"           /* ossl_ec_key_get_libctx */
29
#include "crypto/ecx.h"          /* ECX_KEY, etc... */
30
#include "crypto/rsa.h"          /* RSA_PSS_PARAMS_30, etc... */
31
#include "prov/bio.h"
32
#include "prov/implementations.h"
33
#include "endecoder_local.h"
34
35
DEFINE_SPECIAL_STACK_OF_CONST(BIGNUM_const, BIGNUM)
36
37
# ifdef SIXTY_FOUR_BIT_LONG
38
#  define BN_FMTu "%lu"
39
#  define BN_FMTx "%lx"
40
# endif
41
42
# ifdef SIXTY_FOUR_BIT
43
#  define BN_FMTu "%llu"
44
#  define BN_FMTx "%llx"
45
# endif
46
47
# ifdef THIRTY_TWO_BIT
48
#  define BN_FMTu "%u"
49
#  define BN_FMTx "%x"
50
# endif
51
52
static int print_labeled_bignum(BIO *out, const char *label, const BIGNUM *bn)
53
250k
{
54
250k
    int ret = 0, use_sep = 0;
55
250k
    char *hex_str = NULL, *p;
56
250k
    const char spaces[] = "    ";
57
250k
    const char *post_label_spc = " ";
58
59
250k
    const char *neg = "";
60
250k
    int bytes;
61
62
250k
    if (bn == NULL)
63
956
        return 0;
64
249k
    if (label == NULL) {
65
167k
        label = "";
66
167k
        post_label_spc = "";
67
167k
    }
68
69
249k
    if (BN_is_zero(bn))
70
47.2k
        return BIO_printf(out, "%s%s0\n", label, post_label_spc);
71
72
202k
    if (BN_num_bytes(bn) <= BN_BYTES) {
73
161k
        BN_ULONG *words = bn_get_words(bn);
74
75
161k
        if (BN_is_negative(bn))
76
203
            neg = "-";
77
78
161k
        return BIO_printf(out, "%s%s%s" BN_FMTu " (%s0x" BN_FMTx ")\n",
79
161k
                          label, post_label_spc, neg, words[0], neg, words[0]);
80
161k
    }
81
82
41.3k
    hex_str = BN_bn2hex(bn);
83
41.3k
    if (hex_str == NULL)
84
0
        return 0;
85
86
41.3k
    p = hex_str;
87
41.3k
    if (*p == '-') {
88
217
        ++p;
89
217
        neg = " (Negative)";
90
217
    }
91
41.3k
    if (BIO_printf(out, "%s%s\n", label, neg) <= 0)
92
0
        goto err;
93
94
    /* Keep track of how many bytes we have printed out so far */
95
41.3k
    bytes = 0;
96
97
41.3k
    if (BIO_printf(out, "%s", spaces) <= 0)
98
0
        goto err;
99
100
    /* Add a leading 00 if the top bit is set */
101
41.3k
    if (*p >= '8') {
102
18.2k
        if (BIO_printf(out, "%02x", 0) <= 0)
103
0
            goto err;
104
18.2k
        ++bytes;
105
18.2k
        use_sep = 1;
106
18.2k
    }
107
39.9M
    while (*p != '\0') {
108
        /* Do a newline after every 15 hex bytes + add the space indent */
109
39.8M
        if ((bytes % 15) == 0 && bytes > 0) {
110
2.63M
            if (BIO_printf(out, ":\n%s", spaces) <= 0)
111
0
                goto err;
112
2.63M
            use_sep = 0; /* The first byte on the next line doesn't have a : */
113
2.63M
        }
114
39.8M
        if (BIO_printf(out, "%s%c%c", use_sep ? ":" : "",
115
39.8M
                       tolower((unsigned char)p[0]),
116
39.8M
                       tolower((unsigned char)p[1])) <= 0)
117
0
            goto err;
118
39.8M
        ++bytes;
119
39.8M
        p += 2;
120
39.8M
        use_sep = 1;
121
39.8M
    }
122
41.3k
    if (BIO_printf(out, "\n") <= 0)
123
0
        goto err;
124
41.3k
    ret = 1;
125
41.3k
err:
126
41.3k
    OPENSSL_free(hex_str);
127
41.3k
    return ret;
128
41.3k
}
129
130
/* Number of octets per line */
131
500k
#define LABELED_BUF_PRINT_WIDTH    15
132
133
#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_EC)
134
static int print_labeled_buf(BIO *out, const char *label,
135
                             const unsigned char *buf, size_t buflen)
136
12.5k
{
137
12.5k
    size_t i;
138
139
12.5k
    if (BIO_printf(out, "%s\n", label) <= 0)
140
0
        return 0;
141
142
513k
    for (i = 0; i < buflen; i++) {
143
500k
        if ((i % LABELED_BUF_PRINT_WIDTH) == 0) {
144
38.2k
            if (i > 0 && BIO_printf(out, "\n") <= 0)
145
0
                return 0;
146
38.2k
            if (BIO_printf(out, "    ") <= 0)
147
0
                return 0;
148
38.2k
        }
149
150
500k
        if (BIO_printf(out, "%02x%s", buf[i],
151
500k
                                 (i == buflen - 1) ? "" : ":") <= 0)
152
0
            return 0;
153
500k
    }
154
12.5k
    if (BIO_printf(out, "\n") <= 0)
155
0
        return 0;
156
157
12.5k
    return 1;
158
12.5k
}
159
#endif
160
161
#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA)
162
static int ffc_params_to_text(BIO *out, const FFC_PARAMS *ffc)
163
12.2k
{
164
12.2k
    if (ffc->nid != NID_undef) {
165
0
#ifndef OPENSSL_NO_DH
166
0
        const DH_NAMED_GROUP *group = ossl_ffc_uid_to_dh_named_group(ffc->nid);
167
0
        const char *name = ossl_ffc_named_group_get_name(group);
168
169
0
        if (name == NULL)
170
0
            goto err;
171
0
        if (BIO_printf(out, "GROUP: %s\n", name) <= 0)
172
0
            goto err;
173
0
        return 1;
174
#else
175
        /* How could this be? We should not have a nid in a no-dh build. */
176
        goto err;
177
#endif
178
0
    }
179
180
12.2k
    if (!print_labeled_bignum(out, "P:   ", ffc->p))
181
0
        goto err;
182
12.2k
    if (ffc->q != NULL) {
183
10.4k
        if (!print_labeled_bignum(out, "Q:   ", ffc->q))
184
0
            goto err;
185
10.4k
    }
186
12.2k
    if (!print_labeled_bignum(out, "G:   ", ffc->g))
187
0
        goto err;
188
12.2k
    if (ffc->j != NULL) {
189
303
        if (!print_labeled_bignum(out, "J:   ", ffc->j))
190
0
            goto err;
191
303
    }
192
12.2k
    if (ffc->seed != NULL) {
193
112
        if (!print_labeled_buf(out, "SEED:", ffc->seed, ffc->seedlen))
194
0
            goto err;
195
112
    }
196
12.2k
    if (ffc->gindex != -1) {
197
0
        if (BIO_printf(out, "gindex: %d\n", ffc->gindex) <= 0)
198
0
            goto err;
199
0
    }
200
12.2k
    if (ffc->pcounter != -1) {
201
134
        if (BIO_printf(out, "pcounter: %d\n", ffc->pcounter) <= 0)
202
0
            goto err;
203
134
    }
204
12.2k
    if (ffc->h != 0) {
205
0
        if (BIO_printf(out, "h: %d\n", ffc->h) <= 0)
206
0
            goto err;
207
0
    }
208
12.2k
    return 1;
209
0
err:
210
0
    return 0;
211
12.2k
}
212
#endif
213
214
/* ---------------------------------------------------------------------- */
215
216
#ifndef OPENSSL_NO_DH
217
static int dh_to_text(BIO *out, const void *key, int selection)
218
27.8k
{
219
27.8k
    const DH *dh = key;
220
27.8k
    const char *type_label = NULL;
221
27.8k
    const BIGNUM *priv_key = NULL, *pub_key = NULL;
222
27.8k
    const FFC_PARAMS *params = NULL;
223
27.8k
    const BIGNUM *p = NULL;
224
27.8k
    long length;
225
226
27.8k
    if (out == NULL || dh == NULL) {
227
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
228
0
        return 0;
229
0
    }
230
231
27.8k
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
232
9.07k
        type_label = "DH Private-Key";
233
18.7k
    else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
234
9.75k
        type_label = "DH Public-Key";
235
8.98k
    else if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)
236
8.98k
        type_label = "DH Parameters";
237
238
27.8k
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
239
9.07k
        priv_key = DH_get0_priv_key(dh);
240
9.07k
        if (priv_key == NULL) {
241
8.94k
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);
242
8.94k
            return 0;
243
8.94k
        }
244
9.07k
    }
245
18.8k
    if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
246
9.88k
        pub_key = DH_get0_pub_key(dh);
247
9.88k
        if (pub_key == NULL) {
248
8.69k
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);
249
8.69k
            return 0;
250
8.69k
        }
251
9.88k
    }
252
10.1k
    if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) {
253
10.1k
        params = ossl_dh_get0_params((DH *)dh);
254
10.1k
        if (params == NULL) {
255
0
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_PARAMETERS);
256
0
            return 0;
257
0
        }
258
10.1k
    }
259
260
10.1k
    p = DH_get0_p(dh);
261
10.1k
    if (p == NULL) {
262
0
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);
263
0
        return 0;
264
0
    }
265
266
10.1k
    if (BIO_printf(out, "%s: (%d bit)\n", type_label, BN_num_bits(p)) <= 0)
267
0
        return 0;
268
10.1k
    if (priv_key != NULL
269
10.1k
        && !print_labeled_bignum(out, "private-key:", priv_key))
270
0
        return 0;
271
10.1k
    if (pub_key != NULL
272
10.1k
        && !print_labeled_bignum(out, "public-key:", pub_key))
273
0
        return 0;
274
10.1k
    if (params != NULL
275
10.1k
        && !ffc_params_to_text(out, params))
276
0
        return 0;
277
10.1k
    length = DH_get_length(dh);
278
10.1k
    if (length > 0
279
10.1k
        && BIO_printf(out, "recommended-private-length: %ld bits\n",
280
215
                      length) <= 0)
281
0
        return 0;
282
283
10.1k
    return 1;
284
10.1k
}
285
286
# define dh_input_type          "DH"
287
# define dhx_input_type         "DHX"
288
#endif
289
290
/* ---------------------------------------------------------------------- */
291
292
#ifndef OPENSSL_NO_DSA
293
static int dsa_to_text(BIO *out, const void *key, int selection)
294
10.1k
{
295
10.1k
    const DSA *dsa = key;
296
10.1k
    const char *type_label = NULL;
297
10.1k
    const BIGNUM *priv_key = NULL, *pub_key = NULL;
298
10.1k
    const FFC_PARAMS *params = NULL;
299
10.1k
    const BIGNUM *p = NULL;
300
301
10.1k
    if (out == NULL || dsa == NULL) {
302
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
303
0
        return 0;
304
0
    }
305
306
10.1k
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
307
5.24k
        type_label = "Private-Key";
308
4.90k
    else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
309
2.49k
        type_label = "Public-Key";
310
2.40k
    else if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)
311
2.40k
        type_label = "DSA-Parameters";
312
313
10.1k
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
314
5.24k
        priv_key = DSA_get0_priv_key(dsa);
315
5.24k
        if (priv_key == NULL) {
316
276
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);
317
276
            return 0;
318
276
        }
319
5.24k
    }
320
9.87k
    if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
321
7.46k
        pub_key = DSA_get0_pub_key(dsa);
322
7.46k
        if (pub_key == NULL) {
323
0
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);
324
0
            return 0;
325
0
        }
326
7.46k
    }
327
9.87k
    if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) {
328
9.87k
        params = ossl_dsa_get0_params((DSA *)dsa);
329
9.87k
        if (params == NULL) {
330
0
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_PARAMETERS);
331
0
            return 0;
332
0
        }
333
9.87k
    }
334
335
9.87k
    p = DSA_get0_p(dsa);
336
9.87k
    if (p == NULL) {
337
0
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);
338
0
        return 0;
339
0
    }
340
341
9.87k
    if (BIO_printf(out, "%s: (%d bit)\n", type_label, BN_num_bits(p)) <= 0)
342
0
        return 0;
343
9.87k
    if (priv_key != NULL
344
9.87k
        && !print_labeled_bignum(out, "priv:", priv_key))
345
0
        return 0;
346
9.87k
    if (pub_key != NULL
347
9.87k
        && !print_labeled_bignum(out, "pub: ", pub_key))
348
0
        return 0;
349
9.87k
    if (params != NULL
350
9.87k
        && !ffc_params_to_text(out, params))
351
0
        return 0;
352
353
9.87k
    return 1;
354
9.87k
}
355
356
# define dsa_input_type         "DSA"
357
#endif
358
359
/* ---------------------------------------------------------------------- */
360
361
#ifndef OPENSSL_NO_EC
362
static int ec_param_explicit_curve_to_text(BIO *out, const EC_GROUP *group,
363
                                           BN_CTX *ctx)
364
1.84k
{
365
1.84k
    const char *plabel = "Prime:";
366
1.84k
    BIGNUM *p = NULL, *a = NULL, *b = NULL;
367
368
1.84k
    p = BN_CTX_get(ctx);
369
1.84k
    a = BN_CTX_get(ctx);
370
1.84k
    b = BN_CTX_get(ctx);
371
1.84k
    if (b == NULL
372
1.84k
        || !EC_GROUP_get_curve(group, p, a, b, ctx))
373
0
        return 0;
374
375
1.84k
    if (EC_GROUP_get_field_type(group) == NID_X9_62_characteristic_two_field) {
376
0
        int basis_type = EC_GROUP_get_basis_type(group);
377
378
        /* print the 'short name' of the base type OID */
379
0
        if (basis_type == NID_undef
380
0
            || BIO_printf(out, "Basis Type: %s\n", OBJ_nid2sn(basis_type)) <= 0)
381
0
            return 0;
382
0
        plabel = "Polynomial:";
383
0
    }
384
1.84k
    return print_labeled_bignum(out, plabel, p)
385
1.84k
        && print_labeled_bignum(out, "A:   ", a)
386
1.84k
        && print_labeled_bignum(out, "B:   ", b);
387
1.84k
}
388
389
static int ec_param_explicit_gen_to_text(BIO *out, const EC_GROUP *group,
390
                                         BN_CTX *ctx)
391
1.84k
{
392
1.84k
    int ret;
393
1.84k
    size_t buflen;
394
1.84k
    point_conversion_form_t form;
395
1.84k
    const EC_POINT *point = NULL;
396
1.84k
    const char *glabel = NULL;
397
1.84k
    unsigned char *buf = NULL;
398
399
1.84k
    form = EC_GROUP_get_point_conversion_form(group);
400
1.84k
    point = EC_GROUP_get0_generator(group);
401
402
1.84k
    if (point == NULL)
403
0
        return 0;
404
405
1.84k
    switch (form) {
406
1.62k
    case POINT_CONVERSION_COMPRESSED:
407
1.62k
       glabel = "Generator (compressed):";
408
1.62k
       break;
409
144
    case POINT_CONVERSION_UNCOMPRESSED:
410
144
        glabel = "Generator (uncompressed):";
411
144
        break;
412
79
    case POINT_CONVERSION_HYBRID:
413
79
        glabel = "Generator (hybrid):";
414
79
        break;
415
0
    default:
416
0
        return 0;
417
1.84k
    }
418
419
1.84k
    buflen = EC_POINT_point2buf(group, point, form, &buf, ctx);
420
1.84k
    if (buflen == 0)
421
0
        return 0;
422
423
1.84k
    ret = print_labeled_buf(out, glabel, buf, buflen);
424
1.84k
    OPENSSL_clear_free(buf, buflen);
425
1.84k
    return ret;
426
1.84k
}
427
428
/* Print explicit parameters */
429
static int ec_param_explicit_to_text(BIO *out, const EC_GROUP *group,
430
                                     OSSL_LIB_CTX *libctx)
431
1.84k
{
432
1.84k
    int ret = 0, tmp_nid;
433
1.84k
    BN_CTX *ctx = NULL;
434
1.84k
    const BIGNUM *order = NULL, *cofactor = NULL;
435
1.84k
    const unsigned char *seed;
436
1.84k
    size_t seed_len = 0;
437
438
1.84k
    ctx = BN_CTX_new_ex(libctx);
439
1.84k
    if (ctx == NULL)
440
0
        return 0;
441
1.84k
    BN_CTX_start(ctx);
442
443
1.84k
    tmp_nid = EC_GROUP_get_field_type(group);
444
1.84k
    order = EC_GROUP_get0_order(group);
445
1.84k
    if (order == NULL)
446
0
        goto err;
447
448
1.84k
    seed = EC_GROUP_get0_seed(group);
449
1.84k
    if (seed != NULL)
450
1.06k
        seed_len = EC_GROUP_get_seed_len(group);
451
1.84k
    cofactor = EC_GROUP_get0_cofactor(group);
452
453
    /* print the 'short name' of the field type */
454
1.84k
    if (BIO_printf(out, "Field Type: %s\n", OBJ_nid2sn(tmp_nid)) <= 0
455
1.84k
        || !ec_param_explicit_curve_to_text(out, group, ctx)
456
1.84k
        || !ec_param_explicit_gen_to_text(out, group, ctx)
457
1.84k
        || !print_labeled_bignum(out, "Order: ", order)
458
1.84k
        || (cofactor != NULL
459
1.84k
            && !print_labeled_bignum(out, "Cofactor: ", cofactor))
460
1.84k
        || (seed != NULL
461
1.84k
            && !print_labeled_buf(out, "Seed:", seed, seed_len)))
462
0
        goto err;
463
1.84k
    ret = 1;
464
1.84k
err:
465
1.84k
    BN_CTX_end(ctx);
466
1.84k
    BN_CTX_free(ctx);
467
1.84k
    return ret;
468
1.84k
}
469
470
static int ec_param_to_text(BIO *out, const EC_GROUP *group,
471
                            OSSL_LIB_CTX *libctx)
472
14.7k
{
473
14.7k
    if (EC_GROUP_get_asn1_flag(group) & OPENSSL_EC_NAMED_CURVE) {
474
12.9k
        const char *curve_name;
475
12.9k
        int curve_nid = EC_GROUP_get_curve_name(group);
476
477
        /* Explicit parameters */
478
12.9k
        if (curve_nid == NID_undef)
479
0
            return 0;
480
481
12.9k
        if (BIO_printf(out, "%s: %s\n", "ASN1 OID", OBJ_nid2sn(curve_nid)) <= 0)
482
0
            return 0;
483
484
12.9k
        curve_name = EC_curve_nid2nist(curve_nid);
485
12.9k
        return (curve_name == NULL
486
12.9k
                || BIO_printf(out, "%s: %s\n", "NIST CURVE", curve_name) > 0);
487
12.9k
    } else {
488
1.84k
        return ec_param_explicit_to_text(out, group, libctx);
489
1.84k
    }
490
14.7k
}
491
492
static int ec_to_text(BIO *out, const void *key, int selection)
493
18.8k
{
494
18.8k
    const EC_KEY *ec = key;
495
18.8k
    const char *type_label = NULL;
496
18.8k
    unsigned char *priv = NULL, *pub = NULL;
497
18.8k
    size_t priv_len = 0, pub_len = 0;
498
18.8k
    const EC_GROUP *group;
499
18.8k
    int ret = 0;
500
501
18.8k
    if (out == NULL || ec == NULL) {
502
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
503
0
        return 0;
504
0
    }
505
506
18.8k
    if ((group = EC_KEY_get0_group(ec)) == NULL) {
507
0
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);
508
0
        return 0;
509
0
    }
510
511
18.8k
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
512
8.41k
        type_label = "Private-Key";
513
10.4k
    else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
514
6.18k
        type_label = "Public-Key";
515
4.27k
    else if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)
516
4.27k
        if (EC_GROUP_get_curve_name(group) != NID_sm2)
517
4.23k
            type_label = "EC-Parameters";
518
519
18.8k
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
520
8.41k
        const BIGNUM *priv_key = EC_KEY_get0_private_key(ec);
521
522
8.41k
        if (priv_key == NULL) {
523
1.23k
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);
524
1.23k
            goto err;
525
1.23k
        }
526
7.17k
        priv_len = EC_KEY_priv2buf(ec, &priv);
527
7.17k
        if (priv_len == 0)
528
1.82k
            goto err;
529
7.17k
    }
530
15.8k
    if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
531
11.5k
        const EC_POINT *pub_pt = EC_KEY_get0_public_key(ec);
532
533
11.5k
        if (pub_pt == NULL) {
534
620
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);
535
620
            goto err;
536
620
        }
537
538
10.9k
        pub_len = EC_KEY_key2buf(ec, EC_KEY_get_conv_form(ec), &pub, NULL);
539
10.9k
        if (pub_len == 0)
540
416
            goto err;
541
10.9k
    }
542
543
14.7k
    if (type_label != NULL
544
14.7k
        && BIO_printf(out, "%s: (%d bit)\n", type_label,
545
14.7k
                      EC_GROUP_order_bits(group)) <= 0)
546
0
        goto err;
547
14.7k
    if (priv != NULL
548
14.7k
        && !print_labeled_buf(out, "priv:", priv, priv_len))
549
0
        goto err;
550
14.7k
    if (pub != NULL
551
14.7k
        && !print_labeled_buf(out, "pub:", pub, pub_len))
552
0
        goto err;
553
14.7k
    if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)
554
14.7k
        ret = ec_param_to_text(out, group, ossl_ec_key_get_libctx(ec));
555
18.8k
err:
556
18.8k
    OPENSSL_clear_free(priv, priv_len);
557
18.8k
    OPENSSL_free(pub);
558
18.8k
    return ret;
559
14.7k
}
560
561
# define ec_input_type          "EC"
562
563
# ifndef OPENSSL_NO_SM2
564
#  define sm2_input_type        "SM2"
565
# endif
566
#endif
567
568
/* ---------------------------------------------------------------------- */
569
570
#ifndef OPENSSL_NO_ECX
571
static int ecx_to_text(BIO *out, const void *key, int selection)
572
474
{
573
474
    const ECX_KEY *ecx = key;
574
474
    const char *type_label = NULL;
575
576
474
    if (out == NULL || ecx == NULL) {
577
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
578
0
        return 0;
579
0
    }
580
581
474
    switch (ecx->type) {
582
78
    case ECX_KEY_TYPE_X25519:
583
78
        type_label = "X25519";
584
78
        break;
585
113
    case ECX_KEY_TYPE_X448:
586
113
        type_label = "X448";
587
113
        break;
588
72
    case ECX_KEY_TYPE_ED25519:
589
72
        type_label = "ED25519";
590
72
        break;
591
211
    case ECX_KEY_TYPE_ED448:
592
211
        type_label = "ED448";
593
211
        break;
594
474
    }
595
596
474
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
597
103
        if (ecx->privkey == NULL) {
598
18
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);
599
18
            return 0;
600
18
        }
601
602
85
        if (BIO_printf(out, "%s Private-Key:\n", type_label) <= 0)
603
0
            return 0;
604
85
        if (!print_labeled_buf(out, "priv:", ecx->privkey, ecx->keylen))
605
0
            return 0;
606
371
    } else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {
607
        /* ecx->pubkey is an array, not a pointer... */
608
302
        if (!ecx->haspubkey) {
609
0
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);
610
0
            return 0;
611
0
        }
612
613
302
        if (BIO_printf(out, "%s Public-Key:\n", type_label) <= 0)
614
0
            return 0;
615
302
    }
616
617
456
    if (!print_labeled_buf(out, "pub:", ecx->pubkey, ecx->keylen))
618
0
        return 0;
619
620
456
    return 1;
621
456
}
622
623
# define ed25519_input_type     "ED25519"
624
# define ed448_input_type       "ED448"
625
# define x25519_input_type      "X25519"
626
# define x448_input_type        "X448"
627
#endif
628
629
/* ---------------------------------------------------------------------- */
630
631
static int rsa_to_text(BIO *out, const void *key, int selection)
632
17.8k
{
633
17.8k
    const RSA *rsa = key;
634
17.8k
    const char *type_label = "RSA key";
635
17.8k
    const char *modulus_label = NULL;
636
17.8k
    const char *exponent_label = NULL;
637
17.8k
    const BIGNUM *rsa_d = NULL, *rsa_n = NULL, *rsa_e = NULL;
638
17.8k
    STACK_OF(BIGNUM_const) *factors = NULL;
639
17.8k
    STACK_OF(BIGNUM_const) *exps = NULL;
640
17.8k
    STACK_OF(BIGNUM_const) *coeffs = NULL;
641
17.8k
    int primes;
642
17.8k
    const RSA_PSS_PARAMS_30 *pss_params = ossl_rsa_get0_pss_params_30((RSA *)rsa);
643
17.8k
    int ret = 0;
644
645
17.8k
    if (out == NULL || rsa == NULL) {
646
0
        ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);
647
0
        goto err;
648
0
    }
649
650
17.8k
    factors = sk_BIGNUM_const_new_null();
651
17.8k
    exps = sk_BIGNUM_const_new_null();
652
17.8k
    coeffs = sk_BIGNUM_const_new_null();
653
654
17.8k
    if (factors == NULL || exps == NULL || coeffs == NULL) {
655
0
        ERR_raise(ERR_LIB_PROV, ERR_R_CRYPTO_LIB);
656
0
        goto err;
657
0
    }
658
659
17.8k
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
660
4.84k
        type_label = "Private-Key";
661
4.84k
        modulus_label = "modulus:";
662
4.84k
        exponent_label = "publicExponent:";
663
13.0k
    } else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {
664
9.54k
        type_label = "Public-Key";
665
9.54k
        modulus_label = "Modulus:";
666
9.54k
        exponent_label = "Exponent:";
667
9.54k
    }
668
669
17.8k
    RSA_get0_key(rsa, &rsa_n, &rsa_e, &rsa_d);
670
17.8k
    ossl_rsa_get0_all_params((RSA *)rsa, factors, exps, coeffs);
671
17.8k
    primes = sk_BIGNUM_const_num(factors);
672
673
17.8k
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
674
4.84k
        if (BIO_printf(out, "%s: (%d bit, %d primes)\n",
675
4.84k
                       type_label, BN_num_bits(rsa_n), primes) <= 0)
676
0
            goto err;
677
13.0k
    } else {
678
13.0k
        if (BIO_printf(out, "%s: (%d bit)\n",
679
13.0k
                       type_label, BN_num_bits(rsa_n)) <= 0)
680
0
            goto err;
681
13.0k
    }
682
683
17.8k
    if (!print_labeled_bignum(out, modulus_label, rsa_n))
684
0
        goto err;
685
17.8k
    if (!print_labeled_bignum(out, exponent_label, rsa_e))
686
0
        goto err;
687
17.8k
    if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
688
4.84k
        int i;
689
690
4.84k
        if (!print_labeled_bignum(out, "privateExponent:", rsa_d))
691
1.52k
            goto err;
692
3.32k
        if (!print_labeled_bignum(out, "prime1:",
693
3.32k
                                  sk_BIGNUM_const_value(factors, 0)))
694
0
            goto err;
695
3.32k
        if (!print_labeled_bignum(out, "prime2:",
696
3.32k
                                  sk_BIGNUM_const_value(factors, 1)))
697
0
            goto err;
698
3.32k
        if (!print_labeled_bignum(out, "exponent1:",
699
3.32k
                                  sk_BIGNUM_const_value(exps, 0)))
700
0
            goto err;
701
3.32k
        if (!print_labeled_bignum(out, "exponent2:",
702
3.32k
                                  sk_BIGNUM_const_value(exps, 1)))
703
0
            goto err;
704
3.32k
        if (!print_labeled_bignum(out, "coefficient:",
705
3.32k
                                  sk_BIGNUM_const_value(coeffs, 0)))
706
0
            goto err;
707
62.3k
        for (i = 2; i < sk_BIGNUM_const_num(factors); i++) {
708
59.0k
            if (BIO_printf(out, "prime%d:", i + 1) <= 0)
709
0
                goto err;
710
59.0k
            if (!print_labeled_bignum(out, NULL,
711
59.0k
                                      sk_BIGNUM_const_value(factors, i)))
712
0
                goto err;
713
59.0k
            if (BIO_printf(out, "exponent%d:", i + 1) <= 0)
714
0
                goto err;
715
59.0k
            if (!print_labeled_bignum(out, NULL,
716
59.0k
                                      sk_BIGNUM_const_value(exps, i)))
717
0
                goto err;
718
59.0k
            if (BIO_printf(out, "coefficient%d:", i + 1) <= 0)
719
0
                goto err;
720
59.0k
            if (!print_labeled_bignum(out, NULL,
721
59.0k
                                      sk_BIGNUM_const_value(coeffs, i - 1)))
722
0
                goto err;
723
59.0k
        }
724
3.32k
    }
725
726
16.3k
    if ((selection & OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) != 0) {
727
16.3k
        switch (RSA_test_flags(rsa, RSA_FLAG_TYPE_MASK)) {
728
16.1k
        case RSA_FLAG_TYPE_RSA:
729
16.1k
            if (!ossl_rsa_pss_params_30_is_unrestricted(pss_params)) {
730
0
                if (BIO_printf(out, "(INVALID PSS PARAMETERS)\n") <= 0)
731
0
                    goto err;
732
0
            }
733
16.1k
            break;
734
16.1k
        case RSA_FLAG_TYPE_RSASSAPSS:
735
182
            if (ossl_rsa_pss_params_30_is_unrestricted(pss_params)) {
736
41
                if (BIO_printf(out, "No PSS parameter restrictions\n") <= 0)
737
0
                    goto err;
738
141
            } else {
739
141
                int hashalg_nid = ossl_rsa_pss_params_30_hashalg(pss_params);
740
141
                int maskgenalg_nid =
741
141
                    ossl_rsa_pss_params_30_maskgenalg(pss_params);
742
141
                int maskgenhashalg_nid =
743
141
                    ossl_rsa_pss_params_30_maskgenhashalg(pss_params);
744
141
                int saltlen = ossl_rsa_pss_params_30_saltlen(pss_params);
745
141
                int trailerfield =
746
141
                    ossl_rsa_pss_params_30_trailerfield(pss_params);
747
748
141
                if (BIO_printf(out, "PSS parameter restrictions:\n") <= 0)
749
0
                    goto err;
750
141
                if (BIO_printf(out, "  Hash Algorithm: %s%s\n",
751
141
                               ossl_rsa_oaeppss_nid2name(hashalg_nid),
752
141
                               (hashalg_nid == NID_sha1
753
141
                                ? " (default)" : "")) <= 0)
754
0
                    goto err;
755
141
                if (BIO_printf(out, "  Mask Algorithm: %s with %s%s\n",
756
141
                               ossl_rsa_mgf_nid2name(maskgenalg_nid),
757
141
                               ossl_rsa_oaeppss_nid2name(maskgenhashalg_nid),
758
141
                               (maskgenalg_nid == NID_mgf1
759
141
                                && maskgenhashalg_nid == NID_sha1
760
141
                                ? " (default)" : "")) <= 0)
761
0
                    goto err;
762
141
                if (BIO_printf(out, "  Minimum Salt Length: %d%s\n",
763
141
                               saltlen,
764
141
                               (saltlen == 20 ? " (default)" : "")) <= 0)
765
0
                    goto err;
766
141
                if (BIO_printf(out, "  Trailer Field: 0x%x%s\n",
767
141
                               trailerfield,
768
141
                               (trailerfield == 1 ? " (default)" : "")) <= 0)
769
0
                    goto err;
770
141
            }
771
182
            break;
772
16.3k
        }
773
16.3k
    }
774
775
16.3k
    ret = 1;
776
17.8k
 err:
777
17.8k
    sk_BIGNUM_const_free(factors);
778
17.8k
    sk_BIGNUM_const_free(exps);
779
17.8k
    sk_BIGNUM_const_free(coeffs);
780
17.8k
    return ret;
781
16.3k
}
782
783
#define rsa_input_type          "RSA"
784
#define rsapss_input_type       "RSA-PSS"
785
786
/* ---------------------------------------------------------------------- */
787
788
static void *key2text_newctx(void *provctx)
789
85.1k
{
790
85.1k
    return provctx;
791
85.1k
}
792
793
static void key2text_freectx(ossl_unused void *vctx)
794
85.1k
{
795
85.1k
}
796
797
static int key2text_encode(void *vctx, const void *key, int selection,
798
                           OSSL_CORE_BIO *cout,
799
                           int (*key2text)(BIO *out, const void *key,
800
                                           int selection),
801
                           OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)
802
75.3k
{
803
75.3k
    BIO *out = ossl_bio_new_from_core_bio(vctx, cout);
804
75.3k
    int ret;
805
806
75.3k
    if (out == NULL)
807
0
        return 0;
808
809
75.3k
    ret = key2text(out, key, selection);
810
75.3k
    BIO_free(out);
811
812
75.3k
    return ret;
813
75.3k
}
814
815
#define MAKE_TEXT_ENCODER(impl, type)                                   \
816
    static OSSL_FUNC_encoder_import_object_fn                           \
817
    impl##2text_import_object;                                          \
818
    static OSSL_FUNC_encoder_free_object_fn                             \
819
    impl##2text_free_object;                                            \
820
    static OSSL_FUNC_encoder_encode_fn impl##2text_encode;              \
821
                                                                        \
822
    static void *impl##2text_import_object(void *ctx, int selection,    \
823
                                           const OSSL_PARAM params[])   \
824
0
    {                                                                   \
825
0
        return ossl_prov_import_key(ossl_##impl##_keymgmt_functions,    \
826
0
                                    ctx, selection, params);            \
827
0
    }                                                                   \
Unexecuted instantiation: encode_key2text.c:dh2text_import_object
Unexecuted instantiation: encode_key2text.c:dhx2text_import_object
Unexecuted instantiation: encode_key2text.c:dsa2text_import_object
Unexecuted instantiation: encode_key2text.c:ec2text_import_object
Unexecuted instantiation: encode_key2text.c:sm22text_import_object
Unexecuted instantiation: encode_key2text.c:ed255192text_import_object
Unexecuted instantiation: encode_key2text.c:ed4482text_import_object
Unexecuted instantiation: encode_key2text.c:x255192text_import_object
Unexecuted instantiation: encode_key2text.c:x4482text_import_object
Unexecuted instantiation: encode_key2text.c:rsa2text_import_object
Unexecuted instantiation: encode_key2text.c:rsapss2text_import_object
828
    static void impl##2text_free_object(void *key)                      \
829
0
    {                                                                   \
830
0
        ossl_prov_free_key(ossl_##impl##_keymgmt_functions, key);       \
831
0
    }                                                                   \
Unexecuted instantiation: encode_key2text.c:dh2text_free_object
Unexecuted instantiation: encode_key2text.c:dhx2text_free_object
Unexecuted instantiation: encode_key2text.c:dsa2text_free_object
Unexecuted instantiation: encode_key2text.c:ec2text_free_object
Unexecuted instantiation: encode_key2text.c:sm22text_free_object
Unexecuted instantiation: encode_key2text.c:ed255192text_free_object
Unexecuted instantiation: encode_key2text.c:ed4482text_free_object
Unexecuted instantiation: encode_key2text.c:x255192text_free_object
Unexecuted instantiation: encode_key2text.c:x4482text_free_object
Unexecuted instantiation: encode_key2text.c:rsa2text_free_object
Unexecuted instantiation: encode_key2text.c:rsapss2text_free_object
832
    static int impl##2text_encode(void *vctx, OSSL_CORE_BIO *cout,      \
833
                                  const void *key,                      \
834
                                  const OSSL_PARAM key_abstract[],      \
835
                                  int selection,                        \
836
                                  OSSL_PASSPHRASE_CALLBACK *cb,         \
837
                                  void *cbarg)                          \
838
75.1k
    {                                                                   \
839
75.1k
        /* We don't deal with abstract objects */                       \
840
75.1k
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
75.1k
        return key2text_encode(vctx, key, selection, cout,              \
845
75.1k
                               type##_to_text, cb, cbarg);              \
846
75.1k
    }                                                                   \
encode_key2text.c:dh2text_encode
Line
Count
Source
838
7.37k
    {                                                                   \
839
7.37k
        /* We don't deal with abstract objects */                       \
840
7.37k
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
7.37k
        return key2text_encode(vctx, key, selection, cout,              \
845
7.37k
                               type##_to_text, cb, cbarg);              \
846
7.37k
    }                                                                   \
encode_key2text.c:dhx2text_encode
Line
Count
Source
838
20.4k
    {                                                                   \
839
20.4k
        /* We don't deal with abstract objects */                       \
840
20.4k
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
20.4k
        return key2text_encode(vctx, key, selection, cout,              \
845
20.4k
                               type##_to_text, cb, cbarg);              \
846
20.4k
    }                                                                   \
encode_key2text.c:dsa2text_encode
Line
Count
Source
838
10.1k
    {                                                                   \
839
10.1k
        /* We don't deal with abstract objects */                       \
840
10.1k
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
10.1k
        return key2text_encode(vctx, key, selection, cout,              \
845
10.1k
                               type##_to_text, cb, cbarg);              \
846
10.1k
    }                                                                   \
encode_key2text.c:ec2text_encode
Line
Count
Source
838
18.6k
    {                                                                   \
839
18.6k
        /* We don't deal with abstract objects */                       \
840
18.6k
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
18.6k
        return key2text_encode(vctx, key, selection, cout,              \
845
18.6k
                               type##_to_text, cb, cbarg);              \
846
18.6k
    }                                                                   \
encode_key2text.c:sm22text_encode
Line
Count
Source
838
187
    {                                                                   \
839
187
        /* We don't deal with abstract objects */                       \
840
187
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
187
        return key2text_encode(vctx, key, selection, cout,              \
845
187
                               type##_to_text, cb, cbarg);              \
846
187
    }                                                                   \
encode_key2text.c:ed255192text_encode
Line
Count
Source
838
72
    {                                                                   \
839
72
        /* We don't deal with abstract objects */                       \
840
72
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
72
        return key2text_encode(vctx, key, selection, cout,              \
845
72
                               type##_to_text, cb, cbarg);              \
846
72
    }                                                                   \
encode_key2text.c:ed4482text_encode
Line
Count
Source
838
211
    {                                                                   \
839
211
        /* We don't deal with abstract objects */                       \
840
211
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
211
        return key2text_encode(vctx, key, selection, cout,              \
845
211
                               type##_to_text, cb, cbarg);              \
846
211
    }                                                                   \
encode_key2text.c:x255192text_encode
Line
Count
Source
838
78
    {                                                                   \
839
78
        /* We don't deal with abstract objects */                       \
840
78
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
78
        return key2text_encode(vctx, key, selection, cout,              \
845
78
                               type##_to_text, cb, cbarg);              \
846
78
    }                                                                   \
encode_key2text.c:x4482text_encode
Line
Count
Source
838
113
    {                                                                   \
839
113
        /* We don't deal with abstract objects */                       \
840
113
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
113
        return key2text_encode(vctx, key, selection, cout,              \
845
113
                               type##_to_text, cb, cbarg);              \
846
113
    }                                                                   \
encode_key2text.c:rsa2text_encode
Line
Count
Source
838
17.6k
    {                                                                   \
839
17.6k
        /* We don't deal with abstract objects */                       \
840
17.6k
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
17.6k
        return key2text_encode(vctx, key, selection, cout,              \
845
17.6k
                               type##_to_text, cb, cbarg);              \
846
17.6k
    }                                                                   \
encode_key2text.c:rsapss2text_encode
Line
Count
Source
838
194
    {                                                                   \
839
194
        /* We don't deal with abstract objects */                       \
840
194
        if (key_abstract != NULL) {                                     \
841
0
            ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);     \
842
0
            return 0;                                                   \
843
0
        }                                                               \
844
194
        return key2text_encode(vctx, key, selection, cout,              \
845
194
                               type##_to_text, cb, cbarg);              \
846
194
    }                                                                   \
847
    const OSSL_DISPATCH ossl_##impl##_to_text_encoder_functions[] = {   \
848
        { OSSL_FUNC_ENCODER_NEWCTX,                                     \
849
          (void (*)(void))key2text_newctx },                            \
850
        { OSSL_FUNC_ENCODER_FREECTX,                                    \
851
          (void (*)(void))key2text_freectx },                           \
852
        { OSSL_FUNC_ENCODER_IMPORT_OBJECT,                              \
853
          (void (*)(void))impl##2text_import_object },                  \
854
        { OSSL_FUNC_ENCODER_FREE_OBJECT,                                \
855
          (void (*)(void))impl##2text_free_object },                    \
856
        { OSSL_FUNC_ENCODER_ENCODE,                                     \
857
          (void (*)(void))impl##2text_encode },                         \
858
        OSSL_DISPATCH_END                                               \
859
    }
860
861
#ifndef OPENSSL_NO_DH
862
MAKE_TEXT_ENCODER(dh, dh);
863
MAKE_TEXT_ENCODER(dhx, dh);
864
#endif
865
#ifndef OPENSSL_NO_DSA
866
MAKE_TEXT_ENCODER(dsa, dsa);
867
#endif
868
#ifndef OPENSSL_NO_EC
869
MAKE_TEXT_ENCODER(ec, ec);
870
# ifndef OPENSSL_NO_SM2
871
MAKE_TEXT_ENCODER(sm2, ec);
872
# endif
873
# ifndef OPENSSL_NO_ECX
874
MAKE_TEXT_ENCODER(ed25519, ecx);
875
MAKE_TEXT_ENCODER(ed448, ecx);
876
MAKE_TEXT_ENCODER(x25519, ecx);
877
MAKE_TEXT_ENCODER(x448, ecx);
878
# endif
879
#endif
880
MAKE_TEXT_ENCODER(rsa, rsa);
881
MAKE_TEXT_ENCODER(rsapss, rsa);