/src/openssl/providers/implementations/encode_decode/decode_der2key.c
Line | Count | Source (jump to first uncovered line) |
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 | | |
11 | | /* |
12 | | * low level APIs are deprecated for public use, but still ok for |
13 | | * internal use. |
14 | | */ |
15 | | #include "internal/deprecated.h" |
16 | | |
17 | | #include <openssl/byteorder.h> |
18 | | #include <openssl/core_dispatch.h> |
19 | | #include <openssl/core_names.h> |
20 | | #include <openssl/core_object.h> |
21 | | #include <openssl/crypto.h> |
22 | | #include <openssl/err.h> |
23 | | #include <openssl/params.h> |
24 | | #include <openssl/pem.h> /* PEM_BUFSIZE and public PEM functions */ |
25 | | #include <openssl/pkcs12.h> |
26 | | #include <openssl/provider.h> |
27 | | #include <openssl/x509.h> |
28 | | #include <openssl/proverr.h> |
29 | | #include <openssl/asn1t.h> |
30 | | #include "internal/cryptlib.h" /* ossl_assert() */ |
31 | | #include "crypto/dh.h" |
32 | | #include "crypto/dsa.h" |
33 | | #include "crypto/ec.h" |
34 | | #include "crypto/evp.h" |
35 | | #include "crypto/ecx.h" |
36 | | #include "crypto/rsa.h" |
37 | | #include "crypto/ml_dsa.h" |
38 | | #include "crypto/slh_dsa.h" |
39 | | #include "crypto/x509.h" |
40 | | #include "crypto/ml_kem.h" |
41 | | #include "openssl/obj_mac.h" |
42 | | #include "prov/bio.h" |
43 | | #include "prov/implementations.h" |
44 | | #include "prov/endecoder_local.h" |
45 | | #include "internal/nelem.h" |
46 | | #include "prov/ml_dsa_codecs.h" |
47 | | #include "prov/ml_kem_codecs.h" |
48 | | |
49 | | #ifndef OPENSSL_NO_SLH_DSA |
50 | | typedef struct { |
51 | | ASN1_OBJECT *oid; |
52 | | } BARE_ALGOR; |
53 | | |
54 | | typedef struct { |
55 | | BARE_ALGOR algor; |
56 | | ASN1_BIT_STRING *pubkey; |
57 | | } BARE_PUBKEY; |
58 | | |
59 | | ASN1_SEQUENCE(BARE_ALGOR) = { |
60 | | ASN1_SIMPLE(BARE_ALGOR, oid, ASN1_OBJECT), |
61 | | } static_ASN1_SEQUENCE_END(BARE_ALGOR) |
62 | | |
63 | | ASN1_SEQUENCE(BARE_PUBKEY) = { |
64 | | ASN1_EMBED(BARE_PUBKEY, algor, BARE_ALGOR), |
65 | | ASN1_SIMPLE(BARE_PUBKEY, pubkey, ASN1_BIT_STRING) |
66 | | } static_ASN1_SEQUENCE_END(BARE_PUBKEY) |
67 | | #endif /* OPENSSL_NO_SLH_DSA */ |
68 | | |
69 | | struct der2key_ctx_st; /* Forward declaration */ |
70 | | typedef int check_key_fn(void *, struct der2key_ctx_st *ctx); |
71 | | typedef void adjust_key_fn(void *, struct der2key_ctx_st *ctx); |
72 | | typedef void free_key_fn(void *); |
73 | | typedef void *d2i_PKCS8_fn(const unsigned char **, long, |
74 | | struct der2key_ctx_st *); |
75 | | typedef void *d2i_PUBKEY_fn(const unsigned char **, long, |
76 | | struct der2key_ctx_st *); |
77 | | struct keytype_desc_st { |
78 | | const char *keytype_name; |
79 | | const OSSL_DISPATCH *fns; /* Keymgmt (to pilfer functions from) */ |
80 | | |
81 | | /* The input structure name */ |
82 | | const char *structure_name; |
83 | | |
84 | | /* |
85 | | * The EVP_PKEY_xxx type macro. Should be zero for type specific |
86 | | * structures, non-zero when the outermost structure is PKCS#8 or |
87 | | * SubjectPublicKeyInfo. This determines which of the function |
88 | | * pointers below will be used. |
89 | | */ |
90 | | int evp_type; |
91 | | |
92 | | /* The selection mask for OSSL_FUNC_decoder_does_selection() */ |
93 | | int selection_mask; |
94 | | |
95 | | /* For type specific decoders, we use the corresponding d2i */ |
96 | | d2i_of_void *d2i_private_key; /* From type-specific DER */ |
97 | | d2i_of_void *d2i_public_key; /* From type-specific DER */ |
98 | | d2i_of_void *d2i_key_params; /* From type-specific DER */ |
99 | | d2i_PKCS8_fn *d2i_PKCS8; /* Wrapped in a PrivateKeyInfo */ |
100 | | d2i_PUBKEY_fn *d2i_PUBKEY; /* Wrapped in a SubjectPublicKeyInfo */ |
101 | | |
102 | | /* |
103 | | * For any key, we may need to check that the key meets expectations. |
104 | | * This is useful when the same functions can decode several variants |
105 | | * of a key. |
106 | | */ |
107 | | check_key_fn *check_key; |
108 | | |
109 | | /* |
110 | | * For any key, we may need to make provider specific adjustments, such |
111 | | * as ensure the key carries the correct library context. |
112 | | */ |
113 | | adjust_key_fn *adjust_key; |
114 | | /* {type}_free() */ |
115 | | free_key_fn *free_key; |
116 | | }; |
117 | | |
118 | | /* |
119 | | * Context used for DER to key decoding. |
120 | | */ |
121 | | struct der2key_ctx_st { |
122 | | PROV_CTX *provctx; |
123 | | char propq[OSSL_MAX_PROPQUERY_SIZE]; |
124 | | const struct keytype_desc_st *desc; |
125 | | /* The selection that is passed to der2key_decode() */ |
126 | | int selection; |
127 | | /* Flag used to signal that a failure is fatal */ |
128 | | unsigned int flag_fatal : 1; |
129 | | }; |
130 | | |
131 | | typedef void *key_from_pkcs8_t(const PKCS8_PRIV_KEY_INFO *p8inf, |
132 | | OSSL_LIB_CTX *libctx, const char *propq); |
133 | | static void *der2key_decode_p8(const unsigned char **input_der, |
134 | | long input_der_len, struct der2key_ctx_st *ctx, |
135 | | key_from_pkcs8_t *key_from_pkcs8) |
136 | 964k | { |
137 | 964k | PKCS8_PRIV_KEY_INFO *p8inf = NULL; |
138 | 964k | const X509_ALGOR *alg = NULL; |
139 | 964k | void *key = NULL; |
140 | | |
141 | 964k | if ((p8inf = d2i_PKCS8_PRIV_KEY_INFO(NULL, input_der, input_der_len)) != NULL |
142 | 964k | && PKCS8_pkey_get0(NULL, NULL, NULL, &alg, p8inf) |
143 | 964k | && (OBJ_obj2nid(alg->algorithm) == ctx->desc->evp_type |
144 | | /* Allow decoding sm2 private key with id_ecPublicKey */ |
145 | 99.0k | || (OBJ_obj2nid(alg->algorithm) == NID_X9_62_id_ecPublicKey |
146 | 79.8k | && ctx->desc->evp_type == NID_sm2))) |
147 | 19.7k | key = key_from_pkcs8(p8inf, PROV_LIBCTX_OF(ctx->provctx), ctx->propq); |
148 | 964k | PKCS8_PRIV_KEY_INFO_free(p8inf); |
149 | | |
150 | 964k | return key; |
151 | 964k | } |
152 | | |
153 | | /* ---------------------------------------------------------------------- */ |
154 | | |
155 | | static OSSL_FUNC_decoder_freectx_fn der2key_freectx; |
156 | | static OSSL_FUNC_decoder_decode_fn der2key_decode; |
157 | | static OSSL_FUNC_decoder_export_object_fn der2key_export_object; |
158 | | static OSSL_FUNC_decoder_settable_ctx_params_fn der2key_settable_ctx_params; |
159 | | static OSSL_FUNC_decoder_set_ctx_params_fn der2key_set_ctx_params; |
160 | | |
161 | | static struct der2key_ctx_st * |
162 | | der2key_newctx(void *provctx, const struct keytype_desc_st *desc) |
163 | 8.09M | { |
164 | 8.09M | struct der2key_ctx_st *ctx = OPENSSL_zalloc(sizeof(*ctx)); |
165 | | |
166 | 8.09M | if (ctx != NULL) { |
167 | 8.09M | ctx->provctx = provctx; |
168 | 8.09M | ctx->desc = desc; |
169 | 8.09M | } |
170 | 8.09M | return ctx; |
171 | 8.09M | } |
172 | | |
173 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
174 | | #ifndef der2key_set_ctx_params_list |
175 | | static const OSSL_PARAM der2key_set_ctx_params_list[] = { |
176 | | OSSL_PARAM_utf8_string(OSSL_DECODER_PARAM_PROPERTIES, NULL, 0), |
177 | | OSSL_PARAM_END |
178 | | }; |
179 | | #endif |
180 | | |
181 | | #ifndef der2key_set_ctx_params_st |
182 | | struct der2key_set_ctx_params_st { |
183 | | OSSL_PARAM *propq; |
184 | | }; |
185 | | #endif |
186 | | |
187 | | #ifndef der2key_set_ctx_params_decoder |
188 | | static int der2key_set_ctx_params_decoder |
189 | | (const OSSL_PARAM *p, struct der2key_set_ctx_params_st *r) |
190 | 0 | { |
191 | 0 | const char *s; |
192 | |
|
193 | 0 | memset(r, 0, sizeof(*r)); |
194 | 0 | if (p != NULL) |
195 | 0 | for (; (s = p->key) != NULL; p++) |
196 | 0 | if (ossl_likely(strcmp("properties", s + 0) == 0)) { |
197 | | /* DECODER_PARAM_PROPERTIES */ |
198 | 0 | if (ossl_unlikely(r->propq != NULL)) { |
199 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
200 | 0 | "param %s is repeated", s); |
201 | 0 | return 0; |
202 | 0 | } |
203 | 0 | r->propq = (OSSL_PARAM *)p; |
204 | 0 | } |
205 | 0 | return 1; |
206 | 0 | } |
207 | | #endif |
208 | | /* End of machine generated */ |
209 | | |
210 | | static const OSSL_PARAM *der2key_settable_ctx_params(ossl_unused void *provctx) |
211 | 0 | { |
212 | 0 | return der2key_set_ctx_params_list; |
213 | 0 | } |
214 | | |
215 | | static int der2key_set_ctx_params(void *vctx, const OSSL_PARAM params[]) |
216 | 0 | { |
217 | 0 | struct der2key_ctx_st *ctx = vctx; |
218 | 0 | struct der2key_set_ctx_params_st p; |
219 | 0 | char *str; |
220 | |
|
221 | 0 | if (ctx == NULL || !der2key_set_ctx_params_decoder(params, &p)) |
222 | 0 | return 0; |
223 | | |
224 | 0 | str = ctx->propq; |
225 | 0 | if (p.propq != NULL |
226 | 0 | && !OSSL_PARAM_get_utf8_string(p.propq, &str, sizeof(ctx->propq))) |
227 | 0 | return 0; |
228 | | |
229 | 0 | return 1; |
230 | 0 | } |
231 | | |
232 | | static void der2key_freectx(void *vctx) |
233 | 8.09M | { |
234 | 8.09M | struct der2key_ctx_st *ctx = vctx; |
235 | | |
236 | 8.09M | OPENSSL_free(ctx); |
237 | 8.09M | } |
238 | | |
239 | | static int der2key_check_selection(int selection, |
240 | | const struct keytype_desc_st *desc) |
241 | 8.99M | { |
242 | | /* |
243 | | * The selections are kinda sorta "levels", i.e. each selection given |
244 | | * here is assumed to include those following. |
245 | | */ |
246 | 8.99M | int checks[] = { |
247 | 8.99M | OSSL_KEYMGMT_SELECT_PRIVATE_KEY, |
248 | 8.99M | OSSL_KEYMGMT_SELECT_PUBLIC_KEY, |
249 | 8.99M | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS |
250 | 8.99M | }; |
251 | 8.99M | size_t i; |
252 | | |
253 | | /* The decoder implementations made here support guessing */ |
254 | 8.99M | if (selection == 0) |
255 | 237 | return 1; |
256 | | |
257 | 16.5M | for (i = 0; i < OSSL_NELEM(checks); i++) { |
258 | 16.5M | int check1 = (selection & checks[i]) != 0; |
259 | 16.5M | int check2 = (desc->selection_mask & checks[i]) != 0; |
260 | | |
261 | | /* |
262 | | * If the caller asked for the currently checked bit(s), return |
263 | | * whether the decoder description says it's supported. |
264 | | */ |
265 | 16.5M | if (check1) |
266 | 8.99M | return check2; |
267 | 16.5M | } |
268 | | |
269 | | /* This should be dead code, but just to be safe... */ |
270 | 0 | return 0; |
271 | 8.99M | } |
272 | | |
273 | | static int der2key_decode(void *vctx, OSSL_CORE_BIO *cin, int selection, |
274 | | OSSL_CALLBACK *data_cb, void *data_cbarg, |
275 | | OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg) |
276 | 4.06M | { |
277 | 4.06M | struct der2key_ctx_st *ctx = vctx; |
278 | 4.06M | unsigned char *der = NULL; |
279 | 4.06M | const unsigned char *derp; |
280 | 4.06M | long der_len = 0; |
281 | 4.06M | void *key = NULL; |
282 | 4.06M | int ok = 0; |
283 | | |
284 | 4.06M | ctx->selection = selection; |
285 | | /* |
286 | | * The caller is allowed to specify 0 as a selection mask, to have the |
287 | | * structure and key type guessed. For type-specific structures, this |
288 | | * is not recommended, as some structures are very similar. |
289 | | * Note that 0 isn't the same as OSSL_KEYMGMT_SELECT_ALL, as the latter |
290 | | * signifies a private key structure, where everything else is assumed |
291 | | * to be present as well. |
292 | | */ |
293 | 4.06M | if (selection == 0) |
294 | 1.29M | selection = ctx->desc->selection_mask; |
295 | 4.06M | if ((selection & ctx->desc->selection_mask) == 0) { |
296 | 0 | ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT); |
297 | 0 | return 0; |
298 | 0 | } |
299 | | |
300 | 4.06M | ok = ossl_read_der(ctx->provctx, cin, &der, &der_len); |
301 | 4.06M | if (!ok) |
302 | 626k | goto next; |
303 | | |
304 | 3.44M | ok = 0; /* Assume that we fail */ |
305 | | |
306 | 3.44M | ERR_set_mark(); |
307 | 3.44M | if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) { |
308 | 2.05M | derp = der; |
309 | 2.05M | if (ctx->desc->d2i_PKCS8 != NULL) { |
310 | 1.44M | key = ctx->desc->d2i_PKCS8(&derp, der_len, ctx); |
311 | 1.44M | if (ctx->flag_fatal) { |
312 | 0 | ERR_clear_last_mark(); |
313 | 0 | goto end; |
314 | 0 | } |
315 | 1.44M | } else if (ctx->desc->d2i_private_key != NULL) { |
316 | 609k | key = ctx->desc->d2i_private_key(NULL, &derp, der_len); |
317 | 609k | } |
318 | 2.05M | if (key == NULL && ctx->selection != 0) { |
319 | 1.36M | ERR_clear_last_mark(); |
320 | 1.36M | goto next; |
321 | 1.36M | } |
322 | 2.05M | } |
323 | 2.07M | if (key == NULL && (selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) { |
324 | 1.36M | derp = der; |
325 | 1.36M | if (ctx->desc->d2i_PUBKEY != NULL) |
326 | 1.29M | key = ctx->desc->d2i_PUBKEY(&derp, der_len, ctx); |
327 | 68.3k | else if (ctx->desc->d2i_public_key != NULL) |
328 | 68.3k | key = ctx->desc->d2i_public_key(NULL, &derp, der_len); |
329 | 1.36M | if (key == NULL && ctx->selection != 0) { |
330 | 406k | ERR_clear_last_mark(); |
331 | 406k | goto next; |
332 | 406k | } |
333 | 1.36M | } |
334 | 1.67M | if (key == NULL && (selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0) { |
335 | 173k | derp = der; |
336 | 173k | if (ctx->desc->d2i_key_params != NULL) |
337 | 173k | key = ctx->desc->d2i_key_params(NULL, &derp, der_len); |
338 | 173k | if (key == NULL && ctx->selection != 0) { |
339 | 0 | ERR_clear_last_mark(); |
340 | 0 | goto next; |
341 | 0 | } |
342 | 173k | } |
343 | 1.67M | if (key == NULL) |
344 | 1.08M | ERR_clear_last_mark(); |
345 | 589k | else |
346 | 589k | ERR_pop_to_mark(); |
347 | | |
348 | | /* |
349 | | * Last minute check to see if this was the correct type of key. This |
350 | | * should never lead to a fatal error, i.e. the decoding itself was |
351 | | * correct, it was just an unexpected key type. This is generally for |
352 | | * classes of key types that have subtle variants, like RSA-PSS keys as |
353 | | * opposed to plain RSA keys. |
354 | | */ |
355 | 1.67M | if (key != NULL |
356 | 1.67M | && ctx->desc->check_key != NULL |
357 | 1.67M | && !ctx->desc->check_key(key, ctx)) { |
358 | 10.0k | ctx->desc->free_key(key); |
359 | 10.0k | key = NULL; |
360 | 10.0k | } |
361 | | |
362 | 1.67M | if (key != NULL && ctx->desc->adjust_key != NULL) |
363 | 579k | ctx->desc->adjust_key(key, ctx); |
364 | | |
365 | 4.06M | next: |
366 | | /* |
367 | | * Indicated that we successfully decoded something, or not at all. |
368 | | * Ending up "empty handed" is not an error. |
369 | | */ |
370 | 4.06M | ok = 1; |
371 | | |
372 | | /* |
373 | | * We free memory here so it's not held up during the callback, because |
374 | | * we know the process is recursive and the allocated chunks of memory |
375 | | * add up. |
376 | | */ |
377 | 4.06M | OPENSSL_free(der); |
378 | 4.06M | der = NULL; |
379 | | |
380 | 4.06M | if (key != NULL) { |
381 | 579k | OSSL_PARAM params[4]; |
382 | 579k | int object_type = OSSL_OBJECT_PKEY; |
383 | | |
384 | 579k | params[0] = |
385 | 579k | OSSL_PARAM_construct_int(OSSL_OBJECT_PARAM_TYPE, &object_type); |
386 | | |
387 | 579k | #ifndef OPENSSL_NO_SM2 |
388 | 579k | if (strcmp(ctx->desc->keytype_name, "EC") == 0 |
389 | 579k | && (EC_KEY_get_flags(key) & EC_FLAG_SM2_RANGE) != 0) |
390 | 4 | params[1] = |
391 | 4 | OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_TYPE, |
392 | 4 | "SM2", 0); |
393 | 579k | else |
394 | 579k | #endif |
395 | 579k | params[1] = |
396 | 579k | OSSL_PARAM_construct_utf8_string(OSSL_OBJECT_PARAM_DATA_TYPE, |
397 | 579k | (char *)ctx->desc->keytype_name, |
398 | 579k | 0); |
399 | | /* The address of the key becomes the octet string */ |
400 | 579k | params[2] = |
401 | 579k | OSSL_PARAM_construct_octet_string(OSSL_OBJECT_PARAM_REFERENCE, |
402 | 579k | &key, sizeof(key)); |
403 | 579k | params[3] = OSSL_PARAM_construct_end(); |
404 | | |
405 | 579k | ok = data_cb(params, data_cbarg); |
406 | 579k | } |
407 | | |
408 | 4.06M | end: |
409 | 4.06M | ctx->desc->free_key(key); |
410 | 4.06M | OPENSSL_free(der); |
411 | | |
412 | 4.06M | return ok; |
413 | 4.06M | } |
414 | | |
415 | | static int der2key_export_object(void *vctx, |
416 | | const void *reference, size_t reference_sz, |
417 | | OSSL_CALLBACK *export_cb, void *export_cbarg) |
418 | 0 | { |
419 | 0 | struct der2key_ctx_st *ctx = vctx; |
420 | 0 | OSSL_FUNC_keymgmt_export_fn *export = |
421 | 0 | ossl_prov_get_keymgmt_export(ctx->desc->fns); |
422 | 0 | void *keydata; |
423 | |
|
424 | 0 | if (reference_sz == sizeof(keydata) && export != NULL) { |
425 | 0 | int selection = ctx->selection; |
426 | |
|
427 | 0 | if (selection == 0) |
428 | 0 | selection = OSSL_KEYMGMT_SELECT_ALL; |
429 | | /* The contents of the reference is the address to our object */ |
430 | 0 | keydata = *(void **)reference; |
431 | |
|
432 | 0 | return export(keydata, selection, export_cb, export_cbarg); |
433 | 0 | } |
434 | 0 | return 0; |
435 | 0 | } |
436 | | |
437 | | #define D2I_PUBKEY_NOCTX(n, f) \ |
438 | | static void * \ |
439 | | n##_d2i_PUBKEY(const unsigned char **der, long der_len, \ |
440 | | ossl_unused struct der2key_ctx_st *ctx) \ |
441 | 321k | { \ |
442 | 321k | return f(NULL, der, der_len); \ |
443 | 321k | } decode_der2key.c:dh_d2i_PUBKEY Line | Count | Source | 441 | 7.92k | { \ | 442 | 7.92k | return f(NULL, der, der_len); \ | 443 | 7.92k | } |
decode_der2key.c:dhx_d2i_PUBKEY Line | Count | Source | 441 | 21.4k | { \ | 442 | 21.4k | return f(NULL, der, der_len); \ | 443 | 21.4k | } |
decode_der2key.c:dsa_d2i_PUBKEY Line | Count | Source | 441 | 36.4k | { \ | 442 | 36.4k | return f(NULL, der, der_len); \ | 443 | 36.4k | } |
decode_der2key.c:ec_d2i_PUBKEY Line | Count | Source | 441 | 208k | { \ | 442 | 208k | return f(NULL, der, der_len); \ | 443 | 208k | } |
decode_der2key.c:x25519_d2i_PUBKEY Line | Count | Source | 441 | 12.3k | { \ | 442 | 12.3k | return f(NULL, der, der_len); \ | 443 | 12.3k | } |
decode_der2key.c:x448_d2i_PUBKEY Line | Count | Source | 441 | 11.6k | { \ | 442 | 11.6k | return f(NULL, der, der_len); \ | 443 | 11.6k | } |
decode_der2key.c:ed25519_d2i_PUBKEY Line | Count | Source | 441 | 11.6k | { \ | 442 | 11.6k | return f(NULL, der, der_len); \ | 443 | 11.6k | } |
decode_der2key.c:ed448_d2i_PUBKEY Line | Count | Source | 441 | 11.6k | { \ | 442 | 11.6k | return f(NULL, der, der_len); \ | 443 | 11.6k | } |
|
444 | | |
445 | | /* ---------------------------------------------------------------------- */ |
446 | | |
447 | | #ifndef OPENSSL_NO_DH |
448 | | # define dh_evp_type EVP_PKEY_DH |
449 | | # define dh_d2i_private_key NULL |
450 | | # define dh_d2i_public_key NULL |
451 | | # define dh_d2i_key_params (d2i_of_void *)d2i_DHparams |
452 | | # define dh_free (free_key_fn *)DH_free |
453 | | # define dh_check NULL |
454 | | |
455 | | static void *dh_d2i_PKCS8(const unsigned char **der, long der_len, |
456 | | struct der2key_ctx_st *ctx) |
457 | 164k | { |
458 | 164k | return der2key_decode_p8(der, der_len, ctx, |
459 | 164k | (key_from_pkcs8_t *)ossl_dh_key_from_pkcs8); |
460 | 164k | } |
461 | | |
462 | | D2I_PUBKEY_NOCTX(dh, ossl_d2i_DH_PUBKEY) |
463 | | D2I_PUBKEY_NOCTX(dhx, ossl_d2i_DHx_PUBKEY) |
464 | | |
465 | | static void dh_adjust(void *key, struct der2key_ctx_st *ctx) |
466 | 35.4k | { |
467 | 35.4k | ossl_dh_set0_libctx(key, PROV_LIBCTX_OF(ctx->provctx)); |
468 | 35.4k | } |
469 | | |
470 | | # define dhx_evp_type EVP_PKEY_DHX |
471 | | # define dhx_d2i_private_key NULL |
472 | | # define dhx_d2i_public_key NULL |
473 | | # define dhx_d2i_key_params (d2i_of_void *)d2i_DHxparams |
474 | | # define dhx_d2i_PKCS8 dh_d2i_PKCS8 |
475 | | # define dhx_free (free_key_fn *)DH_free |
476 | | # define dhx_check NULL |
477 | | # define dhx_adjust dh_adjust |
478 | | #endif |
479 | | |
480 | | /* ---------------------------------------------------------------------- */ |
481 | | |
482 | | #ifndef OPENSSL_NO_DSA |
483 | | # define dsa_evp_type EVP_PKEY_DSA |
484 | | # define dsa_d2i_private_key (d2i_of_void *)d2i_DSAPrivateKey |
485 | | # define dsa_d2i_public_key (d2i_of_void *)d2i_DSAPublicKey |
486 | | # define dsa_d2i_key_params (d2i_of_void *)d2i_DSAparams |
487 | | # define dsa_free (free_key_fn *)DSA_free |
488 | | # define dsa_check NULL |
489 | | |
490 | | static void *dsa_d2i_PKCS8(const unsigned char **der, long der_len, |
491 | | struct der2key_ctx_st *ctx) |
492 | 81.0k | { |
493 | 81.0k | return der2key_decode_p8(der, der_len, ctx, |
494 | 81.0k | (key_from_pkcs8_t *)ossl_dsa_key_from_pkcs8); |
495 | 81.0k | } |
496 | | |
497 | | D2I_PUBKEY_NOCTX(dsa, ossl_d2i_DSA_PUBKEY) |
498 | | |
499 | | static void dsa_adjust(void *key, struct der2key_ctx_st *ctx) |
500 | 104k | { |
501 | 104k | ossl_dsa_set0_libctx(key, PROV_LIBCTX_OF(ctx->provctx)); |
502 | 104k | } |
503 | | #endif |
504 | | |
505 | | /* ---------------------------------------------------------------------- */ |
506 | | |
507 | | #ifndef OPENSSL_NO_EC |
508 | | # define ec_evp_type EVP_PKEY_EC |
509 | | # define ec_d2i_private_key (d2i_of_void *)d2i_ECPrivateKey |
510 | | # define ec_d2i_public_key NULL |
511 | | # define ec_d2i_key_params (d2i_of_void *)d2i_ECParameters |
512 | | # define ec_free (free_key_fn *)EC_KEY_free |
513 | | |
514 | | static void *ec_d2i_PKCS8(const unsigned char **der, long der_len, |
515 | | struct der2key_ctx_st *ctx) |
516 | 81.7k | { |
517 | 81.7k | return der2key_decode_p8(der, der_len, ctx, |
518 | 81.7k | (key_from_pkcs8_t *)ossl_ec_key_from_pkcs8); |
519 | 81.7k | } |
520 | | |
521 | | D2I_PUBKEY_NOCTX(ec, d2i_EC_PUBKEY) |
522 | | |
523 | | static int ec_check(void *key, struct der2key_ctx_st *ctx) |
524 | 303k | { |
525 | | /* We're trying to be clever by comparing two truths */ |
526 | 303k | int ret = 0; |
527 | 303k | int sm2 = (EC_KEY_get_flags(key) & EC_FLAG_SM2_RANGE) != 0; |
528 | | |
529 | 303k | if (sm2) |
530 | 6.01k | ret = ctx->desc->evp_type == EVP_PKEY_SM2 |
531 | 6.01k | || ctx->desc->evp_type == NID_X9_62_id_ecPublicKey; |
532 | 297k | else |
533 | 297k | ret = ctx->desc->evp_type != EVP_PKEY_SM2; |
534 | | |
535 | 303k | return ret; |
536 | 303k | } |
537 | | |
538 | | static void ec_adjust(void *key, struct der2key_ctx_st *ctx) |
539 | 296k | { |
540 | 296k | ossl_ec_key_set0_libctx(key, PROV_LIBCTX_OF(ctx->provctx)); |
541 | 296k | } |
542 | | |
543 | | # ifndef OPENSSL_NO_ECX |
544 | | /* |
545 | | * ED25519, ED448, X25519, X448 only implement PKCS#8 and SubjectPublicKeyInfo, |
546 | | * so no d2i functions to be had. |
547 | | */ |
548 | | |
549 | | static void *ecx_d2i_PKCS8(const unsigned char **der, long der_len, |
550 | | struct der2key_ctx_st *ctx) |
551 | 378k | { |
552 | 378k | return der2key_decode_p8(der, der_len, ctx, |
553 | 378k | (key_from_pkcs8_t *)ossl_ecx_key_from_pkcs8); |
554 | 378k | } |
555 | | |
556 | | D2I_PUBKEY_NOCTX(ed25519, ossl_d2i_ED25519_PUBKEY) |
557 | | D2I_PUBKEY_NOCTX(ed448, ossl_d2i_ED448_PUBKEY) |
558 | | D2I_PUBKEY_NOCTX(x25519, ossl_d2i_X25519_PUBKEY) |
559 | | D2I_PUBKEY_NOCTX(x448, ossl_d2i_X448_PUBKEY) |
560 | | |
561 | | static void ecx_key_adjust(void *key, struct der2key_ctx_st *ctx) |
562 | 3.47k | { |
563 | 3.47k | ossl_ecx_key_set0_libctx(key, PROV_LIBCTX_OF(ctx->provctx)); |
564 | 3.47k | } |
565 | | |
566 | | # define ed25519_evp_type EVP_PKEY_ED25519 |
567 | | # define ed25519_d2i_private_key NULL |
568 | | # define ed25519_d2i_public_key NULL |
569 | | # define ed25519_d2i_key_params NULL |
570 | | # define ed25519_d2i_PKCS8 ecx_d2i_PKCS8 |
571 | | # define ed25519_free (free_key_fn *)ossl_ecx_key_free |
572 | | # define ed25519_check NULL |
573 | | # define ed25519_adjust ecx_key_adjust |
574 | | |
575 | | # define ed448_evp_type EVP_PKEY_ED448 |
576 | | # define ed448_d2i_private_key NULL |
577 | | # define ed448_d2i_public_key NULL |
578 | | # define ed448_d2i_key_params NULL |
579 | | # define ed448_d2i_PKCS8 ecx_d2i_PKCS8 |
580 | | # define ed448_free (free_key_fn *)ossl_ecx_key_free |
581 | | # define ed448_check NULL |
582 | | # define ed448_adjust ecx_key_adjust |
583 | | |
584 | | # define x25519_evp_type EVP_PKEY_X25519 |
585 | | # define x25519_d2i_private_key NULL |
586 | | # define x25519_d2i_public_key NULL |
587 | | # define x25519_d2i_key_params NULL |
588 | | # define x25519_d2i_PKCS8 ecx_d2i_PKCS8 |
589 | | # define x25519_free (free_key_fn *)ossl_ecx_key_free |
590 | | # define x25519_check NULL |
591 | | # define x25519_adjust ecx_key_adjust |
592 | | |
593 | | # define x448_evp_type EVP_PKEY_X448 |
594 | | # define x448_d2i_private_key NULL |
595 | | # define x448_d2i_public_key NULL |
596 | | # define x448_d2i_key_params NULL |
597 | | # define x448_d2i_PKCS8 ecx_d2i_PKCS8 |
598 | | # define x448_free (free_key_fn *)ossl_ecx_key_free |
599 | | # define x448_check NULL |
600 | | # define x448_adjust ecx_key_adjust |
601 | | # endif /* OPENSSL_NO_ECX */ |
602 | | |
603 | | # ifndef OPENSSL_NO_SM2 |
604 | | # define sm2_evp_type EVP_PKEY_SM2 |
605 | | # define sm2_d2i_private_key (d2i_of_void *)d2i_ECPrivateKey |
606 | | # define sm2_d2i_public_key NULL |
607 | | # define sm2_d2i_key_params (d2i_of_void *)d2i_ECParameters |
608 | | # define sm2_d2i_PUBKEY ec_d2i_PUBKEY |
609 | | # define sm2_free (free_key_fn *)EC_KEY_free |
610 | | # define sm2_check ec_check |
611 | | # define sm2_adjust ec_adjust |
612 | | |
613 | | static void *sm2_d2i_PKCS8(const unsigned char **der, long der_len, |
614 | | struct der2key_ctx_st *ctx) |
615 | 95.1k | { |
616 | 95.1k | return der2key_decode_p8(der, der_len, ctx, |
617 | 95.1k | (key_from_pkcs8_t *)ossl_ec_key_from_pkcs8); |
618 | 95.1k | } |
619 | | # endif |
620 | | |
621 | | #endif |
622 | | |
623 | | /* ---------------------------------------------------------------------- */ |
624 | | |
625 | | #ifndef OPENSSL_NO_ML_KEM |
626 | | static void * |
627 | | ml_kem_d2i_PKCS8(const uint8_t **der, long der_len, struct der2key_ctx_st *ctx) |
628 | 79.5k | { |
629 | 79.5k | ML_KEM_KEY *key; |
630 | | |
631 | 79.5k | key = ossl_ml_kem_d2i_PKCS8(*der, der_len, ctx->desc->evp_type, |
632 | 79.5k | ctx->provctx, ctx->propq); |
633 | 79.5k | if (key != NULL) |
634 | 0 | *der += der_len; |
635 | 79.5k | return key; |
636 | 79.5k | } |
637 | | |
638 | | static ossl_inline void * |
639 | | ml_kem_d2i_PUBKEY(const uint8_t **der, long der_len, |
640 | | struct der2key_ctx_st *ctx) |
641 | 35.2k | { |
642 | 35.2k | ML_KEM_KEY *key; |
643 | | |
644 | 35.2k | key = ossl_ml_kem_d2i_PUBKEY(*der, der_len, ctx->desc->evp_type, |
645 | 35.2k | ctx->provctx, ctx->propq); |
646 | 35.2k | if (key != NULL) |
647 | 160 | *der += der_len; |
648 | 35.2k | return key; |
649 | 35.2k | } |
650 | | |
651 | | # define ml_kem_512_evp_type EVP_PKEY_ML_KEM_512 |
652 | | # define ml_kem_512_d2i_private_key NULL |
653 | | # define ml_kem_512_d2i_public_key NULL |
654 | | # define ml_kem_512_d2i_key_params NULL |
655 | | # define ml_kem_512_d2i_PUBKEY ml_kem_d2i_PUBKEY |
656 | | # define ml_kem_512_d2i_PKCS8 ml_kem_d2i_PKCS8 |
657 | | # define ml_kem_512_free (free_key_fn *)ossl_ml_kem_key_free |
658 | | # define ml_kem_512_check NULL |
659 | | # define ml_kem_512_adjust NULL |
660 | | |
661 | | # define ml_kem_768_evp_type EVP_PKEY_ML_KEM_768 |
662 | | # define ml_kem_768_d2i_private_key NULL |
663 | | # define ml_kem_768_d2i_public_key NULL |
664 | | # define ml_kem_768_d2i_key_params NULL |
665 | | # define ml_kem_768_d2i_PUBKEY ml_kem_d2i_PUBKEY |
666 | | # define ml_kem_768_d2i_PKCS8 ml_kem_d2i_PKCS8 |
667 | | # define ml_kem_768_free (free_key_fn *)ossl_ml_kem_key_free |
668 | | # define ml_kem_768_check NULL |
669 | | # define ml_kem_768_adjust NULL |
670 | | |
671 | | # define ml_kem_1024_evp_type EVP_PKEY_ML_KEM_1024 |
672 | | # define ml_kem_1024_d2i_private_key NULL |
673 | | # define ml_kem_1024_d2i_public_key NULL |
674 | | # define ml_kem_1024_d2i_PUBKEY ml_kem_d2i_PUBKEY |
675 | | # define ml_kem_1024_d2i_PKCS8 ml_kem_d2i_PKCS8 |
676 | | # define ml_kem_1024_d2i_key_params NULL |
677 | | # define ml_kem_1024_free (free_key_fn *)ossl_ml_kem_key_free |
678 | | # define ml_kem_1024_check NULL |
679 | | # define ml_kem_1024_adjust NULL |
680 | | |
681 | | #endif |
682 | | |
683 | | #ifndef OPENSSL_NO_SLH_DSA |
684 | | static void * |
685 | | slh_dsa_d2i_PKCS8(const uint8_t **der, long der_len, struct der2key_ctx_st *ctx) |
686 | 318k | { |
687 | 318k | SLH_DSA_KEY *key = NULL, *ret = NULL; |
688 | 318k | OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(ctx->provctx); |
689 | 318k | PKCS8_PRIV_KEY_INFO *p8inf = NULL; |
690 | 318k | const unsigned char *p; |
691 | 318k | const X509_ALGOR *alg = NULL; |
692 | 318k | int plen, ptype; |
693 | | |
694 | 318k | if ((p8inf = d2i_PKCS8_PRIV_KEY_INFO(NULL, der, der_len)) == NULL |
695 | 318k | || !PKCS8_pkey_get0(NULL, &p, &plen, &alg, p8inf)) |
696 | 317k | goto end; |
697 | | |
698 | | /* Algorithm parameters must be absent. */ |
699 | 463 | if ((X509_ALGOR_get0(NULL, &ptype, NULL, alg), ptype != V_ASN1_UNDEF)) { |
700 | 330 | ERR_raise_data(ERR_LIB_PROV, PROV_R_UNEXPECTED_KEY_PARAMETERS, |
701 | 330 | "unexpected parameters with a PKCS#8 %s private key", |
702 | 330 | ctx->desc->keytype_name); |
703 | 330 | goto end; |
704 | 330 | } |
705 | 133 | if (OBJ_obj2nid(alg->algorithm) != ctx->desc->evp_type) |
706 | 132 | goto end; |
707 | 1 | if ((key = ossl_slh_dsa_key_new(libctx, ctx->propq, |
708 | 1 | ctx->desc->keytype_name)) == NULL) |
709 | 0 | goto end; |
710 | | |
711 | 1 | if (!ossl_slh_dsa_set_priv(key, p, plen)) |
712 | 1 | goto end; |
713 | 0 | ret = key; |
714 | 318k | end: |
715 | 318k | PKCS8_PRIV_KEY_INFO_free(p8inf); |
716 | 318k | if (ret == NULL) |
717 | 318k | ossl_slh_dsa_key_free(key); |
718 | 318k | return ret; |
719 | 0 | } |
720 | | |
721 | | static ossl_inline void *slh_dsa_d2i_PUBKEY(const uint8_t **der, long der_len, |
722 | | struct der2key_ctx_st *ctx) |
723 | 145k | { |
724 | 145k | int ok = 0; |
725 | 145k | OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(ctx->provctx); |
726 | 145k | SLH_DSA_KEY *ret = NULL; |
727 | 145k | BARE_PUBKEY *spki = NULL; |
728 | 145k | const uint8_t *end = *der; |
729 | 145k | size_t len; |
730 | | |
731 | 145k | ret = ossl_slh_dsa_key_new(libctx, ctx->propq, ctx->desc->keytype_name); |
732 | 145k | if (ret == NULL) |
733 | 0 | return NULL; |
734 | 145k | len = ossl_slh_dsa_key_get_pub_len(ret); |
735 | | |
736 | | /*- |
737 | | * The DER ASN.1 encoding of SLH-DSA public keys prepends 18 bytes to the |
738 | | * encoded public key (since the largest public key size is 64 bytes): |
739 | | * |
740 | | * - 2 byte outer sequence tag and length |
741 | | * - 2 byte algorithm sequence tag and length |
742 | | * - 2 byte algorithm OID tag and length |
743 | | * - 9 byte algorithm OID |
744 | | * - 2 byte bit string tag and length |
745 | | * - 1 bitstring lead byte |
746 | | * |
747 | | * Check that we have the right OID, the bit string has no "bits left" and |
748 | | * that we consume all the input exactly. |
749 | | */ |
750 | 145k | if (der_len != 18 + (long)len) { |
751 | 143k | ERR_raise_data(ERR_LIB_PROV, PROV_R_BAD_ENCODING, |
752 | 143k | "unexpected %s public key length: %ld != %ld", |
753 | 143k | ctx->desc->keytype_name, der_len, |
754 | 143k | 18 + (long)len); |
755 | 143k | goto err; |
756 | 143k | } |
757 | | |
758 | 1.80k | if ((spki = OPENSSL_zalloc(sizeof(*spki))) == NULL) |
759 | 0 | goto err; |
760 | | |
761 | | /* The spki storage is freed on error */ |
762 | 1.80k | if (ASN1_item_d2i_ex((ASN1_VALUE **)&spki, &end, der_len, |
763 | 1.80k | ASN1_ITEM_rptr(BARE_PUBKEY), NULL, NULL) == NULL) { |
764 | 1.79k | ERR_raise_data(ERR_LIB_PROV, PROV_R_BAD_ENCODING, |
765 | 1.79k | "malformed %s public key ASN.1 encoding", |
766 | 1.79k | ossl_slh_dsa_key_get_name(ret)); |
767 | 1.79k | goto err; |
768 | 1.79k | } |
769 | | |
770 | | /* The spki structure now owns some memory */ |
771 | 8 | if ((spki->pubkey->flags & 0x7) != 0 || end != *der + der_len) { |
772 | 8 | ERR_raise_data(ERR_LIB_PROV, PROV_R_BAD_ENCODING, |
773 | 8 | "malformed %s public key ASN.1 encoding", |
774 | 8 | ossl_slh_dsa_key_get_name(ret)); |
775 | 8 | goto err; |
776 | 8 | } |
777 | 0 | if (OBJ_cmp(OBJ_nid2obj(ctx->desc->evp_type), spki->algor.oid) != 0) { |
778 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_BAD_ENCODING, |
779 | 0 | "unexpected algorithm OID for an %s public key", |
780 | 0 | ossl_slh_dsa_key_get_name(ret)); |
781 | 0 | goto err; |
782 | 0 | } |
783 | | |
784 | 0 | if (!ossl_slh_dsa_set_pub(ret, spki->pubkey->data, spki->pubkey->length)) { |
785 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_BAD_ENCODING, |
786 | 0 | "failed to parse %s public key from the input data", |
787 | 0 | ossl_slh_dsa_key_get_name(ret)); |
788 | 0 | goto err; |
789 | 0 | } |
790 | 0 | ok = 1; |
791 | 145k | err: |
792 | 145k | if (spki != NULL) { |
793 | 8 | ASN1_OBJECT_free(spki->algor.oid); |
794 | 8 | ASN1_BIT_STRING_free(spki->pubkey); |
795 | 8 | OPENSSL_free(spki); |
796 | 8 | } |
797 | 145k | if (!ok) { |
798 | 145k | ossl_slh_dsa_key_free(ret); |
799 | 145k | ret = NULL; |
800 | 145k | } |
801 | 145k | return ret; |
802 | 0 | } |
803 | | |
804 | | # define slh_dsa_sha2_128s_evp_type EVP_PKEY_SLH_DSA_SHA2_128S |
805 | | # define slh_dsa_sha2_128s_d2i_private_key NULL |
806 | | # define slh_dsa_sha2_128s_d2i_public_key NULL |
807 | | # define slh_dsa_sha2_128s_d2i_key_params NULL |
808 | | # define slh_dsa_sha2_128s_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
809 | | # define slh_dsa_sha2_128s_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
810 | | # define slh_dsa_sha2_128s_free (free_key_fn *)ossl_slh_dsa_key_free |
811 | | # define slh_dsa_sha2_128s_check NULL |
812 | | # define slh_dsa_sha2_128s_adjust NULL |
813 | | |
814 | | # define slh_dsa_sha2_128f_evp_type EVP_PKEY_SLH_DSA_SHA2_128F |
815 | | # define slh_dsa_sha2_128f_d2i_private_key NULL |
816 | | # define slh_dsa_sha2_128f_d2i_public_key NULL |
817 | | # define slh_dsa_sha2_128f_d2i_key_params NULL |
818 | | # define slh_dsa_sha2_128f_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
819 | | # define slh_dsa_sha2_128f_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
820 | | # define slh_dsa_sha2_128f_free (free_key_fn *)ossl_slh_dsa_key_free |
821 | | # define slh_dsa_sha2_128f_check NULL |
822 | | # define slh_dsa_sha2_128f_adjust NULL |
823 | | |
824 | | # define slh_dsa_sha2_192s_evp_type EVP_PKEY_SLH_DSA_SHA2_192S |
825 | | # define slh_dsa_sha2_192s_d2i_private_key NULL |
826 | | # define slh_dsa_sha2_192s_d2i_public_key NULL |
827 | | # define slh_dsa_sha2_192s_d2i_key_params NULL |
828 | | # define slh_dsa_sha2_192s_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
829 | | # define slh_dsa_sha2_192s_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
830 | | # define slh_dsa_sha2_192s_free (free_key_fn *)ossl_slh_dsa_key_free |
831 | | # define slh_dsa_sha2_192s_check NULL |
832 | | # define slh_dsa_sha2_192s_adjust NULL |
833 | | |
834 | | # define slh_dsa_sha2_192f_evp_type EVP_PKEY_SLH_DSA_SHA2_192F |
835 | | # define slh_dsa_sha2_192f_d2i_private_key NULL |
836 | | # define slh_dsa_sha2_192f_d2i_public_key NULL |
837 | | # define slh_dsa_sha2_192f_d2i_key_params NULL |
838 | | # define slh_dsa_sha2_192f_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
839 | | # define slh_dsa_sha2_192f_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
840 | | # define slh_dsa_sha2_192f_free (free_key_fn *)ossl_slh_dsa_key_free |
841 | | # define slh_dsa_sha2_192f_check NULL |
842 | | # define slh_dsa_sha2_192f_adjust NULL |
843 | | |
844 | | # define slh_dsa_sha2_256s_evp_type EVP_PKEY_SLH_DSA_SHA2_256S |
845 | | # define slh_dsa_sha2_256s_d2i_private_key NULL |
846 | | # define slh_dsa_sha2_256s_d2i_public_key NULL |
847 | | # define slh_dsa_sha2_256s_d2i_key_params NULL |
848 | | # define slh_dsa_sha2_256s_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
849 | | # define slh_dsa_sha2_256s_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
850 | | # define slh_dsa_sha2_256s_free (free_key_fn *)ossl_slh_dsa_key_free |
851 | | # define slh_dsa_sha2_256s_check NULL |
852 | | # define slh_dsa_sha2_256s_adjust NULL |
853 | | |
854 | | # define slh_dsa_sha2_256f_evp_type EVP_PKEY_SLH_DSA_SHA2_256F |
855 | | # define slh_dsa_sha2_256f_d2i_private_key NULL |
856 | | # define slh_dsa_sha2_256f_d2i_public_key NULL |
857 | | # define slh_dsa_sha2_256f_d2i_key_params NULL |
858 | | # define slh_dsa_sha2_256f_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
859 | | # define slh_dsa_sha2_256f_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
860 | | # define slh_dsa_sha2_256f_free (free_key_fn *)ossl_slh_dsa_key_free |
861 | | # define slh_dsa_sha2_256f_check NULL |
862 | | # define slh_dsa_sha2_256f_adjust NULL |
863 | | |
864 | | # define slh_dsa_shake_128s_evp_type EVP_PKEY_SLH_DSA_SHAKE_128S |
865 | | # define slh_dsa_shake_128s_d2i_private_key NULL |
866 | | # define slh_dsa_shake_128s_d2i_public_key NULL |
867 | | # define slh_dsa_shake_128s_d2i_key_params NULL |
868 | | # define slh_dsa_shake_128s_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
869 | | # define slh_dsa_shake_128s_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
870 | | # define slh_dsa_shake_128s_free (free_key_fn *)ossl_slh_dsa_key_free |
871 | | # define slh_dsa_shake_128s_check NULL |
872 | | # define slh_dsa_shake_128s_adjust NULL |
873 | | |
874 | | # define slh_dsa_shake_128f_evp_type EVP_PKEY_SLH_DSA_SHAKE_128F |
875 | | # define slh_dsa_shake_128f_d2i_private_key NULL |
876 | | # define slh_dsa_shake_128f_d2i_public_key NULL |
877 | | # define slh_dsa_shake_128f_d2i_key_params NULL |
878 | | # define slh_dsa_shake_128f_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
879 | | # define slh_dsa_shake_128f_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
880 | | # define slh_dsa_shake_128f_free (free_key_fn *)ossl_slh_dsa_key_free |
881 | | # define slh_dsa_shake_128f_check NULL |
882 | | # define slh_dsa_shake_128f_adjust NULL |
883 | | |
884 | | # define slh_dsa_shake_192s_evp_type EVP_PKEY_SLH_DSA_SHAKE_192S |
885 | | # define slh_dsa_shake_192s_d2i_private_key NULL |
886 | | # define slh_dsa_shake_192s_d2i_public_key NULL |
887 | | # define slh_dsa_shake_192s_d2i_key_params NULL |
888 | | # define slh_dsa_shake_192s_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
889 | | # define slh_dsa_shake_192s_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
890 | | # define slh_dsa_shake_192s_free (free_key_fn *)ossl_slh_dsa_key_free |
891 | | # define slh_dsa_shake_192s_check NULL |
892 | | # define slh_dsa_shake_192s_adjust NULL |
893 | | |
894 | | # define slh_dsa_shake_192f_evp_type EVP_PKEY_SLH_DSA_SHAKE_192F |
895 | | # define slh_dsa_shake_192f_d2i_private_key NULL |
896 | | # define slh_dsa_shake_192f_d2i_public_key NULL |
897 | | # define slh_dsa_shake_192f_d2i_key_params NULL |
898 | | # define slh_dsa_shake_192f_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
899 | | # define slh_dsa_shake_192f_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
900 | | # define slh_dsa_shake_192f_free (free_key_fn *)ossl_slh_dsa_key_free |
901 | | # define slh_dsa_shake_192f_check NULL |
902 | | # define slh_dsa_shake_192f_adjust NULL |
903 | | |
904 | | # define slh_dsa_shake_256s_evp_type EVP_PKEY_SLH_DSA_SHAKE_256S |
905 | | # define slh_dsa_shake_256s_d2i_private_key NULL |
906 | | # define slh_dsa_shake_256s_d2i_public_key NULL |
907 | | # define slh_dsa_shake_256s_d2i_key_params NULL |
908 | | # define slh_dsa_shake_256s_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
909 | | # define slh_dsa_shake_256s_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
910 | | # define slh_dsa_shake_256s_free (free_key_fn *)ossl_slh_dsa_key_free |
911 | | # define slh_dsa_shake_256s_check NULL |
912 | | # define slh_dsa_shake_256s_adjust NULL |
913 | | |
914 | | # define slh_dsa_shake_256f_evp_type EVP_PKEY_SLH_DSA_SHAKE_256F |
915 | | # define slh_dsa_shake_256f_d2i_private_key NULL |
916 | | # define slh_dsa_shake_256f_d2i_public_key NULL |
917 | | # define slh_dsa_shake_256f_d2i_key_params NULL |
918 | | # define slh_dsa_shake_256f_d2i_PKCS8 slh_dsa_d2i_PKCS8 |
919 | | # define slh_dsa_shake_256f_d2i_PUBKEY slh_dsa_d2i_PUBKEY |
920 | | # define slh_dsa_shake_256f_free (free_key_fn *)ossl_slh_dsa_key_free |
921 | | # define slh_dsa_shake_256f_check NULL |
922 | | # define slh_dsa_shake_256f_adjust NULL |
923 | | #endif /* OPENSSL_NO_SLH_DSA */ |
924 | | |
925 | | /* ---------------------------------------------------------------------- */ |
926 | | |
927 | | #define rsa_evp_type EVP_PKEY_RSA |
928 | | #define rsa_d2i_private_key (d2i_of_void *)d2i_RSAPrivateKey |
929 | | #define rsa_d2i_public_key (d2i_of_void *)d2i_RSAPublicKey |
930 | | #define rsa_d2i_key_params NULL |
931 | | #define rsa_free (free_key_fn *)RSA_free |
932 | | |
933 | | static void *rsa_d2i_PKCS8(const unsigned char **der, long der_len, |
934 | | struct der2key_ctx_st *ctx) |
935 | 163k | { |
936 | 163k | return der2key_decode_p8(der, der_len, ctx, |
937 | 163k | (key_from_pkcs8_t *)ossl_rsa_key_from_pkcs8); |
938 | 163k | } |
939 | | |
940 | | static void * |
941 | | rsa_d2i_PUBKEY(const unsigned char **der, long der_len, |
942 | | ossl_unused struct der2key_ctx_st *ctx) |
943 | 58.3k | { |
944 | 58.3k | return d2i_RSA_PUBKEY(NULL, der, der_len); |
945 | 58.3k | } |
946 | | |
947 | | static int rsa_check(void *key, struct der2key_ctx_st *ctx) |
948 | 72.1k | { |
949 | 72.1k | int valid; |
950 | | |
951 | 72.1k | switch (RSA_test_flags(key, RSA_FLAG_TYPE_MASK)) { |
952 | 67.6k | case RSA_FLAG_TYPE_RSA: |
953 | 67.6k | valid = (ctx->desc->evp_type == EVP_PKEY_RSA); |
954 | 67.6k | break; |
955 | 4.52k | case RSA_FLAG_TYPE_RSASSAPSS: |
956 | 4.52k | valid = (ctx->desc->evp_type == EVP_PKEY_RSA_PSS); |
957 | 4.52k | break; |
958 | 0 | default: |
959 | | /* Currently unsupported RSA key type */ |
960 | 0 | valid = 0; |
961 | 72.1k | } |
962 | | |
963 | 72.1k | valid = (valid && ossl_rsa_check_factors(key)); |
964 | | |
965 | 72.1k | return valid; |
966 | 72.1k | } |
967 | | |
968 | | static void rsa_adjust(void *key, struct der2key_ctx_st *ctx) |
969 | 139k | { |
970 | 139k | ossl_rsa_set0_libctx(key, PROV_LIBCTX_OF(ctx->provctx)); |
971 | 139k | } |
972 | | |
973 | | #define rsapss_evp_type EVP_PKEY_RSA_PSS |
974 | | #define rsapss_d2i_private_key (d2i_of_void *)d2i_RSAPrivateKey |
975 | | #define rsapss_d2i_public_key (d2i_of_void *)d2i_RSAPublicKey |
976 | | #define rsapss_d2i_key_params NULL |
977 | | #define rsapss_d2i_PKCS8 rsa_d2i_PKCS8 |
978 | | #define rsapss_d2i_PUBKEY rsa_d2i_PUBKEY |
979 | | #define rsapss_free (free_key_fn *)RSA_free |
980 | | #define rsapss_check rsa_check |
981 | | #define rsapss_adjust rsa_adjust |
982 | | |
983 | | /* ---------------------------------------------------------------------- */ |
984 | | |
985 | | #ifndef OPENSSL_NO_ML_DSA |
986 | | static void * |
987 | | ml_dsa_d2i_PKCS8(const uint8_t **der, long der_len, struct der2key_ctx_st *ctx) |
988 | 79.5k | { |
989 | 79.5k | ML_DSA_KEY *key; |
990 | | |
991 | 79.5k | key = ossl_ml_dsa_d2i_PKCS8(*der, der_len, ctx->desc->evp_type, |
992 | 79.5k | ctx->provctx, ctx->propq); |
993 | 79.5k | if (key != NULL) |
994 | 0 | *der += der_len; |
995 | 79.5k | return key; |
996 | 79.5k | } |
997 | | |
998 | | static ossl_inline void * ml_dsa_d2i_PUBKEY(const uint8_t **der, long der_len, |
999 | | struct der2key_ctx_st *ctx) |
1000 | 35.6k | { |
1001 | 35.6k | ML_DSA_KEY *key; |
1002 | | |
1003 | 35.6k | key = ossl_ml_dsa_d2i_PUBKEY(*der, der_len, ctx->desc->evp_type, |
1004 | 35.6k | ctx->provctx, ctx->propq); |
1005 | 35.6k | if (key != NULL) |
1006 | 16 | *der += der_len; |
1007 | 35.6k | return key; |
1008 | 35.6k | } |
1009 | | |
1010 | | # define ml_dsa_44_evp_type EVP_PKEY_ML_DSA_44 |
1011 | | # define ml_dsa_44_d2i_private_key NULL |
1012 | | # define ml_dsa_44_d2i_public_key NULL |
1013 | | # define ml_dsa_44_d2i_key_params NULL |
1014 | | # define ml_dsa_44_d2i_PUBKEY ml_dsa_d2i_PUBKEY |
1015 | | # define ml_dsa_44_d2i_PKCS8 ml_dsa_d2i_PKCS8 |
1016 | | # define ml_dsa_44_free (free_key_fn *)ossl_ml_dsa_key_free |
1017 | | # define ml_dsa_44_check NULL |
1018 | | # define ml_dsa_44_adjust NULL |
1019 | | |
1020 | | # define ml_dsa_65_evp_type EVP_PKEY_ML_DSA_65 |
1021 | | # define ml_dsa_65_d2i_private_key NULL |
1022 | | # define ml_dsa_65_d2i_public_key NULL |
1023 | | # define ml_dsa_65_d2i_key_params NULL |
1024 | | # define ml_dsa_65_d2i_PUBKEY ml_dsa_d2i_PUBKEY |
1025 | | # define ml_dsa_65_d2i_PKCS8 ml_dsa_d2i_PKCS8 |
1026 | | # define ml_dsa_65_free (free_key_fn *)ossl_ml_dsa_key_free |
1027 | | # define ml_dsa_65_check NULL |
1028 | | # define ml_dsa_65_adjust NULL |
1029 | | |
1030 | | # define ml_dsa_87_evp_type EVP_PKEY_ML_DSA_87 |
1031 | | # define ml_dsa_87_d2i_private_key NULL |
1032 | | # define ml_dsa_87_d2i_public_key NULL |
1033 | | # define ml_dsa_87_d2i_PUBKEY ml_dsa_d2i_PUBKEY |
1034 | | # define ml_dsa_87_d2i_PKCS8 ml_dsa_d2i_PKCS8 |
1035 | | # define ml_dsa_87_d2i_key_params NULL |
1036 | | # define ml_dsa_87_free (free_key_fn *)ossl_ml_dsa_key_free |
1037 | | # define ml_dsa_87_check NULL |
1038 | | # define ml_dsa_87_adjust NULL |
1039 | | |
1040 | | #endif |
1041 | | |
1042 | | /* ---------------------------------------------------------------------- */ |
1043 | | |
1044 | | /* |
1045 | | * The DO_ macros help define the selection mask and the method functions |
1046 | | * for each kind of object we want to decode. |
1047 | | */ |
1048 | | #define DO_type_specific_keypair(keytype) \ |
1049 | | "type-specific", keytype##_evp_type, \ |
1050 | | ( OSSL_KEYMGMT_SELECT_KEYPAIR ), \ |
1051 | | keytype##_d2i_private_key, \ |
1052 | | keytype##_d2i_public_key, \ |
1053 | | NULL, \ |
1054 | | NULL, \ |
1055 | | NULL, \ |
1056 | | keytype##_check, \ |
1057 | | keytype##_adjust, \ |
1058 | | keytype##_free |
1059 | | |
1060 | | #define DO_type_specific_pub(keytype) \ |
1061 | | "type-specific", keytype##_evp_type, \ |
1062 | | ( OSSL_KEYMGMT_SELECT_PUBLIC_KEY ), \ |
1063 | | NULL, \ |
1064 | | keytype##_d2i_public_key, \ |
1065 | | NULL, \ |
1066 | | NULL, \ |
1067 | | NULL, \ |
1068 | | keytype##_check, \ |
1069 | | keytype##_adjust, \ |
1070 | | keytype##_free |
1071 | | |
1072 | | #define DO_type_specific_priv(keytype) \ |
1073 | | "type-specific", keytype##_evp_type, \ |
1074 | | ( OSSL_KEYMGMT_SELECT_PRIVATE_KEY ), \ |
1075 | | keytype##_d2i_private_key, \ |
1076 | | NULL, \ |
1077 | | NULL, \ |
1078 | | NULL, \ |
1079 | | NULL, \ |
1080 | | keytype##_check, \ |
1081 | | keytype##_adjust, \ |
1082 | | keytype##_free |
1083 | | |
1084 | | #define DO_type_specific_params(keytype) \ |
1085 | | "type-specific", keytype##_evp_type, \ |
1086 | | ( OSSL_KEYMGMT_SELECT_ALL_PARAMETERS ), \ |
1087 | | NULL, \ |
1088 | | NULL, \ |
1089 | | keytype##_d2i_key_params, \ |
1090 | | NULL, \ |
1091 | | NULL, \ |
1092 | | keytype##_check, \ |
1093 | | keytype##_adjust, \ |
1094 | | keytype##_free |
1095 | | |
1096 | | #define DO_type_specific(keytype) \ |
1097 | | "type-specific", keytype##_evp_type, \ |
1098 | | ( OSSL_KEYMGMT_SELECT_ALL ), \ |
1099 | | keytype##_d2i_private_key, \ |
1100 | | keytype##_d2i_public_key, \ |
1101 | | keytype##_d2i_key_params, \ |
1102 | | NULL, \ |
1103 | | NULL, \ |
1104 | | keytype##_check, \ |
1105 | | keytype##_adjust, \ |
1106 | | keytype##_free |
1107 | | |
1108 | | #define DO_type_specific_no_pub(keytype) \ |
1109 | | "type-specific", keytype##_evp_type, \ |
1110 | | ( OSSL_KEYMGMT_SELECT_PRIVATE_KEY \ |
1111 | | | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS ), \ |
1112 | | keytype##_d2i_private_key, \ |
1113 | | NULL, \ |
1114 | | keytype##_d2i_key_params, \ |
1115 | | NULL, \ |
1116 | | NULL, \ |
1117 | | keytype##_check, \ |
1118 | | keytype##_adjust, \ |
1119 | | keytype##_free |
1120 | | |
1121 | | #define DO_PrivateKeyInfo(keytype) \ |
1122 | | "PrivateKeyInfo", keytype##_evp_type, \ |
1123 | | ( OSSL_KEYMGMT_SELECT_PRIVATE_KEY ), \ |
1124 | | NULL, \ |
1125 | | NULL, \ |
1126 | | NULL, \ |
1127 | | keytype##_d2i_PKCS8, \ |
1128 | | NULL, \ |
1129 | | keytype##_check, \ |
1130 | | keytype##_adjust, \ |
1131 | | keytype##_free |
1132 | | |
1133 | | #define DO_SubjectPublicKeyInfo(keytype) \ |
1134 | | "SubjectPublicKeyInfo", keytype##_evp_type, \ |
1135 | | ( OSSL_KEYMGMT_SELECT_PUBLIC_KEY ), \ |
1136 | | NULL, \ |
1137 | | NULL, \ |
1138 | | NULL, \ |
1139 | | NULL, \ |
1140 | | keytype##_d2i_PUBKEY, \ |
1141 | | keytype##_check, \ |
1142 | | keytype##_adjust, \ |
1143 | | keytype##_free |
1144 | | |
1145 | | #define DO_DH(keytype) \ |
1146 | | "DH", keytype##_evp_type, \ |
1147 | | ( OSSL_KEYMGMT_SELECT_ALL_PARAMETERS ), \ |
1148 | | NULL, \ |
1149 | | NULL, \ |
1150 | | keytype##_d2i_key_params, \ |
1151 | | NULL, \ |
1152 | | NULL, \ |
1153 | | keytype##_check, \ |
1154 | | keytype##_adjust, \ |
1155 | | keytype##_free |
1156 | | |
1157 | | #define DO_DHX(keytype) \ |
1158 | | "DHX", keytype##_evp_type, \ |
1159 | | ( OSSL_KEYMGMT_SELECT_ALL_PARAMETERS ), \ |
1160 | | NULL, \ |
1161 | | NULL, \ |
1162 | | keytype##_d2i_key_params, \ |
1163 | | NULL, \ |
1164 | | NULL, \ |
1165 | | keytype##_check, \ |
1166 | | keytype##_adjust, \ |
1167 | | keytype##_free |
1168 | | |
1169 | | #define DO_DSA(keytype) \ |
1170 | | "DSA", keytype##_evp_type, \ |
1171 | | ( OSSL_KEYMGMT_SELECT_ALL ), \ |
1172 | | keytype##_d2i_private_key, \ |
1173 | | keytype##_d2i_public_key, \ |
1174 | | keytype##_d2i_key_params, \ |
1175 | | NULL, \ |
1176 | | NULL, \ |
1177 | | keytype##_check, \ |
1178 | | keytype##_adjust, \ |
1179 | | keytype##_free |
1180 | | |
1181 | | #define DO_EC(keytype) \ |
1182 | | "EC", keytype##_evp_type, \ |
1183 | | ( OSSL_KEYMGMT_SELECT_PRIVATE_KEY \ |
1184 | | | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS ), \ |
1185 | | keytype##_d2i_private_key, \ |
1186 | | NULL, \ |
1187 | | keytype##_d2i_key_params, \ |
1188 | | NULL, \ |
1189 | | NULL, \ |
1190 | | keytype##_check, \ |
1191 | | keytype##_adjust, \ |
1192 | | keytype##_free |
1193 | | |
1194 | | #define DO_RSA(keytype) \ |
1195 | | "RSA", keytype##_evp_type, \ |
1196 | | ( OSSL_KEYMGMT_SELECT_KEYPAIR ), \ |
1197 | | keytype##_d2i_private_key, \ |
1198 | | keytype##_d2i_public_key, \ |
1199 | | NULL, \ |
1200 | | NULL, \ |
1201 | | NULL, \ |
1202 | | keytype##_check, \ |
1203 | | keytype##_adjust, \ |
1204 | | keytype##_free |
1205 | | |
1206 | | /* |
1207 | | * MAKE_DECODER is the single driver for creating OSSL_DISPATCH tables. |
1208 | | * It takes the following arguments: |
1209 | | * |
1210 | | * keytype_name The implementation key type as a string. |
1211 | | * keytype The implementation key type. This must correspond exactly |
1212 | | * to our existing keymgmt keytype names... in other words, |
1213 | | * there must exist an ossl_##keytype##_keymgmt_functions. |
1214 | | * type The type name for the set of functions that implement the |
1215 | | * decoder for the key type. This isn't necessarily the same |
1216 | | * as keytype. For example, the key types ed25519, ed448, |
1217 | | * x25519 and x448 are all handled by the same functions with |
1218 | | * the common type name ecx. |
1219 | | * kind The kind of support to implement. This translates into |
1220 | | * the DO_##kind macros above, to populate the keytype_desc_st |
1221 | | * structure. |
1222 | | */ |
1223 | | #define MAKE_DECODER(keytype_name, keytype, type, kind) \ |
1224 | | static const struct keytype_desc_st kind##_##keytype##_desc = \ |
1225 | | { keytype_name, ossl_##keytype##_keymgmt_functions, \ |
1226 | | DO_##kind(keytype) }; \ |
1227 | | \ |
1228 | | static OSSL_FUNC_decoder_newctx_fn kind##_der2##keytype##_newctx; \ |
1229 | | \ |
1230 | | static void *kind##_der2##keytype##_newctx(void *provctx) \ |
1231 | 8.09M | { \ |
1232 | 8.09M | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ |
1233 | 8.09M | } \ decode_der2key.c:PrivateKeyInfo_der2dh_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2dh_newctx Line | Count | Source | 1231 | 52.8k | { \ | 1232 | 52.8k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 52.8k | } \ |
decode_der2key.c:type_specific_params_der2dh_newctx Line | Count | Source | 1231 | 37.8k | { \ | 1232 | 37.8k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 37.8k | } \ |
decode_der2key.c:DH_der2dh_newctx Line | Count | Source | 1231 | 37.8k | { \ | 1232 | 37.8k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 37.8k | } \ |
decode_der2key.c:PrivateKeyInfo_der2dhx_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2dhx_newctx Line | Count | Source | 1231 | 81.6k | { \ | 1232 | 81.6k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 81.6k | } \ |
decode_der2key.c:type_specific_params_der2dhx_newctx Line | Count | Source | 1231 | 37.8k | { \ | 1232 | 37.8k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 37.8k | } \ |
decode_der2key.c:DHX_der2dhx_newctx Line | Count | Source | 1231 | 37.8k | { \ | 1232 | 37.8k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 37.8k | } \ |
decode_der2key.c:PrivateKeyInfo_der2dsa_newctx Line | Count | Source | 1231 | 226k | { \ | 1232 | 226k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 226k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2dsa_newctx Line | Count | Source | 1231 | 157k | { \ | 1232 | 157k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 157k | } \ |
decode_der2key.c:type_specific_der2dsa_newctx Line | Count | Source | 1231 | 346k | { \ | 1232 | 346k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 346k | } \ |
decode_der2key.c:DSA_der2dsa_newctx Line | Count | Source | 1231 | 346k | { \ | 1232 | 346k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 346k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ec_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ec_newctx Line | Count | Source | 1231 | 535k | { \ | 1232 | 535k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 535k | } \ |
decode_der2key.c:type_specific_no_pub_der2ec_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:EC_der2ec_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:PrivateKeyInfo_der2x25519_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2x25519_newctx Line | Count | Source | 1231 | 39.5k | { \ | 1232 | 39.5k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 39.5k | } \ |
decode_der2key.c:PrivateKeyInfo_der2x448_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2x448_newctx Line | Count | Source | 1231 | 43.2k | { \ | 1232 | 43.2k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 43.2k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ed25519_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ed25519_newctx Line | Count | Source | 1231 | 48.6k | { \ | 1232 | 48.6k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 48.6k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ed448_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ed448_newctx Line | Count | Source | 1231 | 39.3k | { \ | 1232 | 39.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 39.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2sm2_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2sm2_newctx Line | Count | Source | 1231 | 535k | { \ | 1232 | 535k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 535k | } \ |
decode_der2key.c:type_specific_no_pub_der2sm2_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_kem_512_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_kem_512_newctx Line | Count | Source | 1231 | 15.7k | { \ | 1232 | 15.7k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 15.7k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_kem_768_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_kem_768_newctx Line | Count | Source | 1231 | 15.7k | { \ | 1232 | 15.7k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 15.7k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_kem_1024_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_kem_1024_newctx Line | Count | Source | 1231 | 15.7k | { \ | 1232 | 15.7k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 15.7k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_128s_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_128f_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_192s_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_192f_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_256s_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_256f_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_128s_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_128f_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_192s_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_192f_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_256s_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_256f_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_128s_newctx Line | Count | Source | 1231 | 16.0k | { \ | 1232 | 16.0k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 16.0k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_128f_newctx Line | Count | Source | 1231 | 15.6k | { \ | 1232 | 15.6k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 15.6k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_192s_newctx Line | Count | Source | 1231 | 16.5k | { \ | 1232 | 16.5k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 16.5k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_192f_newctx Line | Count | Source | 1231 | 16.1k | { \ | 1232 | 16.1k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 16.1k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_256s_newctx Line | Count | Source | 1231 | 15.6k | { \ | 1232 | 15.6k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 15.6k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_256f_newctx Line | Count | Source | 1231 | 16.4k | { \ | 1232 | 16.4k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 16.4k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_128s_newctx Line | Count | Source | 1231 | 15.6k | { \ | 1232 | 15.6k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 15.6k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_128f_newctx Line | Count | Source | 1231 | 15.6k | { \ | 1232 | 15.6k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 15.6k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_192s_newctx Line | Count | Source | 1231 | 15.6k | { \ | 1232 | 15.6k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 15.6k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_192f_newctx Line | Count | Source | 1231 | 18.1k | { \ | 1232 | 18.1k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 18.1k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_256s_newctx Line | Count | Source | 1231 | 16.5k | { \ | 1232 | 16.5k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 16.5k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_256f_newctx Line | Count | Source | 1231 | 15.6k | { \ | 1232 | 15.6k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 15.6k | } \ |
decode_der2key.c:PrivateKeyInfo_der2rsa_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2rsa_newctx Line | Count | Source | 1231 | 143k | { \ | 1232 | 143k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 143k | } \ |
decode_der2key.c:type_specific_keypair_der2rsa_newctx Line | Count | Source | 1231 | 330k | { \ | 1232 | 330k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 330k | } \ |
decode_der2key.c:RSA_der2rsa_newctx Line | Count | Source | 1231 | 330k | { \ | 1232 | 330k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 330k | } \ |
decode_der2key.c:PrivateKeyInfo_der2rsapss_newctx Line | Count | Source | 1231 | 224k | { \ | 1232 | 224k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 224k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2rsapss_newctx Line | Count | Source | 1231 | 70.9k | { \ | 1232 | 70.9k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 70.9k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_dsa_44_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_dsa_44_newctx Line | Count | Source | 1231 | 15.7k | { \ | 1232 | 15.7k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 15.7k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_dsa_65_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_dsa_65_newctx Line | Count | Source | 1231 | 15.7k | { \ | 1232 | 15.7k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 15.7k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_dsa_87_newctx Line | Count | Source | 1231 | 78.3k | { \ | 1232 | 78.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 78.3k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_dsa_87_newctx Line | Count | Source | 1231 | 16.3k | { \ | 1232 | 16.3k | return der2key_newctx(provctx, &kind##_##keytype##_desc); \ | 1233 | 16.3k | } \ |
|
1234 | | static int kind##_der2##keytype##_does_selection(void *provctx, \ |
1235 | | int selection) \ |
1236 | 8.99M | { \ |
1237 | 8.99M | return der2key_check_selection(selection, \ |
1238 | 8.99M | &kind##_##keytype##_desc); \ |
1239 | 8.99M | } \ decode_der2key.c:PrivateKeyInfo_der2dh_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2dh_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:type_specific_params_der2dh_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:DH_der2dh_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:PrivateKeyInfo_der2dhx_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2dhx_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:type_specific_params_der2dhx_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:DHX_der2dhx_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:PrivateKeyInfo_der2dsa_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2dsa_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:type_specific_der2dsa_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:DSA_der2dsa_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ec_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ec_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:type_specific_no_pub_der2ec_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:EC_der2ec_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:PrivateKeyInfo_der2x25519_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2x25519_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:PrivateKeyInfo_der2x448_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2x448_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ed25519_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ed25519_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ed448_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ed448_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:PrivateKeyInfo_der2sm2_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2sm2_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:type_specific_no_pub_der2sm2_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_kem_512_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_kem_512_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_kem_768_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_kem_768_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_kem_1024_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_kem_1024_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_128s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_128f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_192s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_192f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_256s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_sha2_256f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_128s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_128f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_192s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_192f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_256s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2slh_dsa_shake_256f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_128s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_128f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_192s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_192f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_256s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_sha2_256f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_128s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_128f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_192s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_192f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_256s_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2slh_dsa_shake_256f_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2rsa_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2rsa_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:type_specific_keypair_der2rsa_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:RSA_der2rsa_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:PrivateKeyInfo_der2rsapss_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2rsapss_does_selection Line | Count | Source | 1236 | 265k | { \ | 1237 | 265k | return der2key_check_selection(selection, \ | 1238 | 265k | &kind##_##keytype##_desc); \ | 1239 | 265k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_dsa_44_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_dsa_44_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_dsa_65_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_dsa_65_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:PrivateKeyInfo_der2ml_dsa_87_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
decode_der2key.c:SubjectPublicKeyInfo_der2ml_dsa_87_does_selection Line | Count | Source | 1236 | 6.50k | { \ | 1237 | 6.50k | return der2key_check_selection(selection, \ | 1238 | 6.50k | &kind##_##keytype##_desc); \ | 1239 | 6.50k | } \ |
|
1240 | | const OSSL_DISPATCH \ |
1241 | | ossl_##kind##_der_to_##keytype##_decoder_functions[] = { \ |
1242 | | { OSSL_FUNC_DECODER_NEWCTX, \ |
1243 | | (void (*)(void))kind##_der2##keytype##_newctx }, \ |
1244 | | { OSSL_FUNC_DECODER_FREECTX, \ |
1245 | | (void (*)(void))der2key_freectx }, \ |
1246 | | { OSSL_FUNC_DECODER_DOES_SELECTION, \ |
1247 | | (void (*)(void))kind##_der2##keytype##_does_selection }, \ |
1248 | | { OSSL_FUNC_DECODER_DECODE, \ |
1249 | | (void (*)(void))der2key_decode }, \ |
1250 | | { OSSL_FUNC_DECODER_EXPORT_OBJECT, \ |
1251 | | (void (*)(void))der2key_export_object }, \ |
1252 | | { OSSL_FUNC_DECODER_SETTABLE_CTX_PARAMS, \ |
1253 | | (void (*)(void))der2key_settable_ctx_params }, \ |
1254 | | { OSSL_FUNC_DECODER_SET_CTX_PARAMS, \ |
1255 | | (void (*)(void))der2key_set_ctx_params }, \ |
1256 | | OSSL_DISPATCH_END \ |
1257 | | } |
1258 | | |
1259 | | #ifndef OPENSSL_NO_DH |
1260 | | MAKE_DECODER("DH", dh, dh, PrivateKeyInfo); |
1261 | | MAKE_DECODER("DH", dh, dh, SubjectPublicKeyInfo); |
1262 | | MAKE_DECODER("DH", dh, dh, type_specific_params); |
1263 | | MAKE_DECODER("DH", dh, dh, DH); |
1264 | | MAKE_DECODER("DHX", dhx, dhx, PrivateKeyInfo); |
1265 | | MAKE_DECODER("DHX", dhx, dhx, SubjectPublicKeyInfo); |
1266 | | MAKE_DECODER("DHX", dhx, dhx, type_specific_params); |
1267 | | MAKE_DECODER("DHX", dhx, dhx, DHX); |
1268 | | #endif |
1269 | | #ifndef OPENSSL_NO_DSA |
1270 | | MAKE_DECODER("DSA", dsa, dsa, PrivateKeyInfo); |
1271 | | MAKE_DECODER("DSA", dsa, dsa, SubjectPublicKeyInfo); |
1272 | | MAKE_DECODER("DSA", dsa, dsa, type_specific); |
1273 | | MAKE_DECODER("DSA", dsa, dsa, DSA); |
1274 | | #endif |
1275 | | #ifndef OPENSSL_NO_EC |
1276 | | MAKE_DECODER("EC", ec, ec, PrivateKeyInfo); |
1277 | | MAKE_DECODER("EC", ec, ec, SubjectPublicKeyInfo); |
1278 | | MAKE_DECODER("EC", ec, ec, type_specific_no_pub); |
1279 | | MAKE_DECODER("EC", ec, ec, EC); |
1280 | | # ifndef OPENSSL_NO_ECX |
1281 | | MAKE_DECODER("X25519", x25519, ecx, PrivateKeyInfo); |
1282 | | MAKE_DECODER("X25519", x25519, ecx, SubjectPublicKeyInfo); |
1283 | | MAKE_DECODER("X448", x448, ecx, PrivateKeyInfo); |
1284 | | MAKE_DECODER("X448", x448, ecx, SubjectPublicKeyInfo); |
1285 | | MAKE_DECODER("ED25519", ed25519, ecx, PrivateKeyInfo); |
1286 | | MAKE_DECODER("ED25519", ed25519, ecx, SubjectPublicKeyInfo); |
1287 | | MAKE_DECODER("ED448", ed448, ecx, PrivateKeyInfo); |
1288 | | MAKE_DECODER("ED448", ed448, ecx, SubjectPublicKeyInfo); |
1289 | | # endif |
1290 | | # ifndef OPENSSL_NO_SM2 |
1291 | | MAKE_DECODER("SM2", sm2, ec, PrivateKeyInfo); |
1292 | | MAKE_DECODER("SM2", sm2, ec, SubjectPublicKeyInfo); |
1293 | | MAKE_DECODER("SM2", sm2, sm2, type_specific_no_pub); |
1294 | | # endif |
1295 | | #endif |
1296 | | #ifndef OPENSSL_NO_ML_KEM |
1297 | | MAKE_DECODER("ML-KEM-512", ml_kem_512, ml_kem_512, PrivateKeyInfo); |
1298 | | MAKE_DECODER("ML-KEM-512", ml_kem_512, ml_kem_512, SubjectPublicKeyInfo); |
1299 | | MAKE_DECODER("ML-KEM-768", ml_kem_768, ml_kem_768, PrivateKeyInfo); |
1300 | | MAKE_DECODER("ML-KEM-768", ml_kem_768, ml_kem_768, SubjectPublicKeyInfo); |
1301 | | MAKE_DECODER("ML-KEM-1024", ml_kem_1024, ml_kem_1024, PrivateKeyInfo); |
1302 | | MAKE_DECODER("ML-KEM-1024", ml_kem_1024, ml_kem_1024, SubjectPublicKeyInfo); |
1303 | | #endif |
1304 | | #ifndef OPENSSL_NO_SLH_DSA |
1305 | | MAKE_DECODER("SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, slh_dsa, PrivateKeyInfo); |
1306 | | MAKE_DECODER("SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, slh_dsa, PrivateKeyInfo); |
1307 | | MAKE_DECODER("SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, slh_dsa, PrivateKeyInfo); |
1308 | | MAKE_DECODER("SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, slh_dsa, PrivateKeyInfo); |
1309 | | MAKE_DECODER("SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, slh_dsa, PrivateKeyInfo); |
1310 | | MAKE_DECODER("SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, slh_dsa, PrivateKeyInfo); |
1311 | | MAKE_DECODER("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, slh_dsa, PrivateKeyInfo); |
1312 | | MAKE_DECODER("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, slh_dsa, PrivateKeyInfo); |
1313 | | MAKE_DECODER("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, slh_dsa, PrivateKeyInfo); |
1314 | | MAKE_DECODER("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, slh_dsa, PrivateKeyInfo); |
1315 | | MAKE_DECODER("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, slh_dsa, PrivateKeyInfo); |
1316 | | MAKE_DECODER("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, slh_dsa, PrivateKeyInfo); |
1317 | | |
1318 | | MAKE_DECODER("SLH-DSA-SHA2-128s", slh_dsa_sha2_128s, slh_dsa, SubjectPublicKeyInfo); |
1319 | | MAKE_DECODER("SLH-DSA-SHA2-128f", slh_dsa_sha2_128f, slh_dsa, SubjectPublicKeyInfo); |
1320 | | MAKE_DECODER("SLH-DSA-SHA2-192s", slh_dsa_sha2_192s, slh_dsa, SubjectPublicKeyInfo); |
1321 | | MAKE_DECODER("SLH-DSA-SHA2-192f", slh_dsa_sha2_192f, slh_dsa, SubjectPublicKeyInfo); |
1322 | | MAKE_DECODER("SLH-DSA-SHA2-256s", slh_dsa_sha2_256s, slh_dsa, SubjectPublicKeyInfo); |
1323 | | MAKE_DECODER("SLH-DSA-SHA2-256f", slh_dsa_sha2_256f, slh_dsa, SubjectPublicKeyInfo); |
1324 | | MAKE_DECODER("SLH-DSA-SHAKE-128s", slh_dsa_shake_128s, slh_dsa, SubjectPublicKeyInfo); |
1325 | | MAKE_DECODER("SLH-DSA-SHAKE-128f", slh_dsa_shake_128f, slh_dsa, SubjectPublicKeyInfo); |
1326 | | MAKE_DECODER("SLH-DSA-SHAKE-192s", slh_dsa_shake_192s, slh_dsa, SubjectPublicKeyInfo); |
1327 | | MAKE_DECODER("SLH-DSA-SHAKE-192f", slh_dsa_shake_192f, slh_dsa, SubjectPublicKeyInfo); |
1328 | | MAKE_DECODER("SLH-DSA-SHAKE-256s", slh_dsa_shake_256s, slh_dsa, SubjectPublicKeyInfo); |
1329 | | MAKE_DECODER("SLH-DSA-SHAKE-256f", slh_dsa_shake_256f, slh_dsa, SubjectPublicKeyInfo); |
1330 | | #endif /* OPENSSL_NO_SLH_DSA */ |
1331 | | MAKE_DECODER("RSA", rsa, rsa, PrivateKeyInfo); |
1332 | | MAKE_DECODER("RSA", rsa, rsa, SubjectPublicKeyInfo); |
1333 | | MAKE_DECODER("RSA", rsa, rsa, type_specific_keypair); |
1334 | | MAKE_DECODER("RSA", rsa, rsa, RSA); |
1335 | | MAKE_DECODER("RSA-PSS", rsapss, rsapss, PrivateKeyInfo); |
1336 | | MAKE_DECODER("RSA-PSS", rsapss, rsapss, SubjectPublicKeyInfo); |
1337 | | |
1338 | | #ifndef OPENSSL_NO_ML_DSA |
1339 | | MAKE_DECODER("ML-DSA-44", ml_dsa_44, ml_dsa_44, PrivateKeyInfo); |
1340 | | MAKE_DECODER("ML-DSA-44", ml_dsa_44, ml_dsa_44, SubjectPublicKeyInfo); |
1341 | | MAKE_DECODER("ML-DSA-65", ml_dsa_65, ml_dsa_65, PrivateKeyInfo); |
1342 | | MAKE_DECODER("ML-DSA-65", ml_dsa_65, ml_dsa_65, SubjectPublicKeyInfo); |
1343 | | MAKE_DECODER("ML-DSA-87", ml_dsa_87, ml_dsa_87, PrivateKeyInfo); |
1344 | | MAKE_DECODER("ML-DSA-87", ml_dsa_87, ml_dsa_87, SubjectPublicKeyInfo); |
1345 | | #endif |