forked from besser82/libxcrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alg-sha256.h
46 lines (36 loc) · 1.73 KB
/
alg-sha256.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Declaration of functions and data types used for SHA256 sum computing
library functions.
Copyright (C) 2007-2017 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _CRYPT_ALG_SHA256_H
#define _CRYPT_ALG_SHA256_H 1
/* Structure to save state of computation between the single steps. */
struct sha256_ctx
{
uint32_t H[8];
uint64_t total;
uint32_t buflen;
unsigned char buffer[128];
};
/* Initialize structure containing state of computation.
(FIPS 180-2: 5.3.2) */
extern void sha256_init_ctx (struct sha256_ctx *ctx);
/* Starting with the result of former calls of this function (or the
initialization function) update the context for the next LEN bytes
starting at BUFFER. LEN does not need to be a multiple of 64. */
extern void sha256_process_bytes (const void *buffer, size_t len,
struct sha256_ctx *ctx);
/* Process the remaining bytes in the buffer and write the finalized
hash to RESBUF, which should point to 32 bytes of storage. */
extern void *sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf);
#endif /* alg-sha256.h */