GNU libmicrohttpd  0.9.63
sha256.h
Go to the documentation of this file.
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 #define SHA256_DIGEST_SIZE 32
40 #define SHA256_BLOCK_SIZE 64
41 
42 /* Digest is kept internally as 8 32-bit words. */
43 #define _SHA256_DIGEST_LENGTH 8
44 
45 struct sha256_ctx
46 {
47  uint32_t state[_SHA256_DIGEST_LENGTH]; /* State variables */
48  uint64_t count; /* 64-bit block count */
49  uint8_t block[SHA256_BLOCK_SIZE]; /* SHA256 data buffer */
50  unsigned int index; /* index into buffer */
51 };
52 
53 
59 void
60 sha256_init (void *ctx_);
61 
62 
70 void
71 sha256_update (void *ctx_,
72  const uint8_t *data,
73  size_t length);
74 
81 void
82 sha256_digest (void *ctx_,
83  uint8_t digest[SHA256_DIGEST_SIZE]);
84 
85 #endif /* NETTLE_SHA2_H_INCLUDED */
void * data
Definition: microhttpd.h:2709
uint8_t block[SHA256_BLOCK_SIZE]
Definition: sha256.h:49
#define SHA256_DIGEST_SIZE
Definition: sha256.h:39
void sha256_update(void *ctx_, const uint8_t *data, size_t length)
Definition: sha256.c:326
uint64_t count
Definition: sha256.h:48
void sha256_digest(void *ctx_, uint8_t digest[SHA256_DIGEST_SIZE])
#define SHA256_BLOCK_SIZE
Definition: sha256.h:40
void sha256_init(void *ctx_)
Definition: sha256.c:238
#define _SHA256_DIGEST_LENGTH
Definition: sha256.h:43
uint32_t state[_SHA256_DIGEST_LENGTH]
Definition: sha256.h:47
unsigned int index
Definition: sha256.h:50