Coverage Report

Created: 2023-09-25 06:45

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