GNU libmicrohttpd 1.0.2
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
27#ifndef MHD_SHA256_WRAP_H
28#define MHD_SHA256_WRAP_H 1
29
30#include "mhd_options.h"
31#include "mhd_options.h"
32#ifndef MHD_SHA256_SUPPORT
33#error This file must be used only when SHA-256 is enabled
34#endif
35#ifndef MHD_SHA256_TLSLIB
36#include "sha256.h"
37#else /* MHD_SHA256_TLSLIB */
38#include "sha256_ext.h"
39#endif /* MHD_SHA256_TLSLIB */
40
41#ifndef SHA256_DIGEST_SIZE
46#define SHA256_DIGEST_SIZE (32)
47#endif /* ! SHA256_DIGEST_SIZE */
48
49#ifndef SHA256_DIGEST_STRING_SIZE
53#define SHA256_DIGEST_STRING_SIZE ((SHA256_DIGEST_SIZE) * 2 + 1)
54#endif /* ! SHA256_DIGEST_STRING_SIZE */
55
56#ifndef MHD_SHA256_TLSLIB
60#define Sha256CtxWr Sha256Ctx
61#else /* MHD_SHA256_TLSLIB */
65#define Sha256CtxWr Sha256CtxExt
66#endif /* MHD_SHA256_TLSLIB */
67
68#ifndef MHD_SHA256_HAS_INIT_ONE_TIME
72#define MHD_SHA256_init_one_time(ctx) MHD_SHA256_init(ctx)
73#endif /* ! MHD_SHA256_HAS_INIT_ONE_TIME */
74
75#ifndef MHD_SHA256_HAS_FINISH_RESET
79#define MHD_SHA256_reset(ctx) MHD_SHA256_init(ctx)
83#define MHD_SHA256_finish_reset(ctx,digest) MHD_SHA256_finish(ctx,digest), \
84 MHD_SHA256_reset(ctx)
85
86#else /* MHD_SHA256_HAS_FINISH_RESET */
87#define MHD_SHA256_reset(ctx) (void)0
88#endif /* MHD_SHA256_HAS_FINISH_RESET */
89
90#ifndef MHD_SHA256_HAS_DEINIT
91#define MHD_SHA256_deinit(ignore) (void)0
92#endif /* HAVE_SHA256_DEINIT */
93
94/* Sanity checks */
95
96#if ! defined(MHD_SHA256_HAS_FINISH_RESET) && ! defined(MHD_SHA256_HAS_FINISH)
97#error Required MHD_SHA256_finish_reset() or MHD_SHA256_finish_reset()
98#endif /* ! MHD_SHA256_HAS_FINISH_RESET && ! MHD_SHA256_HAS_FINISH */
99
100#endif /* MHD_SHA256_WRAP_H */
additional automatic macros for MHD_config.h
Calculation of SHA-256 digest.
Wrapper for SHA-256 calculation performed by TLS library.