PolarSSL v1.2.7
sha2.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_SHA2_H
28 #define POLARSSL_SHA2_H
29 
30 #include <string.h>
31 
32 #ifdef _MSC_VER
33 #include <basetsd.h>
34 typedef UINT32 uint32_t;
35 #else
36 #include <inttypes.h>
37 #endif
38 
39 #define POLARSSL_ERR_SHA2_FILE_IO_ERROR -0x0078
44 typedef struct
45 {
46  uint32_t total[2];
47  uint32_t state[8];
48  unsigned char buffer[64];
50  unsigned char ipad[64];
51  unsigned char opad[64];
52  int is224;
53 }
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
66 void sha2_starts( sha2_context *ctx, int is224 );
67 
75 void sha2_update( sha2_context *ctx, const unsigned char *input, size_t ilen );
76 
83 void sha2_finish( sha2_context *ctx, unsigned char output[32] );
84 
93 void sha2( const unsigned char *input, size_t ilen,
94  unsigned char output[32], int is224 );
95 
105 int sha2_file( const char *path, unsigned char output[32], int is224 );
106 
115 void sha2_hmac_starts( sha2_context *ctx, const unsigned char *key, size_t keylen,
116  int is224 );
117 
125 void sha2_hmac_update( sha2_context *ctx, const unsigned char *input, size_t ilen );
126 
133 void sha2_hmac_finish( sha2_context *ctx, unsigned char output[32] );
134 
140 void sha2_hmac_reset( sha2_context *ctx );
141 
152 void sha2_hmac( const unsigned char *key, size_t keylen,
153  const unsigned char *input, size_t ilen,
154  unsigned char output[32], int is224 );
155 
161 int sha2_self_test( int verbose );
162 
163 /* Internal use */
164 void sha2_process( sha2_context *ctx, const unsigned char data[64] );
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* sha2.h */