pkg_src_list_push: remove unused function
[oweals/opkg-lede.git] / libopkg / sha256.h
1 /* Declarations of functions and data types used for SHA256 and SHA224 sum
2    library functions.
3    Copyright (C) 2005, 2006 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify it
6    under the terms of the GNU General Public License as published by the
7    Free Software Foundation; either version 2, or (at your option) any
8    later version.
9
10    This program 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
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #ifndef SHA256_H
20 #define SHA256_H 1
21
22 #include <stdio.h>
23 #include <stdint.h>
24
25 /* Structure to save state of computation between the single steps.  */
26 struct sha256_ctx {
27         uint32_t state[8];
28
29         uint32_t total[2];
30         uint32_t buflen;
31         uint32_t buffer[32];
32 };
33
34 /* Initialize structure containing state of computation. */
35 extern void sha256_init_ctx(struct sha256_ctx *ctx);
36 extern void sha224_init_ctx(struct sha256_ctx *ctx);
37
38 /* Starting with the result of former calls of this function (or the
39    initialization function update the context for the next LEN bytes
40    starting at BUFFER.
41    It is necessary that LEN is a multiple of 64!!! */
42 extern void sha256_process_block(const void *buffer, size_t len,
43                                  struct sha256_ctx *ctx);
44
45 /* Starting with the result of former calls of this function (or the
46    initialization function update the context for the next LEN bytes
47    starting at BUFFER.
48    It is NOT required that LEN is a multiple of 64.  */
49 extern void sha256_process_bytes(const void *buffer, size_t len,
50                                  struct sha256_ctx *ctx);
51
52 /* Process the remaining bytes in the buffer and put result from CTX
53    in first 32 (28) bytes following RESBUF.  The result is always in little
54    endian byte order, so that a byte-wise output yields to the wanted
55    ASCII representation of the message digest.
56
57    IMPORTANT: On some systems it is required that RESBUF be correctly
58    aligned for a 32 bits value.  */
59 extern void *sha256_finish_ctx(struct sha256_ctx *ctx, void *resbuf);
60 extern void *sha224_finish_ctx(struct sha256_ctx *ctx, void *resbuf);
61
62 /* Put result from CTX in first 32 (28) bytes following RESBUF.  The result is
63    always in little endian byte order, so that a byte-wise output yields
64    to the wanted ASCII representation of the message digest.
65
66    IMPORTANT: On some systems it is required that RESBUF is correctly
67    aligned for a 32 bits value.  */
68 extern void *sha256_read_ctx(const struct sha256_ctx *ctx, void *resbuf);
69 extern void *sha224_read_ctx(const struct sha256_ctx *ctx, void *resbuf);
70
71 /* Compute SHA256 (SHA224) message digest for bytes read from STREAM.  The
72    resulting message digest number will be written into the 32 (28) bytes
73    beginning at RESBLOCK.  */
74 extern int sha256_stream(FILE * stream, void *resblock);
75 extern int sha224_stream(FILE * stream, void *resblock);
76
77 /* Compute SHA256 (SHA224) message digest for LEN bytes beginning at BUFFER.  The
78    result is always in little endian byte order, so that a byte-wise
79    output yields to the wanted ASCII representation of the message
80    digest.  */
81 extern void *sha256_buffer(const char *buffer, size_t len, void *resblock);
82 extern void *sha224_buffer(const char *buffer, size_t len, void *resblock);
83
84 #endif