aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/md5_ext.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/md5_ext.h')
-rw-r--r--src/microhttpd/md5_ext.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/microhttpd/md5_ext.h b/src/microhttpd/md5_ext.h
new file mode 100644
index 00000000..b7437c03
--- /dev/null
+++ b/src/microhttpd/md5_ext.h
@@ -0,0 +1,115 @@
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
20/**
21 * @file microhttpd/md5_ext.h
22 * @brief Wrapper declarations for MD5 calculation performed by TLS library
23 * @author Karlson2k (Evgeny Grin)
24 */
25
26#ifndef MHD_MD5_EXT_H
27#define MHD_MD5_EXT_H 1
28
29#include "mhd_options.h"
30#include <stdint.h>
31#ifdef HAVE_STDDEF_H
32#include <stddef.h> /* for size_t */
33#endif /* HAVE_STDDEF_H */
34
35/**
36 * Size of MD5 resulting digest in bytes
37 * This is the final digest size, not intermediate hash.
38 */
39#define MD5_DIGEST_SIZE (16)
40
41/* Actual declaration is in GnuTLS lib header */
42struct hash_hd_st;
43
44/**
45 * Indicates that struct Md5CtxExt has 'ext_error'
46 */
47#define MHD_MD5_HAS_EXT_ERROR 1
48
49/**
50 * MD5 calculation context
51 */
52struct Md5CtxExt
53{
54 struct hash_hd_st *handle; /**< Hash calculation handle */
55 int ext_error; /**< Non-zero if external error occurs during init or hashing */
56};
57
58/**
59 * Indicates that MHD_MD5_init_one_time() function is present.
60 */
61#define MHD_MD5_HAS_INIT_ONE_TIME 1
62
63/**
64 * Initialise structure for MD5 calculation, allocate resources.
65 *
66 * This function must not be called more than one time for @a ctx.
67 *
68 * @param ctx the calculation context
69 */
70void
71MHD_MD5_init_one_time (struct Md5CtxExt *ctx);
72
73
74/**
75 * MD5 process portion of bytes.
76 *
77 * @param ctx the calculation context
78 * @param data bytes to add to hash
79 * @param length number of bytes in @a data
80 */
81void
82MHD_MD5_update (struct Md5CtxExt *ctx,
83 const uint8_t *data,
84 size_t length);
85
86
87/**
88 * Indicates that MHD_MD5_finish_reset() function is available
89 */
90#define MHD_MD5_HAS_FINISH_RESET 1
91
92/**
93 * Finalise MD5 calculation, return digest, reset hash calculation.
94 *
95 * @param ctx the calculation context
96 * @param[out] digest set to the hash, must be #MD5_DIGEST_SIZE bytes
97 */
98void
99MHD_MD5_finish_reset (struct Md5CtxExt *ctx,
100 uint8_t digest[MD5_DIGEST_SIZE]);
101
102/**
103 * Indicates that MHD_MD5_deinit() function is present
104 */
105#define MHD_MD5_HAS_DEINIT 1
106
107/**
108 * Free allocated resources.
109 *
110 * @param ctx the calculation context
111 */
112void
113MHD_MD5_deinit (struct Md5CtxExt *ctx);
114
115#endif /* MHD_MD5_EXT_H */