/src/openssl/providers/implementations/signature/dsa_sig.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2019-2024 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 | | * DSA low level APIs are deprecated for public use, but still ok for |
13 | | * internal use. |
14 | | */ |
15 | | #include "internal/deprecated.h" |
16 | | |
17 | | #include <string.h> |
18 | | |
19 | | #include <openssl/crypto.h> |
20 | | #include <openssl/core_dispatch.h> |
21 | | #include <openssl/core_names.h> |
22 | | #include <openssl/err.h> |
23 | | #include <openssl/dsa.h> |
24 | | #include <openssl/params.h> |
25 | | #include <openssl/evp.h> |
26 | | #include <openssl/proverr.h> |
27 | | #include "internal/nelem.h" |
28 | | #include "internal/sizes.h" |
29 | | #include "internal/cryptlib.h" |
30 | | #include "prov/providercommon.h" |
31 | | #include "prov/implementations.h" |
32 | | #include "prov/provider_ctx.h" |
33 | | #include "prov/securitycheck.h" |
34 | | #include "prov/der_dsa.h" |
35 | | #include "crypto/dsa.h" |
36 | | |
37 | | static OSSL_FUNC_signature_newctx_fn dsa_newctx; |
38 | | static OSSL_FUNC_signature_sign_init_fn dsa_sign_init; |
39 | | static OSSL_FUNC_signature_verify_init_fn dsa_verify_init; |
40 | | static OSSL_FUNC_signature_sign_fn dsa_sign; |
41 | | static OSSL_FUNC_signature_sign_message_update_fn dsa_signverify_message_update; |
42 | | static OSSL_FUNC_signature_sign_message_final_fn dsa_sign_message_final; |
43 | | static OSSL_FUNC_signature_verify_fn dsa_verify; |
44 | | static OSSL_FUNC_signature_verify_message_update_fn dsa_signverify_message_update; |
45 | | static OSSL_FUNC_signature_verify_message_final_fn dsa_verify_message_final; |
46 | | static OSSL_FUNC_signature_digest_sign_init_fn dsa_digest_sign_init; |
47 | | static OSSL_FUNC_signature_digest_sign_update_fn dsa_digest_signverify_update; |
48 | | static OSSL_FUNC_signature_digest_sign_final_fn dsa_digest_sign_final; |
49 | | static OSSL_FUNC_signature_digest_verify_init_fn dsa_digest_verify_init; |
50 | | static OSSL_FUNC_signature_digest_verify_update_fn dsa_digest_signverify_update; |
51 | | static OSSL_FUNC_signature_digest_verify_final_fn dsa_digest_verify_final; |
52 | | static OSSL_FUNC_signature_freectx_fn dsa_freectx; |
53 | | static OSSL_FUNC_signature_dupctx_fn dsa_dupctx; |
54 | | static OSSL_FUNC_signature_query_key_types_fn dsa_sigalg_query_key_types; |
55 | | static OSSL_FUNC_signature_get_ctx_params_fn dsa_get_ctx_params; |
56 | | static OSSL_FUNC_signature_gettable_ctx_params_fn dsa_gettable_ctx_params; |
57 | | static OSSL_FUNC_signature_set_ctx_params_fn dsa_set_ctx_params; |
58 | | static OSSL_FUNC_signature_settable_ctx_params_fn dsa_settable_ctx_params; |
59 | | static OSSL_FUNC_signature_get_ctx_md_params_fn dsa_get_ctx_md_params; |
60 | | static OSSL_FUNC_signature_gettable_ctx_md_params_fn dsa_gettable_ctx_md_params; |
61 | | static OSSL_FUNC_signature_set_ctx_md_params_fn dsa_set_ctx_md_params; |
62 | | static OSSL_FUNC_signature_settable_ctx_md_params_fn dsa_settable_ctx_md_params; |
63 | | static OSSL_FUNC_signature_set_ctx_params_fn dsa_sigalg_set_ctx_params; |
64 | | static OSSL_FUNC_signature_settable_ctx_params_fn dsa_sigalg_settable_ctx_params; |
65 | | |
66 | | /* |
67 | | * What's passed as an actual key is defined by the KEYMGMT interface. |
68 | | * We happen to know that our KEYMGMT simply passes DSA structures, so |
69 | | * we use that here too. |
70 | | */ |
71 | | |
72 | | typedef struct { |
73 | | OSSL_LIB_CTX *libctx; |
74 | | char *propq; |
75 | | DSA *dsa; |
76 | | /* |operation| reuses EVP's operation bitfield */ |
77 | | int operation; |
78 | | |
79 | | /* |
80 | | * Flag to determine if a full sigalg is run (1) or if a composable |
81 | | * signature algorithm is run (0). |
82 | | * |
83 | | * When a full sigalg is run (1), this currently affects the following |
84 | | * other flags, which are to remain untouched after their initialization: |
85 | | * |
86 | | * - flag_allow_md (initialized to 0) |
87 | | */ |
88 | | unsigned int flag_sigalg : 1; |
89 | | /* |
90 | | * Flag to determine if the hash function can be changed (1) or not (0) |
91 | | * Because it's dangerous to change during a DigestSign or DigestVerify |
92 | | * operation, this flag is cleared by their Init function, and set again |
93 | | * by their Final function. |
94 | | */ |
95 | | unsigned int flag_allow_md : 1; |
96 | | |
97 | | /* If this is set to 1 then the generated k is not random */ |
98 | | unsigned int nonce_type; |
99 | | |
100 | | /* The Algorithm Identifier of the combined signature algorithm */ |
101 | | unsigned char aid_buf[OSSL_MAX_ALGORITHM_ID_SIZE]; |
102 | | size_t aid_len; |
103 | | |
104 | | /* main digest */ |
105 | | char mdname[OSSL_MAX_NAME_SIZE]; |
106 | | EVP_MD *md; |
107 | | EVP_MD_CTX *mdctx; |
108 | | |
109 | | /* Signature, for verification */ |
110 | | unsigned char *sig; |
111 | | size_t siglen; |
112 | | |
113 | | OSSL_FIPS_IND_DECLARE |
114 | | } PROV_DSA_CTX; |
115 | | |
116 | | static size_t dsa_get_md_size(const PROV_DSA_CTX *pdsactx) |
117 | 0 | { |
118 | 0 | int md_size; |
119 | |
|
120 | 0 | if (pdsactx->md != NULL) { |
121 | 0 | md_size = EVP_MD_get_size(pdsactx->md); |
122 | 0 | if (md_size <= 0) |
123 | 0 | return 0; |
124 | 0 | return (size_t)md_size; |
125 | 0 | } |
126 | 0 | return 0; |
127 | 0 | } |
128 | | |
129 | | static void *dsa_newctx(void *provctx, const char *propq) |
130 | 0 | { |
131 | 0 | PROV_DSA_CTX *pdsactx; |
132 | |
|
133 | 0 | if (!ossl_prov_is_running()) |
134 | 0 | return NULL; |
135 | | |
136 | 0 | pdsactx = OPENSSL_zalloc(sizeof(PROV_DSA_CTX)); |
137 | 0 | if (pdsactx == NULL) |
138 | 0 | return NULL; |
139 | | |
140 | 0 | pdsactx->libctx = PROV_LIBCTX_OF(provctx); |
141 | 0 | pdsactx->flag_allow_md = 1; |
142 | 0 | OSSL_FIPS_IND_INIT(pdsactx) |
143 | 0 | if (propq != NULL && (pdsactx->propq = OPENSSL_strdup(propq)) == NULL) { |
144 | 0 | OPENSSL_free(pdsactx); |
145 | 0 | pdsactx = NULL; |
146 | 0 | } |
147 | 0 | return pdsactx; |
148 | 0 | } |
149 | | |
150 | | static int dsa_setup_md(PROV_DSA_CTX *ctx, |
151 | | const char *mdname, const char *mdprops, |
152 | | const char *desc) |
153 | 0 | { |
154 | 0 | EVP_MD *md = NULL; |
155 | |
|
156 | 0 | if (mdprops == NULL) |
157 | 0 | mdprops = ctx->propq; |
158 | |
|
159 | 0 | if (mdname != NULL) { |
160 | 0 | WPACKET pkt; |
161 | 0 | int md_nid; |
162 | 0 | size_t mdname_len = strlen(mdname); |
163 | 0 | unsigned char *aid = NULL; |
164 | |
|
165 | 0 | md = EVP_MD_fetch(ctx->libctx, mdname, mdprops); |
166 | 0 | md_nid = ossl_digest_get_approved_nid(md); |
167 | |
|
168 | 0 | if (md == NULL) { |
169 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST, |
170 | 0 | "%s could not be fetched", mdname); |
171 | 0 | goto err; |
172 | 0 | } |
173 | 0 | if (md_nid == NID_undef) { |
174 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED, |
175 | 0 | "digest=%s", mdname); |
176 | 0 | goto err; |
177 | 0 | } |
178 | 0 | if (mdname_len >= sizeof(ctx->mdname)) { |
179 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST, |
180 | 0 | "%s exceeds name buffer length", mdname); |
181 | 0 | goto err; |
182 | 0 | } |
183 | | /* XOF digests don't work */ |
184 | 0 | if (EVP_MD_xof(md)) { |
185 | 0 | ERR_raise(ERR_LIB_PROV, PROV_R_XOF_DIGESTS_NOT_ALLOWED); |
186 | 0 | goto err; |
187 | 0 | } |
188 | | #ifdef FIPS_MODULE |
189 | | { |
190 | | int sha1_allowed |
191 | | = ((ctx->operation |
192 | | & (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_SIGNMSG)) == 0); |
193 | | |
194 | | if (!ossl_fips_ind_digest_sign_check(OSSL_FIPS_IND_GET(ctx), |
195 | | OSSL_FIPS_IND_SETTABLE1, |
196 | | ctx->libctx, |
197 | | md_nid, sha1_allowed, desc, |
198 | | ossl_fips_config_signature_digest_check)) |
199 | | goto err; |
200 | | } |
201 | | #endif |
202 | | |
203 | 0 | if (!ctx->flag_allow_md) { |
204 | 0 | if (ctx->mdname[0] != '\0' |
205 | 0 | && !EVP_MD_is_a(md, ctx->mdname)) { |
206 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED, |
207 | 0 | "digest %s != %s", mdname, ctx->mdname); |
208 | 0 | goto err; |
209 | 0 | } |
210 | 0 | EVP_MD_free(md); |
211 | 0 | return 1; |
212 | 0 | } |
213 | | |
214 | 0 | EVP_MD_CTX_free(ctx->mdctx); |
215 | 0 | EVP_MD_free(ctx->md); |
216 | | |
217 | | /* |
218 | | * We do not care about DER writing errors. |
219 | | * All it really means is that for some reason, there's no |
220 | | * AlgorithmIdentifier to be had, but the operation itself is |
221 | | * still valid, just as long as it's not used to construct |
222 | | * anything that needs an AlgorithmIdentifier. |
223 | | */ |
224 | 0 | ctx->aid_len = 0; |
225 | 0 | if (WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf)) |
226 | 0 | && ossl_DER_w_algorithmIdentifier_DSA_with_MD(&pkt, -1, ctx->dsa, |
227 | 0 | md_nid) |
228 | 0 | && WPACKET_finish(&pkt)) { |
229 | 0 | WPACKET_get_total_written(&pkt, &ctx->aid_len); |
230 | 0 | aid = WPACKET_get_curr(&pkt); |
231 | 0 | } |
232 | 0 | WPACKET_cleanup(&pkt); |
233 | 0 | if (aid != NULL && ctx->aid_len != 0) |
234 | 0 | memmove(ctx->aid_buf, aid, ctx->aid_len); |
235 | |
|
236 | 0 | ctx->mdctx = NULL; |
237 | 0 | ctx->md = md; |
238 | 0 | OPENSSL_strlcpy(ctx->mdname, mdname, sizeof(ctx->mdname)); |
239 | 0 | } |
240 | | |
241 | 0 | return 1; |
242 | 0 | err: |
243 | 0 | EVP_MD_free(md); |
244 | 0 | return 0; |
245 | 0 | } |
246 | | |
247 | | #ifdef FIPS_MODULE |
248 | | |
249 | | static int dsa_sign_check_approved(PROV_DSA_CTX *ctx, int signing, |
250 | | const char *desc) |
251 | | { |
252 | | /* DSA Signing is not approved in FIPS 140-3 */ |
253 | | if (signing |
254 | | && !OSSL_FIPS_IND_ON_UNAPPROVED(ctx, OSSL_FIPS_IND_SETTABLE2, |
255 | | ctx->libctx, desc, "DSA", |
256 | | ossl_fips_config_dsa_sign_disallowed)) |
257 | | return 0; |
258 | | return 1; |
259 | | } |
260 | | |
261 | | static int dsa_check_key(PROV_DSA_CTX *ctx, int sign, const char *desc) |
262 | | { |
263 | | int approved = ossl_dsa_check_key(ctx->dsa, sign); |
264 | | |
265 | | if (!approved) { |
266 | | if (!OSSL_FIPS_IND_ON_UNAPPROVED(ctx, OSSL_FIPS_IND_SETTABLE0, |
267 | | ctx->libctx, desc, "DSA Key", |
268 | | ossl_fips_config_signature_digest_check)) { |
269 | | ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH); |
270 | | return 0; |
271 | | } |
272 | | } |
273 | | return 1; |
274 | | } |
275 | | #endif |
276 | | |
277 | | static int |
278 | | dsa_signverify_init(void *vpdsactx, void *vdsa, |
279 | | OSSL_FUNC_signature_set_ctx_params_fn *set_ctx_params, |
280 | | const OSSL_PARAM params[], int operation, |
281 | | const char *desc) |
282 | 0 | { |
283 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
284 | |
|
285 | 0 | if (!ossl_prov_is_running() |
286 | 0 | || pdsactx == NULL) |
287 | 0 | return 0; |
288 | | |
289 | 0 | if (vdsa == NULL && pdsactx->dsa == NULL) { |
290 | 0 | ERR_raise(ERR_LIB_PROV, PROV_R_NO_KEY_SET); |
291 | 0 | return 0; |
292 | 0 | } |
293 | | |
294 | 0 | if (vdsa != NULL) { |
295 | 0 | if (!DSA_up_ref(vdsa)) |
296 | 0 | return 0; |
297 | 0 | DSA_free(pdsactx->dsa); |
298 | 0 | pdsactx->dsa = vdsa; |
299 | 0 | } |
300 | | |
301 | 0 | pdsactx->operation = operation; |
302 | |
|
303 | 0 | OSSL_FIPS_IND_SET_APPROVED(pdsactx) |
304 | 0 | if (!set_ctx_params(pdsactx, params)) |
305 | 0 | return 0; |
306 | | #ifdef FIPS_MODULE |
307 | | { |
308 | | int operation_is_sign |
309 | | = (operation & (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_SIGNMSG)) != 0; |
310 | | |
311 | | if (!dsa_sign_check_approved(pdsactx, operation_is_sign, desc)) |
312 | | return 0; |
313 | | if (!dsa_check_key(pdsactx, operation_is_sign, desc)) |
314 | | return 0; |
315 | | } |
316 | | #endif |
317 | 0 | return 1; |
318 | 0 | } |
319 | | |
320 | | static int dsa_sign_init(void *vpdsactx, void *vdsa, const OSSL_PARAM params[]) |
321 | 0 | { |
322 | 0 | return dsa_signverify_init(vpdsactx, vdsa, dsa_set_ctx_params, params, |
323 | 0 | EVP_PKEY_OP_SIGN, "DSA Sign Init"); |
324 | 0 | } |
325 | | |
326 | | /* |
327 | | * Sign tbs without digesting it first. This is suitable for "primitive" |
328 | | * signing and signing the digest of a message, i.e. should be used with |
329 | | * implementations of the keytype related algorithms. |
330 | | */ |
331 | | static int dsa_sign_directly(void *vpdsactx, |
332 | | unsigned char *sig, size_t *siglen, size_t sigsize, |
333 | | const unsigned char *tbs, size_t tbslen) |
334 | 0 | { |
335 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
336 | 0 | int ret; |
337 | 0 | unsigned int sltmp; |
338 | 0 | size_t dsasize = DSA_size(pdsactx->dsa); |
339 | 0 | size_t mdsize = dsa_get_md_size(pdsactx); |
340 | |
|
341 | 0 | if (!ossl_prov_is_running()) |
342 | 0 | return 0; |
343 | | |
344 | | #ifdef FIPS_MODULE |
345 | | if (!dsa_sign_check_approved(pdsactx, 1, "Sign")) |
346 | | return 0; |
347 | | #endif |
348 | | |
349 | 0 | if (sig == NULL) { |
350 | 0 | *siglen = dsasize; |
351 | 0 | return 1; |
352 | 0 | } |
353 | | |
354 | 0 | if (sigsize < dsasize) |
355 | 0 | return 0; |
356 | | |
357 | 0 | if (mdsize != 0 && tbslen != mdsize) |
358 | 0 | return 0; |
359 | | |
360 | 0 | ret = ossl_dsa_sign_int(0, tbs, (int)tbslen, sig, &sltmp, pdsactx->dsa, |
361 | 0 | pdsactx->nonce_type, pdsactx->mdname, |
362 | 0 | pdsactx->libctx, pdsactx->propq); |
363 | 0 | if (ret <= 0) |
364 | 0 | return 0; |
365 | | |
366 | 0 | *siglen = sltmp; |
367 | 0 | return 1; |
368 | 0 | } |
369 | | |
370 | | static int dsa_signverify_message_update(void *vpdsactx, |
371 | | const unsigned char *data, |
372 | | size_t datalen) |
373 | 0 | { |
374 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
375 | |
|
376 | 0 | if (pdsactx == NULL) |
377 | 0 | return 0; |
378 | | |
379 | 0 | return EVP_DigestUpdate(pdsactx->mdctx, data, datalen); |
380 | 0 | } |
381 | | |
382 | | static int dsa_sign_message_final(void *vpdsactx, unsigned char *sig, |
383 | | size_t *siglen, size_t sigsize) |
384 | 0 | { |
385 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
386 | 0 | unsigned char digest[EVP_MAX_MD_SIZE]; |
387 | 0 | unsigned int dlen = 0; |
388 | |
|
389 | 0 | if (!ossl_prov_is_running() || pdsactx == NULL || pdsactx->mdctx == NULL) |
390 | 0 | return 0; |
391 | | /* |
392 | | * If sig is NULL then we're just finding out the sig size. Other fields |
393 | | * are ignored. Defer to dsa_sign. |
394 | | */ |
395 | 0 | if (sig != NULL) { |
396 | | /* |
397 | | * When this function is used through dsa_digest_sign_final(), |
398 | | * there is the possibility that some externally provided digests |
399 | | * exceed EVP_MAX_MD_SIZE. We should probably handle that |
400 | | * somehow but that problem is much larger than just in DSA. |
401 | | */ |
402 | 0 | if (!EVP_DigestFinal_ex(pdsactx->mdctx, digest, &dlen)) |
403 | 0 | return 0; |
404 | 0 | } |
405 | | |
406 | 0 | return dsa_sign_directly(vpdsactx, sig, siglen, sigsize, digest, dlen); |
407 | 0 | } |
408 | | |
409 | | /* |
410 | | * If signing a message, digest tbs and sign the result. |
411 | | * Otherwise, sign tbs directly. |
412 | | */ |
413 | | static int dsa_sign(void *vpdsactx, unsigned char *sig, size_t *siglen, |
414 | | size_t sigsize, const unsigned char *tbs, size_t tbslen) |
415 | 0 | { |
416 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
417 | |
|
418 | 0 | if (pdsactx->operation == EVP_PKEY_OP_SIGNMSG) { |
419 | | /* |
420 | | * If |sig| is NULL, the caller is only looking for the sig length. |
421 | | * DO NOT update the input in this case. |
422 | | */ |
423 | 0 | if (sig == NULL) |
424 | 0 | return dsa_sign_message_final(pdsactx, sig, siglen, sigsize); |
425 | | |
426 | 0 | if (dsa_signverify_message_update(pdsactx, tbs, tbslen) <= 0) |
427 | 0 | return 0; |
428 | 0 | return dsa_sign_message_final(pdsactx, sig, siglen, sigsize); |
429 | 0 | } |
430 | 0 | return dsa_sign_directly(pdsactx, sig, siglen, sigsize, tbs, tbslen); |
431 | 0 | } |
432 | | |
433 | | static int dsa_verify_init(void *vpdsactx, void *vdsa, |
434 | | const OSSL_PARAM params[]) |
435 | 0 | { |
436 | 0 | return dsa_signverify_init(vpdsactx, vdsa, dsa_set_ctx_params, params, |
437 | 0 | EVP_PKEY_OP_VERIFY, "DSA Verify Init"); |
438 | 0 | } |
439 | | |
440 | | static int dsa_verify_directly(void *vpdsactx, |
441 | | const unsigned char *sig, size_t siglen, |
442 | | const unsigned char *tbs, size_t tbslen) |
443 | 0 | { |
444 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
445 | 0 | size_t mdsize = dsa_get_md_size(pdsactx); |
446 | |
|
447 | 0 | if (!ossl_prov_is_running() || (mdsize != 0 && tbslen != mdsize)) |
448 | 0 | return 0; |
449 | | |
450 | 0 | return DSA_verify(0, tbs, (int)tbslen, sig, (int)siglen, pdsactx->dsa); |
451 | 0 | } |
452 | | |
453 | | static int dsa_verify_set_sig(void *vpdsactx, |
454 | | const unsigned char *sig, size_t siglen) |
455 | 0 | { |
456 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
457 | 0 | OSSL_PARAM params[2]; |
458 | |
|
459 | 0 | params[0] = |
460 | 0 | OSSL_PARAM_construct_octet_string(OSSL_SIGNATURE_PARAM_SIGNATURE, |
461 | 0 | (unsigned char *)sig, siglen); |
462 | 0 | params[1] = OSSL_PARAM_construct_end(); |
463 | 0 | return dsa_sigalg_set_ctx_params(pdsactx, params); |
464 | 0 | } |
465 | | |
466 | | static int dsa_verify_message_final(void *vpdsactx) |
467 | 0 | { |
468 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
469 | 0 | unsigned char digest[EVP_MAX_MD_SIZE]; |
470 | 0 | unsigned int dlen = 0; |
471 | |
|
472 | 0 | if (!ossl_prov_is_running()) |
473 | 0 | return 0; |
474 | | |
475 | 0 | if (pdsactx == NULL || pdsactx->mdctx == NULL) |
476 | 0 | return 0; |
477 | | |
478 | | /* |
479 | | * The digests used here are all known (see dsa_get_md_nid()), so they |
480 | | * should not exceed the internal buffer size of EVP_MAX_MD_SIZE. |
481 | | */ |
482 | 0 | if (!EVP_DigestFinal_ex(pdsactx->mdctx, digest, &dlen)) |
483 | 0 | return 0; |
484 | | |
485 | 0 | return dsa_verify_directly(vpdsactx, pdsactx->sig, pdsactx->siglen, |
486 | 0 | digest, dlen); |
487 | 0 | } |
488 | | |
489 | | /* |
490 | | * If verifying a message, digest tbs and verify the result. |
491 | | * Otherwise, verify tbs directly. |
492 | | */ |
493 | | static int dsa_verify(void *vpdsactx, |
494 | | const unsigned char *sig, size_t siglen, |
495 | | const unsigned char *tbs, size_t tbslen) |
496 | 0 | { |
497 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
498 | |
|
499 | 0 | if (pdsactx->operation == EVP_PKEY_OP_VERIFYMSG) { |
500 | 0 | if (dsa_verify_set_sig(pdsactx, sig, siglen) <= 0) |
501 | 0 | return 0; |
502 | 0 | if (dsa_signverify_message_update(pdsactx, tbs, tbslen) <= 0) |
503 | 0 | return 0; |
504 | 0 | return dsa_verify_message_final(pdsactx); |
505 | 0 | } |
506 | 0 | return dsa_verify_directly(pdsactx, sig, siglen, tbs, tbslen); |
507 | 0 | } |
508 | | |
509 | | /* DigestSign/DigestVerify wrappers */ |
510 | | |
511 | | static int dsa_digest_signverify_init(void *vpdsactx, const char *mdname, |
512 | | void *vdsa, const OSSL_PARAM params[], |
513 | | int operation, const char *desc) |
514 | 0 | { |
515 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
516 | |
|
517 | 0 | if (!ossl_prov_is_running()) |
518 | 0 | return 0; |
519 | | |
520 | 0 | if (!dsa_signverify_init(vpdsactx, vdsa, dsa_set_ctx_params, params, |
521 | 0 | operation, desc)) |
522 | 0 | return 0; |
523 | | |
524 | 0 | if (mdname != NULL |
525 | | /* was dsa_setup_md already called in dsa_signverify_init()? */ |
526 | 0 | && (mdname[0] == '\0' || OPENSSL_strcasecmp(pdsactx->mdname, mdname) != 0) |
527 | 0 | && !dsa_setup_md(pdsactx, mdname, NULL, desc)) |
528 | 0 | return 0; |
529 | | |
530 | 0 | pdsactx->flag_allow_md = 0; |
531 | |
|
532 | 0 | if (pdsactx->mdctx == NULL) { |
533 | 0 | pdsactx->mdctx = EVP_MD_CTX_new(); |
534 | 0 | if (pdsactx->mdctx == NULL) |
535 | 0 | goto error; |
536 | 0 | } |
537 | | |
538 | 0 | if (!EVP_DigestInit_ex2(pdsactx->mdctx, pdsactx->md, params)) |
539 | 0 | goto error; |
540 | | |
541 | 0 | return 1; |
542 | | |
543 | 0 | error: |
544 | 0 | EVP_MD_CTX_free(pdsactx->mdctx); |
545 | 0 | pdsactx->mdctx = NULL; |
546 | 0 | return 0; |
547 | 0 | } |
548 | | |
549 | | static int dsa_digest_sign_init(void *vpdsactx, const char *mdname, |
550 | | void *vdsa, const OSSL_PARAM params[]) |
551 | 0 | { |
552 | 0 | return dsa_digest_signverify_init(vpdsactx, mdname, vdsa, params, |
553 | 0 | EVP_PKEY_OP_SIGNMSG, |
554 | 0 | "DSA Digest Sign Init"); |
555 | 0 | } |
556 | | |
557 | | static int dsa_digest_signverify_update(void *vpdsactx, const unsigned char *data, |
558 | | size_t datalen) |
559 | 0 | { |
560 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
561 | |
|
562 | 0 | if (pdsactx == NULL) |
563 | 0 | return 0; |
564 | | /* Sigalg implementations shouldn't do digest_sign */ |
565 | 0 | if (pdsactx->flag_sigalg) |
566 | 0 | return 0; |
567 | | |
568 | 0 | return dsa_signverify_message_update(vpdsactx, data, datalen); |
569 | 0 | } |
570 | | |
571 | | static int dsa_digest_sign_final(void *vpdsactx, unsigned char *sig, |
572 | | size_t *siglen, size_t sigsize) |
573 | 0 | { |
574 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
575 | 0 | int ok = 0; |
576 | |
|
577 | 0 | if (pdsactx == NULL) |
578 | 0 | return 0; |
579 | | /* Sigalg implementations shouldn't do digest_sign */ |
580 | 0 | if (pdsactx->flag_sigalg) |
581 | 0 | return 0; |
582 | | |
583 | 0 | ok = dsa_sign_message_final(pdsactx, sig, siglen, sigsize); |
584 | |
|
585 | 0 | pdsactx->flag_allow_md = 1; |
586 | |
|
587 | 0 | return ok; |
588 | 0 | } |
589 | | |
590 | | static int dsa_digest_verify_init(void *vpdsactx, const char *mdname, |
591 | | void *vdsa, const OSSL_PARAM params[]) |
592 | 0 | { |
593 | 0 | return dsa_digest_signverify_init(vpdsactx, mdname, vdsa, params, |
594 | 0 | EVP_PKEY_OP_VERIFYMSG, |
595 | 0 | "DSA Digest Verify Init"); |
596 | 0 | } |
597 | | |
598 | | int dsa_digest_verify_final(void *vpdsactx, const unsigned char *sig, |
599 | | size_t siglen) |
600 | 0 | { |
601 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
602 | 0 | int ok = 0; |
603 | |
|
604 | 0 | if (pdsactx == NULL) |
605 | 0 | return 0; |
606 | | /* Sigalg implementations shouldn't do digest_verify */ |
607 | 0 | if (pdsactx->flag_sigalg) |
608 | 0 | return 0; |
609 | | |
610 | 0 | if (dsa_verify_set_sig(pdsactx, sig, siglen)) |
611 | 0 | ok = dsa_verify_message_final(vpdsactx); |
612 | |
|
613 | 0 | pdsactx->flag_allow_md = 1; |
614 | |
|
615 | 0 | return ok; |
616 | 0 | } |
617 | | |
618 | | static void dsa_freectx(void *vpdsactx) |
619 | 0 | { |
620 | 0 | PROV_DSA_CTX *ctx = (PROV_DSA_CTX *)vpdsactx; |
621 | |
|
622 | 0 | EVP_MD_CTX_free(ctx->mdctx); |
623 | 0 | EVP_MD_free(ctx->md); |
624 | 0 | OPENSSL_free(ctx->sig); |
625 | 0 | OPENSSL_free(ctx->propq); |
626 | 0 | DSA_free(ctx->dsa); |
627 | 0 | OPENSSL_free(ctx); |
628 | 0 | } |
629 | | |
630 | | static void *dsa_dupctx(void *vpdsactx) |
631 | 0 | { |
632 | 0 | PROV_DSA_CTX *srcctx = (PROV_DSA_CTX *)vpdsactx; |
633 | 0 | PROV_DSA_CTX *dstctx; |
634 | |
|
635 | 0 | if (!ossl_prov_is_running()) |
636 | 0 | return NULL; |
637 | | |
638 | 0 | dstctx = OPENSSL_zalloc(sizeof(*srcctx)); |
639 | 0 | if (dstctx == NULL) |
640 | 0 | return NULL; |
641 | | |
642 | 0 | *dstctx = *srcctx; |
643 | 0 | dstctx->dsa = NULL; |
644 | 0 | dstctx->propq = NULL; |
645 | |
|
646 | 0 | if (srcctx->dsa != NULL && !DSA_up_ref(srcctx->dsa)) |
647 | 0 | goto err; |
648 | 0 | dstctx->dsa = srcctx->dsa; |
649 | |
|
650 | 0 | if (srcctx->md != NULL && !EVP_MD_up_ref(srcctx->md)) |
651 | 0 | goto err; |
652 | 0 | dstctx->md = srcctx->md; |
653 | |
|
654 | 0 | if (srcctx->mdctx != NULL) { |
655 | 0 | dstctx->mdctx = EVP_MD_CTX_new(); |
656 | 0 | if (dstctx->mdctx == NULL |
657 | 0 | || !EVP_MD_CTX_copy_ex(dstctx->mdctx, srcctx->mdctx)) |
658 | 0 | goto err; |
659 | 0 | } |
660 | | |
661 | 0 | if (srcctx->propq != NULL) { |
662 | 0 | dstctx->propq = OPENSSL_strdup(srcctx->propq); |
663 | 0 | if (dstctx->propq == NULL) |
664 | 0 | goto err; |
665 | 0 | } |
666 | | |
667 | 0 | return dstctx; |
668 | 0 | err: |
669 | 0 | dsa_freectx(dstctx); |
670 | 0 | return NULL; |
671 | 0 | } |
672 | | |
673 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
674 | | #ifndef dsa_get_ctx_params_list |
675 | | static const OSSL_PARAM dsa_get_ctx_params_list[] = { |
676 | | OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_ALGORITHM_ID, NULL, 0), |
677 | | OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0), |
678 | | OSSL_PARAM_uint(OSSL_SIGNATURE_PARAM_NONCE_TYPE, NULL), |
679 | | # if defined(FIPS_MODULE) |
680 | | OSSL_PARAM_int(OSSL_SIGNATURE_PARAM_FIPS_APPROVED_INDICATOR, NULL), |
681 | | # endif |
682 | | OSSL_PARAM_END |
683 | | }; |
684 | | #endif |
685 | | |
686 | | #ifndef dsa_get_ctx_params_st |
687 | | struct dsa_get_ctx_params_st { |
688 | | OSSL_PARAM *algid; |
689 | | OSSL_PARAM *digest; |
690 | | # if defined(FIPS_MODULE) |
691 | | OSSL_PARAM *ind; |
692 | | # endif |
693 | | OSSL_PARAM *nonce; |
694 | | }; |
695 | | #endif |
696 | | |
697 | | #ifndef dsa_get_ctx_params_decoder |
698 | | static int dsa_get_ctx_params_decoder |
699 | | (const OSSL_PARAM *p, struct dsa_get_ctx_params_st *r) |
700 | 0 | { |
701 | 0 | const char *s; |
702 | |
|
703 | 0 | memset(r, 0, sizeof(*r)); |
704 | 0 | if (p != NULL) |
705 | 0 | for (; (s = p->key) != NULL; p++) |
706 | 0 | switch(s[0]) { |
707 | 0 | default: |
708 | 0 | break; |
709 | 0 | case 'a': |
710 | 0 | if (ossl_likely(strcmp("lgorithm-id", s + 1) == 0)) { |
711 | | /* SIGNATURE_PARAM_ALGORITHM_ID */ |
712 | 0 | if (ossl_unlikely(r->algid != NULL)) { |
713 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
714 | 0 | "param %s is repeated", s); |
715 | 0 | return 0; |
716 | 0 | } |
717 | 0 | r->algid = (OSSL_PARAM *)p; |
718 | 0 | } |
719 | 0 | break; |
720 | 0 | case 'd': |
721 | 0 | if (ossl_likely(strcmp("igest", s + 1) == 0)) { |
722 | | /* SIGNATURE_PARAM_DIGEST */ |
723 | 0 | if (ossl_unlikely(r->digest != NULL)) { |
724 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
725 | 0 | "param %s is repeated", s); |
726 | 0 | return 0; |
727 | 0 | } |
728 | 0 | r->digest = (OSSL_PARAM *)p; |
729 | 0 | } |
730 | 0 | break; |
731 | 0 | case 'f': |
732 | | # if defined(FIPS_MODULE) |
733 | | if (ossl_likely(strcmp("ips-indicator", s + 1) == 0)) { |
734 | | /* SIGNATURE_PARAM_FIPS_APPROVED_INDICATOR */ |
735 | | if (ossl_unlikely(r->ind != NULL)) { |
736 | | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
737 | | "param %s is repeated", s); |
738 | | return 0; |
739 | | } |
740 | | r->ind = (OSSL_PARAM *)p; |
741 | | } |
742 | | # endif |
743 | 0 | break; |
744 | 0 | case 'n': |
745 | 0 | if (ossl_likely(strcmp("once-type", s + 1) == 0)) { |
746 | | /* SIGNATURE_PARAM_NONCE_TYPE */ |
747 | 0 | if (ossl_unlikely(r->nonce != NULL)) { |
748 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
749 | 0 | "param %s is repeated", s); |
750 | 0 | return 0; |
751 | 0 | } |
752 | 0 | r->nonce = (OSSL_PARAM *)p; |
753 | 0 | } |
754 | 0 | } |
755 | 0 | return 1; |
756 | 0 | } |
757 | | #endif |
758 | | /* End of machine generated */ |
759 | | |
760 | | static int dsa_get_ctx_params(void *vpdsactx, OSSL_PARAM *params) |
761 | 0 | { |
762 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
763 | 0 | struct dsa_get_ctx_params_st p; |
764 | |
|
765 | 0 | if (pdsactx == NULL || !dsa_get_ctx_params_decoder(params, &p)) |
766 | 0 | return 0; |
767 | | |
768 | 0 | if (p.algid != NULL |
769 | 0 | && !OSSL_PARAM_set_octet_string(p.algid, |
770 | 0 | pdsactx->aid_len == 0 ? NULL : pdsactx->aid_buf, |
771 | 0 | pdsactx->aid_len)) |
772 | 0 | return 0; |
773 | | |
774 | 0 | if (p.digest != NULL && !OSSL_PARAM_set_utf8_string(p.digest, pdsactx->mdname)) |
775 | 0 | return 0; |
776 | | |
777 | 0 | if (p.nonce != NULL && !OSSL_PARAM_set_uint(p.nonce, pdsactx->nonce_type)) |
778 | 0 | return 0; |
779 | | |
780 | 0 | if (!OSSL_FIPS_IND_GET_CTX_FROM_PARAM(pdsactx, p.ind)) |
781 | 0 | return 0; |
782 | | |
783 | 0 | return 1; |
784 | 0 | } |
785 | | |
786 | | static const OSSL_PARAM *dsa_gettable_ctx_params(ossl_unused void *ctx, |
787 | | ossl_unused void *provctx) |
788 | 0 | { |
789 | 0 | return dsa_get_ctx_params_list; |
790 | 0 | } |
791 | | |
792 | | struct dsa_all_set_ctx_params_st { |
793 | | OSSL_PARAM *digest; /* dsa_set_ctx_params */ |
794 | | OSSL_PARAM *propq; /* dsa_set_ctx_params */ |
795 | | #ifdef FIPS_MODULE |
796 | | OSSL_PARAM *ind_d; |
797 | | OSSL_PARAM *ind_k; |
798 | | OSSL_PARAM *ind_sign; |
799 | | #endif |
800 | | OSSL_PARAM *nonce; |
801 | | OSSL_PARAM *sig; /* dsa_sigalg_set_ctx_params */ |
802 | | }; |
803 | | |
804 | | /** |
805 | | * @brief Setup common params for dsa_set_ctx_params and dsa_sigalg_set_ctx_params |
806 | | * The caller is responsible for checking |vpdsactx| is not NULL and |params| |
807 | | * is not empty. |
808 | | */ |
809 | | static int dsa_common_set_ctx_params(PROV_DSA_CTX *pdsactx, |
810 | | const struct dsa_all_set_ctx_params_st *p) |
811 | 0 | { |
812 | 0 | if (!OSSL_FIPS_IND_SET_CTX_FROM_PARAM(pdsactx, OSSL_FIPS_IND_SETTABLE0, |
813 | 0 | p->ind_k)) |
814 | 0 | return 0; |
815 | 0 | if (!OSSL_FIPS_IND_SET_CTX_FROM_PARAM(pdsactx, OSSL_FIPS_IND_SETTABLE1, |
816 | 0 | p->ind_d)) |
817 | 0 | return 0; |
818 | 0 | if (!OSSL_FIPS_IND_SET_CTX_FROM_PARAM(pdsactx, OSSL_FIPS_IND_SETTABLE2, |
819 | 0 | p->ind_sign)) |
820 | 0 | return 0; |
821 | | |
822 | 0 | if (p->nonce != NULL |
823 | 0 | && !OSSL_PARAM_get_uint(p->nonce, &pdsactx->nonce_type)) |
824 | 0 | return 0; |
825 | 0 | return 1; |
826 | 0 | } |
827 | | |
828 | | #define dsa_set_ctx_params_st dsa_all_set_ctx_params_st |
829 | | |
830 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
831 | | #ifndef dsa_set_ctx_params_list |
832 | | static const OSSL_PARAM dsa_set_ctx_params_list[] = { |
833 | | OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0), |
834 | | OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PROPERTIES, NULL, 0), |
835 | | OSSL_PARAM_uint(OSSL_SIGNATURE_PARAM_NONCE_TYPE, NULL), |
836 | | # if defined(FIPS_MODULE) |
837 | | OSSL_PARAM_int(OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK, NULL), |
838 | | # endif |
839 | | # if defined(FIPS_MODULE) |
840 | | OSSL_PARAM_int(OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK, NULL), |
841 | | # endif |
842 | | # if defined(FIPS_MODULE) |
843 | | OSSL_PARAM_int(OSSL_SIGNATURE_PARAM_FIPS_SIGN_CHECK, NULL), |
844 | | # endif |
845 | | OSSL_PARAM_END |
846 | | }; |
847 | | #endif |
848 | | |
849 | | #ifndef dsa_set_ctx_params_st |
850 | | struct dsa_set_ctx_params_st { |
851 | | OSSL_PARAM *digest; |
852 | | # if defined(FIPS_MODULE) |
853 | | OSSL_PARAM *ind_d; |
854 | | # endif |
855 | | # if defined(FIPS_MODULE) |
856 | | OSSL_PARAM *ind_k; |
857 | | # endif |
858 | | # if defined(FIPS_MODULE) |
859 | | OSSL_PARAM *ind_sign; |
860 | | # endif |
861 | | OSSL_PARAM *nonce; |
862 | | OSSL_PARAM *propq; |
863 | | }; |
864 | | #endif |
865 | | |
866 | | #ifndef dsa_set_ctx_params_decoder |
867 | | static int dsa_set_ctx_params_decoder |
868 | | (const OSSL_PARAM *p, struct dsa_set_ctx_params_st *r) |
869 | 0 | { |
870 | 0 | const char *s; |
871 | |
|
872 | 0 | memset(r, 0, sizeof(*r)); |
873 | 0 | if (p != NULL) |
874 | 0 | for (; (s = p->key) != NULL; p++) |
875 | 0 | switch(s[0]) { |
876 | 0 | default: |
877 | 0 | break; |
878 | 0 | case 'd': |
879 | 0 | switch(s[1]) { |
880 | 0 | default: |
881 | 0 | break; |
882 | 0 | case 'i': |
883 | 0 | switch(s[2]) { |
884 | 0 | default: |
885 | 0 | break; |
886 | 0 | case 'g': |
887 | 0 | switch(s[3]) { |
888 | 0 | default: |
889 | 0 | break; |
890 | 0 | case 'e': |
891 | 0 | switch(s[4]) { |
892 | 0 | default: |
893 | 0 | break; |
894 | 0 | case 's': |
895 | 0 | switch(s[5]) { |
896 | 0 | default: |
897 | 0 | break; |
898 | 0 | case 't': |
899 | 0 | switch(s[6]) { |
900 | 0 | default: |
901 | 0 | break; |
902 | 0 | case '-': |
903 | | # if defined(FIPS_MODULE) |
904 | | if (ossl_likely(strcmp("check", s + 7) == 0)) { |
905 | | /* SIGNATURE_PARAM_FIPS_DIGEST_CHECK */ |
906 | | if (ossl_unlikely(r->ind_d != NULL)) { |
907 | | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
908 | | "param %s is repeated", s); |
909 | | return 0; |
910 | | } |
911 | | r->ind_d = (OSSL_PARAM *)p; |
912 | | } |
913 | | # endif |
914 | 0 | break; |
915 | 0 | case '\0': |
916 | 0 | if (ossl_unlikely(r->digest != NULL)) { |
917 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
918 | 0 | "param %s is repeated", s); |
919 | 0 | return 0; |
920 | 0 | } |
921 | 0 | r->digest = (OSSL_PARAM *)p; |
922 | 0 | } |
923 | 0 | } |
924 | 0 | } |
925 | 0 | } |
926 | 0 | } |
927 | 0 | } |
928 | 0 | break; |
929 | 0 | case 'k': |
930 | | # if defined(FIPS_MODULE) |
931 | | if (ossl_likely(strcmp("ey-check", s + 1) == 0)) { |
932 | | /* SIGNATURE_PARAM_FIPS_KEY_CHECK */ |
933 | | if (ossl_unlikely(r->ind_k != NULL)) { |
934 | | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
935 | | "param %s is repeated", s); |
936 | | return 0; |
937 | | } |
938 | | r->ind_k = (OSSL_PARAM *)p; |
939 | | } |
940 | | # endif |
941 | 0 | break; |
942 | 0 | case 'n': |
943 | 0 | if (ossl_likely(strcmp("once-type", s + 1) == 0)) { |
944 | | /* SIGNATURE_PARAM_NONCE_TYPE */ |
945 | 0 | if (ossl_unlikely(r->nonce != NULL)) { |
946 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
947 | 0 | "param %s is repeated", s); |
948 | 0 | return 0; |
949 | 0 | } |
950 | 0 | r->nonce = (OSSL_PARAM *)p; |
951 | 0 | } |
952 | 0 | break; |
953 | 0 | case 'p': |
954 | 0 | if (ossl_likely(strcmp("roperties", s + 1) == 0)) { |
955 | | /* SIGNATURE_PARAM_PROPERTIES */ |
956 | 0 | if (ossl_unlikely(r->propq != NULL)) { |
957 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
958 | 0 | "param %s is repeated", s); |
959 | 0 | return 0; |
960 | 0 | } |
961 | 0 | r->propq = (OSSL_PARAM *)p; |
962 | 0 | } |
963 | 0 | break; |
964 | 0 | case 's': |
965 | | # if defined(FIPS_MODULE) |
966 | | if (ossl_likely(strcmp("ign-check", s + 1) == 0)) { |
967 | | /* SIGNATURE_PARAM_FIPS_SIGN_CHECK */ |
968 | | if (ossl_unlikely(r->ind_sign != NULL)) { |
969 | | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
970 | | "param %s is repeated", s); |
971 | | return 0; |
972 | | } |
973 | | r->ind_sign = (OSSL_PARAM *)p; |
974 | | } |
975 | | # endif |
976 | 0 | break; |
977 | 0 | } |
978 | 0 | return 1; |
979 | 0 | } |
980 | | #endif |
981 | | /* End of machine generated */ |
982 | | |
983 | | static int dsa_set_ctx_params(void *vpdsactx, const OSSL_PARAM params[]) |
984 | 0 | { |
985 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
986 | 0 | struct dsa_all_set_ctx_params_st p; |
987 | 0 | int ret; |
988 | |
|
989 | 0 | if (pdsactx == NULL || !dsa_set_ctx_params_decoder(params, &p)) |
990 | 0 | return 0; |
991 | | |
992 | 0 | if ((ret = dsa_common_set_ctx_params(pdsactx, &p)) <= 0) |
993 | 0 | return ret; |
994 | | |
995 | 0 | if (p.digest != NULL) { |
996 | 0 | char mdname[OSSL_MAX_NAME_SIZE] = "", *pmdname = mdname; |
997 | 0 | char mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmdprops = mdprops; |
998 | |
|
999 | 0 | if (!OSSL_PARAM_get_utf8_string(p.digest, &pmdname, sizeof(mdname))) |
1000 | 0 | return 0; |
1001 | 0 | if (p.propq != NULL |
1002 | 0 | && !OSSL_PARAM_get_utf8_string(p.propq, &pmdprops, sizeof(mdprops))) |
1003 | 0 | return 0; |
1004 | 0 | if (!dsa_setup_md(pdsactx, mdname, mdprops, "DSA Set Ctx")) |
1005 | 0 | return 0; |
1006 | 0 | } |
1007 | 0 | return 1; |
1008 | 0 | } |
1009 | | |
1010 | | static const OSSL_PARAM settable_ctx_params_no_digest[] = { |
1011 | | OSSL_PARAM_END |
1012 | | }; |
1013 | | |
1014 | | static const OSSL_PARAM *dsa_settable_ctx_params(void *vpdsactx, |
1015 | | ossl_unused void *provctx) |
1016 | 0 | { |
1017 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
1018 | |
|
1019 | 0 | if (pdsactx != NULL && !pdsactx->flag_allow_md) |
1020 | 0 | return settable_ctx_params_no_digest; |
1021 | 0 | return dsa_set_ctx_params_list; |
1022 | 0 | } |
1023 | | |
1024 | | static int dsa_get_ctx_md_params(void *vpdsactx, OSSL_PARAM *params) |
1025 | 0 | { |
1026 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
1027 | |
|
1028 | 0 | if (pdsactx->mdctx == NULL) |
1029 | 0 | return 0; |
1030 | | |
1031 | 0 | return EVP_MD_CTX_get_params(pdsactx->mdctx, params); |
1032 | 0 | } |
1033 | | |
1034 | | static const OSSL_PARAM *dsa_gettable_ctx_md_params(void *vpdsactx) |
1035 | 0 | { |
1036 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
1037 | |
|
1038 | 0 | if (pdsactx->md == NULL) |
1039 | 0 | return 0; |
1040 | | |
1041 | 0 | return EVP_MD_gettable_ctx_params(pdsactx->md); |
1042 | 0 | } |
1043 | | |
1044 | | static int dsa_set_ctx_md_params(void *vpdsactx, const OSSL_PARAM params[]) |
1045 | 0 | { |
1046 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
1047 | |
|
1048 | 0 | if (pdsactx->mdctx == NULL) |
1049 | 0 | return 0; |
1050 | | |
1051 | 0 | return EVP_MD_CTX_set_params(pdsactx->mdctx, params); |
1052 | 0 | } |
1053 | | |
1054 | | static const OSSL_PARAM *dsa_settable_ctx_md_params(void *vpdsactx) |
1055 | 0 | { |
1056 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
1057 | |
|
1058 | 0 | if (pdsactx->md == NULL) |
1059 | 0 | return 0; |
1060 | | |
1061 | 0 | return EVP_MD_settable_ctx_params(pdsactx->md); |
1062 | 0 | } |
1063 | | |
1064 | | const OSSL_DISPATCH ossl_dsa_signature_functions[] = { |
1065 | | { OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))dsa_newctx }, |
1066 | | { OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))dsa_sign_init }, |
1067 | | { OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))dsa_sign }, |
1068 | | { OSSL_FUNC_SIGNATURE_VERIFY_INIT, (void (*)(void))dsa_verify_init }, |
1069 | | { OSSL_FUNC_SIGNATURE_VERIFY, (void (*)(void))dsa_verify }, |
1070 | | { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT, |
1071 | | (void (*)(void))dsa_digest_sign_init }, |
1072 | | { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE, |
1073 | | (void (*)(void))dsa_digest_signverify_update }, |
1074 | | { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL, |
1075 | | (void (*)(void))dsa_digest_sign_final }, |
1076 | | { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT, |
1077 | | (void (*)(void))dsa_digest_verify_init }, |
1078 | | { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE, |
1079 | | (void (*)(void))dsa_digest_signverify_update }, |
1080 | | { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL, |
1081 | | (void (*)(void))dsa_digest_verify_final }, |
1082 | | { OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))dsa_freectx }, |
1083 | | { OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))dsa_dupctx }, |
1084 | | { OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, (void (*)(void))dsa_get_ctx_params }, |
1085 | | { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS, |
1086 | | (void (*)(void))dsa_gettable_ctx_params }, |
1087 | | { OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS, (void (*)(void))dsa_set_ctx_params }, |
1088 | | { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS, |
1089 | | (void (*)(void))dsa_settable_ctx_params }, |
1090 | | { OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS, |
1091 | | (void (*)(void))dsa_get_ctx_md_params }, |
1092 | | { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS, |
1093 | | (void (*)(void))dsa_gettable_ctx_md_params }, |
1094 | | { OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS, |
1095 | | (void (*)(void))dsa_set_ctx_md_params }, |
1096 | | { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS, |
1097 | | (void (*)(void))dsa_settable_ctx_md_params }, |
1098 | | OSSL_DISPATCH_END |
1099 | | }; |
1100 | | |
1101 | | /* ------------------------------------------------------------------ */ |
1102 | | |
1103 | | /* |
1104 | | * So called sigalgs (composite DSA+hash) implemented below. They |
1105 | | * are pretty much hard coded. |
1106 | | */ |
1107 | | |
1108 | | static OSSL_FUNC_signature_query_key_types_fn dsa_sigalg_query_key_types; |
1109 | | static OSSL_FUNC_signature_settable_ctx_params_fn dsa_sigalg_settable_ctx_params; |
1110 | | static OSSL_FUNC_signature_set_ctx_params_fn dsa_sigalg_set_ctx_params; |
1111 | | |
1112 | | /* |
1113 | | * dsa_sigalg_signverify_init() is almost like dsa_digest_signverify_init(), |
1114 | | * just doesn't allow fetching an MD from whatever the user chooses. |
1115 | | */ |
1116 | | static int dsa_sigalg_signverify_init(void *vpdsactx, void *vdsa, |
1117 | | OSSL_FUNC_signature_set_ctx_params_fn *set_ctx_params, |
1118 | | const OSSL_PARAM params[], |
1119 | | const char *mdname, |
1120 | | int operation, const char *desc) |
1121 | 0 | { |
1122 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
1123 | |
|
1124 | 0 | if (!ossl_prov_is_running()) |
1125 | 0 | return 0; |
1126 | | |
1127 | 0 | if (!dsa_signverify_init(vpdsactx, vdsa, set_ctx_params, params, operation, |
1128 | 0 | desc)) |
1129 | 0 | return 0; |
1130 | | |
1131 | 0 | if (!dsa_setup_md(pdsactx, mdname, NULL, desc)) |
1132 | 0 | return 0; |
1133 | | |
1134 | 0 | pdsactx->flag_sigalg = 1; |
1135 | 0 | pdsactx->flag_allow_md = 0; |
1136 | |
|
1137 | 0 | if (pdsactx->mdctx == NULL) { |
1138 | 0 | pdsactx->mdctx = EVP_MD_CTX_new(); |
1139 | 0 | if (pdsactx->mdctx == NULL) |
1140 | 0 | goto error; |
1141 | 0 | } |
1142 | | |
1143 | 0 | if (!EVP_DigestInit_ex2(pdsactx->mdctx, pdsactx->md, params)) |
1144 | 0 | goto error; |
1145 | | |
1146 | 0 | return 1; |
1147 | | |
1148 | 0 | error: |
1149 | 0 | EVP_MD_CTX_free(pdsactx->mdctx); |
1150 | 0 | pdsactx->mdctx = NULL; |
1151 | 0 | return 0; |
1152 | 0 | } |
1153 | | |
1154 | | static const char **dsa_sigalg_query_key_types(void) |
1155 | 0 | { |
1156 | 0 | static const char *keytypes[] = { "DSA", NULL }; |
1157 | |
|
1158 | 0 | return keytypes; |
1159 | 0 | } |
1160 | | |
1161 | | #define dsa_sigalg_set_ctx_params_st dsa_all_set_ctx_params_st |
1162 | | |
1163 | | /* Machine generated by util/perl/OpenSSL/paramnames.pm */ |
1164 | | #ifndef dsa_sigalg_set_ctx_params_list |
1165 | | static const OSSL_PARAM dsa_sigalg_set_ctx_params_list[] = { |
1166 | | OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_SIGNATURE, NULL, 0), |
1167 | | OSSL_PARAM_uint(OSSL_SIGNATURE_PARAM_NONCE_TYPE, NULL), |
1168 | | # if defined(FIPS_MODULE) |
1169 | | OSSL_PARAM_int(OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK, NULL), |
1170 | | # endif |
1171 | | # if defined(FIPS_MODULE) |
1172 | | OSSL_PARAM_int(OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK, NULL), |
1173 | | # endif |
1174 | | # if defined(FIPS_MODULE) |
1175 | | OSSL_PARAM_int(OSSL_SIGNATURE_PARAM_FIPS_SIGN_CHECK, NULL), |
1176 | | # endif |
1177 | | OSSL_PARAM_END |
1178 | | }; |
1179 | | #endif |
1180 | | |
1181 | | #ifndef dsa_sigalg_set_ctx_params_st |
1182 | | struct dsa_sigalg_set_ctx_params_st { |
1183 | | # if defined(FIPS_MODULE) |
1184 | | OSSL_PARAM *ind_d; |
1185 | | # endif |
1186 | | # if defined(FIPS_MODULE) |
1187 | | OSSL_PARAM *ind_k; |
1188 | | # endif |
1189 | | # if defined(FIPS_MODULE) |
1190 | | OSSL_PARAM *ind_sign; |
1191 | | # endif |
1192 | | OSSL_PARAM *nonce; |
1193 | | OSSL_PARAM *sig; |
1194 | | }; |
1195 | | #endif |
1196 | | |
1197 | | #ifndef dsa_sigalg_set_ctx_params_decoder |
1198 | | static int dsa_sigalg_set_ctx_params_decoder |
1199 | | (const OSSL_PARAM *p, struct dsa_sigalg_set_ctx_params_st *r) |
1200 | 0 | { |
1201 | 0 | const char *s; |
1202 | |
|
1203 | 0 | memset(r, 0, sizeof(*r)); |
1204 | 0 | if (p != NULL) |
1205 | 0 | for (; (s = p->key) != NULL; p++) |
1206 | 0 | switch(s[0]) { |
1207 | 0 | default: |
1208 | 0 | break; |
1209 | 0 | case 'd': |
1210 | | # if defined(FIPS_MODULE) |
1211 | | if (ossl_likely(strcmp("igest-check", s + 1) == 0)) { |
1212 | | /* SIGNATURE_PARAM_FIPS_DIGEST_CHECK */ |
1213 | | if (ossl_unlikely(r->ind_d != NULL)) { |
1214 | | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
1215 | | "param %s is repeated", s); |
1216 | | return 0; |
1217 | | } |
1218 | | r->ind_d = (OSSL_PARAM *)p; |
1219 | | } |
1220 | | # endif |
1221 | 0 | break; |
1222 | 0 | case 'k': |
1223 | | # if defined(FIPS_MODULE) |
1224 | | if (ossl_likely(strcmp("ey-check", s + 1) == 0)) { |
1225 | | /* SIGNATURE_PARAM_FIPS_KEY_CHECK */ |
1226 | | if (ossl_unlikely(r->ind_k != NULL)) { |
1227 | | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
1228 | | "param %s is repeated", s); |
1229 | | return 0; |
1230 | | } |
1231 | | r->ind_k = (OSSL_PARAM *)p; |
1232 | | } |
1233 | | # endif |
1234 | 0 | break; |
1235 | 0 | case 'n': |
1236 | 0 | if (ossl_likely(strcmp("once-type", s + 1) == 0)) { |
1237 | | /* SIGNATURE_PARAM_NONCE_TYPE */ |
1238 | 0 | if (ossl_unlikely(r->nonce != NULL)) { |
1239 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
1240 | 0 | "param %s is repeated", s); |
1241 | 0 | return 0; |
1242 | 0 | } |
1243 | 0 | r->nonce = (OSSL_PARAM *)p; |
1244 | 0 | } |
1245 | 0 | break; |
1246 | 0 | case 's': |
1247 | 0 | switch(s[1]) { |
1248 | 0 | default: |
1249 | 0 | break; |
1250 | 0 | case 'i': |
1251 | 0 | switch(s[2]) { |
1252 | 0 | default: |
1253 | 0 | break; |
1254 | 0 | case 'g': |
1255 | 0 | switch(s[3]) { |
1256 | 0 | default: |
1257 | 0 | break; |
1258 | 0 | case 'n': |
1259 | 0 | switch(s[4]) { |
1260 | 0 | default: |
1261 | 0 | break; |
1262 | 0 | case '-': |
1263 | | # if defined(FIPS_MODULE) |
1264 | | if (ossl_likely(strcmp("check", s + 5) == 0)) { |
1265 | | /* SIGNATURE_PARAM_FIPS_SIGN_CHECK */ |
1266 | | if (ossl_unlikely(r->ind_sign != NULL)) { |
1267 | | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
1268 | | "param %s is repeated", s); |
1269 | | return 0; |
1270 | | } |
1271 | | r->ind_sign = (OSSL_PARAM *)p; |
1272 | | } |
1273 | | # endif |
1274 | 0 | break; |
1275 | 0 | case 'a': |
1276 | 0 | if (ossl_likely(strcmp("ture", s + 5) == 0)) { |
1277 | | /* SIGNATURE_PARAM_SIGNATURE */ |
1278 | 0 | if (ossl_unlikely(r->sig != NULL)) { |
1279 | 0 | ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER, |
1280 | 0 | "param %s is repeated", s); |
1281 | 0 | return 0; |
1282 | 0 | } |
1283 | 0 | r->sig = (OSSL_PARAM *)p; |
1284 | 0 | } |
1285 | 0 | } |
1286 | 0 | } |
1287 | 0 | } |
1288 | 0 | } |
1289 | 0 | } |
1290 | 0 | return 1; |
1291 | 0 | } |
1292 | | #endif |
1293 | | /* End of machine generated */ |
1294 | | |
1295 | | static const OSSL_PARAM *dsa_sigalg_settable_ctx_params(void *vpdsactx, |
1296 | | ossl_unused void *provctx) |
1297 | 0 | { |
1298 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
1299 | |
|
1300 | 0 | if (pdsactx != NULL && pdsactx->operation == EVP_PKEY_OP_VERIFYMSG) |
1301 | 0 | return dsa_sigalg_set_ctx_params_list; |
1302 | 0 | return NULL; |
1303 | 0 | } |
1304 | | |
1305 | | static int dsa_sigalg_set_ctx_params(void *vpdsactx, const OSSL_PARAM params[]) |
1306 | 0 | { |
1307 | 0 | PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; |
1308 | 0 | struct dsa_all_set_ctx_params_st p; |
1309 | 0 | int ret; |
1310 | |
|
1311 | 0 | if (pdsactx == NULL || !dsa_sigalg_set_ctx_params_decoder(params, &p)) |
1312 | 0 | return 0; |
1313 | | |
1314 | 0 | if ((ret = dsa_common_set_ctx_params(pdsactx, &p)) <= 0) |
1315 | 0 | return ret; |
1316 | | |
1317 | 0 | if (pdsactx->operation == EVP_PKEY_OP_VERIFYMSG) { |
1318 | 0 | if (p.sig != NULL) { |
1319 | 0 | OPENSSL_free(pdsactx->sig); |
1320 | 0 | pdsactx->sig = NULL; |
1321 | 0 | pdsactx->siglen = 0; |
1322 | 0 | if (!OSSL_PARAM_get_octet_string(p.sig, (void **)&pdsactx->sig, |
1323 | 0 | 0, &pdsactx->siglen)) |
1324 | 0 | return 0; |
1325 | 0 | } |
1326 | 0 | } |
1327 | 0 | return 1; |
1328 | 0 | } |
1329 | | |
1330 | | #define IMPL_DSA_SIGALG(md, MD) \ |
1331 | | static OSSL_FUNC_signature_sign_init_fn dsa_##md##_sign_init; \ |
1332 | | static OSSL_FUNC_signature_sign_message_init_fn \ |
1333 | | dsa_##md##_sign_message_init; \ |
1334 | | static OSSL_FUNC_signature_verify_init_fn dsa_##md##_verify_init; \ |
1335 | | static OSSL_FUNC_signature_verify_message_init_fn \ |
1336 | | dsa_##md##_verify_message_init; \ |
1337 | | \ |
1338 | | static int \ |
1339 | | dsa_##md##_sign_init(void *vpdsactx, void *vdsa, \ |
1340 | | const OSSL_PARAM params[]) \ |
1341 | 0 | { \ |
1342 | 0 | static const char desc[] = "DSA-" MD " Sign Init"; \ |
1343 | 0 | \ |
1344 | 0 | return dsa_sigalg_signverify_init(vpdsactx, vdsa, \ |
1345 | 0 | dsa_sigalg_set_ctx_params, \ |
1346 | 0 | params, MD, \ |
1347 | 0 | EVP_PKEY_OP_SIGN, \ |
1348 | 0 | desc); \ |
1349 | 0 | } \ Unexecuted instantiation: dsa_sig.c:dsa_sha1_sign_init Unexecuted instantiation: dsa_sig.c:dsa_sha224_sign_init Unexecuted instantiation: dsa_sig.c:dsa_sha256_sign_init Unexecuted instantiation: dsa_sig.c:dsa_sha384_sign_init Unexecuted instantiation: dsa_sig.c:dsa_sha512_sign_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_224_sign_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_256_sign_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_384_sign_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_512_sign_init |
1350 | | \ |
1351 | | static int \ |
1352 | | dsa_##md##_sign_message_init(void *vpdsactx, void *vdsa, \ |
1353 | | const OSSL_PARAM params[]) \ |
1354 | 0 | { \ |
1355 | 0 | static const char desc[] = "DSA-" MD " Sign Message Init"; \ |
1356 | 0 | \ |
1357 | 0 | return dsa_sigalg_signverify_init(vpdsactx, vdsa, \ |
1358 | 0 | dsa_sigalg_set_ctx_params, \ |
1359 | 0 | params, MD, \ |
1360 | 0 | EVP_PKEY_OP_SIGNMSG, \ |
1361 | 0 | desc); \ |
1362 | 0 | } \ Unexecuted instantiation: dsa_sig.c:dsa_sha1_sign_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha224_sign_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha256_sign_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha384_sign_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha512_sign_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_224_sign_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_256_sign_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_384_sign_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_512_sign_message_init |
1363 | | \ |
1364 | | static int \ |
1365 | | dsa_##md##_verify_init(void *vpdsactx, void *vdsa, \ |
1366 | | const OSSL_PARAM params[]) \ |
1367 | 0 | { \ |
1368 | 0 | static const char desc[] = "DSA-" MD " Verify Init"; \ |
1369 | 0 | \ |
1370 | 0 | return dsa_sigalg_signverify_init(vpdsactx, vdsa, \ |
1371 | 0 | dsa_sigalg_set_ctx_params, \ |
1372 | 0 | params, MD, \ |
1373 | 0 | EVP_PKEY_OP_VERIFY, \ |
1374 | 0 | desc); \ |
1375 | 0 | } \ Unexecuted instantiation: dsa_sig.c:dsa_sha1_verify_init Unexecuted instantiation: dsa_sig.c:dsa_sha224_verify_init Unexecuted instantiation: dsa_sig.c:dsa_sha256_verify_init Unexecuted instantiation: dsa_sig.c:dsa_sha384_verify_init Unexecuted instantiation: dsa_sig.c:dsa_sha512_verify_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_224_verify_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_256_verify_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_384_verify_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_512_verify_init |
1376 | | \ |
1377 | | static int \ |
1378 | | dsa_##md##_verify_message_init(void *vpdsactx, void *vdsa, \ |
1379 | | const OSSL_PARAM params[]) \ |
1380 | 0 | { \ |
1381 | 0 | static const char desc[] = "DSA-" MD " Verify Message Init"; \ |
1382 | 0 | \ |
1383 | 0 | return dsa_sigalg_signverify_init(vpdsactx, vdsa, \ |
1384 | 0 | dsa_sigalg_set_ctx_params, \ |
1385 | 0 | params, MD, \ |
1386 | 0 | EVP_PKEY_OP_VERIFYMSG, \ |
1387 | 0 | desc); \ |
1388 | 0 | } \ Unexecuted instantiation: dsa_sig.c:dsa_sha1_verify_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha224_verify_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha256_verify_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha384_verify_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha512_verify_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_224_verify_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_256_verify_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_384_verify_message_init Unexecuted instantiation: dsa_sig.c:dsa_sha3_512_verify_message_init |
1389 | | \ |
1390 | | const OSSL_DISPATCH ossl_dsa_##md##_signature_functions[] = { \ |
1391 | | { OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))dsa_newctx }, \ |
1392 | | { OSSL_FUNC_SIGNATURE_SIGN_INIT, \ |
1393 | | (void (*)(void))dsa_##md##_sign_init }, \ |
1394 | | { OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))dsa_sign }, \ |
1395 | | { OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_INIT, \ |
1396 | | (void (*)(void))dsa_##md##_sign_message_init }, \ |
1397 | | { OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_UPDATE, \ |
1398 | | (void (*)(void))dsa_signverify_message_update }, \ |
1399 | | { OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_FINAL, \ |
1400 | | (void (*)(void))dsa_sign_message_final }, \ |
1401 | | { OSSL_FUNC_SIGNATURE_VERIFY_INIT, \ |
1402 | | (void (*)(void))dsa_##md##_verify_init }, \ |
1403 | | { OSSL_FUNC_SIGNATURE_VERIFY, \ |
1404 | | (void (*)(void))dsa_verify }, \ |
1405 | | { OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_INIT, \ |
1406 | | (void (*)(void))dsa_##md##_verify_message_init }, \ |
1407 | | { OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_UPDATE, \ |
1408 | | (void (*)(void))dsa_signverify_message_update }, \ |
1409 | | { OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_FINAL, \ |
1410 | | (void (*)(void))dsa_verify_message_final }, \ |
1411 | | { OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))dsa_freectx }, \ |
1412 | | { OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))dsa_dupctx }, \ |
1413 | | { OSSL_FUNC_SIGNATURE_QUERY_KEY_TYPES, \ |
1414 | | (void (*)(void))dsa_sigalg_query_key_types }, \ |
1415 | | { OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, \ |
1416 | | (void (*)(void))dsa_get_ctx_params }, \ |
1417 | | { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS, \ |
1418 | | (void (*)(void))dsa_gettable_ctx_params }, \ |
1419 | | { OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS, \ |
1420 | | (void (*)(void))dsa_sigalg_set_ctx_params }, \ |
1421 | | { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS, \ |
1422 | | (void (*)(void))dsa_sigalg_settable_ctx_params }, \ |
1423 | | OSSL_DISPATCH_END \ |
1424 | | } |
1425 | | |
1426 | | IMPL_DSA_SIGALG(sha1, "SHA1"); |
1427 | | IMPL_DSA_SIGALG(sha224, "SHA2-224"); |
1428 | | IMPL_DSA_SIGALG(sha256, "SHA2-256"); |
1429 | | IMPL_DSA_SIGALG(sha384, "SHA2-384"); |
1430 | | IMPL_DSA_SIGALG(sha512, "SHA2-512"); |
1431 | | IMPL_DSA_SIGALG(sha3_224, "SHA3-224"); |
1432 | | IMPL_DSA_SIGALG(sha3_256, "SHA3-256"); |
1433 | | IMPL_DSA_SIGALG(sha3_384, "SHA3-384"); |
1434 | | IMPL_DSA_SIGALG(sha3_512, "SHA3-512"); |