Common process - adapter the symmetry api provide by OS
更多...
#include "tuya_cloud_types.h"
浏览源代码.
|
|
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
- 版权所有
- Copyright 2021-2025 Tuya Inc. All Rights Reserved.
◆ tkl_aes_create_init()
| OPERATE_RET tkl_aes_create_init |
( |
TKL_SYMMETRY_HANDLE * |
ctx | ) |
|
This function Create&initializes a aes context.
- 参数
-
- 注解
- 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] | ctx | The AES context to use for encryption or decryption. It must be initialized and bound to a key. |
| [in] | mode | The AES operation: |
| [in] | length | The length of the input data in Bytes. This must be a multiple of the block size (16 Bytes). |
| [in] | iv | Initialization vector (updated after use). It must be a readable and writeable buffer of 16 Bytes. |
| [in] | input | The buffer holding the input data. It must be readable and of size length Bytes. |
| [in] | output | The 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] | ctx | The AES context to use for encryption or decryption. It must be initialized and bound to a key. |
| [in] | mode | The AES operation: |
| [in] | length | The length of the input data in Bytes. This must be a multiple of the block size (16 Bytes). |
| [in] | input | The buffer holding the input data. It must be readable and of size length Bytes. |
| [in] | output | The 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] | ctx | The 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] | ctx | The AES context to which the key should be bound. It must be initialized. |
| [in] | key | The decryption key.. |
| [in] | keybits | The 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] | ctx | The AES context to which the key should be bound. It must be initialized. |
| [in] | key | The encryption key.. |
| [in] | keybits | The 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