Coverage Report

Created: 2025-11-16 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl33/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
349
{
44
349
    struct blake2_mac_data_st *macctx;
45
46
349
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
349
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
349
    if (macctx != NULL) {
51
349
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
349
    }
54
349
    return macctx;
55
349
}
blake2b_mac.c:blake2_mac_new
Line
Count
Source
43
205
{
44
205
    struct blake2_mac_data_st *macctx;
45
46
205
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
205
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
205
    if (macctx != NULL) {
51
205
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
205
    }
54
205
    return macctx;
55
205
}
blake2s_mac.c:blake2_mac_new
Line
Count
Source
43
144
{
44
144
    struct blake2_mac_data_st *macctx;
45
46
144
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
144
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
144
    if (macctx != NULL) {
51
144
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
144
    }
54
144
    return macctx;
55
144
}
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
349
{
75
349
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
349
    if (macctx != NULL) {
78
349
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
349
        OPENSSL_free(macctx);
80
349
    }
81
349
}
blake2b_mac.c:blake2_mac_free
Line
Count
Source
74
205
{
75
205
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
205
    if (macctx != NULL) {
78
205
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
205
        OPENSSL_free(macctx);
80
205
    }
81
205
}
blake2s_mac.c:blake2_mac_free
Line
Count
Source
74
144
{
75
144
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
144
    if (macctx != NULL) {
78
144
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
144
        OPENSSL_free(macctx);
80
144
    }
81
144
}
82
83
static size_t blake2_mac_size(void *vmacctx)
84
8.82k
{
85
8.82k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
8.82k
    return macctx->params.digest_length;
88
8.82k
}
blake2b_mac.c:blake2_mac_size
Line
Count
Source
84
4.33k
{
85
4.33k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
4.33k
    return macctx->params.digest_length;
88
4.33k
}
blake2s_mac.c:blake2_mac_size
Line
Count
Source
84
4.49k
{
85
4.49k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
4.49k
    return macctx->params.digest_length;
88
4.49k
}
89
90
static int blake2_setkey(struct blake2_mac_data_st *macctx,
91
                         const unsigned char *key, size_t keylen)
92
4.80k
{
93
4.80k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
94
86
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
95
86
        return 0;
96
86
    }
97
4.71k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
4.71k
    if (keylen < BLAKE2_KEYBYTES)
100
4.27k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
4.71k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
4.71k
    return 1;
103
4.80k
}
blake2b_mac.c:blake2_setkey
Line
Count
Source
92
2.40k
{
93
2.40k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
94
49
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
95
49
        return 0;
96
49
    }
97
2.35k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
2.35k
    if (keylen < BLAKE2_KEYBYTES)
100
2.20k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
2.35k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
2.35k
    return 1;
103
2.40k
}
blake2s_mac.c:blake2_setkey
Line
Count
Source
92
2.39k
{
93
2.39k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
94
37
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
95
37
        return 0;
96
37
    }
97
2.35k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
2.35k
    if (keylen < BLAKE2_KEYBYTES)
100
2.07k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
2.35k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
2.35k
    return 1;
103
2.39k
}
104
105
static int blake2_mac_init(void *vmacctx, const unsigned char *key,
106
                           size_t keylen, const OSSL_PARAM params[])
107
4.62k
{
108
4.62k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
4.62k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
204
        return 0;
112
4.41k
    if (key != NULL) {
113
4.41k
        if (!blake2_setkey(macctx, key, keylen))
114
2
            return 0;
115
4.41k
    } 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
4.41k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
4.41k
}
blake2b_mac.c:blake2_mac_init
Line
Count
Source
107
2.29k
{
108
2.29k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
2.29k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
121
        return 0;
112
2.16k
    if (key != NULL) {
113
2.16k
        if (!blake2_setkey(macctx, key, keylen))
114
0
            return 0;
115
2.16k
    } 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
2.16k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
2.16k
}
blake2s_mac.c:blake2_mac_init
Line
Count
Source
107
2.33k
{
108
2.33k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
2.33k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
83
        return 0;
112
2.24k
    if (key != NULL) {
113
2.24k
        if (!blake2_setkey(macctx, key, keylen))
114
2
            return 0;
115
2.24k
    } 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
2.24k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
2.24k
}
122
123
static int blake2_mac_update(void *vmacctx,
124
                             const unsigned char *data, size_t datalen)
125
4.69k
{
126
4.69k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
4.69k
    if (datalen == 0)
129
0
        return 1;
130
131
4.69k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
4.69k
}
blake2b_mac.c:blake2_mac_update
Line
Count
Source
125
2.31k
{
126
2.31k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
2.31k
    if (datalen == 0)
129
0
        return 1;
130
131
2.31k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
2.31k
}
blake2s_mac.c:blake2_mac_update
Line
Count
Source
125
2.38k
{
126
2.38k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
2.38k
    if (datalen == 0)
129
0
        return 1;
130
131
2.38k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
2.38k
}
133
134
static int blake2_mac_final(void *vmacctx,
135
                            unsigned char *out, size_t *outl,
136
                            size_t outsize)
137
4.40k
{
138
4.40k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
4.40k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
4.40k
    *outl = blake2_mac_size(macctx);
144
4.40k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
4.40k
}
blake2b_mac.c:blake2_mac_final
Line
Count
Source
137
2.16k
{
138
2.16k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
2.16k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
2.16k
    *outl = blake2_mac_size(macctx);
144
2.16k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
2.16k
}
blake2s_mac.c:blake2_mac_final
Line
Count
Source
137
2.24k
{
138
2.24k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
2.24k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
2.24k
    *outl = blake2_mac_size(macctx);
144
2.24k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
2.24k
}
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.38k
{
160
4.38k
    OSSL_PARAM *p;
161
162
4.38k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL
163
4.38k
            && !OSSL_PARAM_set_size_t(p, blake2_mac_size(vmacctx)))
164
0
        return 0;
165
166
4.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
4.38k
    return 1;
171
4.38k
}
blake2b_mac.c:blake2_get_ctx_params
Line
Count
Source
159
2.14k
{
160
2.14k
    OSSL_PARAM *p;
161
162
2.14k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL
163
2.14k
            && !OSSL_PARAM_set_size_t(p, blake2_mac_size(vmacctx)))
164
0
        return 0;
165
166
2.14k
    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.14k
    return 1;
171
2.14k
}
blake2s_mac.c:blake2_get_ctx_params
Line
Count
Source
159
2.23k
{
160
2.23k
    OSSL_PARAM *p;
161
162
2.23k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL
163
2.23k
            && !OSSL_PARAM_set_size_t(p, blake2_mac_size(vmacctx)))
164
0
        return 0;
165
166
2.23k
    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.23k
    return 1;
171
2.23k
}
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
319
{
183
319
    return known_settable_ctx_params;
184
319
}
blake2b_mac.c:blake2_mac_settable_ctx_params
Line
Count
Source
182
192
{
183
192
    return known_settable_ctx_params;
184
192
}
blake2s_mac.c:blake2_mac_settable_ctx_params
Line
Count
Source
182
127
{
183
127
    return known_settable_ctx_params;
184
127
}
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.43k
{
191
2.43k
    struct blake2_mac_data_st *macctx = vmacctx;
192
2.43k
    const OSSL_PARAM *p;
193
194
2.43k
    if (params == NULL)
195
2.27k
        return 1;
196
197
166
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
152
        size_t size;
199
200
152
        if (!OSSL_PARAM_get_size_t(p, &size)
201
152
            || size < 1
202
147
            || size > BLAKE2_OUTBYTES) {
203
19
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
19
            return 0;
205
19
        }
206
133
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
133
    }
208
209
147
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
133
            && !blake2_setkey(macctx, p->data, p->data_size))
211
32
        return 0;
212
213
115
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_CUSTOM))
214
115
        != 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
101
        if (p->data_size > BLAKE2_PERSONALBYTES) {
220
15
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
221
15
            return 0;
222
15
        }
223
86
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
86
    }
225
226
100
    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
86
        if (p->data_size > BLAKE2_SALTBYTES) {
232
6
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
233
6
            return 0;
234
6
        }
235
80
        BLAKE2_PARAM_SET_SALT(&macctx->params, p->data, p->data_size);
236
80
    }
237
94
    return 1;
238
100
}
blake2b_mac.c:blake2_mac_set_ctx_params
Line
Count
Source
190
1.21k
{
191
1.21k
    struct blake2_mac_data_st *macctx = vmacctx;
192
1.21k
    const OSSL_PARAM *p;
193
194
1.21k
    if (params == NULL)
195
1.11k
        return 1;
196
197
97
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
91
        size_t size;
199
200
91
        if (!OSSL_PARAM_get_size_t(p, &size)
201
91
            || size < 1
202
88
            || size > BLAKE2_OUTBYTES) {
203
10
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
10
            return 0;
205
10
        }
206
81
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
81
    }
208
209
87
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
81
            && !blake2_setkey(macctx, p->data, p->data_size))
211
17
        return 0;
212
213
70
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_CUSTOM))
214
70
        != 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
64
        if (p->data_size > BLAKE2_PERSONALBYTES) {
220
9
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
221
9
            return 0;
222
9
        }
223
55
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
55
    }
225
226
61
    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
55
        if (p->data_size > BLAKE2_SALTBYTES) {
232
5
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
233
5
            return 0;
234
5
        }
235
50
        BLAKE2_PARAM_SET_SALT(&macctx->params, p->data, p->data_size);
236
50
    }
237
56
    return 1;
238
61
}
blake2s_mac.c:blake2_mac_set_ctx_params
Line
Count
Source
190
1.22k
{
191
1.22k
    struct blake2_mac_data_st *macctx = vmacctx;
192
1.22k
    const OSSL_PARAM *p;
193
194
1.22k
    if (params == NULL)
195
1.15k
        return 1;
196
197
69
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
61
        size_t size;
199
200
61
        if (!OSSL_PARAM_get_size_t(p, &size)
201
61
            || size < 1
202
59
            || size > BLAKE2_OUTBYTES) {
203
9
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
9
            return 0;
205
9
        }
206
52
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
52
    }
208
209
60
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
52
            && !blake2_setkey(macctx, p->data, p->data_size))
211
15
        return 0;
212
213
45
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_CUSTOM))
214
45
        != 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
37
        if (p->data_size > BLAKE2_PERSONALBYTES) {
220
6
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
221
6
            return 0;
222
6
        }
223
31
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
31
    }
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
31
        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
30
        BLAKE2_PARAM_SET_SALT(&macctx->params, p->data, p->data_size);
236
30
    }
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
};