1 /* Declarations of functions and data types used for SHA256 and SHA224 sum
3 Copyright (C) 2005, 2006 Free Software Foundation, Inc.
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
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.
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. */
25 /* Structure to save state of computation between the single steps. */
36 /* Initialize structure containing state of computation. */
37 extern void sha256_init_ctx (struct sha256_ctx
*ctx
);
38 extern void sha224_init_ctx (struct sha256_ctx
*ctx
);
40 /* Starting with the result of former calls of this function (or the
41 initialization function update the context for the next LEN bytes
43 It is necessary that LEN is a multiple of 64!!! */
44 extern void sha256_process_block (const void *buffer
, size_t len
,
45 struct sha256_ctx
*ctx
);
47 /* Starting with the result of former calls of this function (or the
48 initialization function update the context for the next LEN bytes
50 It is NOT required that LEN is a multiple of 64. */
51 extern void sha256_process_bytes (const void *buffer
, size_t len
,
52 struct sha256_ctx
*ctx
);
54 /* Process the remaining bytes in the buffer and put result from CTX
55 in first 32 (28) bytes following RESBUF. The result is always in little
56 endian byte order, so that a byte-wise output yields to the wanted
57 ASCII representation of the message digest.
59 IMPORTANT: On some systems it is required that RESBUF be correctly
60 aligned for a 32 bits value. */
61 extern void *sha256_finish_ctx (struct sha256_ctx
*ctx
, void *resbuf
);
62 extern void *sha224_finish_ctx (struct sha256_ctx
*ctx
, void *resbuf
);
65 /* Put result from CTX in first 32 (28) bytes following RESBUF. The result is
66 always in little endian byte order, so that a byte-wise output yields
67 to the wanted ASCII representation of the message digest.
69 IMPORTANT: On some systems it is required that RESBUF is correctly
70 aligned for a 32 bits value. */
71 extern void *sha256_read_ctx (const struct sha256_ctx
*ctx
, void *resbuf
);
72 extern void *sha224_read_ctx (const struct sha256_ctx
*ctx
, void *resbuf
);
75 /* Compute SHA256 (SHA224) message digest for bytes read from STREAM. The
76 resulting message digest number will be written into the 32 (28) bytes
77 beginning at RESBLOCK. */
78 extern int sha256_stream (FILE *stream
, void *resblock
);
79 extern int sha224_stream (FILE *stream
, void *resblock
);
81 /* Compute SHA256 (SHA224) message digest for LEN bytes beginning at BUFFER. The
82 result is always in little endian byte order, so that a byte-wise
83 output yields to the wanted ASCII representation of the message
85 extern void *sha256_buffer (const char *buffer
, size_t len
, void *resblock
);
86 extern void *sha224_buffer (const char *buffer
, size_t len
, void *resblock
);