diff --git a/include/crypto_config.h b/include/crypto_config.h index 78112d9d..6d597282 100644 --- a/include/crypto_config.h +++ b/include/crypto_config.h @@ -109,7 +109,7 @@ // Generic Defines #define NUM_SA 64 -#define SPI_LEN 2 /* bytes */ +#define SPI_LEN 2 /* bytes */ #define SPI_MIN 0 #define SPI_MAX NUM_SA - 1 #define KEY_SIZE 512 /* bytes */ diff --git a/include/crypto_error.h b/include/crypto_error.h index 01a7111c..5f9c51d8 100644 --- a/include/crypto_error.h +++ b/include/crypto_error.h @@ -143,7 +143,6 @@ #define CRYPTO_CORE_ERROR_CODES_MAX -69 - // Define codes for returning MDB Strings, and determining error based on strings #define CAM_ERROR_CODES 600 #define CAM_ERROR_CODES_MAX 610 diff --git a/src/core/crypto.c b/src/core/crypto.c index 9b12d6ff..1799322a 100644 --- a/src/core/crypto.c +++ b/src/core/crypto.c @@ -761,7 +761,6 @@ int32_t Crypto_Get_Managed_Parameters_For_Gvcid(uint8_t tfvn, uint16_t scid, uin return status; } - /** * @brief Function: Crypto_Process_Extended_Procedure_Pdu * @param tc_sdls_processed_frame: TC_t* @@ -776,7 +775,7 @@ int32_t Crypto_Get_Managed_Parameters_For_Gvcid(uint8_t tfvn, uint16_t scid, uin int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t *tc_sdls_processed_frame, uint8_t *ingest) { int32_t status = CRYPTO_LIB_SUCCESS; - ingest = ingest; // Suppress unused variable error depending on build + ingest = ingest; // Suppress unused variable error depending on build // Check for null pointers if (tc_sdls_processed_frame == NULL) @@ -786,7 +785,8 @@ int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t *tc_sdls_processed_frame, uin // Validate correct SA for EPs uint8_t valid_ep_sa = CRYPTO_FALSE; - if ((tc_sdls_processed_frame->tc_sec_header.spi == SPI_MIN) || (tc_sdls_processed_frame->tc_sec_header.spi == SPI_MAX)) + if ((tc_sdls_processed_frame->tc_sec_header.spi == SPI_MIN) || + (tc_sdls_processed_frame->tc_sec_header.spi == SPI_MAX)) { valid_ep_sa = CRYPTO_TRUE; } @@ -798,7 +798,7 @@ int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t *tc_sdls_processed_frame, uin { #ifdef CRYPTO_EPROC // Check validity of SAs used for EP - if(valid_ep_sa == CRYPTO_TRUE) + if (valid_ep_sa == CRYPTO_TRUE) { #ifdef DEBUG printf(KGRN "Received SDLS command w/ packet header:\n\t " RESET); @@ -817,8 +817,8 @@ int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t *tc_sdls_processed_frame, uin // Using PUS Header if (crypto_config.has_pus_hdr == TC_HAS_PUS_HDR) - { - // If ECSS PUS Header is being used + { + // If ECSS PUS Header is being used sdls_frame.pus.shf = (tc_sdls_processed_frame->tc_pdu[6] & 0x80) >> 7; sdls_frame.pus.pusv = (tc_sdls_processed_frame->tc_pdu[6] & 0x70) >> 4; sdls_frame.pus.ack = (tc_sdls_processed_frame->tc_pdu[6] & 0x0F); @@ -827,7 +827,7 @@ int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t *tc_sdls_processed_frame, uin sdls_frame.pus.sid = (tc_sdls_processed_frame->tc_pdu[9] & 0xF0) >> 4; sdls_frame.pus.spare = (tc_sdls_processed_frame->tc_pdu[9] & 0x0F); - // SDLS TLV PDU + // SDLS TLV PDU sdls_frame.pdu.hdr.type = (tc_sdls_processed_frame->tc_pdu[10] & 0x80) >> 7; sdls_frame.pdu.hdr.uf = (tc_sdls_processed_frame->tc_pdu[10] & 0x40) >> 6; sdls_frame.pdu.hdr.sg = (tc_sdls_processed_frame->tc_pdu[10] & 0x30) >> 4; @@ -836,7 +836,8 @@ int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t *tc_sdls_processed_frame, uin (tc_sdls_processed_frame->tc_pdu[11] << 8) | tc_sdls_processed_frame->tc_pdu[12]; // Subtract headers from total frame length - // uint16_t max_tlv = tc_sdls_processed_frame->tc_header.fl - CCSDS_HDR_SIZE - CCSDS_PUS_SIZE - SDLS_TLV_HDR_SIZE; + // uint16_t max_tlv = tc_sdls_processed_frame->tc_header.fl - CCSDS_HDR_SIZE - CCSDS_PUS_SIZE - + // SDLS_TLV_HDR_SIZE; if (sdls_frame.hdr.pkt_length < TLV_DATA_SIZE) // && (sdls_frame.hdr.pkt_length < max_tlv)) { for (int x = 13; x < (13 + sdls_frame.hdr.pkt_length); x++) @@ -853,14 +854,14 @@ int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t *tc_sdls_processed_frame, uin // Not using PUS Header else { - // SDLS TLV PDU + // SDLS TLV PDU sdls_frame.pdu.hdr.type = (tc_sdls_processed_frame->tc_pdu[6] & 0x80) >> 7; sdls_frame.pdu.hdr.uf = (tc_sdls_processed_frame->tc_pdu[6] & 0x40) >> 6; sdls_frame.pdu.hdr.sg = (tc_sdls_processed_frame->tc_pdu[6] & 0x30) >> 4; sdls_frame.pdu.hdr.pid = (tc_sdls_processed_frame->tc_pdu[6] & 0x0F); sdls_frame.pdu.hdr.pdu_len = (tc_sdls_processed_frame->tc_pdu[7] << 8) | tc_sdls_processed_frame->tc_pdu[8]; - + // Make sure TLV isn't larger than we have allocated, and it is sane given total frame length uint16_t max_tlv = tc_sdls_processed_frame->tc_header.fl - CCSDS_HDR_SIZE - SDLS_TLV_HDR_SIZE; if ((sdls_frame.hdr.pkt_length < TLV_DATA_SIZE) && (sdls_frame.hdr.pkt_length < max_tlv)) @@ -877,51 +878,51 @@ int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t *tc_sdls_processed_frame, uin } } - - #ifdef CCSDS_DEBUG Crypto_ccsdsPrint(&sdls_frame); #endif - - // Determine type of PDU - status = Crypto_PDU(ingest, tc_sdls_processed_frame); + + // Determine type of PDU + status = Crypto_PDU(ingest, tc_sdls_processed_frame); } // Received EP PDU on invalid SA else { #ifdef CCSDS_DEBUG - printf(KRED "Received EP PDU on invalid SA! SPI %d\n" RESET, tc_sdls_processed_frame->tc_sec_header.spi); + printf(KRED "Received EP PDU on invalid SA! SPI %d\n" RESET, + tc_sdls_processed_frame->tc_sec_header.spi); #endif status = CRYPTO_LIB_ERR_SDLS_EP_WRONG_SPI; } - #else // Received an EP command without EPs being built +#else // Received an EP command without EPs being built valid_ep_sa = valid_ep_sa; // Suppress build error - status = CRYPTO_LIB_ERR_SDLS_EP_NOT_BUILT; - #endif //CRYPTO_EPROC + status = CRYPTO_LIB_ERR_SDLS_EP_NOT_BUILT; +#endif // CRYPTO_EPROC } // If not a specific APID, check if using VCIDs for SDLS PDUs with no packet layer - else if (tc_sdls_processed_frame->tc_header.vcid == TC_SDLS_EP_VCID) + else if (tc_sdls_processed_frame->tc_header.vcid == TC_SDLS_EP_VCID) { - #ifdef CRYPTO_EPROC +#ifdef CRYPTO_EPROC // Check validity of SAs used for EP - if(valid_ep_sa == CRYPTO_TRUE) - { + if (valid_ep_sa == CRYPTO_TRUE) + { #ifdef CCSDS_DEBUG printf(KGRN "Received SDLS command (No Packet Header or PUS): " RESET); #endif // No Packet HDR or PUS in these frames // SDLS TLV PDU - sdls_frame.hdr.type = (tc_sdls_processed_frame->tc_pdu[0] & 0x80) >> 7; - sdls_frame.pdu.hdr.uf = (tc_sdls_processed_frame->tc_pdu[0] & 0x40) >> 6; - sdls_frame.pdu.hdr.sg = (tc_sdls_processed_frame->tc_pdu[0] & 0x30) >> 4; - sdls_frame.pdu.hdr.pid = (tc_sdls_processed_frame->tc_pdu[0] & 0x0F); - sdls_frame.pdu.hdr.pdu_len = (tc_sdls_processed_frame->tc_pdu[1] << 8) | tc_sdls_processed_frame->tc_pdu[2]; + sdls_frame.hdr.type = (tc_sdls_processed_frame->tc_pdu[0] & 0x80) >> 7; + sdls_frame.pdu.hdr.uf = (tc_sdls_processed_frame->tc_pdu[0] & 0x40) >> 6; + sdls_frame.pdu.hdr.sg = (tc_sdls_processed_frame->tc_pdu[0] & 0x30) >> 4; + sdls_frame.pdu.hdr.pid = (tc_sdls_processed_frame->tc_pdu[0] & 0x0F); + sdls_frame.pdu.hdr.pdu_len = + (tc_sdls_processed_frame->tc_pdu[1] << 8) | tc_sdls_processed_frame->tc_pdu[2]; for (int x = 3; x < (3 + tc_sdls_processed_frame->tc_header.fl); x++) { - // Todo - Consider how this behaves with large OTAR PDUs that are larger than 1 TC in size. Most likely - // fails. Must consider Uplink Sessions (sequence numbers). + // Todo - Consider how this behaves with large OTAR PDUs that are larger than 1 TC in size. Most + // likely fails. Must consider Uplink Sessions (sequence numbers). sdls_frame.pdu.data[x - 3] = tc_sdls_processed_frame->tc_pdu[x]; } @@ -932,13 +933,13 @@ int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t *tc_sdls_processed_frame, uin // Determine type of PDU status = Crypto_PDU(ingest, tc_sdls_processed_frame); } - #else // Received an EP command without EPs being built +#else // Received an EP command without EPs being built #ifdef CCSDS_DEBUG printf(KRED "PDU DEBUG %s %d\n" RESET, __FILE__, __LINE__); #endif valid_ep_sa = valid_ep_sa; // Suppress build error - status = CRYPTO_LIB_ERR_SDLS_EP_NOT_BUILT; - #endif //CRYPTO_EPROC + status = CRYPTO_LIB_ERR_SDLS_EP_NOT_BUILT; +#endif // CRYPTO_EPROC } } return status; @@ -1255,7 +1256,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_aos.c b/src/core/crypto_aos.c index 62ef7f3b..d9aead6b 100644 --- a/src/core/crypto_aos.c +++ b/src/core/crypto_aos.c @@ -1214,7 +1214,6 @@ int32_t Crypto_AOS_ProcessSecurity(uint8_t *p_ingest, uint16_t len_ingest, uint8 crypto_key_t *ekp = NULL; crypto_key_t *akp = NULL; - if (sa_ptr->est == 1) { ekp = key_if->get_key(sa_ptr->ekid); diff --git a/src/core/crypto_key_mgmt.c b/src/core/crypto_key_mgmt.c index 1a759cc6..73693fe4 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; @@ -101,31 +102,32 @@ int32_t Crypto_Key_OTAR(void) } // Check key state - if(ekp->key_state != KEY_ACTIVE) + if (ekp->key_state != KEY_ACTIVE) { return CRYPTO_LIB_ERR_KEY_STATE_INVALID; } uint8_t ecs = CRYPTO_CIPHER_AES256_GCM; // Per SDLS baseline - 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 ); // If decryption errors, return @@ -351,8 +353,9 @@ int32_t Crypto_Key_inventory(uint8_t *ingest) // Prepare for Reply range = packet.kid_last - packet.kid_first + 1; sdls_frame.pdu.hdr.pdu_len = (SDLS_KEY_INVENTORY_RPLY_SIZE * (range)) * BYTE_LEN; - sdls_frame.hdr.pkt_length = - CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1 + 2; // 2 = Num Keys Returned Field (2 Bytes) + sdls_frame.hdr.pkt_length = CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1 + + 2; // 2 = Num Keys Returned Field (2 Bytes) count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); sdls_ep_reply[count++] = ((range & 0xFF00) >> BYTE_LEN); @@ -413,7 +416,8 @@ int32_t Crypto_Key_verify(TC_t *tc_frame) for (x = 0; x < pdu_keys; x++) { // Key ID - packet.blk[x].kid = ((uint8_t)sdls_frame.pdu.data[count] << BYTE_LEN) | ((uint8_t)sdls_frame.pdu.data[count + 1]); + packet.blk[x].kid = + ((uint8_t)sdls_frame.pdu.data[count] << BYTE_LEN) | ((uint8_t)sdls_frame.pdu.data[count + 1]); count += 2; #ifdef PDU_DEBUG printf("\tCrypto_Key_verify: Block %d Key ID is %d ", x, packet.blk[x].kid); @@ -484,32 +488,34 @@ int32_t Crypto_Key_verify(TC_t *tc_frame) // Encrypt challenge uint8_t ecs = CRYPTO_CIPHER_AES256_GCM; - status = cryptography_if->cryptography_aead_encrypt(&(sdls_ep_keyv_reply.blk[x].challenged[0]), // ciphertext output - (size_t)CHALLENGE_SIZE, // length of data - &(packet.blk[x].challenge[0]), // plaintext input - (size_t)CHALLENGE_SIZE, // in data length - &(ekp->value[0]), // Key Index - SDLS_KEY_LEN, // Key Length - NULL, // SA Reference for key - &(sdls_ep_keyv_reply.blk[x].iv[0]), // IV - SDLS_IV_LEN, // IV Length - &(sdls_ep_keyv_reply.blk[x].mac[0]), // MAC - CHALLENGE_MAC_SIZE, // MAC Size - NULL, 0, - CRYPTO_TRUE, // Encrypt - CRYPTO_TRUE, // Authenticate - CRYPTO_FALSE, // AAD - &ecs, // encryption cipher - NULL, // authentication cipher - NULL // cam_cookies - ); + status = + cryptography_if->cryptography_aead_encrypt(&(sdls_ep_keyv_reply.blk[x].challenged[0]), // ciphertext output + (size_t)CHALLENGE_SIZE, // length of data + &(packet.blk[x].challenge[0]), // plaintext input + (size_t)CHALLENGE_SIZE, // in data length + &(ekp->value[0]), // Key Index + SDLS_KEY_LEN, // Key Length + NULL, // SA Reference for key + &(sdls_ep_keyv_reply.blk[x].iv[0]), // IV + SDLS_IV_LEN, // IV Length + &(sdls_ep_keyv_reply.blk[x].mac[0]), // MAC + CHALLENGE_MAC_SIZE, // MAC Size + NULL, 0, + CRYPTO_TRUE, // Encrypt + CRYPTO_TRUE, // Authenticate + CRYPTO_FALSE, // AAD + &ecs, // encryption cipher + NULL, // authentication cipher + NULL // cam_cookies + ); // If encryption errors, capture something about it for testing // We need to continue on, other keys could be successful if (status != CRYPTO_LIB_SUCCESS) { #ifdef DEBUG - printf(KRED "Error: OTAR Key Verification encryption failed for new key index %d with error %d \n" RESET, x, status); + printf(KRED "Error: OTAR Key Verification encryption failed for new key index %d with error %d \n" RESET, x, + status); #endif } diff --git a/src/core/crypto_mc.c b/src/core/crypto_mc.c index 997bc7c0..ae52fc5d 100644 --- a/src/core/crypto_mc.c +++ b/src/core/crypto_mc.c @@ -37,8 +37,9 @@ int32_t Crypto_MC_ping(uint8_t *ingest) // Prepare for Reply sdls_frame.pdu.hdr.pdu_len = 0; - sdls_frame.hdr.pkt_length = CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; - count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); + sdls_frame.hdr.pkt_length = + CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; + count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); #ifdef PDU_DEBUG printf("MC Ping Reply: \t 0x"); @@ -65,8 +66,9 @@ int32_t Crypto_MC_status(uint8_t *ingest) // Prepare for Reply sdls_frame.pdu.hdr.pdu_len = SDLS_MC_LOG_RPLY_SIZE * BYTE_LEN; - sdls_frame.hdr.pkt_length = CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; - count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); + sdls_frame.hdr.pkt_length = + CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; + count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); // PDU sdls_ep_reply[count] = (log_summary.num_se & 0xFF00) >> BYTE_LEN; count++; @@ -106,8 +108,9 @@ int32_t Crypto_MC_dump(uint8_t *ingest) // Prepare for Reply sdls_frame.pdu.hdr.pdu_len = (SDLS_MC_DUMP_RPLY_SIZE * log_count) * BYTE_LEN; - sdls_frame.hdr.pkt_length = CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; - count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); + sdls_frame.hdr.pkt_length = + CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; + count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); // PDU for (x = 0; x < log_count; x++) { @@ -180,8 +183,9 @@ int32_t Crypto_MC_erase(uint8_t *ingest) // Prepare for Reply sdls_frame.pdu.hdr.pdu_len = SDLS_MC_LOG_RPLY_SIZE * BYTE_LEN; // 4 - sdls_frame.hdr.pkt_length = CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; - count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); + sdls_frame.hdr.pkt_length = + CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; + count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); // PDU sdls_ep_reply[count] = (log_summary.num_se & 0xFF00) >> BYTE_LEN; count++; @@ -223,9 +227,10 @@ int32_t Crypto_MC_selftest(uint8_t *ingest) // Prepare for Reply sdls_frame.pdu.hdr.pdu_len = SDLS_MC_ST_RPLY_SIZE * BYTE_LEN; - sdls_frame.hdr.pkt_length = CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; - sdls_frame.pdu.data[0] = result; - count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); + sdls_frame.hdr.pkt_length = + CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; + sdls_frame.pdu.data[0] = result; + count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); sdls_ep_reply[count] = result; count++; @@ -276,8 +281,9 @@ int32_t Crypto_SA_readARSN(uint8_t *ingest) { // Prepare for Reply sdls_frame.pdu.hdr.pdu_len = (SPI_LEN + sa_ptr->arsn_len) * BYTE_LEN; // bits - sdls_frame.hdr.pkt_length = CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; - uint8_t count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); + sdls_frame.hdr.pkt_length = + CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; + uint8_t count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); // Write SPI to reply sdls_ep_reply[count] = (spi & 0xFF00) >> BYTE_LEN; diff --git a/src/core/crypto_print.c b/src/core/crypto_print.c index ec78cc70..6a7646db 100644 --- a/src/core/crypto_print.c +++ b/src/core/crypto_print.c @@ -183,7 +183,7 @@ void Crypto_ccsdsPrint(CCSDS_t *sdls_frame) printf("\t\t seq = 0x%01x \n", sdls_frame->hdr.seq); printf("\t\t pktid = 0x%04x \n", sdls_frame->hdr.pktid); printf("\t\t pkt_length = 0x%04x \n", sdls_frame->hdr.pkt_length); - if(crypto_config.has_pus_hdr == TC_HAS_PUS_HDR) + if (crypto_config.has_pus_hdr == TC_HAS_PUS_HDR) { printf("\t PUS Header\n"); printf("\t\t shf = 0x%01x \n", sdls_frame->pus.shf); diff --git a/src/core/crypto_tc.c b/src/core/crypto_tc.c index cca8a8fa..92b65284 100644 --- a/src/core/crypto_tc.c +++ b/src/core/crypto_tc.c @@ -346,12 +346,12 @@ int32_t Crypto_TC_Do_Encrypt_PLAINTEXT(uint8_t sa_service_type, SecurityAssociat uint16_t *index_p, const uint8_t *p_in_frame, char *cam_cookies, uint32_t pkcs_padding) { - int32_t status = CRYPTO_LIB_SUCCESS; - uint16_t index = *index_p; - crypto_key_t *akp = NULL; + int32_t status = CRYPTO_LIB_SUCCESS; + uint16_t index = *index_p; + crypto_key_t *akp = NULL; /* Get Key */ - + if (sa_ptr->est == 1) { ekp = key_if->get_key(sa_ptr->ekid); @@ -1607,7 +1607,6 @@ int32_t Crypto_TC_Get_Keys(crypto_key_t **ekp, crypto_key_t **akp, SecurityAssoc mc_if->mc_log(status); } } - return status; } @@ -1906,7 +1905,6 @@ int32_t Crypto_TC_ProcessSecurity_Cam(uint8_t *ingest, int *len_ingest, TC_t *tc memcpy((tc_sdls_processed_frame->tc_sec_header.pad), &(ingest[TC_FRAME_HEADER_SIZE + segment_hdr_len + SPI_LEN + sa_ptr->shivf_len + sa_ptr->shsnf_len]), sa_ptr->shplf_len); - // Parse MAC, prepare AAD status = Crypto_TC_Prep_AAD(tc_sdls_processed_frame, fecf_len, sa_service_type, ecs_is_aead_algorithm, &aad_len, @@ -1964,7 +1962,7 @@ int32_t Crypto_TC_ProcessSecurity_Cam(uint8_t *ingest, int *len_ingest, TC_t *tc return status; // Cryptography IF call failed, return. } // Extended PDU processing, if applicable - + if (status == CRYPTO_LIB_SUCCESS && crypto_config.process_sdls_pdus == TC_PROCESS_SDLS_PDUS_TRUE) { status = Crypto_Process_Extended_Procedure_Pdu(tc_sdls_processed_frame, ingest); @@ -2051,18 +2049,18 @@ uint8_t *Crypto_Prepare_TC_AAD(uint8_t *buffer, uint16_t len_aad, uint8_t *abm_b static int32_t validate_sa_index(SecurityAssociation_t *sa) { - int32_t returnval = -1; + int32_t returnval = -1; SecurityAssociation_t *temp_sa; sa_if->sa_get_from_spi(sa->spi, &temp_sa); int sa_index = -1; - sa_index = (int)(sa - temp_sa); // Based on array memory location + sa_index = (int)(sa - temp_sa); // Based on array memory location #ifdef DEBUG - if(sa_index == 0) + if (sa_index == 0) printf("SA Index matches SPI\n"); else printf("Malformed SA SPI based on SA Index!\n"); #endif - if(sa_index == 0) + if (sa_index == 0) returnval = 0; return returnval; } @@ -2076,7 +2074,7 @@ static int32_t validate_sa_index(SecurityAssociation_t *sa) **/ static int32_t crypto_tc_validate_sa(SecurityAssociation_t *sa) { - if(validate_sa_index(sa) != 0) + if (validate_sa_index(sa) != 0) { return CRYPTO_LIB_ERR_SPI_INDEX_MISMATCH; } diff --git a/src/sa/internal/sa_interface_inmemory.template.c b/src/sa/internal/sa_interface_inmemory.template.c index 870ccee6..c8850c33 100644 --- a/src/sa/internal/sa_interface_inmemory.template.c +++ b/src/sa/internal/sa_interface_inmemory.template.c @@ -37,7 +37,6 @@ static int32_t sa_delete(TC_t *tc_frame); // Security Association Local Functions int32_t sa_verify_data(SecurityAssociation_t *); - /* ** Global Variables */ @@ -1101,13 +1100,13 @@ static int32_t sa_start(TC_t *tc_frame) static int32_t sa_stop(TC_t *tc_frame) { // Local variables - int32_t status = CRYPTO_LIB_SUCCESS; - uint16_t spi = 0x0000; + int32_t status = CRYPTO_LIB_SUCCESS; + uint16_t spi = 0x0000; uint16_t control_spi = 0x0000; int x; // Read ingest - spi = ((uint8_t)sdls_frame.pdu.data[0] << BYTE_LEN) | (uint8_t)sdls_frame.pdu.data[1]; + spi = ((uint8_t)sdls_frame.pdu.data[0] << BYTE_LEN) | (uint8_t)sdls_frame.pdu.data[1]; control_spi = tc_frame->tc_sec_header.spi; #ifdef DEBUG @@ -1347,9 +1346,9 @@ static int32_t sa_expire(TC_t *tc_frame) static int32_t sa_create(TC_t *tc_frame) { // Local variables - int32_t status = CRYPTO_LIB_SUCCESS; - uint8_t count = 6; - uint16_t spi = 0x0000; + int32_t status = CRYPTO_LIB_SUCCESS; + uint8_t count = 6; + uint16_t spi = 0x0000; uint16_t control_spi = 0x0000; int x; @@ -1381,7 +1380,7 @@ static int32_t sa_create(TC_t *tc_frame) // 3-4 : Service Group Field (sg) // 5-8 : Procedure Identification Field (pid) temp_sa->lpid = (sdls_frame.pdu.hdr.type << 7) | (sdls_frame.pdu.hdr.uf << 6) | (sdls_frame.pdu.hdr.sg << 4) | - sdls_frame.pdu.hdr.pid; + sdls_frame.pdu.hdr.pid; // Write SA Configuration temp_sa->est = ((uint8_t)sdls_frame.pdu.data[2] & 0x80) >> 7; @@ -1406,7 +1405,7 @@ static int32_t sa_create(TC_t *tc_frame) temp_sa->acs = ((uint8_t)sdls_frame.pdu.data[count++]); } temp_sa->abm_len = (uint8_t)((sdls_frame.pdu.data[count] << BYTE_LEN) | (sdls_frame.pdu.data[count + 1])); - count = count + 2; + count = count + 2; for (x = 0; x < temp_sa->abm_len; x++) { temp_sa->abm[x] = ((uint8_t)sdls_frame.pdu.data[count++]); @@ -1431,20 +1430,20 @@ static int32_t sa_create(TC_t *tc_frame) if (status == CRYPTO_LIB_SUCCESS) { // Copy data from temp_sa to sa[spi] - sa[spi].lpid = temp_sa->lpid; - sa[spi].est = temp_sa->est; - sa[spi].ast = temp_sa->ast; - sa[spi].shivf_len = temp_sa->shivf_len; - sa[spi].shsnf_len = temp_sa->shsnf_len; - sa[spi].shplf_len = temp_sa->shplf_len; + sa[spi].lpid = temp_sa->lpid; + sa[spi].est = temp_sa->est; + sa[spi].ast = temp_sa->ast; + sa[spi].shivf_len = temp_sa->shivf_len; + sa[spi].shsnf_len = temp_sa->shsnf_len; + sa[spi].shplf_len = temp_sa->shplf_len; sa[spi].stmacf_len = temp_sa->stmacf_len; - sa[spi].ecs_len = temp_sa->ecs_len; - sa[spi].ecs = temp_sa->ecs; + sa[spi].ecs_len = temp_sa->ecs_len; + sa[spi].ecs = temp_sa->ecs; for (x = 0; x < sa[spi].shivf_len; x++) { sa[spi].iv[x] = temp_sa->iv[x]; } - sa[spi].acs = temp_sa->acs; + sa[spi].acs = temp_sa->acs; sa[spi].abm_len = temp_sa->abm_len; for (x = 0; x < sa[spi].abm_len; x++) { @@ -1456,8 +1455,8 @@ static int32_t sa_create(TC_t *tc_frame) *(sa[spi].arsn + x) = *(temp_sa->arsn + x); } sa[spi].arsnw_len = temp_sa->arsnw_len; - sa[spi].arsnw = temp_sa->arsnw; - sa[spi].sa_state = temp_sa->sa_state; + sa[spi].arsnw = temp_sa->arsnw; + sa[spi].sa_state = temp_sa->sa_state; } #ifdef PDU_DEBUG @@ -1481,7 +1480,7 @@ static int32_t sa_create(TC_t *tc_frame) static int32_t sa_delete(TC_t *tc_frame) { // Local variables - uint16_t spi = 0x0000; + uint16_t spi = 0x0000; uint16_t control_spi = 0x0000; int32_t status = CRYPTO_LIB_SUCCESS; @@ -1548,12 +1547,12 @@ static int32_t sa_setARSN(TC_t *tc_frame) // Local variables uint16_t spi = 0x0000; uint16_t control_spi = 0x0000; - int32_t status = CRYPTO_LIB_SUCCESS; + int32_t status = CRYPTO_LIB_SUCCESS; int x; // Read ingest spi = ((uint8_t)sdls_frame.pdu.data[0] << BYTE_LEN) | (uint8_t)sdls_frame.pdu.data[1]; - + control_spi = tc_frame->tc_sec_header.spi; if (spi == control_spi) { @@ -1690,8 +1689,9 @@ static int32_t sa_status(uint8_t *ingest) printf("SIZE: %ld\n", SDLS_SA_STATUS_RPLY_SIZE); // Prepare for Reply sdls_frame.pdu.hdr.pdu_len = SDLS_SA_STATUS_RPLY_SIZE * BYTE_LEN; - sdls_frame.hdr.pkt_length = CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; - count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); + sdls_frame.hdr.pkt_length = + CCSDS_HDR_SIZE + CCSDS_PUS_SIZE + SDLS_TLV_HDR_SIZE + (sdls_frame.pdu.hdr.pdu_len / BYTE_LEN) - 1; + count = Crypto_Prep_Reply(sdls_ep_reply, CRYPTOLIB_APPID); // PDU sdls_ep_reply[count++] = (spi & 0xFF00) >> BYTE_LEN; sdls_ep_reply[count++] = (spi & 0x00FF); @@ -1720,7 +1720,7 @@ static int32_t sa_status(uint8_t *ingest) return status; } -int32_t sa_verify_data(SecurityAssociation_t * sa_ptr) +int32_t sa_verify_data(SecurityAssociation_t *sa_ptr) { int32_t status = CRYPTO_LIB_SUCCESS; if (sa_ptr->shivf_len > IV_SIZE) diff --git a/test/unit/ut_aos_apply.c b/test/unit/ut_aos_apply.c index eac6ea09..0b7bf59d 100644 --- a/test/unit/ut_aos_apply.c +++ b/test/unit/ut_aos_apply.c @@ -255,13 +255,13 @@ UTEST(AOS_APPLY, HAPPY_PATH_CLEAR_FECF) SecurityAssociation_t *test_association; sa_if->sa_get_from_spi(10, &test_association); - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_ACTIVE; status = Crypto_AOS_ApplySecurity((uint8_t *)test_aos_b); ASSERT_EQ(CRYPTO_LIB_SUCCESS, status); @@ -390,13 +390,13 @@ UTEST(AOS_APPLY, HAPPY_PATH_CLEAR_FECF_LEFT_BLANK) SecurityAssociation_t *test_association; sa_if->sa_get_from_spi(10, &test_association); - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_ACTIVE; status = Crypto_AOS_ApplySecurity((uint8_t *)test_aos_b); ASSERT_EQ(CRYPTO_LIB_SUCCESS, status); @@ -526,13 +526,13 @@ UTEST(AOS_APPLY, HAPPY_PATH_CLEAR_FHEC_FECF) SecurityAssociation_t *test_association; sa_if->sa_get_from_spi(10, &test_association); - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_ACTIVE; status = Crypto_AOS_ApplySecurity((uint8_t *)test_aos_b); ASSERT_EQ(CRYPTO_LIB_SUCCESS, status); @@ -663,13 +663,13 @@ UTEST(AOS_APPLY, HAPPY_PATH_CLEAR_FHEC_OID_FECF) SecurityAssociation_t *test_association; sa_if->sa_get_from_spi(10, &test_association); - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_ACTIVE; status = Crypto_AOS_ApplySecurity((uint8_t *)test_aos_b); ASSERT_EQ(CRYPTO_LIB_SUCCESS, status); @@ -808,13 +808,13 @@ UTEST(AOS_APPLY, AES_CMAC_256_TEST_BITMASK_1) sa_if->sa_get_from_spi(10, &sa_ptr); sa_ptr->sa_state = SA_OPERATIONAL; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; status = Crypto_AOS_ApplySecurity((uint8_t *)test_aos_b); ASSERT_EQ(CRYPTO_LIB_SUCCESS, status); @@ -1111,13 +1111,13 @@ UTEST(AOS_APPLY, AES_GCM) aos_frame_pri_hdr.vcid = ((uint8_t)test_aos_b[1] & 0x3F); sa_if->sa_get_from_spi(10, &sa_ptr); - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; status = Crypto_AOS_ApplySecurity((uint8_t *)test_aos_b); ASSERT_EQ(CRYPTO_LIB_SUCCESS, status); @@ -1269,13 +1269,13 @@ UTEST(AOS_APPLY, AOS_KEY_STATE_TEST) sa_ptr->shivf_len = 16; sa_ptr->stmacf_len = 16; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; status = Crypto_AOS_ApplySecurity((uint8_t *)test_aos_b); ASSERT_EQ(CRYPTO_LIB_SUCCESS, status); @@ -1379,18 +1379,17 @@ UTEST(AOS_APPLY, AEAD_GCM_BITMASK_1) sa_ptr->shivf_len = 16; sa_ptr->stmacf_len = 16; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_DEACTIVATED; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_DEACTIVATED; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_DEACTIVATED; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_DEACTIVATED; status = Crypto_AOS_ApplySecurity((uint8_t *)test_aos_b); ASSERT_EQ(CRYPTO_LIB_ERR_KEY_STATE_INVALID, status); - free(test_aos_b); Crypto_Shutdown(); } diff --git a/test/unit/ut_aos_process.c b/test/unit/ut_aos_process.c index a470af7f..5bf8d97f 100644 --- a/test/unit/ut_aos_process.c +++ b/test/unit/ut_aos_process.c @@ -1535,13 +1535,13 @@ UTEST(AOS_PROCESS, AES_GCM_DEC_ONLY) test_association->shsnf_len = 0; memset(test_association->abm, 0xFF, (test_association->abm_len * sizeof(uint8_t))); // Bitmask of ones - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_ACTIVE; // Set a more obvious IV for test purposes char *iv_h = "DEADBEEFDEADBEEFDEADBEEFDEADBEEE"; @@ -1804,13 +1804,13 @@ UTEST(AOS_PROCESS, AOS_SA_NOT_OPERATIONAL) sa_if->sa_get_from_spi(5, &sa_ptr); // Enable and setup 5 sa_ptr->sa_state = SA_NONE; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; status = Crypto_AOS_ProcessSecurity((uint8_t *)framed_aos_b, framed_aos_len, &ptr_processed_frame, &processed_aos_len); @@ -1824,7 +1824,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; @@ -1850,10 +1850,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 = @@ -1899,16 +1899,16 @@ UTEST(AOS_PROCESS, AOS_KEY_STATE_TEST) sa_ptr->sa_state = SA_KEYED; sa_if->sa_get_from_spi(5, &sa_ptr); // Enable and setup 5 sa_ptr->sa_state = SA_OPERATIONAL; - sa_ptr->est = 1; - sa_ptr->ecs = CRYPTO_CIPHER_AES256_GCM; - - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_DEACTIVATED; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_DEACTIVATED; + sa_ptr->est = 1; + sa_ptr->ecs = CRYPTO_CIPHER_AES256_GCM; + + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_DEACTIVATED; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_DEACTIVATED; status = Crypto_AOS_ProcessSecurity((uint8_t *)framed_aos_b, framed_aos_len, &ptr_processed_frame, &processed_aos_len); diff --git a/test/unit/ut_crypto.c b/test/unit/ut_crypto.c index 35ad07ee..0d5e55d2 100644 --- a/test/unit/ut_crypto.c +++ b/test/unit/ut_crypto.c @@ -114,11 +114,11 @@ 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.sg = SG_KEY_MGMT; // sdls_frame.pdu.hdr.pid = PID_OTAR; - uint8_t *ingest = NULL; + uint8_t *ingest = NULL; TC_t tc_frame; // status = Crypto_PDU(ingest, &tc_frame); @@ -132,8 +132,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; @@ -251,7 +251,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; @@ -264,7 +264,6 @@ UTEST(CRYPTO_C, PDU_SWITCH) ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); } - /** * @brief Unit Test: Crypto Extended Procedures PDU Test **/ @@ -282,7 +281,7 @@ UTEST(CRYPTO_C, EXT_PROC_PDU) status = Crypto_Process_Extended_Procedure_Pdu(tc_frame, ingest); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); } -#endif //CRYPTO_EPROC +#endif // CRYPTO_EPROC /** * @brief Unit Test: Crypto ACS Get Algorithm response @@ -362,21 +361,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); @@ -468,5 +467,5 @@ UTEST(CRYPTO_C, OTAR_0_140_142_FAIL_TEST) free(buffer_nist_key_b); free(buffer_OTAR_b); } -#endif //CRYPTO_EPROC +#endif // CRYPTO_EPROC UTEST_MAIN(); \ No newline at end of file diff --git a/test/unit/ut_ep_key_mgmt.c b/test/unit/ut_ep_key_mgmt.c index fee64c54..08a5140a 100644 --- a/test/unit/ut_ep_key_mgmt.c +++ b/test/unit/ut_ep_key_mgmt.c @@ -251,7 +251,6 @@ UTEST(EP_KEY_MGMT, INVENTORY_132_134) char *buffer_nist_iv_h = "000000000000000000000000"; // The last valid IV that was seen by the SA char *buffer_INVENTORY_h = "2003001e00ff000000001880d03b000a197f0b00070004008400861f6d82ebe4fc55555555"; - uint8_t *buffer_nist_iv_b, *buffer_nist_key_b, *buffer_INVENTORY_b = NULL; int buffer_nist_iv_len, buffer_nist_key_len, buffer_INVENTORY_len = 0; @@ -368,17 +367,17 @@ UTEST(EP_KEY_MGMT, VERIFY_132_134) // Activate SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->sa_state = SA_OPERATIONAL; - test_association->ecs_len = 0; - test_association->ecs = CRYPTO_CIPHER_NONE; - test_association->est = 0; - test_association->ast = 0; - test_association->shsnf_len = 2; - test_association->arsn_len = 2; - test_association->arsnw_len = 1; - test_association->arsnw = 5; - test_association->shivf_len = 0; - test_association->iv_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->ecs_len = 0; + test_association->ecs = CRYPTO_CIPHER_NONE; + test_association->est = 0; + test_association->ast = 0; + test_association->shsnf_len = 2; + test_association->arsn_len = 2; + test_association->arsnw_len = 1; + test_association->arsnw = 5; + test_association->shivf_len = 0; + test_association->iv_len = 0; test_association->gvcid_blk.scid = 0; // Insert key into keyring of SA 9 @@ -427,7 +426,7 @@ UTEST(EP_KEY_MGMT, VERIFY_132_134) } /* -** Test that an OTAR attempt with non-active Master Key will bubble up to a top-level error. +** Test that an OTAR attempt with non-active Master Key will bubble up to a top-level error. */ UTEST(EP_KEY_MGMT, OTAR_0_140_142_MK_NOT_ACTIVE) { @@ -473,7 +472,8 @@ UTEST(EP_KEY_MGMT, OTAR_0_140_142_MK_NOT_ACTIVE) // |0b| = sst, sid, spare // |0001| = PDU Tag // |0084| = PDU Length - // |007F| = Master Key ID - Valid id, invalid that it isn't set up in the keyring! + // |007F| = Master Key ID - Valid id, invalid that + // it isn't set up in the keyring! // |344892bbc54f5395297d4c37| = IV // |172f| = Encrypted // Key ID @@ -531,7 +531,7 @@ UTEST(EP_KEY_MGMT, OTAR_0_140_142_MK_NOT_ACTIVE) } /* -** Test that a fail OTAR key decryption will bubble up to a top-level error. +** Test that a fail OTAR key decryption will bubble up to a top-level error. */ UTEST(EP_KEY_MGMT, OTAR_0_140_142_BAD_DECRYPT) { @@ -555,9 +555,9 @@ UTEST(EP_KEY_MGMT, OTAR_0_140_142_BAD_DECRYPT) Crypto_Config_Add_Gvcid_Managed_Parameters(TC_1_Managed_Parameters); Crypto_Init(); - SaInterface sa_if = get_sa_interface_inmemory(); - crypto_key_t* ekp = NULL; - int status = CRYPTO_LIB_SUCCESS; + SaInterface sa_if = get_sa_interface_inmemory(); + crypto_key_t *ekp = NULL; + int status = CRYPTO_LIB_SUCCESS; // NOTE: Added Transfer Frame header to the plaintext char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F"; @@ -577,7 +577,8 @@ UTEST(EP_KEY_MGMT, OTAR_0_140_142_BAD_DECRYPT) // |0b| = sst, sid, spare // |0001| = PDU Tag // |0084| = PDU Length - // |007F| = Master Key ID - Valid id, invalid that it isn't set up in the keyring! + // |007F| = Master Key ID - Valid id, invalid that + // it isn't set up in the keyring! // |344892bbc54f5395297d4c37| = IV // |172f| = Encrypted // Key ID @@ -614,7 +615,7 @@ UTEST(EP_KEY_MGMT, OTAR_0_140_142_BAD_DECRYPT) test_association->ekid = 127; // Insert key into keyring of SA 9 hex_conversion(buffer_nist_key_h, (char **)&buffer_nist_key_b, &buffer_nist_key_len); - ekp = key_if->get_key(test_association->ekid); + ekp = key_if->get_key(test_association->ekid); ekp->key_state = KEY_ACTIVE; // memcpy(ekp->value, buffer_nist_key_b, buffer_nist_key_len); @@ -760,7 +761,7 @@ UTEST(EP_KEY_MGMT, DEACTIVATE_142_NO_PUS_BAD_TLV) // Activate SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->sa_state = SA_OPERATIONAL; + test_association->sa_state = SA_OPERATIONAL; test_association->ecs = CRYPTO_CIPHER_NONE; test_association->est = 0; test_association->ast = 0; @@ -794,7 +795,6 @@ UTEST(EP_KEY_MGMT, DEACTIVATE_142_NO_PUS_BAD_TLV) free(buffer_DEACTIVATE_b); } - UTEST(EP_KEY_MGMT, DEACTIVATE_142_PUS_BAD_TLV) { remove("sa_save_file.bin"); diff --git a/test/unit/ut_ep_mc.c b/test/unit/ut_ep_mc.c index 1e6e24fc..a0d1ca73 100644 --- a/test/unit/ut_ep_mc.c +++ b/test/unit/ut_ep_mc.c @@ -49,14 +49,14 @@ UTEST(EP_MC, MC_REGULAR_PING) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); @@ -133,14 +133,14 @@ UTEST(EP_MC, MC_STATUS) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); @@ -214,14 +214,14 @@ UTEST(EP_MC, MC_DUMP) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); @@ -298,14 +298,14 @@ UTEST(EP_MC, MC_ERASE) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); @@ -381,14 +381,14 @@ UTEST(EP_MC, MC_SELF_TEST) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); @@ -451,7 +451,7 @@ UTEST(EP_MC, MC_ALARM_FLAG_RESET) // NOTE: Added Transfer Frame header to the plaintext char *buffer_ALARM_h = "2003001a00ff000000001880d2c70008197f0b00370000b1fe312855"; - + uint8_t *buffer_ALARM_b = NULL; int buffer_ALARM_len = 0; @@ -463,14 +463,14 @@ UTEST(EP_MC, MC_ALARM_FLAG_RESET) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); diff --git a/test/unit/ut_ep_sa_mgmt.c b/test/unit/ut_ep_sa_mgmt.c index 4d009c4d..f7396fe0 100644 --- a/test/unit/ut_ep_sa_mgmt.c +++ b/test/unit/ut_ep_sa_mgmt.c @@ -27,7 +27,7 @@ UTEST(EP_SA_MGMT, SA_6_REKEY_133) // NOTE: Added Transfer Frame header to the plaintext char *buffer_REKEY_h = "2003002a00ff000000001880d0ac0018197f0b0016000c00060085000000000000000000000000da959fc8555555555555"; - + uint8_t *buffer_REKEY_b = NULL; int buffer_REKEY_len = 0; @@ -39,14 +39,14 @@ UTEST(EP_SA_MGMT, SA_6_REKEY_133) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); @@ -96,14 +96,14 @@ UTEST(EP_SA_MGMT, SA_START_6) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Convert frames that will be processed hex_conversion(buffer_START_h, (char **)&buffer_START_b, &buffer_START_len); @@ -126,7 +126,6 @@ UTEST(EP_SA_MGMT, SA_6_READ_ARSN) TC_IGNORE_SA_STATE_FALSE, TC_IGNORE_ANTI_REPLAY_TRUE, TC_UNIQUE_SA_PER_MAP_ID_FALSE, TC_CHECK_FECF_FALSE, 0x3F, SA_INCREMENT_NONTRANSMITTED_IV_TRUE); - GvcidManagedParameters_t TC_0_Managed_Parameters = { 0, 0x0003, 0, TC_NO_FECF, AOS_FHEC_NA, AOS_IZ_NA, 0, TC_HAS_SEGMENT_HDRS, 1024, TC_OCF_NA, 1}; Crypto_Config_Add_Gvcid_Managed_Parameters(TC_0_Managed_Parameters); @@ -150,14 +149,14 @@ UTEST(EP_SA_MGMT, SA_6_READ_ARSN) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); @@ -238,14 +237,14 @@ UTEST(EP_SA_MGMT, SA_6_SET_ARSNW) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); @@ -297,14 +296,14 @@ UTEST(EP_SA_MGMT, SA_6_SET_ARSN) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); @@ -369,14 +368,14 @@ UTEST(EP_SA_MGMT, SA_6_STATUS) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); @@ -449,14 +448,14 @@ UTEST(EP_SA_MGMT, SA_STOP_6) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); @@ -489,7 +488,6 @@ UTEST(EP_SA_MGMT, SA_EXPIRE_6) Crypto_Init(); - int status = CRYPTO_LIB_SUCCESS; // NOTE: Added Transfer Frame header to the plaintext @@ -518,14 +516,14 @@ UTEST(EP_SA_MGMT, SA_EXPIRE_6) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Convert frames that will be processed hex_conversion(buffer_EXPIRE_h, (char **)&buffer_EXPIRE_b, &buffer_EXPIRE_len); @@ -571,14 +569,14 @@ UTEST(EP_SA_MGMT, SA_STOP_SELF) // Modify SA 0 sa_if->sa_get_from_spi(0, &test_association); - test_association->shivf_len = 0; - test_association->sa_state = SA_OPERATIONAL; - test_association->iv_len = 12; - test_association->shsnf_len = 2; - test_association->arsnw = 5; - test_association->arsnw_len = 1; - test_association->arsn_len = 2; - test_association->gvcid_blk.scid = SCID & 0x3FF; + test_association->shivf_len = 0; + test_association->sa_state = SA_OPERATIONAL; + test_association->iv_len = 12; + test_association->shsnf_len = 2; + test_association->arsnw = 5; + test_association->arsnw_len = 1; + test_association->arsn_len = 2; + test_association->gvcid_blk.scid = SCID & 0x3FF; // Modify SA 6 sa_if->sa_get_from_spi(6, &test_association); diff --git a/test/unit/ut_tc_apply.c b/test/unit/ut_tc_apply.c index a487c1cf..f12b1c38 100644 --- a/test/unit/ut_tc_apply.c +++ b/test/unit/ut_tc_apply.c @@ -1455,15 +1455,15 @@ UTEST(TC_APPLY_SECURITY, TC_KEY_STATE_TEST) test_association->sa_state = SA_KEYED; sa_if->sa_get_from_spi(4, &test_association); test_association->sa_state = SA_OPERATIONAL; - test_association->ekid = 130; + test_association->ekid = 130; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_DEACTIVATED; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_DEACTIVATED; - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_DEACTIVATED; + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_DEACTIVATED; return_val = Crypto_TC_ApplySecurity((uint8_t *)raw_tc_sdls_ping_b, raw_tc_sdls_ping_len, &ptr_enc_frame, &enc_frame_len); diff --git a/test/unit/ut_tc_process.c b/test/unit/ut_tc_process.c index a098c3de..7b1b44ca 100644 --- a/test/unit/ut_tc_process.c +++ b/test/unit/ut_tc_process.c @@ -707,13 +707,13 @@ UTEST(TC_PROCESS, HAPPY_PATH_DECRYPT_CBC) test_association->ekid = 130; test_association->sa_state = SA_OPERATIONAL; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_ACTIVE; - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_ACTIVE; // Convert input test frame hex_conversion(test_frame_pt_h, (char **)&test_frame_pt_b, &test_frame_pt_len); @@ -789,13 +789,13 @@ UTEST(TC_PROCESS, DECRYPT_CBC_1B) test_association->ekid = 130; test_association->sa_state = SA_OPERATIONAL; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_ACTIVE; - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_ACTIVE; // Convert input test frame hex_conversion(test_frame_pt_h, (char **)&test_frame_pt_b, &test_frame_pt_len); @@ -871,13 +871,13 @@ UTEST(TC_PROCESS, DECRYPT_CBC_16B) test_association->sa_state = SA_OPERATIONAL; test_association->ekid = 130; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_ACTIVE; - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_ACTIVE; // Convert input test frame hex_conversion(test_frame_pt_h, (char **)&test_frame_pt_b, &test_frame_pt_len); @@ -1238,15 +1238,15 @@ UTEST(TC_PROCESS, TC_KEY_STATE_TEST) SecurityAssociation_t *test_association; sa_if->sa_get_from_spi(1, &test_association); test_association->sa_state = SA_OPERATIONAL; - test_association->est = 1; + test_association->est = 1; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_DEACTIVATED; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_DEACTIVATED; - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_DEACTIVATED; + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_DEACTIVATED; // Convert input test frame hex_conversion(test_frame_pt_h, (char **)&test_frame_pt_b, &test_frame_pt_len); diff --git a/test/unit/ut_tm_apply.c b/test/unit/ut_tm_apply.c index b54f84c7..a06c1aa8 100644 --- a/test/unit/ut_tm_apply.c +++ b/test/unit/ut_tm_apply.c @@ -412,13 +412,13 @@ UTEST(TM_APPLY_SECURITY, HAPPY_PATH_CLEAR_FECF_LEFT_BLANK) sa_ptr->arsnw = 5; sa_ptr->gvcid_blk.vcid = 0; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -550,13 +550,13 @@ UTEST(TM_APPLY_SECURITY, SECONDARY_HDR_PRESENT_PLAINTEXT) sa_ptr->gvcid_blk.vcid = 0; sa_ptr->gvcid_blk.scid = 44; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -709,13 +709,13 @@ UTEST(TM_APPLY_SECURITY, SECONDARY_HDR_PRESENT_MAC) sa_ptr->gvcid_blk.scid = 44; sa_ptr->gvcid_blk.vcid = 0; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Determine managed parameters by GVCID, which nominally happens in TO status = @@ -866,13 +866,13 @@ UTEST(TM_APPLY_SECURITY, AES_CMAC_256_TEST_0) sa_ptr->ekid = 0; sa_ptr->akid = 136; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -1040,13 +1040,13 @@ UTEST(TM_APPLY_SECURITY, AES_CMAC_256_TEST_1) sa_ptr->ekid = 0; sa_ptr->akid = 136; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -1209,13 +1209,13 @@ UTEST(TM_APPLY_ENC_VAL, AES_HMAC_SHA_256_TEST_0) sa_ptr->ekid = 0; sa_ptr->akid = 136; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -1376,13 +1376,13 @@ UTEST(TM_APPLY_ENC_VAL, AES_HMAC_SHA_256_TEST_1) sa_ptr->ekid = 0; sa_ptr->akid = 136; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -1545,14 +1545,13 @@ UTEST(TM_APPLY_ENC_VAL, AES_HMAC_SHA_512_TEST_0) sa_ptr->akid = 136; // Update key length for SHA512 - akp = key_if->get_key(sa_ptr->akid); - akp->key_len = 64; + akp = key_if->get_key(sa_ptr->akid); + akp->key_len = 64; akp->key_state = KEY_ACTIVE; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -1722,13 +1721,13 @@ UTEST(TM_APPLY_ENC_VAL, AES_HMAC_SHA_512_TEST_1) sa_ptr->akid = 136; // Update key length for SHA512 - akp = key_if->get_key(sa_ptr->akid); - akp->key_len = 64; + akp = key_if->get_key(sa_ptr->akid); + akp->key_len = 64; akp->key_state = KEY_ACTIVE; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -1879,13 +1878,13 @@ UTEST(TM_APPLY_ENC_VAL, AES_GCM_BITMASK_1) sa_ptr->iv_len = 16; sa_ptr->shivf_len = 16; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Set a more obvious IV for test purposes char *iv_h = "DEADBEEFDEADBEEFDEADBEEFDEADBEEF"; @@ -2055,13 +2054,13 @@ UTEST(TM_APPLY_ENC_VAL, AEAD_AES_GCM_BITMASK_1) sa_ptr->shivf_len = 16; sa_ptr->stmacf_len = 16; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Set a more obvious IV for test purposes char *iv_h = "DEADBEEFDEADBEEFDEADBEEFDEADBEEF"; @@ -2242,13 +2241,13 @@ UTEST(TM_APPLY_ENC_VAL, TM_KEY_STATE_TEST) sa_ptr->shivf_len = 16; sa_ptr->stmacf_len = 16; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_DEACTIVATED; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_DEACTIVATED; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_DEACTIVATED; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_DEACTIVATED; // Set a more obvious IV for test purposes char *iv_h = "DEADBEEFDEADBEEFDEADBEEFDEADBEEF"; diff --git a/test/unit/ut_tm_process.c b/test/unit/ut_tm_process.c index ecc604ba..81f6f3a5 100644 --- a/test/unit/ut_tm_process.c +++ b/test/unit/ut_tm_process.c @@ -295,13 +295,13 @@ UTEST(TM_PROCESS_SECURITY, HAPPY_PATH_CLEAR_FECF) sa_if->sa_get_from_spi(5, &sa_ptr); sa_ptr->sa_state = SA_OPERATIONAL; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; status = Crypto_TM_ProcessSecurity((uint8_t *)framed_tm_b, framed_tm_len, &ptr_processed_frame, &processed_tm_len); ASSERT_EQ(CRYPTO_LIB_SUCCESS, status); @@ -450,13 +450,13 @@ UTEST(TM_PROCESS_SECURITY, SECONDARY_HDR_PRESENT_PLAINTEXT) sa_ptr->shivf_len = 16; sa_ptr->stmacf_len = 0; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; status = Crypto_TM_ProcessSecurity((uint8_t *)framed_tm_b, framed_tm_len, &ptr_processed_frame, &processed_tm_len); ASSERT_EQ(CRYPTO_LIB_SUCCESS, status); @@ -615,13 +615,13 @@ UTEST(TM_PROCESS_SECURITY, SECONDARY_HDR_PRESENT_MAC) sa_ptr->ekid = 0; sa_ptr->akid = 136; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Determine managed parameters by GVCID, which nominally happens in TO // status = Crypto_Get_Managed_Parameters_For_Gvcid(tm_frame_pri_hdr.tfvn, tm_frame_pri_hdr.scid, @@ -772,13 +772,13 @@ UTEST(TM_PROCESS_SECURITY, AES_CMAC_256_TEST_0) sa_ptr->ekid = 0; sa_ptr->akid = 136; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -949,13 +949,13 @@ UTEST(TM_PROCESS_SECURITY, AES_CMAC_256_TEST_1) sa_ptr->ekid = 0; sa_ptr->akid = 136; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -1124,13 +1124,13 @@ UTEST(TM_PROCESS_ENC_VAL, AES_HMAC_SHA_256_TEST_0) sa_ptr->ekid = 0; sa_ptr->akid = 136; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -1299,13 +1299,13 @@ UTEST(TM_PROCESS_ENC_VAL, AES_HMAC_SHA_256_TEST_1) sa_ptr->ekid = 0; sa_ptr->akid = 136; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -1477,13 +1477,13 @@ UTEST(TM_PROCESS_ENC_VAL, AES_HMAC_SHA_512_TEST_0) sa_ptr->akid = 136; // Update key length for SHA512 - akp = key_if->get_key(sa_ptr->akid); - akp->key_len = 64; + akp = key_if->get_key(sa_ptr->akid); + akp->key_len = 64; akp->key_state = KEY_ACTIVE; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -1655,13 +1655,13 @@ UTEST(TM_PROCESS_ENC_VAL, AES_HMAC_SHA_512_TEST_1) sa_ptr->akid = 136; // Update key length for SHA512 - akp = key_if->get_key(sa_ptr->akid); - akp->key_len = 64; + akp = key_if->get_key(sa_ptr->akid); + akp->key_len = 64; akp->key_state = KEY_ACTIVE; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; // Bit math to give concise access to values already set in the static transfer frame tm_frame_pri_hdr.tfvn = ((uint8_t)framed_tm_b[0] & 0xC0) >> 6; @@ -1833,13 +1833,13 @@ UTEST(TM_PROCESS_ENC_VAL, AES_GCM_BITMASK_1) test_association->iv_len = 16; test_association->shivf_len = 16; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_ACTIVE; // Set a more obvious IV for test purposes char *iv_h = "DEADBEEFDEADBEEFDEADBEEFDEADBEEE"; @@ -2019,13 +2019,13 @@ UTEST(TM_PROCESS_ENC_VAL, AEAD_AES_GCM_BITMASK_1) test_association->shivf_len = 16; test_association->stmacf_len = 16; - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(test_association->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(test_association->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(test_association->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(test_association->akid); + akp->key_state = KEY_ACTIVE; // Set a more obvious IV for test purposes char *iv_h = "DEADBEEFDEADBEEFDEADBEEFDEADBEEE"; @@ -2170,13 +2170,13 @@ UTEST(TM_PROCESS, TM_SA_NOT_OPERATIONAL) SecurityAssociation_t *sa_ptr; sa_if->sa_get_from_spi(44, &sa_ptr); - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_ACTIVE; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_ACTIVE; + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_ACTIVE; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_ACTIVE; status = Crypto_TM_ProcessSecurity((uint8_t *)framed_tm_b, framed_tm_len, &ptr_processed_frame, &processed_tm_len); @@ -2219,16 +2219,16 @@ UTEST(TM_PROCESS, TM_KEY_STATE_TEST) SecurityAssociation_t *sa_ptr; sa_if->sa_get_from_spi(1, &sa_ptr); sa_ptr->sa_state = SA_OPERATIONAL; - sa_ptr->est = 1; - sa_ptr->ecs = CRYPTO_CIPHER_AES256_GCM; - - crypto_key_t *ekp = NULL; - ekp = key_if->get_key(sa_ptr->ekid); - ekp->key_state = KEY_DEACTIVATED; - - crypto_key_t *akp = NULL; - akp = key_if->get_key(sa_ptr->akid); - akp->key_state = KEY_DEACTIVATED; + sa_ptr->est = 1; + sa_ptr->ecs = CRYPTO_CIPHER_AES256_GCM; + + crypto_key_t *ekp = NULL; + ekp = key_if->get_key(sa_ptr->ekid); + ekp->key_state = KEY_DEACTIVATED; + + crypto_key_t *akp = NULL; + akp = key_if->get_key(sa_ptr->akid); + akp->key_state = KEY_DEACTIVATED; status = Crypto_TM_ProcessSecurity((uint8_t *)framed_tm_b, framed_tm_len, &ptr_processed_frame, &processed_tm_len);