diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml index b0feee60..625b882b 100644 --- a/.github/workflows/cpp-linter.yml +++ b/.github/workflows/cpp-linter.yml @@ -1,6 +1,8 @@ name: cpp-linter on: + push: + branches: [ 341-resolve-cpp-linter-suggestions ] pull_request: branches: [ main, dev ] diff --git a/src/core/crypto.c b/src/core/crypto.c index 15b40df8..aa68126d 100644 --- a/src/core/crypto.c +++ b/src/core/crypto.c @@ -1173,7 +1173,8 @@ int32_t Crypto_Get_Security_Trailer_Length(SecurityAssociation_t *sa_ptr) void Crypto_Set_FSR(uint8_t *p_ingest, uint16_t byte_idx, uint16_t pdu_len, SecurityAssociation_t *sa_ptr) { - if (current_managed_parameters_struct.has_ocf == TM_HAS_OCF || current_managed_parameters_struct.has_ocf == AOS_HAS_OCF) + if (current_managed_parameters_struct.has_ocf == TM_HAS_OCF || + current_managed_parameters_struct.has_ocf == AOS_HAS_OCF) { Telemetry_Frame_Ocf_Fsr_t temp_report; byte_idx += (pdu_len + sa_ptr->stmacf_len); diff --git a/src/core/crypto_key_mgmt.c b/src/core/crypto_key_mgmt.c index 28b55829..ce91c07d 100644 --- a/src/core/crypto_key_mgmt.c +++ b/src/core/crypto_key_mgmt.c @@ -45,7 +45,8 @@ int32_t Crypto_Key_OTAR(void) int y; int32_t status = CRYPTO_LIB_SUCCESS; // uint16_t pdu_len = (uint16_t) sdls_frame.pdu.hdr.pdu_len[1] << 8 | sdls_frame.pdu.hdr.pdu_len[0]; - int pdu_keys = (sdls_frame.pdu.hdr.pdu_len - SDLS_KEYID_LEN - SDLS_IV_LEN - MAC_SIZE) / (SDLS_KEYID_LEN + SDLS_KEY_LEN); + int pdu_keys = + (sdls_frame.pdu.hdr.pdu_len - SDLS_KEYID_LEN - SDLS_IV_LEN - MAC_SIZE) / (SDLS_KEYID_LEN + SDLS_KEY_LEN); int w; crypto_key_t *ekp = NULL; @@ -100,25 +101,26 @@ int32_t Crypto_Key_OTAR(void) } uint8_t ecs = CRYPTO_CIPHER_AES256_GCM; - status = cryptography_if->cryptography_aead_decrypt(&(sdls_frame.pdu.data[14]), // plaintext output - (size_t)(pdu_keys * (SDLS_KEYID_LEN + SDLS_KEY_LEN)), // length of data - NULL, // in place decryption - 0, // in data length - &(ekp->value[0]), // key - ekp->key_len, // key length - NULL, // SA reference - &(packet.iv[0]), // IV - SDLS_IV_LEN, // IV length - &(packet.mac[0]), // tag input - MAC_SIZE, // tag size - NULL, // AAD - 0, // AAD Length - CRYPTO_TRUE, // decrypt - CRYPTO_TRUE, // authenticate - CRYPTO_FALSE, // AAD Bool - &ecs, // encryption cipher - NULL, // authentication cipher - NULL // cam_cookies + status = cryptography_if->cryptography_aead_decrypt( + &(sdls_frame.pdu.data[14]), // plaintext output + (size_t)(pdu_keys * (SDLS_KEYID_LEN + SDLS_KEY_LEN)), // length of data + NULL, // in place decryption + 0, // in data length + &(ekp->value[0]), // key + ekp->key_len, // key length + NULL, // SA reference + &(packet.iv[0]), // IV + SDLS_IV_LEN, // IV length + &(packet.mac[0]), // tag input + MAC_SIZE, // tag size + NULL, // AAD + 0, // AAD Length + CRYPTO_TRUE, // decrypt + CRYPTO_TRUE, // authenticate + CRYPTO_FALSE, // AAD Bool + &ecs, // encryption cipher + NULL, // authentication cipher + NULL // cam_cookies ); // Read in Decrypted Data diff --git a/test/unit/ut_aos_process.c b/test/unit/ut_aos_process.c index 342ef8ae..6959e460 100644 --- a/test/unit/ut_aos_process.c +++ b/test/unit/ut_aos_process.c @@ -1808,7 +1808,7 @@ UTEST(AOS_PROCESS, AOS_SA_NOT_OPERATIONAL) UTEST(AOS_PROCESS, AOS_OCF_TEST) { remove("sa_save_file.bin"); - + // Local Variables int32_t status = CRYPTO_LIB_SUCCESS; uint8_t *ptr_processed_frame = NULL; @@ -1834,10 +1834,10 @@ UTEST(AOS_PROCESS, AOS_OCF_TEST) SecurityAssociation_t *sa_ptr = NULL; SaInterface sa_if = get_sa_interface_inmemory(); sa_if->sa_get_from_spi(9, &sa_ptr); // Enable and setup 5 - sa_ptr->sa_state = SA_OPERATIONAL; - sa_ptr->shivf_len = 0; - sa_ptr->gvcid_blk.tfvn = 1; - sa_ptr->gvcid_blk.vcid = 0; + sa_ptr->sa_state = SA_OPERATIONAL; + sa_ptr->shivf_len = 0; + sa_ptr->gvcid_blk.tfvn = 1; + sa_ptr->gvcid_blk.vcid = 0; sa_ptr->gvcid_blk.mapid = 0; status = diff --git a/test/unit/ut_crypto.c b/test/unit/ut_crypto.c index 9c209c54..6e30a45c 100644 --- a/test/unit/ut_crypto.c +++ b/test/unit/ut_crypto.c @@ -113,7 +113,7 @@ UTEST(CRYPTO_C, PDU_SWITCH) Crypto_Init(); sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; - sdls_frame.pdu.hdr.uf = PDU_USER_FLAG_FALSE; + sdls_frame.pdu.hdr.uf = PDU_USER_FLAG_FALSE; printf("SG_KEY_MGMT\n"); sdls_frame.pdu.hdr.sg = SG_KEY_MGMT; sdls_frame.pdu.hdr.pid = PID_OTAR; @@ -131,8 +131,8 @@ UTEST(CRYPTO_C, PDU_SWITCH) status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.pid = PID_KEY_VERIFICATION; - status = Crypto_PDU(ingest, &tc_frame); + sdls_frame.pdu.hdr.pid = PID_KEY_VERIFICATION; + status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); sdls_frame.pdu.hdr.pid = PID_KEY_DESTRUCTION; @@ -250,7 +250,7 @@ UTEST(CRYPTO_C, PDU_SWITCH) ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); sdls_frame.pdu.hdr.pid = PID_MODIFY_VCID; - status = Crypto_PDU(ingest, &tc_frame); + status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_ERROR); sdls_frame.pdu.hdr.pid = 8; @@ -359,21 +359,21 @@ UTEST(CRYPTO_C, STRUCT_SIZE_VERIFICATION) ASSERT_EQ(SDLS_TLV_HDR_SIZE, (size_t)3); ASSERT_EQ(SDLS_TLV_SIZE, (size_t)497); ASSERT_EQ(SDLS_EKB_SIZE, (size_t)514); - ASSERT_EQ(SDLS_OTAR_SIZE, (size_t)(2 + 16 + 30*514 + 16)); + ASSERT_EQ(SDLS_OTAR_SIZE, (size_t)(2 + 16 + 30 * 514 + 16)); ASSERT_EQ(SDLS_KEY_SIZE, (size_t)2); ASSERT_EQ(SDLS_KEY_INVENTORY_CMD_SIZE, (size_t)4); ASSERT_EQ(SDLS_KEY_INVENTORY_RPLY_SIZE, (size_t)3); ASSERT_EQ(SDLS_KEYV_CMD_BLK_SIZE, (size_t)18); - ASSERT_EQ(SDLS_KEYV_CMD_SIZE, (size_t)(29*18)); + ASSERT_EQ(SDLS_KEYV_CMD_SIZE, (size_t)(29 * 18)); ASSERT_EQ(SDLS_KEYV_RPLY_BLK_SIZE, (size_t)50); - ASSERT_EQ(SDLS_KEYV_RPLY_SIZE, (size_t)(50*29)); + ASSERT_EQ(SDLS_KEYV_RPLY_SIZE, (size_t)(50 * 29)); ASSERT_EQ(SDLS_KEYDB_CMD_SIZE, (size_t)12); ASSERT_EQ(SDLS_KEYDB_RPLY_SIZE, (size_t)38); ASSERT_EQ(SDLS_SA_STATUS_RPLY_SIZE, (size_t)3); ASSERT_EQ(SDLS_SA_READ_ARSN_RPLY_SIZE, (size_t)22); ASSERT_EQ(SDLS_MC_LOG_RPLY_SIZE, (size_t)4); ASSERT_EQ(SDLS_MC_DUMP_RPLY_SIZE, (size_t)7); - ASSERT_EQ(SDLS_MC_DUMP_BLK_RPLY_SIZE, (size_t)(7*50)); + ASSERT_EQ(SDLS_MC_DUMP_BLK_RPLY_SIZE, (size_t)(7 * 50)); ASSERT_EQ(SDLS_MC_ST_RPLY_SIZE, (size_t)1); ASSERT_EQ(SDLS_MC_SN_RPLY_SIZE, (size_t)16); ASSERT_EQ(TC_FRAME_PRIMARYHEADER_STRUCT_SIZE, (size_t)5);