(CLEANFILES): Add generated files: ftw.h search.h.
[coreutils.git] / lib / sha.h
blob2ee17f212b48d60d69eb9a88e7cc2b4e97086f72
1 /* sha.h - Declaration of functions and datatypes for SHA1 sum computing
2 library functions.
4 Copyright (C) 1999, Scott G. Miller
5 */
7 #ifndef _SHA_H
8 # define _SHA_H 1
10 # include <stdio.h>
11 # include "md5.h"
13 /* Structure to save state of computation between the single steps. */
14 struct sha_ctx
16 md5_uint32 A;
17 md5_uint32 B;
18 md5_uint32 C;
19 md5_uint32 D;
20 md5_uint32 E;
22 md5_uint32 total[2];
23 md5_uint32 buflen;
24 char buffer[128];
28 /* Starting with the result of former calls of this function (or the
29 initialization function update the context for the next LEN bytes
30 starting at BUFFER.
31 It is necessary that LEN is a multiple of 64!!! */
32 extern void sha_process_block __P ((const void *buffer, size_t len,
33 struct sha_ctx *ctx));
35 /* Starting with the result of former calls of this function (or the
36 initialization function update the context for the next LEN bytes
37 starting at BUFFER.
38 It is NOT required that LEN is a multiple of 64. */
39 extern void sha_process_bytes __P((const void *buffer, size_t len,
40 struct sha_ctx *ctx));
42 /* Initialize structure containing state of computation. */
43 extern void sha_init_ctx __P ((struct sha_ctx *ctx));
45 /* Process the remaining bytes in the buffer and put result from CTX
46 in first 16 bytes following RESBUF. The result is always in little
47 endian byte order, so that a byte-wise output yields to the wanted
48 ASCII representation of the message digest.
50 IMPORTANT: On some systems it is required that RESBUF is correctly
51 aligned for a 32 bits value. */
52 extern void *sha_finish_ctx __P ((struct sha_ctx *ctx, void *resbuf));
55 /* Put result from CTX in first 16 bytes following RESBUF. The result is
56 always in little endian byte order, so that a byte-wise output yields
57 to the wanted ASCII representation of the message digest.
59 IMPORTANT: On some systems it is required that RESBUF is correctly
60 aligned for a 32 bits value. */
61 extern void *sha_read_ctx __P ((const struct sha_ctx *ctx, void *resbuf));
64 /* Compute MD5 message digest for bytes read from STREAM. The
65 resulting message digest number will be written into the 16 bytes
66 beginning at RESBLOCK. */
67 extern int sha_stream __P ((FILE *stream, void *resblock));
69 /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
70 result is always in little endian byte order, so that a byte-wise
71 output yields to the wanted ASCII representation of the message
72 digest. */
73 extern void *sha_buffer __P ((const char *buffer, size_t len, void *resblock));
75 #endif