Coverage Report

Created: 2026-07-12 07:21

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