aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/sha256.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/sha256.h')
-rw-r--r--src/microhttpd/sha256.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/microhttpd/sha256.h b/src/microhttpd/sha256.h
new file mode 100644
index 00000000..6d36ebef
--- /dev/null
+++ b/src/microhttpd/sha256.h
@@ -0,0 +1,74 @@
1/* sha256.h
2
3 The sha256 hash function.
4
5 Copyright (C) 2001, 2012 Niels Möller
6 Copyright (C) 2018 Christian Grothoff (extraction of minimal subset
7 from GNU Nettle to work with GNU libmicrohttpd)
8
9 This file is part of GNU Nettle.
10
11 GNU Nettle is free software: you can redistribute it and/or
12 modify it under the terms of either:
13
14 * the GNU Lesser General Public License as published by the Free
15 Software Foundation; either version 3 of the License, or (at your
16 option) any later version.
17
18 or
19
20 * the GNU General Public License as published by the Free
21 Software Foundation; either version 2 of the License, or (at your
22 option) any later version.
23
24 or both in parallel, as here.
25
26 GNU Nettle is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 General Public License for more details.
30
31 You should have received copies of the GNU General Public License and
32 the GNU Lesser General Public License along with this program. If
33 not, see http://www.gnu.org/licenses/.
34*/
35
36#ifndef NETTLE_SHA2_H_INCLUDED
37#define NETTLE_SHA2_H_INCLUDED
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
43#define SHA256_DIGEST_SIZE 32
44#define SHA256_BLOCK_SIZE 64
45
46/* Digest is kept internally as 8 32-bit words. */
47#define _SHA256_DIGEST_LENGTH 8
48
49struct sha256_ctx
50{
51 uint32_t state[_SHA256_DIGEST_LENGTH]; /* State variables */
52 uint64_t count; /* 64-bit block count */
53 uint8_t block[SHA256_BLOCK_SIZE]; /* SHA256 data buffer */
54 unsigned int index; /* index into buffer */
55};
56
57void
58sha256_init(struct sha256_ctx *ctx);
59
60void
61sha256_update(struct sha256_ctx *ctx,
62 size_t length,
63 const uint8_t *data);
64
65void
66sha256_digest(struct sha256_ctx *ctx,
67 size_t length,
68 uint8_t *digest);
69
70#ifdef __cplusplus
71}
72#endif
73
74#endif /* NETTLE_SHA2_H_INCLUDED */