Coverage Report

Created: 2026-02-14 07:20

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
401
{
44
401
    struct blake2_mac_data_st *macctx;
45
46
401
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
401
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
401
    if (macctx != NULL) {
51
401
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
401
    }
54
401
    return macctx;
55
401
}
blake2b_mac.c:blake2_mac_new
Line
Count
Source
43
221
{
44
221
    struct blake2_mac_data_st *macctx;
45
46
221
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
221
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
221
    if (macctx != NULL) {
51
221
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
221
    }
54
221
    return macctx;
55
221
}
blake2s_mac.c:blake2_mac_new
Line
Count
Source
43
180
{
44
180
    struct blake2_mac_data_st *macctx;
45
46
180
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
180
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
180
    if (macctx != NULL) {
51
180
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
180
    }
54
180
    return macctx;
55
180
}
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
401
{
75
401
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
401
    if (macctx != NULL) {
78
401
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
401
        OPENSSL_free(macctx);
80
401
    }
81
401
}
blake2b_mac.c:blake2_mac_free
Line
Count
Source
74
221
{
75
221
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
221
    if (macctx != NULL) {
78
221
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
221
        OPENSSL_free(macctx);
80
221
    }
81
221
}
blake2s_mac.c:blake2_mac_free
Line
Count
Source
74
180
{
75
180
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
180
    if (macctx != NULL) {
78
180
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
180
        OPENSSL_free(macctx);
80
180
    }
81
180
}
82
83
static size_t blake2_mac_size(void *vmacctx)
84
14.5k
{
85
14.5k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
14.5k
    return macctx->params.digest_length;
88
14.5k
}
blake2b_mac.c:blake2_mac_size
Line
Count
Source
84
7.09k
{
85
7.09k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
7.09k
    return macctx->params.digest_length;
88
7.09k
}
blake2s_mac.c:blake2_mac_size
Line
Count
Source
84
7.45k
{
85
7.45k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
7.45k
    return macctx->params.digest_length;
88
7.45k
}
89
90
static int blake2_setkey(struct blake2_mac_data_st *macctx,
91
    const unsigned char *key, size_t keylen)
92
7.73k
{
93
7.73k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
94
97
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
95
97
        return 0;
96
97
    }
97
7.63k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
7.63k
    if (keylen < BLAKE2_KEYBYTES)
100
6.97k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
7.63k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
7.63k
    return 1;
103
7.73k
}
blake2b_mac.c:blake2_setkey
Line
Count
Source
92
3.81k
{
93
3.81k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
94
52
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
95
52
        return 0;
96
52
    }
97
3.76k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
3.76k
    if (keylen < BLAKE2_KEYBYTES)
100
3.52k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
3.76k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
3.76k
    return 1;
103
3.81k
}
blake2s_mac.c:blake2_setkey
Line
Count
Source
92
3.91k
{
93
3.91k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
94
45
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
95
45
        return 0;
96
45
    }
97
3.87k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
3.87k
    if (keylen < BLAKE2_KEYBYTES)
100
3.44k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
3.87k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
3.87k
    return 1;
103
3.91k
}
104
105
static int blake2_mac_init(void *vmacctx, const unsigned char *key,
106
    size_t keylen, const OSSL_PARAM params[])
107
7.49k
{
108
7.49k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
7.49k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
209
        return 0;
112
7.28k
    if (key != NULL) {
113
7.28k
        if (!blake2_setkey(macctx, key, keylen))
114
3
            return 0;
115
7.28k
    } 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
7.28k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
7.28k
}
blake2b_mac.c:blake2_mac_init
Line
Count
Source
107
3.66k
{
108
3.66k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
3.66k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
114
        return 0;
112
3.55k
    if (key != NULL) {
113
3.55k
        if (!blake2_setkey(macctx, key, keylen))
114
0
            return 0;
115
3.55k
    } 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.55k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
3.55k
}
blake2s_mac.c:blake2_mac_init
Line
Count
Source
107
3.82k
{
108
3.82k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
3.82k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
95
        return 0;
112
3.73k
    if (key != NULL) {
113
3.73k
        if (!blake2_setkey(macctx, key, keylen))
114
3
            return 0;
115
3.73k
    } 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.72k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
3.73k
}
122
123
static int blake2_mac_update(void *vmacctx,
124
    const unsigned char *data, size_t datalen)
125
7.72k
{
126
7.72k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
7.72k
    if (datalen == 0)
129
0
        return 1;
130
131
7.72k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
7.72k
}
blake2b_mac.c:blake2_mac_update
Line
Count
Source
125
3.75k
{
126
3.75k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
3.75k
    if (datalen == 0)
129
0
        return 1;
130
131
3.75k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
3.75k
}
blake2s_mac.c:blake2_mac_update
Line
Count
Source
125
3.96k
{
126
3.96k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
3.96k
    if (datalen == 0)
129
0
        return 1;
130
131
3.96k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
3.96k
}
133
134
static int blake2_mac_final(void *vmacctx,
135
    unsigned char *out, size_t *outl,
136
    size_t outsize)
137
7.26k
{
138
7.26k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
7.26k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
7.26k
    *outl = blake2_mac_size(macctx);
144
7.26k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
7.26k
}
blake2b_mac.c:blake2_mac_final
Line
Count
Source
137
3.54k
{
138
3.54k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
3.54k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
3.54k
    *outl = blake2_mac_size(macctx);
144
3.54k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
3.54k
}
blake2s_mac.c:blake2_mac_final
Line
Count
Source
137
3.72k
{
138
3.72k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
3.72k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
3.72k
    *outl = blake2_mac_size(macctx);
144
3.72k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
3.72k
}
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.80k
{
160
4.80k
    OSSL_PARAM *p;
161
162
4.80k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL
163
4.80k
        && !OSSL_PARAM_set_size_t(p, blake2_mac_size(vmacctx)))
164
0
        return 0;
165
166
4.80k
    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.80k
    return 1;
171
4.80k
}
blake2b_mac.c:blake2_get_ctx_params
Line
Count
Source
159
2.41k
{
160
2.41k
    OSSL_PARAM *p;
161
162
2.41k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL
163
2.41k
        && !OSSL_PARAM_set_size_t(p, blake2_mac_size(vmacctx)))
164
0
        return 0;
165
166
2.41k
    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.41k
    return 1;
171
2.41k
}
blake2s_mac.c:blake2_get_ctx_params
Line
Count
Source
159
2.38k
{
160
2.38k
    OSSL_PARAM *p;
161
162
2.38k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL
163
2.38k
        && !OSSL_PARAM_set_size_t(p, blake2_mac_size(vmacctx)))
164
0
        return 0;
165
166
2.38k
    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.38k
    return 1;
171
2.38k
}
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
353
{
183
353
    return known_settable_ctx_params;
184
353
}
blake2b_mac.c:blake2_mac_settable_ctx_params
Line
Count
Source
182
199
{
183
199
    return known_settable_ctx_params;
184
199
}
blake2s_mac.c:blake2_mac_settable_ctx_params
Line
Count
Source
182
154
{
183
154
    return known_settable_ctx_params;
184
154
}
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
2.30k
{
191
2.30k
    struct blake2_mac_data_st *macctx = vmacctx;
192
2.30k
    const OSSL_PARAM *p;
193
194
2.30k
    if (ossl_param_is_empty(params))
195
2.15k
        return 1;
196
197
143
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
130
        size_t size;
199
200
130
        if (!OSSL_PARAM_get_size_t(p, &size)
201
130
            || size < 1
202
126
            || size > BLAKE2_OUTBYTES) {
203
13
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
13
            return 0;
205
13
        }
206
117
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
117
    }
208
209
130
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
117
        && !blake2_setkey(macctx, p->data, p->data_size))
211
20
        return 0;
212
213
110
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_CUSTOM))
214
110
        != 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
97
        if (p->data_size > BLAKE2_PERSONALBYTES) {
220
8
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
221
8
            return 0;
222
8
        }
223
89
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
89
    }
225
226
102
    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
89
        if (p->data_size > BLAKE2_SALTBYTES) {
232
11
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
233
11
            return 0;
234
11
        }
235
78
        BLAKE2_PARAM_SET_SALT(&macctx->params, p->data, p->data_size);
236
78
    }
237
91
    return 1;
238
102
}
blake2b_mac.c:blake2_mac_set_ctx_params
Line
Count
Source
190
927
{
191
927
    struct blake2_mac_data_st *macctx = vmacctx;
192
927
    const OSSL_PARAM *p;
193
194
927
    if (ossl_param_is_empty(params))
195
846
        return 1;
196
197
81
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
76
        size_t size;
199
200
76
        if (!OSSL_PARAM_get_size_t(p, &size)
201
76
            || size < 1
202
74
            || size > BLAKE2_OUTBYTES) {
203
6
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
6
            return 0;
205
6
        }
206
70
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
70
    }
208
209
75
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
70
        && !blake2_setkey(macctx, p->data, p->data_size))
211
9
        return 0;
212
213
66
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_CUSTOM))
214
66
        != 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
61
        if (p->data_size > BLAKE2_PERSONALBYTES) {
220
4
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
221
4
            return 0;
222
4
        }
223
57
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
57
    }
225
226
62
    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
57
        if (p->data_size > BLAKE2_SALTBYTES) {
232
7
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
233
7
            return 0;
234
7
        }
235
50
        BLAKE2_PARAM_SET_SALT(&macctx->params, p->data, p->data_size);
236
50
    }
237
55
    return 1;
238
62
}
blake2s_mac.c:blake2_mac_set_ctx_params
Line
Count
Source
190
1.37k
{
191
1.37k
    struct blake2_mac_data_st *macctx = vmacctx;
192
1.37k
    const OSSL_PARAM *p;
193
194
1.37k
    if (ossl_param_is_empty(params))
195
1.31k
        return 1;
196
197
62
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
54
        size_t size;
199
200
54
        if (!OSSL_PARAM_get_size_t(p, &size)
201
54
            || size < 1
202
52
            || size > BLAKE2_OUTBYTES) {
203
7
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
7
            return 0;
205
7
        }
206
47
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
47
    }
208
209
55
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
47
        && !blake2_setkey(macctx, p->data, p->data_size))
211
11
        return 0;
212
213
44
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_CUSTOM))
214
44
        != 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
36
        if (p->data_size > BLAKE2_PERSONALBYTES) {
220
4
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
221
4
            return 0;
222
4
        }
223
32
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
32
    }
225
226
40
    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
32
        if (p->data_size > BLAKE2_SALTBYTES) {
232
4
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
233
4
            return 0;
234
4
        }
235
28
        BLAKE2_PARAM_SET_SALT(&macctx->params, p->data, p->data_size);
236
28
    }
237
36
    return 1;
238
40
}
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
};