PolarSSL v1.2.11
sha2.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_SHA2_H
28 #define POLARSSL_SHA2_H
29 
30 #include "config.h"
31 
32 #include <string.h>
33 
34 #ifdef _MSC_VER
35 #include <basetsd.h>
36 typedef UINT32 uint32_t;
37 #else
38 #include <inttypes.h>
39 #endif
40 
41 #define POLARSSL_ERR_SHA2_FILE_IO_ERROR -0x0078
43 #if !defined(POLARSSL_SHA2_ALT)
44 // Regular implementation
45 //
46 
50 typedef struct
51 {
52  uint32_t total[2];
53  uint32_t state[8];
54  unsigned char buffer[64];
56  unsigned char ipad[64];
57  unsigned char opad[64];
58  int is224;
59 }
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
72 void sha2_starts( sha2_context *ctx, int is224 );
73 
81 void sha2_update( sha2_context *ctx, const unsigned char *input, size_t ilen );
82 
89 void sha2_finish( sha2_context *ctx, unsigned char output[32] );
90 
91 /* Internal use */
92 void sha2_process( sha2_context *ctx, const unsigned char data[64] );
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #else /* POLARSSL_SHA2_ALT */
99 #include "sha2_alt.h"
100 #endif /* POLARSSL_SHA2_ALT */
101 
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105 
114 void sha2( const unsigned char *input, size_t ilen,
115  unsigned char output[32], int is224 );
116 
126 int sha2_file( const char *path, unsigned char output[32], int is224 );
127 
136 void sha2_hmac_starts( sha2_context *ctx, const unsigned char *key, size_t keylen,
137  int is224 );
138 
146 void sha2_hmac_update( sha2_context *ctx, const unsigned char *input, size_t ilen );
147 
154 void sha2_hmac_finish( sha2_context *ctx, unsigned char output[32] );
155 
161 void sha2_hmac_reset( sha2_context *ctx );
162 
173 void sha2_hmac( const unsigned char *key, size_t keylen,
174  const unsigned char *input, size_t ilen,
175  unsigned char output[32], int is224 );
176 
182 int sha2_self_test( int verbose );
183 
184 #ifdef __cplusplus
185 }
186 #endif
187 
188 #endif /* sha2.h */
void sha2_hmac_update(sha2_context *ctx, const unsigned char *input, size_t ilen)
SHA-256 HMAC process buffer.
SHA-256 context structure.
Definition: sha2.h:50
void sha2_hmac_starts(sha2_context *ctx, const unsigned char *key, size_t keylen, int is224)
SHA-256 HMAC context setup.
Configuration options (set of defines)
void sha2_hmac_reset(sha2_context *ctx)
SHA-256 HMAC context reset.
void sha2_hmac_finish(sha2_context *ctx, unsigned char output[32])
SHA-256 HMAC final digest.
int sha2_self_test(int verbose)
Checkup routine.
void sha2_update(sha2_context *ctx, const unsigned char *input, size_t ilen)
SHA-256 process buffer.
void sha2_process(sha2_context *ctx, const unsigned char data[64])
int is224
Definition: sha2.h:58
void sha2_hmac(const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
Output = HMAC-SHA-256( hmac key, input buffer )
int sha2_file(const char *path, unsigned char output[32], int is224)
Output = SHA-256( file contents )
void sha2(const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
Output = SHA-256( input buffer )
void sha2_starts(sha2_context *ctx, int is224)
SHA-256 context setup.
void sha2_finish(sha2_context *ctx, unsigned char output[32])
SHA-256 final digest.