00001
00027 #ifndef POLARSSL_SHA256_H
00028 #define POLARSSL_SHA256_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_SHA256_FILE_IO_ERROR -0x0078
00043 #if !defined(POLARSSL_SHA256_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[8];
00058 unsigned char buffer[64];
00060 unsigned char ipad[64];
00061 unsigned char opad[64];
00062 int is224;
00063 }
00064 sha256_context;
00065
00072 void sha256_starts( sha256_context *ctx, int is224 );
00073
00081 void sha256_update( sha256_context *ctx, const unsigned char *input, size_t ilen );
00082
00089 void sha256_finish( sha256_context *ctx, unsigned char output[32] );
00090
00091
00092 void sha256_process( sha256_context *ctx, const unsigned char data[64] );
00093
00094 #ifdef __cplusplus
00095 }
00096 #endif
00097
00098 #else
00099 #include "sha256_alt.h"
00100 #endif
00101
00102 #ifdef __cplusplus
00103 extern "C" {
00104 #endif
00105
00114 void sha256( const unsigned char *input, size_t ilen,
00115 unsigned char output[32], int is224 );
00116
00126 int sha256_file( const char *path, unsigned char output[32], int is224 );
00127
00136 void sha256_hmac_starts( sha256_context *ctx, const unsigned char *key,
00137 size_t keylen, int is224 );
00138
00146 void sha256_hmac_update( sha256_context *ctx, const unsigned char *input, size_t ilen );
00147
00154 void sha256_hmac_finish( sha256_context *ctx, unsigned char output[32] );
00155
00161 void sha256_hmac_reset( sha256_context *ctx );
00162
00173 void sha256_hmac( const unsigned char *key, size_t keylen,
00174 const unsigned char *input, size_t ilen,
00175 unsigned char output[32], int is224 );
00176
00182 int sha256_self_test( int verbose );
00183
00184 #ifdef __cplusplus
00185 }
00186 #endif
00187
00188 #endif