Coverage Report

Created: 2026-10-28 06:28

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