1 | /*
|
---|
2 | * sha.h
|
---|
3 | *
|
---|
4 | * Originally taken from the public domain SHA1 implementation
|
---|
5 | * written by by Steve Reid <steve@edmweb.com>
|
---|
6 | *
|
---|
7 | * Modified by Aaron D. Gifford <agifford@infowest.com>
|
---|
8 | *
|
---|
9 | * NO COPYRIGHT - THIS IS 100% IN THE PUBLIC DOMAIN
|
---|
10 | *
|
---|
11 | * The original unmodified version is available at:
|
---|
12 | * ftp://ftp.funet.fi/pub/crypt/hash/sha/sha1.c
|
---|
13 | *
|
---|
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS ``AS IS'' AND
|
---|
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
|
---|
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
24 | * SUCH DAMAGE.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef __SHA1_H__
|
---|
28 | #define __SHA1_H__
|
---|
29 |
|
---|
30 | #ifdef __cplusplus
|
---|
31 | extern "C" {
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Define this if your machine is LITTLE_ENDIAN, otherwise #undef it: */
|
---|
35 | #ifdef WORDS_BIGENDIAN
|
---|
36 | # undef LITTLE_ENDIAN
|
---|
37 | #else
|
---|
38 | # ifndef LITTLE_ENDIAN
|
---|
39 | # define LITTLE_ENDIAN
|
---|
40 | # endif
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | /* Make sure you define these types for your architecture: */
|
---|
44 | typedef unsigned int sha1_quadbyte; /* 4 byte type */
|
---|
45 | typedef unsigned char sha1_byte; /* single byte type */
|
---|
46 |
|
---|
47 | /*
|
---|
48 | * Be sure to get the above definitions right. For instance, on my
|
---|
49 | * x86 based FreeBSD box, I define LITTLE_ENDIAN and use the type
|
---|
50 | * "unsigned long" for the quadbyte. On FreeBSD on the Alpha, however,
|
---|
51 | * while I still use LITTLE_ENDIAN, I must define the quadbyte type
|
---|
52 | * as "unsigned int" instead.
|
---|
53 | */
|
---|
54 |
|
---|
55 | #define SHA1_BLOCK_LENGTH 64
|
---|
56 | #define SHA1_DIGEST_LENGTH 20
|
---|
57 |
|
---|
58 | /* The SHA1 structure: */
|
---|
59 | typedef struct _SHA_CTX {
|
---|
60 | sha1_quadbyte state[5];
|
---|
61 | sha1_quadbyte count[2];
|
---|
62 | sha1_byte buffer[SHA1_BLOCK_LENGTH];
|
---|
63 | } SHA_CTX;
|
---|
64 |
|
---|
65 | #ifndef NOPROTO
|
---|
66 | void SHA1_Init(SHA_CTX *context);
|
---|
67 | void SHA1_Update(SHA_CTX *context, sha1_byte *data, unsigned int len);
|
---|
68 | void SHA1_Final(sha1_byte digest[SHA1_DIGEST_LENGTH],
|
---|
69 | SHA_CTX* context);
|
---|
70 | #else
|
---|
71 | void SHA1_Init();
|
---|
72 | void SHA1_Update();
|
---|
73 | void SHA1_Final();
|
---|
74 | #endif
|
---|
75 |
|
---|
76 | #ifdef __cplusplus
|
---|
77 | }
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | #endif
|
---|