pspsdk-1.0+beta2
sha1.h
Go to the documentation of this file.
1 /*
2  ---------------------------------------------------------------------------
3  Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved.
4 
5  LICENSE TERMS
6 
7  The free distribution and use of this software in both source and binary
8  form is allowed (with or without changes) provided that:
9 
10  1. distributions of this source code include the above copyright
11  notice, this list of conditions and the following disclaimer;
12 
13  2. distributions in binary form include the above copyright
14  notice, this list of conditions and the following disclaimer
15  in the documentation and/or other associated materials;
16 
17  3. the copyright holder's name is not used to endorse products
18  built using this software without specific written permission.
19 
20  ALTERNATIVELY, provided that this notice is retained in full, this product
21  may be distributed under the terms of the GNU General Public License (GPL),
22  in which case the provisions of the GPL apply INSTEAD OF those given above.
23 
24  DISCLAIMER
25 
26  This software is provided 'as is' with no explicit or implied warranties
27  in respect of its properties, including, but not limited to, correctness
28  and/or fitness for purpose.
29  ---------------------------------------------------------------------------
30  Issue Date: 26/08/2003
31 */
32 
33 #ifndef _SHA1_H
34 #define _SHA1_H
35 
36 #include <limits.h>
37 
38 #define SHA1_BLOCK_SIZE 64
39 #define SHA1_DIGEST_SIZE 20
40 
41 #if defined(__cplusplus)
42 extern "C"
43 {
44 #endif
45 
46 /* define an unsigned 32-bit type */
47 
48 #if defined(_MSC_VER)
49  typedef unsigned long sha1_32t;
50 #elif defined(ULONG_MAX) && ULONG_MAX == 0xfffffffful
51  typedef unsigned long sha1_32t;
52 #elif defined(UINT_MAX) && UINT_MAX == 0xffffffff
53  typedef unsigned int sha1_32t;
54 #else
55 # error Please define sha1_32t as an unsigned 32 bit type in sha1.h
56 #endif
57 
58 /* type to hold the SHA256 context */
59 
60 typedef struct
61 { sha1_32t count[2];
62  sha1_32t hash[5];
63  sha1_32t wbuf[16];
64 } sha1_ctx;
65 
66 /* Note that these prototypes are the same for both bit and */
67 /* byte oriented implementations. However the length fields */
68 /* are in bytes or bits as appropriate for the version used */
69 /* and bit sequences are input as arrays of bytes in which */
70 /* bit sequences run from the most to the least significant */
71 /* end of each byte */
72 
73 void sha1_compile(sha1_ctx ctx[1]);
74 
75 void sha1_begin(sha1_ctx ctx[1]);
76 void sha1_hash(const unsigned char data[], unsigned long len, sha1_ctx ctx[1]);
77 void sha1_end(unsigned char hval[], sha1_ctx ctx[1]);
78 void sha1(unsigned char hval[], const unsigned char data[], unsigned long len);
79 
80 #if defined(__cplusplus)
81 }
82 #endif
83 
84 #endif