From 9b4f3111228cdc9d48378aeea07d643920758467 Mon Sep 17 00:00:00 2001 From: Kemin <541416002@qq.com> Date: Thu, 17 Nov 2022 20:46:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5device=5Fattest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mini/src/attest_framework_client_mini.c | 2 +- .../src/service/attest_framework_feature.c | 2 +- .../core/adapter/attest_adapter_mock.c | 2 +- .../services/core/attest/attest_service.c | 9 ++++--- .../core/attest/attest_service_active.c | 6 ++--- .../core/attest/attest_service_auth.c | 6 ++--- .../core/attest/attest_service_challenge.c | 2 +- .../core/attest/attest_service_reset.c | 4 +-- .../services/core/attest_entry.c | 17 +++++------- .../services/core/attest_entry.h | 2 +- .../include/adapter/attest_adapter_mock.h | 4 +-- .../{attest_error_code.h => attest_error.h} | 0 .../services/core/include/attest_type.h | 2 +- .../core/include/utils/attest_utils_log.h | 2 +- .../services/core/network/attest_tls.c | 2 +- .../services/core/security/attest_security.c | 5 +++- .../core/security/attest_security_ticket.c | 2 +- .../core/security/attest_security_token.c | 2 +- .../services/core/utils/attest_utils.c | 1 - .../services/core/utils/attest_utils_file.c | 26 +++++++++---------- .../services/core/utils/attest_utils_list.c | 2 +- .../services/core/utils/attest_utils_log.c | 2 +- device_attest_lite/test/data/tokenA | 1 + 23 files changed, 50 insertions(+), 53 deletions(-) rename device_attest_lite/services/core/include/{attest_error_code.h => attest_error.h} (100%) create mode 100644 device_attest_lite/test/data/tokenA diff --git a/device_attest_lite/framework/mini/src/attest_framework_client_mini.c b/device_attest_lite/framework/mini/src/attest_framework_client_mini.c index eee9b2e..5ea5335 100644 --- a/device_attest_lite/framework/mini/src/attest_framework_client_mini.c +++ b/device_attest_lite/framework/mini/src/attest_framework_client_mini.c @@ -24,7 +24,7 @@ int32_t StartDevAttestTask(void) attr.stack_size = LITEOS_M_STACK_SIZE; attr.priority = osPriorityNormal; attr.name = ATTEST_TASK_THREAD_NAME; - if (osThreadNew((osThreadFunc_t)DevAttestTask, NULL, &attr) == NULL) { + if (osThreadNew((osThreadFunc_t)AttestTask, NULL, &attr) == NULL) { return DEVATTEST_FAIL; } return DEVATTEST_SUCCESS; diff --git a/device_attest_lite/framework/small/src/service/attest_framework_feature.c b/device_attest_lite/framework/small/src/service/attest_framework_feature.c index 840bf52..f6b415f 100644 --- a/device_attest_lite/framework/small/src/service/attest_framework_feature.c +++ b/device_attest_lite/framework/small/src/service/attest_framework_feature.c @@ -149,7 +149,7 @@ static int32_t Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req int32_t ret = DEVATTEST_SUCCESS; switch (funcId) { case ATTEST_FRAMEWORK_MSG_PROC: - DevAttestTask(); + AttestTask(); WriteInt32(reply, DEVATTEST_SUCCESS); break; case ATTEST_FRAMEWORK_MSG_QUERY: diff --git a/device_attest_lite/services/core/adapter/attest_adapter_mock.c b/device_attest_lite/services/core/adapter/attest_adapter_mock.c index 7ac13f9..a749e0c 100644 --- a/device_attest_lite/services/core/adapter/attest_adapter_mock.c +++ b/device_attest_lite/services/core/adapter/attest_adapter_mock.c @@ -64,7 +64,7 @@ int32_t SendChallMsgStub(ATTEST_ACTION_TYPE actionType, char** respMsg) return ret; } -int32_t SendAttestMsgStub(ATTEST_ACTION_TYPE actionType, char **respMsg) +int32_t SendDevAttestStub(ATTEST_ACTION_TYPE actionType, char **respMsg) { if (respMsg == NULL || actionType >= ATTEST_ACTION_MAX) { return ATTEST_ERR; diff --git a/device_attest_lite/services/core/attest/attest_service.c b/device_attest_lite/services/core/attest/attest_service.c index e5b40e6..914d5bb 100644 --- a/device_attest_lite/services/core/attest/attest_service.c +++ b/device_attest_lite/services/core/attest/attest_service.c @@ -30,6 +30,7 @@ #include "attest_service_challenge.h" #include "attest_network.h" #include "attest_service.h" +#include "attest_service_device.h" pthread_mutex_t g_mtxAttest = PTHREAD_MUTEX_INITIALIZER; @@ -153,7 +154,7 @@ static int32_t ActiveToken(AuthResult* authResult) ATTEST_LOG_ERROR("[ActiveToken] Invalid parameter"); return ATTEST_ERR; } - ATTEST_LOG_DEBUG("[ActiveToken] Flush token begin."); + int32_t ret = FlushToken(authResult); if (ret != ATTEST_OK) { ATTEST_LOG_ERROR("[ActiveToken] Flush Token failed, ret = %d.", ret); @@ -198,7 +199,7 @@ static int32_t ActiveToken(AuthResult* authResult) static int32_t ProcAttestImpl(void) { - ATTEST_LOG_DEBUG("[ProcAttestImpl] Proc begin."); + ATTEST_LOG_DEBUG("[ProcAttestImpl] Proc attest begin."); int32_t ret = InitSysData(); // 初始化系统参数 if (ret != ATTEST_OK) { @@ -269,7 +270,7 @@ static int32_t ProcAttestImpl(void) // 结果保存到启动子系统parameter,方便展示 ret = FlushAttestStatusPara(authResult->authStatus); if (ret != ATTEST_OK) { - ATTEST_LOG_ERROR("[ProcAttestImpl] Flush para failed, ret = %d.", ret); + ATTEST_LOG_ERROR("[ProcAttestImpl] Flush attest para failed, ret = %d.", ret); } ret = GetAttestStatusPara(); if (ret != ATTEST_OK) { @@ -318,7 +319,7 @@ int32_t ProcAttest(void) static int32_t QueryAttestStatusImpl(int32_t* authResult, int32_t* softwareResult, char** ticket) { - ATTEST_LOG_DEBUG("[QueryAttestStatusImpl] Query status begin."); + ATTEST_LOG_DEBUG("[QueryAttestStatusImpl] Query attest status begin."); if (authResult == NULL || softwareResult == NULL || ticket == NULL) { return ATTEST_ERR; } diff --git a/device_attest_lite/services/core/attest/attest_service_active.c b/device_attest_lite/services/core/attest/attest_service_active.c index aa60ebd..5023bb6 100644 --- a/device_attest_lite/services/core/attest/attest_service_active.c +++ b/device_attest_lite/services/core/attest/attest_service_active.c @@ -20,10 +20,10 @@ #include "attest_dfx.h" #include "attest_security.h" #include "attest_service_device.h" -#include "attest_security_token.h" #include "attest_network.h" #include "attest_adapter_mock.h" #include "attest_service_active.h" +#include "attest_security_token.h" int32_t GenActiveMsg(AuthResult* authResult, const ChallengeResult* challengeResult, DevicePacket** devPacket) { @@ -76,7 +76,7 @@ int32_t SendActiveMsg(const DevicePacket* devicePacket, char** respMsg) { ATTEST_LOG_DEBUG("[SendActiveMsg] Begin."); if (ATTEST_MOCK_NETWORK_STUB_FLAG) { - return SendAttestMsgStub(ATTEST_ACTION_ACTIVATE, respMsg); + return SendDevAttestStub(ATTEST_ACTION_ACTIVATE, respMsg); } if (devicePacket == NULL || respMsg == NULL) { ATTEST_LOG_ERROR("[SendActiveMsg] Input paramter is null."); @@ -85,7 +85,7 @@ int32_t SendActiveMsg(const DevicePacket* devicePacket, char** respMsg) char* recvMsg = NULL; uint32_t ret = SendAttestMsg(devicePacket, ATTEST_ACTION_ACTIVATE, &recvMsg); if (ret != ATTEST_OK) { - ATTEST_LOG_ERROR("[SendActiveMsg] Send Msg failed."); + ATTEST_LOG_ERROR("[SendActiveMsg] Send AttestMsg failed."); return ATTEST_ERR; } *respMsg = recvMsg; diff --git a/device_attest_lite/services/core/attest/attest_service_auth.c b/device_attest_lite/services/core/attest/attest_service_auth.c index 360a510..b0dff27 100644 --- a/device_attest_lite/services/core/attest/attest_service_auth.c +++ b/device_attest_lite/services/core/attest/attest_service_auth.c @@ -369,7 +369,7 @@ int32_t CheckVersionChanged(AuthStatus* authStatus) } char* versionIdFromOs = AttestGetVersionId(); if (versionIdFromOs == NULL) { - ATTEST_LOG_ERROR("[CheckVersionChanged] GetVersionId fail"); + ATTEST_LOG_ERROR("[CheckVersionChanged] Attest GetVersionId is null"); return ATTEST_ERR; } @@ -710,7 +710,7 @@ int32_t SendAuthMsg(const DevicePacket* devicePacket, char** respMsg) { ATTEST_LOG_DEBUG("[SendAuthMsg] Begin."); if (ATTEST_MOCK_NETWORK_STUB_FLAG) { - return SendAttestMsgStub(ATTEST_ACTION_AUTHORIZE, respMsg); + return SendDevAttestStub(ATTEST_ACTION_AUTHORIZE, respMsg); } if (devicePacket == NULL || respMsg == NULL) { ATTEST_LOG_ERROR("[SendAuthMsg] Invalid parameter"); @@ -719,7 +719,7 @@ int32_t SendAuthMsg(const DevicePacket* devicePacket, char** respMsg) char* recvMsg = NULL; uint32_t ret = SendAttestMsg(devicePacket, ATTEST_ACTION_AUTHORIZE, &recvMsg); if (ret != ATTEST_OK) { - ATTEST_LOG_ERROR("[SendAuthMsg] Send Msg failed"); + ATTEST_LOG_ERROR("[SendAuthMsg] Send AttestMsg failed"); return ATTEST_ERR; } *respMsg = recvMsg; diff --git a/device_attest_lite/services/core/attest/attest_service_challenge.c b/device_attest_lite/services/core/attest/attest_service_challenge.c index 2215ca9..205b5c5 100644 --- a/device_attest_lite/services/core/attest/attest_service_challenge.c +++ b/device_attest_lite/services/core/attest/attest_service_challenge.c @@ -72,7 +72,7 @@ static int32_t SendChallMsg(const DevicePacket* devicePacket, char** respMsg, AT char* recvMsg = NULL; uint32_t ret = SendAttestMsg(devicePacket, ATTEST_ACTION_CHALLENGE, &recvMsg); if (ret != ATTEST_OK) { - ATTEST_LOG_ERROR("[SendChallMsg] Send Msg failed"); + ATTEST_LOG_ERROR("[SendChallMsg] Send AttestMsg failed"); return ATTEST_ERR; } *respMsg = recvMsg; diff --git a/device_attest_lite/services/core/attest/attest_service_reset.c b/device_attest_lite/services/core/attest/attest_service_reset.c index 886348f..23fefae 100644 --- a/device_attest_lite/services/core/attest/attest_service_reset.c +++ b/device_attest_lite/services/core/attest/attest_service_reset.c @@ -63,7 +63,7 @@ int32_t SendResetMsg(const DevicePacket* devicePacket, char** respMsg) { ATTEST_LOG_DEBUG("[SendResetMsg] Begin."); if (ATTEST_MOCK_NETWORK_STUB_FLAG) { - return SendAttestMsgStub(ATTEST_ACTION_RESET, respMsg); + return SendDevAttestStub(ATTEST_ACTION_RESET, respMsg); } if (devicePacket == NULL || respMsg == NULL) { ATTEST_LOG_ERROR("[SendResetMsg] Invalid parameter"); @@ -72,7 +72,7 @@ int32_t SendResetMsg(const DevicePacket* devicePacket, char** respMsg) char* recvMsg = NULL; uint32_t ret = SendAttestMsg(devicePacket, ATTEST_ACTION_RESET, &recvMsg); if (ret != ATTEST_OK) { - ATTEST_LOG_ERROR("[SendResetMsg] Send Msg failed"); + ATTEST_LOG_ERROR("[SendResetMsg] Send AttestMsg failed"); return ATTEST_ERR; } *respMsg = recvMsg; diff --git a/device_attest_lite/services/core/attest_entry.c b/device_attest_lite/services/core/attest_entry.c index ea4eab3..412514d 100644 --- a/device_attest_lite/services/core/attest_entry.c +++ b/device_attest_lite/services/core/attest_entry.c @@ -39,7 +39,7 @@ static int CreateAttestThread(void(*run)(void *), void *argv, const char *name, return ATTEST_OK; } -static void AttestTask(void *argv) +static void AttestTaskThread(void *argv) { AttestTaskCallback cb = (AttestTaskCallback)argv; cb(); @@ -57,7 +57,7 @@ static void AttestAuthCallBack(void *argv) } g_ProcAttestTimerId = NULL; } - if (CreateAttestThread(AttestTask, (void *)ProcAttest, ATTEST_CALLBACK_THREAD_NAME, g_ProcAttestTimerId) != ATTEST_OK) { + if (CreateAttestThread(AttestTaskThread, (void *)ProcAttest, ATTEST_CALLBACK_THREAD_NAME, g_ProcAttestTimerId) != ATTEST_OK) { ATTEST_LOG_ERROR("[AttestAuthCallBack] CreateAttestThread return failed"); } return; @@ -74,24 +74,21 @@ static void AttestAuthCallBack(void *argv) } #endif - -int32_t DevAttestTask(void) +int32_t AttestTask(void) { - ATTEST_LOG_INFO("[DevAttestTask] Begin."); - + ATTEST_LOG_INFO("[AttestTask] Begin."); // 执行主流程代码 int32_t ret = ProcAttest(); if (ret != ATTEST_OK) { - ATTEST_LOG_ERROR("[DevAttestTask] Proc failed ret = %d.", ret); + ATTEST_LOG_ERROR("[AttestTask] Proc failed ret = %d.", ret); } // 创建主流程定时器 ret = AttestCreateTimerTask(ATTEST_TIMER_TYPE_PERIOD, EXPIRED_INTERVAL, &AttestAuthCallBack, NULL, &g_ProcAttestTimerId); - if (ret != ATTEST_OK) { - ATTEST_LOG_ERROR("[DevAttestTask] Create Periodic TimerTask return ret = %d.", ret); + ATTEST_LOG_ERROR("[AttestTask] Create Periodic TimerTask return ret = %d.", ret); } - ATTEST_LOG_INFO("[DevAttestTask] End."); + ATTEST_LOG_INFO("[AttestTask] End."); return ret; } diff --git a/device_attest_lite/services/core/attest_entry.h b/device_attest_lite/services/core/attest_entry.h index 941eade..3545e0e 100644 --- a/device_attest_lite/services/core/attest_entry.h +++ b/device_attest_lite/services/core/attest_entry.h @@ -34,7 +34,7 @@ extern "C" { #define ATTEST_CALLBACK_THREAD_NAME "AttestAuth" -int32_t DevAttestTask(void); +int32_t AttestTask(void); int32_t QueryAttest(int32_t* authResult, int32_t* softwareResult, char** ticket); diff --git a/device_attest_lite/services/core/include/adapter/attest_adapter_mock.h b/device_attest_lite/services/core/include/adapter/attest_adapter_mock.h index 5e16844..012a330 100644 --- a/device_attest_lite/services/core/include/adapter/attest_adapter_mock.h +++ b/device_attest_lite/services/core/include/adapter/attest_adapter_mock.h @@ -16,8 +16,6 @@ #ifndef ATTEST_ADAPTER_MOCK_H #define ATTEST_ADAPTER_MOCK_H -#include "attest_type.h" - #ifdef __cplusplus #if __cplusplus extern "C" { @@ -52,7 +50,7 @@ extern "C" { int32_t SendChallMsgStub(ATTEST_ACTION_TYPE actionType, char** respMsg); -int32_t SendAttestMsgStub(ATTEST_ACTION_TYPE actionType, char** respMsg); +int32_t SendDevAttestStub(ATTEST_ACTION_TYPE actionType, char** respMsg); char* OsGetVersionIdStub(void); diff --git a/device_attest_lite/services/core/include/attest_error_code.h b/device_attest_lite/services/core/include/attest_error.h similarity index 100% rename from device_attest_lite/services/core/include/attest_error_code.h rename to device_attest_lite/services/core/include/attest_error.h diff --git a/device_attest_lite/services/core/include/attest_type.h b/device_attest_lite/services/core/include/attest_type.h index c84d460..7f05890 100644 --- a/device_attest_lite/services/core/include/attest_type.h +++ b/device_attest_lite/services/core/include/attest_type.h @@ -27,7 +27,7 @@ #include "cJSON.h" #include "limits.h" #include "securec.h" -#include "attest_error_code.h" +#include "attest_error.h" #ifdef __cplusplus #if __cplusplus diff --git a/device_attest_lite/services/core/include/utils/attest_utils_log.h b/device_attest_lite/services/core/include/utils/attest_utils_log.h index 73ebcfe..c9e8f93 100644 --- a/device_attest_lite/services/core/include/utils/attest_utils_log.h +++ b/device_attest_lite/services/core/include/utils/attest_utils_log.h @@ -34,7 +34,7 @@ typedef enum { #define ATTEST_LOG_STR_LEM 256 -#define ATTESTLOG_LABEL "ATTEST" +#define ATTESTLOG_LABEL "DEVATTEST" void AttestLog(AttestLogLevel logLevel, const char* fmt, ...); diff --git a/device_attest_lite/services/core/network/attest_tls.c b/device_attest_lite/services/core/network/attest_tls.c index a1e3e6e..fd5db07 100644 --- a/device_attest_lite/services/core/network/attest_tls.c +++ b/device_attest_lite/services/core/network/attest_tls.c @@ -14,7 +14,7 @@ */ #include "attest_utils_log.h" -#include "attest_error_code.h" +#include "attest_error.h" #include "attest_tls.h" const unsigned char GLOBALSIGN_ROOT_CA_R3_DER[] = { diff --git a/device_attest_lite/services/core/security/attest_security.c b/device_attest_lite/services/core/security/attest_security.c index 9d94d62..2961355 100644 --- a/device_attest_lite/services/core/security/attest_security.c +++ b/device_attest_lite/services/core/security/attest_security.c @@ -15,7 +15,7 @@ #include #include "securec.h" -#include "attest_error_code.h" +#include "attest_error.h" #include "attest_adapter.h" #include "attest_utils.h" #include "attest_utils_log.h" @@ -78,6 +78,9 @@ void GetSalt(uint8_t* salt, uint32_t saltLen) } // temp右移8bits salt[i] = (uint8_t)((temp >> ((i % randomNumBytes) * offsetBits)) & 0xff); + if (salt[i] == 0) { + salt[i]++; + } } } diff --git a/device_attest_lite/services/core/security/attest_security_ticket.c b/device_attest_lite/services/core/security/attest_security_ticket.c index ce36d5d..8633067 100644 --- a/device_attest_lite/services/core/security/attest_security_ticket.c +++ b/device_attest_lite/services/core/security/attest_security_ticket.c @@ -15,7 +15,7 @@ #include #include "securec.h" -#include "attest_error_code.h" +#include "attest_error.h" #include "attest_adapter.h" #include "attest_utils_log.h" #include "attest_security.h" diff --git a/device_attest_lite/services/core/security/attest_security_token.c b/device_attest_lite/services/core/security/attest_security_token.c index 8d726dc..e133145 100644 --- a/device_attest_lite/services/core/security/attest_security_token.c +++ b/device_attest_lite/services/core/security/attest_security_token.c @@ -15,7 +15,7 @@ #include #include "securec.h" -#include "attest_error_code.h" +#include "attest_error.h" #include "attest_adapter.h" #include "attest_utils_log.h" #include "attest_dfx.h" diff --git a/device_attest_lite/services/core/utils/attest_utils.c b/device_attest_lite/services/core/utils/attest_utils.c index 590e89c..6b75e8b 100644 --- a/device_attest_lite/services/core/utils/attest_utils.c +++ b/device_attest_lite/services/core/utils/attest_utils.c @@ -23,7 +23,6 @@ #include "attest_utils_memleak.h" #include "attest_utils.h" -#define HEX_LEN_PER_BYTE 2 // 16进制1字节占用长度 #define DEV_BUF_LENGTH 3 #define HASH_LENGTH 32 diff --git a/device_attest_lite/services/core/utils/attest_utils_file.c b/device_attest_lite/services/core/utils/attest_utils_file.c index f13d8ad..413b821 100644 --- a/device_attest_lite/services/core/utils/attest_utils_file.c +++ b/device_attest_lite/services/core/utils/attest_utils_file.c @@ -182,18 +182,18 @@ int32_t GetFileSize(const char* path, const char* fileName, uint32_t* result) char* formatPath = realpath(filePath, NULL); ATTEST_MEM_FREE(filePath); if (formatPath == NULL) { - ATTEST_LOG_ERROR("[GetFileSize] Invalid path"); + ATTEST_LOG_ERROR("[GetFileSize] Invalid path of %s", path); return ATTEST_ERR; } FILE* fp = fopen(formatPath, "r"); if (fp == NULL) { - ATTEST_LOG_ERROR("[GetFileSize] open file failed"); + ATTEST_LOG_ERROR("[GetFileSize] open file %s failed", formatPath); free(formatPath); return ATTEST_ERR; } if (fseek(fp, 0, SEEK_END) < 0) { - ATTEST_LOG_ERROR("[GetFileSize] seek file failed"); + ATTEST_LOG_ERROR("[GetFileSize] seek file %s failed", formatPath); free(formatPath); (void)fclose(fp); return ATTEST_ERR; @@ -220,13 +220,13 @@ int32_t WriteFile(const char* path, const char* fileName, const char* data, uint char* formatPath = realpath(filePath, NULL); ATTEST_MEM_FREE(filePath); if (formatPath == NULL) { - ATTEST_LOG_ERROR("[WriteFile] Invalid path"); + ATTEST_LOG_ERROR("[WriteFile] Invalid path of %s", path); return ATTEST_ERR; } FILE* fp = fopen(formatPath, "wb+"); if (fp == NULL) { - ATTEST_LOG_ERROR("[WriteFile] open file failed"); + ATTEST_LOG_ERROR("[WriteFile] open file %s failed", formatPath); free(formatPath); return ATTEST_ERR; } @@ -236,7 +236,7 @@ int32_t WriteFile(const char* path, const char* fileName, const char* data, uint return ATTEST_ERR; } if (fwrite(data, dataLen, 1, fp) != 1) { - ATTEST_LOG_ERROR("[WriteFile] write file failed"); + ATTEST_LOG_ERROR("[WriteFile] write file %s failed", formatPath); free(formatPath); (void)fclose(fp); return ATTEST_ERR; @@ -268,18 +268,18 @@ int32_t ReadFile(const char* path, const char* fileName, char* buffer, uint32_t char* formatPath = realpath(filePath, NULL); ATTEST_MEM_FREE(filePath); if (formatPath == NULL) { - ATTEST_LOG_ERROR("[ReadFile] Invalid path or file not exist"); + ATTEST_LOG_ERROR("[ReadFile] Invalid path of %s or file %s not exist", path, fileName); return ATTEST_ERR; } FILE* fp = fopen(formatPath, "rb"); if (fp == NULL) { - ATTEST_LOG_ERROR("[ReadFile] open file failed"); + ATTEST_LOG_ERROR("[ReadFile] open file %s failed", formatPath); free(formatPath); return ATTEST_ERR; } if (fread(buffer, fileSize, 1, fp) != 1) { - ATTEST_LOG_ERROR("[ReadFile] read file data from device failed"); + ATTEST_LOG_ERROR("[ReadFile] read file %s data from device failed", formatPath); free(formatPath); (void)fclose(fp); return ATTEST_ERR; @@ -297,7 +297,7 @@ int32_t CreateFile(const char* path, const char* fileName) char* formatPath = realpath(path, NULL); if (formatPath == NULL) { - ATTEST_LOG_ERROR("[CreateFile] Invalid path or file not exist"); + ATTEST_LOG_ERROR("[CreateFile] Invalid path of %s or file %s not exist", path, fileName); return ATTEST_ERR; } uint32_t realPathLen = strlen(formatPath) + 1 + strlen(fileName) + 1; @@ -326,22 +326,20 @@ int32_t CreateFile(const char* path, const char* fileName) return ATTEST_OK; } -bool IsFileExist(const char* path, const char* fileName) +bool IsFileExist(const char* path, const char* fileName) { if (path == NULL || fileName == NULL) { return false; } - char* filePath = GenFilePath(path, fileName); if (filePath == NULL) { ATTEST_LOG_ERROR("[IsFileExist] Generate file path failed"); return false; } - char* formatPath = realpath(filePath, NULL); ATTEST_MEM_FREE(filePath); if (formatPath == NULL) { - ATTEST_LOG_ERROR("[IsFileExist] Invalid path or file not exist"); + ATTEST_LOG_ERROR("[IsFileExist] Invalid path of %s or file %s not exist", path, fileName); return false; } diff --git a/device_attest_lite/services/core/utils/attest_utils_list.c b/device_attest_lite/services/core/utils/attest_utils_list.c index 27555dc..7408e02 100644 --- a/device_attest_lite/services/core/utils/attest_utils_list.c +++ b/device_attest_lite/services/core/utils/attest_utils_list.c @@ -16,7 +16,7 @@ #include #include #include "string.h" -#include "attest_error_code.h" +#include "attest_error.h" #include "attest_utils.h" #include "attest_utils_list.h" diff --git a/device_attest_lite/services/core/utils/attest_utils_log.c b/device_attest_lite/services/core/utils/attest_utils_log.c index d4c62e6..54b2f3b 100644 --- a/device_attest_lite/services/core/utils/attest_utils_log.c +++ b/device_attest_lite/services/core/utils/attest_utils_log.c @@ -106,7 +106,7 @@ void AttestLogAnonyStr(AttestLogLevel logLevel, const char* fmt, const char* str ret = sprintf_s(outStr, sizeof(outStr), fmt, strDup); ATTEST_MEM_FREE(strDup); if (ret < 0) { - AttestLogPrint(logLevel, "[AttestLogAnonyStr] anony str length error."); + AttestLogPrint(logLevel, "[AttestLogAnonyStr] Attest anony str length error."); return; } AttestLogPrint(logLevel, outStr); diff --git a/device_attest_lite/test/data/tokenA b/device_attest_lite/test/data/tokenA new file mode 100644 index 0000000..a2582ff --- /dev/null +++ b/device_attest_lite/test/data/tokenA @@ -0,0 +1 @@ +6PkCJZDsUfuqqdvxTLv8ZH+FqASsUInUV4y9IPLHtPyJt0v0RrwtVaLHpEunfMjD,yCbOb5Y3M4sgXEqhyTqIXwDl4JEWTmEfWr3Vov0NamgsBmzMCHXsM4xH3pNT+ZMd,XXoIPrlEu6EV+/rI,1000 \ No newline at end of file -- Gitee