2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)sha.h 1.4 03/06/28 Copyright 1998,1999 Heiko Eissfeldt */
14 /*____________________________________________________________________________
16 // CD Index - The Internet CD Index
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
23 // This program is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 // GNU General Public License for more details.
28 // You should have received a copy of the GNU General Public License
29 // along with this program; if not, write to the Free Software
30 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 // $Id: sha.h,v 1.1.1.2 1999/04/29 00:53:34 marc Exp $
33 //____________________________________________________________________________
38 /* NIST Secure Hash Algorithm */
39 /* heavily modified by Uwe Hollerbach <uh@alumni.caltech edu> */
40 /* from Peter C. Gutmann's implementation as found in */
41 /* Applied Cryptography by Bruce Schneier */
43 /* This code is in the public domain */
45 /* Useful defines & typedefs */
47 typedef unsigned char BYTE; /* 8-bit quantity */
48 typedef unsigned long ULONG; /* 32-or-more-bit quantity */
50 #define SHA_BLOCKSIZE 64
51 #define SHA_DIGESTSIZE 20
54 ULONG digest[5]; /* message digest */
55 ULONG count_lo, count_hi; /* 64-bit bit count */
56 BYTE data[SHA_BLOCKSIZE]; /* SHA data buffer */
57 int local; /* unprocessed amount in data */
60 void sha_init(SHA_INFO *);
61 void sha_update(SHA_INFO *, BYTE *, int);
62 void sha_final(unsigned char [20], SHA_INFO *);
70 void sha_stream(unsigned char [20], SHA_INFO *, FILE *);
71 void sha_print(unsigned char [20]);
72 char *sha_version(void);
73 #endif /* SHA_FOR_C */
78 #ifdef WORDS_BIGENDIAN
79 # if SIZEOF_UNSIGNED_LONG_INT == 4
80 # define SHA_BYTE_ORDER 4321
82 # if SIZEOF_UNSIGNED_LONG_INT == 8
83 # define SHA_BYTE_ORDER 87654321
87 # if SIZEOF_UNSIGNED_LONG_INT == 4
88 # define SHA_BYTE_ORDER 1234
90 # if SIZEOF_UNSIGNED_LONG_INT == 8
91 # define SHA_BYTE_ORDER 12345678
98 #define SHA_BYTE_ORDER 1234