Path: blob/main/crypto/openssl/providers/implementations/encode_decode/encode_key2text.c
48383 views
/*1* Copyright 2020-2025 The OpenSSL Project Authors. All Rights Reserved.2*3* Licensed under the Apache License 2.0 (the "License"). You may not use4* this file except in compliance with the License. You can obtain a copy5* in the file LICENSE in the source distribution or at6* https://www.openssl.org/source/license.html7*/89/*10* Low level APIs are deprecated for public use, but still ok for internal use.11*/12#include "internal/deprecated.h"1314#include <openssl/core.h>15#include <openssl/core_dispatch.h>16#include <openssl/core_names.h>17#include <openssl/bn.h>18#include <openssl/err.h>19#include <openssl/safestack.h>20#include <openssl/proverr.h>21#include "crypto/dh.h" /* ossl_dh_get0_params() */22#include "crypto/dsa.h" /* ossl_dsa_get0_params() */23#include "crypto/ec.h" /* ossl_ec_key_get_libctx */24#include "crypto/ecx.h" /* ECX_KEY, etc... */25#include "crypto/ml_kem.h" /* ML_KEM_KEY, etc... */26#include "crypto/rsa.h" /* RSA_PSS_PARAMS_30, etc... */27#include "crypto/ml_dsa.h"28#include "crypto/slh_dsa.h"29#include "prov/bio.h"30#include "prov/implementations.h"31#include "internal/encoder.h"32#include "endecoder_local.h"33#include "ml_dsa_codecs.h"34#include "ml_kem_codecs.h"3536DEFINE_SPECIAL_STACK_OF_CONST(BIGNUM_const, BIGNUM)3738/* ---------------------------------------------------------------------- */3940#ifndef OPENSSL_NO_DH41static int dh_to_text(BIO *out, const void *key, int selection)42{43const DH *dh = key;44const char *type_label = NULL;45const BIGNUM *priv_key = NULL, *pub_key = NULL;46const FFC_PARAMS *params = NULL;47const BIGNUM *p = NULL;48long length;4950if (out == NULL || dh == NULL) {51ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);52return 0;53}5455if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)56type_label = "DH Private-Key";57else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)58type_label = "DH Public-Key";59else if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)60type_label = "DH Parameters";6162if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {63priv_key = DH_get0_priv_key(dh);64if (priv_key == NULL) {65ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);66return 0;67}68}69if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {70pub_key = DH_get0_pub_key(dh);71if (pub_key == NULL) {72ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);73return 0;74}75}76if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) {77params = ossl_dh_get0_params((DH *)dh);78if (params == NULL) {79ERR_raise(ERR_LIB_PROV, PROV_R_NOT_PARAMETERS);80return 0;81}82}8384p = DH_get0_p(dh);85if (p == NULL) {86ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);87return 0;88}8990if (BIO_printf(out, "%s: (%d bit)\n", type_label, BN_num_bits(p)) <= 0)91return 0;92if (priv_key != NULL93&& !ossl_bio_print_labeled_bignum(out, "private-key:", priv_key))94return 0;95if (pub_key != NULL96&& !ossl_bio_print_labeled_bignum(out, "public-key:", pub_key))97return 0;98if (params != NULL99&& !ossl_bio_print_ffc_params(out, params))100return 0;101length = DH_get_length(dh);102if (length > 0103&& BIO_printf(out, "recommended-private-length: %ld bits\n",104length) <= 0)105return 0;106107return 1;108}109#endif110111/* ---------------------------------------------------------------------- */112113#ifndef OPENSSL_NO_DSA114static int dsa_to_text(BIO *out, const void *key, int selection)115{116const DSA *dsa = key;117const char *type_label = NULL;118const BIGNUM *priv_key = NULL, *pub_key = NULL;119const FFC_PARAMS *params = NULL;120const BIGNUM *p = NULL;121122if (out == NULL || dsa == NULL) {123ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);124return 0;125}126127if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)128type_label = "Private-Key";129else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)130type_label = "Public-Key";131else if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)132type_label = "DSA-Parameters";133134if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {135priv_key = DSA_get0_priv_key(dsa);136if (priv_key == NULL) {137ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);138return 0;139}140}141if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {142pub_key = DSA_get0_pub_key(dsa);143if (pub_key == NULL) {144ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);145return 0;146}147}148if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) {149params = ossl_dsa_get0_params((DSA *)dsa);150if (params == NULL) {151ERR_raise(ERR_LIB_PROV, PROV_R_NOT_PARAMETERS);152return 0;153}154}155156p = DSA_get0_p(dsa);157if (p == NULL) {158ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);159return 0;160}161162if (BIO_printf(out, "%s: (%d bit)\n", type_label, BN_num_bits(p)) <= 0)163return 0;164if (priv_key != NULL165&& !ossl_bio_print_labeled_bignum(out, "priv:", priv_key))166return 0;167if (pub_key != NULL168&& !ossl_bio_print_labeled_bignum(out, "pub: ", pub_key))169return 0;170if (params != NULL171&& !ossl_bio_print_ffc_params(out, params))172return 0;173174return 1;175}176#endif177178/* ---------------------------------------------------------------------- */179180#ifndef OPENSSL_NO_EC181static int ec_param_explicit_curve_to_text(BIO *out, const EC_GROUP *group,182BN_CTX *ctx)183{184const char *plabel = "Prime:";185BIGNUM *p = NULL, *a = NULL, *b = NULL;186187p = BN_CTX_get(ctx);188a = BN_CTX_get(ctx);189b = BN_CTX_get(ctx);190if (b == NULL191|| !EC_GROUP_get_curve(group, p, a, b, ctx))192return 0;193194if (EC_GROUP_get_field_type(group) == NID_X9_62_characteristic_two_field) {195int basis_type = EC_GROUP_get_basis_type(group);196197/* print the 'short name' of the base type OID */198if (basis_type == NID_undef199|| BIO_printf(out, "Basis Type: %s\n", OBJ_nid2sn(basis_type)) <= 0)200return 0;201plabel = "Polynomial:";202}203return ossl_bio_print_labeled_bignum(out, plabel, p)204&& ossl_bio_print_labeled_bignum(out, "A: ", a)205&& ossl_bio_print_labeled_bignum(out, "B: ", b);206}207208static int ec_param_explicit_gen_to_text(BIO *out, const EC_GROUP *group,209BN_CTX *ctx)210{211int ret;212size_t buflen;213point_conversion_form_t form;214const EC_POINT *point = NULL;215const char *glabel = NULL;216unsigned char *buf = NULL;217218form = EC_GROUP_get_point_conversion_form(group);219point = EC_GROUP_get0_generator(group);220221if (point == NULL)222return 0;223224switch (form) {225case POINT_CONVERSION_COMPRESSED:226glabel = "Generator (compressed):";227break;228case POINT_CONVERSION_UNCOMPRESSED:229glabel = "Generator (uncompressed):";230break;231case POINT_CONVERSION_HYBRID:232glabel = "Generator (hybrid):";233break;234default:235return 0;236}237238buflen = EC_POINT_point2buf(group, point, form, &buf, ctx);239if (buflen == 0)240return 0;241242ret = ossl_bio_print_labeled_buf(out, glabel, buf, buflen);243OPENSSL_clear_free(buf, buflen);244return ret;245}246247/* Print explicit parameters */248static int ec_param_explicit_to_text(BIO *out, const EC_GROUP *group,249OSSL_LIB_CTX *libctx)250{251int ret = 0, tmp_nid;252BN_CTX *ctx = NULL;253const BIGNUM *order = NULL, *cofactor = NULL;254const unsigned char *seed;255size_t seed_len = 0;256257ctx = BN_CTX_new_ex(libctx);258if (ctx == NULL)259return 0;260BN_CTX_start(ctx);261262tmp_nid = EC_GROUP_get_field_type(group);263order = EC_GROUP_get0_order(group);264if (order == NULL)265goto err;266267seed = EC_GROUP_get0_seed(group);268if (seed != NULL)269seed_len = EC_GROUP_get_seed_len(group);270cofactor = EC_GROUP_get0_cofactor(group);271272/* print the 'short name' of the field type */273if (BIO_printf(out, "Field Type: %s\n", OBJ_nid2sn(tmp_nid)) <= 0274|| !ec_param_explicit_curve_to_text(out, group, ctx)275|| !ec_param_explicit_gen_to_text(out, group, ctx)276|| !ossl_bio_print_labeled_bignum(out, "Order: ", order)277|| (cofactor != NULL278&& !ossl_bio_print_labeled_bignum(out, "Cofactor: ", cofactor))279|| (seed != NULL280&& !ossl_bio_print_labeled_buf(out, "Seed:", seed, seed_len)))281goto err;282ret = 1;283err:284BN_CTX_end(ctx);285BN_CTX_free(ctx);286return ret;287}288289static int ec_param_to_text(BIO *out, const EC_GROUP *group,290OSSL_LIB_CTX *libctx)291{292if (EC_GROUP_get_asn1_flag(group) & OPENSSL_EC_NAMED_CURVE) {293const char *curve_name;294int curve_nid = EC_GROUP_get_curve_name(group);295296/* Explicit parameters */297if (curve_nid == NID_undef)298return 0;299300if (BIO_printf(out, "%s: %s\n", "ASN1 OID", OBJ_nid2sn(curve_nid)) <= 0)301return 0;302303curve_name = EC_curve_nid2nist(curve_nid);304return (curve_name == NULL305|| BIO_printf(out, "%s: %s\n", "NIST CURVE", curve_name) > 0);306} else {307return ec_param_explicit_to_text(out, group, libctx);308}309}310311static int ec_to_text(BIO *out, const void *key, int selection)312{313const EC_KEY *ec = key;314const char *type_label = NULL;315unsigned char *priv = NULL, *pub = NULL;316size_t priv_len = 0, pub_len = 0;317const EC_GROUP *group;318int ret = 0;319320if (out == NULL || ec == NULL) {321ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);322return 0;323}324325if ((group = EC_KEY_get0_group(ec)) == NULL) {326ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);327return 0;328}329330if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)331type_label = "Private-Key";332else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)333type_label = "Public-Key";334else if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)335if (EC_GROUP_get_curve_name(group) != NID_sm2)336type_label = "EC-Parameters";337338if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {339const BIGNUM *priv_key = EC_KEY_get0_private_key(ec);340341if (priv_key == NULL) {342ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);343goto err;344}345priv_len = EC_KEY_priv2buf(ec, &priv);346if (priv_len == 0)347goto err;348}349if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {350const EC_POINT *pub_pt = EC_KEY_get0_public_key(ec);351352if (pub_pt == NULL) {353ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);354goto err;355}356357pub_len = EC_KEY_key2buf(ec, EC_KEY_get_conv_form(ec), &pub, NULL);358if (pub_len == 0)359goto err;360}361362if (type_label != NULL363&& BIO_printf(out, "%s: (%d bit)\n", type_label,364EC_GROUP_order_bits(group)) <= 0)365goto err;366if (priv != NULL367&& !ossl_bio_print_labeled_buf(out, "priv:", priv, priv_len))368goto err;369if (pub != NULL370&& !ossl_bio_print_labeled_buf(out, "pub:", pub, pub_len))371goto err;372if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)373ret = ec_param_to_text(out, group, ossl_ec_key_get_libctx(ec));374err:375OPENSSL_clear_free(priv, priv_len);376OPENSSL_free(pub);377return ret;378}379#endif380381/* ---------------------------------------------------------------------- */382383#ifndef OPENSSL_NO_ECX384static int ecx_to_text(BIO *out, const void *key, int selection)385{386const ECX_KEY *ecx = key;387const char *type_label = NULL;388389if (out == NULL || ecx == NULL) {390ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);391return 0;392}393394switch (ecx->type) {395case ECX_KEY_TYPE_X25519:396type_label = "X25519";397break;398case ECX_KEY_TYPE_X448:399type_label = "X448";400break;401case ECX_KEY_TYPE_ED25519:402type_label = "ED25519";403break;404case ECX_KEY_TYPE_ED448:405type_label = "ED448";406break;407}408409if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {410if (ecx->privkey == NULL) {411ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);412return 0;413}414415if (BIO_printf(out, "%s Private-Key:\n", type_label) <= 0)416return 0;417if (!ossl_bio_print_labeled_buf(out, "priv:", ecx->privkey, ecx->keylen))418return 0;419} else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {420/* ecx->pubkey is an array, not a pointer... */421if (!ecx->haspubkey) {422ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);423return 0;424}425426if (BIO_printf(out, "%s Public-Key:\n", type_label) <= 0)427return 0;428}429430if (!ossl_bio_print_labeled_buf(out, "pub:", ecx->pubkey, ecx->keylen))431return 0;432433return 1;434}435#endif436437/* ---------------------------------------------------------------------- */438439#ifndef OPENSSL_NO_ML_KEM440static int ml_kem_to_text(BIO *out, const void *vkey, int selection)441{442return ossl_ml_kem_key_to_text(out, (ML_KEM_KEY *)vkey, selection);443}444#endif445446/* ---------------------------------------------------------------------- */447448#ifndef OPENSSL_NO_SLH_DSA449static int slh_dsa_to_text(BIO *out, const void *key, int selection)450{451return ossl_slh_dsa_key_to_text(out, (SLH_DSA_KEY *)key, selection);452}453#endif /* OPENSSL_NO_SLH_DSA */454455static int rsa_to_text(BIO *out, const void *key, int selection)456{457const RSA *rsa = key;458const char *type_label = "RSA key";459const char *modulus_label = NULL;460const char *exponent_label = NULL;461const BIGNUM *rsa_d = NULL, *rsa_n = NULL, *rsa_e = NULL;462STACK_OF(BIGNUM_const) *factors = NULL;463STACK_OF(BIGNUM_const) *exps = NULL;464STACK_OF(BIGNUM_const) *coeffs = NULL;465int primes;466const RSA_PSS_PARAMS_30 *pss_params = ossl_rsa_get0_pss_params_30((RSA *)rsa);467int ret = 0;468469if (out == NULL || rsa == NULL) {470ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);471goto err;472}473474factors = sk_BIGNUM_const_new_null();475exps = sk_BIGNUM_const_new_null();476coeffs = sk_BIGNUM_const_new_null();477478if (factors == NULL || exps == NULL || coeffs == NULL) {479ERR_raise(ERR_LIB_PROV, ERR_R_CRYPTO_LIB);480goto err;481}482483if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {484type_label = "Private-Key";485modulus_label = "modulus:";486exponent_label = "publicExponent:";487} else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {488type_label = "Public-Key";489modulus_label = "Modulus:";490exponent_label = "Exponent:";491}492493RSA_get0_key(rsa, &rsa_n, &rsa_e, &rsa_d);494ossl_rsa_get0_all_params((RSA *)rsa, factors, exps, coeffs);495primes = sk_BIGNUM_const_num(factors);496497if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {498if (BIO_printf(out, "%s: (%d bit, %d primes)\n",499type_label, BN_num_bits(rsa_n), primes) <= 0)500goto err;501} else {502if (BIO_printf(out, "%s: (%d bit)\n",503type_label, BN_num_bits(rsa_n)) <= 0)504goto err;505}506507if (!ossl_bio_print_labeled_bignum(out, modulus_label, rsa_n))508goto err;509if (!ossl_bio_print_labeled_bignum(out, exponent_label, rsa_e))510goto err;511if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {512int i;513514if (!ossl_bio_print_labeled_bignum(out, "privateExponent:", rsa_d))515goto err;516if (!ossl_bio_print_labeled_bignum(out, "prime1:",517sk_BIGNUM_const_value(factors, 0)))518goto err;519if (!ossl_bio_print_labeled_bignum(out, "prime2:",520sk_BIGNUM_const_value(factors, 1)))521goto err;522if (!ossl_bio_print_labeled_bignum(out, "exponent1:",523sk_BIGNUM_const_value(exps, 0)))524goto err;525if (!ossl_bio_print_labeled_bignum(out, "exponent2:",526sk_BIGNUM_const_value(exps, 1)))527goto err;528if (!ossl_bio_print_labeled_bignum(out, "coefficient:",529sk_BIGNUM_const_value(coeffs, 0)))530goto err;531for (i = 2; i < sk_BIGNUM_const_num(factors); i++) {532if (BIO_printf(out, "prime%d:", i + 1) <= 0)533goto err;534if (!ossl_bio_print_labeled_bignum(out, NULL,535sk_BIGNUM_const_value(factors, i)))536goto err;537if (BIO_printf(out, "exponent%d:", i + 1) <= 0)538goto err;539if (!ossl_bio_print_labeled_bignum(out, NULL,540sk_BIGNUM_const_value(exps, i)))541goto err;542if (BIO_printf(out, "coefficient%d:", i + 1) <= 0)543goto err;544if (!ossl_bio_print_labeled_bignum(out, NULL,545sk_BIGNUM_const_value(coeffs, i - 1)))546goto err;547}548}549550if ((selection & OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) != 0) {551switch (RSA_test_flags(rsa, RSA_FLAG_TYPE_MASK)) {552case RSA_FLAG_TYPE_RSA:553if (!ossl_rsa_pss_params_30_is_unrestricted(pss_params)) {554if (BIO_printf(out, "(INVALID PSS PARAMETERS)\n") <= 0)555goto err;556}557break;558case RSA_FLAG_TYPE_RSASSAPSS:559if (ossl_rsa_pss_params_30_is_unrestricted(pss_params)) {560if (BIO_printf(out, "No PSS parameter restrictions\n") <= 0)561goto err;562} else {563int hashalg_nid = ossl_rsa_pss_params_30_hashalg(pss_params);564int maskgenalg_nid =565ossl_rsa_pss_params_30_maskgenalg(pss_params);566int maskgenhashalg_nid =567ossl_rsa_pss_params_30_maskgenhashalg(pss_params);568int saltlen = ossl_rsa_pss_params_30_saltlen(pss_params);569int trailerfield =570ossl_rsa_pss_params_30_trailerfield(pss_params);571572if (BIO_printf(out, "PSS parameter restrictions:\n") <= 0)573goto err;574if (BIO_printf(out, " Hash Algorithm: %s%s\n",575ossl_rsa_oaeppss_nid2name(hashalg_nid),576(hashalg_nid == NID_sha1577? " (default)" : "")) <= 0)578goto err;579if (BIO_printf(out, " Mask Algorithm: %s with %s%s\n",580ossl_rsa_mgf_nid2name(maskgenalg_nid),581ossl_rsa_oaeppss_nid2name(maskgenhashalg_nid),582(maskgenalg_nid == NID_mgf1583&& maskgenhashalg_nid == NID_sha1584? " (default)" : "")) <= 0)585goto err;586if (BIO_printf(out, " Minimum Salt Length: %d%s\n",587saltlen,588(saltlen == 20 ? " (default)" : "")) <= 0)589goto err;590if (BIO_printf(out, " Trailer Field: 0x%x%s\n",591trailerfield,592(trailerfield == 1 ? " (default)" : "")) <= 0)593goto err;594}595break;596}597}598599ret = 1;600err:601sk_BIGNUM_const_free(factors);602sk_BIGNUM_const_free(exps);603sk_BIGNUM_const_free(coeffs);604return ret;605}606607/* ---------------------------------------------------------------------- */608609#ifndef OPENSSL_NO_ML_DSA610static int ml_dsa_to_text(BIO *out, const void *key, int selection)611{612return ossl_ml_dsa_key_to_text(out, (ML_DSA_KEY *)key, selection);613}614#endif /* OPENSSL_NO_ML_DSA */615/* ---------------------------------------------------------------------- */616617static void *key2text_newctx(void *provctx)618{619return provctx;620}621622static void key2text_freectx(ossl_unused void *vctx)623{624}625626static int key2text_encode(void *vctx, const void *key, int selection,627OSSL_CORE_BIO *cout,628int (*key2text)(BIO *out, const void *key,629int selection),630OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)631{632BIO *out = ossl_bio_new_from_core_bio(vctx, cout);633int ret;634635if (out == NULL)636return 0;637638ret = key2text(out, key, selection);639BIO_free(out);640641return ret;642}643644#define MAKE_TEXT_ENCODER(impl, type) \645static OSSL_FUNC_encoder_import_object_fn \646impl##2text_import_object; \647static OSSL_FUNC_encoder_free_object_fn \648impl##2text_free_object; \649static OSSL_FUNC_encoder_encode_fn impl##2text_encode; \650\651static void *impl##2text_import_object(void *ctx, int selection, \652const OSSL_PARAM params[]) \653{ \654return ossl_prov_import_key(ossl_##impl##_keymgmt_functions, \655ctx, selection, params); \656} \657static void impl##2text_free_object(void *key) \658{ \659ossl_prov_free_key(ossl_##impl##_keymgmt_functions, key); \660} \661static int impl##2text_encode(void *vctx, OSSL_CORE_BIO *cout, \662const void *key, \663const OSSL_PARAM key_abstract[], \664int selection, \665OSSL_PASSPHRASE_CALLBACK *cb, \666void *cbarg) \667{ \668/* We don't deal with abstract objects */ \669if (key_abstract != NULL) { \670ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT); \671return 0; \672} \673return key2text_encode(vctx, key, selection, cout, \674type##_to_text, cb, cbarg); \675} \676const OSSL_DISPATCH ossl_##impl##_to_text_encoder_functions[] = { \677{ OSSL_FUNC_ENCODER_NEWCTX, \678(void (*)(void))key2text_newctx }, \679{ OSSL_FUNC_ENCODER_FREECTX, \680(void (*)(void))key2text_freectx }, \681{ OSSL_FUNC_ENCODER_IMPORT_OBJECT, \682(void (*)(void))impl##2text_import_object }, \683{ OSSL_FUNC_ENCODER_FREE_OBJECT, \684(void (*)(void))impl##2text_free_object }, \685{ OSSL_FUNC_ENCODER_ENCODE, \686(void (*)(void))impl##2text_encode }, \687OSSL_DISPATCH_END \688}689690#ifndef OPENSSL_NO_DH691MAKE_TEXT_ENCODER(dh, dh);692MAKE_TEXT_ENCODER(dhx, dh);693#endif694#ifndef OPENSSL_NO_DSA695MAKE_TEXT_ENCODER(dsa, dsa);696#endif697#ifndef OPENSSL_NO_EC698MAKE_TEXT_ENCODER(ec, ec);699# ifndef OPENSSL_NO_SM2700MAKE_TEXT_ENCODER(sm2, ec);701# endif702# ifndef OPENSSL_NO_ECX703MAKE_TEXT_ENCODER(ed25519, ecx);704MAKE_TEXT_ENCODER(ed448, ecx);705MAKE_TEXT_ENCODER(x25519, ecx);706MAKE_TEXT_ENCODER(x448, ecx);707# endif708#endif709#ifndef OPENSSL_NO_ML_KEM710MAKE_TEXT_ENCODER(ml_kem_512, ml_kem);711MAKE_TEXT_ENCODER(ml_kem_768, ml_kem);712MAKE_TEXT_ENCODER(ml_kem_1024, ml_kem);713#endif714MAKE_TEXT_ENCODER(rsa, rsa);715MAKE_TEXT_ENCODER(rsapss, rsa);716717#ifndef OPENSSL_NO_ML_DSA718MAKE_TEXT_ENCODER(ml_dsa_44, ml_dsa);719MAKE_TEXT_ENCODER(ml_dsa_65, ml_dsa);720MAKE_TEXT_ENCODER(ml_dsa_87, ml_dsa);721#endif722723#ifndef OPENSSL_NO_SLH_DSA724MAKE_TEXT_ENCODER(slh_dsa_sha2_128s, slh_dsa);725MAKE_TEXT_ENCODER(slh_dsa_sha2_128f, slh_dsa);726MAKE_TEXT_ENCODER(slh_dsa_sha2_192s, slh_dsa);727MAKE_TEXT_ENCODER(slh_dsa_sha2_192f, slh_dsa);728MAKE_TEXT_ENCODER(slh_dsa_sha2_256s, slh_dsa);729MAKE_TEXT_ENCODER(slh_dsa_sha2_256f, slh_dsa);730MAKE_TEXT_ENCODER(slh_dsa_shake_128s, slh_dsa);731MAKE_TEXT_ENCODER(slh_dsa_shake_128f, slh_dsa);732MAKE_TEXT_ENCODER(slh_dsa_shake_192s, slh_dsa);733MAKE_TEXT_ENCODER(slh_dsa_shake_192f, slh_dsa);734MAKE_TEXT_ENCODER(slh_dsa_shake_256s, slh_dsa);735MAKE_TEXT_ENCODER(slh_dsa_shake_256f, slh_dsa);736#endif737738739