Skip to content

Commit

Permalink
[#344] Ran formatter. Running cpp-linter again to get latest results
Browse files Browse the repository at this point in the history
  • Loading branch information
Donnie-Ice committed Nov 4, 2024
1 parent da65f0d commit 2980a88
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cpp-linter.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: cpp-linter

on:
push:
branches: [ 341-resolve-cpp-linter-suggestions ]
pull_request:
branches: [ main, dev ]

Expand Down
3 changes: 2 additions & 1 deletion src/core/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
42 changes: 22 additions & 20 deletions src/core/crypto_key_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/unit/ut_aos_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 =
Expand Down
16 changes: 8 additions & 8 deletions test/unit/ut_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2980a88

Please sign in to comment.