PolarSSL v1.3.8
sha256.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_SHA256_H
28 #define POLARSSL_SHA256_H
29 
30 #if !defined(POLARSSL_CONFIG_FILE)
31 #include "config.h"
32 #else
33 #include POLARSSL_CONFIG_FILE
34 #endif
35 
36 #include <string.h>
37 
38 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
39 #include <basetsd.h>
40 typedef UINT32 uint32_t;
41 #else
42 #include <inttypes.h>
43 #endif
44 
45 #define POLARSSL_ERR_SHA256_FILE_IO_ERROR -0x0078
47 #if !defined(POLARSSL_SHA256_ALT)
48 // Regular implementation
49 //
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
58 typedef struct
59 {
60  uint32_t total[2];
61  uint32_t state[8];
62  unsigned char buffer[64];
64  unsigned char ipad[64];
65  unsigned char opad[64];
66  int is224;
67 }
69 
75 void sha256_init( sha256_context *ctx );
76 
82 void sha256_free( sha256_context *ctx );
83 
90 void sha256_starts( sha256_context *ctx, int is224 );
91 
99 void sha256_update( sha256_context *ctx, const unsigned char *input,
100  size_t ilen );
101 
108 void sha256_finish( sha256_context *ctx, unsigned char output[32] );
109 
110 /* Internal use */
111 void sha256_process( sha256_context *ctx, const unsigned char data[64] );
112 
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #else /* POLARSSL_SHA256_ALT */
118 #include "sha256_alt.h"
119 #endif /* POLARSSL_SHA256_ALT */
120 
121 #ifdef __cplusplus
122 extern "C" {
123 #endif
124 
133 void sha256( const unsigned char *input, size_t ilen,
134  unsigned char output[32], int is224 );
135 
145 int sha256_file( const char *path, unsigned char output[32], int is224 );
146 
155 void sha256_hmac_starts( sha256_context *ctx, const unsigned char *key,
156  size_t keylen, int is224 );
157 
165 void sha256_hmac_update( sha256_context *ctx, const unsigned char *input,
166  size_t ilen );
167 
174 void sha256_hmac_finish( sha256_context *ctx, unsigned char output[32] );
175 
181 void sha256_hmac_reset( sha256_context *ctx );
182 
193 void sha256_hmac( const unsigned char *key, size_t keylen,
194  const unsigned char *input, size_t ilen,
195  unsigned char output[32], int is224 );
196 
202 int sha256_self_test( int verbose );
203 
204 #ifdef __cplusplus
205 }
206 #endif
207 
208 #endif /* sha256.h */