TuyaOS
枚举 | 函数
tal_symmetry.h 文件参考

Common process - adapter the symmetry api provide by OS 更多...

#include "tuya_cloud_types.h"
#include "tkl_symmetry.h"
tal_symmetry.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

枚举

enum  TAL_SYMMETRY_CRYPT_MODE { SYMMETRY_DECRYPT = 0 , SYMMETRY_ENCRYPT = 1 }
 

函数

OPERATE_RET tal_aes128_cbc_decode (IN UINT8_T *data, IN UINT32_T len, IN UINT8_T *key, IN UINT8_T *iv, OUT UINT8_T **dec_data, OUT UINT32_T *dec_len)
 
OPERATE_RET tal_aes128_cbc_decode_raw (UINT8_T *data, size_t len, UINT8_T *key, UINT8_T *iv, UINT8_T *dec_data)
 
OPERATE_RET tal_aes128_cbc_encode (IN UINT8_T *data, IN UINT32_T len, IN UINT8_T *key, IN UINT8_T *iv, OUT UINT8_T **ec_data, OUT UINT32_T *ec_len)
 
OPERATE_RET tal_aes128_cbc_encode_raw (UINT8_T *data, size_t len, UINT8_T *key, UINT8_T *iv, UINT8_T *ec_data)
 
OPERATE_RET tal_aes128_ecb_decode (IN UINT8_T *data, IN UINT32_T len, OUT UINT8_T **dec_data, OUT UINT32_T *dec_len, IN UINT8_T *key)
 
OPERATE_RET tal_aes128_ecb_decode_raw (UINT8_T *data, size_t len, UINT8_T *dec_data, UINT8_T *key)
 
OPERATE_RET tal_aes128_ecb_encode (IN UINT8_T *data, IN UINT32_T len, OUT UINT8_T **ec_data, OUT UINT32_T *ec_len, IN UINT8_T *key)
 
OPERATE_RET tal_aes128_ecb_encode_raw (UINT8_T *data, size_t len, UINT8_T *ec_data, UINT8_T *key)
 
OPERATE_RET tal_aes256_cbc_decode_raw (UINT8_T *data, size_t len, UINT8_T *key, UINT8_T *iv, UINT8_T *dec_data)
 
OPERATE_RET tal_aes256_cbc_encode_raw (UINT8_T *data, size_t len, UINT8_T *key, UINT8_T *iv, UINT8_T *ec_data)
 
OPERATE_RET tal_aes256_ctr_raw (UINT8_T *input, size_t len, UINT8_T *key, size_t *nc_off, UINT8_T nonce_counter[16], UINT8_T stream_block[16], UINT8_T *output)
 
OPERATE_RET tal_aes_create_init (TKL_SYMMETRY_HANDLE *ctx)
 This function Create&initializes a aes context. 更多...
 
OPERATE_RET tal_aes_crypt_cbc (TKL_SYMMETRY_HANDLE ctx, INT32_T mode, size_t length, UINT8_T iv[16], UINT8_T *input, UINT8_T *output)
 This function performs an AES-CBC encryption or decryption operation on full blocks. 更多...
 
OPERATE_RET tal_aes_crypt_ctr (TKL_SYMMETRY_HANDLE ctx, size_t length, size_t *nc_off, UINT8_T nonce_counter[16], UINT8_T stream_block[16], UINT8_T *input, UINT8_T *output)
 
OPERATE_RET tal_aes_crypt_ecb (TKL_SYMMETRY_HANDLE ctx, INT32_T mode, size_t length, UINT8_T *input, UINT8_T *output)
 This function performs an AES encryption or decryption operation. 更多...
 
OPERATE_RET tal_aes_free (TKL_SYMMETRY_HANDLE ctx)
 This function releases and clears the specified AES context. 更多...
 
OPERATE_RET tal_aes_free_data (IN UINT8_T *data)
 
OPERATE_RET tal_aes_self_test (INT32_T verbose)
 
OPERATE_RET tal_aes_setkey_dec (TKL_SYMMETRY_HANDLE ctx, UINT8_T *key, UINT32_T keybits)
 This function sets the decryption key. 更多...
 
OPERATE_RET tal_aes_setkey_enc (TKL_SYMMETRY_HANDLE ctx, UINT8_T *key, UINT32_T keybits)
 This function sets the encryption key. 更多...
 
INT32_T tal_get_actual_length (IN UINT8_T *dec_data, IN UINT32_T dec_data_len)
 
UINT32_T tal_pkcs7padding_buffer (UINT8_T *p_buffer, UINT32_T length)
 

详细描述

Common process - adapter the symmetry api provide by OS

版本
0.1
日期
2022-04-22

函数说明

◆ tal_aes_create_init()

OPERATE_RET tal_aes_create_init ( TKL_SYMMETRY_HANDLE *  ctx)

This function Create&initializes a aes context.

参数
[out]ctxaes handle
注解
This API is used to create and init aes.
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tal_aes_crypt_cbc()

OPERATE_RET tal_aes_crypt_cbc ( TKL_SYMMETRY_HANDLE  ctx,
INT32_T  mode,
size_t  length,
UINT8_T  iv[16],
UINT8_T *  input,
UINT8_T *  output 
)

This function performs an AES-CBC encryption or decryption operation on full blocks.

It performs the operation defined in the mode parameter (encrypt/decrypt), on the input data buffer defined in the input parameter.

It can be called as many times as needed, until all the input data is processed. tal_aes_init(), and either tal_aes_setkey_enc() or tal_aes_setkey_dec() must be called before the first call to this API with the same context.

参数
[in]ctxThe AES context to use for encryption or decryption. It must be initialized and bound to a key.
[in]modeThe AES operation:
[in]lengthThe length of the input data in Bytes. This must be a multiple of the block size (16 Bytes).
[in]ivInitialization vector (updated after use). It must be a readable and writeable buffer of 16 Bytes.
[in]inputThe buffer holding the input data. It must be readable and of size length Bytes.
[in]outputThe buffer where the output data will be written. It must be writeable and of size length Bytes.
注解
This function operates on full blocks, that is, the input size must be a multiple of the AES block size of 16 Bytes.
Upon exit, the content of the IV is updated so that you can call the same function again on the next block(s) of data and get the same result as if it was encrypted in one call. This allows a "streaming" usage. If you need to retain the contents of the IV, you should either save it manually or use the cipher module instead.
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tal_aes_crypt_ecb()

OPERATE_RET tal_aes_crypt_ecb ( TKL_SYMMETRY_HANDLE  ctx,
INT32_T  mode,
size_t  length,
UINT8_T *  input,
UINT8_T *  output 
)

This function performs an AES encryption or decryption operation.

参数
[in]ctxThe AES context to use for encryption or decryption. It must be initialized and bound to a key.
[in]modeThe AES operation:
[in]lengthThe length of the input data in Bytes. This must be a multiple of the block size (16 Bytes).
[in]inputThe buffer holding the input data. It must be readable and of size length Bytes.
[in]outputThe buffer where the output data will be written. It must be writeable and of size length Bytes.
注解
This function operates on full blocks, that is, the input size must be a multiple of the AES block size of 16 Bytes.
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tal_aes_free()

OPERATE_RET tal_aes_free ( TKL_SYMMETRY_HANDLE  ctx)

This function releases and clears the specified AES context.

参数
[in]ctxThe AES context to clear.
注解
This API is used to release aes.
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tal_aes_setkey_dec()

OPERATE_RET tal_aes_setkey_dec ( TKL_SYMMETRY_HANDLE  ctx,
UINT8_T *  key,
UINT32_T  keybits 
)

This function sets the decryption key.

参数
[in]ctxThe AES context to which the key should be bound. It must be initialized.
[in]keyThe decryption key..
[in]keybitsThe size of data passed in bits. Valid options are:
  • 128 bits
  • 192 bits
  • 256 bits
注解
This API is used to set aes key.
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ tal_aes_setkey_enc()

OPERATE_RET tal_aes_setkey_enc ( TKL_SYMMETRY_HANDLE  ctx,
UINT8_T *  key,
UINT32_T  keybits 
)

This function sets the encryption key.

参数
[in]ctxThe AES context to which the key should be bound. It must be initialized.
[in]keyThe encryption key..
[in]keybitsThe size of data passed in bits. Valid options are:
  • 128 bits
  • 192 bits
  • 256 bits
注解
This API is used to set aes key.
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h