PolarSSL v1.3.7
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 
76 void sha256_starts( sha256_context *ctx, int is224 );
77 
85 void sha256_update( sha256_context *ctx, const unsigned char *input,
86  size_t ilen );
87 
94 void sha256_finish( sha256_context *ctx, unsigned char output[32] );
95 
96 /* Internal use */
97 void sha256_process( sha256_context *ctx, const unsigned char data[64] );
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #else /* POLARSSL_SHA256_ALT */
104 #include "sha256_alt.h"
105 #endif /* POLARSSL_SHA256_ALT */
106 
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
110 
119 void sha256( const unsigned char *input, size_t ilen,
120  unsigned char output[32], int is224 );
121 
131 int sha256_file( const char *path, unsigned char output[32], int is224 );
132 
141 void sha256_hmac_starts( sha256_context *ctx, const unsigned char *key,
142  size_t keylen, int is224 );
143 
151 void sha256_hmac_update( sha256_context *ctx, const unsigned char *input,
152  size_t ilen );
153 
160 void sha256_hmac_finish( sha256_context *ctx, unsigned char output[32] );
161 
167 void sha256_hmac_reset( sha256_context *ctx );
168 
179 void sha256_hmac( const unsigned char *key, size_t keylen,
180  const unsigned char *input, size_t ilen,
181  unsigned char output[32], int is224 );
182 
188 int sha256_self_test( int verbose );
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #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:58