mirror of
https://github.com/openharmony/security_deviceauth.git
synced 2026-08-26 19:50:40 -04:00
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "clib_types.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
|
||||
void *ClibMalloc(uint32_t size, char val)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ HcParcel CreateParcel(uint32_t size, uint32_t allocUnit)
|
||||
parcel.allocUnit = PARCEL_DEFAULT_INCREASE_STEP;
|
||||
}
|
||||
if (size > 0) {
|
||||
parcel.data = (char*)ClibMalloc(size, 0);
|
||||
parcel.data = (char *)ClibMalloc(size, 0);
|
||||
if (parcel.data != NULL) {
|
||||
parcel.length = size;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "json_utils.h"
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "clib_error.h"
|
||||
#include "clib_types.h"
|
||||
#include "string_util.h"
|
||||
@@ -203,12 +203,7 @@ int32_t GetByteFromJson(const CJson *jsonObj, const char *key, uint8_t *byte, ui
|
||||
if (len < strlen(valueStr) / BYTE_TO_HEX_OPER_LENGTH) {
|
||||
return CLIB_ERR_INVALID_LEN;
|
||||
}
|
||||
int32_t ret = HexStringToByte(valueStr, byte, len);
|
||||
if (ret != CLIB_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return HexStringToByte(valueStr, byte, len);
|
||||
}
|
||||
|
||||
int32_t GetIntFromJson(const CJson *jsonObj, const char *key, int32_t *value)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "clib_error.h"
|
||||
#include "clib_types.h"
|
||||
|
||||
@@ -228,8 +228,7 @@ int32_t ByteToBase64String(const uint8_t *byte, uint32_t byteLen, char *base64St
|
||||
if (byteLen % 3 == 1) {
|
||||
base64Str[i - 2] = '=';
|
||||
base64Str[i - 1] = '=';
|
||||
}
|
||||
if (byteLen % 3 == 2) {
|
||||
} else if (byteLen % 3 == 2) {
|
||||
base64Str[i - 1] = '=';
|
||||
}
|
||||
base64Str[len] = '\0';
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "mbedtls_hash_to_point.h"
|
||||
#include <stdio.h>
|
||||
#include <mbedtls/bignum.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "alg_defs.h"
|
||||
#include "hal_error.h"
|
||||
#include "hc_log.h"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "hc_log.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
|
||||
#define LOG_PRINT_MAX_LEN 256
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "securec.h"
|
||||
#include "hc_log.h"
|
||||
#include "hc_types.h"
|
||||
#include "securec.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -123,8 +123,8 @@ int HcFileRead(FileHandle file, void *dst, int dstSize)
|
||||
int total = 0;
|
||||
while (total < dstSize) {
|
||||
int readCount = fread(dstBuffer + total, 1, dstSize - total, fp);
|
||||
if ((readCount < 0) || (readCount > (dstSize - total))) {
|
||||
return -1;
|
||||
if (ferror(fp) != 0) {
|
||||
LOGE("read file error!");
|
||||
}
|
||||
if (readCount == 0) {
|
||||
return total;
|
||||
@@ -146,8 +146,8 @@ int HcFileWrite(FileHandle file, const void *src, int srcSize)
|
||||
int total = 0;
|
||||
while (total < srcSize) {
|
||||
int writeCount = fwrite(srcBuffer + total, 1, srcSize - total, fp);
|
||||
if (writeCount < 0 || writeCount > (srcSize - total)) {
|
||||
return -1;
|
||||
if (ferror(fp) != 0) {
|
||||
LOGE("write file error!");
|
||||
}
|
||||
total += writeCount;
|
||||
}
|
||||
@@ -196,6 +196,9 @@ void HcFileGetSubFileName(const char *path, StringVector *nameVec)
|
||||
DeleteString(&subFileName);
|
||||
}
|
||||
}
|
||||
if (closedir(dir) < 0) {
|
||||
LOGE("Failed to close file");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <securec.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "hal_error.h"
|
||||
#include "hc_log.h"
|
||||
#include "securec.h"
|
||||
#include "utils_file.h"
|
||||
|
||||
#define MAX_FOLDER_NAME_SIZE 128
|
||||
@@ -136,8 +136,11 @@ void HcFileGetSubFileName(const char *path, StringVector *nameVec)
|
||||
continue;
|
||||
}
|
||||
if (nameVec->pushBackT(nameVec, subFileName) == NULL) {
|
||||
LOGE("Failed to push path to pathVec!");
|
||||
LOGE("Failed to push name!");
|
||||
DeleteString(&subFileName);
|
||||
}
|
||||
}
|
||||
if (closedir(dir) < 0) {
|
||||
LOGE("Failed to close file");
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "add_auth_info.h"
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "base.h"
|
||||
#include "mem_stat.h"
|
||||
@@ -192,7 +192,7 @@ int32_t import_signed_auth_info_hilink(const struct hichain *hichain, const stru
|
||||
uint32_t len = (data->length / BYTE_TO_HEX_OPER_LENGTH) + 1;
|
||||
uint8_t *receive_data = (uint8_t *)MALLOC(len);
|
||||
if (receive_data == NULL) {
|
||||
LOGE("malloc inport signed auth info receive data failed");
|
||||
LOGE("malloc import signed auth info receive data failed");
|
||||
return HC_MALLOC_FAILED;
|
||||
}
|
||||
(void)memset_s(receive_data, len, 0, len);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "add_auth_info_client.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "huks_adapter.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "auth_info.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "huks_adapter.h"
|
||||
@@ -78,7 +78,7 @@ int32_t encrypt_payload(const struct var_buffer *key, const struct uint8_buff *p
|
||||
struct aes_aad aes_aad;
|
||||
(void)memset_s(&aes_aad, sizeof(aes_aad), 0, sizeof(aes_aad));
|
||||
if (strcpy_s((char *)aes_aad.aad, sizeof(aes_aad.aad), aad) != EOK) {
|
||||
LOGE("What happened was that the probability was zero"); /* caller perceives memery error, no return */
|
||||
LOGE("What happened was that the probability was zero"); /* caller perceives memory error, no return */
|
||||
}
|
||||
aes_aad.length = strlen(aad);
|
||||
int32_t ret = aes_gcm_encrypt((struct var_buffer *)key, plain, &aes_aad, payload);
|
||||
@@ -104,7 +104,7 @@ int32_t decrypt_payload(const struct var_buffer *key, const struct uint8_buff *p
|
||||
struct aes_aad aes_aad;
|
||||
(void)memset_s(&aes_aad, sizeof(aes_aad), 0, sizeof(aes_aad));
|
||||
if (strcpy_s((char *)aes_aad.aad, sizeof(aes_aad.aad), aad) != EOK) {
|
||||
LOGE("What happened was that the probability was zero"); /* caller perceives memery error, no return */
|
||||
LOGE("What happened was that the probability was zero"); /* caller perceives memory error, no return */
|
||||
}
|
||||
aes_aad.length = strlen(aad);
|
||||
int32_t ret = aes_gcm_decrypt((struct var_buffer *)key, payload, &aes_aad, plain);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_) || defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_))
|
||||
|
||||
#include "exchange_auth_info.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "base.h"
|
||||
#include "mem_stat.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_CLIENT_) || defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_CLIENT_))
|
||||
#include "exchange_auth_info_client.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "base.h"
|
||||
#include "mem_stat.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "remove_auth_info_client.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "base.h"
|
||||
#include "mem_stat.h"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "commonutil.h"
|
||||
#include "distribution.h"
|
||||
#include "log.h"
|
||||
@@ -242,7 +242,7 @@ int32_t init_center(const struct hc_package_name *package_name, const struct hc_
|
||||
LOGE("Generate derived dek failed");
|
||||
return ret;
|
||||
}
|
||||
if (memcpy_s(dek, sizeof(struct hc_key_alias), &dek_alias, sizeof(struct hc_key_alias)) != HC_OK) {
|
||||
if (memcpy_s(dek, sizeof(struct hc_key_alias), &dek_alias, sizeof(struct hc_key_alias)) != EOK) {
|
||||
return HC_INNER_ERROR;
|
||||
}
|
||||
|
||||
@@ -1175,7 +1175,7 @@ static int32_t delete_public_key(hc_handle handle, struct service_id service_id,
|
||||
(void)memset_s(auth_id_list, length, 0, length);
|
||||
|
||||
uint32_t peers_num = list_trust_peers(handle, user_type, NULL, &auth_id_list);
|
||||
LOGI("peers_num %d", peers_num);
|
||||
LOGI("peers_num %u", peers_num);
|
||||
for (uint32_t loop = 0; loop < peers_num; loop++) {
|
||||
struct hc_key_alias key_alias = generate_key_alias(&service_id, &auth_id_list[loop], user_type);
|
||||
if (key_alias.length == 0) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "commonutil.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "base.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
char hex_to_char(uint8_t hex)
|
||||
{
|
||||
return (hex > 9) ? hex + 0x37 : hex + 0x30; /* Convert to the corresponding character */
|
||||
/* Convert to the corresponding character, hex + 0x37 -> A-F, hex + 0x30 -> 0-9 */
|
||||
return (hex > 9) ? hex + 0x37 : hex + 0x30;
|
||||
}
|
||||
|
||||
void byte_to_hex_string(const uint8_t *hex, int32_t hex_len, uint8_t *buf, int32_t buf_len)
|
||||
@@ -117,22 +118,6 @@ int32_t string_convert(json_pobject obj, const char *field, uint8_t *str, uint32
|
||||
return HC_OK;
|
||||
}
|
||||
|
||||
void hex_string_convert(uint32_t length, const uint8_t *hex, const char *field, json_pobject parent)
|
||||
{
|
||||
int32_t org_cha_len = length;
|
||||
int32_t tmp_cha_data_hex_len = org_cha_len * BYTE_TO_HEX_OPER_LENGTH + 1;
|
||||
uint8_t *tmp_cha_data_hex = (uint8_t *)MALLOC(tmp_cha_data_hex_len);
|
||||
|
||||
if (tmp_cha_data_hex == NULL) {
|
||||
return;
|
||||
}
|
||||
(void)memset_s(tmp_cha_data_hex, tmp_cha_data_hex_len, 0, tmp_cha_data_hex_len);
|
||||
byte_to_hex_string(hex, org_cha_len, tmp_cha_data_hex, org_cha_len * BYTE_TO_HEX_OPER_LENGTH);
|
||||
add_string_to_object(parent, field, (char *)tmp_cha_data_hex);
|
||||
FREE(tmp_cha_data_hex);
|
||||
tmp_cha_data_hex = NULL;
|
||||
}
|
||||
|
||||
int32_t memory_copy_error(const char *fun, unsigned int line)
|
||||
{
|
||||
(void)fun;
|
||||
|
||||
@@ -28,7 +28,6 @@ void print_bytes(uint8_t *buf, int32_t buf_len);
|
||||
|
||||
int32_t byte_convert(json_pobject obj, const char *field, uint8_t *hex, uint32_t *length, uint32_t max_len);
|
||||
int32_t string_convert(json_pobject obj, const char *field, uint8_t *str, uint32_t *length, uint32_t max_len);
|
||||
void hex_string_convert(uint32_t length, const uint8_t *hex, const char *field, json_pobject parent);
|
||||
|
||||
int32_t memory_copy_error(const char *fun, unsigned int line);
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ json_handle parse_json(const char *data)
|
||||
return (void *)root;
|
||||
}
|
||||
|
||||
void free_json(json_handle hanlde)
|
||||
void free_json(json_handle handle)
|
||||
{
|
||||
if (hanlde != NULL) {
|
||||
cJSON_Delete((cJSON *)hanlde);
|
||||
if (handle != NULL) {
|
||||
cJSON_Delete((cJSON *)handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ typedef void *json_handle;
|
||||
typedef void *json_pobject;
|
||||
|
||||
json_handle parse_json(const char *data);
|
||||
void free_json(json_handle hanlde);
|
||||
void free_json(json_handle handle);
|
||||
|
||||
json_pobject get_json_obj(json_pobject parent, const char *field);
|
||||
int32_t get_json_int(json_pobject obj, const char *field);
|
||||
|
||||
@@ -62,7 +62,7 @@ int32_t send_start_response(void *handle, void *receive_data, void *send_data)
|
||||
}
|
||||
set_state(base, START_RESPONSE);
|
||||
set_last_time_sec(base);
|
||||
DBG_OUT("Object %u receive start request data send start response data succcess", base->sn);
|
||||
DBG_OUT("Object %u receive start request data send start response data success", base->sn);
|
||||
return HC_OK;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ int32_t send_end_response(void *handle, void *receive_data, void *send_data)
|
||||
}
|
||||
set_state(base, PROTOCOL_FINISH);
|
||||
set_last_time_sec(base);
|
||||
DBG_OUT("Object %u receive end request data send end response data succcess", base->sn);
|
||||
DBG_OUT("Object %u receive end request data send end response data success", base->sn);
|
||||
return HC_OK;
|
||||
}
|
||||
#endif /* DESC */
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_CLIENT_))
|
||||
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "huks_adapter.h"
|
||||
#include "commonutil.h"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "huks_adapter.h"
|
||||
#include "mem_stat.h"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "sec_clone_server.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "huks_adapter.h"
|
||||
#include "log.h"
|
||||
#include "commonutil.h"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_CLIENT_))
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "huks_adapter.h"
|
||||
#include "log.h"
|
||||
#include "commonutil.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "commonutil.h"
|
||||
#include "distribution.h"
|
||||
#include "mem_stat.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#ifndef _HC_DEBUG_
|
||||
|
||||
#include "log.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "base.h"
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "build_object.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "auth_info.h"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "distribution.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "pake_client.h"
|
||||
#include "pake_server.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_ADD_) || defined(_CUT_ADD_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_ADD_) || defined(_CUT_ADD_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_ADD_) || defined(_CUT_ADD_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
@@ -90,8 +90,8 @@ void free_auth_start_request(void *obj)
|
||||
}
|
||||
}
|
||||
|
||||
static char *make_requst_json_str(struct sts_start_request_data *auth_start_request,
|
||||
struct sts_start_request_data_hex tmp_hex)
|
||||
static char *make_request_json_str(struct sts_start_request_data *auth_start_request,
|
||||
struct sts_start_request_data_hex tmp_hex)
|
||||
{
|
||||
char *tmp_str = (char *)MALLOC(RET_STR_LENGTH);
|
||||
if (tmp_str == NULL) {
|
||||
@@ -156,7 +156,7 @@ char *make_auth_start_request(void *data)
|
||||
FREE(tmp_hex.tmp_cha_data_hex);
|
||||
return NULL;
|
||||
}
|
||||
char *ret_str = make_requst_json_str(auth_start_request, tmp_hex);
|
||||
char *ret_str = make_request_json_str(auth_start_request, tmp_hex);
|
||||
FREE(tmp_hex.tmp_epk_data_hex);
|
||||
FREE(tmp_hex.tmp_cha_data_hex);
|
||||
FREE(tmp_hex.tmp_type_data_hex);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_) || defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_) || defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_) || defined(_CUT_EXCHANGE_) || defined(_CUT_EXCHANGE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "key_agreement_version.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_))
|
||||
|
||||
#include <log.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
#include "commonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_PAKE_) || defined(_CUT_PAKE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "parsedata.h"
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
#include "log.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_REMOVE_) || defined(_CUT_REMOVE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_REMOVE_) || defined(_CUT_REMOVE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#if !(defined(_CUT_STS_) || defined(_CUT_STS_SERVER_) || defined(_CUT_REMOVE_) || defined(_CUT_REMOVE_SERVER_))
|
||||
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "log.h"
|
||||
#include "mem_stat.h"
|
||||
#include "jsonutil.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#if (defined(_SUPPORT_SEC_CLONE_) || defined(_SUPPORT_SEC_CLONE_SERVER_))
|
||||
|
||||
#include <string.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "jsonutil.h"
|
||||
#include "commonutil.h"
|
||||
#include "exchange_auth_info.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "deviceauth_test.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <securec.h>
|
||||
#include "securec.h"
|
||||
#include "hichain.h"
|
||||
|
||||
#define LOG(format, ...) (printf(format"\n", ##__VA_ARGS__))
|
||||
@@ -54,7 +54,7 @@ static void Transmit(const struct session_identity *identity, const void *data,
|
||||
LOG("--------Transmit--------");
|
||||
LOG("identity session_id[%d] package_name[%s]", identity->session_id, identity->package_name.name);
|
||||
LOG("data[%s]", (char *)data);
|
||||
LOG("length[%d]", length);
|
||||
LOG("length[%u]", length);
|
||||
LOG("--------Transmit--------");
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ extern "C" {
|
||||
|
||||
typedef struct {
|
||||
SvcIdentity stubIdentity;
|
||||
bool registed;
|
||||
bool registered;
|
||||
} StubDevAuthCb;
|
||||
|
||||
int32_t CbStubOnRemoteRequest(const IpcContext *ctx, void *ipcMsg, IpcIo *data, void *arg);
|
||||
|
||||
@@ -1392,8 +1392,8 @@ void SetCbCtxToDataCtx(uintptr_t callCtx, int32_t cbIdx)
|
||||
ProxyDevAuthData *dataCache = NULL;
|
||||
const SvcIdentity *stubInfo = &g_sdkCbStub.stubIdentity;
|
||||
(void)cbIdx;
|
||||
if (!g_sdkCbStub.registed) {
|
||||
LOGW("SDK callback stub un-registed");
|
||||
if (!g_sdkCbStub.registered) {
|
||||
LOGW("SDK callback stub un-registered");
|
||||
return;
|
||||
}
|
||||
ShowIpcSvcInfo(stubInfo);
|
||||
@@ -1661,7 +1661,7 @@ int32_t InitProxyAdapt(void)
|
||||
LOGI("get proxy instance success");
|
||||
}
|
||||
|
||||
if (!g_sdkCbStub.registed) {
|
||||
if (!g_sdkCbStub.registered) {
|
||||
ret = RegisterIpcCallback(CbStubOnRemoteRequest, 0, IPC_WAIT_FOREVER, &(g_sdkCbStub.stubIdentity), NULL);
|
||||
if (ret != 0) {
|
||||
LOGE("register ipc cb failed");
|
||||
@@ -1669,7 +1669,7 @@ int32_t InitProxyAdapt(void)
|
||||
}
|
||||
ShowIpcSvcInfo(&(g_sdkCbStub.stubIdentity));
|
||||
LOGI("register ipc cb success");
|
||||
g_sdkCbStub.registed = true;
|
||||
g_sdkCbStub.registered = true;
|
||||
}
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
@@ -1680,7 +1680,7 @@ void UnInitProxyAdapt(void)
|
||||
if (UnregisterIpcCallback(g_sdkCbStub.stubIdentity)) {
|
||||
LOGW("un-register ipc cb failed");
|
||||
}
|
||||
g_sdkCbStub.registed = false;
|
||||
g_sdkCbStub.registered = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ static int32_t BinderLiteProcess(SvcIdentity **svc, int32_t procType)
|
||||
(void)BinderRelease((*svc)->ipcContext, (*svc)->handle);
|
||||
break;
|
||||
default:
|
||||
LOGW("internal error: unknow processing type");
|
||||
LOGW("internal error: unknown processing type");
|
||||
}
|
||||
#endif
|
||||
return (ret == 0) ? HC_SUCCESS : HC_ERROR;
|
||||
|
||||
@@ -1349,6 +1349,7 @@ int32_t AddDevAuthServiceToManager(uintptr_t *serviceCtx)
|
||||
ret = sysMgr->AddSystemAbility(DEVICE_AUTH_SERVICE_ID, sPtr);
|
||||
if (ret != ERR_OK) {
|
||||
LOGE("add service failed");
|
||||
delete sPtr;
|
||||
return HC_ERROR;
|
||||
}
|
||||
*serviceCtx = reinterpret_cast<uintptr_t>(sPtr);
|
||||
|
||||
@@ -140,7 +140,7 @@ enum {
|
||||
BAD_PAYLOAD = 0xF000000B,
|
||||
ALGORITHM_UNSUPPORTED = 0xF000000C,
|
||||
PROOF_MISMATCH = 0xF000000D,
|
||||
UNKOWN = 0xF0000000,
|
||||
UNKNOWN = 0xF0000000,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -61,7 +61,7 @@ bool IsDasMsgNeedIgnore(const CJson *in)
|
||||
return false;
|
||||
}
|
||||
|
||||
LOGI("The message needs to ignore, message: %u.", message);
|
||||
LOGI("The message needs to ignore, message: %d.", message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -402,12 +402,12 @@ int32_t GetAndCheckAuthIdPeer(const CJson *in, const Uint8Buff *authIdSelf, cons
|
||||
return HC_ERR_CONVERT_FAILED;
|
||||
}
|
||||
if ((authIdSelf->length == authIdPeer->length) &&
|
||||
memcmp(authIdSelf->val, authIdPeer->val, authIdSelf->length) == 0) {
|
||||
memcmp(authIdSelf->val, authIdPeer->val, authIdSelf->length) == EOK) {
|
||||
LOGE("Peer id can not be equal to self id.");
|
||||
HcFree(authIdPeerTmp);
|
||||
return HC_ERR_INVALID_PARAMS;
|
||||
}
|
||||
if (memcmp(authIdPeer->val, authIdPeerTmp, authIdPeer->length) != 0) {
|
||||
if (memcmp(authIdPeer->val, authIdPeerTmp, authIdPeer->length) != EOK) {
|
||||
LOGE("Peer authId does not match.");
|
||||
HcFree(authIdPeerTmp);
|
||||
return HC_ERR_INVALID_PARAMS;
|
||||
|
||||
+1
-5
@@ -58,11 +58,7 @@ static int ExchangeRequest(AsyBaseCurTask *task, PakeParams *params, const CJson
|
||||
}
|
||||
|
||||
// execute
|
||||
res = ClientRequestStandardBindExchange(params, &(realTask->params));
|
||||
if (res != HC_SUCCESS) {
|
||||
LOGE("ClientRequestStandardBindExchange failed");
|
||||
return res;
|
||||
}
|
||||
GOTO_ERR_AND_SET_RET(ClientRequestStandardBindExchange(params, &(realTask->params)), res);
|
||||
|
||||
// package message
|
||||
GOTO_ERR_AND_SET_RET(AddIntToJson(sendToPeer, FIELD_MESSAGE, PAKE_BIND_EXCHANGE_REQUEST), res);
|
||||
|
||||
@@ -127,10 +127,7 @@ static bool EndWithZero(HcParcel *parcel)
|
||||
if (p == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (*p == '\0') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return (*p == '\0');
|
||||
}
|
||||
|
||||
static bool LoadStringVectorFromParcel(StringVector *vec, HcParcel *parcel)
|
||||
@@ -201,7 +198,7 @@ static bool GetOsAccountInfoPath(int32_t osAccountId, char *infoPath, uint32_t p
|
||||
{
|
||||
const char *beginPath = GetStorageDirPath();
|
||||
if (beginPath == NULL) {
|
||||
LOGE("[DB]: Failed to get the stroage path dir!");
|
||||
LOGE("[DB]: Failed to get the storage path dir!");
|
||||
return false;
|
||||
}
|
||||
int32_t ret;
|
||||
@@ -424,13 +421,13 @@ static bool ReadParcelFromFile(int32_t osAccountId, HcParcel *parcel)
|
||||
}
|
||||
int fileSize = HcFileSize(file);
|
||||
if (fileSize <= 0) {
|
||||
LOGE("[DB]: The databse file size is invalid!");
|
||||
LOGE("[DB]: The database file size is invalid!");
|
||||
HcFileClose(file);
|
||||
return false;
|
||||
}
|
||||
char *fileData = (char *)HcMalloc(fileSize, 0);
|
||||
if (fileData == NULL) {
|
||||
LOGE("[DB]: Failed to allocate fileData memroy!");
|
||||
LOGE("[DB]: Failed to allocate fileData memory!");
|
||||
HcFileClose(file);
|
||||
return false;
|
||||
}
|
||||
@@ -697,16 +694,25 @@ static TrustedDeviceEntry **QueryDeviceEntryPtrIfMatch(const DeviceEntryVec *vec
|
||||
|
||||
static void PostGroupCreatedMsg(const TrustedGroupEntry *groupEntry)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
GetBroadcaster()->postOnGroupCreated(groupEntry);
|
||||
}
|
||||
|
||||
static void PostGroupDeletedMsg(const TrustedGroupEntry *groupEntry)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
GetBroadcaster()->postOnGroupDeleted(groupEntry);
|
||||
}
|
||||
|
||||
static void PostDeviceBoundMsg(OsAccountTrustedInfo *info, const TrustedDeviceEntry *deviceEntry)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
QueryGroupParams groupParams = InitQueryGroupParams();
|
||||
groupParams.groupId = StringGet(&deviceEntry->groupId);
|
||||
TrustedGroupEntry **groupEntryPtr = QueryGroupEntryPtrIfMatch(&info->groups, &groupParams);
|
||||
@@ -717,11 +723,21 @@ static void PostDeviceBoundMsg(OsAccountTrustedInfo *info, const TrustedDeviceEn
|
||||
|
||||
static void PostDeviceUnBoundMsg(OsAccountTrustedInfo *info, const TrustedDeviceEntry *deviceEntry)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
const char *groupId = StringGet(&deviceEntry->groupId);
|
||||
const char *udid = StringGet(&deviceEntry->udid);
|
||||
QueryGroupParams groupParams = InitQueryGroupParams();
|
||||
groupParams.groupId = StringGet(&deviceEntry->groupId);
|
||||
groupParams.groupId = groupId;
|
||||
TrustedGroupEntry **groupEntryPtr = QueryGroupEntryPtrIfMatch(&info->groups, &groupParams);
|
||||
if (groupEntryPtr != NULL) {
|
||||
GetBroadcaster()->postOnDeviceUnBound(StringGet(&deviceEntry->udid), *groupEntryPtr);
|
||||
GetBroadcaster()->postOnDeviceUnBound(udid, *groupEntryPtr);
|
||||
}
|
||||
QueryDeviceParams deviceParams = InitQueryDeviceParams();
|
||||
deviceParams.udid = udid;
|
||||
if (QueryDeviceEntryPtrIfMatch(&info->devices, &deviceParams) == NULL) {
|
||||
GetBroadcaster()->postOnDeviceNotTrusted(udid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1021,7 +1037,7 @@ int32_t QueryGroups(int32_t osAccountId, const QueryGroupParams *params, GroupEn
|
||||
continue;
|
||||
}
|
||||
if (vec->pushBackT(vec, newEntry) == NULL) {
|
||||
LOGE("[DB]: Faild to push entry to vec!");
|
||||
LOGE("[DB]: Failed to push entry to vec!");
|
||||
DestroyGroupEntry(newEntry);
|
||||
}
|
||||
}
|
||||
@@ -1053,7 +1069,7 @@ int32_t QueryDevices(int32_t osAccountId, const QueryDeviceParams *params, Devic
|
||||
continue;
|
||||
}
|
||||
if (vec->pushBackT(vec, newEntry) == NULL) {
|
||||
LOGE("[DB]: Faild to push entry to vec!");
|
||||
LOGE("[DB]: Failed to push entry to vec!");
|
||||
DestroyDeviceEntry(newEntry);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,855 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "database_util.h"
|
||||
|
||||
#include "broadcast_manager.h"
|
||||
#include "device_auth.h"
|
||||
#include "hc_dev_info.h"
|
||||
#include "hc_log.h"
|
||||
#include "hc_types.h"
|
||||
#include "securec.h"
|
||||
|
||||
IMPLEMENT_HC_VECTOR(StringVector, HcString, 1)
|
||||
|
||||
/* cache across account groupId func */
|
||||
static GenGroupIdFunc g_generateIdFunc = NULL;
|
||||
|
||||
static bool EndWithZero(HcParcel *parcel)
|
||||
{
|
||||
const char *p = GetParcelLastChar(parcel);
|
||||
if (p == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (*p == '\0') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int32_t GenerateGroupInfoCommonByEntry(const TrustedGroupEntry *groupEntry, GroupInfo *returnGroupInfo)
|
||||
{
|
||||
if (HC_VECTOR_SIZE(&(groupEntry->managers)) == 0) {
|
||||
LOGE("[DB]: The group owner is lost!");
|
||||
return HC_ERR_LOST_DATA;
|
||||
}
|
||||
HcString entryOwner = HC_VECTOR_GET(&groupEntry->managers, 0);
|
||||
if (!StringSet(&(returnGroupInfo->ownerName), entryOwner)) {
|
||||
LOGE("[DB]: Failed to copy groupOwner!");
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
}
|
||||
if (!StringSet(&(returnGroupInfo->userIdHash), groupEntry->userIdHash)) {
|
||||
LOGE("[DB]: Failed to copy userIdHash!");
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
}
|
||||
returnGroupInfo->type = groupEntry->type;
|
||||
returnGroupInfo->visibility = groupEntry->visibility;
|
||||
returnGroupInfo->expireTime = groupEntry->expireTime;
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GenerateGroupInfoIdAndName(const char *groupId, const char *groupName, GroupInfo *returnGroupInfo)
|
||||
{
|
||||
if (!StringSetPointer(&(returnGroupInfo->id), groupId)) {
|
||||
LOGE("[DB]: Failed to copy groupId!");
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
}
|
||||
if (!StringSetPointer(&(returnGroupInfo->name), groupName)) {
|
||||
LOGE("[DB]: Failed to copy groupName!");
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
}
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GenerateGroupInfoSharedUserIdHash(const char *sharedUserIdHash, GroupInfo *returnGroupInfo)
|
||||
{
|
||||
if (!StringSetPointer(&(returnGroupInfo->sharedUserIdHash), sharedUserIdHash)) {
|
||||
LOGE("[DB]: Failed to copy sharedUserIdHash!");
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
}
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GenerateAcrossAccountGroupInfoById(const TrustedGroupEntry *groupEntry, const char *groupId,
|
||||
GroupInfo *returnGroupInfo)
|
||||
{
|
||||
int32_t result = GenerateGroupInfoIdAndName(groupId, groupId, returnGroupInfo);
|
||||
if (result != HC_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
const char *targetSharedUserIdHash = NULL;
|
||||
result = GetSharedUserIdFromVecByGroupId(groupEntry, groupId, &targetSharedUserIdHash);
|
||||
if (result != HC_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
return GenerateGroupInfoSharedUserIdHash(targetSharedUserIdHash, returnGroupInfo);
|
||||
}
|
||||
|
||||
static int32_t GenerateAcrossAccountGroupInfoByUserIdHash(const TrustedGroupEntry *groupEntry,
|
||||
const char *sharedUserIdHash, GroupInfo *returnGroupInfo)
|
||||
{
|
||||
if (g_generateIdFunc == NULL) {
|
||||
LOGE("[DB]: Generate groupId function is NULL!");
|
||||
return HC_ERR_NOT_SUPPORT;
|
||||
}
|
||||
char *tempGroupId = NULL;
|
||||
const char *userIdHash = StringGet(&groupEntry->userIdHash);
|
||||
if (userIdHash == NULL) {
|
||||
LOGE("[DB]: Failed to get userIdHash from groupEntry!");
|
||||
return HC_ERR_NULL_PTR;
|
||||
}
|
||||
int32_t result = g_generateIdFunc(userIdHash, sharedUserIdHash, &tempGroupId);
|
||||
if (result != HC_SUCCESS) {
|
||||
LOGE("[DB]: Failed to generate temp groupId!");
|
||||
return result;
|
||||
}
|
||||
result = GenerateGroupInfoIdAndName(tempGroupId, tempGroupId, returnGroupInfo);
|
||||
HcFree(tempGroupId);
|
||||
if (result != HC_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
return GenerateGroupInfoSharedUserIdHash(sharedUserIdHash, returnGroupInfo);
|
||||
}
|
||||
|
||||
static int32_t GenerateDeviceInfoCommonByEntry(const TrustedDeviceEntry *entry, TrustedDeviceEntry *returnDeviceInfo)
|
||||
{
|
||||
if (!StringSet(&returnDeviceInfo->udid, entry->udid)) {
|
||||
LOGE("[DB]: Failed to copy udid!");
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
}
|
||||
if (!StringSet(&returnDeviceInfo->authId, entry->authId)) {
|
||||
LOGE("[DB]: Failed to copy authId!");
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
}
|
||||
if (!StringSet(&returnDeviceInfo->serviceType, entry->serviceType)) {
|
||||
LOGE("[DB]: Failed to copy serviceType!");
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
}
|
||||
if (!StringSet(&returnDeviceInfo->userIdHash, entry->userIdHash)) {
|
||||
LOGE("[DB]: Failed to copy userIdHash!");
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
}
|
||||
returnDeviceInfo->credential = entry->credential;
|
||||
returnDeviceInfo->devType = entry->devType;
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GenerateDeviceInfoId(const char *groupId, TrustedDeviceEntry *returnDeviceInfo)
|
||||
{
|
||||
if (!StringSetPointer(&(returnDeviceInfo->groupId), groupId)) {
|
||||
LOGE("[DB]: Failed to copy groupId!");
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
}
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GenerateGroupInfoByDevEntry(const TrustedDeviceEntry *deviceEntry, GroupInfo *groupInfo)
|
||||
{
|
||||
const TrustedGroupEntry *groupEntry = deviceEntry->groupEntry;
|
||||
if (groupEntry == NULL) {
|
||||
LOGE("[DB]: The groupEntry is NULL!");
|
||||
return HC_ERR_NULL_PTR;
|
||||
}
|
||||
const char *groupId = StringGet(&deviceEntry->serviceType);
|
||||
if (groupId == NULL) {
|
||||
LOGE("[DB]: The groupId is NULL!");
|
||||
return HC_ERR_NULL_PTR;
|
||||
}
|
||||
return GenerateGroupInfoByEntry(groupEntry, groupId, NULL, groupInfo);
|
||||
}
|
||||
|
||||
static int32_t AddGroupIdToList(const char *userIdHash, const char *sharedUserIdHash, CJson *groupIdList)
|
||||
{
|
||||
char *groupId = NULL;
|
||||
int32_t result = g_generateIdFunc(userIdHash, sharedUserIdHash, &groupId);
|
||||
if (result != HC_SUCCESS) {
|
||||
LOGE("[DB]: Failed to generate groupId!");
|
||||
return result;
|
||||
}
|
||||
if (AddStringToArray(groupIdList, groupId) != HC_SUCCESS) {
|
||||
LOGE("[DB]: Failed to add groupId to groupIdList!");
|
||||
HcFree(groupId);
|
||||
return HC_ERR_JSON_ADD;
|
||||
}
|
||||
HcFree(groupId);
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
bool LoadStringVectorFromParcel(StringVector *vec, HcParcel *parcel)
|
||||
{
|
||||
uint32_t strLen = 0;
|
||||
do {
|
||||
if (!ParcelReadUint32(parcel, &strLen)) {
|
||||
return true;
|
||||
}
|
||||
if ((strLen == 0) || (strLen > MAX_STRING_LEN)) {
|
||||
return false;
|
||||
}
|
||||
HcString str = CreateString();
|
||||
ClearParcel(&str.parcel);
|
||||
if (!ParcelReadParcel(parcel, &str.parcel, strLen, false) ||
|
||||
!EndWithZero(&str.parcel)) {
|
||||
DeleteString(&str);
|
||||
return false;
|
||||
} else {
|
||||
if (vec->pushBack(vec, &str) == NULL) {
|
||||
DeleteString(&str);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
|
||||
bool SaveStringVectorToParcel(const StringVector *vec, HcParcel *parcel)
|
||||
{
|
||||
uint32_t index;
|
||||
HcString *str = NULL;
|
||||
FOR_EACH_HC_VECTOR(*vec, index, str) {
|
||||
uint32_t len = StringLength(str) + sizeof(char);
|
||||
if (!ParcelWriteUint32(parcel, len)) {
|
||||
return false;
|
||||
}
|
||||
if (!ParcelWrite(parcel, GetParcelData(&str->parcel), GetParcelDataSize(&str->parcel))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
StringVector CreateStrVector(void)
|
||||
{
|
||||
return CreateStringVector();
|
||||
}
|
||||
|
||||
void DestroyStrVector(StringVector *vec)
|
||||
{
|
||||
uint32_t index;
|
||||
HcString *strItemPtr = NULL;
|
||||
FOR_EACH_HC_VECTOR(*vec, index, strItemPtr) {
|
||||
DeleteString(strItemPtr);
|
||||
}
|
||||
DESTROY_HC_VECTOR(StringVector, vec);
|
||||
}
|
||||
|
||||
GroupInfo *CreateGroupInfoStruct(void)
|
||||
{
|
||||
GroupInfo *ptr = (GroupInfo *)HcMalloc(sizeof(GroupInfo), 0);
|
||||
if (ptr == NULL) {
|
||||
LOGE("[DB]: Failed to allocate groupInfo memory!");
|
||||
return NULL;
|
||||
}
|
||||
ptr->name = CreateString();
|
||||
ptr->id = CreateString();
|
||||
ptr->ownerName = CreateString();
|
||||
ptr->userIdHash = CreateString();
|
||||
ptr->sharedUserIdHash = CreateString();
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void DestroyGroupInfoStruct(GroupInfo *groupInfo)
|
||||
{
|
||||
if (groupInfo == NULL) {
|
||||
return;
|
||||
}
|
||||
DeleteString(&(groupInfo->name));
|
||||
DeleteString(&(groupInfo->id));
|
||||
DeleteString(&(groupInfo->ownerName));
|
||||
DeleteString(&(groupInfo->userIdHash));
|
||||
DeleteString(&(groupInfo->sharedUserIdHash));
|
||||
HcFree(groupInfo);
|
||||
}
|
||||
|
||||
TrustedDeviceEntry *CreateDeviceInfoStruct(void)
|
||||
{
|
||||
TrustedDeviceEntry *deviceInfo = (TrustedDeviceEntry *)HcMalloc(sizeof(DeviceInfo), 0);
|
||||
if (deviceInfo == NULL) {
|
||||
LOGE("[DB]: Failed to allocate deviceInfo memory!");
|
||||
return NULL;
|
||||
}
|
||||
deviceInfo->authId = CreateString();
|
||||
deviceInfo->udid = CreateString();
|
||||
deviceInfo->serviceType = CreateString();
|
||||
deviceInfo->userIdHash = CreateString();
|
||||
deviceInfo->groupId = CreateString();
|
||||
return deviceInfo;
|
||||
}
|
||||
|
||||
void DestroyDeviceInfoStruct(TrustedDeviceEntry *deviceInfo)
|
||||
{
|
||||
if (deviceInfo == NULL) {
|
||||
return;
|
||||
}
|
||||
DeleteString(&(deviceInfo->authId));
|
||||
DeleteString(&(deviceInfo->udid));
|
||||
DeleteString(&(deviceInfo->serviceType));
|
||||
DeleteString(&(deviceInfo->userIdHash));
|
||||
DeleteString(&(deviceInfo->groupId));
|
||||
HcFree(deviceInfo);
|
||||
}
|
||||
|
||||
TrustedGroupEntry *CreateGroupEntryStruct(void)
|
||||
{
|
||||
TrustedGroupEntry *ptr = (TrustedGroupEntry *)HcMalloc(sizeof(TrustedGroupEntry), 0);
|
||||
if (ptr == NULL) {
|
||||
LOGE("[DB]: Failed to allocate groupEntry memory!");
|
||||
return NULL;
|
||||
}
|
||||
ptr->name = CreateString();
|
||||
ptr->id = CreateString();
|
||||
ptr->userIdHash = CreateString();
|
||||
ptr->sharedUserIdHashVec = CREATE_HC_VECTOR(StringVector);
|
||||
ptr->managers = CREATE_HC_VECTOR(StringVector);
|
||||
ptr->friends = CREATE_HC_VECTOR(StringVector);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void DestroyGroupEntryStruct(TrustedGroupEntry *groupEntry)
|
||||
{
|
||||
DeleteString(&groupEntry->name);
|
||||
DeleteString(&groupEntry->id);
|
||||
DeleteString(&groupEntry->userIdHash);
|
||||
DestroyStrVector(&groupEntry->managers);
|
||||
DestroyStrVector(&groupEntry->friends);
|
||||
DestroyStrVector(&groupEntry->sharedUserIdHashVec);
|
||||
}
|
||||
|
||||
void DestroyDeviceEntryStruct(TrustedDeviceEntry *deviceEntry)
|
||||
{
|
||||
DeleteString(&deviceEntry->udid);
|
||||
DeleteString(&deviceEntry->authId);
|
||||
DeleteString(&deviceEntry->serviceType);
|
||||
DeleteString(&deviceEntry->userIdHash);
|
||||
DeleteParcel(&deviceEntry->ext);
|
||||
}
|
||||
|
||||
int32_t GenerateGroupInfoByEntry(const TrustedGroupEntry *groupEntry, const char *groupId,
|
||||
const char *sharedUserIdHash, GroupInfo *returnGroupInfo)
|
||||
{
|
||||
if ((groupEntry == NULL) || (returnGroupInfo == NULL)) {
|
||||
LOGE("[DB]: The input parameters contains NULL value!");
|
||||
return HC_ERR_NULL_PTR;
|
||||
}
|
||||
int32_t result = GenerateGroupInfoCommonByEntry(groupEntry, returnGroupInfo);
|
||||
if (result != HC_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if (groupEntry->type != ACROSS_ACCOUNT_AUTHORIZE_GROUP) {
|
||||
return GenerateGroupInfoIdAndName(StringGet(&groupEntry->id), StringGet(&groupEntry->name), returnGroupInfo);
|
||||
}
|
||||
if (groupId != NULL) {
|
||||
return GenerateAcrossAccountGroupInfoById(groupEntry, groupId, returnGroupInfo);
|
||||
} else if (sharedUserIdHash != NULL) {
|
||||
return GenerateAcrossAccountGroupInfoByUserIdHash(groupEntry, sharedUserIdHash, returnGroupInfo);
|
||||
} else {
|
||||
return HC_ERR_INVALID_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t GenerateDeviceInfoByEntry(const TrustedDeviceEntry *deviceEntry, const char *groupId,
|
||||
TrustedDeviceEntry *returnDeviceInfo)
|
||||
{
|
||||
int32_t result = GenerateDeviceInfoCommonByEntry(deviceEntry, returnDeviceInfo);
|
||||
if (result != HC_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
if (groupId != NULL) {
|
||||
return GenerateDeviceInfoId(groupId, returnDeviceInfo);
|
||||
}
|
||||
if (deviceEntry->groupEntry->type != ACROSS_ACCOUNT_AUTHORIZE_GROUP) {
|
||||
return GenerateDeviceInfoId(StringGet(&deviceEntry->groupEntry->id), returnDeviceInfo);
|
||||
}
|
||||
return GenerateDeviceInfoId(StringGet(&deviceEntry->serviceType), returnDeviceInfo);
|
||||
}
|
||||
|
||||
int32_t GetSharedUserIdFromVecByGroupId(const TrustedGroupEntry *groupEntry, const char *groupId,
|
||||
const char **returnUserIdHash)
|
||||
{
|
||||
if ((groupEntry == NULL) || (groupId == NULL) || (returnUserIdHash == NULL)) {
|
||||
LOGE("[DB]: The input parameters contains NULL value!");
|
||||
return HC_ERR_INVALID_PARAMS;
|
||||
}
|
||||
if ((groupEntry->type != ACROSS_ACCOUNT_AUTHORIZE_GROUP) || (g_generateIdFunc == NULL)) {
|
||||
return HC_ERR_NOT_SUPPORT;
|
||||
}
|
||||
if (strcmp(groupId, "") == 0) {
|
||||
return HC_ERR_INVALID_PARAMS;
|
||||
}
|
||||
const char *userIdHash = StringGet(&groupEntry->userIdHash);
|
||||
if (userIdHash == NULL) {
|
||||
LOGE("[DB]: Failed to get userIdHash from groupEntry!");
|
||||
return HC_ERR_NULL_PTR;
|
||||
}
|
||||
/* The groupId of the across account group needs to be generated temporarily due to device resource problems. */
|
||||
uint32_t index;
|
||||
HcString *sharedUserIdHash = NULL;
|
||||
FOR_EACH_HC_VECTOR(groupEntry->sharedUserIdHashVec, index, sharedUserIdHash) {
|
||||
const char *sharedUserIdHashPtr = StringGet(sharedUserIdHash);
|
||||
if (sharedUserIdHashPtr == NULL) {
|
||||
LOGW("[DB]: Failed to get sharedUserIdHash from sharedUserIdHashVec!");
|
||||
continue;
|
||||
}
|
||||
char *tmpGroupId = NULL;
|
||||
int32_t result = g_generateIdFunc(userIdHash, sharedUserIdHashPtr, &tmpGroupId);
|
||||
if (result != HC_SUCCESS) {
|
||||
LOGE("[DB]: Failed to generate temp groupId!");
|
||||
return result;
|
||||
}
|
||||
bool isEquals = (strcmp(tmpGroupId, groupId) == 0) ? true : false;
|
||||
HcFree(tmpGroupId);
|
||||
if (isEquals) {
|
||||
*returnUserIdHash = sharedUserIdHashPtr;
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
}
|
||||
return HC_ERR_GROUP_NOT_EXIST;
|
||||
}
|
||||
|
||||
void AddNewSharedUserId(const StringVector *sharedUserIdHashList, TrustedGroupEntry *entry, CJson *groupIdList)
|
||||
{
|
||||
if ((sharedUserIdHashList == NULL) || (entry == NULL) || (groupIdList == NULL)) {
|
||||
LOGE("[DB]: The input parameters contains NULL value!");
|
||||
return;
|
||||
}
|
||||
HcString *sharedUserIdHash = NULL;
|
||||
uint32_t sharedUserIdIndex = 0;
|
||||
while (sharedUserIdIndex < sharedUserIdHashList->size(sharedUserIdHashList)) {
|
||||
sharedUserIdHash = sharedUserIdHashList->getp(sharedUserIdHashList, sharedUserIdIndex);
|
||||
sharedUserIdIndex++;
|
||||
const char *sharedUserIdHashPtr = StringGet(sharedUserIdHash);
|
||||
if (sharedUserIdHashPtr == NULL) {
|
||||
continue;
|
||||
}
|
||||
bool isNeedAdd = true;
|
||||
uint32_t tmpIndex;
|
||||
HcString *tmpSharedUserIdHash = NULL;
|
||||
FOR_EACH_HC_VECTOR(entry->sharedUserIdHashVec, tmpIndex, tmpSharedUserIdHash) {
|
||||
const char *tmpSharedUserIdHashPtr = StringGet(tmpSharedUserIdHash);
|
||||
if ((tmpSharedUserIdHashPtr != NULL) && (strcmp(sharedUserIdHashPtr, tmpSharedUserIdHashPtr) == 0)) {
|
||||
isNeedAdd = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isNeedAdd) {
|
||||
continue;
|
||||
}
|
||||
HcString newSharedUserIdHash = CreateString();
|
||||
if (!StringSet(&newSharedUserIdHash, *sharedUserIdHash)) {
|
||||
LOGE("Failed to copy sharedUserIdHash!");
|
||||
DeleteString(&newSharedUserIdHash);
|
||||
continue;
|
||||
}
|
||||
HC_VECTOR_PUSHBACK(&entry->sharedUserIdHashVec, &newSharedUserIdHash);
|
||||
NotifyGroupCreated(entry, StringGet(&newSharedUserIdHash));
|
||||
if (groupIdList != NULL) {
|
||||
(void)AddGroupIdToList(StringGet(&entry->userIdHash), StringGet(&newSharedUserIdHash), groupIdList);
|
||||
}
|
||||
LOGI("[DB]: Add a across account group to database successfully!");
|
||||
}
|
||||
}
|
||||
|
||||
void DeleteExpiredSharedUserId(const StringVector *sharedUserIdHashList, TrustedGroupEntry *entry)
|
||||
{
|
||||
if ((sharedUserIdHashList == NULL) || (entry == NULL)) {
|
||||
LOGE("[DB]: The input parameters contains NULL value!");
|
||||
return;
|
||||
}
|
||||
HcString *sharedUserIdHash = NULL;
|
||||
uint32_t sharedUserIdIndex = 0;
|
||||
while (sharedUserIdIndex < entry->sharedUserIdHashVec.size(&entry->sharedUserIdHashVec)) {
|
||||
sharedUserIdHash = entry->sharedUserIdHashVec.getp(&entry->sharedUserIdHashVec, sharedUserIdIndex);
|
||||
const char *sharedUserIdHashPtr = StringGet(sharedUserIdHash);
|
||||
if (sharedUserIdHash == NULL) {
|
||||
sharedUserIdIndex++;
|
||||
continue;
|
||||
}
|
||||
bool isNeedRemove = true;
|
||||
uint32_t tmpIndex;
|
||||
HcString *tmpSharedUserIdHash = NULL;
|
||||
FOR_EACH_HC_VECTOR(*sharedUserIdHashList, tmpIndex, tmpSharedUserIdHash) {
|
||||
const char *tmpSharedUserIdHashPtr = StringGet(tmpSharedUserIdHash);
|
||||
if ((tmpSharedUserIdHashPtr != NULL) && (strcmp(sharedUserIdHashPtr, tmpSharedUserIdHashPtr) == 0)) {
|
||||
isNeedRemove = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isNeedRemove) {
|
||||
sharedUserIdIndex++;
|
||||
continue;
|
||||
}
|
||||
HcString popSharedUserIdHash;
|
||||
HC_VECTOR_POPELEMENT(&entry->sharedUserIdHashVec, &popSharedUserIdHash, sharedUserIdIndex);
|
||||
NotifyGroupDeleted(entry, StringGet(&popSharedUserIdHash));
|
||||
DeleteString(&popSharedUserIdHash);
|
||||
LOGI("[DB]: Delete a across account group from database successfully!");
|
||||
}
|
||||
}
|
||||
|
||||
bool CompareGroupTypeInGroupEntryOrAll(const TrustedGroupEntry *groupEntry, int32_t groupType)
|
||||
{
|
||||
if (groupType == ALL_GROUP) {
|
||||
return true;
|
||||
} else {
|
||||
return (groupType == groupEntry->type);
|
||||
}
|
||||
}
|
||||
|
||||
bool CompareDevIdInDeviceEntryOrNull(const TrustedDeviceEntry *deviceEntry, const char *devId, bool isUdid)
|
||||
{
|
||||
if (devId == NULL) {
|
||||
return true;
|
||||
} else {
|
||||
const char *entryDevId = isUdid ? StringGet(&deviceEntry->udid) : StringGet(&deviceEntry->authId);
|
||||
if (entryDevId == NULL) {
|
||||
return false;
|
||||
}
|
||||
return (strcmp(entryDevId, devId) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool CompareGroupIdInDeviceEntryOrNull(const TrustedDeviceEntry *deviceEntry, const char *groupId)
|
||||
{
|
||||
if (groupId == NULL) {
|
||||
return true;
|
||||
} else {
|
||||
const char *tmpGroupId = (deviceEntry->groupEntry->type != ACROSS_ACCOUNT_AUTHORIZE_GROUP) ?
|
||||
(StringGet(&deviceEntry->groupEntry->id)) : (StringGet(&deviceEntry->serviceType));
|
||||
if (tmpGroupId == NULL) {
|
||||
return false;
|
||||
}
|
||||
/* Check whether the device is the local device entry in the across account group. */
|
||||
if (strcmp(tmpGroupId, "") != 0) {
|
||||
return (strcmp(tmpGroupId, groupId) == 0);
|
||||
}
|
||||
const char *sharedUserIdHash = NULL;
|
||||
if (GetSharedUserIdFromVecByGroupId(deviceEntry->groupEntry, groupId, &sharedUserIdHash) == HC_SUCCESS) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CompareSearchParams(int32_t groupType, const char *groupId, const char *groupName, const char *groupOwner,
|
||||
const TrustedGroupEntry *entry)
|
||||
{
|
||||
if ((groupType != ALL_GROUP) && (entry->type != groupType)) {
|
||||
return false;
|
||||
}
|
||||
if ((groupId != NULL) && (!IsGroupIdEquals(entry, groupId))) {
|
||||
return false;
|
||||
}
|
||||
if ((groupName != NULL) && (!IsGroupNameEquals(entry, groupName))) {
|
||||
return false;
|
||||
}
|
||||
if (HC_VECTOR_SIZE(&(entry->managers)) == 0) {
|
||||
LOGE("[DB]: The group owner is lost!");
|
||||
return false;
|
||||
}
|
||||
if (groupOwner != NULL) {
|
||||
HcString entryOwnerStr = HC_VECTOR_GET(&(entry->managers), 0);
|
||||
const char *entryOwner = StringGet(&entryOwnerStr);
|
||||
if ((entryOwner == NULL) || (strcmp(entryOwner, groupOwner) != 0)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsGroupIdEquals(const TrustedGroupEntry *groupEntry, const char *groupId)
|
||||
{
|
||||
if ((groupEntry == NULL) || (groupId == NULL)) {
|
||||
return false;
|
||||
}
|
||||
if (groupEntry->type != ACROSS_ACCOUNT_AUTHORIZE_GROUP) {
|
||||
const char *entryGroupId = StringGet(&groupEntry->id);
|
||||
if ((entryGroupId != NULL) && (strcmp(entryGroupId, groupId) == 0)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const char *sharedUserIdHash = NULL;
|
||||
if (GetSharedUserIdFromVecByGroupId(groupEntry, groupId, &sharedUserIdHash) == HC_SUCCESS) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsGroupNameEquals(const TrustedGroupEntry *groupEntry, const char *groupName)
|
||||
{
|
||||
if ((groupEntry == NULL) || (groupName == NULL)) {
|
||||
return false;
|
||||
}
|
||||
if (groupEntry->type != ACROSS_ACCOUNT_AUTHORIZE_GROUP) {
|
||||
const char *entryGroupName = StringGet(&groupEntry->name);
|
||||
if ((entryGroupName != NULL) && (strcmp(entryGroupName, groupName) == 0)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const char *sharedUserIdHash = NULL;
|
||||
if (GetSharedUserIdFromVecByGroupId(groupEntry, groupName, &sharedUserIdHash) == HC_SUCCESS) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsGroupManager(const char *appId, const TrustedGroupEntry *entry)
|
||||
{
|
||||
uint32_t index;
|
||||
HcString *manager = NULL;
|
||||
FOR_EACH_HC_VECTOR(entry->managers, index, manager) {
|
||||
if (strcmp(StringGet(manager), appId) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsGroupFriend(const char *appId, const TrustedGroupEntry *entry)
|
||||
{
|
||||
uint32_t index;
|
||||
HcString *trustedFriend = NULL;
|
||||
FOR_EACH_HC_VECTOR(entry->friends, index, trustedFriend) {
|
||||
if (strcmp(StringGet(trustedFriend), appId) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SetGroupElement(TlvGroupElement *element, TrustedGroupEntry **entry)
|
||||
{
|
||||
if (!StringSet(&element->name.data, (*entry)->name)) {
|
||||
return false;
|
||||
}
|
||||
if (!StringSet(&element->id.data, (*entry)->id)) {
|
||||
return false;
|
||||
}
|
||||
if (!StringSet(&element->userIdHash.data, (*entry)->userIdHash)) {
|
||||
return false;
|
||||
}
|
||||
element->type.data = (*entry)->type;
|
||||
element->visibility.data = (*entry)->visibility;
|
||||
element->expireTime.data = (*entry)->expireTime;
|
||||
if (!SaveStringVectorToParcel(&(*entry)->managers, &element->managers.data)) {
|
||||
return false;
|
||||
}
|
||||
if (!SaveStringVectorToParcel(&(*entry)->friends, &element->friends.data)) {
|
||||
return false;
|
||||
}
|
||||
if (!SaveStringVectorToParcel(&(*entry)->sharedUserIdHashVec, &element->sharedUserIdHashVec.data)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetDeviceElement(TlvDevAuthElement *element, TrustedDeviceEntry *entry)
|
||||
{
|
||||
if (!StringSet(&element->groupId.data, entry->groupEntry->id)) {
|
||||
return false;
|
||||
}
|
||||
if (!StringSet(&element->udid.data, entry->udid)) {
|
||||
return false;
|
||||
}
|
||||
if (!StringSet(&element->authId.data, entry->authId)) {
|
||||
return false;
|
||||
}
|
||||
if (!StringSet(&element->serviceType.data, entry->serviceType)) {
|
||||
return false;
|
||||
}
|
||||
if (!StringSet(&element->userIdHash.data, entry->userIdHash)) {
|
||||
return false;
|
||||
}
|
||||
if (!ParcelCopy(&element->ext.data, &entry->ext)) {
|
||||
return false;
|
||||
}
|
||||
element->info.data.credential = entry->credential;
|
||||
element->info.data.devType = entry->devType;
|
||||
element->info.data.lastTm = entry->lastTm;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SatisfyType(int32_t type, int32_t standardType)
|
||||
{
|
||||
return ((standardType == ALL_GROUP) || (type == standardType));
|
||||
}
|
||||
|
||||
bool SatisfyVisibility(int32_t visibility, int32_t standardVisibility)
|
||||
{
|
||||
return ((standardVisibility == ALL_GROUP_VISIBILITY) || (visibility == standardVisibility));
|
||||
}
|
||||
|
||||
void RegGenerateGroupIdFunc(GenGroupIdFunc func)
|
||||
{
|
||||
if (func == NULL) {
|
||||
LOGE("[DB]: The input func is NULL!");
|
||||
return;
|
||||
}
|
||||
g_generateIdFunc = func;
|
||||
}
|
||||
|
||||
void DeregGenerateGroupIdFunc(void)
|
||||
{
|
||||
g_generateIdFunc = NULL;
|
||||
}
|
||||
|
||||
void NotifyGroupCreated(const TrustedGroupEntry *groupEntry, const char *sharedUserIdHash)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
if (groupEntry == NULL) {
|
||||
return;
|
||||
}
|
||||
Broadcaster *broadcaster = GetBroadcaster();
|
||||
if ((broadcaster == NULL) || (broadcaster->postOnGroupCreated == NULL)) {
|
||||
LOGE("[DB]: Failed to get broadcaster!");
|
||||
return;
|
||||
}
|
||||
GroupInfo *groupInfo = CreateGroupInfoStruct();
|
||||
if (groupInfo == NULL) {
|
||||
LOGE("[DB]: Failed to allocate groupInfo memory!");
|
||||
return;
|
||||
}
|
||||
if (GenerateGroupInfoByEntry(groupEntry, NULL, sharedUserIdHash, groupInfo) != HC_SUCCESS) {
|
||||
DestroyGroupInfoStruct(groupInfo);
|
||||
return;
|
||||
}
|
||||
broadcaster->postOnGroupCreated(groupInfo);
|
||||
DestroyGroupInfoStruct(groupInfo);
|
||||
}
|
||||
|
||||
void NotifyGroupDeleted(const TrustedGroupEntry *groupEntry, const char *sharedUserIdHash)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
if (groupEntry == NULL) {
|
||||
return;
|
||||
}
|
||||
Broadcaster *broadcaster = GetBroadcaster();
|
||||
if ((broadcaster == NULL) || (broadcaster->postOnGroupDeleted == NULL)) {
|
||||
LOGE("[DB]: Failed to get broadcaster!");
|
||||
return;
|
||||
}
|
||||
GroupInfo *groupInfo = CreateGroupInfoStruct();
|
||||
if (groupInfo == NULL) {
|
||||
LOGE("[DB]: Failed to allocate groupInfo memory!");
|
||||
return;
|
||||
}
|
||||
if (GenerateGroupInfoByEntry(groupEntry, NULL, sharedUserIdHash, groupInfo) != HC_SUCCESS) {
|
||||
DestroyGroupInfoStruct(groupInfo);
|
||||
return;
|
||||
}
|
||||
broadcaster->postOnGroupDeleted(groupInfo);
|
||||
DestroyGroupInfoStruct(groupInfo);
|
||||
}
|
||||
|
||||
void NotifyDeviceBound(const TrustedDeviceEntry *deviceEntry)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
if (deviceEntry == NULL) {
|
||||
return;
|
||||
}
|
||||
Broadcaster *broadcaster = GetBroadcaster();
|
||||
if ((broadcaster == NULL) || (broadcaster->postOnDeviceBound == NULL)) {
|
||||
LOGE("[DB]: Failed to get broadcaster!");
|
||||
return;
|
||||
}
|
||||
GroupInfo *groupInfo = CreateGroupInfoStruct();
|
||||
if (groupInfo == NULL) {
|
||||
LOGE("[DB]: Failed to allocate groupInfo memory!");
|
||||
return;
|
||||
}
|
||||
if (GenerateGroupInfoByDevEntry(deviceEntry, groupInfo) != HC_SUCCESS) {
|
||||
DestroyGroupInfoStruct(groupInfo);
|
||||
return;
|
||||
}
|
||||
broadcaster->postOnDeviceBound(StringGet(&deviceEntry->udid), groupInfo);
|
||||
DestroyGroupInfoStruct(groupInfo);
|
||||
}
|
||||
|
||||
void NotifyDeviceUnBound(const TrustedDeviceEntry *deviceEntry)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
if (deviceEntry == NULL) {
|
||||
return;
|
||||
}
|
||||
Broadcaster *broadcaster = GetBroadcaster();
|
||||
if ((broadcaster == NULL) || (broadcaster->postOnDeviceUnBound == NULL)) {
|
||||
LOGE("[DB]: Failed to get broadcaster!");
|
||||
return;
|
||||
}
|
||||
GroupInfo *groupInfo = CreateGroupInfoStruct();
|
||||
if (groupInfo == NULL) {
|
||||
LOGE("[DB]: Failed to allocate groupInfo memory!");
|
||||
return;
|
||||
}
|
||||
if (GenerateGroupInfoByDevEntry(deviceEntry, groupInfo) != HC_SUCCESS) {
|
||||
DestroyGroupInfoStruct(groupInfo);
|
||||
return;
|
||||
}
|
||||
broadcaster->postOnDeviceUnBound(StringGet(&deviceEntry->udid), groupInfo);
|
||||
DestroyGroupInfoStruct(groupInfo);
|
||||
}
|
||||
|
||||
void NotifyDeviceNotTrusted(const char *peerUdid)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
if (peerUdid == NULL) {
|
||||
return;
|
||||
}
|
||||
Broadcaster *broadcaster = GetBroadcaster();
|
||||
if ((broadcaster == NULL) || (broadcaster->postOnDeviceNotTrusted == NULL)) {
|
||||
LOGE("[DB]: Failed to get broadcaster!");
|
||||
return;
|
||||
}
|
||||
broadcaster->postOnDeviceNotTrusted(peerUdid);
|
||||
}
|
||||
|
||||
void NotifyLastGroupDeleted(const char *peerUdid, int groupType)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
if (peerUdid == NULL) {
|
||||
return;
|
||||
}
|
||||
Broadcaster *broadcaster = GetBroadcaster();
|
||||
if ((broadcaster == NULL) || (broadcaster->postOnLastGroupDeleted == NULL)) {
|
||||
LOGE("[DB]: Failed to get broadcaster!");
|
||||
return;
|
||||
}
|
||||
broadcaster->postOnLastGroupDeleted(peerUdid, groupType);
|
||||
}
|
||||
|
||||
void NotifyTrustedDeviceNumChanged(int trustedDeviceNum)
|
||||
{
|
||||
if (!IsBroadcastSupported()) {
|
||||
return;
|
||||
}
|
||||
Broadcaster *broadcaster = GetBroadcaster();
|
||||
if ((broadcaster == NULL) || (broadcaster->postOnTrustedDeviceNumChanged == NULL)) {
|
||||
LOGE("[DB]: Failed to get broadcaster!");
|
||||
return;
|
||||
}
|
||||
broadcaster->postOnTrustedDeviceNumChanged(trustedDeviceNum);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ int32_t GetInfoHash(const uint8_t *info, uint32_t infoLen, char *str, uint32_t s
|
||||
}
|
||||
int32_t res;
|
||||
do {
|
||||
if (memcpy_s(message.val, message.length, info, infoLen) != HC_SUCCESS) {
|
||||
if (memcpy_s(message.val, message.length, info, infoLen) != EOK) {
|
||||
LOGE("Failed to copy data!");
|
||||
res = HC_ERR_ALLOC_MEMORY;
|
||||
break;
|
||||
|
||||
@@ -62,7 +62,7 @@ static int32_t AddChannelEntry(int64_t requestId, int64_t channelId)
|
||||
{
|
||||
int64_t tmpReqId = DEFAULT_REQUEST_ID;
|
||||
if (GetReqIdByChannelId(channelId, &tmpReqId) == HC_SUCCESS) {
|
||||
LOGE("A request to use the channel alreay exists!");
|
||||
LOGE("A request to use the channel already exists!");
|
||||
return HC_ERR_REQUEST_EXIST;
|
||||
}
|
||||
ChannelEntry entry = {
|
||||
@@ -149,7 +149,7 @@ static char *GenRecvData(int64_t channelId, const void *data, uint32_t dataLen,
|
||||
|
||||
static bool IsServer(int sessionId)
|
||||
{
|
||||
return (GetSessionSide(sessionId) == 0) ? true : false;
|
||||
return GetSessionSide(sessionId) == 0;
|
||||
}
|
||||
|
||||
static int OnChannelOpenedCb(int sessionId, int result)
|
||||
|
||||
@@ -998,7 +998,7 @@ int32_t ProcessKeyPair(int action, const CJson *jsonParams, const char *groupId)
|
||||
LOGE("Failed to allocate authIdBuff memory!");
|
||||
return HC_ERR_ALLOC_MEMORY;
|
||||
}
|
||||
if (memcpy_s(authIdBuff.val, authIdBuff.length, authId, authIdBuff.length) != HC_SUCCESS) {
|
||||
if (memcpy_s(authIdBuff.val, authIdBuff.length, authId, authIdBuff.length) != EOK) {
|
||||
LOGE("Failed to copy authId!");
|
||||
HcFree(authIdBuff.val);
|
||||
return HC_ERR_MEMORY_COPY;
|
||||
|
||||
@@ -30,6 +30,7 @@ ohos_unittest("deviceauth_llt") {
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/common",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/transport",
|
||||
"//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
|
||||
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@@ -47,19 +48,18 @@ ohos_unittest("deviceauth_llt") {
|
||||
"${os_adapter_path}/impl/src/hc_task_thread.c",
|
||||
"${os_adapter_path}/impl/src/hc_time.c",
|
||||
"${os_adapter_path}/impl/src/linux/hc_condition.c",
|
||||
"${os_adapter_path}/impl/src/linux/hc_dev_info.c",
|
||||
"${os_adapter_path}/impl/src/linux/hc_file.c",
|
||||
"${os_adapter_path}/impl/src/linux/hc_init_protection.c",
|
||||
"${os_adapter_path}/impl/src/linux/hc_thread.c",
|
||||
"${os_adapter_path}/impl/src/linux/hc_types.c",
|
||||
]
|
||||
sources += deviceauth_files
|
||||
sources += [
|
||||
"source/deviceauth_standard_test.cpp",
|
||||
"source/deviceauth_test_mock.cpp",
|
||||
]
|
||||
sources += [ "source/deviceauth_standard_test.cpp" ]
|
||||
|
||||
deps = [
|
||||
"//base/security/huks/interfaces/innerkits/huks_standard/main:libhukssdk",
|
||||
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
|
||||
"//third_party/cJSON:cjson_static",
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest_main",
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DEVICEAUTH_STANDARD_MOCK_H
|
||||
#define DEVICEAUTH_STANDARD_MOCK_H
|
||||
|
||||
#include <cstdbool>
|
||||
#include <cstdint>
|
||||
#include "hc_dev_info.h"
|
||||
|
||||
void SetClient(bool tag);
|
||||
bool GetClient();
|
||||
|
||||
const char *GetStorageDirPath(void);
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -14,44 +14,730 @@
|
||||
*/
|
||||
|
||||
#include "deviceauth_standard_test.h"
|
||||
#include <ctime>
|
||||
#include <cstdint>
|
||||
#include <gtest/gtest.h>
|
||||
#include "common_defs.h"
|
||||
#include "deviceauth_test_mock.h"
|
||||
#include "device_auth.h"
|
||||
#include "device_auth_defines.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "json_utils.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace testing::ext;
|
||||
|
||||
/* test suit - GET_INSTANCE */
|
||||
class GET_INSTANCE : public testing::Test {
|
||||
#define TEST_REQ_ID 123
|
||||
#define TEST_APP_ID "TestAppId"
|
||||
|
||||
class InitDeviceAuthServiceTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase() {};
|
||||
static void TearDownTestCase() {};
|
||||
virtual void SetUp()
|
||||
{
|
||||
int32_t ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret == HC_SUCCESS, true);
|
||||
}
|
||||
virtual void TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
/* start cases */
|
||||
TEST_F(GET_INSTANCE, TC_GET_GM_INSTANCE)
|
||||
void InitDeviceAuthServiceTest::SetUpTestCase() {}
|
||||
void InitDeviceAuthServiceTest::TearDownTestCase() {}
|
||||
void InitDeviceAuthServiceTest::SetUp() {}
|
||||
void InitDeviceAuthServiceTest::TearDown() {}
|
||||
|
||||
HWTEST_F(InitDeviceAuthServiceTest, InitDeviceAuthServiceTest001, TestSize.Level0)
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class DestroyDeviceAuthServiceTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void DestroyDeviceAuthServiceTest::SetUpTestCase() {}
|
||||
void DestroyDeviceAuthServiceTest::TearDownTestCase() {}
|
||||
void DestroyDeviceAuthServiceTest::SetUp() {}
|
||||
void DestroyDeviceAuthServiceTest::TearDown() {}
|
||||
|
||||
HWTEST_F(DestroyDeviceAuthServiceTest, DestroyDeviceAuthServiceTest001, TestSize.Level0)
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
class GetGmInstanceTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GetGmInstanceTest::SetUpTestCase() {}
|
||||
void GetGmInstanceTest::TearDownTestCase() {}
|
||||
|
||||
void GetGmInstanceTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GetGmInstanceTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GetGmInstanceTest, GetGmInstanceTest001, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(GET_INSTANCE, TC_GET_GA_INSTANCE)
|
||||
class GetGaInstanceTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GetGaInstanceTest::SetUpTestCase() {}
|
||||
void GetGaInstanceTest::TearDownTestCase() {}
|
||||
|
||||
void GetGaInstanceTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GetGaInstanceTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GetGaInstanceTest, GetGaInstanceTest001, TestSize.Level0)
|
||||
{
|
||||
const GroupAuthManager *ga = GetGaInstance();
|
||||
EXPECT_NE(ga, nullptr);
|
||||
}
|
||||
|
||||
class GmRegCallbackTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmRegCallbackTest::SetUpTestCase() {}
|
||||
void GmRegCallbackTest::TearDownTestCase() {}
|
||||
|
||||
void GmRegCallbackTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmRegCallbackTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmRegCallbackTest, GmRegCallbackTest001, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
DeviceAuthCallback callback;
|
||||
int32_t ret = gm->regCallback(TEST_APP_ID, &callback);
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmUnRegCallbackTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmUnRegCallbackTest::SetUpTestCase() {}
|
||||
void GmUnRegCallbackTest::TearDownTestCase() {}
|
||||
|
||||
void GmUnRegCallbackTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmUnRegCallbackTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmUnRegCallbackTest, GmUnRegCallbackTest001, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
DeviceAuthCallback callback;
|
||||
int32_t ret = gm->regCallback(TEST_APP_ID, &callback);
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
ret = gm->unRegCallback(TEST_APP_ID);
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmRegDataChangeListenerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmRegDataChangeListenerTest::SetUpTestCase() {}
|
||||
void GmRegDataChangeListenerTest::TearDownTestCase() {}
|
||||
|
||||
void GmRegDataChangeListenerTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmRegDataChangeListenerTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmRegDataChangeListenerTest, GmRegDataChangeListenerTest001, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
DataChangeListener listener;
|
||||
int32_t ret = gm->regDataChangeListener(TEST_APP_ID, &listener);
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmUnRegDataChangeListenerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmUnRegDataChangeListenerTest::SetUpTestCase() {}
|
||||
void GmUnRegDataChangeListenerTest::TearDownTestCase() {}
|
||||
|
||||
void GmUnRegDataChangeListenerTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmUnRegDataChangeListenerTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmUnRegDataChangeListenerTest, GmUnRegDataChangeListenerTest001, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
DataChangeListener listener;
|
||||
int32_t ret = gm->regDataChangeListener(TEST_APP_ID, &listener);
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
ret = gm->unRegDataChangeListener(TEST_APP_ID);
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmCreateGroupTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmCreateGroupTest::SetUpTestCase() {}
|
||||
void GmCreateGroupTest::TearDownTestCase() {}
|
||||
|
||||
void GmCreateGroupTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmCreateGroupTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmCreateGroupTest, GmCreateGroupTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
int32_t ret = gm->createGroup(DEFAULT_OS_ACCOUNT, TEST_REQ_ID, TEST_APP_ID, NULL);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmDeleteGroupTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmDeleteGroupTest::SetUpTestCase() {}
|
||||
void GmDeleteGroupTest::TearDownTestCase() {}
|
||||
|
||||
void GmDeleteGroupTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmDeleteGroupTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmDeleteGroupTest, GmDeleteGroupTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
int32_t ret = gm->deleteGroup(DEFAULT_OS_ACCOUNT, TEST_REQ_ID, TEST_APP_ID, NULL);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmAddMemberToGroupTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmAddMemberToGroupTest::SetUpTestCase() {}
|
||||
void GmAddMemberToGroupTest::TearDownTestCase() {}
|
||||
|
||||
void GmAddMemberToGroupTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmAddMemberToGroupTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmAddMemberToGroupTest, GmAddMemberToGroupTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
int32_t ret = gm->addMemberToGroup(DEFAULT_OS_ACCOUNT, TEST_REQ_ID, TEST_APP_ID, NULL);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmDeleteMemberFromGroupTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmDeleteMemberFromGroupTest::SetUpTestCase() {}
|
||||
void GmDeleteMemberFromGroupTest::TearDownTestCase() {}
|
||||
|
||||
void GmDeleteMemberFromGroupTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmDeleteMemberFromGroupTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmDeleteMemberFromGroupTest, GmDeleteMemberFromGroupTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
int32_t ret = gm->deleteMemberFromGroup(DEFAULT_OS_ACCOUNT, TEST_REQ_ID, TEST_APP_ID, NULL);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmProcessDataTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmProcessDataTest::SetUpTestCase() {}
|
||||
void GmProcessDataTest::TearDownTestCase() {}
|
||||
|
||||
void GmProcessDataTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmProcessDataTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmProcessDataTest, GmProcessDataTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
int32_t ret = gm->processData(TEST_REQ_ID, NULL, 0);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmCheckAccessToGroupTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmCheckAccessToGroupTest::SetUpTestCase() {}
|
||||
void GmCheckAccessToGroupTest::TearDownTestCase() {}
|
||||
|
||||
void GmCheckAccessToGroupTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmCheckAccessToGroupTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmCheckAccessToGroupTest, GmCheckAccessToGroupTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
int32_t ret = gm->checkAccessToGroup(TEST_REQ_ID, TEST_APP_ID, NULL);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmGetPkInfoListTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmGetPkInfoListTest::SetUpTestCase() {}
|
||||
void GmGetPkInfoListTest::TearDownTestCase() {}
|
||||
|
||||
void GmGetPkInfoListTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmGetPkInfoListTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmGetPkInfoListTest, GmGetPkInfoListTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
char *returnData = NULL;
|
||||
uint32_t returnNum = 0;
|
||||
int32_t ret = gm->getPkInfoList(TEST_REQ_ID, TEST_APP_ID, NULL, &returnData, &returnNum);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmGetGroupInfoByIdTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmGetGroupInfoByIdTest::SetUpTestCase() {}
|
||||
void GmGetGroupInfoByIdTest::TearDownTestCase() {}
|
||||
|
||||
void GmGetGroupInfoByIdTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmGetGroupInfoByIdTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmGetGroupInfoByIdTest, GmGetGroupInfoByIdTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
char *returnData = NULL;
|
||||
int32_t ret = gm->getGroupInfoById(TEST_REQ_ID, TEST_APP_ID, NULL, &returnData);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmGetGroupInfoTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmGetGroupInfoTest::SetUpTestCase() {}
|
||||
void GmGetGroupInfoTest::TearDownTestCase() {}
|
||||
|
||||
void GmGetGroupInfoTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmGetGroupInfoTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmGetGroupInfoTest, GmGetGroupInfoTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
char *returnData = NULL;
|
||||
uint32_t returnNum = 0;
|
||||
int32_t ret = gm->getGroupInfo(TEST_REQ_ID, TEST_APP_ID, NULL, &returnData, &returnNum);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmGetJoinedGroupsTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmGetJoinedGroupsTest::SetUpTestCase() {}
|
||||
void GmGetJoinedGroupsTest::TearDownTestCase() {}
|
||||
|
||||
void GmGetJoinedGroupsTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmGetJoinedGroupsTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmGetJoinedGroupsTest, GmGetJoinedGroupsTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
char *returnData = NULL;
|
||||
uint32_t returnNum = 0;
|
||||
int32_t ret = gm->getJoinedGroups(TEST_REQ_ID, TEST_APP_ID, IDENTICAL_ACCOUNT_GROUP, &returnData, &returnNum);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmGetRelatedGroupsTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmGetRelatedGroupsTest::SetUpTestCase() {}
|
||||
void GmGetRelatedGroupsTest::TearDownTestCase() {}
|
||||
|
||||
void GmGetRelatedGroupsTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmGetRelatedGroupsTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmGetRelatedGroupsTest, GmGetRelatedGroupsTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
char *returnData = NULL;
|
||||
uint32_t returnNum = 0;
|
||||
int32_t ret = gm->getRelatedGroups(TEST_REQ_ID, TEST_APP_ID, NULL, &returnData, &returnNum);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmGetDeviceInfoByIdTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmGetDeviceInfoByIdTest::SetUpTestCase() {}
|
||||
void GmGetDeviceInfoByIdTest::TearDownTestCase() {}
|
||||
|
||||
void GmGetDeviceInfoByIdTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmGetDeviceInfoByIdTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmGetDeviceInfoByIdTest, GmGetDeviceInfoByIdTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
char *returnData = NULL;
|
||||
int32_t ret = gm->getDeviceInfoById(TEST_REQ_ID, TEST_APP_ID, NULL, NULL, &returnData);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmGetTrustedDevicesTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmGetTrustedDevicesTest::SetUpTestCase() {}
|
||||
void GmGetTrustedDevicesTest::TearDownTestCase() {}
|
||||
|
||||
void GmGetTrustedDevicesTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmGetTrustedDevicesTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmGetTrustedDevicesTest, GmGetTrustedDevicesTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
char *returnData = NULL;
|
||||
uint32_t returnNum = 0;
|
||||
int32_t ret = gm->getTrustedDevices(TEST_REQ_ID, TEST_APP_ID, NULL, &returnData, &returnNum);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GmIsDeviceInGroupTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GmIsDeviceInGroupTest::SetUpTestCase() {}
|
||||
void GmIsDeviceInGroupTest::TearDownTestCase() {}
|
||||
|
||||
void GmIsDeviceInGroupTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GmIsDeviceInGroupTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GmIsDeviceInGroupTest, GmIsDeviceInGroupTest002, TestSize.Level0)
|
||||
{
|
||||
const DeviceGroupManager *gm = GetGmInstance();
|
||||
EXPECT_NE(gm, nullptr);
|
||||
bool ret = gm->isDeviceInGroup(TEST_REQ_ID, TEST_APP_ID, NULL, NULL);
|
||||
EXPECT_NE(ret, true);
|
||||
}
|
||||
|
||||
class GaAuthDeviceTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GaAuthDeviceTest::SetUpTestCase() {}
|
||||
void GaAuthDeviceTest::TearDownTestCase() {}
|
||||
|
||||
void GaAuthDeviceTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GaAuthDeviceTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GaAuthDeviceTest, GaAuthDeviceTest002, TestSize.Level0)
|
||||
{
|
||||
const GroupAuthManager *ga = GetGaInstance();
|
||||
EXPECT_NE(ga, nullptr);
|
||||
int32_t ret = ga->authDevice(DEFAULT_OS_ACCOUNT, TEST_REQ_ID, NULL, NULL);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
class GaProcessDataTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
void GaProcessDataTest::SetUpTestCase() {}
|
||||
void GaProcessDataTest::TearDownTestCase() {}
|
||||
|
||||
void GaProcessDataTest::SetUp()
|
||||
{
|
||||
int ret = InitDeviceAuthService();
|
||||
EXPECT_EQ(ret, HC_SUCCESS);
|
||||
}
|
||||
|
||||
void GaProcessDataTest::TearDown()
|
||||
{
|
||||
DestroyDeviceAuthService();
|
||||
}
|
||||
|
||||
HWTEST_F(GaProcessDataTest, GaProcessDataTest002, TestSize.Level0)
|
||||
{
|
||||
const GroupAuthManager *ga = GetGaInstance();
|
||||
EXPECT_NE(ga, nullptr);
|
||||
int32_t ret = ga->processData(TEST_REQ_ID, NULL, 0, NULL);
|
||||
EXPECT_NE(ret, HC_SUCCESS);
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "deviceauth_test_mock.h"
|
||||
#include "iostream"
|
||||
#include <cstring>
|
||||
#include "securec.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static bool g_testForClient = false;
|
||||
|
||||
void SetClient(bool tag)
|
||||
{
|
||||
g_testForClient = tag;
|
||||
}
|
||||
|
||||
bool GetClient()
|
||||
{
|
||||
return g_testForClient;
|
||||
}
|
||||
|
||||
int32_t HcGetUdid(uint8_t *udid, int32_t udidLen)
|
||||
{
|
||||
const char *clientUdid = "D6350E39AD8F11963C181BEEDC11AC85158E04466B68F1F4E6D895237E0FE81C";
|
||||
const char *serverUdid = "ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00";
|
||||
if (g_testForClient) {
|
||||
(void)memcpy_s(udid, udidLen - 1, clientUdid, strlen(clientUdid));
|
||||
return 0;
|
||||
}
|
||||
(void)memcpy_s(udid, udidLen - 1, serverUdid, strlen(serverUdid));
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *GetStoragePath(void)
|
||||
{
|
||||
return "/data/data/deviceauth/hcgroup.dat";
|
||||
}
|
||||
|
||||
const char *GetStorageDirPath(void)
|
||||
{
|
||||
#ifndef LITE_DEVICE
|
||||
const char *storageFile = "/data/data/deviceauth";
|
||||
#else
|
||||
const char *storageFile = "/storage/deviceauth";
|
||||
#endif
|
||||
return storageFile;
|
||||
}
|
||||
Reference in New Issue
Block a user