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