diff --git a/include/syscap_define.h b/include/syscap_define.h index 4d28c17da9572b4b869807817c2cd3da0c4b6b9f..82b8b6b0c4abc861099d8eadb3c5a53aab271ab0 100644 --- a/include/syscap_define.h +++ b/include/syscap_define.h @@ -21,7 +21,7 @@ #define SINGLE_SYSCAP_LEN (256 + 17) typedef struct SystemCapabilityWithNum { - char syscapStr[SINGLE_SYSCAP_LEN]; + char str[SINGLE_SYSCAP_LEN]; uint16_t num; } SyscapWithNum; @@ -177,11 +177,12 @@ typedef enum SystemCapabilityNum { USERIAM_USERAUTH_FINGERPRINTAUTH, USERIAM_USERAUTH_PINAUTH, USERIAM_USERIDM, + SECURITY_CERTIFICATE_MANAGER, SYSCAP_NUM_MAX = 960 } SyscapNum; /* sort by enum */ -const static SyscapWithNum arraySyscap[] = { +const static SyscapWithNum g_arraySyscap[] = { {"SystemCapability.Account.AppAccount", ACCOUNT_APPACCOUNT}, {"SystemCapability.Account.OsAccount", ACCOUNT_OSACCOUNT}, {"SystemCapability.Ace.UiAppearance", ACE_UIAPPEARANCE}, @@ -331,7 +332,8 @@ const static SyscapWithNum arraySyscap[] = { {"SystemCapability.UserIAM.UserAuth.FaceAuth", USERIAM_USERAUTH_FACEAUTH}, {"SystemCapability.UserIAM.UserAuth.FingerprintAuth", USERIAM_USERAUTH_FINGERPRINTAUTH}, {"SystemCapability.UserIAM.UserAuth.PinAuth", USERIAM_USERAUTH_PINAUTH}, - {"SystemCapability.UserIAM.UserIdm", USERIAM_USERIDM} + {"SystemCapability.UserIAM.UserIdm", USERIAM_USERIDM}, + {"SystemCapability.Security.CertificateManager", SECURITY_CERTIFICATE_MANAGER} }; #endif // _SYSCAP_DEFINE_H diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index 0e2ece220051945e501b1b8a50e092e249e790bb..a42a7a5965ff8f02a8602da85572157527f4c634 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -219,9 +219,9 @@ bool DecodeOsSyscap(const char input[PCID_MAIN_BYTES], char (**output)[SINGLE_SY *output = strSyscap; for (i = 0; i < countOfSyscap; i++) { - for (j = 0; j < sizeof(arraySyscap) / sizeof(SyscapWithNum); j++) { - if (arraySyscap[j].num == indexOfSyscap[i]) { - nRet = strcpy_s(*strSyscap, SINGLE_SYSCAP_LEN, arraySyscap[j].syscapStr); + for (j = 0; j < sizeof(g_arraySyscap) / sizeof(SyscapWithNum); j++) { + if (g_arraySyscap[j].num == indexOfSyscap[i]) { + nRet = strcpy_s(*strSyscap, SINGLE_SYSCAP_LEN, g_arraySyscap[j].str); if (nRet != EOK) { printf("strcpy_s failed. error = %d\n", nRet); *outputCnt = 0; @@ -322,10 +322,10 @@ static int SetOsSysCapBitMap(uint8_t *out, uint16_t outLen, uint16_t *index, uin static cJSON *CreateWholeSyscapJsonObj(void) { - size_t numOfSyscapAll = sizeof(arraySyscap) / sizeof(SyscapWithNum); + size_t numOfSyscapAll = sizeof(g_arraySyscap) / sizeof(SyscapWithNum); cJSON *root = cJSON_CreateObject(); for (size_t i = 0; i < numOfSyscapAll; i++) { - cJSON_AddItemToObject(root, arraySyscap[i].syscapStr, cJSON_CreateNumber(arraySyscap[i].num)); + cJSON_AddItemToObject(root, g_arraySyscap[i].str, cJSON_CreateNumber(g_arraySyscap[i].num)); } return root; } @@ -378,7 +378,7 @@ FREE_SYSCAP_OUT: return ret; } -static int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *Len) +static int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *len) { uint32_t bufferLen; uint16_t sysCaptype, sysCapLength; @@ -410,7 +410,7 @@ static int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t * } *buffer = contextBuffer; - *Len = bufferLen; + *len = bufferLen; return 0; } @@ -556,6 +556,7 @@ int32_t ComparePcidString(const char *pcidString, const char *rpcidString, Compa bool priSysFound; uint32_t pcidPriSyscapLen, rpcidPriSyscapLen; uint32_t i, j, temp1, temp2; + uint32_t retFlag = 0; uint32_t pcidOsAarry[PCID_OUT_BUFFER] = {0}; uint32_t rpcidOsAarry[PCID_OUT_BUFFER] = {0}; @@ -591,7 +592,7 @@ int32_t ComparePcidString(const char *pcidString, const char *rpcidString, Compa return -1; } ret = strcpy_s(temp, sizeof(char) * SINGLE_SYSCAP_LEN, - arraySyscap[(i - 2) * INT_BIT + k].syscapStr); // 2, header of pcid & rpcid + g_arraySyscap[(i - 2) * INT_BIT + k].str); // 2, header of pcid & rpcid if (ret != EOK) { PRINT_ERR("strcpy_s failed.\n"); FreeCompareError(result); @@ -632,13 +633,13 @@ int32_t ComparePcidString(const char *pcidString, const char *rpcidString, Compa } if (versionFlag > 0) { - ret |= 0x1 << 0; + retFlag |= 0x1 << 0; } if (ossyscapFlag > 0 || prisyscapFlag > 0) { - ret |= 0x1 << 1; + retFlag |= 0x1 << 1; result->missSyscapNum = ossyscapFlag + prisyscapFlag; } - return ret; + return (int32_t)retFlag; } int32_t FreeCompareError(CompareError *result) diff --git a/src/create_pcid.c b/src/create_pcid.c index af2b2cef5ccfa54008b9b8bafa5dacc599d4f070..8710a952b7a6e35ae8589625f4fab03591dbe05a 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -158,10 +158,10 @@ static int32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename static cJSON *CreateWholeSyscapJsonObj(void) { - size_t numOfSyscapAll = sizeof(arraySyscap) / sizeof(SyscapWithNum); + size_t numOfSyscapAll = sizeof(g_arraySyscap) / sizeof(SyscapWithNum); cJSON *root = cJSON_CreateObject(); for (size_t i = 0; i < numOfSyscapAll; i++) { - cJSON_AddItemToObject(root, arraySyscap[i].syscapStr, cJSON_CreateNumber(arraySyscap[i].num)); + cJSON_AddItemToObject(root, g_arraySyscap[i].str, cJSON_CreateNumber(g_arraySyscap[i].num)); } return root; } @@ -393,9 +393,9 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) } } for (i = 0; i < countOfSyscap; i++) { - for (j = 0; j < sizeof(arraySyscap) / sizeof(SyscapWithNum); j++) { - if (arraySyscap[j].num == indexOfSyscap[i]) { - if (!cJSON_AddItemToArray(capVectorPtr, cJSON_CreateString(arraySyscap[j].syscapStr))) { + for (j = 0; j < sizeof(g_arraySyscap) / sizeof(SyscapWithNum); j++) { + if (g_arraySyscap[j].num == indexOfSyscap[i]) { + if (!cJSON_AddItemToArray(capVectorPtr, cJSON_CreateString(g_arraySyscap[j].str))) { printf("cJSON_AddItemToArray or cJSON_CreateString failed\n"); ret = -1; goto FREE_VECTOR_OUT; @@ -614,11 +614,11 @@ static int32_t AddOsSyscapToJsonObj(uint32_t *osSyscapArray, uint32_t osSyscapAr } for (i = 0; i < osSyscapCount; i++) { - for (j = 0; j < sizeof(arraySyscap) / sizeof(SyscapWithNum); j++) { - if (index[i] != arraySyscap[j].num) { + for (j = 0; j < sizeof(g_arraySyscap) / sizeof(SyscapWithNum); j++) { + if (index[i] != g_arraySyscap[j].num) { continue; } - if (!cJSON_AddItemToArray(sysCapArray, cJSON_CreateString(arraySyscap[j].syscapStr))) { + if (!cJSON_AddItemToArray(sysCapArray, cJSON_CreateString(g_arraySyscap[j].str))) { PRINT_ERR("Add os syscap string to json failed.\n"); free(sysCapArray); return -1; @@ -732,8 +732,8 @@ PARSE_FAILED: int32_t EncodePcidscToString(char *inputFile, char *outDirPath) { int32_t ret = 0; - size_t bufferLen, privateSyscapLen; - uint32_t i, j, outputLen; + size_t bufferLen, privateSyscapLen, outputLen; + uint32_t i, j; uint32_t *mainSyscap = NULL; uint16_t priSyscapCount = 0; char *contextBuffer = NULL; diff --git a/src/syscap_tool.c b/src/syscap_tool.c index d5cceca9fe630ed704912a43a9b0db518c39ea7e..54c7063bb7309cc9f4c1b922dffb137917dd89a8 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -174,10 +174,10 @@ static int32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename static cJSON *CreateWholeSyscapJsonObj(void) { - size_t numOfSyscapAll = sizeof(arraySyscap) / sizeof(SyscapWithNum); + size_t numOfSyscapAll = sizeof(g_arraySyscap) / sizeof(SyscapWithNum); cJSON *root = cJSON_CreateObject(); for (size_t i = 0; i < numOfSyscapAll; i++) { - cJSON_AddItemToObject(root, arraySyscap[i].syscapStr, cJSON_CreateNumber(arraySyscap[i].num)); + cJSON_AddItemToObject(root, g_arraySyscap[i].str, cJSON_CreateNumber(g_arraySyscap[i].num)); } return root; } @@ -569,7 +569,7 @@ int32_t SeparateSyscapFromString(const char *inputString, uint32_t *osArray, uin { int32_t ret = 0; uint32_t i; - uint32_t inputLen = strlen(inputString); + size_t inputLen = strlen(inputString); uint32_t count = 0; char *temp = NULL; char *tok = NULL; @@ -699,7 +699,7 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile) for (uint8_t k = 0; k < INT_BIT; k++) { if (temp2 & (0x1 << k)) { // 2, header of pcid & rpcid - printf("Missing: %s\n", arraySyscap[(i - 2) * INT_BIT + k].syscapStr); + printf("Missing: %s\n", g_arraySyscap[(i - 2) * INT_BIT + k].str); ossyscapFlag += 1; } }