00001
00002
00003
00004
00005 #ifndef _SHA1_H
00006 #define _SHA1_H
00007
00008 #include <limits.h>
00009
00010 #if UINT_MAX == 0xffffffff
00011 typedef unsigned int sha1_32t;
00012 #elif ULONG_MAX == 0xffffffff
00013 typedef unsigned long sha1_32t;
00014 #else
00015 #error Please define sha1_32t as an unsigned 32 bit type in sha2.h
00016 #endif
00017
00018 #if defined(__cplusplus)
00019 extern "C"
00020 {
00021 #endif
00022
00023 #define SHA1_BLOCK_SIZE 64
00024 #define SHA1_DIGEST_SIZE 20
00025 #define SHA2_GOOD 0
00026 #define SHA2_BAD 1
00027
00028 typedef struct
00029 { sha1_32t count[2];
00030 sha1_32t hash[5];
00031 sha1_32t wbuf[16];
00032 } sha1_ctx;
00033
00034 void sha1_compile(sha1_ctx ctx[1]);
00035
00036 void sha1_begin(sha1_ctx ctx[1]);
00037 void sha1_hash(const unsigned char data[], unsigned int len, sha1_ctx ctx[1]);
00038 void sha1_end(unsigned char hval[], sha1_ctx ctx[1]);
00039 void sha1(unsigned char hval[], const unsigned char data[], unsigned int len);
00040
00041 #if defined(__cplusplus)
00042 }
00043 #endif
00044
00045 #include "sha1.cpp"
00046
00047 #endif