GNU libmicrohttpd 1.0.6
Loading...
Searching...
No Matches
mhd_sha256_wrap.h
Go to the documentation of this file.
1/*
2 This file is part of GNU libmicrohttpd
3 Copyright (C) 2022 Evgeny Grin (Karlson2k)
4
5 GNU libmicrohttpd is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with GNU libmicrohttpd.
17 If not, see <http://www.gnu.org/licenses/>.
18*/
19
26
27#ifndef MHD_SHA256_WRAP_H
28#define MHD_SHA256_WRAP_H 1
29
30#include "mhd_options.h"
31#ifndef MHD_SHA256_SUPPORT
32#error This file must be used only when SHA-256 is enabled
33#endif
34#ifndef MHD_SHA256_TLSLIB
35#include "sha256.h"
36#else /* MHD_SHA256_TLSLIB */
37#include "sha256_ext.h"
38#endif /* MHD_SHA256_TLSLIB */
39
40#ifndef SHA256_DIGEST_SIZE
45#define SHA256_DIGEST_SIZE (32)
46#endif /* ! SHA256_DIGEST_SIZE */
47
48#ifndef SHA256_DIGEST_STRING_SIZE
52#define SHA256_DIGEST_STRING_SIZE ((SHA256_DIGEST_SIZE) * 2 + 1)
53#endif /* ! SHA256_DIGEST_STRING_SIZE */
54
55#ifndef MHD_SHA256_TLSLIB
59#define Sha256CtxWr Sha256Ctx
60#else /* MHD_SHA256_TLSLIB */
64#define Sha256CtxWr Sha256CtxExt
65#endif /* MHD_SHA256_TLSLIB */
66
67#ifndef MHD_SHA256_HAS_INIT_ONE_TIME
71#define MHD_SHA256_init_one_time(ctx) MHD_SHA256_init(ctx)
72#endif /* ! MHD_SHA256_HAS_INIT_ONE_TIME */
73
74#ifndef MHD_SHA256_HAS_FINISH_RESET
78#define MHD_SHA256_reset(ctx) MHD_SHA256_init(ctx)
82#define MHD_SHA256_finish_reset(ctx,digest) MHD_SHA256_finish(ctx,digest), \
83 MHD_SHA256_reset(ctx)
84
85#else /* MHD_SHA256_HAS_FINISH_RESET */
86#define MHD_SHA256_reset(ctx) (void)0
87#endif /* MHD_SHA256_HAS_FINISH_RESET */
88
89#ifndef MHD_SHA256_HAS_DEINIT
90#define MHD_SHA256_deinit(ignore) (void)0
91#endif /* HAVE_SHA256_DEINIT */
92
93/* Sanity checks */
94
95#if ! defined(MHD_SHA256_HAS_FINISH_RESET) && ! defined(MHD_SHA256_HAS_FINISH)
96#error Required MHD_SHA256_finish_reset() or MHD_SHA256_finish()
97#endif /* ! MHD_SHA256_HAS_FINISH_RESET && ! MHD_SHA256_HAS_FINISH */
98
99#endif /* MHD_SHA256_WRAP_H */
additional automatic macros for MHD_config.h
Calculation of SHA-256 digest.
Wrapper declarations for SHA-256 calculation performed by TLS library.