| 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 |
*/ |
| 49 |
ENCODER_TEXT("RSA", rsa, yes), |
| 50 |
ENCODER_TEXT("RSA-PSS", rsapss, yes), |
| 51 |
#ifndef OPENSSL_NO_DH |
| 52 |
ENCODER_TEXT("DH", dh, yes), |
| 53 |
ENCODER_TEXT("DHX", dhx, yes), |
| 54 |
#endif |
| 55 |
#ifndef OPENSSL_NO_DSA |
| 56 |
ENCODER_TEXT("DSA", dsa, yes), |
| 57 |
#endif |
| 58 |
#ifndef OPENSSL_NO_EC |
| 59 |
ENCODER_TEXT("EC", ec, yes), |
| 60 |
# ifndef OPENSSL_NO_ECX |
| 61 |
ENCODER_TEXT("ED25519", ed25519, yes), |
| 62 |
ENCODER_TEXT("ED448", ed448, yes), |
| 63 |
ENCODER_TEXT("X25519", x25519, yes), |
| 64 |
ENCODER_TEXT("X448", x448, yes), |
| 65 |
# endif |
| 66 |
# ifndef OPENSSL_NO_SM2 |
| 67 |
ENCODER_TEXT("SM2", sm2, no), |
| 68 |
# endif |
| 69 |
#endif |
| 70 |
#ifndef OPENSSL_NO_ML_KEM |
| 71 |
ENCODER_TEXT("ML-KEM-512", ml_kem_512, yes), |
| 72 |
ENCODER_TEXT("ML-KEM-768", ml_kem_768, yes), |
| 73 |
ENCODER_TEXT("ML-KEM-1024", ml_kem_1024, yes), |
| 74 |
#endif |
| 75 |
#ifndef OPENSSL_NO_ML_DSA |
| 76 |
ENCODER_TEXT("ML-DSA-44", ml_dsa_44, yes), |
| 77 |
ENCODER_TEXT("ML-DSA-65", ml_dsa_65, yes), |
| 78 |
ENCODER_TEXT("ML-DSA-87", ml_dsa_87, yes), |
| 79 |
#endif |
| 80 |
#ifndef OPENSSL_NO_SLH_DSA |
| 81 |
ENCODER_TEXT("SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes), |
| 82 |
ENCODER_TEXT("SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes), |
| 83 |
ENCODER_TEXT("SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes), |
| 84 |
ENCODER_TEXT("SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes), |
| 85 |
ENCODER_TEXT("SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes), |
| 86 |
ENCODER_TEXT("SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes), |
| 87 |
ENCODER_TEXT("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes), |
| 88 |
ENCODER_TEXT("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes), |
| 89 |
ENCODER_TEXT("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes), |
| 90 |
ENCODER_TEXT("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes), |
| 91 |
ENCODER_TEXT("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes), |
| 92 |
ENCODER_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 */ |
| 120 |
ENCODER_w_structure("RSA", rsa, yes, der, type_specific_keypair), |
| 121 |
ENCODER_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. */ |
| 124 |
ENCODER_w_structure("DH", dh, yes, der, type_specific_params), |
| 125 |
ENCODER_w_structure("DH", dh, yes, pem, type_specific_params), |
| 126 |
ENCODER_w_structure("DHX", dhx, yes, der, type_specific_params), |
| 127 |
ENCODER_w_structure("DHX", dhx, yes, pem, type_specific_params), |
| 128 |
#endif |
| 129 |
#ifndef OPENSSL_NO_DSA |
| 130 |
ENCODER_w_structure("DSA", dsa, yes, der, type_specific), |
| 131 |
ENCODER_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. */ |
| 135 |
ENCODER_w_structure("EC", ec, yes, der, type_specific_no_pub), |
| 136 |
ENCODER_w_structure("EC", ec, yes, pem, type_specific_no_pub), |
| 137 |
/* EC supports blob output for the public key */ |
| 138 |
ENCODER("EC", ec, yes, blob), |
| 139 |
# ifndef OPENSSL_NO_SM2 |
| 140 |
ENCODER_w_structure("SM2", sm2, no, der, type_specific_no_pub), |
| 141 |
ENCODER_w_structure("SM2", sm2, no, pem, type_specific_no_pub), |
| 142 |
ENCODER("SM2", sm2, no, blob), |
| 143 |
# endif |
| 144 |
#endif |
| 145 |
|
| 146 |
/* |
| 147 |
* Entries for the output formats MSBLOB and PVK |
| 148 |
*/ |
| 149 |
ENCODER("RSA", rsa, yes, msblob), |
| 150 |
ENCODER("RSA", rsa, yes, pvk), |
| 151 |
#ifndef OPENSSL_NO_DSA |
| 152 |
ENCODER("DSA", dsa, yes, msblob), |
| 153 |
ENCODER("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 |
*/ |
| 163 |
ENCODER_w_structure("RSA", rsa, yes, der, EncryptedPrivateKeyInfo), |
| 164 |
ENCODER_w_structure("RSA", rsa, yes, pem, EncryptedPrivateKeyInfo), |
| 165 |
ENCODER_w_structure("RSA", rsa, yes, der, PrivateKeyInfo), |
| 166 |
ENCODER_w_structure("RSA", rsa, yes, pem, PrivateKeyInfo), |
| 167 |
ENCODER_w_structure("RSA", rsa, yes, der, SubjectPublicKeyInfo), |
| 168 |
ENCODER_w_structure("RSA", rsa, yes, pem, SubjectPublicKeyInfo), |
| 169 |
|
| 170 |
ENCODER_w_structure("RSA-PSS", rsapss, yes, der, EncryptedPrivateKeyInfo), |
| 171 |
ENCODER_w_structure("RSA-PSS", rsapss, yes, pem, EncryptedPrivateKeyInfo), |
| 172 |
ENCODER_w_structure("RSA-PSS", rsapss, yes, der, PrivateKeyInfo), |
| 173 |
ENCODER_w_structure("RSA-PSS", rsapss, yes, pem, PrivateKeyInfo), |
| 174 |
ENCODER_w_structure("RSA-PSS", rsapss, yes, der, SubjectPublicKeyInfo), |
| 175 |
ENCODER_w_structure("RSA-PSS", rsapss, yes, pem, SubjectPublicKeyInfo), |
| 176 |
|
| 177 |
#ifndef OPENSSL_NO_DH |
| 178 |
ENCODER_w_structure("DH", dh, yes, der, EncryptedPrivateKeyInfo), |
| 179 |
ENCODER_w_structure("DH", dh, yes, pem, EncryptedPrivateKeyInfo), |
| 180 |
ENCODER_w_structure("DH", dh, yes, der, PrivateKeyInfo), |
| 181 |
ENCODER_w_structure("DH", dh, yes, pem, PrivateKeyInfo), |
| 182 |
ENCODER_w_structure("DH", dh, yes, der, SubjectPublicKeyInfo), |
| 183 |
ENCODER_w_structure("DH", dh, yes, pem, SubjectPublicKeyInfo), |
| 184 |
|
| 185 |
ENCODER_w_structure("DHX", dhx, yes, der, EncryptedPrivateKeyInfo), |
| 186 |
ENCODER_w_structure("DHX", dhx, yes, pem, EncryptedPrivateKeyInfo), |
| 187 |
ENCODER_w_structure("DHX", dhx, yes, der, PrivateKeyInfo), |
| 188 |
ENCODER_w_structure("DHX", dhx, yes, pem, PrivateKeyInfo), |
| 189 |
ENCODER_w_structure("DHX", dhx, yes, der, SubjectPublicKeyInfo), |
| 190 |
ENCODER_w_structure("DHX", dhx, yes, pem, SubjectPublicKeyInfo), |
| 191 |
#endif |
| 192 |
|
| 193 |
#ifndef OPENSSL_NO_DSA |
| 194 |
ENCODER_w_structure("DSA", dsa, yes, der, EncryptedPrivateKeyInfo), |
| 195 |
ENCODER_w_structure("DSA", dsa, yes, pem, EncryptedPrivateKeyInfo), |
| 196 |
ENCODER_w_structure("DSA", dsa, yes, der, PrivateKeyInfo), |
| 197 |
ENCODER_w_structure("DSA", dsa, yes, pem, PrivateKeyInfo), |
| 198 |
ENCODER_w_structure("DSA", dsa, yes, der, SubjectPublicKeyInfo), |
| 199 |
ENCODER_w_structure("DSA", dsa, yes, pem, SubjectPublicKeyInfo), |
| 200 |
#endif |
| 201 |
|
| 202 |
#ifndef OPENSSL_NO_EC |
| 203 |
ENCODER_w_structure("EC", ec, yes, der, EncryptedPrivateKeyInfo), |
| 204 |
ENCODER_w_structure("EC", ec, yes, pem, EncryptedPrivateKeyInfo), |
| 205 |
ENCODER_w_structure("EC", ec, yes, der, PrivateKeyInfo), |
| 206 |
ENCODER_w_structure("EC", ec, yes, pem, PrivateKeyInfo), |
| 207 |
ENCODER_w_structure("EC", ec, yes, der, SubjectPublicKeyInfo), |
| 208 |
ENCODER_w_structure("EC", ec, yes, pem, SubjectPublicKeyInfo), |
| 209 |
|
| 210 |
# ifndef OPENSSL_NO_SM2 |
| 211 |
ENCODER_w_structure("SM2", sm2, no, der, EncryptedPrivateKeyInfo), |
| 212 |
ENCODER_w_structure("SM2", sm2, no, pem, EncryptedPrivateKeyInfo), |
| 213 |
ENCODER_w_structure("SM2", sm2, no, der, PrivateKeyInfo), |
| 214 |
ENCODER_w_structure("SM2", sm2, no, pem, PrivateKeyInfo), |
| 215 |
ENCODER_w_structure("SM2", sm2, no, der, SubjectPublicKeyInfo), |
| 216 |
ENCODER_w_structure("SM2", sm2, no, pem, SubjectPublicKeyInfo), |
| 217 |
# endif |
| 218 |
#endif |
| 219 |
|
| 220 |
#ifndef OPENSSL_NO_ECX |
| 221 |
ENCODER_w_structure("X25519", x25519, yes, der, EncryptedPrivateKeyInfo), |
| 222 |
ENCODER_w_structure("X25519", x25519, yes, pem, EncryptedPrivateKeyInfo), |
| 223 |
ENCODER_w_structure("X25519", x25519, yes, der, PrivateKeyInfo), |
| 224 |
ENCODER_w_structure("X25519", x25519, yes, pem, PrivateKeyInfo), |
| 225 |
ENCODER_w_structure("X25519", x25519, yes, der, SubjectPublicKeyInfo), |
| 226 |
ENCODER_w_structure("X25519", x25519, yes, pem, SubjectPublicKeyInfo), |
| 227 |
|
| 228 |
ENCODER_w_structure("X448", x448, yes, der, EncryptedPrivateKeyInfo), |
| 229 |
ENCODER_w_structure("X448", x448, yes, pem, EncryptedPrivateKeyInfo), |
| 230 |
ENCODER_w_structure("X448", x448, yes, der, PrivateKeyInfo), |
| 231 |
ENCODER_w_structure("X448", x448, yes, pem, PrivateKeyInfo), |
| 232 |
ENCODER_w_structure("X448", x448, yes, der, SubjectPublicKeyInfo), |
| 233 |
ENCODER_w_structure("X448", x448, yes, pem, SubjectPublicKeyInfo), |
| 234 |
|
| 235 |
ENCODER_w_structure("ED25519", ed25519, yes, der, EncryptedPrivateKeyInfo), |
| 236 |
ENCODER_w_structure("ED25519", ed25519, yes, pem, EncryptedPrivateKeyInfo), |
| 237 |
ENCODER_w_structure("ED25519", ed25519, yes, der, PrivateKeyInfo), |
| 238 |
ENCODER_w_structure("ED25519", ed25519, yes, pem, PrivateKeyInfo), |
| 239 |
ENCODER_w_structure("ED25519", ed25519, yes, der, SubjectPublicKeyInfo), |
| 240 |
ENCODER_w_structure("ED25519", ed25519, yes, pem, SubjectPublicKeyInfo), |
| 241 |
|
| 242 |
ENCODER_w_structure("ED448", ed448, yes, der, EncryptedPrivateKeyInfo), |
| 243 |
ENCODER_w_structure("ED448", ed448, yes, pem, EncryptedPrivateKeyInfo), |
| 244 |
ENCODER_w_structure("ED448", ed448, yes, der, PrivateKeyInfo), |
| 245 |
ENCODER_w_structure("ED448", ed448, yes, pem, PrivateKeyInfo), |
| 246 |
ENCODER_w_structure("ED448", ed448, yes, der, SubjectPublicKeyInfo), |
| 247 |
ENCODER_w_structure("ED448", ed448, yes, pem, SubjectPublicKeyInfo), |
| 248 |
#endif |
| 249 |
#ifndef OPENSSL_NO_SLH_DSA |
| 250 |
ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, der, EncryptedPrivateKeyInfo), |
| 251 |
ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, der, EncryptedPrivateKeyInfo), |
| 252 |
ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, der, EncryptedPrivateKeyInfo), |
| 253 |
ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, der, EncryptedPrivateKeyInfo), |
| 254 |
ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, der, EncryptedPrivateKeyInfo), |
| 255 |
ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, der, EncryptedPrivateKeyInfo), |
| 256 |
ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, der, EncryptedPrivateKeyInfo), |
| 257 |
ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, der, EncryptedPrivateKeyInfo), |
| 258 |
ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, der, EncryptedPrivateKeyInfo), |
| 259 |
ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, der, EncryptedPrivateKeyInfo), |
| 260 |
ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, der, EncryptedPrivateKeyInfo), |
| 261 |
ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, der, EncryptedPrivateKeyInfo), |
| 262 |
|
| 263 |
ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, pem, EncryptedPrivateKeyInfo), |
| 264 |
ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, pem, EncryptedPrivateKeyInfo), |
| 265 |
ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, pem, EncryptedPrivateKeyInfo), |
| 266 |
ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, pem, EncryptedPrivateKeyInfo), |
| 267 |
ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, pem, EncryptedPrivateKeyInfo), |
| 268 |
ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, pem, EncryptedPrivateKeyInfo), |
| 269 |
ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, pem, EncryptedPrivateKeyInfo), |
| 270 |
ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, pem, EncryptedPrivateKeyInfo), |
| 271 |
ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, pem, EncryptedPrivateKeyInfo), |
| 272 |
ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, pem, EncryptedPrivateKeyInfo), |
| 273 |
ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, pem, EncryptedPrivateKeyInfo), |
| 274 |
ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, pem, EncryptedPrivateKeyInfo), |
| 275 |
|
| 276 |
ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, der, PrivateKeyInfo), |
| 277 |
ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, der, PrivateKeyInfo), |
| 278 |
ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, der, PrivateKeyInfo), |
| 279 |
ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, der, PrivateKeyInfo), |
| 280 |
ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, der, PrivateKeyInfo), |
| 281 |
ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, der, PrivateKeyInfo), |
| 282 |
ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, der, PrivateKeyInfo), |
| 283 |
ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, der, PrivateKeyInfo), |
| 284 |
ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, der, PrivateKeyInfo), |
| 285 |
ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, der, PrivateKeyInfo), |
| 286 |
ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, der, PrivateKeyInfo), |
| 287 |
ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, der, PrivateKeyInfo), |
| 288 |
|
| 289 |
ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, pem, PrivateKeyInfo), |
| 290 |
ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, pem, PrivateKeyInfo), |
| 291 |
ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, pem, PrivateKeyInfo), |
| 292 |
ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, pem, PrivateKeyInfo), |
| 293 |
ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, pem, PrivateKeyInfo), |
| 294 |
ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, pem, PrivateKeyInfo), |
| 295 |
ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, pem, PrivateKeyInfo), |
| 296 |
ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, pem, PrivateKeyInfo), |
| 297 |
ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, pem, PrivateKeyInfo), |
| 298 |
ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, pem, PrivateKeyInfo), |
| 299 |
ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, pem, PrivateKeyInfo), |
| 300 |
ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, pem, PrivateKeyInfo), |
| 301 |
|
| 302 |
ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, der, SubjectPublicKeyInfo), |
| 303 |
ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, der, SubjectPublicKeyInfo), |
| 304 |
ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, der, SubjectPublicKeyInfo), |
| 305 |
ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, der, SubjectPublicKeyInfo), |
| 306 |
ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, der, SubjectPublicKeyInfo), |
| 307 |
ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, der, SubjectPublicKeyInfo), |
| 308 |
ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, der, SubjectPublicKeyInfo), |
| 309 |
ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, der, SubjectPublicKeyInfo), |
| 310 |
ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, der, SubjectPublicKeyInfo), |
| 311 |
ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, der, SubjectPublicKeyInfo), |
| 312 |
ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, der, SubjectPublicKeyInfo), |
| 313 |
ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, der, SubjectPublicKeyInfo), |
| 314 |
|
| 315 |
ENCODER_w_structure( "SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, yes, pem, SubjectPublicKeyInfo), |
| 316 |
ENCODER_w_structure( "SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, yes, pem, SubjectPublicKeyInfo), |
| 317 |
ENCODER_w_structure( "SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, yes, pem, SubjectPublicKeyInfo), |
| 318 |
ENCODER_w_structure( "SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, yes, pem, SubjectPublicKeyInfo), |
| 319 |
ENCODER_w_structure( "SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, yes, pem, SubjectPublicKeyInfo), |
| 320 |
ENCODER_w_structure( "SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, yes, pem, SubjectPublicKeyInfo), |
| 321 |
ENCODER_w_structure("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, yes, pem, SubjectPublicKeyInfo), |
| 322 |
ENCODER_w_structure("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, yes, pem, SubjectPublicKeyInfo), |
| 323 |
ENCODER_w_structure("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, yes, pem, SubjectPublicKeyInfo), |
| 324 |
ENCODER_w_structure("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, yes, pem, SubjectPublicKeyInfo), |
| 325 |
ENCODER_w_structure("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, yes, pem, SubjectPublicKeyInfo), |
| 326 |
ENCODER_w_structure("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, yes, pem, SubjectPublicKeyInfo), |
| 327 |
#endif |
| 328 |
|
| 329 |
#ifndef OPENSSL_NO_ML_KEM |
| 330 |
ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, der, EncryptedPrivateKeyInfo), |
| 331 |
ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, pem, EncryptedPrivateKeyInfo), |
| 332 |
ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, der, PrivateKeyInfo), |
| 333 |
ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, pem, PrivateKeyInfo), |
| 334 |
ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, der, SubjectPublicKeyInfo), |
| 335 |
ENCODER_w_structure("ML-KEM-512", ml_kem_512, yes, pem, SubjectPublicKeyInfo), |
| 336 |
|
| 337 |
ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, der, EncryptedPrivateKeyInfo), |
| 338 |
ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, pem, EncryptedPrivateKeyInfo), |
| 339 |
ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, der, PrivateKeyInfo), |
| 340 |
ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, pem, PrivateKeyInfo), |
| 341 |
ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, der, SubjectPublicKeyInfo), |
| 342 |
ENCODER_w_structure("ML-KEM-768", ml_kem_768, yes, pem, SubjectPublicKeyInfo), |
| 343 |
|
| 344 |
ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, der, EncryptedPrivateKeyInfo), |
| 345 |
ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, pem, EncryptedPrivateKeyInfo), |
| 346 |
ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, der, PrivateKeyInfo), |
| 347 |
ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, pem, PrivateKeyInfo), |
| 348 |
ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, der, SubjectPublicKeyInfo), |
| 349 |
ENCODER_w_structure("ML-KEM-1024", ml_kem_1024, yes, pem, SubjectPublicKeyInfo), |
| 350 |
#endif |
| 351 |
|
| 352 |
# ifndef OPENSSL_NO_ML_DSA |
| 353 |
ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, der, EncryptedPrivateKeyInfo), |
| 354 |
ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, pem, EncryptedPrivateKeyInfo), |
| 355 |
ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, der, PrivateKeyInfo), |
| 356 |
ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, pem, PrivateKeyInfo), |
| 357 |
ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, der, SubjectPublicKeyInfo), |
| 358 |
ENCODER_w_structure("ML-DSA-44", ml_dsa_44, yes, pem, SubjectPublicKeyInfo), |
| 359 |
|
| 360 |
ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, der, EncryptedPrivateKeyInfo), |
| 361 |
ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, pem, EncryptedPrivateKeyInfo), |
| 362 |
ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, der, PrivateKeyInfo), |
| 363 |
ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, pem, PrivateKeyInfo), |
| 364 |
ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, der, SubjectPublicKeyInfo), |
| 365 |
ENCODER_w_structure("ML-DSA-65", ml_dsa_65, yes, pem, SubjectPublicKeyInfo), |
| 366 |
|
| 367 |
ENCODER_w_structure("ML-DSA-87", ml_dsa_87, yes, der, EncryptedPrivateKeyInfo), |
| 368 |
ENCODER_w_structure("ML-DSA-87", ml_dsa_87, yes, pem, EncryptedPrivateKeyInfo), |
| 369 |
ENCODER_w_structure("ML-DSA-87", ml_dsa_87, yes, der, PrivateKeyInfo), |
| 370 |
ENCODER_w_structure("ML-DSA-87", ml_dsa_87, yes, pem, PrivateKeyInfo), |
| 371 |
ENCODER_w_structure("ML-DSA-87", ml_dsa_87, yes, der, SubjectPublicKeyInfo), |
| 372 |
ENCODER_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 */ |
| 383 |
ENCODER_w_structure("RSA", rsa, yes, der, RSA), |
| 384 |
ENCODER_w_structure("RSA", rsa, yes, pem, RSA), |
| 385 |
#ifndef OPENSSL_NO_DH |
| 386 |
/* DH and X9.42 DH only support key parameters output. */ |
| 387 |
ENCODER_w_structure("DH", dh, yes, der, DH), |
| 388 |
ENCODER_w_structure("DH", dh, yes, pem, DH), |
| 389 |
ENCODER_w_structure("DHX", dhx, yes, der, DHX), |
| 390 |
ENCODER_w_structure("DHX", dhx, yes, pem, DHX), |
| 391 |
#endif |
| 392 |
#ifndef OPENSSL_NO_DSA |
| 393 |
ENCODER_w_structure("DSA", dsa, yes, der, DSA), |
| 394 |
ENCODER_w_structure("DSA", dsa, yes, pem, DSA), |
| 395 |
#endif |
| 396 |
#ifndef OPENSSL_NO_EC |
| 397 |
ENCODER_w_structure("EC", ec, yes, der, EC), |
| 398 |
ENCODER_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 */ |
| 408 |
ENCODER_w_structure("RSA", rsa, yes, der, PKCS1), |
| 409 |
ENCODER_w_structure("RSA", rsa, yes, pem, PKCS1), |
| 410 |
ENCODER_w_structure("RSA-PSS", rsapss, yes, der, PKCS1), |
| 411 |
ENCODER_w_structure("RSA-PSS", rsapss, yes, pem, PKCS1), |
| 412 |
#ifndef OPENSSL_NO_DH |
| 413 |
/* PKCS#3 defines the format for DH parameters */ |
| 414 |
ENCODER_w_structure("DH", dh, yes, der, PKCS3), |
| 415 |
ENCODER_w_structure("DH", dh, yes, pem, PKCS3), |
| 416 |
/* X9.42 defines the format for DHX parameters */ |
| 417 |
ENCODER_w_structure("DHX", dhx, yes, der, X9_42), |
| 418 |
ENCODER_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 */ |
| 422 |
ENCODER_w_structure("EC", ec, yes, der, X9_62), |
| 423 |
ENCODER_w_structure("EC", ec, yes, pem, X9_62), |
| 424 |
#endif |