00001 /* 00002 * sha1.h 00003 * 00004 * Description: 00005 * This is the header file for code which implements the Secure 00006 * Hashing Algorithm 1 as defined in FIPS PUB 180-1 published 00007 * April 17, 1995. 00008 * 00009 * Many of the variable names in this code, especially the 00010 * single character names, were used because those were the names 00011 * used in the publication. 00012 * 00013 * Please read the file sha1.c for more information. 00014 * 00015 */ 00016 00017 #ifndef _SHA1_H_ 00018 #define _SHA1_H_ 00019 00020 /* FIXME: begin: lat changed from: #include <stdint.h> */ 00021 #ifdef _MSC_VER 00022 typedef unsigned __int32 uint32_t; 00023 typedef unsigned __int8 uint8_t; 00024 typedef int int_least16_t; 00025 #else 00026 # include <inttypes.h> 00027 #endif 00028 /* FIXME: end */ 00029 00030 /* 00031 * If you do not have the ISO standard stdint.h header file, then you 00032 * must typdef the following: 00033 * name meaning 00034 * uint32_t unsigned 32 bit integer 00035 * uint8_t unsigned 8 bit integer (i.e., unsigned char) 00036 * int_least16_t integer of >= 16 bits 00037 * 00038 */ 00039 00040 #ifndef _SHA_enum_ 00041 #define _SHA_enum_ 00042 enum 00043 { 00044 shaSuccess = 0, 00045 shaNull, /* Null pointer parameter */ 00046 shaInputTooLong, /* input data too long */ 00047 shaStateError /* called Input after Result */ 00048 }; 00049 #endif 00050 #define SHA1HashSize 20 00051 00052 /* 00053 * This structure will hold context information for the SHA-1 00054 * hashing operation 00055 */ 00056 typedef struct SHA1Context 00057 { 00058 uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */ 00059 00060 uint32_t Length_Low; /* Message length in bits */ 00061 uint32_t Length_High; /* Message length in bits */ 00062 00063 /* Index into message block array */ 00064 int_least16_t Message_Block_Index; 00065 uint8_t Message_Block[64]; /* 512-bit message blocks */ 00066 00067 int Computed; /* Is the digest computed? */ 00068 int Corrupted; /* Is the message digest corrupted? */ 00069 } SHA1Context; 00070 00071 /* 00072 * Function Prototypes 00073 */ 00074 00075 int SHA1Reset( SHA1Context *); 00076 int SHA1Input( SHA1Context *, 00077 const uint8_t *, 00078 unsigned int); 00079 int SHA1Result( SHA1Context *, 00080 uint8_t Message_Digest[SHA1HashSize]); 00081 00082 #endif