TuyaOS
类型定义 | 函数
tkl_symmetry.h 文件参考

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

#include "tuya_cloud_types.h"
tkl_symmetry.h 的引用(Include)关系图:

浏览源代码.

类型定义

typedef VOID_T * TKL_SYMMETRY_HANDLE
 

函数

OPERATE_RET tkl_aes_create_init (TKL_SYMMETRY_HANDLE *ctx)
 This function Create&initializes a aes context. 更多...
 
OPERATE_RET tkl_aes_crypt_cbc (TKL_SYMMETRY_HANDLE ctx, INT32_T mode, size_t length, UINT8_T iv[16], const UINT8_T *input, UINT8_T *output)
 This function performs an AES-CBC encryption or decryption operation on full blocks. 更多...
 
OPERATE_RET tkl_aes_crypt_ecb (TKL_SYMMETRY_HANDLE ctx, INT32_T mode, size_t length, const UINT8_T *input, UINT8_T *output)
 This function performs an AES encryption or decryption operation. 更多...
 
OPERATE_RET tkl_aes_free (TKL_SYMMETRY_HANDLE ctx)
 This function releases and clears the specified AES context. 更多...
 
OPERATE_RET tkl_aes_setkey_dec (TKL_SYMMETRY_HANDLE ctx, const UINT8_T *key, UINT32_T keybits)
 This function sets the decryption key. 更多...
 
OPERATE_RET tkl_aes_setkey_enc (TKL_SYMMETRY_HANDLE ctx, const UINT8_T *key, UINT32_T keybits)
 This function sets the encryption key. 更多...
 

详细描述

Common process - adapter the symmetry api provide by OS

版本
0.1
日期
2022-04-22

函数说明

◆ tkl_aes_create_init()

OPERATE_RET tkl_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

◆ tkl_aes_crypt_cbc()

OPERATE_RET tkl_aes_crypt_cbc ( TKL_SYMMETRY_HANDLE  ctx,
INT32_T  mode,
size_t  length,
UINT8_T  iv[16],
const 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. tkl_aes_init(), and either tkl_aes_setkey_enc() or tkl_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

◆ tkl_aes_crypt_ecb()

OPERATE_RET tkl_aes_crypt_ecb ( TKL_SYMMETRY_HANDLE  ctx,
INT32_T  mode,
size_t  length,
const 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

◆ tkl_aes_free()

OPERATE_RET tkl_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

◆ tkl_aes_setkey_dec()

OPERATE_RET tkl_aes_setkey_dec ( TKL_SYMMETRY_HANDLE  ctx,
const 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

◆ tkl_aes_setkey_enc()

OPERATE_RET tkl_aes_setkey_enc ( TKL_SYMMETRY_HANDLE  ctx,
const 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