TuyaOS
|
Common process - adapter the symmetry api provide by OS 更多...
#include "tuya_cloud_types.h"
#include "tkl_symmetry.h"
枚举 | |
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
OPERATE_RET tal_aes_create_init | ( | TKL_SYMMETRY_HANDLE * | ctx | ) |
This function Create&initializes a aes context.
[out] | ctx | aes handle |
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] | 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. |
16
Bytes. 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] | 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. |
16
Bytes.OPERATE_RET tal_aes_free | ( | TKL_SYMMETRY_HANDLE | ctx | ) |
This function releases and clears the specified AES context.
[in] | ctx | The AES context to clear. |
OPERATE_RET tal_aes_setkey_dec | ( | TKL_SYMMETRY_HANDLE | ctx, |
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:
|
OPERATE_RET tal_aes_setkey_enc | ( | TKL_SYMMETRY_HANDLE | ctx, |
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:
|