2 * shs - old Secure Hash Standard
4 **************************************************************************
5 * This version implements the old Secure Hash Algorithm specified by *
6 * (FIPS Pub 180). This version is kept for backward compatibility with *
7 * shs version 2.10.1. See the shs utility for the new standard. *
8 **************************************************************************
10 * Written 2 September 1992, Peter C. Gutmann.
12 * This file was Modified by:
15 * http://www.isthe.com/chongo/
17 * chongo <was here> /\../\
19 * This code has been placed in the public domain. Please do not
20 * copyright this code.
22 * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
23 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
24 * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT
25 * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
26 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
27 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
28 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
29 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
35 * This file is not covered under version 2.1 of the GNU LGPL.
39 #if !defined(__SHS_H__)
43 /* SHS_CHUNKSIZE must be a power of 2 - fixed value defined by the algorithm */
44 #define SHS_CHUNKSIZE (1<<6)
45 #define SHS_CHUNKWORDS (SHS_CHUNKSIZE/sizeof(USB32))
47 /* SHS_DIGESTSIZE is a the length of the digest as defined by the algorithm */
48 #define SHS_DIGESTSIZE (20)
49 #define SHS_DIGESTWORDS (SHS_DIGESTSIZE/sizeof(USB32))
51 /* SHS_LOW - where low 32 bits of 64 bit count is stored during final */
54 /* SHS_HIGH - where high 32 bits of 64 bit count is stored during final */
58 * The structure for storing SHS info
60 * We will assume that bit count is a multiple of 8.
63 USB32 digest[SHS_DIGESTWORDS]; /* message digest */
64 USB32 countLo; /* 64 bit count: bits 3-34 */
65 USB32 countHi; /* 64 bit count: bits 35-63 */
66 USB32 datalen; /* length of data in data */
67 USB32 data[SHS_CHUNKWORDS]; /* SHS chunk buffer */
71 * SHSCOUNT(SHS_INFO*, USB32) - update the 64 bit count in an SHS_INFO
73 * We will count bytes and convert to bit count during the final
74 * transform. This assumes that the count is < 2^32.
76 #define SHSCOUNT(shsinfo, count) { \
78 tmp_countLo = (shsinfo)->countLo; \
79 if (((shsinfo)->countLo += (count)) < tmp_countLo) { \
80 (shsinfo)->countHi++; \
85 #endif /* !__SHS_H__ */