Coverage Report

Created: 2025-12-10 06:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/crypto/ml_dsa/ml_dsa_params.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
#include <stddef.h>
10
#include <string.h>
11
#include <openssl/evp.h>
12
#include "ml_dsa_local.h"
13
14
/* See FIPS 204 Section 4 Table 1 & Table 2 */
15
#define ML_DSA_44_TAU 39
16
#define ML_DSA_44_LAMBDA 128
17
#define ML_DSA_44_K 4
18
#define ML_DSA_44_L 4
19
#define ML_DSA_44_ETA ML_DSA_ETA_2
20
#define ML_DSA_44_BETA 78
21
#define ML_DSA_44_OMEGA 80
22
#define ML_DSA_44_SECURITY_CATEGORY 2
23
24
/* See FIPS 204 Section 4 Table 1 & Table 2 */
25
#define ML_DSA_65_TAU 49
26
#define ML_DSA_65_LAMBDA 192
27
#define ML_DSA_65_K 6
28
#define ML_DSA_65_L 5
29
#define ML_DSA_65_ETA ML_DSA_ETA_4
30
#define ML_DSA_65_BETA 196
31
#define ML_DSA_65_OMEGA 55
32
#define ML_DSA_65_SECURITY_CATEGORY 3
33
34
/* See FIPS 204 Section 4 Table 1 & Table 2 */
35
#define ML_DSA_87_TAU 60
36
#define ML_DSA_87_LAMBDA 256
37
#define ML_DSA_87_K 8
38
#define ML_DSA_87_L 7
39
#define ML_DSA_87_ETA ML_DSA_ETA_2
40
#define ML_DSA_87_BETA 120
41
#define ML_DSA_87_OMEGA 75
42
#define ML_DSA_87_SECURITY_CATEGORY 5
43
44
static const ML_DSA_PARAMS ml_dsa_params[] = {
45
    { "ML-DSA-44",
46
        EVP_PKEY_ML_DSA_44,
47
        ML_DSA_44_TAU,
48
        ML_DSA_44_LAMBDA,
49
        ML_DSA_GAMMA1_TWO_POWER_17,
50
        ML_DSA_GAMMA2_Q_MINUS1_DIV88,
51
        ML_DSA_44_K,
52
        ML_DSA_44_L,
53
        ML_DSA_44_ETA,
54
        ML_DSA_44_BETA,
55
        ML_DSA_44_OMEGA,
56
        ML_DSA_44_SECURITY_CATEGORY,
57
        ML_DSA_44_PRIV_LEN,
58
        ML_DSA_44_PUB_LEN,
59
        ML_DSA_44_SIG_LEN },
60
    { "ML-DSA-65",
61
        EVP_PKEY_ML_DSA_65,
62
        ML_DSA_65_TAU,
63
        ML_DSA_65_LAMBDA,
64
        ML_DSA_GAMMA1_TWO_POWER_19,
65
        ML_DSA_GAMMA2_Q_MINUS1_DIV32,
66
        ML_DSA_65_K,
67
        ML_DSA_65_L,
68
        ML_DSA_65_ETA,
69
        ML_DSA_65_BETA,
70
        ML_DSA_65_OMEGA,
71
        ML_DSA_65_SECURITY_CATEGORY,
72
        ML_DSA_65_PRIV_LEN,
73
        ML_DSA_65_PUB_LEN,
74
        ML_DSA_65_SIG_LEN },
75
    { "ML-DSA-87",
76
        EVP_PKEY_ML_DSA_87,
77
        ML_DSA_87_TAU,
78
        ML_DSA_87_LAMBDA,
79
        ML_DSA_GAMMA1_TWO_POWER_19,
80
        ML_DSA_GAMMA2_Q_MINUS1_DIV32,
81
        ML_DSA_87_K,
82
        ML_DSA_87_L,
83
        ML_DSA_87_ETA,
84
        ML_DSA_87_BETA,
85
        ML_DSA_87_OMEGA,
86
        ML_DSA_87_SECURITY_CATEGORY,
87
        ML_DSA_87_PRIV_LEN,
88
        ML_DSA_87_PUB_LEN,
89
        ML_DSA_87_SIG_LEN },
90
    { NULL },
91
};
92
93
/**
94
 * @brief A getter to convert an algorithm name into a ML_DSA_PARAMS object
95
 */
96
const ML_DSA_PARAMS *ossl_ml_dsa_params_get(int evp_type)
97
0
{
98
0
    const ML_DSA_PARAMS *p;
99
100
0
    for (p = ml_dsa_params; p->alg != NULL; ++p) {
101
0
        if (p->evp_type == evp_type)
102
0
            return p;
103
0
    }
104
0
    return NULL;
105
0
}