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

cloud storage 更多...

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

浏览源代码.

宏定义

#define AES128_CBC_LEN_WITH_PKCS7(len)   ((len) + (16 - (len) % 16))
 
#define CLOUD_STORAGE_ENC_LEN(len)   AES128_CBC_LEN_WITH_PKCS7(len)
 

类型定义

typedef struct storage_ctx storage_ctx
 

函数

OPERATE_RET cloud_storage_aes128_cbc_decrypt (IN CONST storage_ctx *ctx, IN BYTE_T *data, IN CONST UINT_T len, OUT BYTE_T **dec_data, OUT UINT_T *dec_len)
 AES128-CBC Decrypt 更多...
 
OPERATE_RET cloud_storage_aes128_cbc_encrypt (IN CONST storage_ctx *ctx, IN BYTE_T *data, IN CONST UINT_T len, OUT BYTE_T **ec_data, OUT UINT_T *ec_len)
 AES128-CBC Encrypt 更多...
 
OPERATE_RET cloud_storage_backup (storage_ctx *ctx, BYTE_T *data, UINT_T data_len, BOOL_T encrypt)
 backup uploading 更多...
 
OPERATE_RET cloud_storage_backup_post (storage_ctx *ctx)
 Data backup postpone 更多...
 
OPERATE_RET cloud_storage_backup_prepare (storage_ctx *ctx)
 backup prepare 更多...
 
OPERATE_RET cloud_storage_backup_raw_begin (storage_ctx *ctx, UINT_T data_total_len)
 Backup data prepare 更多...
 
OPERATE_RET cloud_storage_backup_raw_end (storage_ctx *ctx)
 Data backup 更多...
 
OPERATE_RET cloud_storage_backup_raw_write (storage_ctx *ctx, BYTE_T *data, UINT_T data_len, BOOL_T encrypt)
 Backup data to the cloud in raw mode 更多...
 
OPERATE_RET cloud_storage_backup_simple (CONST CHAR_T *dev_id, CONST CHAR_T *scene_code, CONST CHAR_T *file_name, BOOL_T encrypt, BYTE_T *data, UINT_T data_len)
 Data backup(simple mode) 更多...
 
OPERATE_RET cloud_storage_ctx_free (storage_ctx *ctx)
 release storage context resource 更多...
 
storage_ctx * cloud_storage_ctx_new (CONST CHAR_T *dev_id, CONST CHAR_T *scene_code, CONST CHAR_T *file_name)
 create storage context 更多...
 
OPERATE_RET cloud_storage_destory (storage_ctx *ctx)
 Data destory 更多...
 
OPERATE_RET cloud_storage_destory_post (storage_ctx *ctx)
 Data destory postpone 更多...
 
OPERATE_RET cloud_storage_destory_prepare (storage_ctx *ctx)
 Data destory prepare 更多...
 
OPERATE_RET cloud_storage_destory_simple (CONST CHAR_T *dev_id, CONST CHAR_T *scene_code, CONST CHAR_T *file_name)
 Data destory(simple mode) 更多...
 
CONST CHAR_T * cloud_storage_get_sign_url (IN CONST storage_ctx *ctx)
 获取签名URL, 返回值生命周期与ctx关联 更多...
 
OPERATE_RET cloud_storage_is_backup_exist (CONST CHAR_T *dev_id, CONST CHAR_T *scene_code, CONST CHAR_T *file_name, BOOL_T *exist)
 Checking backup data exist 更多...
 
BOOL_T cloud_storage_is_secret_key_exist (IN CONST storage_ctx *ctx)
 Checking secret key is exist 更多...
 
OPERATE_RET cloud_storage_meta_data_get (CONST CHAR_T *dev_id, CONST CHAR_T *scene_code, CONST CHAR_T *file_name, ty_cJSON **result)
 Get file meta data(json formatted) 更多...
 
OPERATE_RET cloud_storage_restore (storage_ctx *ctx, BYTE_T **out_data, UINT_T *out_len, BOOL_T encrypt)
 Data restore 更多...
 
OPERATE_RET cloud_storage_restore_post (storage_ctx *ctx)
 Data restore postpone 更多...
 
OPERATE_RET cloud_storage_restore_prepare (storage_ctx *ctx)
 Prepare for data restore 更多...
 
OPERATE_RET cloud_storage_restore_simple (CONST CHAR_T *dev_id, CONST CHAR_T *scene_code, CONST CHAR_T *file_name, BOOL_T encrypt, BYTE_T **out_data, UINT_T *out_len)
 Data restore(simple mode) 更多...
 
CONST CHAR_T * cloud_storage_secret_iv_get (IN CONST storage_ctx *ctx)
 Fetch IV, for AES128-CBC 更多...
 
VOID cloud_storage_secret_iv_set (IN storage_ctx *ctx, IN CONST CHAR_T *iv)
 
CONST CHAR_T * cloud_storage_secret_key_get (IN CONST storage_ctx *ctx)
 Get secret key 更多...
 
VOID cloud_storage_secret_key_set (IN storage_ctx *ctx, IN CONST CHAR_T *key)
 Set secret key 更多...
 

详细描述

cloud storage

作者
Odin (aodin.nosp@m.g.xi.nosp@m.a@tuy.nosp@m.a.co.nosp@m.m)
版本
0.1
日期
2021-11-11

函数说明

◆ cloud_storage_aes128_cbc_decrypt()

OPERATE_RET cloud_storage_aes128_cbc_decrypt ( IN CONST storage_ctx *  ctx,
IN BYTE_T *  data,
IN CONST UINT_T  len,
OUT BYTE_T **  dec_data,
OUT UINT_T *  dec_len 
)

AES128-CBC Decrypt

参数
ctxCloud storage context handler
datadata for decrypted
lendata length for decrypted
dec_datadata decrypted
dec_lendata length decrypted
返回
OPERATE_RET

◆ cloud_storage_aes128_cbc_encrypt()

OPERATE_RET cloud_storage_aes128_cbc_encrypt ( IN CONST storage_ctx *  ctx,
IN BYTE_T *  data,
IN CONST UINT_T  len,
OUT BYTE_T **  ec_data,
OUT UINT_T *  ec_len 
)

AES128-CBC Encrypt

参数
ctxCloud storage context handler
datadata for encrypt
lendata length for encrypt
ec_datadata encrypted
ec_lendata length encrypted
返回
OPERATE_RET

◆ cloud_storage_backup()

OPERATE_RET cloud_storage_backup ( storage_ctx *  ctx,
BYTE_T *  data,
UINT_T  data_len,
BOOL_T  encrypt 
)

backup uploading

参数
ctxCloud storage context handler
datadata for backup
data_lendata length
encryptSet as TRUE if need data encrypted
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_backup_post()

OPERATE_RET cloud_storage_backup_post ( storage_ctx *  ctx)

Data backup postpone

参数
ctxCloud storage context handler
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_backup_prepare()

OPERATE_RET cloud_storage_backup_prepare ( storage_ctx *  ctx)

backup prepare

参数
ctxCloud storage context handler
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_backup_raw_begin()

OPERATE_RET cloud_storage_backup_raw_begin ( storage_ctx *  ctx,
UINT_T  data_total_len 
)

Backup data prepare

参数
ctxCloud storage context handler
data_total_lentotal length for downloading
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_backup_raw_end()

OPERATE_RET cloud_storage_backup_raw_end ( storage_ctx *  ctx)

Data backup

参数
ctxCloud storage context handler
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_backup_raw_write()

OPERATE_RET cloud_storage_backup_raw_write ( storage_ctx *  ctx,
BYTE_T *  data,
UINT_T  data_len,
BOOL_T  encrypt 
)

Backup data to the cloud in raw mode

参数
ctxCloud storage context handler
datadata for backup
data_lendata length
encryptSet as TRUE if need data encrypted
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_backup_simple()

OPERATE_RET cloud_storage_backup_simple ( CONST CHAR_T *  dev_id,
CONST CHAR_T *  scene_code,
CONST CHAR_T *  file_name,
BOOL_T  encrypt,
BYTE_T *  data,
UINT_T  data_len 
)

Data backup(simple mode)

参数
dev_iddevice id string
scene_codescene code string
file_namefile name string, path name is not permit
encryptWhether encrypted, AES128_CBC is the default encrypt algorithm
datadata which want to upload to cloud
data_lendata length
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_ctx_free()

OPERATE_RET cloud_storage_ctx_free ( storage_ctx *  ctx)

release storage context resource

参数
ctxCloud storage context handler
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_ctx_new()

storage_ctx * cloud_storage_ctx_new ( CONST CHAR_T *  dev_id,
CONST CHAR_T *  scene_code,
CONST CHAR_T *  file_name 
)

create storage context

参数
dev_iddevice id string
scene_codescene code string
file_namefile name string, path name is not permit
返回
storage_ctx*

◆ cloud_storage_destory()

OPERATE_RET cloud_storage_destory ( storage_ctx *  ctx)

Data destory

参数
ctxCloud storage context handler
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_destory_post()

OPERATE_RET cloud_storage_destory_post ( storage_ctx *  ctx)

Data destory postpone

参数
ctxCloud storage context handler
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_destory_prepare()

OPERATE_RET cloud_storage_destory_prepare ( storage_ctx *  ctx)

Data destory prepare

参数
ctxCloud storage context handler
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_destory_simple()

OPERATE_RET cloud_storage_destory_simple ( CONST CHAR_T *  dev_id,
CONST CHAR_T *  scene_code,
CONST CHAR_T *  file_name 
)

Data destory(simple mode)

参数
dev_iddevice id string
scene_codescene code string
file_namefile name string, path name is not permit
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_get_sign_url()

CONST CHAR_T * cloud_storage_get_sign_url ( IN CONST storage_ctx *  ctx)

获取签名URL, 返回值生命周期与ctx关联

参数
ctxCloud storage context handler
返回
CONST CHAR_T*

◆ cloud_storage_is_backup_exist()

OPERATE_RET cloud_storage_is_backup_exist ( CONST CHAR_T *  dev_id,
CONST CHAR_T *  scene_code,
CONST CHAR_T *  file_name,
BOOL_T *  exist 
)

Checking backup data exist

参数
dev_iddevice id string
scene_codescene code string
file_namefile name string, path name is not permit
existExist status
返回
OPERATE_RET

◆ cloud_storage_is_secret_key_exist()

BOOL_T cloud_storage_is_secret_key_exist ( IN CONST storage_ctx *  ctx)

Checking secret key is exist

参数
ctxCloud storage context handler
返回
TRUE or FALSE

◆ cloud_storage_meta_data_get()

OPERATE_RET cloud_storage_meta_data_get ( CONST CHAR_T *  dev_id,
CONST CHAR_T *  scene_code,
CONST CHAR_T *  file_name,
ty_cJSON **  result 
)

Get file meta data(json formatted)

参数
dev_iddevice id string
file_namefile name string, path name is not permit
scene_codescene code string
result
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_restore()

OPERATE_RET cloud_storage_restore ( storage_ctx *  ctx,
BYTE_T **  out_data,
UINT_T *  out_len,
BOOL_T  encrypt 
)

Data restore

参数
ctxCloud storage context handler
out_dataoutput data point for restore, need Free manually
out_lenoutput data lngth point for restore, need Free manually
encryptWhether encrypted, AES128_CBC is the default encrypt algorithm
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_restore_post()

OPERATE_RET cloud_storage_restore_post ( storage_ctx *  ctx)

Data restore postpone

参数
ctxCloud storage context handler
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_restore_prepare()

OPERATE_RET cloud_storage_restore_prepare ( storage_ctx *  ctx)

Prepare for data restore

参数
ctxCloud storage context handler
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_restore_simple()

OPERATE_RET cloud_storage_restore_simple ( CONST CHAR_T *  dev_id,
CONST CHAR_T *  scene_code,
CONST CHAR_T *  file_name,
BOOL_T  encrypt,
BYTE_T **  out_data,
UINT_T *  out_len 
)

Data restore(simple mode)

参数
dev_iddevice id string
scene_codescene code string
file_namefile name string, path name is not permit
encryptWhether encrypted, AES128_CBC is the default encrypt algorithm
out_datadata which restored from cloud, need manual Free() by caller user
out_lendata length
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ cloud_storage_secret_iv_get()

CONST CHAR_T * cloud_storage_secret_iv_get ( IN CONST storage_ctx *  ctx)

Fetch IV, for AES128-CBC

参数
ctxCloud storage context handler
返回
iv string

◆ cloud_storage_secret_iv_set()

VOID cloud_storage_secret_iv_set ( IN storage_ctx *  ctx,
IN CONST CHAR_T *  iv 
)
参数
ctxCloud storage context handler
iv
返回
VOID

◆ cloud_storage_secret_key_get()

CONST CHAR_T * cloud_storage_secret_key_get ( IN CONST storage_ctx *  ctx)

Get secret key

参数
ctxCloud storage context handler
返回
CONST CHAR_T*

◆ cloud_storage_secret_key_set()

VOID cloud_storage_secret_key_set ( IN storage_ctx *  ctx,
IN CONST CHAR_T *  key 
)

Set secret key

参数
ctxCloud storage context handler
keysecret key
返回
VOID