PolarSSL v1.3.3
sha256.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_SHA256_H
28 #define POLARSSL_SHA256_H
29 
30 #include "config.h"
31 
32 #include <string.h>
33 
34 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
35 #include <basetsd.h>
36 typedef UINT32 uint32_t;
37 #else
38 #include <inttypes.h>
39 #endif
40 
41 #define POLARSSL_ERR_SHA256_FILE_IO_ERROR -0x0078
43 #if !defined(POLARSSL_SHA256_ALT)
44 // Regular implementation
45 //
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
54 typedef struct
55 {
56  uint32_t total[2];
57  uint32_t state[8];
58  unsigned char buffer[64];
60  unsigned char ipad[64];
61  unsigned char opad[64];
62  int is224;
63 }
65 
72 void sha256_starts( sha256_context *ctx, int is224 );
73 
81 void sha256_update( sha256_context *ctx, const unsigned char *input, size_t ilen );
82 
89 void sha256_finish( sha256_context *ctx, unsigned char output[32] );
90 
91 /* Internal use */
92 void sha256_process( sha256_context *ctx, const unsigned char data[64] );
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #else /* POLARSSL_SHA256_ALT */
99 #include "sha256_alt.h"
100 #endif /* POLARSSL_SHA256_ALT */
101 
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105 
114 void sha256( const unsigned char *input, size_t ilen,
115  unsigned char output[32], int is224 );
116 
126 int sha256_file( const char *path, unsigned char output[32], int is224 );
127 
136 void sha256_hmac_starts( sha256_context *ctx, const unsigned char *key,
137  size_t keylen, int is224 );
138 
146 void sha256_hmac_update( sha256_context *ctx, const unsigned char *input, size_t ilen );
147 
154 void sha256_hmac_finish( sha256_context *ctx, unsigned char output[32] );
155 
161 void sha256_hmac_reset( sha256_context *ctx );
162 
173 void sha256_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 sha256_self_test( int verbose );
183 
184 #ifdef __cplusplus
185 }
186 #endif
187 
188 #endif /* sha256.h */
void sha256_hmac_update(sha256_context *ctx, const unsigned char *input, size_t ilen)
SHA-256 HMAC process buffer.
int sha256_file(const char *path, unsigned char output[32], int is224)
Output = SHA-256( file contents )
void sha256_update(sha256_context *ctx, const unsigned char *input, size_t ilen)
SHA-256 process buffer.
void sha256(const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
Output = SHA-256( input buffer )
void sha256_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 )
Configuration options (set of defines)
void sha256_hmac_finish(sha256_context *ctx, unsigned char output[32])
SHA-256 HMAC final digest.
void sha256_hmac_starts(sha256_context *ctx, const unsigned char *key, size_t keylen, int is224)
SHA-256 HMAC context setup.
int sha256_self_test(int verbose)
Checkup routine.
void sha256_starts(sha256_context *ctx, int is224)
SHA-256 context setup.
void sha256_hmac_reset(sha256_context *ctx)
SHA-256 HMAC context reset.
void sha256_process(sha256_context *ctx, const unsigned char data[64])
void sha256_finish(sha256_context *ctx, unsigned char output[32])
SHA-256 final digest.
SHA-256 context structure.
Definition: sha256.h:54