modified: makefile
[GalaxyCodeBases.git] / c_cpp / etc / md5_sha / shs.h
blobec50e3df5e8c4daba2dc6fa1b62872e5a2ac3e86
1 /*
2 * shs - old Secure Hash Standard
4 * @(#) $Revision: 13.6 $
5 * @(#) $Id: shs.h,v 13.6 2010/10/12 21:10:17 chongo Exp $
6 * @(#) $Source: /usr/local/src/cmd/hash/RCS/shs.h,v $
8 **************************************************************************
9 * This version implements the old Secure Hash Algorithm specified by *
10 * (FIPS Pub 180). This version is kept for backward compatibility with *
11 * shs version 2.10.1. See the shs utility for the new standard. *
12 **************************************************************************
14 * Written 2 September 1992, Peter C. Gutmann.
16 * This file was written by Landon Curt Noll.
18 * This code has been placed in the public domain. Please do not
19 * copyright this code.
21 * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
22 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
23 * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT
24 * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
25 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
26 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
27 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
28 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30 * chongo (was here) /\oo/\
31 * http://www.isthe.com/chongo/index.html
33 * Share and enjoy! :-)
35 * See shsdrvr.c for version and modification history.
38 #if !defined(SHS_H)
39 #define SHS_H
41 #include <sys/types.h>
42 #include <sys/stat.h>
45 * our version
47 #define SHS_VERSION "$Revision: 13.6 $"
50 * These macros are in common with shs.h, shs.h and md5.h. We use
51 * HASH_MACROS to gaurd against multiple inclusion by external progs
52 * that may want to use multiple hash codes in one module.
54 #if !defined(HASH_MACROS)
55 #define HASH_MACROS
58 * Useful defines/typedefs
60 typedef u_int8_t BYTE; /* must be 1 byte unsigned value */
61 typedef u_int16_t UINT; /* must be 2 byte unsigned value */
62 typedef u_int32_t ULONG; /* must be 4 byte unsigned value */
63 typedef u_int64_t ULLONG; /* must be 8 byte unsigned value */
65 #endif /* HASH_MACROS */
67 /* SHS_CHUNKSIZE must be a power of 2 - fixed value defined by the algorithm */
68 #define SHS_CHUNKSIZE (1<<6)
69 #define SHS_CHUNKMASK (SHS_CHUNKSIZE-1)
70 #define SHS_CHUNKWORDS (SHS_CHUNKSIZE/sizeof(ULONG))
72 /* SHS_DIGESTSIZE is a the length of the digest as defined by the algorithm */
73 #define SHS_DIGESTSIZE (20)
74 #define SHS_DIGESTWORDS (SHS_DIGESTSIZE/sizeof(ULONG))
76 /* SHS_HIGH - the ULONG where the 64 bit count of bits processed is stored */
77 #define SHS_HIGH (SHS_CHUNKWORDS-2)
79 /* SHS_BLOCKSIZE is how large a chunk multiStream processes at a time */
80 #define SHS_BLOCKSIZE (SHS_CHUNKSIZE<<8)
82 /* SHS_READSIZE must be a multiple of SHS_BLOCKSIZE */
83 #define SHS_READSIZE (SHS_BLOCKSIZE<<2)
84 #define SHS_READWORDS (SHS_READSIZE/sizeof(ULONG))
86 /* maximum part of pre_file used */
87 #define SHS_MAX_PRE_FILE 32768
90 * SHS_ROUNDUP(x,y) - round x up to the next multiple of y
92 #define SHS_ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y))
95 * The structure for storing SHS info
97 * We will assume that bit count is a multiple of 8.
99 typedef struct {
100 ULONG digest[SHS_DIGESTWORDS]; /* message digest */
101 ULLONG octets; /* count of octets processed */
102 ULONG datalen; /* length of data in data */
103 ULONG data[SHS_CHUNKWORDS]; /* SHS chunk buffer */
104 } SHS_INFO;
107 * elements of the stat structure that we will process
109 struct shs_stat {
110 dev_t stat_dev;
111 ino_t stat_ino;
112 mode_t stat_mode;
113 nlink_t stat_nlink;
114 uid_t stat_uid;
115 gid_t stat_gid;
116 off_t stat_size;
117 time_t stat_mtime;
118 time_t stat_ctime;
121 /* shs.c */
122 void shsInit(SHS_INFO*);
123 void shsTransform(ULONG *digest, ULONG *W);
124 void shsUpdate(SHS_INFO*, BYTE*, ULONG);
125 void shsfullUpdate(SHS_INFO*, BYTE*, ULONG);
126 void shsFinal(SHS_INFO*);
127 extern char *shs_what;
130 * Some external programs use the functions found in shs.c and shsio.c.
131 * These routines define SHS_IO so that such external programs will not
132 * pick up the following declarations.
135 #if !defined(SHS_IO)
137 /* shsio.c */
138 void shsStream(BYTE*, UINT, FILE*, SHS_INFO*);
139 void shsFile(BYTE*, UINT, char*, int, SHS_INFO*);
140 extern ULONG shs_zero[];
142 /* shsdual.c */
143 void multiMain(int, char**, BYTE*, UINT, char*, int, UINT);
144 void multiTest(void);
145 extern char *shsdual_what;
147 /* shsdrvr.c */
148 void shsPrint(int, int, SHS_INFO*);
149 extern int c_flag;
150 extern int i_flag;
151 extern int q_flag;
152 extern int dot_zero;
153 #endif /* SHS_IO */
154 extern int debug;
155 extern char *program;
157 #endif /* SHS_H */