Coverage Report

Created: 2026-04-11 06:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/crypto/ml_dsa/ml_dsa_key.c
Line
Count
Source
1
/*
2
 * Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (the "License").  You may not use
5
 * this file except in compliance with the License.  You can obtain a copy
6
 * in the file LICENSE in the source distribution or at
7
 * https://www.openssl.org/source/license.html
8
 */
9
10
#include <openssl/core_dispatch.h>
11
#include <openssl/core_names.h>
12
#include <openssl/err.h>
13
#include <openssl/params.h>
14
#include <openssl/proverr.h>
15
#include <openssl/rand.h>
16
#include "ml_dsa_key.h"
17
#include "ml_dsa_matrix.h"
18
#include "ml_dsa_hash.h"
19
#include "internal/encoder.h"
20
21
const ML_DSA_PARAMS *ossl_ml_dsa_key_params(const ML_DSA_KEY *key)
22
0
{
23
0
    return key->params;
24
0
}
25
26
/* Returns the seed data or NULL if there is no seed */
27
const uint8_t *ossl_ml_dsa_key_get_seed(const ML_DSA_KEY *key)
28
0
{
29
0
    return key->seed;
30
0
}
31
32
int ossl_ml_dsa_key_get_prov_flags(const ML_DSA_KEY *key)
33
0
{
34
0
    return key->prov_flags;
35
0
}
36
37
int ossl_ml_dsa_set_prekey(ML_DSA_KEY *key, int flags_set, int flags_clr,
38
    const uint8_t *seed, size_t seed_len,
39
    const uint8_t *sk, size_t sk_len)
40
0
{
41
0
    int ret = 0;
42
43
0
    if (key == NULL
44
0
        || key->pub_encoding != NULL
45
0
        || key->priv_encoding != NULL
46
0
        || (sk != NULL && sk_len != key->params->sk_len)
47
0
        || (seed != NULL && seed_len != ML_DSA_SEED_BYTES)
48
0
        || key->seed != NULL)
49
0
        return 0;
50
51
0
    if (sk != NULL) {
52
0
        key->priv_encoding = OPENSSL_secure_malloc(sk_len);
53
0
        if (key->priv_encoding == NULL)
54
0
            goto end;
55
0
        memcpy(key->priv_encoding, sk, sk_len);
56
0
    }
57
58
0
    if (seed != NULL) {
59
0
        if ((key->seed = OPENSSL_secure_malloc(seed_len)) == NULL)
60
0
            goto end;
61
0
        memcpy(key->seed, seed, seed_len);
62
0
    }
63
0
    key->prov_flags |= flags_set;
64
0
    key->prov_flags &= ~flags_clr;
65
0
    ret = 1;
66
67
0
end:
68
0
    if (!ret) {
69
0
        OPENSSL_secure_clear_free(key->priv_encoding, sk_len);
70
0
        OPENSSL_secure_clear_free(key->seed, seed_len);
71
0
        key->priv_encoding = key->seed = NULL;
72
0
    }
73
0
    return ret;
74
0
}
75
76
/*
77
 * @brief Fetch digest algorithms based on a propq.
78
 * For the import case ossl_ml_dsa_key_new() gets passed a NULL propq,
79
 * so the propq is optionally deferred to the import using OSSL_PARAM.
80
 */
81
int ossl_ml_dsa_key_fetch_digests(ML_DSA_KEY *key, const char *propq)
82
0
{
83
0
    EVP_MD_free(key->shake128_md);
84
0
    EVP_MD_free(key->shake256_md);
85
0
    key->shake128_md = EVP_MD_fetch(key->libctx, "SHAKE-128", propq);
86
0
    key->shake256_md = EVP_MD_fetch(key->libctx, "SHAKE-256", propq);
87
0
    return (key->shake128_md != NULL && key->shake256_md != NULL);
88
0
}
89
90
/**
91
 * @brief Create a new ML_DSA_KEY object
92
 *
93
 * @param libctx A OSSL_LIB_CTX object used for fetching algorithms.
94
 * @param propq The property query used for fetching algorithms
95
 * @param alg The algorithm name associated with the key type
96
 * @returns The new ML_DSA_KEY object on success, or NULL on malloc failure
97
 */
98
ML_DSA_KEY *ossl_ml_dsa_key_new(OSSL_LIB_CTX *libctx, const char *propq,
99
    int evp_type)
100
0
{
101
0
    ML_DSA_KEY *ret;
102
0
    const ML_DSA_PARAMS *params = ossl_ml_dsa_params_get(evp_type);
103
104
0
    if (params == NULL)
105
0
        return NULL;
106
107
0
    ret = OPENSSL_zalloc(sizeof(*ret));
108
0
    if (ret != NULL) {
109
0
        ret->libctx = libctx;
110
0
        ret->params = params;
111
0
        ret->prov_flags = ML_DSA_KEY_PROV_FLAGS_DEFAULT;
112
0
        if (!ossl_ml_dsa_key_fetch_digests(ret, propq))
113
0
            goto err;
114
0
    }
115
0
    return ret;
116
0
err:
117
0
    ossl_ml_dsa_key_free(ret);
118
0
    return NULL;
119
0
}
120
121
int ossl_ml_dsa_key_pub_alloc(ML_DSA_KEY *key)
122
0
{
123
0
    if (key->t1.poly != NULL)
124
0
        return 0;
125
0
    return vector_alloc(&key->t1, key->params->k);
126
0
}
127
128
int ossl_ml_dsa_key_priv_alloc(ML_DSA_KEY *key)
129
0
{
130
0
    size_t k = key->params->k, l = key->params->l;
131
0
    POLY *poly;
132
133
0
    if (key->s1.poly != NULL)
134
0
        return 0;
135
0
    if (!vector_secure_alloc(&key->s1, l + 2 * k))
136
0
        return 0;
137
138
0
    poly = key->s1.poly;
139
0
    key->s1.num_poly = l;
140
0
    vector_init(&key->s2, poly + l, k);
141
0
    vector_init(&key->t0, poly + l + k, k);
142
0
    return 1;
143
0
}
144
145
/**
146
 * @brief Destroy an ML_DSA_KEY object
147
 */
148
void ossl_ml_dsa_key_free(ML_DSA_KEY *key)
149
0
{
150
0
    if (key == NULL)
151
0
        return;
152
153
0
    EVP_MD_free(key->shake128_md);
154
0
    EVP_MD_free(key->shake256_md);
155
0
    ossl_ml_dsa_key_reset(key);
156
0
    OPENSSL_free(key);
157
0
}
158
159
/**
160
 * @brief Factory reset an ML_DSA_KEY object
161
 */
162
void ossl_ml_dsa_key_reset(ML_DSA_KEY *key)
163
0
{
164
    /*
165
     * The allocation for |s1.poly| subsumes those for |s2| and |t0|, which we
166
     * must not access after |s1|'s poly is freed.
167
     */
168
0
    if (key->s1.poly != NULL) {
169
0
        const ML_DSA_PARAMS *params = key->params;
170
0
        size_t k = params->k, l = params->l;
171
172
0
        vector_secure_free(&key->s1, l + 2 * k);
173
0
        vector_init(&key->s2, NULL, 0);
174
0
        vector_init(&key->t0, NULL, 0);
175
0
    }
176
    /* The |t1| vector is public and allocated separately */
177
0
    vector_free(&key->t1);
178
0
    OPENSSL_cleanse(key->K, sizeof(key->K));
179
0
    OPENSSL_free(key->pub_encoding);
180
0
    key->pub_encoding = NULL;
181
0
    if (key->priv_encoding != NULL)
182
0
        OPENSSL_secure_clear_free(key->priv_encoding, key->params->sk_len);
183
0
    key->priv_encoding = NULL;
184
0
    if (key->seed != NULL)
185
0
        OPENSSL_secure_clear_free(key->seed, ML_DSA_SEED_BYTES);
186
0
    key->seed = NULL;
187
0
}
188
189
/**
190
 * @brief Duplicate a key
191
 *
192
 * @param src A ML_DSA_KEY object to copy
193
 * @param selection to select public and/or private components. Selecting the
194
 *                  private key will also select the public key
195
 * @returns The duplicated key, or NULL on failure.
196
 */
197
ML_DSA_KEY *ossl_ml_dsa_key_dup(const ML_DSA_KEY *src, int selection)
198
0
{
199
0
    ML_DSA_KEY *ret = NULL;
200
201
0
    if (src == NULL)
202
0
        return NULL;
203
204
    /* Prekeys with just a seed or private key are not dupable */
205
0
    if (src->pub_encoding == NULL
206
0
        && (src->priv_encoding != NULL || src->seed != NULL))
207
0
        return NULL;
208
209
0
    ret = OPENSSL_zalloc(sizeof(*ret));
210
0
    if (ret != NULL) {
211
0
        ret->libctx = src->libctx;
212
0
        ret->params = src->params;
213
0
        ret->prov_flags = src->prov_flags;
214
0
        if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
215
0
            if (src->pub_encoding != NULL) {
216
                /* The public components are present if the private key is present */
217
0
                memcpy(ret->rho, src->rho, sizeof(src->rho));
218
0
                memcpy(ret->tr, src->tr, sizeof(src->tr));
219
0
                if (src->t1.poly != NULL) {
220
0
                    if (!ossl_ml_dsa_key_pub_alloc(ret))
221
0
                        goto err;
222
0
                    vector_copy(&ret->t1, &src->t1);
223
0
                }
224
0
                if ((ret->pub_encoding = OPENSSL_memdup(src->pub_encoding,
225
0
                         src->params->pk_len))
226
0
                    == NULL)
227
0
                    goto err;
228
0
            }
229
0
            if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
230
0
                if (src->priv_encoding != NULL) {
231
0
                    memcpy(ret->K, src->K, sizeof(src->K));
232
0
                    if (src->s1.poly != NULL) {
233
0
                        if (!ossl_ml_dsa_key_priv_alloc(ret))
234
0
                            goto err;
235
0
                        vector_copy(&ret->s1, &src->s1);
236
0
                        vector_copy(&ret->s2, &src->s2);
237
0
                        vector_copy(&ret->t0, &src->t0);
238
0
                    }
239
0
                    ret->priv_encoding = OPENSSL_secure_malloc(src->params->sk_len);
240
0
                    if (ret->priv_encoding == NULL)
241
0
                        goto err;
242
0
                    memcpy(ret->priv_encoding, src->priv_encoding, src->params->sk_len);
243
0
                }
244
0
                if (src->seed != NULL) {
245
0
                    ret->seed = OPENSSL_secure_malloc(ML_DSA_SEED_BYTES);
246
0
                    if (ret->seed == NULL)
247
0
                        goto err;
248
0
                    memcpy(ret->seed, src->seed, ML_DSA_SEED_BYTES);
249
0
                }
250
0
            }
251
0
        }
252
0
        EVP_MD_up_ref(src->shake128_md);
253
0
        EVP_MD_up_ref(src->shake256_md);
254
0
        ret->shake128_md = src->shake128_md;
255
0
        ret->shake256_md = src->shake256_md;
256
0
    }
257
0
    return ret;
258
0
err:
259
0
    ossl_ml_dsa_key_free(ret);
260
0
    return NULL;
261
0
}
262
263
/**
264
 * @brief Are 2 keys equal?
265
 *
266
 * To be equal the keys must have matching public or private key data and
267
 * contain the same parameters.
268
 * (Note that in OpenSSL that the private key always has a public key component).
269
 *
270
 * @param key1 A ML_DSA_KEY object
271
 * @param key2 A ML_DSA_KEY object
272
 * @param selection to select public and/or private component comparison.
273
 * @returns 1 if the keys are equal otherwise it returns 0.
274
 */
275
int ossl_ml_dsa_key_equal(const ML_DSA_KEY *key1, const ML_DSA_KEY *key2,
276
    int selection)
277
0
{
278
0
    int key_checked = 0;
279
280
0
    if (key1->params != key2->params)
281
0
        return 0;
282
283
0
    if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
284
0
        if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {
285
0
            if (key1->pub_encoding != NULL && key2->pub_encoding != NULL) {
286
0
                if (memcmp(key1->pub_encoding, key2->pub_encoding,
287
0
                        key1->params->pk_len)
288
0
                    != 0)
289
0
                    return 0;
290
0
                key_checked = 1;
291
0
            }
292
0
        }
293
0
        if (!key_checked
294
0
            && (selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
295
0
            if (key1->priv_encoding != NULL && key2->priv_encoding != NULL) {
296
0
                if (memcmp(key1->priv_encoding, key2->priv_encoding,
297
0
                        key1->params->sk_len)
298
0
                    != 0)
299
0
                    return 0;
300
0
                key_checked = 1;
301
0
            }
302
0
        }
303
0
        return key_checked;
304
0
    }
305
0
    return 1;
306
0
}
307
308
int ossl_ml_dsa_key_has(const ML_DSA_KEY *key, int selection)
309
0
{
310
0
    if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
311
        /* Note that the public key always exists if there is a private key */
312
0
        if (ossl_ml_dsa_key_get_pub(key) == NULL)
313
0
            return 0; /* No public key */
314
0
        if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0
315
0
            && ossl_ml_dsa_key_get_priv(key) == NULL)
316
0
            return 0; /* No private key */
317
0
        return 1;
318
0
    }
319
0
    return 0;
320
0
}
321
322
/*
323
 * @brief Given a key containing private key values for rho, s1 & s2
324
 * generate the public value t and return the compressed values t1, t0.
325
 *
326
 * @param key A private key containing params, rh0, s1 & s2.
327
 * @param md_ctx A EVP_MD_CTX used for sampling.
328
 * @param t1 The returned polynomial encoding of the 10 MSB of each coefficient
329
 *        of the uncompressed public key polynomial t.
330
 * @param t0 The returned polynomial encoding of the 13 LSB of each coefficient
331
 *        of the uncompressed public key polynomial t.
332
 * @returns 1 on success, or 0 on failure.
333
 */
334
static int public_from_private(const ML_DSA_KEY *key, EVP_MD_CTX *md_ctx,
335
    VECTOR *t1, VECTOR *t0)
336
0
{
337
0
    int ret = 0;
338
0
    const ML_DSA_PARAMS *params = key->params;
339
0
    uint32_t k = (uint32_t)params->k, l = (uint32_t)params->l;
340
0
    POLY *polys;
341
0
    MATRIX a_ntt;
342
0
    VECTOR s1_ntt;
343
0
    VECTOR t;
344
345
0
    polys = OPENSSL_malloc_array(k + l + k * l, sizeof(*polys));
346
0
    if (polys == NULL)
347
0
        return 0;
348
349
0
    vector_init(&t, polys, k);
350
0
    vector_init(&s1_ntt, t.poly + k, l);
351
0
    matrix_init(&a_ntt, s1_ntt.poly + l, k, l);
352
353
    /* Using rho generate A' = A in NTT form */
354
0
    if (!matrix_expand_A(md_ctx, key->shake128_md, key->rho, &a_ntt))
355
0
        goto err;
356
357
    /* t = NTT_inv(A' * NTT(s1)) + s2 */
358
0
    vector_copy(&s1_ntt, &key->s1);
359
0
    vector_ntt(&s1_ntt);
360
361
0
    matrix_mult_vector(&a_ntt, &s1_ntt, &t);
362
0
    vector_ntt_inverse(&t);
363
0
    vector_add(&t, &key->s2, &t);
364
365
    /* Compress t */
366
0
    vector_power2_round(&t, t1, t0);
367
368
    /* Zeroize secret */
369
0
    vector_zero(&s1_ntt);
370
0
    ret = 1;
371
0
err:
372
0
    OPENSSL_free(polys);
373
0
    return ret;
374
0
}
375
376
int ossl_ml_dsa_key_public_from_private(ML_DSA_KEY *key)
377
0
{
378
0
    int ret = 0;
379
0
    VECTOR t0;
380
0
    EVP_MD_CTX *md_ctx = NULL;
381
382
0
    if (!vector_alloc(&t0, key->params->k)) /* t0 is already in the private key */
383
0
        return 0;
384
0
    ret = ((md_ctx = EVP_MD_CTX_new()) != NULL)
385
0
        && ossl_ml_dsa_key_pub_alloc(key) /* allocate space for t1 */
386
0
        && public_from_private(key, md_ctx, &key->t1, &t0)
387
0
        && vector_equal(&t0, &key->t0) /* compare the generated t0 to the expected */
388
0
        && ossl_ml_dsa_pk_encode(key)
389
0
        && shake_xof(md_ctx, key->shake256_md,
390
0
            key->pub_encoding, key->params->pk_len,
391
0
            key->tr, sizeof(key->tr));
392
0
    vector_free(&t0);
393
0
    EVP_MD_CTX_free(md_ctx);
394
0
    return ret;
395
0
}
396
397
int ossl_ml_dsa_key_pairwise_check(const ML_DSA_KEY *key)
398
0
{
399
0
    int ret = 0;
400
0
    VECTOR t1, t0;
401
0
    POLY *polys = NULL;
402
0
    uint32_t k = (uint32_t)key->params->k;
403
0
    EVP_MD_CTX *md_ctx = NULL;
404
405
0
    if (key->pub_encoding == NULL || key->priv_encoding == 0)
406
0
        return 0;
407
408
0
    polys = OPENSSL_malloc_array(2 * k, sizeof(*polys));
409
0
    if (polys == NULL)
410
0
        return 0;
411
0
    md_ctx = EVP_MD_CTX_new();
412
0
    if (md_ctx == NULL)
413
0
        goto err;
414
415
0
    vector_init(&t1, polys, k);
416
0
    vector_init(&t0, polys + k, k);
417
0
    if (!public_from_private(key, md_ctx, &t1, &t0))
418
0
        goto err;
419
420
0
    ret = vector_equal(&t1, &key->t1) && vector_equal(&t0, &key->t0);
421
0
err:
422
0
    EVP_MD_CTX_free(md_ctx);
423
0
    OPENSSL_free(polys);
424
0
    return ret;
425
0
}
426
427
/*
428
 * @brief Generate a public-private key pair from a seed.
429
 * See FIPS 204, Algorithm 6 ML-DSA.KeyGen_internal().
430
 *
431
 * @param out The generated key (which contains params on input)
432
 *
433
 * @returns 1 on success or 0 on failure.
434
 */
435
static int keygen_internal(ML_DSA_KEY *out)
436
0
{
437
0
    int ret = 0;
438
0
    uint8_t augmented_seed[ML_DSA_SEED_BYTES + 2];
439
0
    uint8_t expanded_seed[ML_DSA_RHO_BYTES + ML_DSA_PRIV_SEED_BYTES + ML_DSA_K_BYTES];
440
0
    const uint8_t *const rho = expanded_seed; /* p = Public Random Seed */
441
0
    const uint8_t *const priv_seed = expanded_seed + ML_DSA_RHO_BYTES;
442
0
    const uint8_t *const K = priv_seed + ML_DSA_PRIV_SEED_BYTES;
443
0
    const ML_DSA_PARAMS *params = out->params;
444
0
    EVP_MD_CTX *md_ctx = NULL;
445
446
0
    if (out->seed == NULL
447
0
        || (md_ctx = EVP_MD_CTX_new()) == NULL
448
0
        || !ossl_ml_dsa_key_pub_alloc(out)
449
0
        || !ossl_ml_dsa_key_priv_alloc(out))
450
0
        goto err;
451
452
    /* augmented_seed = seed || k || l */
453
0
    memcpy(augmented_seed, out->seed, ML_DSA_SEED_BYTES);
454
0
    augmented_seed[ML_DSA_SEED_BYTES] = (uint8_t)params->k;
455
0
    augmented_seed[ML_DSA_SEED_BYTES + 1] = (uint8_t)params->l;
456
    /* Expand the seed into p[32], p'[64], K[32] */
457
0
    if (!shake_xof(md_ctx, out->shake256_md, augmented_seed, sizeof(augmented_seed),
458
0
            expanded_seed, sizeof(expanded_seed)))
459
0
        goto err;
460
461
0
    memcpy(out->rho, rho, sizeof(out->rho));
462
0
    memcpy(out->K, K, sizeof(out->K));
463
464
0
    ret = vector_expand_S(md_ctx, out->shake256_md, params->eta, priv_seed, &out->s1, &out->s2)
465
0
        && public_from_private(out, md_ctx, &out->t1, &out->t0)
466
0
        && ossl_ml_dsa_pk_encode(out)
467
0
        && shake_xof(md_ctx, out->shake256_md, out->pub_encoding, out->params->pk_len,
468
0
            out->tr, sizeof(out->tr))
469
0
        && ossl_ml_dsa_sk_encode(out);
470
471
0
err:
472
0
    EVP_MD_CTX_free(md_ctx);
473
0
    OPENSSL_cleanse(augmented_seed, sizeof(augmented_seed));
474
0
    OPENSSL_cleanse(expanded_seed, sizeof(expanded_seed));
475
0
    return ret;
476
0
}
477
478
int ossl_ml_dsa_generate_key(ML_DSA_KEY *out)
479
0
{
480
0
    size_t seed_len = ML_DSA_SEED_BYTES;
481
0
    uint8_t *sk;
482
0
    int ret;
483
484
0
    if (out->seed == NULL) {
485
0
        if ((out->seed = OPENSSL_secure_malloc(seed_len)) == NULL)
486
0
            return 0;
487
0
        if (RAND_priv_bytes_ex(out->libctx, out->seed, seed_len, 0) <= 0) {
488
0
            OPENSSL_secure_free(out->seed);
489
0
            out->seed = NULL;
490
0
            return 0;
491
0
        }
492
0
    }
493
    /* We're generating from a seed, drop private prekey encoding */
494
0
    sk = out->priv_encoding;
495
0
    out->priv_encoding = NULL;
496
0
    if (sk == NULL) {
497
0
        ret = keygen_internal(out);
498
0
    } else {
499
0
        if ((ret = keygen_internal(out)) != 0
500
0
            && memcmp(out->priv_encoding, sk, out->params->sk_len) != 0) {
501
0
            ret = 0;
502
0
            ossl_ml_dsa_key_reset(out);
503
0
            ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_KEY,
504
0
                "explicit %s private key does not match seed",
505
0
                out->params->alg);
506
0
        }
507
0
        OPENSSL_secure_clear_free(sk, out->params->sk_len);
508
0
    }
509
0
    return ret;
510
0
}
511
512
/**
513
 * @brief This is used when a ML DSA key is used for an operation.
514
 * This checks that the algorithm is the same (i.e. uses the same parameters)
515
 *
516
 * @param key A ML_DSA key to use for an operation.
517
 * @param evp_type The algorithm nid associated with an operation
518
 *
519
 * @returns 1 if the algorithm matches, or 0 otherwise.
520
 */
521
522
int ossl_ml_dsa_key_matches(const ML_DSA_KEY *key, int evp_type)
523
0
{
524
0
    return (key->params->evp_type == evp_type);
525
0
}
526
527
/* Returns the public key data or NULL if there is no public key */
528
const uint8_t *ossl_ml_dsa_key_get_pub(const ML_DSA_KEY *key)
529
0
{
530
0
    return key->pub_encoding;
531
0
}
532
533
/* Returns the encoded public key size */
534
size_t ossl_ml_dsa_key_get_pub_len(const ML_DSA_KEY *key)
535
0
{
536
0
    return key->params->pk_len;
537
0
}
538
539
size_t ossl_ml_dsa_key_get_collision_strength_bits(const ML_DSA_KEY *key)
540
0
{
541
0
    return key->params->bit_strength;
542
0
}
543
544
int ossl_ml_dsa_key_get_security_category(const ML_DSA_KEY *key)
545
0
{
546
0
    return key->params->security_category;
547
0
}
548
549
/* Returns the private key data or NULL if there is no private key */
550
const uint8_t *ossl_ml_dsa_key_get_priv(const ML_DSA_KEY *key)
551
0
{
552
0
    return key->priv_encoding;
553
0
}
554
555
size_t ossl_ml_dsa_key_get_priv_len(const ML_DSA_KEY *key)
556
0
{
557
0
    return key->params->sk_len;
558
0
}
559
560
size_t ossl_ml_dsa_key_get_sig_len(const ML_DSA_KEY *key)
561
0
{
562
0
    return key->params->sig_len;
563
0
}
564
565
OSSL_LIB_CTX *ossl_ml_dsa_key_get0_libctx(const ML_DSA_KEY *key)
566
0
{
567
0
    return key != NULL ? key->libctx : NULL;
568
0
}
569
570
const char *ossl_ml_dsa_key_get_name(const ML_DSA_KEY *key)
571
0
{
572
0
    return key->params->alg;
573
0
}