Fixed compilation issues
[distributed.git] / src / gnulib / sha1.h
blob1a2d19cbeb23c5387077cfab04b6ade978a6cbd5
1 /* Declarations of functions and data types used for SHA1 sum
2 library functions.
3 Copyright (C) 2000, 2001, 2003, 2005, 2006, 2008
4 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 #ifndef SHA1_H
21 # define SHA1_H 1
23 # include <stdio.h>
24 # include <stdint.h>
26 #define SHA1_DIGEST_SIZE 20
28 /* Structure to save state of computation between the single steps. */
29 struct sha1_ctx
31 uint32_t A;
32 uint32_t B;
33 uint32_t C;
34 uint32_t D;
35 uint32_t E;
37 uint32_t total[2];
38 uint32_t buflen;
39 uint32_t buffer[32];
43 /* Initialize structure containing state of computation. */
44 extern void sha1_init_ctx (struct sha1_ctx *ctx);
46 /* Starting with the result of former calls of this function (or the
47 initialization function update the context for the next LEN bytes
48 starting at BUFFER.
49 It is necessary that LEN is a multiple of 64!!! */
50 extern void sha1_process_block (const void *buffer, size_t len,
51 struct sha1_ctx *ctx);
53 /* Starting with the result of former calls of this function (or the
54 initialization function update the context for the next LEN bytes
55 starting at BUFFER.
56 It is NOT required that LEN is a multiple of 64. */
57 extern void sha1_process_bytes (const void *buffer, size_t len,
58 struct sha1_ctx *ctx);
60 /* Process the remaining bytes in the buffer and put result from CTX
61 in first 20 bytes following RESBUF. The result is always in little
62 endian byte order, so that a byte-wise output yields to the wanted
63 ASCII representation of the message digest. */
64 extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
67 /* Put result from CTX in first 20 bytes following RESBUF. The result is
68 always in little endian byte order, so that a byte-wise output yields
69 to the wanted ASCII representation of the message digest. */
70 extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
73 /* Compute SHA1 message digest for bytes read from STREAM. The
74 resulting message digest number will be written into the 20 bytes
75 beginning at RESBLOCK. */
76 extern int sha1_stream (FILE *stream, void *resblock);
78 /* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
79 result is always in little endian byte order, so that a byte-wise
80 output yields to the wanted ASCII representation of the message
81 digest. */
82 extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);
84 #endif