Coverage Report

Created: 2026-09-12 06:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl41/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
441
{
46
441
    struct blake2_mac_data_st *macctx;
47
48
441
    if (!ossl_prov_is_running())
49
0
        return NULL;
50
51
441
    macctx = OPENSSL_zalloc(sizeof(*macctx));
52
441
    if (macctx != NULL) {
53
441
        BLAKE2_PARAM_INIT(&macctx->params);
54
        /* ctx initialization is deferred to BLAKE2b_Init() */
55
441
    }
56
441
    return macctx;
57
441
}
blake2b_mac.c:blake2_mac_new
Line
Count
Source
45
242
{
46
242
    struct blake2_mac_data_st *macctx;
47
48
242
    if (!ossl_prov_is_running())
49
0
        return NULL;
50
51
242
    macctx = OPENSSL_zalloc(sizeof(*macctx));
52
242
    if (macctx != NULL) {
53
242
        BLAKE2_PARAM_INIT(&macctx->params);
54
        /* ctx initialization is deferred to BLAKE2b_Init() */
55
242
    }
56
242
    return macctx;
57
242
}
blake2s_mac.c:blake2_mac_new
Line
Count
Source
45
199
{
46
199
    struct blake2_mac_data_st *macctx;
47
48
199
    if (!ossl_prov_is_running())
49
0
        return NULL;
50
51
199
    macctx = OPENSSL_zalloc(sizeof(*macctx));
52
199
    if (macctx != NULL) {
53
199
        BLAKE2_PARAM_INIT(&macctx->params);
54
        /* ctx initialization is deferred to BLAKE2b_Init() */
55
199
    }
56
199
    return macctx;
57
199
}
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
441
{
77
441
    struct blake2_mac_data_st *macctx = vmacctx;
78
79
441
    if (macctx != NULL) {
80
441
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
81
441
        OPENSSL_free(macctx);
82
441
    }
83
441
}
blake2b_mac.c:blake2_mac_free
Line
Count
Source
76
242
{
77
242
    struct blake2_mac_data_st *macctx = vmacctx;
78
79
242
    if (macctx != NULL) {
80
242
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
81
242
        OPENSSL_free(macctx);
82
242
    }
83
242
}
blake2s_mac.c:blake2_mac_free
Line
Count
Source
76
199
{
77
199
    struct blake2_mac_data_st *macctx = vmacctx;
78
79
199
    if (macctx != NULL) {
80
199
        OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
81
199
        OPENSSL_free(macctx);
82
199
    }
83
199
}
84
85
static size_t blake2_mac_size(void *vmacctx)
86
12.7k
{
87
12.7k
    struct blake2_mac_data_st *macctx = vmacctx;
88
89
12.7k
    return macctx->params.digest_length;
90
12.7k
}
blake2b_mac.c:blake2_mac_size
Line
Count
Source
86
6.90k
{
87
6.90k
    struct blake2_mac_data_st *macctx = vmacctx;
88
89
6.90k
    return macctx->params.digest_length;
90
6.90k
}
blake2s_mac.c:blake2_mac_size
Line
Count
Source
86
5.86k
{
87
5.86k
    struct blake2_mac_data_st *macctx = vmacctx;
88
89
5.86k
    return macctx->params.digest_length;
90
5.86k
}
91
92
static int blake2_setkey(struct blake2_mac_data_st *macctx,
93
    const unsigned char *key, size_t keylen)
94
6.87k
{
95
6.87k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
96
101
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
97
101
        return 0;
98
101
    }
99
6.77k
    memcpy(macctx->key, key, keylen);
100
    /* Pad with zeroes at the end if required */
101
6.77k
    if (keylen < BLAKE2_KEYBYTES)
102
6.10k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
103
6.77k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
104
6.77k
    return 1;
105
6.87k
}
blake2b_mac.c:blake2_setkey
Line
Count
Source
94
3.73k
{
95
3.73k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
96
54
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
97
54
        return 0;
98
54
    }
99
3.68k
    memcpy(macctx->key, key, keylen);
100
    /* Pad with zeroes at the end if required */
101
3.68k
    if (keylen < BLAKE2_KEYBYTES)
102
3.44k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
103
3.68k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
104
3.68k
    return 1;
105
3.73k
}
blake2s_mac.c:blake2_setkey
Line
Count
Source
94
3.14k
{
95
3.14k
    if (keylen > BLAKE2_KEYBYTES || keylen == 0) {
96
47
        ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
97
47
        return 0;
98
47
    }
99
3.09k
    memcpy(macctx->key, key, keylen);
100
    /* Pad with zeroes at the end if required */
101
3.09k
    if (keylen < BLAKE2_KEYBYTES)
102
2.66k
        memset(macctx->key + keylen, 0, BLAKE2_KEYBYTES - keylen);
103
3.09k
    BLAKE2_PARAM_SET_KEY_LENGTH(&macctx->params, (uint8_t)keylen);
104
3.09k
    return 1;
105
3.14k
}
106
107
static int blake2_mac_init(void *vmacctx, const unsigned char *key,
108
    size_t keylen, const OSSL_PARAM params[])
109
6.62k
{
110
6.62k
    struct blake2_mac_data_st *macctx = vmacctx;
111
112
6.62k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
113
236
        return 0;
114
6.39k
    if (key != NULL) {
115
6.39k
        if (!blake2_setkey(macctx, key, keylen))
116
3
            return 0;
117
6.39k
    } 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.39k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
123
6.39k
}
blake2b_mac.c:blake2_mac_init
Line
Count
Source
109
3.58k
{
110
3.58k
    struct blake2_mac_data_st *macctx = vmacctx;
111
112
3.58k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
113
128
        return 0;
114
3.46k
    if (key != NULL) {
115
3.46k
        if (!blake2_setkey(macctx, key, keylen))
116
0
            return 0;
117
3.46k
    } 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.46k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
123
3.46k
}
blake2s_mac.c:blake2_mac_init
Line
Count
Source
109
3.04k
{
110
3.04k
    struct blake2_mac_data_st *macctx = vmacctx;
111
112
3.04k
    if (!ossl_prov_is_running() || !blake2_mac_set_ctx_params(macctx, params))
113
108
        return 0;
114
2.93k
    if (key != NULL) {
115
2.93k
        if (!blake2_setkey(macctx, key, keylen))
116
3
            return 0;
117
2.93k
    } 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
2.93k
    return BLAKE2_INIT_KEY(&macctx->ctx, &macctx->params, macctx->key);
123
2.93k
}
124
125
static int blake2_mac_update(void *vmacctx,
126
    const unsigned char *data, size_t datalen)
127
6.78k
{
128
6.78k
    struct blake2_mac_data_st *macctx = vmacctx;
129
130
6.78k
    if (datalen == 0)
131
0
        return 1;
132
133
6.78k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
134
6.78k
}
blake2b_mac.c:blake2_mac_update
Line
Count
Source
127
3.66k
{
128
3.66k
    struct blake2_mac_data_st *macctx = vmacctx;
129
130
3.66k
    if (datalen == 0)
131
0
        return 1;
132
133
3.66k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
134
3.66k
}
blake2s_mac.c:blake2_mac_update
Line
Count
Source
127
3.12k
{
128
3.12k
    struct blake2_mac_data_st *macctx = vmacctx;
129
130
3.12k
    if (datalen == 0)
131
0
        return 1;
132
133
3.12k
    return BLAKE2_UPDATE(&macctx->ctx, data, datalen);
134
3.12k
}
135
136
static int blake2_mac_final(void *vmacctx,
137
    unsigned char *out, size_t *outl,
138
    size_t outsize)
139
6.37k
{
140
6.37k
    struct blake2_mac_data_st *macctx = vmacctx;
141
142
6.37k
    if (!ossl_prov_is_running())
143
0
        return 0;
144
145
6.37k
    *outl = blake2_mac_size(macctx);
146
6.37k
    return BLAKE2_FINAL(out, &macctx->ctx);
147
6.37k
}
blake2b_mac.c:blake2_mac_final
Line
Count
Source
139
3.44k
{
140
3.44k
    struct blake2_mac_data_st *macctx = vmacctx;
141
142
3.44k
    if (!ossl_prov_is_running())
143
0
        return 0;
144
145
3.44k
    *outl = blake2_mac_size(macctx);
146
3.44k
    return BLAKE2_FINAL(out, &macctx->ctx);
147
3.44k
}
blake2s_mac.c:blake2_mac_final
Line
Count
Source
139
2.93k
{
140
2.93k
    struct blake2_mac_data_st *macctx = vmacctx;
141
142
2.93k
    if (!ossl_prov_is_running())
143
0
        return 0;
144
145
2.93k
    *outl = blake2_mac_size(macctx);
146
2.93k
    return BLAKE2_FINAL(out, &macctx->ctx);
147
2.93k
}
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.36k
{
158
2.36k
    struct blake2_mac_data_st *macctx = vmacctx;
159
2.36k
    struct blake2_get_ctx_st p;
160
161
2.36k
    if (macctx == NULL || !blake2_get_ctx_decoder(params, &p))
162
0
        return 0;
163
164
2.36k
    if (p.size != NULL
165
2.36k
        && !OSSL_PARAM_set_size_t(p.size, blake2_mac_size(macctx)))
166
0
        return 0;
167
168
2.36k
    if (p.bsize != NULL && !OSSL_PARAM_set_size_t(p.bsize, BLAKE2_BLOCKBYTES))
169
0
        return 0;
170
171
2.36k
    return 1;
172
2.36k
}
blake2b_mac.c:blake2_get_ctx_params
Line
Count
Source
157
1.28k
{
158
1.28k
    struct blake2_mac_data_st *macctx = vmacctx;
159
1.28k
    struct blake2_get_ctx_st p;
160
161
1.28k
    if (macctx == NULL || !blake2_get_ctx_decoder(params, &p))
162
0
        return 0;
163
164
1.28k
    if (p.size != NULL
165
1.28k
        && !OSSL_PARAM_set_size_t(p.size, blake2_mac_size(macctx)))
166
0
        return 0;
167
168
1.28k
    if (p.bsize != NULL && !OSSL_PARAM_set_size_t(p.bsize, BLAKE2_BLOCKBYTES))
169
0
        return 0;
170
171
1.28k
    return 1;
172
1.28k
}
blake2s_mac.c:blake2_get_ctx_params
Line
Count
Source
157
1.07k
{
158
1.07k
    struct blake2_mac_data_st *macctx = vmacctx;
159
1.07k
    struct blake2_get_ctx_st p;
160
161
1.07k
    if (macctx == NULL || !blake2_get_ctx_decoder(params, &p))
162
0
        return 0;
163
164
1.07k
    if (p.size != NULL
165
1.07k
        && !OSSL_PARAM_set_size_t(p.size, blake2_mac_size(macctx)))
166
0
        return 0;
167
168
1.07k
    if (p.bsize != NULL && !OSSL_PARAM_set_size_t(p.bsize, BLAKE2_BLOCKBYTES))
169
0
        return 0;
170
171
1.07k
    return 1;
172
1.07k
}
173
174
static const OSSL_PARAM *blake2_mac_settable_ctx_params(
175
    ossl_unused void *ctx, ossl_unused void *p_ctx)
176
384
{
177
384
    return blake2_mac_set_ctx_list;
178
384
}
blake2b_mac.c:blake2_mac_settable_ctx_params
Line
Count
Source
176
214
{
177
214
    return blake2_mac_set_ctx_list;
178
214
}
blake2s_mac.c:blake2_mac_settable_ctx_params
Line
Count
Source
176
170
{
177
170
    return blake2_mac_set_ctx_list;
178
170
}
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.58k
{
185
2.58k
    struct blake2_mac_data_st *macctx = vmacctx;
186
2.58k
    struct blake2_mac_set_ctx_st p;
187
188
2.58k
    if (macctx == NULL || !blake2_mac_set_ctx_decoder(params, &p))
189
0
        return 0;
190
191
2.58k
    if (p.size != NULL) {
192
288
        size_t size;
193
194
288
        if (!OSSL_PARAM_get_size_t(p.size, &size)
195
288
            || size < 1
196
280
            || size > BLAKE2_OUTBYTES) {
197
31
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
198
31
            return 0;
199
31
        }
200
257
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
201
257
    }
202
203
2.55k
    if (p.key != NULL)
204
257
        if (p.key->data_type != OSSL_PARAM_OCTET_STRING
205
257
            || !blake2_setkey(macctx, p.key->data, p.key->data_size))
206
49
            return 0;
207
208
2.50k
    if (p.cust != NULL) {
209
208
        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
208
        if (p.cust->data_size > BLAKE2_PERSONALBYTES) {
216
26
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
217
26
            return 0;
218
26
        }
219
182
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p.cust->data,
220
182
            p.cust->data_size);
221
182
    }
222
223
2.48k
    if (p.salt != NULL) {
224
182
        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
182
        if (p.salt->data_size > BLAKE2_SALTBYTES) {
231
22
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
232
22
            return 0;
233
22
        }
234
160
        BLAKE2_PARAM_SET_SALT(&macctx->params, p.salt->data, p.salt->data_size);
235
160
    }
236
2.46k
    return 1;
237
2.48k
}
blake2b_mac.c:blake2_mac_set_ctx_params
Line
Count
Source
184
1.41k
{
185
1.41k
    struct blake2_mac_data_st *macctx = vmacctx;
186
1.41k
    struct blake2_mac_set_ctx_st p;
187
188
1.41k
    if (macctx == NULL || !blake2_mac_set_ctx_decoder(params, &p))
189
0
        return 0;
190
191
1.41k
    if (p.size != NULL) {
192
167
        size_t size;
193
194
167
        if (!OSSL_PARAM_get_size_t(p.size, &size)
195
167
            || size < 1
196
163
            || size > BLAKE2_OUTBYTES) {
197
16
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
198
16
            return 0;
199
16
        }
200
151
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
201
151
    }
202
203
1.39k
    if (p.key != NULL)
204
151
        if (p.key->data_type != OSSL_PARAM_OCTET_STRING
205
151
            || !blake2_setkey(macctx, p.key->data, p.key->data_size))
206
29
            return 0;
207
208
1.36k
    if (p.cust != NULL) {
209
122
        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
122
        if (p.cust->data_size > BLAKE2_PERSONALBYTES) {
216
15
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
217
15
            return 0;
218
15
        }
219
107
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p.cust->data,
220
107
            p.cust->data_size);
221
107
    }
222
223
1.35k
    if (p.salt != NULL) {
224
107
        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
107
        if (p.salt->data_size > BLAKE2_SALTBYTES) {
231
9
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
232
9
            return 0;
233
9
        }
234
98
        BLAKE2_PARAM_SET_SALT(&macctx->params, p.salt->data, p.salt->data_size);
235
98
    }
236
1.34k
    return 1;
237
1.35k
}
blake2s_mac.c:blake2_mac_set_ctx_params
Line
Count
Source
184
1.17k
{
185
1.17k
    struct blake2_mac_data_st *macctx = vmacctx;
186
1.17k
    struct blake2_mac_set_ctx_st p;
187
188
1.17k
    if (macctx == NULL || !blake2_mac_set_ctx_decoder(params, &p))
189
0
        return 0;
190
191
1.17k
    if (p.size != NULL) {
192
121
        size_t size;
193
194
121
        if (!OSSL_PARAM_get_size_t(p.size, &size)
195
121
            || size < 1
196
117
            || size > BLAKE2_OUTBYTES) {
197
15
            ERR_raise(ERR_LIB_PROV, PROV_R_NOT_XOF_OR_INVALID_LENGTH);
198
15
            return 0;
199
15
        }
200
106
        BLAKE2_PARAM_SET_DIGEST_LENGTH(&macctx->params, (uint8_t)size);
201
106
    }
202
203
1.16k
    if (p.key != NULL)
204
106
        if (p.key->data_type != OSSL_PARAM_OCTET_STRING
205
106
            || !blake2_setkey(macctx, p.key->data, p.key->data_size))
206
20
            return 0;
207
208
1.14k
    if (p.cust != NULL) {
209
86
        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
86
        if (p.cust->data_size > BLAKE2_PERSONALBYTES) {
216
11
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_CUSTOM_LENGTH);
217
11
            return 0;
218
11
        }
219
75
        BLAKE2_PARAM_SET_PERSONAL(&macctx->params, p.cust->data,
220
75
            p.cust->data_size);
221
75
    }
222
223
1.13k
    if (p.salt != NULL) {
224
75
        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
75
        if (p.salt->data_size > BLAKE2_SALTBYTES) {
231
13
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
232
13
            return 0;
233
13
        }
234
62
        BLAKE2_PARAM_SET_SALT(&macctx->params, p.salt->data, p.salt->data_size);
235
62
    }
236
1.11k
    return 1;
237
1.13k
}
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
};