Coverage Report

Created: 2026-02-14 07:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl36/providers/implementations/macs/hmac_prov.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
/* clang-format off */
10
11
/* clang-format on */
12
13
/*
14
 * HMAC low level APIs are deprecated for public use, but still ok for internal
15
 * use.
16
 */
17
#include "internal/deprecated.h"
18
19
#include <string.h>
20
21
#include <openssl/core_dispatch.h>
22
#include <openssl/core_names.h>
23
#include <openssl/params.h>
24
#include <openssl/evp.h>
25
#include <openssl/hmac.h>
26
#include <openssl/proverr.h>
27
#include <openssl/err.h>
28
29
#include "internal/ssl3_cbc.h"
30
#include "internal/cryptlib.h"
31
32
#include "prov/implementations.h"
33
#include "prov/provider_ctx.h"
34
#include "prov/provider_util.h"
35
#include "prov/providercommon.h"
36
#include "prov/securitycheck.h"
37
38
/*
39
 * Forward declaration of everything implemented here.  This is not strictly
40
 * necessary for the compiler, but provides an assurance that the signatures
41
 * of the functions in the dispatch table are correct.
42
 */
43
static OSSL_FUNC_mac_newctx_fn hmac_new;
44
static OSSL_FUNC_mac_dupctx_fn hmac_dup;
45
static OSSL_FUNC_mac_freectx_fn hmac_free;
46
static OSSL_FUNC_mac_gettable_ctx_params_fn hmac_gettable_ctx_params;
47
static OSSL_FUNC_mac_get_ctx_params_fn hmac_get_ctx_params;
48
static OSSL_FUNC_mac_settable_ctx_params_fn hmac_settable_ctx_params;
49
static OSSL_FUNC_mac_set_ctx_params_fn hmac_set_ctx_params;
50
static OSSL_FUNC_mac_init_fn hmac_init;
51
static OSSL_FUNC_mac_update_fn hmac_update;
52
static OSSL_FUNC_mac_final_fn hmac_final;
53
54
/* local HMAC context structure */
55
56
/* typedef EVP_MAC_IMPL */
57
struct hmac_data_st {
58
    void *provctx;
59
    HMAC_CTX *ctx; /* HMAC context */
60
    PROV_DIGEST digest;
61
    unsigned char *key;
62
    size_t keylen;
63
    /* Length of full TLS record including the MAC and any padding */
64
    size_t tls_data_size;
65
    unsigned char tls_header[13];
66
    int tls_header_set;
67
    unsigned char tls_mac_out[EVP_MAX_MD_SIZE];
68
    size_t tls_mac_out_size;
69
#ifdef FIPS_MODULE
70
    /*
71
     * 'internal' is set to 1 if HMAC is used inside another algorithm such as a
72
     * KDF. In this case it is the parent algorithm that is responsible for
73
     * performing any conditional FIPS indicator related checks for the HMAC.
74
     */
75
    int internal;
76
#endif
77
    OSSL_FIPS_IND_DECLARE
78
};
79
80
static void *hmac_new(void *provctx)
81
1.81M
{
82
1.81M
    struct hmac_data_st *macctx;
83
84
1.81M
    if (!ossl_prov_is_running())
85
0
        return NULL;
86
87
1.81M
    if ((macctx = OPENSSL_zalloc(sizeof(*macctx))) == NULL
88
1.81M
        || (macctx->ctx = HMAC_CTX_new()) == NULL) {
89
0
        OPENSSL_free(macctx);
90
0
        return NULL;
91
0
    }
92
1.81M
    macctx->provctx = provctx;
93
1.81M
    OSSL_FIPS_IND_INIT(macctx)
94
95
1.81M
    return macctx;
96
1.81M
}
97
98
static void hmac_free(void *vmacctx)
99
1.81M
{
100
1.81M
    struct hmac_data_st *macctx = vmacctx;
101
102
1.81M
    if (macctx != NULL) {
103
1.81M
        HMAC_CTX_free(macctx->ctx);
104
1.81M
        ossl_prov_digest_reset(&macctx->digest);
105
1.81M
        OPENSSL_clear_free(macctx->key, macctx->keylen);
106
1.81M
        OPENSSL_free(macctx);
107
1.81M
    }
108
1.81M
}
109
110
static void *hmac_dup(void *vsrc)
111
1.53M
{
112
1.53M
    struct hmac_data_st *src = vsrc;
113
1.53M
    struct hmac_data_st *dst;
114
1.53M
    HMAC_CTX *ctx;
115
116
1.53M
    if (!ossl_prov_is_running())
117
0
        return NULL;
118
1.53M
    dst = hmac_new(src->provctx);
119
1.53M
    if (dst == NULL)
120
0
        return NULL;
121
122
1.53M
    ctx = dst->ctx;
123
1.53M
    *dst = *src;
124
1.53M
    dst->ctx = ctx;
125
1.53M
    dst->key = NULL;
126
1.53M
    memset(&dst->digest, 0, sizeof(dst->digest));
127
128
1.53M
    if (!HMAC_CTX_copy(dst->ctx, src->ctx)
129
1.53M
        || !ossl_prov_digest_copy(&dst->digest, &src->digest)) {
130
0
        hmac_free(dst);
131
0
        return NULL;
132
0
    }
133
1.53M
    if (src->key != NULL) {
134
1.53M
        dst->key = OPENSSL_malloc(src->keylen > 0 ? src->keylen : 1);
135
1.53M
        if (dst->key == NULL) {
136
0
            hmac_free(dst);
137
0
            return 0;
138
0
        }
139
1.53M
        if (src->keylen > 0)
140
1.53M
            memcpy(dst->key, src->key, src->keylen);
141
1.53M
    }
142
1.53M
    return dst;
143
1.53M
}
144
145
static size_t hmac_size(struct hmac_data_st *macctx)
146
1.29M
{
147
1.29M
    return HMAC_size(macctx->ctx);
148
1.29M
}
149
150
static int hmac_block_size(struct hmac_data_st *macctx)
151
0
{
152
0
    const EVP_MD *md = ossl_prov_digest_md(&macctx->digest);
153
154
0
    if (md == NULL)
155
0
        return 0;
156
0
    return EVP_MD_block_size(md);
157
0
}
158
159
static int hmac_setkey(struct hmac_data_st *macctx,
160
    const unsigned char *key, size_t keylen)
161
297k
{
162
297k
    const EVP_MD *digest;
163
164
#ifdef FIPS_MODULE
165
    /*
166
     * KDF's pass a salt rather than a key,
167
     * which is why it skips the key check unless "HMAC" is fetched directly.
168
     */
169
    if (!macctx->internal) {
170
        OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(macctx->provctx);
171
        int approved = ossl_mac_check_key_size(keylen);
172
173
        if (!approved) {
174
            if (!OSSL_FIPS_IND_ON_UNAPPROVED(macctx, OSSL_FIPS_IND_SETTABLE0,
175
                    libctx, "HMAC", "keysize",
176
                    ossl_fips_config_hmac_key_check)) {
177
                ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
178
                return 0;
179
            }
180
        }
181
    }
182
#endif
183
184
297k
    if (macctx->key != NULL)
185
27.8k
        OPENSSL_clear_free(macctx->key, macctx->keylen);
186
    /* Keep a copy of the key in case we need it for TLS HMAC */
187
297k
    macctx->key = OPENSSL_malloc(keylen > 0 ? keylen : 1);
188
297k
    if (macctx->key == NULL)
189
0
        return 0;
190
191
297k
    if (keylen > 0)
192
291k
        memcpy(macctx->key, key, keylen);
193
297k
    macctx->keylen = keylen;
194
195
297k
    digest = ossl_prov_digest_md(&macctx->digest);
196
    /* HMAC_Init_ex doesn't tolerate all zero params, so we must be careful */
197
297k
    if (key != NULL || (macctx->tls_data_size == 0 && digest != NULL))
198
297k
        return HMAC_Init_ex(macctx->ctx, key, (int)keylen, digest,
199
297k
            ossl_prov_digest_engine(&macctx->digest));
200
0
    return 1;
201
297k
}
202
203
static int hmac_init(void *vmacctx, const unsigned char *key,
204
    size_t keylen, const OSSL_PARAM params[])
205
297k
{
206
297k
    struct hmac_data_st *macctx = vmacctx;
207
208
297k
    if (!ossl_prov_is_running() || !hmac_set_ctx_params(macctx, params))
209
167
        return 0;
210
211
297k
    if (key != NULL)
212
297k
        return hmac_setkey(macctx, key, keylen);
213
214
    /* Just reinit the HMAC context */
215
0
    return HMAC_Init_ex(macctx->ctx, NULL, 0, NULL, NULL);
216
297k
}
217
218
static int hmac_update(void *vmacctx, const unsigned char *data,
219
    size_t datalen)
220
1.82M
{
221
1.82M
    struct hmac_data_st *macctx = vmacctx;
222
223
1.82M
    if (macctx->tls_data_size > 0) {
224
        /* We're doing a TLS HMAC */
225
359k
        if (!macctx->tls_header_set) {
226
            /* We expect the first update call to contain the TLS header */
227
179k
            if (datalen != sizeof(macctx->tls_header))
228
121
                return 0;
229
179k
            memcpy(macctx->tls_header, data, datalen);
230
179k
            macctx->tls_header_set = 1;
231
179k
            return 1;
232
179k
        }
233
        /* macctx->tls_data_size is datalen plus the padding length */
234
179k
        if (macctx->tls_data_size < datalen)
235
0
            return 0;
236
237
179k
        return ssl3_cbc_digest_record(ossl_prov_digest_md(&macctx->digest),
238
179k
            macctx->tls_mac_out,
239
179k
            &macctx->tls_mac_out_size,
240
179k
            macctx->tls_header,
241
179k
            data,
242
179k
            datalen,
243
179k
            macctx->tls_data_size,
244
179k
            macctx->key,
245
179k
            macctx->keylen,
246
179k
            0);
247
179k
    }
248
249
1.46M
    return HMAC_Update(macctx->ctx, data, datalen);
250
1.82M
}
251
252
static int hmac_final(void *vmacctx, unsigned char *out, size_t *outl,
253
    size_t outsize)
254
1.19M
{
255
1.19M
    unsigned int hlen;
256
1.19M
    struct hmac_data_st *macctx = vmacctx;
257
258
1.19M
    if (!ossl_prov_is_running())
259
0
        return 0;
260
1.19M
    if (macctx->tls_data_size > 0) {
261
179k
        if (macctx->tls_mac_out_size == 0)
262
0
            return 0;
263
179k
        if (outl != NULL)
264
179k
            *outl = macctx->tls_mac_out_size;
265
179k
        memcpy(out, macctx->tls_mac_out, macctx->tls_mac_out_size);
266
179k
        return 1;
267
179k
    }
268
1.01M
    if (!HMAC_Final(macctx->ctx, out, &hlen))
269
0
        return 0;
270
1.01M
    *outl = hlen;
271
1.01M
    return 1;
272
1.01M
}
273
274
/* clang-format off */
275
/* Machine generated by util/perl/OpenSSL/paramnames.pm */
276
#ifndef hmac_get_ctx_params_list
277
static const OSSL_PARAM hmac_get_ctx_params_list[] = {
278
    OSSL_PARAM_size_t(OSSL_MAC_PARAM_SIZE, NULL),
279
    OSSL_PARAM_size_t(OSSL_MAC_PARAM_BLOCK_SIZE, NULL),
280
# if defined(FIPS_MODULE)
281
    OSSL_PARAM_int(OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR, NULL),
282
# endif
283
    OSSL_PARAM_END
284
};
285
#endif
286
287
#ifndef hmac_get_ctx_params_st
288
struct hmac_get_ctx_params_st {
289
    OSSL_PARAM *bsize;
290
# if defined(FIPS_MODULE)
291
    OSSL_PARAM *ind;
292
# endif
293
    OSSL_PARAM *size;
294
};
295
#endif
296
297
#ifndef hmac_get_ctx_params_decoder
298
static int hmac_get_ctx_params_decoder
299
    (const OSSL_PARAM *p, struct hmac_get_ctx_params_st *r)
300
446k
{
301
446k
    const char *s;
302
303
446k
    memset(r, 0, sizeof(*r));
304
446k
    if (p != NULL)
305
892k
        for (; (s = p->key) != NULL; p++)
306
446k
            switch(s[0]) {
307
0
            default:
308
0
                break;
309
0
            case 'b':
310
0
                if (ossl_likely(strcmp("lock-size", s + 1) == 0)) {
311
                    /* OSSL_MAC_PARAM_BLOCK_SIZE */
312
0
                    if (ossl_unlikely(r->bsize != NULL)) {
313
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
314
0
                                       "param %s is repeated", s);
315
0
                        return 0;
316
0
                    }
317
0
                    r->bsize = (OSSL_PARAM *)p;
318
0
                }
319
0
                break;
320
0
            case 'f':
321
# if defined(FIPS_MODULE)
322
                if (ossl_likely(strcmp("ips-indicator", s + 1) == 0)) {
323
                    /* OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR */
324
                    if (ossl_unlikely(r->ind != NULL)) {
325
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
326
                                       "param %s is repeated", s);
327
                        return 0;
328
                    }
329
                    r->ind = (OSSL_PARAM *)p;
330
                }
331
# endif
332
0
                break;
333
446k
            case 's':
334
446k
                if (ossl_likely(strcmp("ize", s + 1) == 0)) {
335
                    /* OSSL_MAC_PARAM_SIZE */
336
446k
                    if (ossl_unlikely(r->size != NULL)) {
337
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
338
0
                                       "param %s is repeated", s);
339
0
                        return 0;
340
0
                    }
341
446k
                    r->size = (OSSL_PARAM *)p;
342
446k
                }
343
446k
            }
344
446k
    return 1;
345
446k
}
346
#endif
347
/* End of machine generated */
348
/* clang-format on */
349
350
static const OSSL_PARAM *hmac_gettable_ctx_params(ossl_unused void *ctx,
351
    ossl_unused void *provctx)
352
0
{
353
0
    return hmac_get_ctx_params_list;
354
0
}
355
356
static int hmac_get_ctx_params(void *vmacctx, OSSL_PARAM params[])
357
446k
{
358
446k
    struct hmac_data_st *macctx = vmacctx;
359
446k
    struct hmac_get_ctx_params_st p;
360
361
446k
    if (macctx == NULL || !hmac_get_ctx_params_decoder(params, &p))
362
0
        return 0;
363
364
446k
    if (p.size != NULL && !OSSL_PARAM_set_size_t(p.size, hmac_size(macctx)))
365
0
        return 0;
366
367
446k
    if (p.bsize != NULL && !OSSL_PARAM_set_int(p.bsize, hmac_block_size(macctx)))
368
0
        return 0;
369
370
#ifdef FIPS_MODULE
371
    if (p.ind != NULL) {
372
        int approved = 0;
373
374
        if (!macctx->internal)
375
            approved = OSSL_FIPS_IND_GET(macctx)->approved;
376
        if (!OSSL_PARAM_set_int(p.ind, approved))
377
            return 0;
378
    }
379
#endif
380
446k
    return 1;
381
446k
}
382
383
/* clang-format off */
384
/* Machine generated by util/perl/OpenSSL/paramnames.pm */
385
#ifndef hmac_set_ctx_params_list
386
static const OSSL_PARAM hmac_set_ctx_params_list[] = {
387
    OSSL_PARAM_utf8_string(OSSL_MAC_PARAM_DIGEST, NULL, 0),
388
    OSSL_PARAM_utf8_string(OSSL_MAC_PARAM_PROPERTIES, NULL, 0),
389
    OSSL_PARAM_octet_string(OSSL_MAC_PARAM_KEY, NULL, 0),
390
    OSSL_PARAM_size_t(OSSL_MAC_PARAM_TLS_DATA_SIZE, NULL),
391
# if defined(FIPS_MODULE)
392
    OSSL_PARAM_int(OSSL_MAC_PARAM_FIPS_KEY_CHECK, NULL),
393
# endif
394
    OSSL_PARAM_END
395
};
396
#endif
397
398
#ifndef hmac_set_ctx_params_st
399
struct hmac_set_ctx_params_st {
400
    OSSL_PARAM *digest;
401
    OSSL_PARAM *engine;
402
# if defined(FIPS_MODULE)
403
    OSSL_PARAM *ind_k;
404
# endif
405
    OSSL_PARAM *key;
406
    OSSL_PARAM *propq;
407
    OSSL_PARAM *tlssize;
408
};
409
#endif
410
411
#ifndef hmac_set_ctx_params_decoder
412
static int hmac_set_ctx_params_decoder
413
    (const OSSL_PARAM *p, struct hmac_set_ctx_params_st *r)
414
159k
{
415
159k
    const char *s;
416
417
159k
    memset(r, 0, sizeof(*r));
418
159k
    if (p != NULL)
419
163k
        for (; (s = p->key) != NULL; p++)
420
76.8k
            switch(s[0]) {
421
45
            default:
422
45
                break;
423
50.0k
            case 'd':
424
50.0k
                if (ossl_likely(strcmp("igest", s + 1) == 0)) {
425
                    /* OSSL_MAC_PARAM_DIGEST */
426
50.0k
                    if (ossl_unlikely(r->digest != NULL)) {
427
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
428
0
                                       "param %s is repeated", s);
429
0
                        return 0;
430
0
                    }
431
50.0k
                    r->digest = (OSSL_PARAM *)p;
432
50.0k
                }
433
50.0k
                break;
434
50.0k
            case 'e':
435
0
                if (ossl_likely(strcmp("ngine", s + 1) == 0)) {
436
                    /* OSSL_ALG_PARAM_ENGINE */
437
0
                    if (ossl_unlikely(r->engine != NULL)) {
438
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
439
0
                                       "param %s is repeated", s);
440
0
                        return 0;
441
0
                    }
442
0
                    r->engine = (OSSL_PARAM *)p;
443
0
                }
444
0
                break;
445
248
            case 'k':
446
248
                switch(s[1]) {
447
0
                default:
448
0
                    break;
449
248
                case 'e':
450
248
                    switch(s[2]) {
451
0
                    default:
452
0
                        break;
453
248
                    case 'y':
454
248
                        switch(s[3]) {
455
0
                        default:
456
0
                            break;
457
0
                        case '-':
458
# if defined(FIPS_MODULE)
459
                            if (ossl_likely(strcmp("check", s + 4) == 0)) {
460
                                /* OSSL_MAC_PARAM_FIPS_KEY_CHECK */
461
                                if (ossl_unlikely(r->ind_k != NULL)) {
462
                                    ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
463
                                                   "param %s is repeated", s);
464
                                    return 0;
465
                                }
466
                                r->ind_k = (OSSL_PARAM *)p;
467
                            }
468
# endif
469
0
                            break;
470
248
                        case '\0':
471
248
                            if (ossl_unlikely(r->key != NULL)) {
472
0
                                ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
473
0
                                               "param %s is repeated", s);
474
0
                                return 0;
475
0
                            }
476
248
                            r->key = (OSSL_PARAM *)p;
477
248
                        }
478
248
                    }
479
248
                }
480
248
                break;
481
1.09k
            case 'p':
482
1.09k
                if (ossl_likely(strcmp("roperties", s + 1) == 0)) {
483
                    /* OSSL_MAC_PARAM_PROPERTIES */
484
1.09k
                    if (ossl_unlikely(r->propq != NULL)) {
485
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
486
0
                                       "param %s is repeated", s);
487
0
                        return 0;
488
0
                    }
489
1.09k
                    r->propq = (OSSL_PARAM *)p;
490
1.09k
                }
491
1.09k
                break;
492
25.4k
            case 't':
493
25.4k
                if (ossl_likely(strcmp("ls-data-size", s + 1) == 0)) {
494
                    /* OSSL_MAC_PARAM_TLS_DATA_SIZE */
495
25.4k
                    if (ossl_unlikely(r->tlssize != NULL)) {
496
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
497
0
                                       "param %s is repeated", s);
498
0
                        return 0;
499
0
                    }
500
25.4k
                    r->tlssize = (OSSL_PARAM *)p;
501
25.4k
                }
502
76.8k
            }
503
159k
    return 1;
504
159k
}
505
#endif
506
/* End of machine generated */
507
/* clang-format on */
508
509
static const OSSL_PARAM *hmac_settable_ctx_params(ossl_unused void *ctx,
510
    ossl_unused void *provctx)
511
153k
{
512
153k
    return hmac_set_ctx_params_list;
513
153k
}
514
515
/*
516
 * ALL parameters should be set before init().
517
 */
518
static int hmac_set_ctx_params(void *vmacctx, const OSSL_PARAM params[])
519
323k
{
520
323k
    struct hmac_data_st *macctx = vmacctx;
521
323k
    OSSL_LIB_CTX *ctx;
522
323k
    struct hmac_set_ctx_params_st p;
523
524
323k
    if (macctx == NULL || !hmac_set_ctx_params_decoder(params, &p))
525
0
        return 0;
526
527
323k
    ctx = PROV_LIBCTX_OF(macctx->provctx);
528
529
323k
    if (!OSSL_FIPS_IND_SET_CTX_FROM_PARAM(macctx, OSSL_FIPS_IND_SETTABLE0, p.ind_k))
530
0
        return 0;
531
532
323k
    if (p.digest != NULL
533
96.3k
        && !ossl_prov_digest_load(&macctx->digest, p.digest, p.propq,
534
96.3k
            p.engine, ctx))
535
456
        return 0;
536
537
323k
    if (p.key != NULL) {
538
454
        if (p.key->data_type != OSSL_PARAM_OCTET_STRING)
539
0
            return 0;
540
541
454
        if (!hmac_setkey(macctx, p.key->data, p.key->data_size))
542
4
            return 0;
543
454
    }
544
545
323k
    if (p.tlssize != NULL && !OSSL_PARAM_get_size_t(p.tlssize, &macctx->tls_data_size))
546
0
        return 0;
547
548
323k
    return 1;
549
323k
}
550
551
const OSSL_DISPATCH ossl_hmac_functions[] = {
552
    { OSSL_FUNC_MAC_NEWCTX, (void (*)(void))hmac_new },
553
    { OSSL_FUNC_MAC_DUPCTX, (void (*)(void))hmac_dup },
554
    { OSSL_FUNC_MAC_FREECTX, (void (*)(void))hmac_free },
555
    { OSSL_FUNC_MAC_INIT, (void (*)(void))hmac_init },
556
    { OSSL_FUNC_MAC_UPDATE, (void (*)(void))hmac_update },
557
    { OSSL_FUNC_MAC_FINAL, (void (*)(void))hmac_final },
558
    { OSSL_FUNC_MAC_GETTABLE_CTX_PARAMS,
559
        (void (*)(void))hmac_gettable_ctx_params },
560
    { OSSL_FUNC_MAC_GET_CTX_PARAMS, (void (*)(void))hmac_get_ctx_params },
561
    { OSSL_FUNC_MAC_SETTABLE_CTX_PARAMS,
562
        (void (*)(void))hmac_settable_ctx_params },
563
    { OSSL_FUNC_MAC_SET_CTX_PARAMS, (void (*)(void))hmac_set_ctx_params },
564
    OSSL_DISPATCH_END
565
};
566
567
#ifdef FIPS_MODULE
568
static OSSL_FUNC_mac_newctx_fn hmac_internal_new;
569
570
static void *hmac_internal_new(void *provctx)
571
{
572
    struct hmac_data_st *macctx = hmac_new(provctx);
573
574
    if (macctx != NULL)
575
        macctx->internal = 1;
576
    return macctx;
577
}
578
579
const OSSL_DISPATCH ossl_hmac_internal_functions[] = {
580
    { OSSL_FUNC_MAC_NEWCTX, (void (*)(void))hmac_internal_new },
581
    { OSSL_FUNC_MAC_DUPCTX, (void (*)(void))hmac_dup },
582
    { OSSL_FUNC_MAC_FREECTX, (void (*)(void))hmac_free },
583
    { OSSL_FUNC_MAC_INIT, (void (*)(void))hmac_init },
584
    { OSSL_FUNC_MAC_UPDATE, (void (*)(void))hmac_update },
585
    { OSSL_FUNC_MAC_FINAL, (void (*)(void))hmac_final },
586
    { OSSL_FUNC_MAC_GETTABLE_CTX_PARAMS,
587
        (void (*)(void))hmac_gettable_ctx_params },
588
    { OSSL_FUNC_MAC_GET_CTX_PARAMS, (void (*)(void))hmac_get_ctx_params },
589
    { OSSL_FUNC_MAC_SETTABLE_CTX_PARAMS,
590
        (void (*)(void))hmac_settable_ctx_params },
591
    { OSSL_FUNC_MAC_SET_CTX_PARAMS, (void (*)(void))hmac_set_ctx_params },
592
    OSSL_DISPATCH_END
593
};
594
595
#endif /* FIPS_MODULE */