Coverage Report

Created: 2025-06-13 06:58

/src/openssl30/providers/implementations/include/prov/digestcommon.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2019-2021 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
#ifndef OSSL_PROVIDERS_DIGESTCOMMON_H
11
# define OSSL_PROVIDERS_DIGESTCOMMON_H
12
13
# include <openssl/core_dispatch.h>
14
# include <openssl/core_names.h>
15
# include <openssl/params.h>
16
# include "prov/providercommon.h"
17
18
/* Internal flags that can be queried */
19
1.09k
#define PROV_DIGEST_FLAG_XOF             0x0001
20
1.09k
#define PROV_DIGEST_FLAG_ALGID_ABSENT    0x0002
21
22
# ifdef __cplusplus
23
extern "C" {
24
# endif
25
26
#define PROV_FUNC_DIGEST_GET_PARAM(name, blksize, dgstsize, flags)             \
27
static OSSL_FUNC_digest_get_params_fn name##_get_params;                       \
28
946
static int name##_get_params(OSSL_PARAM params[])                              \
29
946
{                                                                              \
30
946
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
946
}
blake2_prov.c:blake2s256_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
blake2_prov.c:blake2b512_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
md5_prov.c:md5_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
md5_sha1_prov.c:md5_sha1_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
null_prov.c:nullmd_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
ripemd_prov.c:ripemd160_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha2_prov.c:sha1_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha2_prov.c:sha224_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha2_prov.c:sha256_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha2_prov.c:sha384_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha2_prov.c:sha512_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha2_prov.c:sha512_224_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha2_prov.c:sha512_256_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha3_prov.c:sha3_224_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha3_prov.c:sha3_256_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha3_prov.c:sha3_384_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha3_prov.c:sha3_512_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha3_prov.c:shake_128_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha3_prov.c:shake_256_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha3_prov.c:keccak_kmac_128_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sha3_prov.c:keccak_kmac_256_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
sm3_prov.c:sm3_get_params
Line
Count
Source
28
43
static int name##_get_params(OSSL_PARAM params[])                              \
29
43
{                                                                              \
30
43
    return ossl_digest_default_get_params(params, blksize, dgstsize, flags);   \
31
43
}
32
33
#define PROV_DISPATCH_FUNC_DIGEST_GET_PARAMS(name)                             \
34
{ OSSL_FUNC_DIGEST_GET_PARAMS, (void (*)(void))name##_get_params },            \
35
{ OSSL_FUNC_DIGEST_GETTABLE_PARAMS,                                            \
36
  (void (*)(void))ossl_digest_default_gettable_params }
37
38
# define PROV_FUNC_DIGEST_FINAL(name, dgstsize, fin)                           \
39
static OSSL_FUNC_digest_final_fn name##_internal_final;                        \
40
static int name##_internal_final(void *ctx, unsigned char *out, size_t *outl,  \
41
247M
                                 size_t outsz)                                 \
42
247M
{                                                                              \
43
247M
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
247M
        *outl = dgstsize;                                                      \
45
247M
        return 1;                                                              \
46
247M
    }                                                                          \
47
247M
    return 0;                                                                  \
48
247M
}
md5_prov.c:md5_internal_final
Line
Count
Source
41
327k
                                 size_t outsz)                                 \
42
327k
{                                                                              \
43
327k
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
327k
        *outl = dgstsize;                                                      \
45
327k
        return 1;                                                              \
46
327k
    }                                                                          \
47
327k
    return 0;                                                                  \
48
327k
}
md5_sha1_prov.c:md5_sha1_internal_final
Line
Count
Source
41
5.92k
                                 size_t outsz)                                 \
42
5.92k
{                                                                              \
43
5.92k
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
5.92k
        *outl = dgstsize;                                                      \
45
5.92k
        return 1;                                                              \
46
5.92k
    }                                                                          \
47
5.92k
    return 0;                                                                  \
48
5.92k
}
ripemd_prov.c:ripemd160_internal_final
Line
Count
Source
41
1.03M
                                 size_t outsz)                                 \
42
1.03M
{                                                                              \
43
1.03M
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
1.03M
        *outl = dgstsize;                                                      \
45
1.03M
        return 1;                                                              \
46
1.03M
    }                                                                          \
47
1.03M
    return 0;                                                                  \
48
1.03M
}
sha2_prov.c:sha1_internal_final
Line
Count
Source
41
961k
                                 size_t outsz)                                 \
42
961k
{                                                                              \
43
961k
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
961k
        *outl = dgstsize;                                                      \
45
961k
        return 1;                                                              \
46
961k
    }                                                                          \
47
961k
    return 0;                                                                  \
48
961k
}
sha2_prov.c:sha224_internal_final
Line
Count
Source
41
198k
                                 size_t outsz)                                 \
42
198k
{                                                                              \
43
198k
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
198k
        *outl = dgstsize;                                                      \
45
198k
        return 1;                                                              \
46
198k
    }                                                                          \
47
198k
    return 0;                                                                  \
48
198k
}
sha2_prov.c:sha256_internal_final
Line
Count
Source
41
228M
                                 size_t outsz)                                 \
42
228M
{                                                                              \
43
228M
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
228M
        *outl = dgstsize;                                                      \
45
228M
        return 1;                                                              \
46
228M
    }                                                                          \
47
228M
    return 0;                                                                  \
48
228M
}
sha2_prov.c:sha384_internal_final
Line
Count
Source
41
1.14M
                                 size_t outsz)                                 \
42
1.14M
{                                                                              \
43
1.14M
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
1.14M
        *outl = dgstsize;                                                      \
45
1.14M
        return 1;                                                              \
46
1.14M
    }                                                                          \
47
1.14M
    return 0;                                                                  \
48
1.14M
}
sha2_prov.c:sha512_internal_final
Line
Count
Source
41
15.0M
                                 size_t outsz)                                 \
42
15.0M
{                                                                              \
43
15.0M
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
15.0M
        *outl = dgstsize;                                                      \
45
15.0M
        return 1;                                                              \
46
15.0M
    }                                                                          \
47
15.0M
    return 0;                                                                  \
48
15.0M
}
sha2_prov.c:sha512_224_internal_final
Line
Count
Source
41
71.3k
                                 size_t outsz)                                 \
42
71.3k
{                                                                              \
43
71.3k
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
71.3k
        *outl = dgstsize;                                                      \
45
71.3k
        return 1;                                                              \
46
71.3k
    }                                                                          \
47
71.3k
    return 0;                                                                  \
48
71.3k
}
sha2_prov.c:sha512_256_internal_final
Line
Count
Source
41
83.9k
                                 size_t outsz)                                 \
42
83.9k
{                                                                              \
43
83.9k
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
83.9k
        *outl = dgstsize;                                                      \
45
83.9k
        return 1;                                                              \
46
83.9k
    }                                                                          \
47
83.9k
    return 0;                                                                  \
48
83.9k
}
sm3_prov.c:sm3_internal_final
Line
Count
Source
41
1.40k
                                 size_t outsz)                                 \
42
1.40k
{                                                                              \
43
1.40k
    if (ossl_prov_is_running() && outsz >= dgstsize && fin(out, ctx)) {        \
44
1.40k
        *outl = dgstsize;                                                      \
45
1.40k
        return 1;                                                              \
46
1.40k
    }                                                                          \
47
1.40k
    return 0;                                                                  \
48
1.40k
}
49
50
# define PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_START(                            \
51
    name, CTX, blksize, dgstsize, flags, upd, fin)                             \
52
static OSSL_FUNC_digest_newctx_fn name##_newctx;                               \
53
static OSSL_FUNC_digest_freectx_fn name##_freectx;                             \
54
static OSSL_FUNC_digest_dupctx_fn name##_dupctx;                               \
55
2.45M
static void *name##_newctx(void *prov_ctx)                                     \
56
2.45M
{                                                                              \
57
2.45M
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
2.45M
    return ctx;                                                                \
59
2.45M
}                                                                              \
blake2_prov.c:blake2s256_newctx
Line
Count
Source
55
218
static void *name##_newctx(void *prov_ctx)                                     \
56
218
{                                                                              \
57
218
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
218
    return ctx;                                                                \
59
218
}                                                                              \
blake2_prov.c:blake2b512_newctx
Line
Count
Source
55
27.2k
static void *name##_newctx(void *prov_ctx)                                     \
56
27.2k
{                                                                              \
57
27.2k
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
27.2k
    return ctx;                                                                \
59
27.2k
}                                                                              \
md5_prov.c:md5_newctx
Line
Count
Source
55
66.8k
static void *name##_newctx(void *prov_ctx)                                     \
56
66.8k
{                                                                              \
57
66.8k
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
66.8k
    return ctx;                                                                \
59
66.8k
}                                                                              \
md5_sha1_prov.c:md5_sha1_newctx
Line
Count
Source
55
8.10k
static void *name##_newctx(void *prov_ctx)                                     \
56
8.10k
{                                                                              \
57
8.10k
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
8.10k
    return ctx;                                                                \
59
8.10k
}                                                                              \
null_prov.c:nullmd_newctx
Line
Count
Source
55
15
static void *name##_newctx(void *prov_ctx)                                     \
56
15
{                                                                              \
57
15
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
15
    return ctx;                                                                \
59
15
}                                                                              \
ripemd_prov.c:ripemd160_newctx
Line
Count
Source
55
313k
static void *name##_newctx(void *prov_ctx)                                     \
56
313k
{                                                                              \
57
313k
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
313k
    return ctx;                                                                \
59
313k
}                                                                              \
sha2_prov.c:sha1_newctx
Line
Count
Source
55
454k
static void *name##_newctx(void *prov_ctx)                                     \
56
454k
{                                                                              \
57
454k
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
454k
    return ctx;                                                                \
59
454k
}                                                                              \
sha2_prov.c:sha224_newctx
Line
Count
Source
55
49.0k
static void *name##_newctx(void *prov_ctx)                                     \
56
49.0k
{                                                                              \
57
49.0k
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
49.0k
    return ctx;                                                                \
59
49.0k
}                                                                              \
sha2_prov.c:sha256_newctx
Line
Count
Source
55
644k
static void *name##_newctx(void *prov_ctx)                                     \
56
644k
{                                                                              \
57
644k
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
644k
    return ctx;                                                                \
59
644k
}                                                                              \
sha2_prov.c:sha384_newctx
Line
Count
Source
55
800k
static void *name##_newctx(void *prov_ctx)                                     \
56
800k
{                                                                              \
57
800k
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
800k
    return ctx;                                                                \
59
800k
}                                                                              \
sha2_prov.c:sha512_newctx
Line
Count
Source
55
70.4k
static void *name##_newctx(void *prov_ctx)                                     \
56
70.4k
{                                                                              \
57
70.4k
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
70.4k
    return ctx;                                                                \
59
70.4k
}                                                                              \
sha2_prov.c:sha512_224_newctx
Line
Count
Source
55
5.10k
static void *name##_newctx(void *prov_ctx)                                     \
56
5.10k
{                                                                              \
57
5.10k
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
5.10k
    return ctx;                                                                \
59
5.10k
}                                                                              \
sha2_prov.c:sha512_256_newctx
Line
Count
Source
55
10.5k
static void *name##_newctx(void *prov_ctx)                                     \
56
10.5k
{                                                                              \
57
10.5k
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
10.5k
    return ctx;                                                                \
59
10.5k
}                                                                              \
sm3_prov.c:sm3_newctx
Line
Count
Source
55
491
static void *name##_newctx(void *prov_ctx)                                     \
56
491
{                                                                              \
57
491
    CTX *ctx = ossl_prov_is_running() ? OPENSSL_zalloc(sizeof(*ctx)) : NULL;   \
58
491
    return ctx;                                                                \
59
491
}                                                                              \
60
5.33M
static void name##_freectx(void *vctx)                                         \
61
5.33M
{                                                                              \
62
5.33M
    CTX *ctx = (CTX *)vctx;                                                    \
63
5.33M
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
5.33M
}                                                                              \
blake2_prov.c:blake2s256_freectx
Line
Count
Source
60
400
static void name##_freectx(void *vctx)                                         \
61
400
{                                                                              \
62
400
    CTX *ctx = (CTX *)vctx;                                                    \
63
400
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
400
}                                                                              \
blake2_prov.c:blake2b512_freectx
Line
Count
Source
60
27.3k
static void name##_freectx(void *vctx)                                         \
61
27.3k
{                                                                              \
62
27.3k
    CTX *ctx = (CTX *)vctx;                                                    \
63
27.3k
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
27.3k
}                                                                              \
md5_prov.c:md5_freectx
Line
Count
Source
60
774k
static void name##_freectx(void *vctx)                                         \
61
774k
{                                                                              \
62
774k
    CTX *ctx = (CTX *)vctx;                                                    \
63
774k
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
774k
}                                                                              \
md5_sha1_prov.c:md5_sha1_freectx
Line
Count
Source
60
12.9k
static void name##_freectx(void *vctx)                                         \
61
12.9k
{                                                                              \
62
12.9k
    CTX *ctx = (CTX *)vctx;                                                    \
63
12.9k
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
12.9k
}                                                                              \
null_prov.c:nullmd_freectx
Line
Count
Source
60
18
static void name##_freectx(void *vctx)                                         \
61
18
{                                                                              \
62
18
    CTX *ctx = (CTX *)vctx;                                                    \
63
18
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
18
}                                                                              \
ripemd_prov.c:ripemd160_freectx
Line
Count
Source
60
314k
static void name##_freectx(void *vctx)                                         \
61
314k
{                                                                              \
62
314k
    CTX *ctx = (CTX *)vctx;                                                    \
63
314k
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
314k
}                                                                              \
sha2_prov.c:sha1_freectx
Line
Count
Source
60
1.05M
static void name##_freectx(void *vctx)                                         \
61
1.05M
{                                                                              \
62
1.05M
    CTX *ctx = (CTX *)vctx;                                                    \
63
1.05M
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
1.05M
}                                                                              \
sha2_prov.c:sha224_freectx
Line
Count
Source
60
49.5k
static void name##_freectx(void *vctx)                                         \
61
49.5k
{                                                                              \
62
49.5k
    CTX *ctx = (CTX *)vctx;                                                    \
63
49.5k
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
49.5k
}                                                                              \
sha2_prov.c:sha256_freectx
Line
Count
Source
60
1.51M
static void name##_freectx(void *vctx)                                         \
61
1.51M
{                                                                              \
62
1.51M
    CTX *ctx = (CTX *)vctx;                                                    \
63
1.51M
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
1.51M
}                                                                              \
sha2_prov.c:sha384_freectx
Line
Count
Source
60
1.49M
static void name##_freectx(void *vctx)                                         \
61
1.49M
{                                                                              \
62
1.49M
    CTX *ctx = (CTX *)vctx;                                                    \
63
1.49M
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
1.49M
}                                                                              \
sha2_prov.c:sha512_freectx
Line
Count
Source
60
71.4k
static void name##_freectx(void *vctx)                                         \
61
71.4k
{                                                                              \
62
71.4k
    CTX *ctx = (CTX *)vctx;                                                    \
63
71.4k
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
71.4k
}                                                                              \
sha2_prov.c:sha512_224_freectx
Line
Count
Source
60
5.19k
static void name##_freectx(void *vctx)                                         \
61
5.19k
{                                                                              \
62
5.19k
    CTX *ctx = (CTX *)vctx;                                                    \
63
5.19k
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
5.19k
}                                                                              \
sha2_prov.c:sha512_256_freectx
Line
Count
Source
60
10.6k
static void name##_freectx(void *vctx)                                         \
61
10.6k
{                                                                              \
62
10.6k
    CTX *ctx = (CTX *)vctx;                                                    \
63
10.6k
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
10.6k
}                                                                              \
sm3_prov.c:sm3_freectx
Line
Count
Source
60
725
static void name##_freectx(void *vctx)                                         \
61
725
{                                                                              \
62
725
    CTX *ctx = (CTX *)vctx;                                                    \
63
725
    OPENSSL_clear_free(ctx,  sizeof(*ctx));                                    \
64
725
}                                                                              \
65
2.87M
static void *name##_dupctx(void *ctx)                                          \
66
2.87M
{                                                                              \
67
2.87M
    CTX *in = (CTX *)ctx;                                                      \
68
2.87M
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
2.87M
    if (ret != NULL)                                                           \
70
2.87M
        *ret = *in;                                                            \
71
2.87M
    return ret;                                                                \
72
2.87M
}                                                                              \
blake2_prov.c:blake2s256_dupctx
Line
Count
Source
65
182
static void *name##_dupctx(void *ctx)                                          \
66
182
{                                                                              \
67
182
    CTX *in = (CTX *)ctx;                                                      \
68
182
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
182
    if (ret != NULL)                                                           \
70
182
        *ret = *in;                                                            \
71
182
    return ret;                                                                \
72
182
}                                                                              \
blake2_prov.c:blake2b512_dupctx
Line
Count
Source
65
35
static void *name##_dupctx(void *ctx)                                          \
66
35
{                                                                              \
67
35
    CTX *in = (CTX *)ctx;                                                      \
68
35
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
35
    if (ret != NULL)                                                           \
70
35
        *ret = *in;                                                            \
71
35
    return ret;                                                                \
72
35
}                                                                              \
md5_prov.c:md5_dupctx
Line
Count
Source
65
707k
static void *name##_dupctx(void *ctx)                                          \
66
707k
{                                                                              \
67
707k
    CTX *in = (CTX *)ctx;                                                      \
68
707k
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
707k
    if (ret != NULL)                                                           \
70
707k
        *ret = *in;                                                            \
71
707k
    return ret;                                                                \
72
707k
}                                                                              \
md5_sha1_prov.c:md5_sha1_dupctx
Line
Count
Source
65
4.87k
static void *name##_dupctx(void *ctx)                                          \
66
4.87k
{                                                                              \
67
4.87k
    CTX *in = (CTX *)ctx;                                                      \
68
4.87k
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
4.87k
    if (ret != NULL)                                                           \
70
4.87k
        *ret = *in;                                                            \
71
4.87k
    return ret;                                                                \
72
4.87k
}                                                                              \
null_prov.c:nullmd_dupctx
Line
Count
Source
65
3
static void *name##_dupctx(void *ctx)                                          \
66
3
{                                                                              \
67
3
    CTX *in = (CTX *)ctx;                                                      \
68
3
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
3
    if (ret != NULL)                                                           \
70
3
        *ret = *in;                                                            \
71
3
    return ret;                                                                \
72
3
}                                                                              \
ripemd_prov.c:ripemd160_dupctx
Line
Count
Source
65
555
static void *name##_dupctx(void *ctx)                                          \
66
555
{                                                                              \
67
555
    CTX *in = (CTX *)ctx;                                                      \
68
555
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
555
    if (ret != NULL)                                                           \
70
555
        *ret = *in;                                                            \
71
555
    return ret;                                                                \
72
555
}                                                                              \
sha2_prov.c:sha1_dupctx
Line
Count
Source
65
599k
static void *name##_dupctx(void *ctx)                                          \
66
599k
{                                                                              \
67
599k
    CTX *in = (CTX *)ctx;                                                      \
68
599k
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
599k
    if (ret != NULL)                                                           \
70
599k
        *ret = *in;                                                            \
71
599k
    return ret;                                                                \
72
599k
}                                                                              \
sha2_prov.c:sha224_dupctx
Line
Count
Source
65
563
static void *name##_dupctx(void *ctx)                                          \
66
563
{                                                                              \
67
563
    CTX *in = (CTX *)ctx;                                                      \
68
563
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
563
    if (ret != NULL)                                                           \
70
563
        *ret = *in;                                                            \
71
563
    return ret;                                                                \
72
563
}                                                                              \
sha2_prov.c:sha256_dupctx
Line
Count
Source
65
871k
static void *name##_dupctx(void *ctx)                                          \
66
871k
{                                                                              \
67
871k
    CTX *in = (CTX *)ctx;                                                      \
68
871k
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
871k
    if (ret != NULL)                                                           \
70
871k
        *ret = *in;                                                            \
71
871k
    return ret;                                                                \
72
871k
}                                                                              \
sha2_prov.c:sha384_dupctx
Line
Count
Source
65
692k
static void *name##_dupctx(void *ctx)                                          \
66
692k
{                                                                              \
67
692k
    CTX *in = (CTX *)ctx;                                                      \
68
692k
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
692k
    if (ret != NULL)                                                           \
70
692k
        *ret = *in;                                                            \
71
692k
    return ret;                                                                \
72
692k
}                                                                              \
sha2_prov.c:sha512_dupctx
Line
Count
Source
65
1.00k
static void *name##_dupctx(void *ctx)                                          \
66
1.00k
{                                                                              \
67
1.00k
    CTX *in = (CTX *)ctx;                                                      \
68
1.00k
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
1.00k
    if (ret != NULL)                                                           \
70
1.00k
        *ret = *in;                                                            \
71
1.00k
    return ret;                                                                \
72
1.00k
}                                                                              \
sha2_prov.c:sha512_224_dupctx
Line
Count
Source
65
90
static void *name##_dupctx(void *ctx)                                          \
66
90
{                                                                              \
67
90
    CTX *in = (CTX *)ctx;                                                      \
68
90
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
90
    if (ret != NULL)                                                           \
70
90
        *ret = *in;                                                            \
71
90
    return ret;                                                                \
72
90
}                                                                              \
sha2_prov.c:sha512_256_dupctx
Line
Count
Source
65
48
static void *name##_dupctx(void *ctx)                                          \
66
48
{                                                                              \
67
48
    CTX *in = (CTX *)ctx;                                                      \
68
48
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
48
    if (ret != NULL)                                                           \
70
48
        *ret = *in;                                                            \
71
48
    return ret;                                                                \
72
48
}                                                                              \
sm3_prov.c:sm3_dupctx
Line
Count
Source
65
234
static void *name##_dupctx(void *ctx)                                          \
66
234
{                                                                              \
67
234
    CTX *in = (CTX *)ctx;                                                      \
68
234
    CTX *ret = ossl_prov_is_running() ? OPENSSL_malloc(sizeof(*ret)) : NULL;   \
69
234
    if (ret != NULL)                                                           \
70
234
        *ret = *in;                                                            \
71
234
    return ret;                                                                \
72
234
}                                                                              \
73
PROV_FUNC_DIGEST_FINAL(name, dgstsize, fin)                                    \
74
PROV_FUNC_DIGEST_GET_PARAM(name, blksize, dgstsize, flags)                     \
75
const OSSL_DISPATCH ossl_##name##_functions[] = {                              \
76
    { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))name##_newctx },                \
77
    { OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))upd },                          \
78
    { OSSL_FUNC_DIGEST_FINAL, (void (*)(void))name##_internal_final },         \
79
    { OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))name##_freectx },              \
80
    { OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))name##_dupctx },                \
81
    PROV_DISPATCH_FUNC_DIGEST_GET_PARAMS(name)
82
83
# define PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_END                               \
84
    { 0, NULL }                                                                \
85
};
86
87
# define IMPLEMENT_digest_functions(                                           \
88
    name, CTX, blksize, dgstsize, flags, init, upd, fin)                       \
89
static OSSL_FUNC_digest_init_fn name##_internal_init;                          \
90
static int name##_internal_init(void *ctx,                                     \
91
246M
                                ossl_unused const OSSL_PARAM params[])         \
92
246M
{                                                                              \
93
246M
    return ossl_prov_is_running() && init(ctx);                                \
94
246M
}                                                                              \
md5_prov.c:md5_internal_init
Line
Count
Source
91
72.9k
                                ossl_unused const OSSL_PARAM params[])         \
92
72.9k
{                                                                              \
93
72.9k
    return ossl_prov_is_running() && init(ctx);                                \
94
72.9k
}                                                                              \
null_prov.c:nullmd_internal_init
Line
Count
Source
91
37
                                ossl_unused const OSSL_PARAM params[])         \
92
37
{                                                                              \
93
37
    return ossl_prov_is_running() && init(ctx);                                \
94
37
}                                                                              \
ripemd_prov.c:ripemd160_internal_init
Line
Count
Source
91
1.03M
                                ossl_unused const OSSL_PARAM params[])         \
92
1.03M
{                                                                              \
93
1.03M
    return ossl_prov_is_running() && init(ctx);                                \
94
1.03M
}                                                                              \
sha2_prov.c:sha224_internal_init
Line
Count
Source
91
199k
                                ossl_unused const OSSL_PARAM params[])         \
92
199k
{                                                                              \
93
199k
    return ossl_prov_is_running() && init(ctx);                                \
94
199k
}                                                                              \
sha2_prov.c:sha256_internal_init
Line
Count
Source
91
228M
                                ossl_unused const OSSL_PARAM params[])         \
92
228M
{                                                                              \
93
228M
    return ossl_prov_is_running() && init(ctx);                                \
94
228M
}                                                                              \
sha2_prov.c:sha384_internal_init
Line
Count
Source
91
1.09M
                                ossl_unused const OSSL_PARAM params[])         \
92
1.09M
{                                                                              \
93
1.09M
    return ossl_prov_is_running() && init(ctx);                                \
94
1.09M
}                                                                              \
sha2_prov.c:sha512_internal_init
Line
Count
Source
91
15.1M
                                ossl_unused const OSSL_PARAM params[])         \
92
15.1M
{                                                                              \
93
15.1M
    return ossl_prov_is_running() && init(ctx);                                \
94
15.1M
}                                                                              \
sha2_prov.c:sha512_224_internal_init
Line
Count
Source
91
71.3k
                                ossl_unused const OSSL_PARAM params[])         \
92
71.3k
{                                                                              \
93
71.3k
    return ossl_prov_is_running() && init(ctx);                                \
94
71.3k
}                                                                              \
sha2_prov.c:sha512_256_internal_init
Line
Count
Source
91
83.9k
                                ossl_unused const OSSL_PARAM params[])         \
92
83.9k
{                                                                              \
93
83.9k
    return ossl_prov_is_running() && init(ctx);                                \
94
83.9k
}                                                                              \
sm3_prov.c:sm3_internal_init
Line
Count
Source
91
1.48k
                                ossl_unused const OSSL_PARAM params[])         \
92
1.48k
{                                                                              \
93
1.48k
    return ossl_prov_is_running() && init(ctx);                                \
94
1.48k
}                                                                              \
95
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, flags, \
96
                                          upd, fin),                           \
97
    { OSSL_FUNC_DIGEST_INIT, (void (*)(void))name##_internal_init },           \
98
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_END
99
100
# define IMPLEMENT_digest_functions_with_settable_ctx(                         \
101
    name, CTX, blksize, dgstsize, flags, init, upd, fin,                       \
102
    settable_ctx_params, set_ctx_params)                                       \
103
static OSSL_FUNC_digest_init_fn name##_internal_init;                          \
104
793k
static int name##_internal_init(void *ctx, const OSSL_PARAM params[])          \
105
793k
{                                                                              \
106
793k
    return ossl_prov_is_running()                                              \
107
793k
           && init(ctx)                                                        \
108
793k
           && set_ctx_params(ctx, params);                                     \
109
793k
}                                                                              \
md5_sha1_prov.c:md5_sha1_internal_init
Line
Count
Source
104
8.75k
static int name##_internal_init(void *ctx, const OSSL_PARAM params[])          \
105
8.75k
{                                                                              \
106
8.75k
    return ossl_prov_is_running()                                              \
107
8.75k
           && init(ctx)                                                        \
108
8.75k
           && set_ctx_params(ctx, params);                                     \
109
8.75k
}                                                                              \
sha2_prov.c:sha1_internal_init
Line
Count
Source
104
784k
static int name##_internal_init(void *ctx, const OSSL_PARAM params[])          \
105
784k
{                                                                              \
106
784k
    return ossl_prov_is_running()                                              \
107
784k
           && init(ctx)                                                        \
108
784k
           && set_ctx_params(ctx, params);                                     \
109
784k
}                                                                              \
110
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, flags, \
111
                                          upd, fin),                           \
112
    { OSSL_FUNC_DIGEST_INIT, (void (*)(void))name##_internal_init },           \
113
    { OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS, (void (*)(void))settable_ctx_params }, \
114
    { OSSL_FUNC_DIGEST_SET_CTX_PARAMS, (void (*)(void))set_ctx_params },       \
115
PROV_DISPATCH_FUNC_DIGEST_CONSTRUCT_END
116
117
118
const OSSL_PARAM *ossl_digest_default_gettable_params(void *provctx);
119
int ossl_digest_default_get_params(OSSL_PARAM params[], size_t blksz,
120
                                   size_t paramsz, unsigned long flags);
121
122
# ifdef __cplusplus
123
}
124
# endif
125
126
#endif /* OSSL_PROVIDERS_DIGESTCOMMON_H */