Path: blob/main/crypto/openssl/providers/implementations/encode_decode/encode_key2text.c
102491 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)105<= 0)106return 0;107108return 1;109}110#endif111112/* ---------------------------------------------------------------------- */113114#ifndef OPENSSL_NO_DSA115static int dsa_to_text(BIO *out, const void *key, int selection)116{117const DSA *dsa = key;118const char *type_label = NULL;119const BIGNUM *priv_key = NULL, *pub_key = NULL;120const FFC_PARAMS *params = NULL;121const BIGNUM *p = NULL;122123if (out == NULL || dsa == NULL) {124ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);125return 0;126}127128if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)129type_label = "Private-Key";130else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)131type_label = "Public-Key";132else if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)133type_label = "DSA-Parameters";134135if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {136priv_key = DSA_get0_priv_key(dsa);137if (priv_key == NULL) {138ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);139return 0;140}141}142if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {143pub_key = DSA_get0_pub_key(dsa);144if (pub_key == NULL) {145ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);146return 0;147}148}149if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) {150params = ossl_dsa_get0_params((DSA *)dsa);151if (params == NULL) {152ERR_raise(ERR_LIB_PROV, PROV_R_NOT_PARAMETERS);153return 0;154}155}156157p = DSA_get0_p(dsa);158if (p == NULL) {159ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);160return 0;161}162163if (BIO_printf(out, "%s: (%d bit)\n", type_label, BN_num_bits(p)) <= 0)164return 0;165if (priv_key != NULL166&& !ossl_bio_print_labeled_bignum(out, "priv:", priv_key))167return 0;168if (pub_key != NULL169&& !ossl_bio_print_labeled_bignum(out, "pub: ", pub_key))170return 0;171if (params != NULL172&& !ossl_bio_print_ffc_params(out, params))173return 0;174175return 1;176}177#endif178179/* ---------------------------------------------------------------------- */180181#ifndef OPENSSL_NO_EC182static int ec_param_explicit_curve_to_text(BIO *out, const EC_GROUP *group,183BN_CTX *ctx)184{185const char *plabel = "Prime:";186BIGNUM *p = NULL, *a = NULL, *b = NULL;187188p = BN_CTX_get(ctx);189a = BN_CTX_get(ctx);190b = BN_CTX_get(ctx);191if (b == NULL192|| !EC_GROUP_get_curve(group, p, a, b, ctx))193return 0;194195if (EC_GROUP_get_field_type(group) == NID_X9_62_characteristic_two_field) {196int basis_type = EC_GROUP_get_basis_type(group);197198/* print the 'short name' of the base type OID */199if (basis_type == NID_undef200|| BIO_printf(out, "Basis Type: %s\n", OBJ_nid2sn(basis_type)) <= 0)201return 0;202plabel = "Polynomial:";203}204return ossl_bio_print_labeled_bignum(out, plabel, p)205&& ossl_bio_print_labeled_bignum(out, "A: ", a)206&& ossl_bio_print_labeled_bignum(out, "B: ", b);207}208209static int ec_param_explicit_gen_to_text(BIO *out, const EC_GROUP *group,210BN_CTX *ctx)211{212int ret;213size_t buflen;214point_conversion_form_t form;215const EC_POINT *point = NULL;216const char *glabel = NULL;217unsigned char *buf = NULL;218219form = EC_GROUP_get_point_conversion_form(group);220point = EC_GROUP_get0_generator(group);221222if (point == NULL)223return 0;224225switch (form) {226case POINT_CONVERSION_COMPRESSED:227glabel = "Generator (compressed):";228break;229case POINT_CONVERSION_UNCOMPRESSED:230glabel = "Generator (uncompressed):";231break;232case POINT_CONVERSION_HYBRID:233glabel = "Generator (hybrid):";234break;235default:236return 0;237}238239buflen = EC_POINT_point2buf(group, point, form, &buf, ctx);240if (buflen == 0)241return 0;242243ret = ossl_bio_print_labeled_buf(out, glabel, buf, buflen);244OPENSSL_clear_free(buf, buflen);245return ret;246}247248/* Print explicit parameters */249static int ec_param_explicit_to_text(BIO *out, const EC_GROUP *group,250OSSL_LIB_CTX *libctx)251{252int ret = 0, tmp_nid;253BN_CTX *ctx = NULL;254const BIGNUM *order = NULL, *cofactor = NULL;255const unsigned char *seed;256size_t seed_len = 0;257258ctx = BN_CTX_new_ex(libctx);259if (ctx == NULL)260return 0;261BN_CTX_start(ctx);262263tmp_nid = EC_GROUP_get_field_type(group);264order = EC_GROUP_get0_order(group);265if (order == NULL)266goto err;267268seed = EC_GROUP_get0_seed(group);269if (seed != NULL)270seed_len = EC_GROUP_get_seed_len(group);271cofactor = EC_GROUP_get0_cofactor(group);272273/* print the 'short name' of the field type */274if (BIO_printf(out, "Field Type: %s\n", OBJ_nid2sn(tmp_nid)) <= 0275|| !ec_param_explicit_curve_to_text(out, group, ctx)276|| !ec_param_explicit_gen_to_text(out, group, ctx)277|| !ossl_bio_print_labeled_bignum(out, "Order: ", order)278|| (cofactor != NULL279&& !ossl_bio_print_labeled_bignum(out, "Cofactor: ", cofactor))280|| (seed != NULL281&& !ossl_bio_print_labeled_buf(out, "Seed:", seed, seed_len)))282goto err;283ret = 1;284err:285BN_CTX_end(ctx);286BN_CTX_free(ctx);287return ret;288}289290static int ec_param_to_text(BIO *out, const EC_GROUP *group,291OSSL_LIB_CTX *libctx)292{293if (EC_GROUP_get_asn1_flag(group) & OPENSSL_EC_NAMED_CURVE) {294const char *curve_name;295int curve_nid = EC_GROUP_get_curve_name(group);296297/* Explicit parameters */298if (curve_nid == NID_undef)299return 0;300301if (BIO_printf(out, "%s: %s\n", "ASN1 OID", OBJ_nid2sn(curve_nid)) <= 0)302return 0;303304curve_name = EC_curve_nid2nist(curve_nid);305return (curve_name == NULL306|| BIO_printf(out, "%s: %s\n", "NIST CURVE", curve_name) > 0);307} else {308return ec_param_explicit_to_text(out, group, libctx);309}310}311312static int ec_to_text(BIO *out, const void *key, int selection)313{314const EC_KEY *ec = key;315const char *type_label = NULL;316unsigned char *priv = NULL, *pub = NULL;317size_t priv_len = 0, pub_len = 0;318const EC_GROUP *group;319int ret = 0;320321if (out == NULL || ec == NULL) {322ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);323return 0;324}325326if ((group = EC_KEY_get0_group(ec)) == NULL) {327ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);328return 0;329}330331if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)332type_label = "Private-Key";333else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)334type_label = "Public-Key";335else if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)336if (EC_GROUP_get_curve_name(group) != NID_sm2)337type_label = "EC-Parameters";338339if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {340const BIGNUM *priv_key = EC_KEY_get0_private_key(ec);341342if (priv_key == NULL) {343ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);344goto err;345}346priv_len = EC_KEY_priv2buf(ec, &priv);347if (priv_len == 0)348goto err;349}350if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {351const EC_POINT *pub_pt = EC_KEY_get0_public_key(ec);352353if (pub_pt == NULL) {354ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);355goto err;356}357358pub_len = EC_KEY_key2buf(ec, EC_KEY_get_conv_form(ec), &pub, NULL);359if (pub_len == 0)360goto err;361}362363if (type_label != NULL364&& BIO_printf(out, "%s: (%d bit)\n", type_label,365EC_GROUP_order_bits(group))366<= 0)367goto err;368if (priv != NULL369&& !ossl_bio_print_labeled_buf(out, "priv:", priv, priv_len))370goto err;371if (pub != NULL372&& !ossl_bio_print_labeled_buf(out, "pub:", pub, pub_len))373goto err;374if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)375ret = ec_param_to_text(out, group, ossl_ec_key_get_libctx(ec));376err:377OPENSSL_clear_free(priv, priv_len);378OPENSSL_free(pub);379return ret;380}381#endif382383/* ---------------------------------------------------------------------- */384385#ifndef OPENSSL_NO_ECX386static int ecx_to_text(BIO *out, const void *key, int selection)387{388const ECX_KEY *ecx = key;389const char *type_label = NULL;390391if (out == NULL || ecx == NULL) {392ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);393return 0;394}395396switch (ecx->type) {397case ECX_KEY_TYPE_X25519:398type_label = "X25519";399break;400case ECX_KEY_TYPE_X448:401type_label = "X448";402break;403case ECX_KEY_TYPE_ED25519:404type_label = "ED25519";405break;406case ECX_KEY_TYPE_ED448:407type_label = "ED448";408break;409}410411if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {412if (ecx->privkey == NULL) {413ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PRIVATE_KEY);414return 0;415}416417if (BIO_printf(out, "%s Private-Key:\n", type_label) <= 0)418return 0;419if (!ossl_bio_print_labeled_buf(out, "priv:", ecx->privkey, ecx->keylen))420return 0;421} else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {422/* ecx->pubkey is an array, not a pointer... */423if (!ecx->haspubkey) {424ERR_raise(ERR_LIB_PROV, PROV_R_NOT_A_PUBLIC_KEY);425return 0;426}427428if (BIO_printf(out, "%s Public-Key:\n", type_label) <= 0)429return 0;430}431432if (!ossl_bio_print_labeled_buf(out, "pub:", ecx->pubkey, ecx->keylen))433return 0;434435return 1;436}437#endif438439/* ---------------------------------------------------------------------- */440441#ifndef OPENSSL_NO_ML_KEM442static int ml_kem_to_text(BIO *out, const void *vkey, int selection)443{444return ossl_ml_kem_key_to_text(out, (ML_KEM_KEY *)vkey, selection);445}446#endif447448/* ---------------------------------------------------------------------- */449450#ifndef OPENSSL_NO_SLH_DSA451static int slh_dsa_to_text(BIO *out, const void *key, int selection)452{453return ossl_slh_dsa_key_to_text(out, (SLH_DSA_KEY *)key, selection);454}455#endif /* OPENSSL_NO_SLH_DSA */456457static int rsa_to_text(BIO *out, const void *key, int selection)458{459const RSA *rsa = key;460const char *type_label = "RSA key";461const char *modulus_label = NULL;462const char *exponent_label = NULL;463const BIGNUM *rsa_d = NULL, *rsa_n = NULL, *rsa_e = NULL;464STACK_OF(BIGNUM_const) *factors = NULL;465STACK_OF(BIGNUM_const) *exps = NULL;466STACK_OF(BIGNUM_const) *coeffs = NULL;467int primes;468const RSA_PSS_PARAMS_30 *pss_params = ossl_rsa_get0_pss_params_30((RSA *)rsa);469int ret = 0;470471if (out == NULL || rsa == NULL) {472ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_NULL_PARAMETER);473goto err;474}475476factors = sk_BIGNUM_const_new_null();477exps = sk_BIGNUM_const_new_null();478coeffs = sk_BIGNUM_const_new_null();479480if (factors == NULL || exps == NULL || coeffs == NULL) {481ERR_raise(ERR_LIB_PROV, ERR_R_CRYPTO_LIB);482goto err;483}484485if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {486type_label = "Private-Key";487modulus_label = "modulus:";488exponent_label = "publicExponent:";489} else if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {490type_label = "Public-Key";491modulus_label = "Modulus:";492exponent_label = "Exponent:";493}494495RSA_get0_key(rsa, &rsa_n, &rsa_e, &rsa_d);496ossl_rsa_get0_all_params((RSA *)rsa, factors, exps, coeffs);497primes = sk_BIGNUM_const_num(factors);498499if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {500if (BIO_printf(out, "%s: (%d bit, %d primes)\n",501type_label, BN_num_bits(rsa_n), primes)502<= 0)503goto err;504} else {505if (BIO_printf(out, "%s: (%d bit)\n",506type_label, BN_num_bits(rsa_n))507<= 0)508goto err;509}510511if (!ossl_bio_print_labeled_bignum(out, modulus_label, rsa_n))512goto err;513if (!ossl_bio_print_labeled_bignum(out, exponent_label, rsa_e))514goto err;515if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {516int i;517518if (!ossl_bio_print_labeled_bignum(out, "privateExponent:", rsa_d))519goto err;520if (!ossl_bio_print_labeled_bignum(out, "prime1:",521sk_BIGNUM_const_value(factors, 0)))522goto err;523if (!ossl_bio_print_labeled_bignum(out, "prime2:",524sk_BIGNUM_const_value(factors, 1)))525goto err;526if (!ossl_bio_print_labeled_bignum(out, "exponent1:",527sk_BIGNUM_const_value(exps, 0)))528goto err;529if (!ossl_bio_print_labeled_bignum(out, "exponent2:",530sk_BIGNUM_const_value(exps, 1)))531goto err;532if (!ossl_bio_print_labeled_bignum(out, "coefficient:",533sk_BIGNUM_const_value(coeffs, 0)))534goto err;535for (i = 2; i < sk_BIGNUM_const_num(factors); i++) {536if (BIO_printf(out, "prime%d:", i + 1) <= 0)537goto err;538if (!ossl_bio_print_labeled_bignum(out, NULL,539sk_BIGNUM_const_value(factors, i)))540goto err;541if (BIO_printf(out, "exponent%d:", i + 1) <= 0)542goto err;543if (!ossl_bio_print_labeled_bignum(out, NULL,544sk_BIGNUM_const_value(exps, i)))545goto err;546if (BIO_printf(out, "coefficient%d:", i + 1) <= 0)547goto err;548if (!ossl_bio_print_labeled_bignum(out, NULL,549sk_BIGNUM_const_value(coeffs, i - 1)))550goto err;551}552}553554if ((selection & OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) != 0) {555switch (RSA_test_flags(rsa, RSA_FLAG_TYPE_MASK)) {556case RSA_FLAG_TYPE_RSA:557if (!ossl_rsa_pss_params_30_is_unrestricted(pss_params)) {558if (BIO_printf(out, "(INVALID PSS PARAMETERS)\n") <= 0)559goto err;560}561break;562case RSA_FLAG_TYPE_RSASSAPSS:563if (ossl_rsa_pss_params_30_is_unrestricted(pss_params)) {564if (BIO_printf(out, "No PSS parameter restrictions\n") <= 0)565goto err;566} else {567int hashalg_nid = ossl_rsa_pss_params_30_hashalg(pss_params);568int maskgenalg_nid = ossl_rsa_pss_params_30_maskgenalg(pss_params);569int maskgenhashalg_nid = ossl_rsa_pss_params_30_maskgenhashalg(pss_params);570int saltlen = ossl_rsa_pss_params_30_saltlen(pss_params);571int trailerfield = ossl_rsa_pss_params_30_trailerfield(pss_params);572573if (BIO_printf(out, "PSS parameter restrictions:\n") <= 0)574goto err;575if (BIO_printf(out, " Hash Algorithm: %s%s\n",576ossl_rsa_oaeppss_nid2name(hashalg_nid),577(hashalg_nid == NID_sha1578? " (default)"579: ""))580<= 0)581goto err;582if (BIO_printf(out, " Mask Algorithm: %s with %s%s\n",583ossl_rsa_mgf_nid2name(maskgenalg_nid),584ossl_rsa_oaeppss_nid2name(maskgenhashalg_nid),585(maskgenalg_nid == NID_mgf1586&& maskgenhashalg_nid == NID_sha1587? " (default)"588: ""))589<= 0)590goto err;591if (BIO_printf(out, " Minimum Salt Length: %d%s\n",592saltlen,593(saltlen == 20 ? " (default)" : ""))594<= 0)595goto err;596if (BIO_printf(out, " Trailer Field: 0x%x%s\n",597trailerfield,598(trailerfield == 1 ? " (default)" : ""))599<= 0)600goto err;601}602break;603}604}605606ret = 1;607err:608sk_BIGNUM_const_free(factors);609sk_BIGNUM_const_free(exps);610sk_BIGNUM_const_free(coeffs);611return ret;612}613614/* ---------------------------------------------------------------------- */615616#ifndef OPENSSL_NO_ML_DSA617static int ml_dsa_to_text(BIO *out, const void *key, int selection)618{619return ossl_ml_dsa_key_to_text(out, (ML_DSA_KEY *)key, selection);620}621#endif /* OPENSSL_NO_ML_DSA */622/* ---------------------------------------------------------------------- */623624static void *key2text_newctx(void *provctx)625{626return provctx;627}628629static void key2text_freectx(ossl_unused void *vctx)630{631}632633static int key2text_encode(void *vctx, const void *key, int selection,634OSSL_CORE_BIO *cout,635int (*key2text)(BIO *out, const void *key,636int selection),637OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)638{639BIO *out = ossl_bio_new_from_core_bio(vctx, cout);640int ret;641642if (out == NULL)643return 0;644645ret = key2text(out, key, selection);646BIO_free(out);647648return ret;649}650651#define MAKE_TEXT_ENCODER(impl, type) \652static OSSL_FUNC_encoder_import_object_fn \653impl##2text_import_object; \654static OSSL_FUNC_encoder_free_object_fn \655impl##2text_free_object; \656static OSSL_FUNC_encoder_encode_fn impl##2text_encode; \657\658static void *impl##2text_import_object(void *ctx, int selection, \659const OSSL_PARAM params[]) \660{ \661return ossl_prov_import_key(ossl_##impl##_keymgmt_functions, \662ctx, selection, params); \663} \664static void impl##2text_free_object(void *key) \665{ \666ossl_prov_free_key(ossl_##impl##_keymgmt_functions, key); \667} \668static int impl##2text_encode(void *vctx, OSSL_CORE_BIO *cout, \669const void *key, \670const OSSL_PARAM key_abstract[], \671int selection, \672OSSL_PASSPHRASE_CALLBACK *cb, \673void *cbarg) \674{ \675/* We don't deal with abstract objects */ \676if (key_abstract != NULL) { \677ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT); \678return 0; \679} \680return key2text_encode(vctx, key, selection, cout, \681type##_to_text, cb, cbarg); \682} \683const OSSL_DISPATCH ossl_##impl##_to_text_encoder_functions[] = { \684{ OSSL_FUNC_ENCODER_NEWCTX, \685(void (*)(void))key2text_newctx }, \686{ OSSL_FUNC_ENCODER_FREECTX, \687(void (*)(void))key2text_freectx }, \688{ OSSL_FUNC_ENCODER_IMPORT_OBJECT, \689(void (*)(void))impl##2text_import_object }, \690{ OSSL_FUNC_ENCODER_FREE_OBJECT, \691(void (*)(void))impl##2text_free_object }, \692{ OSSL_FUNC_ENCODER_ENCODE, \693(void (*)(void))impl##2text_encode }, \694OSSL_DISPATCH_END \695}696697#ifndef OPENSSL_NO_DH698MAKE_TEXT_ENCODER(dh, dh);699MAKE_TEXT_ENCODER(dhx, dh);700#endif701#ifndef OPENSSL_NO_DSA702MAKE_TEXT_ENCODER(dsa, dsa);703#endif704#ifndef OPENSSL_NO_EC705MAKE_TEXT_ENCODER(ec, ec);706#ifndef OPENSSL_NO_SM2707MAKE_TEXT_ENCODER(sm2, ec);708#endif709#ifndef OPENSSL_NO_ECX710MAKE_TEXT_ENCODER(ed25519, ecx);711MAKE_TEXT_ENCODER(ed448, ecx);712MAKE_TEXT_ENCODER(x25519, ecx);713MAKE_TEXT_ENCODER(x448, ecx);714#endif715#endif716#ifndef OPENSSL_NO_ML_KEM717MAKE_TEXT_ENCODER(ml_kem_512, ml_kem);718MAKE_TEXT_ENCODER(ml_kem_768, ml_kem);719MAKE_TEXT_ENCODER(ml_kem_1024, ml_kem);720#endif721MAKE_TEXT_ENCODER(rsa, rsa);722MAKE_TEXT_ENCODER(rsapss, rsa);723724#ifndef OPENSSL_NO_ML_DSA725MAKE_TEXT_ENCODER(ml_dsa_44, ml_dsa);726MAKE_TEXT_ENCODER(ml_dsa_65, ml_dsa);727MAKE_TEXT_ENCODER(ml_dsa_87, ml_dsa);728#endif729730#ifndef OPENSSL_NO_SLH_DSA731MAKE_TEXT_ENCODER(slh_dsa_sha2_128s, slh_dsa);732MAKE_TEXT_ENCODER(slh_dsa_sha2_128f, slh_dsa);733MAKE_TEXT_ENCODER(slh_dsa_sha2_192s, slh_dsa);734MAKE_TEXT_ENCODER(slh_dsa_sha2_192f, slh_dsa);735MAKE_TEXT_ENCODER(slh_dsa_sha2_256s, slh_dsa);736MAKE_TEXT_ENCODER(slh_dsa_sha2_256f, slh_dsa);737MAKE_TEXT_ENCODER(slh_dsa_shake_128s, slh_dsa);738MAKE_TEXT_ENCODER(slh_dsa_shake_128f, slh_dsa);739MAKE_TEXT_ENCODER(slh_dsa_shake_192s, slh_dsa);740MAKE_TEXT_ENCODER(slh_dsa_shake_192f, slh_dsa);741MAKE_TEXT_ENCODER(slh_dsa_shake_256s, slh_dsa);742MAKE_TEXT_ENCODER(slh_dsa_shake_256f, slh_dsa);743#endif744745746