00001
00027 #ifndef POLARSSL_SHA1_H
00028 #define POLARSSL_SHA1_H
00029
00030 #include "config.h"
00031
00032 #include <string.h>
00033
00034 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
00035 #include <basetsd.h>
00036 typedef UINT32 uint32_t;
00037 #else
00038 #include <inttypes.h>
00039 #endif
00040
00041 #define POLARSSL_ERR_SHA1_FILE_IO_ERROR -0x0076
00043 #if !defined(POLARSSL_SHA1_ALT)
00044
00045
00046
00047 #ifdef __cplusplus
00048 extern "C" {
00049 #endif
00050
00054 typedef struct
00055 {
00056 uint32_t total[2];
00057 uint32_t state[5];
00058 unsigned char buffer[64];
00060 unsigned char ipad[64];
00061 unsigned char opad[64];
00062 }
00063 sha1_context;
00064
00070 void sha1_starts( sha1_context *ctx );
00071
00079 void sha1_update( sha1_context *ctx, const unsigned char *input, size_t ilen );
00080
00087 void sha1_finish( sha1_context *ctx, unsigned char output[20] );
00088
00089
00090 void sha1_process( sha1_context *ctx, const unsigned char data[64] );
00091
00092 #ifdef __cplusplus
00093 }
00094 #endif
00095
00096 #else
00097 #include "sha1_alt.h"
00098 #endif
00099
00100 #ifdef __cplusplus
00101 extern "C" {
00102 #endif
00103
00111 void sha1( const unsigned char *input, size_t ilen, unsigned char output[20] );
00112
00121 int sha1_file( const char *path, unsigned char output[20] );
00122
00130 void sha1_hmac_starts( sha1_context *ctx, const unsigned char *key, size_t keylen );
00131
00139 void sha1_hmac_update( sha1_context *ctx, const unsigned char *input, size_t ilen );
00140
00147 void sha1_hmac_finish( sha1_context *ctx, unsigned char output[20] );
00148
00154 void sha1_hmac_reset( sha1_context *ctx );
00155
00165 void sha1_hmac( const unsigned char *key, size_t keylen,
00166 const unsigned char *input, size_t ilen,
00167 unsigned char output[20] );
00168
00174 int sha1_self_test( int verbose );
00175
00176 #ifdef __cplusplus
00177 }
00178 #endif
00179
00180 #endif