TuyaOS
tal_hash.h
浏览该文件的文档.
1
11#ifndef __TAL_HASH_H__
12#define __TAL_HASH_H__
13
14#include "tuya_cloud_types.h"
15#include "tkl_hash.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21typedef struct {
22 TKL_HASH_HANDLE ctx;
23 UINT8_T ipad[64];
24 UINT8_T opad[64];
25}
27
37OPERATE_RET tal_sha256_create_init( TKL_HASH_HANDLE *ctx );
38
48OPERATE_RET tal_sha256_free( TKL_HASH_HANDLE ctx );
49
62OPERATE_RET tal_sha256_starts_ret( TKL_HASH_HANDLE ctx, INT32_T is224 );
63
77OPERATE_RET tal_sha256_update_ret( TKL_HASH_HANDLE ctx,
78 const UINT8_T *input,
79 size_t ilen );
80
93OPERATE_RET tal_sha256_finish_ret( TKL_HASH_HANDLE ctx,
94 UINT8_T output[32] );
95
96
106OPERATE_RET tal_md5_create_init( TKL_HASH_HANDLE *ctx );
107
117OPERATE_RET tal_md5_free( TKL_HASH_HANDLE ctx );
118
129OPERATE_RET tal_md5_starts_ret( TKL_HASH_HANDLE ctx);
130
144OPERATE_RET tal_md5_update_ret( TKL_HASH_HANDLE ctx,
145 const UINT8_T *input,
146 size_t ilen );
147
160OPERATE_RET tal_md5_finish_ret( TKL_HASH_HANDLE ctx,
161 UINT8_T output[16] );
162
172OPERATE_RET tal_sha1_create_init( TKL_HASH_HANDLE *ctx );
173
183OPERATE_RET tal_sha1_free( TKL_HASH_HANDLE ctx );
184
195OPERATE_RET tal_sha1_starts_ret( TKL_HASH_HANDLE ctx);
196
210OPERATE_RET tal_sha1_update_ret( TKL_HASH_HANDLE ctx,
211 const UINT8_T *input,
212 size_t ilen );
213
226OPERATE_RET tal_sha1_finish_ret( TKL_HASH_HANDLE ctx,
227 UINT8_T output[16] );
248OPERATE_RET tal_sha256_ret( const UINT8_T *input,
249 size_t ilen,
250 UINT8_T output[32],
251 INT32_T is224 );
252
263OPERATE_RET tal_md5_ret( const UINT8_T *input,
264 size_t ilen,
265 UINT8_T output[16]);
266
277OPERATE_RET tal_sha1_ret( const UINT8_T *input,
278 size_t ilen,
279 UINT8_T output[20]);
299OPERATE_RET tal_sha256_mac_free( tal_hash_mac_context_t *hmac_handle );
300
313OPERATE_RET tal_sha256_mac_starts( tal_hash_mac_context_t *hmac_handle, const UINT8_T *key, size_t keylen);
327OPERATE_RET tal_sha256_mac_update( tal_hash_mac_context_t *hmac_handle, const UINT8_T *input, size_t ilen );
340OPERATE_RET tal_sha256_mac_finish( tal_hash_mac_context_t *hmac_handle, UINT8_T *output );
341
363OPERATE_RET tal_sha256_mac( const UINT8_T *key, size_t keylen,
364 const UINT8_T *input, size_t ilen,
365 UINT8_T *output );
366
367
387OPERATE_RET tal_sha1_mac_free( tal_hash_mac_context_t *hmac_handle );
388
401OPERATE_RET tal_sha1_mac_starts( tal_hash_mac_context_t *hmac_handle, const UINT8_T *key, size_t keylen);
415OPERATE_RET tal_sha1_mac_update( tal_hash_mac_context_t *hmac_handle, const UINT8_T *input, size_t ilen );
428OPERATE_RET tal_sha1_mac_finish( tal_hash_mac_context_t *hmac_handle, UINT8_T *output );
429
451OPERATE_RET tal_sha1_mac( const UINT8_T *key, size_t keylen,
452 const UINT8_T *input, size_t ilen,
453 UINT8_T *output );
454
455OPERATE_RET tal_sha256_self_test( INT32_T verbose );
456
457OPERATE_RET tal_md5_self_test( INT32_T verbose );
458
459OPERATE_RET tal_sha1_self_test( INT32_T verbose );
460
461OPERATE_RET tal_sha256_mac_self_test( INT32_T verbose );
462
463OPERATE_RET tal_sha1_mac_self_test( INT32_T verbose );
464
465#ifdef __cplusplus
466}
467#endif /* __cplusplus */
468
469#endif
470
Definition: tal_hash.h:21
OPERATE_RET tal_sha256_finish_ret(TKL_HASH_HANDLE ctx, UINT8_T output[32])
This function finishes the sha256 operation, and writes the result to the output buffer.
OPERATE_RET tal_sha256_mac(const UINT8_T *key, size_t keylen, const UINT8_T *input, size_t ilen, UINT8_T *output)
This function calculates the SHA-256 MAC checksum of a buffer.
OPERATE_RET tal_sha1_create_init(TKL_HASH_HANDLE *ctx)
This function Create&initializes a sha1 context.
OPERATE_RET tal_md5_update_ret(TKL_HASH_HANDLE ctx, const UINT8_T *input, size_t ilen)
This function feeds an input buffer into an ongoing md5 checksum calculation.
OPERATE_RET tal_sha256_ret(const UINT8_T *input, size_t ilen, UINT8_T output[32], INT32_T is224)
This function calculates the SHA-224 or SHA-256 checksum of a buffer.
OPERATE_RET tal_sha256_create_init(TKL_HASH_HANDLE *ctx)
This function Create&initializes a sha256 context.
OPERATE_RET tal_sha1_free(TKL_HASH_HANDLE ctx)
This function clears a sha1 context.
OPERATE_RET tal_sha256_mac_starts(tal_hash_mac_context_t *hmac_handle, const UINT8_T *key, size_t keylen)
This function starts a sha256 mac checksum calculation.
OPERATE_RET tal_md5_starts_ret(TKL_HASH_HANDLE ctx)
This function starts a md5 checksum calculation.
OPERATE_RET tal_sha1_mac_create_init(tal_hash_mac_context_t *hmac_handle)
This function Create&initializes a sha1 maccontext.
OPERATE_RET tal_sha256_starts_ret(TKL_HASH_HANDLE ctx, INT32_T is224)
This function starts a sha224 or sha256 checksum calculation.
OPERATE_RET tal_md5_free(TKL_HASH_HANDLE ctx)
This function clears a md5 context.
OPERATE_RET tal_md5_create_init(TKL_HASH_HANDLE *ctx)
This function Create&initializes a md5 context.
OPERATE_RET tal_sha1_mac_finish(tal_hash_mac_context_t *hmac_handle, UINT8_T *output)
This function finishes the sha1 mac operation, and writes the result to the output buffer.
OPERATE_RET tal_sha256_mac_finish(tal_hash_mac_context_t *hmac_handle, UINT8_T *output)
This function finishes the sha256 mac operation, and writes the result to the output buffer.
OPERATE_RET tal_sha256_update_ret(TKL_HASH_HANDLE ctx, const UINT8_T *input, size_t ilen)
This function feeds an input buffer into an ongoing sha256 checksum calculation.
OPERATE_RET tal_sha1_update_ret(TKL_HASH_HANDLE ctx, const UINT8_T *input, size_t ilen)
This function feeds an input buffer into an ongoing sha1 checksum calculation.
OPERATE_RET tal_sha1_mac_update(tal_hash_mac_context_t *hmac_handle, const UINT8_T *input, size_t ilen)
This function feeds an input buffer into an ongoing sha1 mac checksum calculation.
OPERATE_RET tal_md5_finish_ret(TKL_HASH_HANDLE ctx, UINT8_T output[16])
This function finishes the md5 operation, and writes the result to the output buffer.
OPERATE_RET tal_sha1_finish_ret(TKL_HASH_HANDLE ctx, UINT8_T output[16])
This function finishes the sha1 operation, and writes the result to the output buffer.
OPERATE_RET tal_sha256_free(TKL_HASH_HANDLE ctx)
This function clears a sha256 context.
OPERATE_RET tal_sha1_mac_free(tal_hash_mac_context_t *hmac_handle)
This function clears a sha1 mac context.
OPERATE_RET tal_sha1_mac_starts(tal_hash_mac_context_t *hmac_handle, const UINT8_T *key, size_t keylen)
This function starts a sha1 mac checksum calculation.
OPERATE_RET tal_md5_ret(const UINT8_T *input, size_t ilen, UINT8_T output[16])
Output = MD5( input buffer )
OPERATE_RET tal_sha1_starts_ret(TKL_HASH_HANDLE ctx)
This function starts a sha1 checksum calculation.
OPERATE_RET tal_sha1_ret(const UINT8_T *input, size_t ilen, UINT8_T output[20])
Output = sha1( input buffer )
OPERATE_RET tal_sha256_mac_free(tal_hash_mac_context_t *hmac_handle)
This function clears a sha256 mac context.
OPERATE_RET tal_sha256_mac_update(tal_hash_mac_context_t *hmac_handle, const UINT8_T *input, size_t ilen)
This function feeds an input buffer into an ongoing sha256 mac checksum calculation.
OPERATE_RET tal_sha256_mac_create_init(tal_hash_mac_context_t *hmac_handle)
This function Create&initializes a sha256 maccontext.
OPERATE_RET tal_sha1_mac(const UINT8_T *key, size_t keylen, const UINT8_T *input, size_t ilen, UINT8_T *output)
This function calculates the SHA-256 MAC checksum of a buffer.