Coverage Report

Created: 2025-12-04 06:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl32/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
402
{
44
402
    struct blake2_mac_data_st *macctx;
45
46
402
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
402
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
402
    if (macctx != NULL) {
51
402
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
402
    }
54
402
    return macctx;
55
402
}
blake2b_mac.c:blake2_mac_new
Line
Count
Source
43
239
{
44
239
    struct blake2_mac_data_st *macctx;
45
46
239
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
239
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
239
    if (macctx != NULL) {
51
239
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
239
    }
54
239
    return macctx;
55
239
}
blake2s_mac.c:blake2_mac_new
Line
Count
Source
43
163
{
44
163
    struct blake2_mac_data_st *macctx;
45
46
163
    if (!ossl_prov_is_running())
47
0
        return NULL;
48
49
163
    macctx = OPENSSL_zalloc(sizeof(*macctx));
50
163
    if (macctx != NULL) {
51
163
        BLAKE2_PARAM_INIT(&macctx->params);
52
        /* ctx initialization is deferred to BLAKE2b_Init() */
53
163
    }
54
163
    return macctx;
55
163
}
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
402
{
75
402
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
402
    if (macctx != NULL) {
78
402
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
402
        OPENSSL_free(macctx);
80
402
    }
81
402
}
blake2b_mac.c:blake2_mac_free
Line
Count
Source
74
239
{
75
239
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
239
    if (macctx != NULL) {
78
239
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
239
        OPENSSL_free(macctx);
80
239
    }
81
239
}
blake2s_mac.c:blake2_mac_free
Line
Count
Source
74
163
{
75
163
    struct blake2_mac_data_st *macctx = vmacctx;
76
77
163
    if (macctx != NULL) {
78
163
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
79
163
        OPENSSL_free(macctx);
80
163
    }
81
163
}
82
83
static size_t blake2_mac_size(void *vmacctx)
84
12.4k
{
85
12.4k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
12.4k
    return macctx->params.digest_length;
88
12.4k
}
blake2b_mac.c:blake2_mac_size
Line
Count
Source
84
6.38k
{
85
6.38k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
6.38k
    return macctx->params.digest_length;
88
6.38k
}
blake2s_mac.c:blake2_mac_size
Line
Count
Source
84
6.07k
{
85
6.07k
    struct blake2_mac_data_st *macctx = vmacctx;
86
87
6.07k
    return macctx->params.digest_length;
88
6.07k
}
89
90
static int blake2_setkey(struct blake2_mac_data_st *macctx,
91
                         const unsigned char *key, size_t keylen)
92
6.67k
{
93
6.67k
    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
6.57k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
6.57k
    if (keylen < BLAKE2_KEYBYTES)
100
5.99k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
6.57k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
6.57k
    return 1;
103
6.67k
}
blake2b_mac.c:blake2_setkey
Line
Count
Source
92
3.46k
{
93
3.46k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
94
57
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
95
57
        return 0;
96
57
    }
97
3.40k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
3.40k
    if (keylen < BLAKE2_KEYBYTES)
100
3.24k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
3.40k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
3.40k
    return 1;
103
3.46k
}
blake2s_mac.c:blake2_setkey
Line
Count
Source
92
3.21k
{
93
3.21k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
94
40
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
95
40
        return 0;
96
40
    }
97
3.17k
    memcpy(macctx->key, key, keylen);
98
    /* Pad with zeroes at the end if required */
99
3.17k
    if (keylen < BLAKE2_KEYBYTES)
100
2.74k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
101
3.17k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
102
3.17k
    return 1;
103
3.21k
}
104
105
static int blake2_mac_init(void *vmacctx, const unsigned char *key,
106
                           size_t keylen, const OSSL_PARAM params[])
107
6.46k
{
108
6.46k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
6.46k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
227
        return 0;
112
6.23k
    if (key != NULL) {
113
6.23k
        if (!blake2_setkey(macctx, key, keylen))
114
3
            return 0;
115
6.23k
    } 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.23k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
6.23k
}
blake2b_mac.c:blake2_mac_init
Line
Count
Source
107
3.34k
{
108
3.34k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
3.34k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
143
        return 0;
112
3.19k
    if (key != NULL) {
113
3.19k
        if (!blake2_setkey(macctx, key, keylen))
114
0
            return 0;
115
3.19k
    } 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.19k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
3.19k
}
blake2s_mac.c:blake2_mac_init
Line
Count
Source
107
3.12k
{
108
3.12k
    struct blake2_mac_data_st *macctx = vmacctx;
109
110
3.12k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
111
84
        return 0;
112
3.04k
    if (key != NULL) {
113
3.04k
        if (!blake2_setkey(macctx, key, keylen))
114
3
            return 0;
115
3.04k
    } 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.03k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
121
3.04k
}
122
123
static int blake2_mac_update(void *vmacctx,
124
                             const unsigned char *data, size_t datalen)
125
6.62k
{
126
6.62k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
6.62k
    if (datalen == 0)
129
0
        return 1;
130
131
6.62k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
6.62k
}
blake2b_mac.c:blake2_mac_update
Line
Count
Source
125
3.39k
{
126
3.39k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
3.39k
    if (datalen == 0)
129
0
        return 1;
130
131
3.39k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
3.39k
}
blake2s_mac.c:blake2_mac_update
Line
Count
Source
125
3.23k
{
126
3.23k
    struct blake2_mac_data_st *macctx = vmacctx;
127
128
3.23k
    if (datalen == 0)
129
0
        return 1;
130
131
3.23k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
132
3.23k
}
133
134
static int blake2_mac_final(void *vmacctx,
135
                            unsigned char *out, size_t *outl,
136
                            size_t outsize)
137
6.22k
{
138
6.22k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
6.22k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
6.22k
    *outl = blake2_mac_size(macctx);
144
6.22k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
6.22k
}
blake2b_mac.c:blake2_mac_final
Line
Count
Source
137
3.19k
{
138
3.19k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
3.19k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
3.19k
    *outl = blake2_mac_size(macctx);
144
3.19k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
3.19k
}
blake2s_mac.c:blake2_mac_final
Line
Count
Source
137
3.03k
{
138
3.03k
    struct blake2_mac_data_st *macctx = vmacctx;
139
140
3.03k
    if (!ossl_prov_is_running())
141
0
        return 0;
142
143
3.03k
    *outl = blake2_mac_size(macctx);
144
3.03k
    return BLAKE2_FINAL(out, &macctx->ctx);
145
3.03k
}
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.10k
{
160
4.10k
    OSSL_PARAM *p;
161
162
4.10k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL
163
4.10k
            && !OSSL_PARAM_set_size_t(p, blake2_mac_size(vmacctx)))
164
0
        return 0;
165
166
4.10k
    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.10k
    return 1;
171
4.10k
}
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
1.96k
{
160
1.96k
    OSSL_PARAM *p;
161
162
1.96k
    if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL
163
1.96k
            && !OSSL_PARAM_set_size_t(p, blake2_mac_size(vmacctx)))
164
0
        return 0;
165
166
1.96k
    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.96k
    return 1;
171
1.96k
}
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
360
{
183
360
    return known_settable_ctx_params;
184
360
}
blake2b_mac.c:blake2_mac_settable_ctx_params
Line
Count
Source
182
220
{
183
220
    return known_settable_ctx_params;
184
220
}
blake2s_mac.c:blake2_mac_settable_ctx_params
Line
Count
Source
182
140
{
183
140
    return known_settable_ctx_params;
184
140
}
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.14k
{
191
2.14k
    struct blake2_mac_data_st *macctx = vmacctx;
192
2.14k
    const OSSL_PARAM *p;
193
194
2.14k
    if (params == NULL)
195
2.00k
        return 1;
196
197
144
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
131
        size_t size;
199
200
131
        if (!OSSL_PARAM_get_size_t(p, &size)
201
131
            || size < 1
202
126
            || size > BLAKE2_OUTBYTES) {
203
17
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
17
            return 0;
205
17
        }
206
114
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
114
    }
208
209
127
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
114
            && !blake2_setkey(macctx, p->data, p->data_size))
211
29
        return 0;
212
213
98
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_CUSTOM))
214
98
        != 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
85
        if (p->data_size > BLAKE2_PERSONALBYTES) {
220
13
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
221
13
            return 0;
222
13
        }
223
72
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
72
    }
225
226
85
    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
72
        if (p->data_size > BLAKE2_SALTBYTES) {
232
2
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
233
2
            return 0;
234
2
        }
235
70
        BLAKE2_PARAM_SET_SALT(&macctx->params, p->data, p->data_size);
236
70
    }
237
83
    return 1;
238
85
}
blake2b_mac.c:blake2_mac_set_ctx_params
Line
Count
Source
190
1.19k
{
191
1.19k
    struct blake2_mac_data_st *macctx = vmacctx;
192
1.19k
    const OSSL_PARAM *p;
193
194
1.19k
    if (params == NULL)
195
1.11k
        return 1;
196
197
79
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
73
        size_t size;
199
200
73
        if (!OSSL_PARAM_get_size_t(p, &size)
201
73
            || size < 1
202
70
            || size > BLAKE2_OUTBYTES) {
203
9
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
9
            return 0;
205
9
        }
206
64
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
64
    }
208
209
70
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
64
            && !blake2_setkey(macctx, p->data, p->data_size))
211
17
        return 0;
212
213
53
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_CUSTOM))
214
53
        != 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
47
        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
39
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
39
    }
225
226
45
    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
39
        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
38
        BLAKE2_PARAM_SET_SALT(&macctx->params, p->data, p->data_size);
236
38
    }
237
44
    return 1;
238
45
}
blake2s_mac.c:blake2_mac_set_ctx_params
Line
Count
Source
190
955
{
191
955
    struct blake2_mac_data_st *macctx = vmacctx;
192
955
    const OSSL_PARAM *p;
193
194
955
    if (params == NULL)
195
890
        return 1;
196
197
65
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_SIZE)) != NULL) {
198
58
        size_t size;
199
200
58
        if (!OSSL_PARAM_get_size_t(p, &size)
201
58
            || size < 1
202
56
            || size > BLAKE2_OUTBYTES) {
203
8
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
204
8
            return 0;
205
8
        }
206
50
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
207
50
    }
208
209
57
    if ((p = OSSL_PARAM_locate_const(params, OSSL_MAC_PARAM_KEY)) != NULL
210
50
            && !blake2_setkey(macctx, p->data, p->data_size))
211
12
        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
38
        if (p->data_size > BLAKE2_PERSONALBYTES) {
220
5
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
221
5
            return 0;
222
5
        }
223
33
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p->data, p->data_size);
224
33
    }
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
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
39
    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
};