Home | History | Annotate | Line # | Download | only in providers
      1  1.1  christos /*
      2  1.1  christos  * Copyright 2020-2025 The OpenSSL Project Authors. All Rights Reserved.
      3  1.1  christos  *
      4  1.1  christos  * Licensed under the Apache License 2.0 (the "License").  You may not use
      5  1.1  christos  * this file except in compliance with the License.  You can obtain a copy
      6  1.1  christos  * in the file LICENSE in the source distribution or at
      7  1.1  christos  * https://www.openssl.org/source/license.html
      8  1.1  christos  */
      9  1.1  christos 
     10  1.1  christos #ifndef ENCODER_PROVIDER
     11  1.1  christos # error Macro ENCODER_PROVIDER undefined
     12  1.1  christos #endif
     13  1.1  christos 
     14  1.1  christos #define ENCODER_STRUCTURE_type_specific_keypair         "type-specific"
     15  1.1  christos #define ENCODER_STRUCTURE_type_specific_params          "type-specific"
     16  1.1  christos #define ENCODER_STRUCTURE_type_specific                 "type-specific"
     17  1.1  christos #define ENCODER_STRUCTURE_type_specific_no_pub          "type-specific"
     18  1.1  christos #define ENCODER_STRUCTURE_EncryptedPrivateKeyInfo       "EncryptedPrivateKeyInfo"
     19  1.1  christos #define ENCODER_STRUCTURE_PrivateKeyInfo                "PrivateKeyInfo"
     20  1.1  christos #define ENCODER_STRUCTURE_SubjectPublicKeyInfo          "SubjectPublicKeyInfo"
     21  1.1  christos #define ENCODER_STRUCTURE_DH                            "dh"
     22  1.1  christos #define ENCODER_STRUCTURE_DHX                           "dhx"
     23  1.1  christos #define ENCODER_STRUCTURE_DSA                           "dsa"
     24  1.1  christos #define ENCODER_STRUCTURE_EC                            "ec"
     25  1.1  christos #define ENCODER_STRUCTURE_RSA                           "rsa"
     26  1.1  christos #define ENCODER_STRUCTURE_PKCS1                         "pkcs1"
     27  1.1  christos #define ENCODER_STRUCTURE_PKCS3                         "pkcs3"
     28  1.1  christos #define ENCODER_STRUCTURE_X9_42                         "X9.42"
     29  1.1  christos #define ENCODER_STRUCTURE_X9_62                         "X9.62"
     30  1.1  christos 
     31  1.1  christos /* Arguments are prefixed with '_' to avoid build breaks on certain platforms */
     32  1.1  christos #define ENCODER_TEXT(_name, _sym, _fips)                                \
     33  1.1  christos     { _name,                                                            \
     34  1.1  christos       "provider=" ENCODER_PROVIDER ",fips=" #_fips ",output=text",      \
     35  1.1  christos       (ossl_##_sym##_to_text_encoder_functions) }
     36  1.1  christos #define ENCODER(_name, _sym, _fips, _output)                            \
     37  1.1  christos     { _name,                                                            \
     38  1.1  christos       "provider=" ENCODER_PROVIDER ",fips=" #_fips ",output=" #_output, \
     39  1.1  christos       (ossl_##_sym##_to_##_output##_encoder_functions) }
     40  1.1  christos #define ENCODER_w_structure(_name, _sym, _fips, _output, _structure)    \
     41  1.1  christos     { _name,                                                            \
     42  1.1  christos       "provider=" ENCODER_PROVIDER ",fips=" #_fips ",output=" #_output  \
     43  1.1  christos       ",structure=" ENCODER_STRUCTURE_##_structure,                     \
     44  1.1  christos       (ossl_##_sym##_to_##_structure##_##_output##_encoder_functions) }
     45  1.1  christos 
     46  1.1  christos /*
     47  1.1  christos  * Entries for human text "encoders"
     48  1.1  christos  */
     49  1.1  christos ENCODER_TEXT("RSA", rsa, yes),
     50  1.1  christos ENCODER_TEXT("RSA-PSS", rsapss, yes),
     51  1.1  christos #ifndef OPENSSL_NO_DH
     52  1.1  christos ENCODER_TEXT("DH", dh, yes),
     53  1.1  christos ENCODER_TEXT("DHX", dhx, yes),
     54  1.1  christos #endif
     55  1.1  christos #ifndef OPENSSL_NO_DSA
     56  1.1  christos ENCODER_TEXT("DSA", dsa, yes),
     57  1.1  christos #endif
     58  1.1  christos #ifndef OPENSSL_NO_EC
     59  1.1  christos ENCODER_TEXT("EC", ec, yes),
     60  1.1  christos # ifndef OPENSSL_NO_ECX
     61  1.1  christos ENCODER_TEXT("ED25519", ed25519, yes),
     62  1.1  christos ENCODER_TEXT("ED448", ed448, yes),
     63  1.1  christos ENCODER_TEXT("X25519", x25519, yes),
     64  1.1  christos ENCODER_TEXT("X448", x448, yes),
     65  1.1  christos # endif
     66  1.1  christos # ifndef OPENSSL_NO_SM2
     67  1.1  christos ENCODER_TEXT("SM2", sm2, no),
     68  1.1  christos # endif
     69  1.1  christos #endif
     70  1.1  christos #ifndef OPENSSL_NO_ML_KEM
     71  1.1  christos ENCODER_TEXT("ML-KEM-512", ml_kem_512, yes),
     72  1.1  christos ENCODER_TEXT("ML-KEM-768", ml_kem_768, yes),
     73  1.1  christos ENCODER_TEXT("ML-KEM-1024", ml_kem_1024, yes),
     74  1.1  christos #endif
     75  1.1  christos #ifndef OPENSSL_NO_ML_DSA
     76  1.1  christos ENCODER_TEXT("ML-DSA-44", ml_dsa_44, yes),
     77  1.1  christos ENCODER_TEXT("ML-DSA-65", ml_dsa_65, yes),
     78  1.1  christos ENCODER_TEXT("ML-DSA-87", ml_dsa_87, yes),
     79  1.1  christos #endif
     80  1.1  christos #ifndef OPENSSL_NO_SLH_DSA
     81  1.1  christos ENCODER_TEXT("SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes),
     82  1.1  christos ENCODER_TEXT("SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes),
     83  1.1  christos ENCODER_TEXT("SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes),
     84  1.1  christos ENCODER_TEXT("SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes),
     85  1.1  christos ENCODER_TEXT("SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes),
     86  1.1  christos ENCODER_TEXT("SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes),
     87  1.1  christos ENCODER_TEXT("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes),
     88  1.1  christos ENCODER_TEXT("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes),
     89  1.1  christos ENCODER_TEXT("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes),
     90  1.1  christos ENCODER_TEXT("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes),
     91  1.1  christos ENCODER_TEXT("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes),
     92  1.1  christos ENCODER_TEXT("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes),
     93  1.1  christos #endif
     94  1.1  christos 
     95  1.1  christos /*
     96  1.1  christos  * Entries for key type specific output formats.  The structure name on these
     97  1.1  christos  * is the same as the key type name.  This allows us to say something like:
     98  1.1  christos  *
     99  1.1  christos  * To replace i2d_{TYPE}PrivateKey(), i2d_{TYPE}PublicKey() and
    100  1.1  christos  * i2d_{TYPE}Params(), use OSSL_ENCODER functions with an OSSL_ENCODER_CTX
    101  1.1  christos  * created like this:
    102  1.1  christos  *
    103  1.1  christos  * OSSL_ENCODER_CTX *ctx =
    104  1.1  christos  *     OSSL_ENCODER_CTX_new_for_pkey(pkey, selection, "DER", "type-specific",
    105  1.1  christos  *                                   NULL, NULL);
    106  1.1  christos  *
    107  1.1  christos  * To replace PEM_write_bio_{TYPE}PrivateKey(), PEM_write_bio_{TYPE}PublicKey()
    108  1.1  christos  * and PEM_write_bio_{TYPE}Params(), use OSSL_ENCODER functions with an
    109  1.1  christos  * OSSL_ENCODER_CTX created like this:
    110  1.1  christos  *
    111  1.1  christos  * OSSL_ENCODER_CTX *ctx =
    112  1.1  christos  *     OSSL_ENCODER_CTX_new_for_pkey(pkey, selection, "PEM", "type-specific",
    113  1.1  christos  *                                   NULL, NULL);
    114  1.1  christos  *
    115  1.1  christos  * We only implement those for which there are current i2d_ and PEM_write_bio
    116  1.1  christos  * implementations.
    117  1.1  christos  */
    118  1.1  christos 
    119  1.1  christos /* The RSA encoders only support private key and public key output */
    120  1.1  christos ENCODER_w_structure("RSA", rsa, yes, der, type_specific_keypair),
    121  1.1  christos ENCODER_w_structure("RSA", rsa, yes, pem, type_specific_keypair),
    122  1.1  christos #ifndef OPENSSL_NO_DH
    123  1.1  christos /* DH and X9.42 DH only support key parameters output. */
    124  1.1  christos ENCODER_w_structure("DH", dh, yes, der, type_specific_params),
    125  1.1  christos ENCODER_w_structure("DH", dh, yes, pem, type_specific_params),
    126  1.1  christos ENCODER_w_structure("DHX", dhx, yes, der, type_specific_params),
    127  1.1  christos ENCODER_w_structure("DHX", dhx, yes, pem, type_specific_params),
    128  1.1  christos #endif
    129  1.1  christos #ifndef OPENSSL_NO_DSA
    130  1.1  christos ENCODER_w_structure("DSA", dsa, yes, der, type_specific),
    131  1.1  christos ENCODER_w_structure("DSA", dsa, yes, pem, type_specific),
    132  1.1  christos #endif
    133  1.1  christos #ifndef OPENSSL_NO_EC
    134  1.1  christos /* EC only supports keypair and parameters DER and PEM output. */
    135  1.1  christos ENCODER_w_structure("EC", ec, yes, der, type_specific_no_pub),
    136  1.1  christos ENCODER_w_structure("EC", ec, yes, pem, type_specific_no_pub),
    137  1.1  christos /* EC supports blob output for the public key */
    138  1.1  christos ENCODER("EC", ec, yes, blob),
    139  1.1  christos # ifndef OPENSSL_NO_SM2
    140  1.1  christos ENCODER_w_structure("SM2", sm2, no, der, type_specific_no_pub),
    141  1.1  christos ENCODER_w_structure("SM2", sm2, no, pem, type_specific_no_pub),
    142  1.1  christos ENCODER("SM2", sm2, no, blob),
    143  1.1  christos # endif
    144  1.1  christos #endif
    145  1.1  christos 
    146  1.1  christos /*
    147  1.1  christos  * Entries for the output formats MSBLOB and PVK
    148  1.1  christos  */
    149  1.1  christos ENCODER("RSA", rsa, yes, msblob),
    150  1.1  christos ENCODER("RSA", rsa, yes, pvk),
    151  1.1  christos #ifndef OPENSSL_NO_DSA
    152  1.1  christos ENCODER("DSA", dsa, yes, msblob),
    153  1.1  christos ENCODER("DSA", dsa, yes, pvk),
    154  1.1  christos #endif
    155  1.1  christos 
    156  1.1  christos /*
    157  1.1  christos  * Entries for encrypted PKCS#8 (EncryptedPrivateKeyInfo), unencrypted PKCS#8
    158  1.1  christos  * (PrivateKeyInfo) and SubjectPublicKeyInfo.  The "der" ones are added
    159  1.1  christos  * convenience for any user that wants to use OSSL_ENCODER directly.
    160  1.1  christos  * The "pem" ones also support PEM_write_bio_PrivateKey() and
    161  1.1  christos  * PEM_write_bio_PUBKEY().
    162  1.1  christos  */
    163  1.1  christos ENCODER_w_structure("RSA", rsa, yes, der, EncryptedPrivateKeyInfo),
    164  1.1  christos ENCODER_w_structure("RSA", rsa, yes, pem, EncryptedPrivateKeyInfo),
    165  1.1  christos ENCODER_w_structure("RSA", rsa, yes, der, PrivateKeyInfo),
    166  1.1  christos ENCODER_w_structure("RSA", rsa, yes, pem, PrivateKeyInfo),
    167  1.1  christos ENCODER_w_structure("RSA", rsa, yes, der, SubjectPublicKeyInfo),
    168  1.1  christos ENCODER_w_structure("RSA", rsa, yes, pem, SubjectPublicKeyInfo),
    169  1.1  christos 
    170  1.1  christos ENCODER_w_structure("RSA-PSS", rsapss, yes, der, EncryptedPrivateKeyInfo),
    171  1.1  christos ENCODER_w_structure("RSA-PSS", rsapss, yes, pem, EncryptedPrivateKeyInfo),
    172  1.1  christos ENCODER_w_structure("RSA-PSS", rsapss, yes, der, PrivateKeyInfo),
    173  1.1  christos ENCODER_w_structure("RSA-PSS", rsapss, yes, pem, PrivateKeyInfo),
    174  1.1  christos ENCODER_w_structure("RSA-PSS", rsapss, yes, der, SubjectPublicKeyInfo),
    175  1.1  christos ENCODER_w_structure("RSA-PSS", rsapss, yes, pem, SubjectPublicKeyInfo),
    176  1.1  christos 
    177  1.1  christos #ifndef OPENSSL_NO_DH
    178  1.1  christos ENCODER_w_structure("DH", dh, yes, der, EncryptedPrivateKeyInfo),
    179  1.1  christos ENCODER_w_structure("DH", dh, yes, pem, EncryptedPrivateKeyInfo),
    180  1.1  christos ENCODER_w_structure("DH", dh, yes, der, PrivateKeyInfo),
    181  1.1  christos ENCODER_w_structure("DH", dh, yes, pem, PrivateKeyInfo),
    182  1.1  christos ENCODER_w_structure("DH", dh, yes, der, SubjectPublicKeyInfo),
    183  1.1  christos ENCODER_w_structure("DH", dh, yes, pem, SubjectPublicKeyInfo),
    184  1.1  christos 
    185  1.1  christos ENCODER_w_structure("DHX", dhx, yes, der, EncryptedPrivateKeyInfo),
    186  1.1  christos ENCODER_w_structure("DHX", dhx, yes, pem, EncryptedPrivateKeyInfo),
    187  1.1  christos ENCODER_w_structure("DHX", dhx, yes, der, PrivateKeyInfo),
    188  1.1  christos ENCODER_w_structure("DHX", dhx, yes, pem, PrivateKeyInfo),
    189  1.1  christos ENCODER_w_structure("DHX", dhx, yes, der, SubjectPublicKeyInfo),
    190  1.1  christos ENCODER_w_structure("DHX", dhx, yes, pem, SubjectPublicKeyInfo),
    191  1.1  christos #endif
    192  1.1  christos 
    193  1.1  christos #ifndef OPENSSL_NO_DSA
    194  1.1  christos ENCODER_w_structure("DSA", dsa, yes, der, EncryptedPrivateKeyInfo),
    195  1.1  christos ENCODER_w_structure("DSA", dsa, yes, pem, EncryptedPrivateKeyInfo),
    196  1.1  christos ENCODER_w_structure("DSA", dsa, yes, der, PrivateKeyInfo),
    197  1.1  christos ENCODER_w_structure("DSA", dsa, yes, pem, PrivateKeyInfo),
    198  1.1  christos ENCODER_w_structure("DSA", dsa, yes, der, SubjectPublicKeyInfo),
    199  1.1  christos ENCODER_w_structure("DSA", dsa, yes, pem, SubjectPublicKeyInfo),
    200  1.1  christos #endif
    201  1.1  christos 
    202  1.1  christos #ifndef OPENSSL_NO_EC
    203  1.1  christos ENCODER_w_structure("EC", ec, yes, der, EncryptedPrivateKeyInfo),
    204  1.1  christos ENCODER_w_structure("EC", ec, yes, pem, EncryptedPrivateKeyInfo),
    205  1.1  christos ENCODER_w_structure("EC", ec, yes, der, PrivateKeyInfo),
    206  1.1  christos ENCODER_w_structure("EC", ec, yes, pem, PrivateKeyInfo),
    207  1.1  christos ENCODER_w_structure("EC", ec, yes, der, SubjectPublicKeyInfo),
    208  1.1  christos ENCODER_w_structure("EC", ec, yes, pem, SubjectPublicKeyInfo),
    209  1.1  christos 
    210  1.1  christos # ifndef OPENSSL_NO_SM2
    211  1.1  christos ENCODER_w_structure("SM2", sm2, no, der, EncryptedPrivateKeyInfo),
    212  1.1  christos ENCODER_w_structure("SM2", sm2, no, pem, EncryptedPrivateKeyInfo),
    213  1.1  christos ENCODER_w_structure("SM2", sm2, no, der, PrivateKeyInfo),
    214  1.1  christos ENCODER_w_structure("SM2", sm2, no, pem, PrivateKeyInfo),
    215  1.1  christos ENCODER_w_structure("SM2", sm2, no, der, SubjectPublicKeyInfo),
    216  1.1  christos ENCODER_w_structure("SM2", sm2, no, pem, SubjectPublicKeyInfo),
    217  1.1  christos # endif
    218  1.1  christos #endif
    219  1.1  christos 
    220  1.1  christos #ifndef OPENSSL_NO_ECX
    221  1.1  christos ENCODER_w_structure("X25519", x25519, yes, der, EncryptedPrivateKeyInfo),
    222  1.1  christos ENCODER_w_structure("X25519", x25519, yes, pem, EncryptedPrivateKeyInfo),
    223  1.1  christos ENCODER_w_structure("X25519", x25519, yes, der, PrivateKeyInfo),
    224  1.1  christos ENCODER_w_structure("X25519", x25519, yes, pem, PrivateKeyInfo),
    225  1.1  christos ENCODER_w_structure("X25519", x25519, yes, der, SubjectPublicKeyInfo),
    226  1.1  christos ENCODER_w_structure("X25519", x25519, yes, pem, SubjectPublicKeyInfo),
    227  1.1  christos 
    228  1.1  christos ENCODER_w_structure("X448", x448, yes, der, EncryptedPrivateKeyInfo),
    229  1.1  christos ENCODER_w_structure("X448", x448, yes, pem, EncryptedPrivateKeyInfo),
    230  1.1  christos ENCODER_w_structure("X448", x448, yes, der, PrivateKeyInfo),
    231  1.1  christos ENCODER_w_structure("X448", x448, yes, pem, PrivateKeyInfo),
    232  1.1  christos ENCODER_w_structure("X448", x448, yes, der, SubjectPublicKeyInfo),
    233  1.1  christos ENCODER_w_structure("X448", x448, yes, pem, SubjectPublicKeyInfo),
    234  1.1  christos 
    235  1.1  christos ENCODER_w_structure("ED25519", ed25519, yes, der, EncryptedPrivateKeyInfo),
    236  1.1  christos ENCODER_w_structure("ED25519", ed25519, yes, pem, EncryptedPrivateKeyInfo),
    237  1.1  christos ENCODER_w_structure("ED25519", ed25519, yes, der, PrivateKeyInfo),
    238  1.1  christos ENCODER_w_structure("ED25519", ed25519, yes, pem, PrivateKeyInfo),
    239  1.1  christos ENCODER_w_structure("ED25519", ed25519, yes, der, SubjectPublicKeyInfo),
    240  1.1  christos ENCODER_w_structure("ED25519", ed25519, yes, pem, SubjectPublicKeyInfo),
    241  1.1  christos 
    242  1.1  christos ENCODER_w_structure("ED448", ed448, yes, der, EncryptedPrivateKeyInfo),
    243  1.1  christos ENCODER_w_structure("ED448", ed448, yes, pem, EncryptedPrivateKeyInfo),
    244  1.1  christos ENCODER_w_structure("ED448", ed448, yes, der, PrivateKeyInfo),
    245  1.1  christos ENCODER_w_structure("ED448", ed448, yes, pem, PrivateKeyInfo),
    246  1.1  christos ENCODER_w_structure("ED448", ed448, yes, der, SubjectPublicKeyInfo),
    247  1.1  christos ENCODER_w_structure("ED448", ed448, yes, pem, SubjectPublicKeyInfo),
    248  1.1  christos #endif
    249  1.1  christos #ifndef OPENSSL_NO_SLH_DSA
    250  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, der, EncryptedPrivateKeyInfo),
    251  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, der, EncryptedPrivateKeyInfo),
    252  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, der, EncryptedPrivateKeyInfo),
    253  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, der, EncryptedPrivateKeyInfo),
    254  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, der, EncryptedPrivateKeyInfo),
    255  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, der, EncryptedPrivateKeyInfo),
    256  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, der, EncryptedPrivateKeyInfo),
    257  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, der, EncryptedPrivateKeyInfo),
    258  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, der, EncryptedPrivateKeyInfo),
    259  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, der, EncryptedPrivateKeyInfo),
    260  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, der, EncryptedPrivateKeyInfo),
    261  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, der, EncryptedPrivateKeyInfo),
    262  1.1  christos 
    263  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, pem, EncryptedPrivateKeyInfo),
    264  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, pem, EncryptedPrivateKeyInfo),
    265  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, pem, EncryptedPrivateKeyInfo),
    266  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, pem, EncryptedPrivateKeyInfo),
    267  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, pem, EncryptedPrivateKeyInfo),
    268  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, pem, EncryptedPrivateKeyInfo),
    269  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, pem, EncryptedPrivateKeyInfo),
    270  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, pem, EncryptedPrivateKeyInfo),
    271  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, pem, EncryptedPrivateKeyInfo),
    272  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, pem, EncryptedPrivateKeyInfo),
    273  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, pem, EncryptedPrivateKeyInfo),
    274  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, pem, EncryptedPrivateKeyInfo),
    275  1.1  christos 
    276  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, der, PrivateKeyInfo),
    277  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, der, PrivateKeyInfo),
    278  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, der, PrivateKeyInfo),
    279  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, der, PrivateKeyInfo),
    280  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, der, PrivateKeyInfo),
    281  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, der, PrivateKeyInfo),
    282  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, der, PrivateKeyInfo),
    283  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, der, PrivateKeyInfo),
    284  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, der, PrivateKeyInfo),
    285  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, der, PrivateKeyInfo),
    286  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, der, PrivateKeyInfo),
    287  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, der, PrivateKeyInfo),
    288  1.1  christos 
    289  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, pem, PrivateKeyInfo),
    290  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, pem, PrivateKeyInfo),
    291  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, pem, PrivateKeyInfo),
    292  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, pem, PrivateKeyInfo),
    293  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, pem, PrivateKeyInfo),
    294  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, pem, PrivateKeyInfo),
    295  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, pem, PrivateKeyInfo),
    296  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, pem, PrivateKeyInfo),
    297  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, pem, PrivateKeyInfo),
    298  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, pem, PrivateKeyInfo),
    299  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, pem, PrivateKeyInfo),
    300  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, pem, PrivateKeyInfo),
    301  1.1  christos 
    302  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, der, SubjectPublicKeyInfo),
    303  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, der, SubjectPublicKeyInfo),
    304  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, der, SubjectPublicKeyInfo),
    305  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, der, SubjectPublicKeyInfo),
    306  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, der, SubjectPublicKeyInfo),
    307  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, der, SubjectPublicKeyInfo),
    308  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, der, SubjectPublicKeyInfo),
    309  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, der, SubjectPublicKeyInfo),
    310  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, der, SubjectPublicKeyInfo),
    311  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, der, SubjectPublicKeyInfo),
    312  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, der, SubjectPublicKeyInfo),
    313  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, der, SubjectPublicKeyInfo),
    314  1.1  christos 
    315  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, pem, SubjectPublicKeyInfo),
    316  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, pem, SubjectPublicKeyInfo),
    317  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, pem, SubjectPublicKeyInfo),
    318  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, pem, SubjectPublicKeyInfo),
    319  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, pem, SubjectPublicKeyInfo),
    320  1.1  christos ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, pem, SubjectPublicKeyInfo),
    321  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, pem, SubjectPublicKeyInfo),
    322  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, pem, SubjectPublicKeyInfo),
    323  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, pem, SubjectPublicKeyInfo),
    324  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, pem, SubjectPublicKeyInfo),
    325  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, pem, SubjectPublicKeyInfo),
    326  1.1  christos ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, pem, SubjectPublicKeyInfo),
    327  1.1  christos #endif
    328  1.1  christos 
    329  1.1  christos #ifndef OPENSSL_NO_ML_KEM
    330  1.1  christos ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, der, EncryptedPrivateKeyInfo),
    331  1.1  christos ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, pem, EncryptedPrivateKeyInfo),
    332  1.1  christos ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, der, PrivateKeyInfo),
    333  1.1  christos ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, pem, PrivateKeyInfo),
    334  1.1  christos ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, der, SubjectPublicKeyInfo),
    335  1.1  christos ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, pem, SubjectPublicKeyInfo),
    336  1.1  christos 
    337  1.1  christos ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, der, EncryptedPrivateKeyInfo),
    338  1.1  christos ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, pem, EncryptedPrivateKeyInfo),
    339  1.1  christos ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, der, PrivateKeyInfo),
    340  1.1  christos ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, pem, PrivateKeyInfo),
    341  1.1  christos ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, der, SubjectPublicKeyInfo),
    342  1.1  christos ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, pem, SubjectPublicKeyInfo),
    343  1.1  christos 
    344  1.1  christos ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, der, EncryptedPrivateKeyInfo),
    345  1.1  christos ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, pem, EncryptedPrivateKeyInfo),
    346  1.1  christos ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, der, PrivateKeyInfo),
    347  1.1  christos ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, pem, PrivateKeyInfo),
    348  1.1  christos ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, der, SubjectPublicKeyInfo),
    349  1.1  christos ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, pem, SubjectPublicKeyInfo),
    350  1.1  christos #endif
    351  1.1  christos 
    352  1.1  christos # ifndef OPENSSL_NO_ML_DSA
    353  1.1  christos ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, der, EncryptedPrivateKeyInfo),
    354  1.1  christos ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, pem, EncryptedPrivateKeyInfo),
    355  1.1  christos ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, der, PrivateKeyInfo),
    356  1.1  christos ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, pem, PrivateKeyInfo),
    357  1.1  christos ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, der, SubjectPublicKeyInfo),
    358  1.1  christos ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, pem, SubjectPublicKeyInfo),
    359  1.1  christos 
    360  1.1  christos ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, der, EncryptedPrivateKeyInfo),
    361  1.1  christos ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, pem, EncryptedPrivateKeyInfo),
    362  1.1  christos ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, der, PrivateKeyInfo),
    363  1.1  christos ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, pem, PrivateKeyInfo),
    364  1.1  christos ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, der, SubjectPublicKeyInfo),
    365  1.1  christos ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, pem, SubjectPublicKeyInfo),
    366  1.1  christos 
    367  1.1  christos ENCODER_w_structure("ML-DSA-87", ml_dsa_87, yes, der, EncryptedPrivateKeyInfo),
    368  1.1  christos ENCODER_w_structure("ML-DSA-87", ml_dsa_87, yes, pem, EncryptedPrivateKeyInfo),
    369  1.1  christos ENCODER_w_structure("ML-DSA-87", ml_dsa_87, yes, der, PrivateKeyInfo),
    370  1.1  christos ENCODER_w_structure("ML-DSA-87", ml_dsa_87, yes, pem, PrivateKeyInfo),
    371  1.1  christos ENCODER_w_structure("ML-DSA-87", ml_dsa_87, yes, der, SubjectPublicKeyInfo),
    372  1.1  christos ENCODER_w_structure("ML-DSA-87", ml_dsa_87, yes, pem, SubjectPublicKeyInfo),
    373  1.1  christos # endif /* OPENSSL_NO_ML_DSA */
    374  1.1  christos 
    375  1.1  christos /*
    376  1.1  christos  * Entries for key type specific output formats.  These are exactly the
    377  1.1  christos  * same as the type specific above, except that they use the key type
    378  1.1  christos  * name as structure name instead of "type-specific", in the call on
    379  1.1  christos  * OSSL_ENCODER_CTX_new_for_pkey().
    380  1.1  christos  */
    381  1.1  christos 
    382  1.1  christos /* The RSA encoders only support private key and public key output */
    383  1.1  christos ENCODER_w_structure("RSA", rsa, yes, der, RSA),
    384  1.1  christos ENCODER_w_structure("RSA", rsa, yes, pem, RSA),
    385  1.1  christos #ifndef OPENSSL_NO_DH
    386  1.1  christos /* DH and X9.42 DH only support key parameters output. */
    387  1.1  christos ENCODER_w_structure("DH", dh, yes, der, DH),
    388  1.1  christos ENCODER_w_structure("DH", dh, yes, pem, DH),
    389  1.1  christos ENCODER_w_structure("DHX", dhx, yes, der, DHX),
    390  1.1  christos ENCODER_w_structure("DHX", dhx, yes, pem, DHX),
    391  1.1  christos #endif
    392  1.1  christos #ifndef OPENSSL_NO_DSA
    393  1.1  christos ENCODER_w_structure("DSA", dsa, yes, der, DSA),
    394  1.1  christos ENCODER_w_structure("DSA", dsa, yes, pem, DSA),
    395  1.1  christos #endif
    396  1.1  christos #ifndef OPENSSL_NO_EC
    397  1.1  christos ENCODER_w_structure("EC", ec, yes, der, EC),
    398  1.1  christos ENCODER_w_structure("EC", ec, yes, pem, EC),
    399  1.1  christos #endif
    400  1.1  christos 
    401  1.1  christos /*
    402  1.1  christos  * Additional entries with structure names being the standard name.
    403  1.1  christos  * This is entirely for the convenience of the user that wants to use
    404  1.1  christos  * OSSL_ENCODER directly with names they may fancy.  These do not impact
    405  1.1  christos  * on libcrypto functionality in any way.
    406  1.1  christos  */
    407  1.1  christos /* PKCS#1 is a well known for plain RSA keys, so we add that too */
    408  1.1  christos ENCODER_w_structure("RSA", rsa, yes, der, PKCS1),
    409  1.1  christos ENCODER_w_structure("RSA", rsa, yes, pem, PKCS1),
    410  1.1  christos ENCODER_w_structure("RSA-PSS", rsapss, yes, der, PKCS1),
    411  1.1  christos ENCODER_w_structure("RSA-PSS", rsapss, yes, pem, PKCS1),
    412  1.1  christos #ifndef OPENSSL_NO_DH
    413  1.1  christos /* PKCS#3 defines the format for DH parameters */
    414  1.1  christos ENCODER_w_structure("DH", dh, yes, der, PKCS3),
    415  1.1  christos ENCODER_w_structure("DH", dh, yes, pem, PKCS3),
    416  1.1  christos /* X9.42 defines the format for DHX parameters */
    417  1.1  christos ENCODER_w_structure("DHX", dhx, yes, der, X9_42),
    418  1.1  christos ENCODER_w_structure("DHX", dhx, yes, pem, X9_42),
    419  1.1  christos #endif
    420  1.1  christos #ifndef OPENSSL_NO_EC
    421  1.1  christos /* RFC 5915 defines the format for EC keys and parameters */
    422  1.1  christos ENCODER_w_structure("EC", ec, yes, der, X9_62),
    423  1.1  christos ENCODER_w_structure("EC", ec, yes, pem, X9_62),
    424  1.1  christos #endif
    425