PolarSSL v1.3.9
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>
40typedef 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
52extern "C" {
53#endif
54
58typedef 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
83
90void sha256_starts( sha256_context *ctx, int is224 );
91
99void sha256_update( sha256_context *ctx, const unsigned char *input,
100 size_t ilen );
101
108void sha256_finish( sha256_context *ctx, unsigned char output[32] );
109
110/* Internal use */
111void 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
122extern "C" {
123#endif
124
133void sha256( const unsigned char *input, size_t ilen,
134 unsigned char output[32], int is224 );
135
145int sha256_file( const char *path, unsigned char output[32], int is224 );
146
155void sha256_hmac_starts( sha256_context *ctx, const unsigned char *key,
156 size_t keylen, int is224 );
157
165void sha256_hmac_update( sha256_context *ctx, const unsigned char *input,
166 size_t ilen );
167
174void sha256_hmac_finish( sha256_context *ctx, unsigned char output[32] );
175
182
193void 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
202int sha256_self_test( int verbose );
203
204#ifdef __cplusplus
205}
206#endif
207
208#endif /* sha256.h */
Configuration options (set of defines)
void sha256_finish(sha256_context *ctx, unsigned char output[32])
SHA-256 final digest.
int sha256_file(const char *path, unsigned char output[32], int is224)
Output = SHA-256( file contents )
void sha256_hmac_finish(sha256_context *ctx, unsigned char output[32])
SHA-256 HMAC final digest.
int sha256_self_test(int verbose)
Checkup routine.
void sha256_hmac_update(sha256_context *ctx, const unsigned char *input, size_t ilen)
SHA-256 HMAC process buffer.
void sha256_free(sha256_context *ctx)
Clear SHA-256 context.
void sha256(const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
Output = SHA-256( input buffer )
void sha256_process(sha256_context *ctx, const unsigned char data[64])
void sha256_hmac_reset(sha256_context *ctx)
SHA-256 HMAC context reset.
void sha256_hmac_starts(sha256_context *ctx, const unsigned char *key, size_t keylen, int is224)
SHA-256 HMAC context setup.
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 )
void sha256_update(sha256_context *ctx, const unsigned char *input, size_t ilen)
SHA-256 process buffer.
void sha256_starts(sha256_context *ctx, int is224)
SHA-256 context setup.
void sha256_init(sha256_context *ctx)
Initialize SHA-256 context.
SHA-256 context structure.
Definition: sha256.h:59