]> git.saurik.com Git - apple/security.git/blob - SecureTransport/privateInc/st_sha.h
Security-28.tar.gz
[apple/security.git] / SecureTransport / privateInc / st_sha.h
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
8 * using this file.
9 *
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
16 */
17
18
19 #ifndef SHA_H
20 #define SHA_H
21
22 /* NIST Secure Hash Algorithm */
23 /* heavily modified from Peter C. Gutmann's implementation */
24
25 /* Useful defines & typedefs */
26
27 /* Possibly an unreasonable assumption, but it works */
28 #ifdef WIN32
29 #define LITTLE_ENDIAN 1
30 #endif
31
32 typedef unsigned char BYTE;
33 typedef unsigned long LONG;
34
35 #define SHA_BLOCKSIZE 64
36 #define SHA_DIGESTSIZE 20
37
38 typedef struct {
39 LONG digest[5]; /* message digest */
40 LONG count_lo, count_hi; /* 64-bit bit count */
41 LONG data[16]; /* SHA data buffer */
42 } SHA_INFO;
43
44 void sha_init(SHA_INFO *);
45 void sha_update(SHA_INFO *, BYTE *, int);
46 void sha_final(SHA_INFO *);
47
48 void sha_stream(SHA_INFO *, FILE *);
49 void sha_print(SHA_INFO *);
50
51 #define USE_MODIFIED_SHA 1
52
53 #endif /* SHA_H */