From 62f6c8c6c5c2c2adbd22959de677ce4247bc0ac1 Mon Sep 17 00:00:00 2001 From: maoyongxing Date: Tue, 20 Sep 2022 18:04:09 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cert_mgr_service/services/core/include/utils/cert_utils.h | 6 +++++- cert_mgr_service/services/core/utils/cert_utils_file.c | 1 - .../services/oem_adapter/src/cert_mgr_oem_file.c | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cert_mgr_service/services/core/include/utils/cert_utils.h b/cert_mgr_service/services/core/include/utils/cert_utils.h index 5ee83c0..13ffa63 100644 --- a/cert_mgr_service/services/core/include/utils/cert_utils.h +++ b/cert_mgr_service/services/core/include/utils/cert_utils.h @@ -21,6 +21,10 @@ #include #include "cert_type.h" +#define CERT_CODE_FILE "__FILE__" +#define CERT_CODE_LINE 0 +#define CERT_CODE_FUNCTION "__FUNCTION__" + #ifdef __cplusplus #if __cplusplus extern "C" { @@ -35,7 +39,7 @@ void CertMemFree(void **point); void *CertMemAlloc(uint32_t size, const char* file, uint32_t line, const char* func); -#define CERT_MEM_MALLOC(size) CertMemAlloc(size, __FILE__, __LINE__, __FUNCTION__) +#define CERT_MEM_MALLOC(size) CertMemAlloc(size, CERT_CODE_FILE, CERT_CODE_LINE, CERT_CODE_FUNCTION) #define ABS(x) ((x) >= 0 ? (x) : -(x)) diff --git a/cert_mgr_service/services/core/utils/cert_utils_file.c b/cert_mgr_service/services/core/utils/cert_utils_file.c index be0b180..23d77fe 100644 --- a/cert_mgr_service/services/core/utils/cert_utils_file.c +++ b/cert_mgr_service/services/core/utils/cert_utils_file.c @@ -42,7 +42,6 @@ bool IsOverTemperatureLimit(void) return true; } } - CERT_LOG_DEBUG("[IsOverTemperatureLimit]: device's temperature = %d\n", temperature); return (temperature >= WRITE_FLASH_MAX_TEMPERATURE); } #endif diff --git a/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c b/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c index f385bb8..39df2f6 100644 --- a/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c +++ b/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c @@ -43,7 +43,6 @@ static bool OEMIsOverTemperatureLimit(void) return true; } } - CERT_LOG_INFO("OEM Adapter: device's temperature = %d", temperature); return (temperature >= WRITE_FLASH_MAX_TEMPERATURE); #else return true; -- Gitee From e67186f23c77bb81a1eab579e1800bb221cac62f Mon Sep 17 00:00:00 2001 From: maoyongxing Date: Tue, 20 Sep 2022 20:19:03 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=AE=8C=E5=96=84log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/core/adapter/cert_adapter_mock.c | 4 -- .../core/include/network/cert_network.h | 2 + .../services/core/include/utils/cert_utils.h | 8 +--- .../services/core/network/cert_network.c | 37 +++++++++---------- .../core/security/cert_security_token.c | 2 +- .../services/core/utils/cert_utils.c | 32 ---------------- .../services/core/utils/cert_utils_file.c | 26 ++++++------- 7 files changed, 32 insertions(+), 79 deletions(-) diff --git a/cert_mgr_service/services/core/adapter/cert_adapter_mock.c b/cert_mgr_service/services/core/adapter/cert_adapter_mock.c index ccba281..e9242f1 100644 --- a/cert_mgr_service/services/core/adapter/cert_adapter_mock.c +++ b/cert_mgr_service/services/core/adapter/cert_adapter_mock.c @@ -57,12 +57,10 @@ int32_t SendChallMsgStub(CERT_ACTION_TYPE actionType, char** respMsg) if (root == NULL) { return CERT_ERR; } - CERT_LOG_INFO("[SendChallMsgStub] action = %s.", root); int32_t ret = GetJsonOjectStringStub(root, CERT_MOCK_L2_CHALLENGE, respMsg); if (ret != CERT_OK) { return CERT_ERR; } - CERT_LOG_INFO("[SendChallMsgStub] respose message = %s.", *respMsg); return ret; } @@ -76,12 +74,10 @@ int32_t SendCertMsgStub(CERT_ACTION_TYPE actionType, char **respMsg) if (root == NULL) { return CERT_ERR; } - CERT_LOG_INFO("[SendCertMsgStub] root name = %s.", root); int32_t ret = GetJsonOjectStringStub(root, CERT_MOCK_L2_RESPONSE, respMsg); if (ret != CERT_OK) { return CERT_ERR; } - CERT_LOG_INFO("[SendCertMsgStub] respose message = %s.", *respMsg); return ret; } diff --git a/cert_mgr_service/services/core/include/network/cert_network.h b/cert_mgr_service/services/core/include/network/cert_network.h index 0cdd875..cb44483 100644 --- a/cert_mgr_service/services/core/include/network/cert_network.h +++ b/cert_mgr_service/services/core/include/network/cert_network.h @@ -62,6 +62,8 @@ char* BuildCoapAuthBody(DevicePacket *devPacket); char* BuildCoapActiveBody(DevicePacket *devPacket); +void PrintListNode(List *list); + #ifdef __cplusplus #if __cplusplus } diff --git a/cert_mgr_service/services/core/include/utils/cert_utils.h b/cert_mgr_service/services/core/include/utils/cert_utils.h index 13ffa63..5d7f3cf 100644 --- a/cert_mgr_service/services/core/include/utils/cert_utils.h +++ b/cert_mgr_service/services/core/include/utils/cert_utils.h @@ -21,25 +21,19 @@ #include #include "cert_type.h" -#define CERT_CODE_FILE "__FILE__" -#define CERT_CODE_LINE 0 -#define CERT_CODE_FUNCTION "__FUNCTION__" - #ifdef __cplusplus #if __cplusplus extern "C" { #endif #endif /* __cplusplus */ -void PrintBuffer(void* buff, unsigned int bufferLen); - void CertMemFree(void **point); #define CERT_MEM_FREE(pointer) CertMemFree((void **)&(pointer)) void *CertMemAlloc(uint32_t size, const char* file, uint32_t line, const char* func); -#define CERT_MEM_MALLOC(size) CertMemAlloc(size, CERT_CODE_FILE, CERT_CODE_LINE, CERT_CODE_FUNCTION) +#define CERT_MEM_MALLOC(size) CertMemAlloc(size, __FILE__, __LINE__, __FUNCTION__) #define ABS(x) ((x) >= 0 ? (x) : -(x)) diff --git a/cert_mgr_service/services/core/network/cert_network.c b/cert_mgr_service/services/core/network/cert_network.c index 1dd59c8..4fe6403 100644 --- a/cert_mgr_service/services/core/network/cert_network.c +++ b/cert_mgr_service/services/core/network/cert_network.c @@ -77,21 +77,21 @@ char *g_uriPath[CERT_ACTION_MAX] = { "device/v3/token/activate", }; -// static void PrintListNode(List *list) -// { -// if (list == NULL) { -// return; -// } -// ListNode *head = list->head; -// while (head != NULL) { -// Option* opt = (Option*)head->data; -// if (opt != NULL) { -// CERT_LOG_ERROR("[PrintListNode] opt->optionLength = %d, opt->optionType = %d, opt->optionValue = %s.", -// opt->optionLength, opt->optionType, opt->optionValue); -// } -// head = head->next; -// } -// } +void PrintListNode(List *list) +{ + if (list == NULL) { + return; + } + ListNode *head = list->head; + while (head != NULL) { + Option* opt = (Option*)head->data; + if (opt != NULL) { + CERT_LOG_ERROR_ANONY("[PrintListNode] opt->optionLength = %d, opt->optionType = %d, opt->optionValue = %s.", + opt->optionLength, opt->optionType, opt->optionValue); + } + head = head->next; + } +} DevicePacket* CreateDevicePacket(void) { @@ -279,12 +279,12 @@ char* BuildCoapChallBody(DevicePacket *postValue) } cJSON *postData = cJSON_CreateObject(); if (postData == NULL) { - CERT_LOG_ERROR("[BuildCoapChallBody] postData CreateObject fail"); + CERT_LOG_ERROR("[BuildCoapChallBody] postData CreateObject fail"); return NULL; } if (cJSON_AddStringToObject(postData, "uniqueId", postValue->udid) == NULL) { cJSON_Delete(postData); - CERT_LOG_ERROR("[BuildCoapChallBody] postData AddStringToObject fail"); + CERT_LOG_ERROR("[BuildCoapChallBody] postData AddStringToObject fail"); return NULL; } char *bodyData = cJSON_Print(postData); @@ -337,7 +337,6 @@ char* BuildCoapResetBody(DevicePacket *postValue) } char *bodyData = cJSON_Print(postData); cJSON_Delete(postData); - CERT_LOG_DEBUG("[BuildCoapResetBody] ResetBody [%u, %u]\n%s\n", strlen(bodyData), strlen(bodyData), bodyData); CERT_LOG_DEBUG("[BuildCoapResetBody] End."); return bodyData; } @@ -461,7 +460,6 @@ char* BuildCoapActiveBody(DevicePacket *postValue) } char *bodyData = cJSON_Print(postData); cJSON_Delete(postData); - CERT_LOG_DEBUG("[BuildCoapActiveBody] ActiBody [%u, %u]\n%s\n", strlen(bodyData), strlen(bodyData), bodyData); CERT_LOG_DEBUG("[BuildCoapActiveBody] End."); return bodyData; } @@ -726,7 +724,6 @@ static int32_t SendCoapMsg(DevicePacket *devPacket, const TLSSession* session, C CERT_MEM_FREE(coapMessage); return ret; } - PrintBuffer(coapMessage, coapMessageLen); int32_t i = 0; for (; i <= WISE_RETRY_CNT; i++) { ret = TLSWrite(session, (unsigned char*)coapMessage, coapMessageLen); diff --git a/cert_mgr_service/services/core/security/cert_security_token.c b/cert_mgr_service/services/core/security/cert_security_token.c index 7330a70..37fed8a 100644 --- a/cert_mgr_service/services/core/security/cert_security_token.c +++ b/cert_mgr_service/services/core/security/cert_security_token.c @@ -210,7 +210,7 @@ static int32_t GetTokenInfo(const char* tokenValue, uint8_t tokenValueLen, } ret = memcpy_s(tokenInfo->version, sizeof(tokenInfo->version), g_tokenVersion, sizeof(tokenInfo->version)); if (ret != 0) { - CERT_LOG_ERROR("[GetTokenInfo] memcpy_s tokenVersion failed"); + CERT_LOG_ERROR("[GetTokenInfo] memcpy_s tokenVersion failed"); return ERR_CERT_SECURITY_MEM_MEMCPY; } return CERT_OK; diff --git a/cert_mgr_service/services/core/utils/cert_utils.c b/cert_mgr_service/services/core/utils/cert_utils.c index 38b4025..394a20e 100644 --- a/cert_mgr_service/services/core/utils/cert_utils.c +++ b/cert_mgr_service/services/core/utils/cert_utils.c @@ -26,38 +26,6 @@ #define DEV_BUF_LENGTH 3 #define HASH_LENGTH 32 -// 以16进制打印一块内存buff -void PrintBuffer(void* buff, unsigned int bufferLen) -{ - if (buff == NULL || bufferLen == 0) { - return; - } - const int bytesPerLine = 16; - unsigned char* p = (unsigned char*)buff; - char szHex[(HEX_LEN_PER_BYTE + 1) * bytesPerLine + 1]; - - printf("-----------------print buffer begin-------------------\n"); - for (unsigned int i = 0; i < bufferLen; ++i) { - int index = 3 * (i % bytesPerLine); - if (index == 0) { - (void)memset_s(szHex, sizeof(szHex), 0, sizeof(szHex)); - } - // buff长度要多传入1个字节 - if (sprintf_s(&szHex[index], (HEX_LEN_PER_BYTE + 1 + 1), "%02x ", p[i]) < 0) { - return; - } - // 以16个字节为一行,进行打印 - if (((i + 1) % bytesPerLine) == 0) { - printf("%s\n", szHex); - } - } - // 打印最后一行未满16个字节的内容 - if ((bufferLen % bytesPerLine) != 0) { - printf("%s\n", szHex); - } - printf("------------------print buffer end-------------------\n"); -} - int32_t GetRandomNum(void) { mbedtls_ctr_drbg_context randomContext; diff --git a/cert_mgr_service/services/core/utils/cert_utils_file.c b/cert_mgr_service/services/core/utils/cert_utils_file.c index 23d77fe..149106f 100644 --- a/cert_mgr_service/services/core/utils/cert_utils_file.c +++ b/cert_mgr_service/services/core/utils/cert_utils_file.c @@ -110,13 +110,11 @@ static int32_t L0WriteFile(const char* path, const char* data, uint32_t dataLen, int32_t fd = UtilsFileOpen(path, flag, 0); if (fd < 0) { - CERT_LOG_ERROR("[L0WriteFile] : Open file failed\n"); return CERT_ERR; } int ret = 0; if (UtilsFileWrite(fd, data, dataLen) != (int32_t)dataLen) { - CERT_LOG_ERROR("[L0WriteFile] : Write data failed\n"); ret = CERT_ERR; } (void)UtilsFileClose(fd); @@ -137,13 +135,11 @@ static int32_t L0ReadFile(const char* path, char* buffer, uint32_t bufferLen) return CERT_ERR; } if (fileSize > bufferLen) { - CERT_LOG_ERROR("[L0ReadFile] : Read data over buffer length\n"); return CERT_ERR; } int32_t fd = UtilsFileOpen(path, O_EXCL_FS | O_RDWR_FS, 0); if (fd < 0) { - CERT_LOG_ERROR("[L0ReadFile] : Open file failed\n"); return CERT_ERR; } @@ -181,18 +177,18 @@ int32_t GetFileSize(const char* path, const char* fileName, uint32_t* result) char* formatPath = realpath(filePath, NULL); CERT_MEM_FREE(filePath); if (formatPath == NULL) { - CERT_LOG_ERROR("[GetFileSize] Invalid path of %s", path); + CERT_LOG_ERROR("[GetFileSize] Invalid path"); return CERT_ERR; } FILE* fp = fopen(formatPath, "r"); if (fp == NULL) { - CERT_LOG_ERROR("[GetFileSize] open file %s failed", formatPath); + CERT_LOG_ERROR("[GetFileSize] open file failed"); free(formatPath); return CERT_ERR; } if (fseek(fp, 0, SEEK_END) < 0) { - CERT_LOG_ERROR("[GetFileSize] seek file %s failed", formatPath); + CERT_LOG_ERROR("[GetFileSize] seek file failed"); free(formatPath); (void)fclose(fp); return CERT_ERR; @@ -227,18 +223,18 @@ int32_t WriteFile(const char* path, const char* fileName, const char* data, uint char* formatPath = realpath(filePath, NULL); CERT_MEM_FREE(filePath); if (formatPath == NULL) { - CERT_LOG_ERROR("[WriteFile] Invalid path of %s", path); + CERT_LOG_ERROR("[WriteFile] Invalid path"); return CERT_ERR; } FILE* fp = fopen(formatPath, "wb+"); if (fp == NULL) { - CERT_LOG_ERROR("[WriteFile] open file %s failed", formatPath); + CERT_LOG_ERROR("[WriteFile] open file failed"); free(formatPath); return CERT_ERR; } if (fwrite(data, dataLen, 1, fp) != 1) { - CERT_LOG_ERROR("[WriteFile] write file %s failed", formatPath); + CERT_LOG_ERROR("[WriteFile] write file failed"); free(formatPath); (void)fclose(fp); return CERT_ERR; @@ -278,18 +274,18 @@ int32_t ReadFile(const char* path, const char* fileName, char* buffer, uint32_t char* formatPath = realpath(filePath, NULL); CERT_MEM_FREE(filePath); if (formatPath == NULL) { - CERT_LOG_ERROR("[ReadFile] Invalid path of %s or file %s not exist", path, fileName); + CERT_LOG_ERROR("[ReadFile] Invalid path or file not exist"); return CERT_ERR; } FILE* fp = fopen(formatPath, "rb"); if (fp == NULL) { - CERT_LOG_ERROR("[ReadFile] open file %s failed", formatPath); + CERT_LOG_ERROR("[ReadFile] open file failed"); free(formatPath); return CERT_ERR; } if (fread(buffer, fileSize, 1, fp) != 1) { - CERT_LOG_ERROR("[ReadFile] read file %s data from device failed", formatPath); + CERT_LOG_ERROR("[ReadFile] read file data from device failed"); free(formatPath); (void)fclose(fp); return CERT_ERR; @@ -315,7 +311,7 @@ int32_t CreateFile(const char* path, const char* fileName) char* formatPath = realpath(path, NULL); if (formatPath == NULL) { - CERT_LOG_ERROR("[CreateFile] Invalid path of %s or file %s not exist", path, fileName); + CERT_LOG_ERROR("[CreateFile] Invalid path or file not exist"); return CERT_ERR; } uint32_t realPathLen = strlen(formatPath) + 1 + strlen(fileName) + 1; @@ -363,7 +359,7 @@ bool IsFileExist(const char* path, const char* fileName) char* formatPath = realpath(filePath, NULL); CERT_MEM_FREE(filePath); if (formatPath == NULL) { - CERT_LOG_ERROR("[IsFileExist] Invalid path of %s or file %s not exist", path, fileName); + CERT_LOG_ERROR("[IsFileExist] Invalid path or file not exist"); return false; } -- Gitee From c9403a130c35837d100f6c1e13899c027a8a3431 Mon Sep 17 00:00:00 2001 From: maoyongxing Date: Tue, 20 Sep 2022 20:21:10 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cert_mgr_service/services/core/include/network/cert_network.h | 1 + cert_mgr_service/services/core/network/cert_network.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/cert_mgr_service/services/core/include/network/cert_network.h b/cert_mgr_service/services/core/include/network/cert_network.h index cb44483..d83ad9b 100644 --- a/cert_mgr_service/services/core/include/network/cert_network.h +++ b/cert_mgr_service/services/core/include/network/cert_network.h @@ -19,6 +19,7 @@ #include #include #include "cert_channel.h" +#include "cert_utils_list.h" #ifdef __cplusplus #if __cplusplus diff --git a/cert_mgr_service/services/core/network/cert_network.c b/cert_mgr_service/services/core/network/cert_network.c index 4fe6403..c58ad80 100644 --- a/cert_mgr_service/services/core/network/cert_network.c +++ b/cert_mgr_service/services/core/network/cert_network.c @@ -32,7 +32,6 @@ #include "cert_utils.h" #include "cert_type.h" #include "cert_service_device.h" -#include "cert_utils_list.h" #include "cert_coap.h" #include "cert_coap_def.h" #include "cert_channel.h" -- Gitee From 0920dbff5006d5a6aaf48a709f7fbbc50242dd44 Mon Sep 17 00:00:00 2001 From: maoyongxing Date: Wed, 21 Sep 2022 14:57:05 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cert_mgr_service/framework/src/mini/cert_manager_interface.c | 2 +- .../framework/src/small/cert_framework_client_proxy.c | 2 +- cert_mgr_service/services/core/cert/cert_service_device.c | 2 +- cert_mgr_service/services/core/network/cert_channel.c | 2 +- cert_mgr_service/services/core/network/cert_coap.c | 3 +-- cert_mgr_service/services/core/network/cert_tls.c | 4 ++-- cert_mgr_service/services/core/utils/cert_utils_file.c | 5 +++++ .../services/oem_adapter/src/cert_mgr_oem_file.c | 1 + 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cert_mgr_service/framework/src/mini/cert_manager_interface.c b/cert_mgr_service/framework/src/mini/cert_manager_interface.c index 25fe5db..29ee080 100644 --- a/cert_mgr_service/framework/src/mini/cert_manager_interface.c +++ b/cert_mgr_service/framework/src/mini/cert_manager_interface.c @@ -36,7 +36,7 @@ int32_t GetCertStatus(CertResultInfo* certResultInfo) return CERTMANAGER_FAIL; } char* ticketStr = NULL; - int authRes = QueryCert(&certResultInfo->authResult, &certResultInfo->softwareResult, &ticketStr); + int authRes = QueryCert(&certResultInfo->authResult, &certResultInfo->softwareResult, &ticketStr); if (authRes == CERTMANAGER_SUCCESS && ticketStr != NULL) { certResultInfo->ticket = ticketStr; } diff --git a/cert_mgr_service/framework/src/small/cert_framework_client_proxy.c b/cert_mgr_service/framework/src/small/cert_framework_client_proxy.c index cbd74c6..e67ffec 100644 --- a/cert_mgr_service/framework/src/small/cert_framework_client_proxy.c +++ b/cert_mgr_service/framework/src/small/cert_framework_client_proxy.c @@ -72,7 +72,7 @@ static int CertClientQueryStatusCb(void *owner, int code, IpcIo *reply) return CERTMANAGER_FAIL; } - int32_t ret = 0; + int32_t ret; ServiceRspMsg *respInfo = (ServiceRspMsg *)owner; if (!ReadInt32(reply, &respInfo->result)) { diff --git a/cert_mgr_service/services/core/cert/cert_service_device.c b/cert_mgr_service/services/core/cert/cert_service_device.c index 132030e..b08fc58 100644 --- a/cert_mgr_service/services/core/cert/cert_service_device.c +++ b/cert_mgr_service/services/core/cert/cert_service_device.c @@ -13,12 +13,12 @@ * limitations under the License. */ +#include "parameter.h" #include "cert_type.h" #include "cert_utils.h" #include "cert_utils_log.h" #include "cert_adapter.h" #include "cert_service_device.h" -#include "parameter.h" char* g_devSysInfos[SYS_DEV_MAX] = {NULL}; const char* g_devSysInfosStr[] = { diff --git a/cert_mgr_service/services/core/network/cert_channel.c b/cert_mgr_service/services/core/network/cert_channel.c index cf21743..73d9f13 100644 --- a/cert_mgr_service/services/core/network/cert_channel.c +++ b/cert_mgr_service/services/core/network/cert_channel.c @@ -13,8 +13,8 @@ * limitations under the License. */ -#include "cert_channel.h" #include "securec.h" +#include "cert_channel.h" #include "cert_tls.h" #include "cert_utils.h" #include "cert_utils_log.h" diff --git a/cert_mgr_service/services/core/network/cert_coap.c b/cert_mgr_service/services/core/network/cert_coap.c index 52ffbd4..37d073e 100644 --- a/cert_mgr_service/services/core/network/cert_coap.c +++ b/cert_mgr_service/services/core/network/cert_coap.c @@ -13,10 +13,9 @@ * limitations under the License. */ -#include "cert_coap.h" - #include "stdlib.h" #include "securec.h" +#include "cert_coap.h" #include "cert_coap_def.h" #include "cert_utils_log.h" #include "cert_utils.h" diff --git a/cert_mgr_service/services/core/network/cert_tls.c b/cert_mgr_service/services/core/network/cert_tls.c index 880e060..86fa82a 100644 --- a/cert_mgr_service/services/core/network/cert_tls.c +++ b/cert_mgr_service/services/core/network/cert_tls.c @@ -151,8 +151,8 @@ CertItem g_commonCerts = { CertItem g_commonOtherCert[] = { { - .certDer = GLOBALSIGN_ECC_ROOT_CA_DER, - .certLen = sizeof(GLOBALSIGN_ECC_ROOT_CA_DER) + .certDer = GLOBALSIGN_ECC_ROOT_CA_DER, + .certLen = sizeof(GLOBALSIGN_ECC_ROOT_CA_DER) } }; int32_t LoadCommonCert(mbedtls_x509_crt* chain) diff --git a/cert_mgr_service/services/core/utils/cert_utils_file.c b/cert_mgr_service/services/core/utils/cert_utils_file.c index 149106f..4173302 100644 --- a/cert_mgr_service/services/core/utils/cert_utils_file.c +++ b/cert_mgr_service/services/core/utils/cert_utils_file.c @@ -42,6 +42,7 @@ bool IsOverTemperatureLimit(void) return true; } } + CERT_LOG_DEBUG("[IsOverTemperatureLimit]: device's temperature = %d\n", temperature); return (temperature >= WRITE_FLASH_MAX_TEMPERATURE); } #endif @@ -110,11 +111,13 @@ static int32_t L0WriteFile(const char* path, const char* data, uint32_t dataLen, int32_t fd = UtilsFileOpen(path, flag, 0); if (fd < 0) { + CERT_LOG_ERROR("[L0WriteFile] : Open file failed\n"); return CERT_ERR; } int ret = 0; if (UtilsFileWrite(fd, data, dataLen) != (int32_t)dataLen) { + CERT_LOG_ERROR("[L0WriteFile] : Write data failed\n"); ret = CERT_ERR; } (void)UtilsFileClose(fd); @@ -135,11 +138,13 @@ static int32_t L0ReadFile(const char* path, char* buffer, uint32_t bufferLen) return CERT_ERR; } if (fileSize > bufferLen) { + CERT_LOG_ERROR("[L0ReadFile] : Read data over buffer length\n"); return CERT_ERR; } int32_t fd = UtilsFileOpen(path, O_EXCL_FS | O_RDWR_FS, 0); if (fd < 0) { + CERT_LOG_ERROR("[L0ReadFile] : Open file failed\n"); return CERT_ERR; } diff --git a/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c b/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c index 39df2f6..f385bb8 100644 --- a/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c +++ b/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c @@ -43,6 +43,7 @@ static bool OEMIsOverTemperatureLimit(void) return true; } } + CERT_LOG_INFO("OEM Adapter: device's temperature = %d", temperature); return (temperature >= WRITE_FLASH_MAX_TEMPERATURE); #else return true; -- Gitee From 6f240626a225955001f8257d1b107c514a9c4c5c Mon Sep 17 00:00:00 2001 From: maoyongxing Date: Thu, 22 Sep 2022 10:22:44 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/src/mini/cert_manager_interface.c | 2 +- .../services/core/adapter/cert_adapter_oem.c | 1 - cert_mgr_service/services/core/cert/cert_service.c | 1 - .../services/core/cert/cert_service_active.c | 2 +- cert_mgr_service/services/core/dfx/cert_dfx.c | 2 +- .../services/core/network/cert_channel.c | 2 +- cert_mgr_service/services/core/network/cert_coap.c | 2 +- cert_mgr_service/services/core/network/cert_tls.c | 2 +- .../services/core/utils/cert_utils_file.c | 12 ++++++------ .../services/oem_adapter/src/cert_mgr_oem_file.c | 2 +- 10 files changed, 13 insertions(+), 15 deletions(-) diff --git a/cert_mgr_service/framework/src/mini/cert_manager_interface.c b/cert_mgr_service/framework/src/mini/cert_manager_interface.c index 29ee080..dee297c 100644 --- a/cert_mgr_service/framework/src/mini/cert_manager_interface.c +++ b/cert_mgr_service/framework/src/mini/cert_manager_interface.c @@ -15,8 +15,8 @@ #include -#include "cert_manager_interface.h" #include "cert_entry.h" +#include "cert_manager_interface.h" int32_t StartCertTask(void) { diff --git a/cert_mgr_service/services/core/adapter/cert_adapter_oem.c b/cert_mgr_service/services/core/adapter/cert_adapter_oem.c index 48e4bb0..3fab6bc 100644 --- a/cert_mgr_service/services/core/adapter/cert_adapter_oem.c +++ b/cert_mgr_service/services/core/adapter/cert_adapter_oem.c @@ -16,7 +16,6 @@ #include "cert_type.h" #include "cert_utils_file.h" #include "cert_adapter_oem.h" -#include "cert_utils_log.h" // 是否存在重置标记 bool OEMIsResetFlagExist(void) diff --git a/cert_mgr_service/services/core/cert/cert_service.c b/cert_mgr_service/services/core/cert/cert_service.c index e755eed..1597587 100644 --- a/cert_mgr_service/services/core/cert/cert_service.c +++ b/cert_mgr_service/services/core/cert/cert_service.c @@ -30,7 +30,6 @@ #include "cert_service_challenge.h" #include "cert_network.h" #include "cert_service.h" -#include "cert_service_device.h" pthread_mutex_t g_mtxCertMgr = PTHREAD_MUTEX_INITIALIZER; diff --git a/cert_mgr_service/services/core/cert/cert_service_active.c b/cert_mgr_service/services/core/cert/cert_service_active.c index 94ead61..a12f026 100644 --- a/cert_mgr_service/services/core/cert/cert_service_active.c +++ b/cert_mgr_service/services/core/cert/cert_service_active.c @@ -20,10 +20,10 @@ #include "cert_dfx.h" #include "cert_security.h" #include "cert_service_device.h" +#include "cert_security_token.h" #include "cert_network.h" #include "cert_adapter_mock.h" #include "cert_service_active.h" -#include "cert_security_token.h" int32_t GenActiveMsg(AuthResult* authResult, const ChallengeResult* challengeResult, DevicePacket** devPacket) { diff --git a/cert_mgr_service/services/core/dfx/cert_dfx.c b/cert_mgr_service/services/core/dfx/cert_dfx.c index 340040d..acecea6 100644 --- a/cert_mgr_service/services/core/dfx/cert_dfx.c +++ b/cert_mgr_service/services/core/dfx/cert_dfx.c @@ -15,8 +15,8 @@ #include "cert_type.h" #include "cert_utils_log.h" -#include "cert_dfx.h" #include "cert_utils.h" +#include "cert_dfx.h" // 写到buffer,统一输出。 void PrintChallengeResult(ChallengeResult* challengeResult) diff --git a/cert_mgr_service/services/core/network/cert_channel.c b/cert_mgr_service/services/core/network/cert_channel.c index 73d9f13..fcf632f 100644 --- a/cert_mgr_service/services/core/network/cert_channel.c +++ b/cert_mgr_service/services/core/network/cert_channel.c @@ -14,10 +14,10 @@ */ #include "securec.h" -#include "cert_channel.h" #include "cert_tls.h" #include "cert_utils.h" #include "cert_utils_log.h" +#include "cert_channel.h" #define MAX_REQUEST_SIZE 2048 const int32_t TLS_READ_TIMEOUT_MS = 500; // time unit is ms diff --git a/cert_mgr_service/services/core/network/cert_coap.c b/cert_mgr_service/services/core/network/cert_coap.c index 37d073e..c617261 100644 --- a/cert_mgr_service/services/core/network/cert_coap.c +++ b/cert_mgr_service/services/core/network/cert_coap.c @@ -15,10 +15,10 @@ #include "stdlib.h" #include "securec.h" -#include "cert_coap.h" #include "cert_coap_def.h" #include "cert_utils_log.h" #include "cert_utils.h" +#include "cert_coap.h" #define USHORT_MAX 0xFFFF diff --git a/cert_mgr_service/services/core/network/cert_tls.c b/cert_mgr_service/services/core/network/cert_tls.c index 86fa82a..a08fa45 100644 --- a/cert_mgr_service/services/core/network/cert_tls.c +++ b/cert_mgr_service/services/core/network/cert_tls.c @@ -13,9 +13,9 @@ * limitations under the License. */ -#include "cert_tls.h" #include "cert_utils_log.h" #include "cert_error.h" +#include "cert_tls.h" const unsigned char GLOBALSIGN_ROOT_CA_R3_DER[] = { 0X30, 0X82, 0X03, 0X5F, 0X30, 0X82, 0X02, 0X47, 0XA0, 0X03, 0X02, 0X01, diff --git a/cert_mgr_service/services/core/utils/cert_utils_file.c b/cert_mgr_service/services/core/utils/cert_utils_file.c index 4173302..2dd68a8 100644 --- a/cert_mgr_service/services/core/utils/cert_utils_file.c +++ b/cert_mgr_service/services/core/utils/cert_utils_file.c @@ -12,21 +12,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#include "cert_utils_log.h" -#include "cert_utils.h" -#include "cert_utils_file.h" - #ifdef __LITEOS_M__ #include "securec.h" #include #include #include -// CERT_L0_DEVICE_FLAG #include "utils_file.h" #include +#endif +#include "cert_utils_log.h" +#include "cert_utils.h" +#include "cert_utils_file.h" + +#ifdef __LITEOS_M__ #define WRITE_FLASH_MAX_TEMPERATURE 80 static const uint32_t MAX_FILE_BYTES_LIMIT = 5120; diff --git a/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c b/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c index f385bb8..42fc7ba 100644 --- a/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c +++ b/cert_mgr_service/services/oem_adapter/src/cert_mgr_oem_file.c @@ -16,8 +16,8 @@ #include #include "limits.h" #include "securec.h" -#include "cert_mgr_oem_file.h" #include "cert_utils_log.h" +#include "cert_mgr_oem_file.h" #ifdef __LITEOS_M__ #include -- Gitee From 147ca7cfd10f01e28f38e44e2a78fa37379329bd Mon Sep 17 00:00:00 2001 From: maoyongxing Date: Thu, 22 Sep 2022 16:20:04 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cert_mgr_service/services/core/utils/cert_utils_log.c | 2 +- cert_mgr_service/test/startup/cert_framework_client_start.c | 2 +- cert_mgr_service/test/unittest/src/cert_mock.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cert_mgr_service/services/core/utils/cert_utils_log.c b/cert_mgr_service/services/core/utils/cert_utils_log.c index e06020b..9d42f4f 100644 --- a/cert_mgr_service/services/core/utils/cert_utils_log.c +++ b/cert_mgr_service/services/core/utils/cert_utils_log.c @@ -13,10 +13,10 @@ * limitations under the License. */ -#include "securec.h" #include #include #include +#include "securec.h" #include "cert_utils.h" #include "cert_utils_log.h" diff --git a/cert_mgr_service/test/startup/cert_framework_client_start.c b/cert_mgr_service/test/startup/cert_framework_client_start.c index cdad720..5ca93ff 100644 --- a/cert_mgr_service/test/startup/cert_framework_client_start.c +++ b/cert_mgr_service/test/startup/cert_framework_client_start.c @@ -44,7 +44,7 @@ int main(void) } } HILOGI("[CLIENT MAIN] end"); - //(void)StartCertTask(); + // (void)StartCertTask(); while (1) { pause(); } diff --git a/cert_mgr_service/test/unittest/src/cert_mock.c b/cert_mgr_service/test/unittest/src/cert_mock.c index 1c6a7e4..d946e7f 100644 --- a/cert_mgr_service/test/unittest/src/cert_mock.c +++ b/cert_mgr_service/test/unittest/src/cert_mock.c @@ -144,7 +144,7 @@ int32_t WriteNetWorkMock(CertNetworkMockData *certNetworkMockData) if (ret != CERT_OK) { return CERT_ERR; } - + CERT_MEM_FREE(networkPara); return ret; } -- Gitee