Coverage Report

Created: 2025-12-31 06:58

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-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
528
{
23
528
    return key->params;
24
528
}
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.21k
{
29
1.21k
    return key->seed;
30
1.21k
}
31
32
int ossl_ml_dsa_key_get_prov_flags(const ML_DSA_KEY *key)
33
60
{
34
60
    return key->prov_flags;
35
60
}
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
588
{
41
588
    int ret = 0;
42
43
588
    if (key == NULL
44
588
        || key->pub_encoding != NULL
45
588
        || key->priv_encoding != NULL
46
588
        || (sk != NULL && sk_len != key->params->sk_len)
47
588
        || (seed != NULL && seed_len != ML_DSA_SEED_BYTES)
48
588
        || key->seed != NULL)
49
0
        return 0;
50
51
588
    if (sk != NULL
52
15
        && (key->priv_encoding = OPENSSL_memdup(sk, sk_len)) == NULL)
53
0
        goto end;
54
588
    if (seed != NULL
55
55
        && (key->seed = OPENSSL_memdup(seed, seed_len)) == NULL)
56
0
        goto end;
57
588
    key->prov_flags |= flags_set;
58
588
    key->prov_flags &= ~flags_clr;
59
588
    ret = 1;
60
61
588
end:
62
588
    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
588
    return ret;
68
588
}
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.64k
{
81
1.64k
    ML_DSA_KEY *ret;
82
1.64k
    const ML_DSA_PARAMS *params = ossl_ml_dsa_params_get(evp_type);
83
84
1.64k
    if (params == NULL)
85
0
        return NULL;
86
87
1.64k
    ret = OPENSSL_zalloc(sizeof(*ret));
88
1.64k
    if (ret != NULL) {
89
1.64k
        ret->libctx = libctx;
90
1.64k
        ret->params = params;
91
1.64k
        ret->prov_flags = ML_DSA_KEY_PROV_FLAGS_DEFAULT;
92
1.64k
        ret->shake128_md = EVP_MD_fetch(libctx, "SHAKE-128", propq);
93
1.64k
        ret->shake256_md = EVP_MD_fetch(libctx, "SHAKE-256", propq);
94
1.64k
        if (ret->shake128_md == NULL || ret->shake256_md == NULL)
95
0
            goto err;
96
1.64k
    }
97
1.64k
    return ret;
98
0
err:
99
0
    ossl_ml_dsa_key_free(ret);
100
0
    return NULL;
101
1.64k
}
102
103
int ossl_ml_dsa_key_pub_alloc(ML_DSA_KEY *key)
104
1.58k
{
105
1.58k
    if (key->t1.poly != NULL)
106
0
        return 0;
107
1.58k
    return vector_alloc(&key->t1, key->params->k);
108
1.58k
}
109
110
int ossl_ml_dsa_key_priv_alloc(ML_DSA_KEY *key)
111
1.61k
{
112
1.61k
    size_t k = key->params->k, l = key->params->l;
113
1.61k
    POLY *poly;
114
115
1.61k
    if (key->s1.poly != NULL)
116
0
        return 0;
117
1.61k
    if (!vector_alloc(&key->s1, l + 2 * k))
118
0
        return 0;
119
120
1.61k
    poly = key->s1.poly;
121
1.61k
    key->s1.num_poly = l;
122
1.61k
    vector_init(&key->s2, poly + l, k);
123
1.61k
    vector_init(&key->t0, poly + l + k, k);
124
1.61k
    return 1;
125
1.61k
}
126
127
/**
128
 * @brief Destroy an ML_DSA_KEY object
129
 */
130
void ossl_ml_dsa_key_free(ML_DSA_KEY *key)
131
208k
{
132
208k
    if (key == NULL)
133
206k
        return;
134
135
1.69k
    EVP_MD_free(key->shake128_md);
136
1.69k
    EVP_MD_free(key->shake256_md);
137
1.69k
    ossl_ml_dsa_key_reset(key);
138
1.69k
    OPENSSL_free(key);
139
1.69k
}
140
141
/**
142
 * @brief Factory reset an ML_DSA_KEY object
143
 */
144
void ossl_ml_dsa_key_reset(ML_DSA_KEY *key)
145
1.69k
{
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
1.69k
    if (key->s1.poly != NULL) {
151
1.61k
        vector_zero(&key->s1);
152
1.61k
        vector_zero(&key->s2);
153
1.61k
        vector_zero(&key->t0);
154
1.61k
        vector_free(&key->s1);
155
1.61k
        key->s2.poly = NULL;
156
1.61k
        key->t0.poly = NULL;
157
1.61k
    }
158
    /* The |t1| vector is public and allocated separately */
159
1.69k
    vector_free(&key->t1);
160
1.69k
    OPENSSL_cleanse(key->K, sizeof(key->K));
161
1.69k
    OPENSSL_free(key->pub_encoding);
162
1.69k
    key->pub_encoding = NULL;
163
1.69k
    if (key->priv_encoding != NULL)
164
1.55k
        OPENSSL_clear_free(key->priv_encoding, key->params->sk_len);
165
1.69k
    key->priv_encoding = NULL;
166
1.69k
    if (key->seed != NULL)
167
1.54k
        OPENSSL_clear_free(key->seed, ML_DSA_SEED_BYTES);
168
1.69k
    key->seed = NULL;
169
1.69k
}
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
4
{
181
4
    ML_DSA_KEY *ret = NULL;
182
183
4
    if (src == NULL)
184
0
        return NULL;
185
186
    /* Prekeys with just a seed or private key are not dupable */
187
4
    if (src->pub_encoding == NULL
188
0
        && (src->priv_encoding != NULL || src->seed != NULL))
189
0
        return NULL;
190
191
4
    ret = OPENSSL_zalloc(sizeof(*ret));
192
4
    if (ret != NULL) {
193
4
        ret->libctx = src->libctx;
194
4
        ret->params = src->params;
195
4
        ret->prov_flags = src->prov_flags;
196
4
        if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
197
4
            if (src->pub_encoding != NULL) {
198
                /* The public components are present if the private key is present */
199
4
                memcpy(ret->rho, src->rho, sizeof(src->rho));
200
4
                memcpy(ret->tr, src->tr, sizeof(src->tr));
201
4
                if (src->t1.poly != NULL) {
202
4
                    if (!ossl_ml_dsa_key_pub_alloc(ret))
203
0
                        goto err;
204
4
                    vector_copy(&ret->t1, &src->t1);
205
4
                }
206
4
                if ((ret->pub_encoding = OPENSSL_memdup(src->pub_encoding,
207
4
                         src->params->pk_len))
208
4
                    == NULL)
209
0
                    goto err;
210
4
            }
211
4
            if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) {
212
4
                if (src->priv_encoding != NULL) {
213
0
                    memcpy(ret->K, src->K, sizeof(src->K));
214
0
                    if (src->s1.poly != NULL) {
215
0
                        if (!ossl_ml_dsa_key_priv_alloc(ret))
216
0
                            goto err;
217
0
                        vector_copy(&ret->s1, &src->s1);
218
0
                        vector_copy(&ret->s2, &src->s2);
219
0
                        vector_copy(&ret->t0, &src->t0);
220
0
                    }
221
0
                    if ((ret->priv_encoding = OPENSSL_memdup(src->priv_encoding,
222
0
                             src->params->sk_len))
223
0
                        == NULL)
224
0
                        goto err;
225
0
                }
226
4
                if (src->seed != NULL
227
0
                    && (ret->seed = OPENSSL_memdup(src->seed,
228
0
                            ML_DSA_SEED_BYTES))
229
0
                        == NULL)
230
0
                    goto err;
231
4
            }
232
4
        }
233
4
        EVP_MD_up_ref(src->shake128_md);
234
4
        EVP_MD_up_ref(src->shake256_md);
235
4
        ret->shake128_md = src->shake128_md;
236
4
        ret->shake256_md = src->shake256_md;
237
4
    }
238
4
    return ret;
239
0
err:
240
0
    ossl_ml_dsa_key_free(ret);
241
0
    return NULL;
242
4
}
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
95
{
259
95
    int key_checked = 0;
260
261
95
    if (key1->params != key2->params)
262
0
        return 0;
263
264
95
    if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
265
95
        if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {
266
95
            if (key1->pub_encoding != NULL && key2->pub_encoding != NULL) {
267
95
                if (memcmp(key1->pub_encoding, key2->pub_encoding,
268
95
                        key1->params->pk_len)
269
95
                    != 0)
270
40
                    return 0;
271
55
                key_checked = 1;
272
55
            }
273
95
        }
274
55
        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 (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
55
        return key_checked;
285
55
    }
286
0
    return 1;
287
95
}
288
289
int ossl_ml_dsa_key_has(const ML_DSA_KEY *key, int selection)
290
382
{
291
382
    if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
292
        /* Note that the public key always exists if there is a private key */
293
382
        if (ossl_ml_dsa_key_get_pub(key) == NULL)
294
0
            return 0; /* No public key */
295
382
        if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0
296
115
            && ossl_ml_dsa_key_get_priv(key) == NULL)
297
0
            return 0; /* No private key */
298
382
        return 1;
299
382
    }
300
0
    return 0;
301
382
}
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
1.49k
{
318
1.49k
    int ret = 0;
319
1.49k
    const ML_DSA_PARAMS *params = key->params;
320
1.49k
    uint32_t k = params->k, l = params->l;
321
1.49k
    POLY *polys;
322
1.49k
    MATRIX a_ntt;
323
1.49k
    VECTOR s1_ntt;
324
1.49k
    VECTOR t;
325
326
1.49k
    polys = OPENSSL_malloc(sizeof(*polys) * (k + l + k * l));
327
1.49k
    if (polys == NULL)
328
0
        return 0;
329
330
1.49k
    vector_init(&t, polys, k);
331
1.49k
    vector_init(&s1_ntt, t.poly + k, l);
332
1.49k
    matrix_init(&a_ntt, s1_ntt.poly + l, k, l);
333
334
    /* Using rho generate A' = A in NTT form */
335
1.49k
    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
1.49k
    vector_copy(&s1_ntt, &key->s1);
340
1.49k
    vector_ntt(&s1_ntt);
341
342
1.49k
    matrix_mult_vector(&a_ntt, &s1_ntt, &t);
343
1.49k
    vector_ntt_inverse(&t);
344
1.49k
    vector_add(&t, &key->s2, &t);
345
346
    /* Compress t */
347
1.49k
    vector_power2_round(&t, t1, t0);
348
349
    /* Zeroize secret */
350
1.49k
    vector_zero(&s1_ntt);
351
1.49k
    ret = 1;
352
1.49k
err:
353
1.49k
    OPENSSL_free(polys);
354
1.49k
    return ret;
355
1.49k
}
356
357
int ossl_ml_dsa_key_public_from_private(ML_DSA_KEY *key)
358
1
{
359
1
    int ret = 0;
360
1
    VECTOR t0;
361
1
    EVP_MD_CTX *md_ctx = NULL;
362
363
1
    if (!vector_alloc(&t0, key->params->k)) /* t0 is already in the private key */
364
0
        return 0;
365
1
    ret = ((md_ctx = EVP_MD_CTX_new()) != NULL)
366
1
        && ossl_ml_dsa_key_pub_alloc(key) /* allocate space for t1 */
367
1
        && public_from_private(key, md_ctx, &key->t1, &t0)
368
1
        && vector_equal(&t0, &key->t0) /* compare the generated t0 to the expected */
369
0
        && ossl_ml_dsa_pk_encode(key)
370
0
        && shake_xof(md_ctx, key->shake256_md,
371
0
            key->pub_encoding, key->params->pk_len,
372
0
            key->tr, sizeof(key->tr));
373
1
    vector_free(&t0);
374
1
    EVP_MD_CTX_free(md_ctx);
375
1
    return ret;
376
1
}
377
378
int ossl_ml_dsa_key_pairwise_check(const ML_DSA_KEY *key)
379
0
{
380
0
    int ret = 0;
381
0
    VECTOR t1, t0;
382
0
    POLY *polys = NULL;
383
0
    uint32_t k = key->params->k;
384
0
    EVP_MD_CTX *md_ctx = NULL;
385
386
0
    if (key->pub_encoding == NULL || key->priv_encoding == 0)
387
0
        return 0;
388
389
0
    polys = OPENSSL_malloc(sizeof(*polys) * (2 * k));
390
0
    if (polys == NULL)
391
0
        return 0;
392
0
    md_ctx = EVP_MD_CTX_new();
393
0
    if (md_ctx == NULL)
394
0
        goto err;
395
396
0
    vector_init(&t1, polys, k);
397
0
    vector_init(&t0, polys + k, k);
398
0
    if (!public_from_private(key, md_ctx, &t1, &t0))
399
0
        goto err;
400
401
0
    ret = vector_equal(&t1, &key->t1) && vector_equal(&t0, &key->t0);
402
0
err:
403
0
    EVP_MD_CTX_free(md_ctx);
404
0
    OPENSSL_free(polys);
405
0
    return ret;
406
0
}
407
408
/*
409
 * @brief Generate a public-private key pair from a seed.
410
 * See FIPS 204, Algorithm 6 ML-DSA.KeyGen_internal().
411
 *
412
 * @param out The generated key (which contains params on input)
413
 *
414
 * @returns 1 on success or 0 on failure.
415
 */
416
static int keygen_internal(ML_DSA_KEY *out)
417
899
{
418
899
    int ret = 0;
419
899
    uint8_t augmented_seed[ML_DSA_SEED_BYTES + 2];
420
899
    uint8_t expanded_seed[ML_DSA_RHO_BYTES + ML_DSA_PRIV_SEED_BYTES + ML_DSA_K_BYTES];
421
899
    const uint8_t *const rho = expanded_seed; /* p = Public Random Seed */
422
899
    const uint8_t *const priv_seed = expanded_seed + ML_DSA_RHO_BYTES;
423
899
    const uint8_t *const K = priv_seed + ML_DSA_PRIV_SEED_BYTES;
424
899
    const ML_DSA_PARAMS *params = out->params;
425
899
    EVP_MD_CTX *md_ctx = NULL;
426
427
899
    if (out->seed == NULL
428
899
        || (md_ctx = EVP_MD_CTX_new()) == NULL
429
899
        || !ossl_ml_dsa_key_pub_alloc(out)
430
899
        || !ossl_ml_dsa_key_priv_alloc(out))
431
0
        goto err;
432
433
    /* augmented_seed = seed || k || l */
434
899
    memcpy(augmented_seed, out->seed, ML_DSA_SEED_BYTES);
435
899
    augmented_seed[ML_DSA_SEED_BYTES] = (uint8_t)params->k;
436
899
    augmented_seed[ML_DSA_SEED_BYTES + 1] = (uint8_t)params->l;
437
    /* Expand the seed into p[32], p'[64], K[32] */
438
899
    if (!shake_xof(md_ctx, out->shake256_md, augmented_seed, sizeof(augmented_seed),
439
899
            expanded_seed, sizeof(expanded_seed)))
440
0
        goto err;
441
442
899
    memcpy(out->rho, rho, sizeof(out->rho));
443
899
    memcpy(out->K, K, sizeof(out->K));
444
445
899
    ret = vector_expand_S(md_ctx, out->shake256_md, params->eta, priv_seed, &out->s1, &out->s2)
446
899
        && public_from_private(out, md_ctx, &out->t1, &out->t0)
447
899
        && ossl_ml_dsa_pk_encode(out)
448
899
        && shake_xof(md_ctx, out->shake256_md, out->pub_encoding, out->params->pk_len,
449
899
            out->tr, sizeof(out->tr))
450
899
        && ossl_ml_dsa_sk_encode(out);
451
452
899
err:
453
899
    if (out->seed != NULL && (out->prov_flags & ML_DSA_KEY_RETAIN_SEED) == 0) {
454
0
        OPENSSL_clear_free(out->seed, ML_DSA_SEED_BYTES);
455
0
        out->seed = NULL;
456
0
    }
457
899
    EVP_MD_CTX_free(md_ctx);
458
899
    OPENSSL_cleanse(augmented_seed, sizeof(augmented_seed));
459
899
    OPENSSL_cleanse(expanded_seed, sizeof(expanded_seed));
460
899
    return ret;
461
899
}
462
463
int ossl_ml_dsa_generate_key(ML_DSA_KEY *out)
464
1.49k
{
465
1.49k
    size_t seed_len = ML_DSA_SEED_BYTES;
466
1.49k
    uint8_t *sk;
467
1.49k
    int ret;
468
469
1.49k
    if (out->seed == NULL) {
470
1.33k
        if ((out->seed = OPENSSL_malloc(seed_len)) == NULL)
471
0
            return 0;
472
1.33k
        if (RAND_priv_bytes_ex(out->libctx, out->seed, seed_len, 0) <= 0) {
473
0
            OPENSSL_free(out->seed);
474
0
            out->seed = NULL;
475
0
            return 0;
476
0
        }
477
1.33k
    }
478
    /* We're generating from a seed, drop private prekey encoding */
479
1.49k
    sk = out->priv_encoding;
480
1.49k
    out->priv_encoding = NULL;
481
1.49k
    if (sk == NULL) {
482
1.49k
        ret = keygen_internal(out);
483
1.49k
    } else {
484
0
        if ((ret = keygen_internal(out)) != 0
485
0
            && memcmp(out->priv_encoding, sk, out->params->sk_len) != 0) {
486
0
            ret = 0;
487
0
            ossl_ml_dsa_key_reset(out);
488
0
            ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_KEY,
489
0
                "explicit %s private key does not match seed",
490
0
                out->params->alg);
491
0
        }
492
0
        OPENSSL_free(sk);
493
0
    }
494
1.49k
    return ret;
495
1.49k
}
496
497
/**
498
 * @brief This is used when a ML DSA key is used for an operation.
499
 * This checks that the algorithm is the same (i.e. uses the same parameters)
500
 *
501
 * @param key A ML_DSA key to use for an operation.
502
 * @param evp_type The algorithm nid associated with an operation
503
 *
504
 * @returns 1 if the algorithm matches, or 0 otherwise.
505
 */
506
507
int ossl_ml_dsa_key_matches(const ML_DSA_KEY *key, int evp_type)
508
1.18k
{
509
1.18k
    return (key->params->evp_type == evp_type);
510
1.18k
}
511
512
/* Returns the public key data or NULL if there is no public key */
513
const uint8_t *ossl_ml_dsa_key_get_pub(const ML_DSA_KEY *key)
514
2.09k
{
515
2.09k
    return key->pub_encoding;
516
2.09k
}
517
518
/* Returns the encoded public key size */
519
size_t ossl_ml_dsa_key_get_pub_len(const ML_DSA_KEY *key)
520
1.59k
{
521
1.59k
    return key->params->pk_len;
522
1.59k
}
523
524
size_t ossl_ml_dsa_key_get_collision_strength_bits(const ML_DSA_KEY *key)
525
1.58k
{
526
1.58k
    return key->params->bit_strength;
527
1.58k
}
528
529
/* Returns the private key data or NULL if there is no private key */
530
const uint8_t *ossl_ml_dsa_key_get_priv(const ML_DSA_KEY *key)
531
2.51k
{
532
2.51k
    return key->priv_encoding;
533
2.51k
}
534
535
size_t ossl_ml_dsa_key_get_priv_len(const ML_DSA_KEY *key)
536
27
{
537
27
    return key->params->sk_len;
538
27
}
539
540
size_t ossl_ml_dsa_key_get_sig_len(const ML_DSA_KEY *key)
541
1.58k
{
542
1.58k
    return key->params->sig_len;
543
1.58k
}
544
545
OSSL_LIB_CTX *ossl_ml_dsa_key_get0_libctx(const ML_DSA_KEY *key)
546
0
{
547
0
    return key != NULL ? key->libctx : NULL;
548
0
}
549
550
const char *ossl_ml_dsa_key_get_name(const ML_DSA_KEY *key)
551
1.18k
{
552
1.18k
    return key->params->alg;
553
1.18k
}