00001
00027 #ifndef POLARSSL_SHA512_H
00028 #define POLARSSL_SHA512_H
00029
00030 #include "config.h"
00031
00032 #include <string.h>
00033
00034 #if defined(_MSC_VER) || defined(__WATCOMC__)
00035 #define UL64(x) x##ui64
00036 typedef unsigned __int64 uint64_t;
00037 #else
00038 #include <inttypes.h>
00039 #define UL64(x) x##ULL
00040 #endif
00041
00042 #define POLARSSL_ERR_SHA512_FILE_IO_ERROR -0x007A
00044 #if !defined(POLARSSL_SHA512_ALT)
00045
00046
00047
00048 #ifdef __cplusplus
00049 extern "C" {
00050 #endif
00051
00055 typedef struct
00056 {
00057 uint64_t total[2];
00058 uint64_t state[8];
00059 unsigned char buffer[128];
00061 unsigned char ipad[128];
00062 unsigned char opad[128];
00063 int is384;
00064 }
00065 sha512_context;
00066
00073 void sha512_starts( sha512_context *ctx, int is384 );
00074
00082 void sha512_update( sha512_context *ctx, const unsigned char *input, size_t ilen );
00083
00090 void sha512_finish( sha512_context *ctx, unsigned char output[64] );
00091
00092 #ifdef __cplusplus
00093 }
00094 #endif
00095
00096 #else
00097 #include "sha512_alt.h"
00098 #endif
00099
00100 #ifdef __cplusplus
00101 extern "C" {
00102 #endif
00103
00112 void sha512( const unsigned char *input, size_t ilen,
00113 unsigned char output[64], int is384 );
00114
00124 int sha512_file( const char *path, unsigned char output[64], int is384 );
00125
00134 void sha512_hmac_starts( sha512_context *ctx, const unsigned char *key,
00135 size_t keylen, int is384 );
00136
00144 void sha512_hmac_update( sha512_context *ctx, const unsigned char *input, size_t ilen );
00145
00152 void sha512_hmac_finish( sha512_context *ctx, unsigned char output[64] );
00153
00159 void sha512_hmac_reset( sha512_context *ctx );
00160
00171 void sha512_hmac( const unsigned char *key, size_t keylen,
00172 const unsigned char *input, size_t ilen,
00173 unsigned char output[64], int is384 );
00174
00180 int sha512_self_test( int verbose );
00181
00182
00183 void sha512_process( sha512_context *ctx, const unsigned char data[128] );
00184
00185 #ifdef __cplusplus
00186 }
00187 #endif
00188
00189 #endif