TuyaOS
tuya_sha256.h
1
27#ifndef POLARSSL_SHA2_H
28#define POLARSSL_SHA2_H
29
30#include <string.h>
31#include "mbedtls/sha256.h"
32#define POLARSSL_SHA2_C 1
33//#define POLARSSL_SELF_TEST 1
34#define POLARSSL_ERR_SHA2_FILE_IO_ERROR -0x0078
35#define SHA256TYPE 0
36#define SHA244TYPE 1
40typedef struct {
41 mbedtls_sha256_context mbedtls;
42 unsigned char ipad[64];
43 unsigned char opad[64];
45}
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
58void sha2_starts(sha2_context *ctx, int is224);
59
67void sha2_update(sha2_context *ctx, const unsigned char *input, size_t ilen);
68
75void sha2_finish(sha2_context *ctx, unsigned char output[32]);
76
85void sha2(const unsigned char *input, size_t ilen,
86 unsigned char output[32], int is224);
87
97int sha2_file(const char *path, unsigned char output[32], int is224);
98
107void sha2_hmac_starts(sha2_context *ctx, const unsigned char *key, size_t keylen,
108 int is224);
109
117void sha2_hmac_update(sha2_context *ctx, const unsigned char *input, size_t ilen);
118
125void sha2_hmac_finish(sha2_context *ctx, unsigned char output[32]);
126
132void sha2_hmac_reset(sha2_context *ctx);
133
144void sha2_hmac(const unsigned char *key, size_t keylen,
145 const unsigned char *input, size_t ilen,
146 unsigned char output[32], int is224);
147
153int sha2_self_test(int verbose);
154
155#ifdef __cplusplus
156}
157#endif
158
159#endif /* sha2.h */
SHA-256 context structure
Definition: tuya_sha256.h:40