Coverage Report

Created: 2026-07-23 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl35/providers/implementations/macs/blake2_mac_impl.c
Line
Count
Source
1
/*
2
 * Copyright 2018-2023 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/params.h>
13
#include <openssl/proverr.h>
14
15
#include "prov/blake2.h"
16
#include "internal/cryptlib.h"
17
#include "prov/implementations.h"
18
#include "prov/providercommon.h"
19
20
/*
21
 * Forward declaration of everything implemented here.  This is not strictly
22
 * necessary for the compiler, but provides an assurance that the signatures
23
 * of the functions in the dispatch table are correct.
24
 */
25
static OSSL_FUNC_mac_newctx_fn blake2_mac_new;
26
static OSSL_FUNC_mac_dupctx_fn blake2_mac_dup;
27
static OSSL_FUNC_mac_freectx_fn blake2_mac_free;
28
static OSSL_FUNC_mac_gettable_ctx_params_fn blake2_gettable_ctx_params;
29
static OSSL_FUNC_mac_get_ctx_params_fn blake2_get_ctx_params;
30
static OSSL_FUNC_mac_settable_ctx_params_fn blake2_mac_settable_ctx_params;
31
static OSSL_FUNC_mac_set_ctx_params_fn blake2_mac_set_ctx_params;
32
static OSSL_FUNC_mac_init_fn blake2_mac_init;
33
static OSSL_FUNC_mac_update_fn blake2_mac_update;
34
static OSSL_FUNC_mac_final_fn blake2_mac_final;
35
36
struct blake2_mac_data_st {
37
    BLAKE2_CTX ctx;
38
    BLAKE2_PARAM params;
39
    unsigned char key[BLAKE2_KEYBYTES];
40
};
41
42
static void *blake2_mac_new(void *unused_provctx)
43
405
{
44
405
    struct blake2_mac_data_st *macctx;
45
46
405
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
405
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
405
    if (macctx != NULL) {
51
405
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
405
    }
54
405
    return macctx;
55
405
}
blake2b_mac.c:blake2_mac_new
Line
Count
Source
43
220
{
44
220
    struct blake2_mac_data_st *macctx;
45
46
220
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
220
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
220
    if (macctx != NULL) {
51
220
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
220
    }
54
220
    return macctx;
55
220
}
blake2s_mac.c:blake2_mac_new
Line
Count
Source
43
185
{
44
185
    struct blake2_mac_data_st *macctx;
45
46
185
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
185
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
185
    if (macctx != NULL) {
51
185
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
185
    }
54
185
    return macctx;
55
185
}
56
57
static void *blake2_mac_dup(void *vsrc)
58
0
{
59
0
    struct blake2_mac_data_st *dst;
60
0
    struct blake2_mac_data_st *src = vsrc;
61
62
0
    if (!ossl_prov_is_running())
63
0
        return NULL;
64
65
0
    dst = OPENSSL_zalloc(sizeof(*dst));
66
0
    if (dst == NULL)
67
0
        return NULL;
68
69
0
    *dst = *src;
70
0
    return dst;
71
0
}
Unexecuted instantiation: blake2b_mac.c:blake2_mac_dup
Unexecuted instantiation: blake2s_mac.c:blake2_mac_dup
72
73
static void blake2_mac_free(void *vmacctx)
74
405
{
75
405
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
405
    if (macctx != NULL) {
78
405
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
405
        OPENSSL_free(macctx);
80
405
    }
81
405
}
blake2b_mac.c:blake2_mac_free
Line
Count
Source
74
220
{
75
220
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
220
    if (macctx != NULL) {
78
220
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
220
        OPENSSL_free(macctx);
80
220
    }
81
220
}
blake2s_mac.c:blake2_mac_free
Line
Count
Source
74
185
{
75
185
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
185
    if (macctx != NULL) {
78
185
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
185
        OPENSSL_free(macctx);
80
185
    }
81
185
}
82
83
static size_t blake2_mac_size(void *vmacctx)
84
13.5k
{
85
13.5k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
13.5k
    return macctx->params.digest_length;
88
13.5k
}
blake2b_mac.c:blake2_mac_size
Line
Count
Source
84
7.13k
{
85
7.13k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
7.13k
    return macctx->params.digest_length;
88
7.13k
}
blake2s_mac.c:blake2_mac_size
Line
Count
Source
84
6.40k
{
85
6.40k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
6.40k
    return macctx->params.digest_length;
88
6.40k
}
89
90
static int blake2_setkey(struct blake2_mac_data_st *macctx,
91
    const unsigned char *key, size_t keylen)
92
7.24k
{
93
7.24k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
94
94
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
95
94
        return 0;
96
94
    }
97
7.14k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
7.14k
    if (keylen < BLAKE2_KEYBYTES)
100
6.48k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
7.14k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
7.14k
    return 1;
103
7.24k
}
blake2b_mac.c:blake2_setkey
Line
Count
Source
92
3.83k
{
93
3.83k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
94
51
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
95
51
        return 0;
96
51
    }
97
3.78k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
3.78k
    if (keylen < BLAKE2_KEYBYTES)
100
3.54k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
3.78k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
3.78k
    return 1;
103
3.83k
}
blake2s_mac.c:blake2_setkey
Line
Count
Source
92
3.41k
{
93
3.41k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
94
43
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
95
43
        return 0;
96
43
    }
97
3.36k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
3.36k
    if (keylen < BLAKE2_KEYBYTES)
100
2.94k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
3.36k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
3.36k
    return 1;
103
3.41k
}
104
105
static int blake2_mac_init(void *vmacctx, const unsigned char *key,
106
    size_t keylen, const OSSL_PARAM params[])
107
6.99k
{
108
6.99k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
6.99k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
212
        return 0;
112
6.77k
    if (key != NULL) {
113
6.77k
        if (!blake2_setkey(macctx, key, keylen))
114
4
            return 0;
115
6.77k
    } else if (macctx->params.key_length == 0) {
116
        /* Check key has been set */
117
0
        ERR_raise(ERR_LIB_PROV, PROV_R_NO_KEY_SET);
118
0
        return 0;
119
0
    }
120
6.77k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
6.77k
}
blake2b_mac.c:blake2_mac_init
Line
Count
Source
107
3.69k
{
108
3.69k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
3.69k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
118
        return 0;
112
3.57k
    if (key != NULL) {
113
3.57k
        if (!blake2_setkey(macctx, key, keylen))
114
0
            return 0;
115
3.57k
    } else if (macctx->params.key_length == 0) {
116
        /* Check key has been set */
117
0
        ERR_raise(ERR_LIB_PROV, PROV_R_NO_KEY_SET);
118
0
        return 0;
119
0
    }
120
3.57k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
3.57k
}
blake2s_mac.c:blake2_mac_init
Line
Count
Source
107
3.29k
{
108
3.29k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
3.29k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
94
        return 0;
112
3.20k
    if (key != NULL) {
113
3.20k
        if (!blake2_setkey(macctx, key, keylen))
114
4
            return 0;
115
3.20k
    } else if (macctx->params.key_length == 0) {
116
        /* Check key has been set */
117
0
        ERR_raise(ERR_LIB_PROV, PROV_R_NO_KEY_SET);
118
0
        return 0;
119
0
    }
120
3.20k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
3.20k
}
122
123
static int blake2_mac_update(void *vmacctx,
124
    const unsigned char *data, size_t datalen)
125
7.17k
{
126
7.17k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
7.17k
    if (datalen == 0)
129
0
        return 1;
130
131
7.17k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
7.17k
}
blake2b_mac.c:blake2_mac_update
Line
Count
Source
125
3.77k
{
126
3.77k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
3.77k
    if (datalen == 0)
129
0
        return 1;
130
131
3.77k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
3.77k
}
blake2s_mac.c:blake2_mac_update
Line
Count
Source
125
3.40k
{
126
3.40k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
3.40k
    if (datalen == 0)
129
0
        return 1;
130
131
3.40k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
3.40k
}
133
134
static int blake2_mac_final(void *vmacctx,
135
    unsigned char *out, size_t *outl,
136
    size_t outsize)
137
6.76k
{
138
6.76k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
6.76k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
6.76k
    *outl = blake2_mac_size(macctx);
144
6.76k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
6.76k
}
blake2b_mac.c:blake2_mac_final
Line
Count
Source
137
3.56k
{
138
3.56k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
3.56k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
3.56k
    *outl = blake2_mac_size(macctx);
144
3.56k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
3.56k
}
blake2s_mac.c:blake2_mac_final
Line
Count
Source
137
3.20k
{
138
3.20k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
3.20k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
3.20k
    *outl = blake2_mac_size(macctx);
144
3.20k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
3.20k
}
146
147
static const OSSL_PARAM known_gettable_ctx_params[] = {
148
    OSSL_PARAM_size_t(OSSL_MAC_PARAM_SIZE, NULL),
149
    OSSL_PARAM_size_t(OSSL_MAC_PARAM_BLOCK_SIZE, NULL),
150
    OSSL_PARAM_END
151
};
152
static const OSSL_PARAM *blake2_gettable_ctx_params(ossl_unused void *ctx,
153
    ossl_unused void *provctx)
154
0
{
155
0
    return known_gettable_ctx_params;
156
0
}
Unexecuted instantiation: blake2b_mac.c:blake2_gettable_ctx_params
Unexecuted instantiation: blake2s_mac.c:blake2_gettable_ctx_params
157
158
static int blake2_get_ctx_params(void *vmacctx, OSSL_PARAM params[])
159
4.03k
{
160
4.03k
    OSSL_PARAM *p;
161
162
4.03k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL
163
4.03k
        && !OSSL_PARAM_set_size_t(p, blake2_mac_size(vmacctx)))
164
0
        return 0;
165
166
4.03k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_BLOCK_SIZE)) != NULL
167
0
        && !OSSL_PARAM_set_size_t(p, BLAKE2_BLOCKBYTES))
168
0
        return 0;
169
170
4.03k
    return 1;
171
4.03k
}
blake2b_mac.c:blake2_get_ctx_params
Line
Count
Source
159
2.18k
{
160
2.18k
    OSSL_PARAM *p;
161
162
2.18k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL
163
2.18k
        && !OSSL_PARAM_set_size_t(p, blake2_mac_size(vmacctx)))
164
0
        return 0;
165
166
2.18k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_BLOCK_SIZE)) != NULL
167
0
        && !OSSL_PARAM_set_size_t(p, BLAKE2_BLOCKBYTES))
168
0
        return 0;
169
170
2.18k
    return 1;
171
2.18k
}
blake2s_mac.c:blake2_get_ctx_params
Line
Count
Source
159
1.85k
{
160
1.85k
    OSSL_PARAM *p;
161
162
1.85k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL
163
1.85k
        && !OSSL_PARAM_set_size_t(p, blake2_mac_size(vmacctx)))
164
0
        return 0;
165
166
1.85k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_BLOCK_SIZE)) != NULL
167
0
        && !OSSL_PARAM_set_size_t(p, BLAKE2_BLOCKBYTES))
168
0
        return 0;
169
170
1.85k
    return 1;
171
1.85k
}
172
173
static const OSSL_PARAM known_settable_ctx_params[] = {
174
    OSSL_PARAM_size_t(OSSL_MAC_PARAM_SIZE, NULL),
175
    OSSL_PARAM_octet_string(OSSL_MAC_PARAM_KEY, NULL, 0),
176
    OSSL_PARAM_octet_string(OSSL_MAC_PARAM_CUSTOM, NULL, 0),
177
    OSSL_PARAM_octet_string(OSSL_MAC_PARAM_SALT, NULL, 0),
178
    OSSL_PARAM_END
179
};
180
static const OSSL_PARAM *blake2_mac_settable_ctx_params(
181
    ossl_unused void *ctx, ossl_unused void *p_ctx)
182
358
{
183
358
    return known_settable_ctx_params;
184
358
}
blake2b_mac.c:blake2_mac_settable_ctx_params
Line
Count
Source
182
198
{
183
198
    return known_settable_ctx_params;
184
198
}
blake2s_mac.c:blake2_mac_settable_ctx_params
Line
Count
Source
182
160
{
183
160
    return known_settable_ctx_params;
184
160
}
185
186
/*
187
 * ALL parameters should be set before init().
188
 */
189
static int blake2_mac_set_ctx_params(void *vmacctx, const OSSL_PARAM params[])
190
1.85k
{
191
1.85k
    struct blake2_mac_data_st *macctx = vmacctx;
192
1.85k
    const OSSL_PARAM *p;
193
194
1.85k
    if (ossl_param_is_empty(params))
195
1.70k
        return 1;
196
197
151
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
140
        size_t size;
199
200
140
        if (!OSSL_PARAM_get_size_t(p, &size)
201
140
            || size < 1
202
138
            || size > BLAKE2_OUTBYTES) {
203
8
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
8
            return 0;
205
8
        }
206
132
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
132
    }
208
209
143
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
132
        && !blake2_setkey(macctx, p->data, p->data_size))
211
22
        return 0;
212
213
121
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_CUSTOM))
214
121
        != NULL) {
215
        /*
216
         * The OSSL_PARAM API doesn't provide direct pointer use, so we
217
         * must handle the OSSL_PARAM structure ourselves here
218
         */
219
110
        if (p->data_size > BLAKE2_PERSONALBYTES) {
220
17
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
221
17
            return 0;
222
17
        }
223
93
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
93
    }
225
226
104
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SALT)) != NULL) {
227
        /*
228
         * The OSSL_PARAM API doesn't provide direct pointer use, so we
229
         * must handle the OSSL_PARAM structure ourselves here as well
230
         */
231
93
        if (p->data_size > BLAKE2_SALTBYTES) {
232
9
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
233
9
            return 0;
234
9
        }
235
84
        BLAKE2_PARAM_SET_SALT(&macctx->params, p->data, p->data_size);
236
84
    }
237
95
    return 1;
238
104
}
blake2b_mac.c:blake2_mac_set_ctx_params
Line
Count
Source
190
1.01k
{
191
1.01k
    struct blake2_mac_data_st *macctx = vmacctx;
192
1.01k
    const OSSL_PARAM *p;
193
194
1.01k
    if (ossl_param_is_empty(params))
195
925
        return 1;
196
197
90
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
85
        size_t size;
199
200
85
        if (!OSSL_PARAM_get_size_t(p, &size)
201
85
            || size < 1
202
84
            || size > BLAKE2_OUTBYTES) {
203
3
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
3
            return 0;
205
3
        }
206
82
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
82
    }
208
209
87
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
82
        && !blake2_setkey(macctx, p->data, p->data_size))
211
12
        return 0;
212
213
75
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_CUSTOM))
214
75
        != NULL) {
215
        /*
216
         * The OSSL_PARAM API doesn't provide direct pointer use, so we
217
         * must handle the OSSL_PARAM structure ourselves here
218
         */
219
70
        if (p->data_size > BLAKE2_PERSONALBYTES) {
220
10
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
221
10
            return 0;
222
10
        }
223
60
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
60
    }
225
226
65
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SALT)) != NULL) {
227
        /*
228
         * The OSSL_PARAM API doesn't provide direct pointer use, so we
229
         * must handle the OSSL_PARAM structure ourselves here as well
230
         */
231
60
        if (p->data_size > BLAKE2_SALTBYTES) {
232
8
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
233
8
            return 0;
234
8
        }
235
52
        BLAKE2_PARAM_SET_SALT(&macctx->params, p->data, p->data_size);
236
52
    }
237
57
    return 1;
238
65
}
blake2s_mac.c:blake2_mac_set_ctx_params
Line
Count
Source
190
838
{
191
838
    struct blake2_mac_data_st *macctx = vmacctx;
192
838
    const OSSL_PARAM *p;
193
194
838
    if (ossl_param_is_empty(params))
195
777
        return 1;
196
197
61
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
55
        size_t size;
199
200
55
        if (!OSSL_PARAM_get_size_t(p, &size)
201
55
            || size < 1
202
54
            || size > BLAKE2_OUTBYTES) {
203
5
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
5
            return 0;
205
5
        }
206
50
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
50
    }
208
209
56
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
50
        && !blake2_setkey(macctx, p->data, p->data_size))
211
10
        return 0;
212
213
46
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_CUSTOM))
214
46
        != NULL) {
215
        /*
216
         * The OSSL_PARAM API doesn't provide direct pointer use, so we
217
         * must handle the OSSL_PARAM structure ourselves here
218
         */
219
40
        if (p->data_size > BLAKE2_PERSONALBYTES) {
220
7
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
221
7
            return 0;
222
7
        }
223
33
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
33
    }
225
226
39
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SALT)) != NULL) {
227
        /*
228
         * The OSSL_PARAM API doesn't provide direct pointer use, so we
229
         * must handle the OSSL_PARAM structure ourselves here as well
230
         */
231
33
        if (p->data_size > BLAKE2_SALTBYTES) {
232
1
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
233
1
            return 0;
234
1
        }
235
32
        BLAKE2_PARAM_SET_SALT(&macctx->params, p->data, p->data_size);
236
32
    }
237
38
    return 1;
238
39
}
239
240
const OSSL_DISPATCH BLAKE2_FUNCTIONS[] = {
241
    { OSSL_FUNC_MAC_NEWCTX, (void (*)(void))blake2_mac_new },
242
    { OSSL_FUNC_MAC_DUPCTX, (void (*)(void))blake2_mac_dup },
243
    { OSSL_FUNC_MAC_FREECTX, (void (*)(void))blake2_mac_free },
244
    { OSSL_FUNC_MAC_INIT, (void (*)(void))blake2_mac_init },
245
    { OSSL_FUNC_MAC_UPDATE, (void (*)(void))blake2_mac_update },
246
    { OSSL_FUNC_MAC_FINAL, (void (*)(void))blake2_mac_final },
247
    { OSSL_FUNC_MAC_GETTABLE_CTX_PARAMS,
248
        (void (*)(void))blake2_gettable_ctx_params },
249
    { OSSL_FUNC_MAC_GET_CTX_PARAMS, (void (*)(void))blake2_get_ctx_params },
250
    { OSSL_FUNC_MAC_SETTABLE_CTX_PARAMS,
251
        (void (*)(void))blake2_mac_settable_ctx_params },
252
    { OSSL_FUNC_MAC_SET_CTX_PARAMS, (void (*)(void))blake2_mac_set_ctx_params },
253
    OSSL_DISPATCH_END
254
};