2 * sha1 - new NIST Secure Hash Standard-1 (SHA1)
4 * Written 2 September 1992, Peter C. Gutmann.
6 * This file and been extensively modified by:
9 * http://www.isthe.com/chongo/
11 * chongo <was here> /\../\
13 * This code has been placed in the public domain. Please do not
14 * copyright this code.
16 * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
17 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
18 * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT
19 * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
21 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
22 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
23 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * @(#) $Revision: 30.3 $
26 * @(#) $Id: sha1.h,v 30.3 2007/07/05 17:37:41 chongo Exp $
27 * @(#) $Source: /usr/local/src/bin/calc/RCS/sha1.h,v $
29 * This file is not covered under version 2.1 of the GNU LGPL.
33 #if !defined(__SHA1_H__)
37 /* SHA1_CHUNKSIZE must be a power of 2 - fixed value defined by the algorithm */
38 #define SHA1_CHUNKSIZE (1<<6)
39 #define SHA1_CHUNKWORDS (SHA1_CHUNKSIZE/sizeof(USB32))
41 /* SHA1_DIGESTSIZE is a the length of the digest as defined by the algorithm */
42 #define SHA1_DIGESTSIZE (20)
43 #define SHA1_DIGESTWORDS (SHA1_DIGESTSIZE/sizeof(USB32))
45 /* SHA1_LOW - where low 32 bits of 64 bit count is stored during final */
48 /* SHA1_HIGH - where high 32 bits of 64 bit count is stored during final */
52 * The structure for storing SHA1 info
54 * We will assume that bit count is a multiple of 8.
57 USB32 digest
[SHA1_DIGESTWORDS
]; /* message digest */
58 USB32 countLo
; /* 64 bit count: bits 3-34 */
59 USB32 countHi
; /* 64 bit count: bits 35-63 */
60 USB32 datalen
; /* length of data in data */
61 USB32 data
[SHA1_CHUNKWORDS
]; /* SHA1 chunk buffer */
65 * SHA1COUNT(SHA1_INFO*, USB32) - update the 64 bit count in an SHA1_INFO
67 * We will count bytes and convert to bit count during the final
70 #define SHA1COUNT(sha1info, count) { \
72 tmp_countLo = (sha1info)->countLo; \
73 if (((sha1info)->countLo += (count)) < tmp_countLo) { \
74 (sha1info)->countHi++; \
79 #endif /* !__SHA1_H__ */