Coverage Report

Created: 2026-05-20 07:05

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