Coverage Report

Created: 2026-04-08 06:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/providers/implementations/signature/dsa_sig.c
Line
Count
Source
1
/*
2
 * Copyright 2019-2026 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
 * DSA low level APIs are deprecated for public use, but still ok for
12
 * internal use.
13
 */
14
#include "internal/deprecated.h"
15
16
#include <string.h>
17
18
#include <openssl/crypto.h>
19
#include <openssl/core_dispatch.h>
20
#include <openssl/core_names.h>
21
#include <openssl/err.h>
22
#include <openssl/dsa.h>
23
#include <openssl/params.h>
24
#include <openssl/evp.h>
25
#include <openssl/proverr.h>
26
#include "internal/fips.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
#ifdef FIPS_MODULE
137
    if (!ossl_deferred_self_test(PROV_LIBCTX_OF(provctx),
138
            ST_ID_SIG_DSA_SHA256))
139
        return NULL;
140
#endif
141
142
0
    pdsactx = OPENSSL_zalloc(sizeof(PROV_DSA_CTX));
143
0
    if (pdsactx == NULL)
144
0
        return NULL;
145
146
0
    pdsactx->libctx = PROV_LIBCTX_OF(provctx);
147
0
    pdsactx->flag_allow_md = 1;
148
0
    OSSL_FIPS_IND_INIT(pdsactx)
149
0
    if (propq != NULL && (pdsactx->propq = OPENSSL_strdup(propq)) == NULL) {
150
0
        OPENSSL_free(pdsactx);
151
0
        pdsactx = NULL;
152
0
    }
153
0
    return pdsactx;
154
0
}
155
156
static int dsa_setup_md(PROV_DSA_CTX *ctx,
157
    const char *mdname, const char *mdprops,
158
    const char *desc)
159
0
{
160
0
    EVP_MD *md = NULL;
161
162
0
    if (mdprops == NULL)
163
0
        mdprops = ctx->propq;
164
165
0
    if (mdname != NULL) {
166
0
        WPACKET pkt;
167
0
        int md_nid;
168
0
        size_t mdname_len = strlen(mdname);
169
0
        unsigned char *aid = NULL;
170
171
0
        md = EVP_MD_fetch(ctx->libctx, mdname, mdprops);
172
0
        md_nid = ossl_digest_get_approved_nid(md);
173
174
0
        if (md == NULL) {
175
0
            ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST,
176
0
                "%s could not be fetched", mdname);
177
0
            goto err;
178
0
        }
179
0
        if (md_nid == NID_undef) {
180
0
            ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED,
181
0
                "digest=%s", mdname);
182
0
            goto err;
183
0
        }
184
0
        if (mdname_len >= sizeof(ctx->mdname)) {
185
0
            ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST,
186
0
                "%s exceeds name buffer length", mdname);
187
0
            goto err;
188
0
        }
189
        /* XOF digests don't work */
190
0
        if (EVP_MD_xof(md)) {
191
0
            ERR_raise(ERR_LIB_PROV, PROV_R_XOF_DIGESTS_NOT_ALLOWED);
192
0
            goto err;
193
0
        }
194
#ifdef FIPS_MODULE
195
        {
196
            int sha1_allowed
197
                = ((ctx->operation
198
                       & (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_SIGNMSG))
199
                    == 0);
200
201
            if (!ossl_fips_ind_digest_sign_check(OSSL_FIPS_IND_GET(ctx),
202
                    OSSL_FIPS_IND_SETTABLE1,
203
                    ctx->libctx,
204
                    md_nid, sha1_allowed, 0, desc,
205
                    FIPS_CONFIG_SIGNATURE_DIGEST_CHECK))
206
                goto err;
207
        }
208
#endif
209
210
0
        if (!ctx->flag_allow_md) {
211
0
            if (ctx->mdname[0] != '\0'
212
0
                && !EVP_MD_is_a(md, ctx->mdname)) {
213
0
                ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED,
214
0
                    "digest %s != %s", mdname, ctx->mdname);
215
0
                goto err;
216
0
            }
217
0
            EVP_MD_free(md);
218
0
            return 1;
219
0
        }
220
221
0
        EVP_MD_CTX_free(ctx->mdctx);
222
0
        EVP_MD_free(ctx->md);
223
224
        /*
225
         * We do not care about DER writing errors.
226
         * All it really means is that for some reason, there's no
227
         * AlgorithmIdentifier to be had, but the operation itself is
228
         * still valid, just as long as it's not used to construct
229
         * anything that needs an AlgorithmIdentifier.
230
         */
231
0
        ctx->aid_len = 0;
232
0
        if (WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf))
233
0
            && ossl_DER_w_algorithmIdentifier_DSA_with_MD(&pkt, -1, ctx->dsa,
234
0
                md_nid)
235
0
            && WPACKET_finish(&pkt)) {
236
0
            WPACKET_get_total_written(&pkt, &ctx->aid_len);
237
0
            aid = WPACKET_get_curr(&pkt);
238
0
        }
239
0
        WPACKET_cleanup(&pkt);
240
0
        if (aid != NULL && ctx->aid_len != 0)
241
0
            memmove(ctx->aid_buf, aid, ctx->aid_len);
242
243
0
        ctx->mdctx = NULL;
244
0
        ctx->md = md;
245
0
        OPENSSL_strlcpy(ctx->mdname, mdname, sizeof(ctx->mdname));
246
0
    }
247
248
0
    return 1;
249
0
err:
250
0
    EVP_MD_free(md);
251
0
    return 0;
252
0
}
253
254
#ifdef FIPS_MODULE
255
256
static int dsa_sign_check_approved(PROV_DSA_CTX *ctx, int signing,
257
    const char *desc)
258
{
259
    /* DSA Signing is not approved in FIPS 140-3 */
260
    if (signing
261
        && !OSSL_FIPS_IND_ON_UNAPPROVED(ctx, OSSL_FIPS_IND_SETTABLE2,
262
            ctx->libctx, desc, "DSA",
263
            FIPS_CONFIG_DSA_SIGN_DISABLED))
264
        return 0;
265
    return 1;
266
}
267
268
static int dsa_check_key(PROV_DSA_CTX *ctx, int sign, const char *desc)
269
{
270
    int approved = ossl_dsa_check_key(ctx->dsa, sign);
271
272
    if (!approved) {
273
        if (!OSSL_FIPS_IND_ON_UNAPPROVED(ctx, OSSL_FIPS_IND_SETTABLE0,
274
                ctx->libctx, desc, "DSA Key",
275
                FIPS_CONFIG_SIGNATURE_DIGEST_CHECK)) {
276
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
277
            return 0;
278
        }
279
    }
280
    return 1;
281
}
282
#endif
283
284
static int
285
dsa_signverify_init(void *vpdsactx, void *vdsa,
286
    OSSL_FUNC_signature_set_ctx_params_fn *set_ctx_params,
287
    const OSSL_PARAM params[], int operation,
288
    const char *desc)
289
0
{
290
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
291
292
0
    if (!ossl_prov_is_running()
293
0
        || pdsactx == NULL)
294
0
        return 0;
295
296
0
    if (vdsa == NULL && pdsactx->dsa == NULL) {
297
0
        ERR_raise(ERR_LIB_PROV, PROV_R_NO_KEY_SET);
298
0
        return 0;
299
0
    }
300
301
0
    if (vdsa != NULL) {
302
0
        if (!DSA_up_ref(vdsa))
303
0
            return 0;
304
0
        DSA_free(pdsactx->dsa);
305
0
        pdsactx->dsa = vdsa;
306
0
    }
307
308
0
    pdsactx->operation = operation;
309
310
0
    OSSL_FIPS_IND_SET_APPROVED(pdsactx)
311
0
    if (!set_ctx_params(pdsactx, params))
312
0
        return 0;
313
#ifdef FIPS_MODULE
314
    {
315
        int operation_is_sign
316
            = (operation & (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_SIGNMSG)) != 0;
317
318
        if (!dsa_sign_check_approved(pdsactx, operation_is_sign, desc))
319
            return 0;
320
        if (!dsa_check_key(pdsactx, operation_is_sign, desc))
321
            return 0;
322
    }
323
#endif
324
0
    return 1;
325
0
}
326
327
static int dsa_sign_init(void *vpdsactx, void *vdsa, const OSSL_PARAM params[])
328
0
{
329
0
    return dsa_signverify_init(vpdsactx, vdsa, dsa_set_ctx_params, params,
330
0
        EVP_PKEY_OP_SIGN, "DSA Sign Init");
331
0
}
332
333
/*
334
 * Sign tbs without digesting it first.  This is suitable for "primitive"
335
 * signing and signing the digest of a message, i.e. should be used with
336
 * implementations of the keytype related algorithms.
337
 */
338
static int dsa_sign_directly(void *vpdsactx,
339
    unsigned char *sig, size_t *siglen, size_t sigsize,
340
    const unsigned char *tbs, size_t tbslen)
341
0
{
342
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
343
0
    int ret;
344
0
    unsigned int sltmp;
345
0
    size_t dsasize = DSA_size(pdsactx->dsa);
346
0
    size_t mdsize = dsa_get_md_size(pdsactx);
347
348
0
    if (!ossl_prov_is_running())
349
0
        return 0;
350
351
#ifdef FIPS_MODULE
352
    if (!dsa_sign_check_approved(pdsactx, 1, "Sign"))
353
        return 0;
354
#endif
355
356
0
    if (sig == NULL) {
357
0
        *siglen = dsasize;
358
0
        return 1;
359
0
    }
360
361
0
    if (sigsize < dsasize)
362
0
        return 0;
363
364
0
    if (mdsize != 0 && tbslen != mdsize)
365
0
        return 0;
366
367
0
    ret = ossl_dsa_sign_int(0, tbs, (int)tbslen, sig, &sltmp, pdsactx->dsa,
368
0
        pdsactx->nonce_type, pdsactx->mdname,
369
0
        pdsactx->libctx, pdsactx->propq);
370
0
    if (ret <= 0)
371
0
        return 0;
372
373
0
    *siglen = sltmp;
374
0
    return 1;
375
0
}
376
377
static int dsa_signverify_message_update(void *vpdsactx,
378
    const unsigned char *data,
379
    size_t datalen)
380
0
{
381
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
382
383
0
    if (pdsactx == NULL)
384
0
        return 0;
385
386
0
    return EVP_DigestUpdate(pdsactx->mdctx, data, datalen);
387
0
}
388
389
static int dsa_sign_message_final(void *vpdsactx, unsigned char *sig,
390
    size_t *siglen, size_t sigsize)
391
0
{
392
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
393
0
    unsigned char digest[EVP_MAX_MD_SIZE];
394
0
    unsigned int dlen = 0;
395
396
0
    if (!ossl_prov_is_running() || pdsactx == NULL || pdsactx->mdctx == NULL)
397
0
        return 0;
398
    /*
399
     * If sig is NULL then we're just finding out the sig size. Other fields
400
     * are ignored. Defer to dsa_sign.
401
     */
402
0
    if (sig != NULL) {
403
        /*
404
         * When this function is used through dsa_digest_sign_final(),
405
         * there is the possibility that some externally provided digests
406
         * exceed EVP_MAX_MD_SIZE. We should probably handle that
407
         * somehow but that problem is much larger than just in DSA.
408
         */
409
0
        if (!EVP_DigestFinal_ex(pdsactx->mdctx, digest, &dlen))
410
0
            return 0;
411
0
    }
412
413
0
    return dsa_sign_directly(vpdsactx, sig, siglen, sigsize, digest, dlen);
414
0
}
415
416
/*
417
 * If signing a message, digest tbs and sign the result.
418
 * Otherwise, sign tbs directly.
419
 */
420
static int dsa_sign(void *vpdsactx, unsigned char *sig, size_t *siglen,
421
    size_t sigsize, const unsigned char *tbs, size_t tbslen)
422
0
{
423
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
424
425
0
    if (pdsactx->operation == EVP_PKEY_OP_SIGNMSG) {
426
        /*
427
         * If |sig| is NULL, the caller is only looking for the sig length.
428
         * DO NOT update the input in this case.
429
         */
430
0
        if (sig == NULL)
431
0
            return dsa_sign_message_final(pdsactx, sig, siglen, sigsize);
432
433
0
        if (dsa_signverify_message_update(pdsactx, tbs, tbslen) <= 0)
434
0
            return 0;
435
0
        return dsa_sign_message_final(pdsactx, sig, siglen, sigsize);
436
0
    }
437
0
    return dsa_sign_directly(pdsactx, sig, siglen, sigsize, tbs, tbslen);
438
0
}
439
440
static int dsa_verify_init(void *vpdsactx, void *vdsa,
441
    const OSSL_PARAM params[])
442
0
{
443
0
    return dsa_signverify_init(vpdsactx, vdsa, dsa_set_ctx_params, params,
444
0
        EVP_PKEY_OP_VERIFY, "DSA Verify Init");
445
0
}
446
447
static int dsa_verify_directly(void *vpdsactx,
448
    const unsigned char *sig, size_t siglen,
449
    const unsigned char *tbs, size_t tbslen)
450
0
{
451
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
452
0
    size_t mdsize = dsa_get_md_size(pdsactx);
453
454
0
    if (!ossl_prov_is_running() || (mdsize != 0 && tbslen != mdsize))
455
0
        return 0;
456
457
0
    return DSA_verify(0, tbs, (int)tbslen, sig, (int)siglen, pdsactx->dsa);
458
0
}
459
460
static int dsa_verify_set_sig(void *vpdsactx,
461
    const unsigned char *sig, size_t siglen)
462
0
{
463
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
464
0
    OSSL_PARAM params[2];
465
466
0
    params[0] = OSSL_PARAM_construct_octet_string(OSSL_SIGNATURE_PARAM_SIGNATURE,
467
0
        (unsigned char *)sig, siglen);
468
0
    params[1] = OSSL_PARAM_construct_end();
469
0
    return dsa_sigalg_set_ctx_params(pdsactx, params);
470
0
}
471
472
static int dsa_verify_message_final(void *vpdsactx)
473
0
{
474
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
475
0
    unsigned char digest[EVP_MAX_MD_SIZE];
476
0
    unsigned int dlen = 0;
477
478
0
    if (!ossl_prov_is_running())
479
0
        return 0;
480
481
0
    if (pdsactx == NULL || pdsactx->mdctx == NULL)
482
0
        return 0;
483
484
    /*
485
     * The digests used here are all known (see dsa_get_md_nid()), so they
486
     * should not exceed the internal buffer size of EVP_MAX_MD_SIZE.
487
     */
488
0
    if (!EVP_DigestFinal_ex(pdsactx->mdctx, digest, &dlen))
489
0
        return 0;
490
491
0
    return dsa_verify_directly(vpdsactx, pdsactx->sig, pdsactx->siglen,
492
0
        digest, dlen);
493
0
}
494
495
/*
496
 * If verifying a message, digest tbs and verify the result.
497
 * Otherwise, verify tbs directly.
498
 */
499
static int dsa_verify(void *vpdsactx,
500
    const unsigned char *sig, size_t siglen,
501
    const unsigned char *tbs, size_t tbslen)
502
0
{
503
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
504
505
0
    if (pdsactx->operation == EVP_PKEY_OP_VERIFYMSG) {
506
0
        if (dsa_verify_set_sig(pdsactx, sig, siglen) <= 0)
507
0
            return 0;
508
0
        if (dsa_signverify_message_update(pdsactx, tbs, tbslen) <= 0)
509
0
            return 0;
510
0
        return dsa_verify_message_final(pdsactx);
511
0
    }
512
0
    return dsa_verify_directly(pdsactx, sig, siglen, tbs, tbslen);
513
0
}
514
515
/* DigestSign/DigestVerify wrappers */
516
517
static int dsa_digest_signverify_init(void *vpdsactx, const char *mdname,
518
    void *vdsa, const OSSL_PARAM params[],
519
    int operation, const char *desc)
520
0
{
521
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
522
523
0
    if (!ossl_prov_is_running())
524
0
        return 0;
525
526
0
    if (!dsa_signverify_init(vpdsactx, vdsa, dsa_set_ctx_params, params,
527
0
            operation, desc))
528
0
        return 0;
529
530
0
    if (mdname != NULL
531
        /* was dsa_setup_md already called in dsa_signverify_init()? */
532
0
        && (mdname[0] == '\0' || OPENSSL_strcasecmp(pdsactx->mdname, mdname) != 0)
533
0
        && !dsa_setup_md(pdsactx, mdname, NULL, desc))
534
0
        return 0;
535
536
0
    pdsactx->flag_allow_md = 0;
537
538
0
    if (pdsactx->mdctx == NULL) {
539
0
        pdsactx->mdctx = EVP_MD_CTX_new();
540
0
        if (pdsactx->mdctx == NULL)
541
0
            goto error;
542
0
    }
543
544
0
    if (!EVP_DigestInit_ex2(pdsactx->mdctx, pdsactx->md, params))
545
0
        goto error;
546
547
0
    return 1;
548
549
0
error:
550
0
    EVP_MD_CTX_free(pdsactx->mdctx);
551
0
    pdsactx->mdctx = NULL;
552
0
    return 0;
553
0
}
554
555
static int dsa_digest_sign_init(void *vpdsactx, const char *mdname,
556
    void *vdsa, const OSSL_PARAM params[])
557
0
{
558
0
    return dsa_digest_signverify_init(vpdsactx, mdname, vdsa, params,
559
0
        EVP_PKEY_OP_SIGNMSG,
560
0
        "DSA Digest Sign Init");
561
0
}
562
563
static int dsa_digest_signverify_update(void *vpdsactx, const unsigned char *data,
564
    size_t datalen)
565
0
{
566
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
567
568
0
    if (pdsactx == NULL)
569
0
        return 0;
570
    /* Sigalg implementations shouldn't do digest_sign */
571
0
    if (pdsactx->flag_sigalg)
572
0
        return 0;
573
574
0
    return dsa_signverify_message_update(vpdsactx, data, datalen);
575
0
}
576
577
static int dsa_digest_sign_final(void *vpdsactx, unsigned char *sig,
578
    size_t *siglen, size_t sigsize)
579
0
{
580
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
581
0
    int ok = 0;
582
583
0
    if (pdsactx == NULL)
584
0
        return 0;
585
    /* Sigalg implementations shouldn't do digest_sign */
586
0
    if (pdsactx->flag_sigalg)
587
0
        return 0;
588
589
0
    ok = dsa_sign_message_final(pdsactx, sig, siglen, sigsize);
590
591
0
    pdsactx->flag_allow_md = 1;
592
593
0
    return ok;
594
0
}
595
596
static int dsa_digest_verify_init(void *vpdsactx, const char *mdname,
597
    void *vdsa, const OSSL_PARAM params[])
598
0
{
599
0
    return dsa_digest_signverify_init(vpdsactx, mdname, vdsa, params,
600
0
        EVP_PKEY_OP_VERIFYMSG,
601
0
        "DSA Digest Verify Init");
602
0
}
603
604
int dsa_digest_verify_final(void *vpdsactx, const unsigned char *sig,
605
    size_t siglen)
606
0
{
607
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
608
0
    int ok = 0;
609
610
0
    if (pdsactx == NULL)
611
0
        return 0;
612
    /* Sigalg implementations shouldn't do digest_verify */
613
0
    if (pdsactx->flag_sigalg)
614
0
        return 0;
615
616
0
    if (dsa_verify_set_sig(pdsactx, sig, siglen))
617
0
        ok = dsa_verify_message_final(vpdsactx);
618
619
0
    pdsactx->flag_allow_md = 1;
620
621
0
    return ok;
622
0
}
623
624
static void dsa_freectx(void *vpdsactx)
625
0
{
626
0
    PROV_DSA_CTX *ctx = (PROV_DSA_CTX *)vpdsactx;
627
628
0
    EVP_MD_CTX_free(ctx->mdctx);
629
0
    EVP_MD_free(ctx->md);
630
0
    OPENSSL_free(ctx->sig);
631
0
    OPENSSL_free(ctx->propq);
632
0
    DSA_free(ctx->dsa);
633
0
    OPENSSL_free(ctx);
634
0
}
635
636
static void *dsa_dupctx(void *vpdsactx)
637
0
{
638
0
    PROV_DSA_CTX *srcctx = (PROV_DSA_CTX *)vpdsactx;
639
0
    PROV_DSA_CTX *dstctx;
640
641
0
    if (!ossl_prov_is_running())
642
0
        return NULL;
643
644
0
    if ((dstctx = OPENSSL_memdup(srcctx, sizeof(*srcctx))) == NULL)
645
0
        return NULL;
646
647
0
    dstctx->dsa = NULL;
648
0
    dstctx->propq = NULL;
649
0
    dstctx->md = NULL;
650
0
    dstctx->mdctx = NULL;
651
0
    dstctx->sig = NULL;
652
653
0
    if (srcctx->dsa != NULL && !DSA_up_ref(srcctx->dsa))
654
0
        goto err;
655
0
    dstctx->dsa = srcctx->dsa;
656
657
0
    if (srcctx->md != NULL && !EVP_MD_up_ref(srcctx->md))
658
0
        goto err;
659
0
    dstctx->md = srcctx->md;
660
661
0
    if (srcctx->mdctx != NULL
662
0
        && (dstctx->mdctx = EVP_MD_CTX_dup(srcctx->mdctx)) == NULL)
663
0
        goto err;
664
0
    if (srcctx->propq != NULL
665
0
        && ((dstctx->propq = OPENSSL_strdup(srcctx->propq)) == NULL))
666
0
        goto err;
667
0
    if (srcctx->sig != NULL
668
0
        && ((dstctx->sig = OPENSSL_memdup(srcctx->sig, srcctx->siglen)) == NULL))
669
0
        goto err;
670
671
0
    return dstctx;
672
0
err:
673
0
    dsa_freectx(dstctx);
674
0
    return NULL;
675
0
}
676
677
struct dsa_all_set_ctx_params_st {
678
    OSSL_PARAM *digest; /* dsa_set_ctx_params */
679
    OSSL_PARAM *propq; /* dsa_set_ctx_params */
680
#ifdef FIPS_MODULE
681
    OSSL_PARAM *ind_d;
682
    OSSL_PARAM *ind_k;
683
    OSSL_PARAM *ind_sign;
684
#endif
685
    OSSL_PARAM *nonce;
686
    OSSL_PARAM *sig; /* dsa_sigalg_set_ctx_params */
687
};
688
689
#define dsa_set_ctx_params_st dsa_all_set_ctx_params_st
690
#define dsa_sigalg_set_ctx_params_st dsa_all_set_ctx_params_st
691
692
#include "providers/implementations/signature/dsa_sig.inc"
693
694
static int dsa_get_ctx_params(void *vpdsactx, OSSL_PARAM *params)
695
0
{
696
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
697
0
    struct dsa_get_ctx_params_st p;
698
699
0
    if (pdsactx == NULL || !dsa_get_ctx_params_decoder(params, &p))
700
0
        return 0;
701
702
0
    if (p.algid != NULL
703
0
        && !OSSL_PARAM_set_octet_string(p.algid,
704
0
            pdsactx->aid_len == 0 ? NULL : pdsactx->aid_buf,
705
0
            pdsactx->aid_len))
706
0
        return 0;
707
708
0
    if (p.digest != NULL && !OSSL_PARAM_set_utf8_string(p.digest, pdsactx->mdname))
709
0
        return 0;
710
711
0
    if (p.nonce != NULL && !OSSL_PARAM_set_uint(p.nonce, pdsactx->nonce_type))
712
0
        return 0;
713
714
0
    if (!OSSL_FIPS_IND_GET_CTX_FROM_PARAM(pdsactx, p.ind))
715
0
        return 0;
716
717
0
    return 1;
718
0
}
719
720
static const OSSL_PARAM *dsa_gettable_ctx_params(ossl_unused void *ctx,
721
    ossl_unused void *provctx)
722
0
{
723
0
    return dsa_get_ctx_params_list;
724
0
}
725
726
/**
727
 * @brief Setup common params for dsa_set_ctx_params and dsa_sigalg_set_ctx_params
728
 * The caller is responsible for checking |vpdsactx| is not NULL and |params|
729
 * is not empty.
730
 */
731
static int dsa_common_set_ctx_params(PROV_DSA_CTX *pdsactx,
732
    const struct dsa_all_set_ctx_params_st *p)
733
0
{
734
0
    if (!OSSL_FIPS_IND_SET_CTX_FROM_PARAM(pdsactx, OSSL_FIPS_IND_SETTABLE0,
735
0
            p->ind_k))
736
0
        return 0;
737
0
    if (!OSSL_FIPS_IND_SET_CTX_FROM_PARAM(pdsactx, OSSL_FIPS_IND_SETTABLE1,
738
0
            p->ind_d))
739
0
        return 0;
740
0
    if (!OSSL_FIPS_IND_SET_CTX_FROM_PARAM(pdsactx, OSSL_FIPS_IND_SETTABLE2,
741
0
            p->ind_sign))
742
0
        return 0;
743
744
0
    if (p->nonce != NULL
745
0
        && !OSSL_PARAM_get_uint(p->nonce, &pdsactx->nonce_type))
746
0
        return 0;
747
0
    return 1;
748
0
}
749
750
static int dsa_set_ctx_params(void *vpdsactx, const OSSL_PARAM params[])
751
0
{
752
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
753
0
    struct dsa_all_set_ctx_params_st p;
754
0
    int ret;
755
756
0
    if (pdsactx == NULL || !dsa_set_ctx_params_decoder(params, &p))
757
0
        return 0;
758
759
0
    if ((ret = dsa_common_set_ctx_params(pdsactx, &p)) <= 0)
760
0
        return ret;
761
762
0
    if (p.digest != NULL) {
763
0
        char mdname[OSSL_MAX_NAME_SIZE] = "", *pmdname = mdname;
764
0
        char mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmdprops = mdprops;
765
766
0
        if (!OSSL_PARAM_get_utf8_string(p.digest, &pmdname, sizeof(mdname)))
767
0
            return 0;
768
0
        if (p.propq != NULL
769
0
            && !OSSL_PARAM_get_utf8_string(p.propq, &pmdprops, sizeof(mdprops)))
770
0
            return 0;
771
0
        if (!dsa_setup_md(pdsactx, mdname, mdprops, "DSA Set Ctx"))
772
0
            return 0;
773
0
    }
774
0
    return 1;
775
0
}
776
777
static const OSSL_PARAM settable_ctx_params_no_digest[] = {
778
    OSSL_PARAM_END
779
};
780
781
static const OSSL_PARAM *dsa_settable_ctx_params(void *vpdsactx,
782
    ossl_unused void *provctx)
783
0
{
784
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
785
786
0
    if (pdsactx != NULL && !pdsactx->flag_allow_md)
787
0
        return settable_ctx_params_no_digest;
788
0
    return dsa_set_ctx_params_list;
789
0
}
790
791
static int dsa_get_ctx_md_params(void *vpdsactx, OSSL_PARAM *params)
792
0
{
793
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
794
795
0
    if (pdsactx->mdctx == NULL)
796
0
        return 0;
797
798
0
    return EVP_MD_CTX_get_params(pdsactx->mdctx, params);
799
0
}
800
801
static const OSSL_PARAM *dsa_gettable_ctx_md_params(void *vpdsactx)
802
0
{
803
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
804
805
0
    if (pdsactx->md == NULL)
806
0
        return 0;
807
808
0
    return EVP_MD_gettable_ctx_params(pdsactx->md);
809
0
}
810
811
static int dsa_set_ctx_md_params(void *vpdsactx, const OSSL_PARAM params[])
812
0
{
813
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
814
815
0
    if (pdsactx->mdctx == NULL)
816
0
        return 0;
817
818
0
    return EVP_MD_CTX_set_params(pdsactx->mdctx, params);
819
0
}
820
821
static const OSSL_PARAM *dsa_settable_ctx_md_params(void *vpdsactx)
822
0
{
823
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
824
825
0
    if (pdsactx->md == NULL)
826
0
        return 0;
827
828
0
    return EVP_MD_settable_ctx_params(pdsactx->md);
829
0
}
830
831
const OSSL_DISPATCH ossl_dsa_signature_functions[] = {
832
    { OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))dsa_newctx },
833
    { OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))dsa_sign_init },
834
    { OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))dsa_sign },
835
    { OSSL_FUNC_SIGNATURE_VERIFY_INIT, (void (*)(void))dsa_verify_init },
836
    { OSSL_FUNC_SIGNATURE_VERIFY, (void (*)(void))dsa_verify },
837
    { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT,
838
        (void (*)(void))dsa_digest_sign_init },
839
    { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE,
840
        (void (*)(void))dsa_digest_signverify_update },
841
    { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL,
842
        (void (*)(void))dsa_digest_sign_final },
843
    { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT,
844
        (void (*)(void))dsa_digest_verify_init },
845
    { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE,
846
        (void (*)(void))dsa_digest_signverify_update },
847
    { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL,
848
        (void (*)(void))dsa_digest_verify_final },
849
    { OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))dsa_freectx },
850
    { OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))dsa_dupctx },
851
    { OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, (void (*)(void))dsa_get_ctx_params },
852
    { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS,
853
        (void (*)(void))dsa_gettable_ctx_params },
854
    { OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS, (void (*)(void))dsa_set_ctx_params },
855
    { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS,
856
        (void (*)(void))dsa_settable_ctx_params },
857
    { OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS,
858
        (void (*)(void))dsa_get_ctx_md_params },
859
    { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS,
860
        (void (*)(void))dsa_gettable_ctx_md_params },
861
    { OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS,
862
        (void (*)(void))dsa_set_ctx_md_params },
863
    { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS,
864
        (void (*)(void))dsa_settable_ctx_md_params },
865
    OSSL_DISPATCH_END
866
};
867
868
/* ------------------------------------------------------------------ */
869
870
/*
871
 * So called sigalgs (composite DSA+hash) implemented below.  They
872
 * are pretty much hard coded.
873
 */
874
875
static OSSL_FUNC_signature_query_key_types_fn dsa_sigalg_query_key_types;
876
static OSSL_FUNC_signature_settable_ctx_params_fn dsa_sigalg_settable_ctx_params;
877
static OSSL_FUNC_signature_set_ctx_params_fn dsa_sigalg_set_ctx_params;
878
879
/*
880
 * dsa_sigalg_signverify_init() is almost like dsa_digest_signverify_init(),
881
 * just doesn't allow fetching an MD from whatever the user chooses.
882
 */
883
static int dsa_sigalg_signverify_init(void *vpdsactx, void *vdsa,
884
    OSSL_FUNC_signature_set_ctx_params_fn *set_ctx_params,
885
    const OSSL_PARAM params[],
886
    const char *mdname,
887
    int operation, const char *desc)
888
0
{
889
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
890
891
0
    if (!ossl_prov_is_running())
892
0
        return 0;
893
894
0
    if (!dsa_signverify_init(vpdsactx, vdsa, set_ctx_params, params, operation,
895
0
            desc))
896
0
        return 0;
897
898
0
    if (!dsa_setup_md(pdsactx, mdname, NULL, desc))
899
0
        return 0;
900
901
0
    pdsactx->flag_sigalg = 1;
902
0
    pdsactx->flag_allow_md = 0;
903
904
0
    if (pdsactx->mdctx == NULL) {
905
0
        pdsactx->mdctx = EVP_MD_CTX_new();
906
0
        if (pdsactx->mdctx == NULL)
907
0
            goto error;
908
0
    }
909
910
0
    if (!EVP_DigestInit_ex2(pdsactx->mdctx, pdsactx->md, params))
911
0
        goto error;
912
913
0
    return 1;
914
915
0
error:
916
0
    EVP_MD_CTX_free(pdsactx->mdctx);
917
0
    pdsactx->mdctx = NULL;
918
0
    return 0;
919
0
}
920
921
static const char **dsa_sigalg_query_key_types(void)
922
0
{
923
0
    static const char *keytypes[] = { "DSA", NULL };
924
925
0
    return keytypes;
926
0
}
927
928
static const OSSL_PARAM *dsa_sigalg_settable_ctx_params(void *vpdsactx,
929
    ossl_unused void *provctx)
930
0
{
931
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
932
933
0
    if (pdsactx != NULL && pdsactx->operation == EVP_PKEY_OP_VERIFYMSG)
934
0
        return dsa_sigalg_set_ctx_params_list;
935
0
    return NULL;
936
0
}
937
938
static int dsa_sigalg_set_ctx_params(void *vpdsactx, const OSSL_PARAM params[])
939
0
{
940
0
    PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx;
941
0
    struct dsa_all_set_ctx_params_st p;
942
0
    int ret;
943
944
0
    if (pdsactx == NULL || !dsa_sigalg_set_ctx_params_decoder(params, &p))
945
0
        return 0;
946
947
0
    if ((ret = dsa_common_set_ctx_params(pdsactx, &p)) <= 0)
948
0
        return ret;
949
950
0
    if (pdsactx->operation == EVP_PKEY_OP_VERIFYMSG) {
951
0
        if (p.sig != NULL) {
952
0
            OPENSSL_free(pdsactx->sig);
953
0
            pdsactx->sig = NULL;
954
0
            pdsactx->siglen = 0;
955
0
            if (!OSSL_PARAM_get_octet_string(p.sig, (void **)&pdsactx->sig,
956
0
                    0, &pdsactx->siglen))
957
0
                return 0;
958
            /* The signature must not be empty */
959
0
            if (pdsactx->siglen == 0) {
960
0
                OPENSSL_free(pdsactx->sig);
961
0
                pdsactx->sig = NULL;
962
0
                return 0;
963
0
            }
964
0
        }
965
0
    }
966
0
    return 1;
967
0
}
968
969
#define IMPL_DSA_SIGALG(md, MD)                                       \
970
    static OSSL_FUNC_signature_sign_init_fn dsa_##md##_sign_init;     \
971
    static OSSL_FUNC_signature_sign_message_init_fn                   \
972
        dsa_##md##_sign_message_init;                                 \
973
    static OSSL_FUNC_signature_verify_init_fn dsa_##md##_verify_init; \
974
    static OSSL_FUNC_signature_verify_message_init_fn                 \
975
        dsa_##md##_verify_message_init;                               \
976
                                                                      \
977
    static int                                                        \
978
    dsa_##md##_sign_init(void *vpdsactx, void *vdsa,                  \
979
        const OSSL_PARAM params[])                                    \
980
0
    {                                                                 \
981
0
        static const char desc[] = "DSA-" MD " Sign Init";            \
982
0
                                                                      \
983
0
        return dsa_sigalg_signverify_init(vpdsactx, vdsa,             \
984
0
            dsa_sigalg_set_ctx_params,                                \
985
0
            params, MD,                                               \
986
0
            EVP_PKEY_OP_SIGN,                                         \
987
0
            desc);                                                    \
988
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
989
                                                                      \
990
    static int                                                        \
991
    dsa_##md##_sign_message_init(void *vpdsactx, void *vdsa,          \
992
        const OSSL_PARAM params[])                                    \
993
0
    {                                                                 \
994
0
        static const char desc[] = "DSA-" MD " Sign Message Init";    \
995
0
                                                                      \
996
0
        return dsa_sigalg_signverify_init(vpdsactx, vdsa,             \
997
0
            dsa_sigalg_set_ctx_params,                                \
998
0
            params, MD,                                               \
999
0
            EVP_PKEY_OP_SIGNMSG,                                      \
1000
0
            desc);                                                    \
1001
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
1002
                                                                      \
1003
    static int                                                        \
1004
    dsa_##md##_verify_init(void *vpdsactx, void *vdsa,                \
1005
        const OSSL_PARAM params[])                                    \
1006
0
    {                                                                 \
1007
0
        static const char desc[] = "DSA-" MD " Verify Init";          \
1008
0
                                                                      \
1009
0
        return dsa_sigalg_signverify_init(vpdsactx, vdsa,             \
1010
0
            dsa_sigalg_set_ctx_params,                                \
1011
0
            params, MD,                                               \
1012
0
            EVP_PKEY_OP_VERIFY,                                       \
1013
0
            desc);                                                    \
1014
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
1015
                                                                      \
1016
    static int                                                        \
1017
    dsa_##md##_verify_message_init(void *vpdsactx, void *vdsa,        \
1018
        const OSSL_PARAM params[])                                    \
1019
0
    {                                                                 \
1020
0
        static const char desc[] = "DSA-" MD " Verify Message Init";  \
1021
0
                                                                      \
1022
0
        return dsa_sigalg_signverify_init(vpdsactx, vdsa,             \
1023
0
            dsa_sigalg_set_ctx_params,                                \
1024
0
            params, MD,                                               \
1025
0
            EVP_PKEY_OP_VERIFYMSG,                                    \
1026
0
            desc);                                                    \
1027
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
1028
                                                                      \
1029
    const OSSL_DISPATCH ossl_dsa_##md##_signature_functions[] = {     \
1030
        { OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))dsa_newctx },   \
1031
        { OSSL_FUNC_SIGNATURE_SIGN_INIT,                              \
1032
            (void (*)(void))dsa_##md##_sign_init },                   \
1033
        { OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))dsa_sign },       \
1034
        { OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_INIT,                      \
1035
            (void (*)(void))dsa_##md##_sign_message_init },           \
1036
        { OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_UPDATE,                    \
1037
            (void (*)(void))dsa_signverify_message_update },          \
1038
        { OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_FINAL,                     \
1039
            (void (*)(void))dsa_sign_message_final },                 \
1040
        { OSSL_FUNC_SIGNATURE_VERIFY_INIT,                            \
1041
            (void (*)(void))dsa_##md##_verify_init },                 \
1042
        { OSSL_FUNC_SIGNATURE_VERIFY,                                 \
1043
            (void (*)(void))dsa_verify },                             \
1044
        { OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_INIT,                    \
1045
            (void (*)(void))dsa_##md##_verify_message_init },         \
1046
        { OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_UPDATE,                  \
1047
            (void (*)(void))dsa_signverify_message_update },          \
1048
        { OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_FINAL,                   \
1049
            (void (*)(void))dsa_verify_message_final },               \
1050
        { OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))dsa_freectx }, \
1051
        { OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))dsa_dupctx },   \
1052
        { OSSL_FUNC_SIGNATURE_QUERY_KEY_TYPES,                        \
1053
            (void (*)(void))dsa_sigalg_query_key_types },             \
1054
        { OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS,                         \
1055
            (void (*)(void))dsa_get_ctx_params },                     \
1056
        { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS,                    \
1057
            (void (*)(void))dsa_gettable_ctx_params },                \
1058
        { OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS,                         \
1059
            (void (*)(void))dsa_sigalg_set_ctx_params },              \
1060
        { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS,                    \
1061
            (void (*)(void))dsa_sigalg_settable_ctx_params },         \
1062
        OSSL_DISPATCH_END                                             \
1063
    }
1064
1065
IMPL_DSA_SIGALG(sha1, "SHA1");
1066
IMPL_DSA_SIGALG(sha224, "SHA2-224");
1067
IMPL_DSA_SIGALG(sha256, "SHA2-256");
1068
IMPL_DSA_SIGALG(sha384, "SHA2-384");
1069
IMPL_DSA_SIGALG(sha512, "SHA2-512");
1070
IMPL_DSA_SIGALG(sha3_224, "SHA3-224");
1071
IMPL_DSA_SIGALG(sha3_256, "SHA3-256");
1072
IMPL_DSA_SIGALG(sha3_384, "SHA3-384");
1073
IMPL_DSA_SIGALG(sha3_512, "SHA3-512");