mbed TLS v1.3.19
sha256.h
Go to the documentation of this file.
1 
24 #ifndef POLARSSL_SHA256_H
25 #define POLARSSL_SHA256_H
26 
27 #if !defined(POLARSSL_CONFIG_FILE)
28 #include "config.h"
29 #else
30 #include POLARSSL_CONFIG_FILE
31 #endif
32 
33 #include <stddef.h>
34 
35 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
36 #include <basetsd.h>
37 typedef UINT32 uint32_t;
38 #else
39 #include <inttypes.h>
40 #endif
41 
42 #define POLARSSL_ERR_SHA256_FILE_IO_ERROR -0x0078
44 #if !defined(POLARSSL_SHA256_ALT)
45 // Regular implementation
46 //
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
55 typedef struct
56 {
57  uint32_t total[2];
58  uint32_t state[8];
59  unsigned char buffer[64];
61  unsigned char ipad[64];
62  unsigned char opad[64];
63  int is224;
64 }
66 
72 void sha256_init( sha256_context *ctx );
73 
79 void sha256_free( sha256_context *ctx );
80 
87 void sha256_starts( sha256_context *ctx, int is224 );
88 
96 void sha256_update( sha256_context *ctx, const unsigned char *input,
97  size_t ilen );
98 
105 void sha256_finish( sha256_context *ctx, unsigned char output[32] );
106 
107 /* Internal use */
108 void sha256_process( sha256_context *ctx, const unsigned char data[64] );
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #else /* POLARSSL_SHA256_ALT */
115 #include "sha256_alt.h"
116 #endif /* POLARSSL_SHA256_ALT */
117 
118 #ifdef __cplusplus
119 extern "C" {
120 #endif
121 
130 void sha256( const unsigned char *input, size_t ilen,
131  unsigned char output[32], int is224 );
132 
142 int sha256_file( const char *path, unsigned char output[32], int is224 );
143 
152 void sha256_hmac_starts( sha256_context *ctx, const unsigned char *key,
153  size_t keylen, int is224 );
154 
162 void sha256_hmac_update( sha256_context *ctx, const unsigned char *input,
163  size_t ilen );
164 
171 void sha256_hmac_finish( sha256_context *ctx, unsigned char output[32] );
172 
178 void sha256_hmac_reset( sha256_context *ctx );
179 
190 void sha256_hmac( const unsigned char *key, size_t keylen,
191  const unsigned char *input, size_t ilen,
192  unsigned char output[32], int is224 );
193 
199 int sha256_self_test( int verbose );
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 
205 #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_init(sha256_context *ctx)
Initialize SHA-256 context.
void sha256_free(sha256_context *ctx)
Clear SHA-256 context.
void sha256_finish(sha256_context *ctx, unsigned char output[32])
SHA-256 final digest.
SHA-256 context structure.
Definition: sha256.h:55