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