Coverage Report

Created: 2026-09-12 06:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl41/providers/implementations/kdfs/hmacdrbg_kdf.inc
Line
Count
Source
1
/*
2
 * Copyright 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
11
12
/* Machine generated by util/perl/OpenSSL/paramnames.pm */
13
#include <string.h>
14
#include <openssl/params.h>
15
#include <openssl/e_os2.h>
16
#include "internal/common.h"
17
#include "prov/proverr.h"
18
19
/* Machine generated */
20
#ifndef hmac_drbg_kdf_get_ctx_params_list
21
static ossl_unused const OSSL_PARAM hmac_drbg_kdf_get_ctx_params_list[] = {
22
    OSSL_PARAM_utf8_string(OSSL_KDF_PARAM_MAC, NULL, 0),
23
    OSSL_PARAM_utf8_string(OSSL_KDF_PARAM_DIGEST, NULL, 0),
24
    OSSL_PARAM_END
25
};
26
#endif
27
28
#ifndef hmac_drbg_kdf_get_ctx_params_st
29
struct hmac_drbg_kdf_get_ctx_params_st {
30
    OSSL_PARAM *digest;
31
    OSSL_PARAM *mac;
32
};
33
#endif
34
35
#ifndef hmac_drbg_kdf_get_ctx_params_decoder
36
static ossl_unused int hmac_drbg_kdf_get_ctx_params_decoder
37
    (const OSSL_PARAM *p, struct hmac_drbg_kdf_get_ctx_params_st *r)
38
0
{
39
0
    const char *s;
40
41
0
    memset(r, 0, sizeof(*r));
42
0
    if (p != NULL)
43
0
        for (; (s = p->key) != NULL; p++)
44
0
            switch(s[0]) {
45
0
            default:
46
0
                break;
47
0
            case 'd':
48
0
                if (ossl_likely(strcmp("igest", s + 1) == 0)) {
49
                    /* OSSL_KDF_PARAM_DIGEST */
50
0
                    if (ossl_unlikely(r->digest != NULL)) {
51
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
52
0
                                       "param %s is repeated", s);
53
0
                        return 0;
54
0
                    }
55
0
                    r->digest = (OSSL_PARAM *)p;
56
0
                }
57
0
                break;
58
0
            case 'm':
59
0
                if (ossl_likely(strcmp("ac", s + 1) == 0)) {
60
                    /* OSSL_KDF_PARAM_MAC */
61
0
                    if (ossl_unlikely(r->mac != NULL)) {
62
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
63
0
                                       "param %s is repeated", s);
64
0
                        return 0;
65
0
                    }
66
0
                    r->mac = (OSSL_PARAM *)p;
67
0
                }
68
0
            }
69
0
    return 1;
70
0
}
71
#endif
72
/* End of machine generated */
73
74
/* Machine generated */
75
#ifndef hmac_drbg_kdf_set_ctx_params_list
76
static ossl_unused const OSSL_PARAM hmac_drbg_kdf_set_ctx_params_list[] = {
77
    OSSL_PARAM_utf8_string(OSSL_KDF_PARAM_PROPERTIES, NULL, 0),
78
    OSSL_PARAM_utf8_string(OSSL_KDF_PARAM_DIGEST, NULL, 0),
79
    OSSL_PARAM_octet_string(OSSL_KDF_PARAM_HMACDRBG_ENTROPY, NULL, 0),
80
    OSSL_PARAM_octet_string(OSSL_KDF_PARAM_HMACDRBG_NONCE, NULL, 0),
81
    OSSL_PARAM_END
82
};
83
#endif
84
85
#ifndef hmac_drbg_kdf_set_ctx_params_st
86
struct hmac_drbg_kdf_set_ctx_params_st {
87
    OSSL_PARAM *digest;
88
    OSSL_PARAM *ent;
89
    OSSL_PARAM *nonce;
90
    OSSL_PARAM *propq;
91
};
92
#endif
93
94
#ifndef hmac_drbg_kdf_set_ctx_params_decoder
95
static ossl_unused int hmac_drbg_kdf_set_ctx_params_decoder
96
    (const OSSL_PARAM *p, struct hmac_drbg_kdf_set_ctx_params_st *r)
97
168
{
98
168
    const char *s;
99
100
168
    memset(r, 0, sizeof(*r));
101
168
    if (p != NULL)
102
445
        for (; (s = p->key) != NULL; p++)
103
356
            switch(s[0]) {
104
0
            default:
105
0
                break;
106
89
            case 'd':
107
89
                if (ossl_likely(strcmp("igest", s + 1) == 0)) {
108
                    /* OSSL_KDF_PARAM_DIGEST */
109
89
                    if (ossl_unlikely(r->digest != NULL)) {
110
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
111
0
                                       "param %s is repeated", s);
112
0
                        return 0;
113
0
                    }
114
89
                    r->digest = (OSSL_PARAM *)p;
115
89
                }
116
89
                break;
117
89
            case 'e':
118
89
                if (ossl_likely(strcmp("ntropy", s + 1) == 0)) {
119
                    /* OSSL_KDF_PARAM_HMACDRBG_ENTROPY */
120
89
                    if (ossl_unlikely(r->ent != NULL)) {
121
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
122
0
                                       "param %s is repeated", s);
123
0
                        return 0;
124
0
                    }
125
89
                    r->ent = (OSSL_PARAM *)p;
126
89
                }
127
89
                break;
128
89
            case 'n':
129
89
                if (ossl_likely(strcmp("once", s + 1) == 0)) {
130
                    /* OSSL_KDF_PARAM_HMACDRBG_NONCE */
131
89
                    if (ossl_unlikely(r->nonce != NULL)) {
132
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
133
0
                                       "param %s is repeated", s);
134
0
                        return 0;
135
0
                    }
136
89
                    r->nonce = (OSSL_PARAM *)p;
137
89
                }
138
89
                break;
139
89
            case 'p':
140
89
                if (ossl_likely(strcmp("roperties", s + 1) == 0)) {
141
                    /* OSSL_KDF_PARAM_PROPERTIES */
142
89
                    if (ossl_unlikely(r->propq != NULL)) {
143
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
144
0
                                       "param %s is repeated", s);
145
0
                        return 0;
146
0
                    }
147
89
                    r->propq = (OSSL_PARAM *)p;
148
89
                }
149
356
            }
150
168
    return 1;
151
168
}
152
#endif
153
/* End of machine generated */