From 9e97406a7237b2983a14e515846552013288fc2a Mon Sep 17 00:00:00 2001 From: Donnie-Ice Date: Tue, 29 Oct 2024 20:42:25 +0000 Subject: [PATCH 1/3] [nasa/cryptolib#332] Added struct size UT and fixed PDU_SWITCH - many of these now return errors with a null ingest --- include/crypto_structs.h | 26 ++++---- test/unit/ut_crypto.c | 125 ++++++++++++++++++++++++++++++--------- 2 files changed, 111 insertions(+), 40 deletions(-) diff --git a/include/crypto_structs.h b/include/crypto_structs.h index 2498002e..5de7a321 100644 --- a/include/crypto_structs.h +++ b/include/crypto_structs.h @@ -46,7 +46,7 @@ typedef struct uint16_t scid : 16; // Spacecraft ID uint16_t vcid : 6; // Virtual Channel ID uint8_t mapid : 6; // Multiplexer Access Point ID -} crypto_gvcid_t; +} __attribute__((packed)) crypto_gvcid_t; #define CRYPTO_GVCID_SIZE (sizeof(crypto_gvcid_t)) /* @@ -88,7 +88,7 @@ typedef struct uint8_t arsnw_len : 8; // Anti-Replay Seq Num Window Length uint16_t arsnw; // Anti-Replay Seq Num Window -} SecurityAssociation_t; +} __attribute__((packed)) SecurityAssociation_t; #define SA_SIZE (sizeof(SecurityAssociation_t)) /* @@ -104,7 +104,7 @@ typedef struct uint8_t ispif : 1; // Invalid SPI Flag uint16_t lspiu : 16; // Last SPI Used uint8_t snval : 8; // SN Value (LSB) -} SDLS_FSR_t; +} __attribute__((packed)) SDLS_FSR_t; #define SDLS_FSR_SIZE (sizeof(SDLS_FSR_t)) typedef struct @@ -275,7 +275,7 @@ typedef struct uint8_t vcid : 6; // Virtual Channel ID uint16_t fl : 10; // The whole transfer frame length (max 1024) uint8_t fsn : 8; // Frame sequence number, also N(S), zeroed on Type-B frames -} TC_FramePrimaryHeader_t; +} __attribute__((packed)) TC_FramePrimaryHeader_t; #define TC_FRAME_PRIMARYHEADER_STRUCT_SIZE (sizeof(TC_FramePrimaryHeader_t)) #define TC_FRAME_HEADER_SIZE 5 @@ -289,7 +289,7 @@ typedef struct uint8_t sn_field_len; uint8_t pad[PAD_SIZE]; // Count of the used fill Bytes uint8_t pad_field_len; -} TC_FrameSecurityHeader_t; +} __attribute__((packed)) TC_FrameSecurityHeader_t; #define TC_FRAME_SECHEADER_SIZE (sizeof(TC_FrameSecurityHeader_t)) typedef struct @@ -297,7 +297,7 @@ typedef struct uint8_t mac[MAC_SIZE]; // Message Authentication Code uint8_t mac_field_len; uint16_t fecf; // Frame Error Control Field -} TC_FrameSecurityTrailer_t; +} __attribute__((packed)) TC_FrameSecurityTrailer_t; #define TC_FRAME_SECTRAILER_SIZE (sizeof(TC_FrameSecurityTrailer_t)) typedef struct @@ -307,7 +307,7 @@ typedef struct uint8_t tc_pdu[TC_FRAME_DATA_SIZE]; uint16_t tc_pdu_len; TC_FrameSecurityTrailer_t tc_sec_trailer; -} TC_t; +} __attribute__((packed)) TC_t; #define TC_SIZE (sizeof(TC_t)) /* @@ -342,7 +342,7 @@ typedef struct CCSDS_HDR_t hdr; CCSDS_PUS_t pus; SDLS_TLV_t pdu; -} CCSDS_t; +} __attribute__((packed)) CCSDS_t; #define CCSDS_SIZE (sizeof(CCSDS_t)) /* @@ -370,7 +370,7 @@ typedef struct uint8_t fbc : 2; // FARM-B Counter uint8_t spare1 : 1; // Reserved Spare "0" uint8_t rv : 8; // Report Value -} Telemetry_Frame_Ocf_Clcw_t; +} __attribute__((packed)) Telemetry_Frame_Ocf_Clcw_t; #define TELEMETRY_FRAME_OCF_CLCW_SIZE (sizeof(Telemetry_Frame_Ocf_Clcw_t)) @@ -386,7 +386,7 @@ typedef struct uint8_t bsaf : 1; // Bad Security Association Flag uint16_t lspi : 16; // Last SPI Used uint8_t snval : 8; // Sequence Number Value (LSB) -} Telemetry_Frame_Ocf_Fsr_t; +} __attribute__((packed)) Telemetry_Frame_Ocf_Fsr_t; #define TELEMETRY_FRAME_OCF_FSR_SIZE (sizeof(Telemetry_Frame_Ocf_Fsr_t)) @@ -463,10 +463,10 @@ typedef struct uint8_t spare : 2; // Reserved Spare // 0 = Shall be set to 0 // Sync Flag 1 = Undefined - uint8_t vfcc : 2; // VC Frame Count cycle + uint8_t vfcc : 4; // VC Frame Count cycle // Sync Flag 0 = Shall be 11 // Sync Flag 1 = Undefined - uint16_t fhp : 11; // First Header Pointer + uint16_t fhp : 16; // First Header Pointer // Sync Flag 0 = Contains position of the first byte of the first packet in the data field // Sync Flag 1 = undefined } AOS_FramePrimaryHeader_t; @@ -493,7 +493,7 @@ typedef struct AOS_FrameSecurityHeader_t tm_sec_header; uint8_t aos_pdu[AOS_FRAME_DATA_SIZE]; AOS_FrameSecurityTrailer_t aos_sec_trailer; -} AOS_t; +} __attribute__((packed)) AOS_t; #define AOS_SIZE (sizeof(AOS_t)) #define AOS_MIN_SIZE \ diff --git a/test/unit/ut_crypto.c b/test/unit/ut_crypto.c index 96d2b2bc..20d6ff52 100644 --- a/test/unit/ut_crypto.c +++ b/test/unit/ut_crypto.c @@ -112,8 +112,8 @@ UTEST(CRYPTO_C, PDU_SWITCH) Crypto_Init(); - sdls_frame.hdr.type = 0; - sdls_frame.pdu.hdr.uf = 0; + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; + 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; @@ -123,149 +123,176 @@ UTEST(CRYPTO_C, PDU_SWITCH) status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_KEY_ACTIVATION; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_KEY_DEACTIVATION; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.pdu_len = 0; + //sdls_frame.pdu.hdr.pdu_len = 0; + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_KEY_VERIFICATION; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_KEY_DESTRUCTION; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_KEY_INVENTORY; status = Crypto_PDU(ingest, &tc_frame); - ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + ASSERT_EQ(status, CRYPTOGRAPHY_UNSUPPORTED_OPERATION_FOR_KEY_RING); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = SG_KEY_MGMT; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); printf("SG_SA_MGMT\n"); sdls_frame.pdu.hdr.sg = SG_SA_MGMT; + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_CREATE_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_DELETE_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_SET_ARSNW; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_REKEY_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_EXPIRE_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_SET_ARSN; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_START_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_STOP_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_READ_ARSN; status = Crypto_PDU(ingest, &tc_frame); - ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + ASSERT_EQ(status, CRYPTO_LIB_ERROR); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_SA_STATUS; status = Crypto_PDU(ingest, &tc_frame); - ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + ASSERT_EQ(status, CRYPTO_LIB_ERROR); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = 0b111; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); printf("SG_SEC_MON_CTRL\n"); sdls_frame.pdu.hdr.sg = SG_SEC_MON_CTRL; + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_LOG_STATUS; status = Crypto_PDU(ingest, &tc_frame); - ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + ASSERT_EQ(status, CRYPTO_LIB_ERROR); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_DUMP_LOG; status = Crypto_PDU(ingest, &tc_frame); - ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + ASSERT_EQ(status, CRYPTO_LIB_ERROR); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_ERASE_LOG; status = Crypto_PDU(ingest, &tc_frame); - ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + ASSERT_EQ(status, CRYPTO_LIB_ERROR); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_SELF_TEST; status = Crypto_PDU(ingest, &tc_frame); - ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + ASSERT_EQ(status, CRYPTO_LIB_ERROR); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_ALARM_FLAG; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = 0b1111; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - printf("PID_LOG_STATUS\n"); - sdls_frame.pdu.hdr.sg = PID_LOG_STATUS; - sdls_frame.pdu.hdr.pid = PID_LOG_STATUS; - status = Crypto_PDU(ingest, &tc_frame); - ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - printf("UF_TRUE\n"); - sdls_frame.pdu.hdr.uf = 1; - sdls_frame.pdu.hdr.pid = 0; + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; + sdls_frame.pdu.hdr.uf = PDU_USER_FLAG_TRUE; + sdls_frame.pdu.hdr.pid = PID_IDLE_FRAME_TRIGGER; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.pid = 1; + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; + sdls_frame.pdu.hdr.pid = PID_TOGGLE_BAD_SPI; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.pid = 2; + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; + sdls_frame.pdu.hdr.pid = PID_TOGGLE_BAD_IV; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.pid = 3; + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; + sdls_frame.pdu.hdr.pid = PID_TOGGLE_BAD_MAC; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.pid = 4; + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; + sdls_frame.pdu.hdr.pid = PID_TOGGLE_BAD_FECF; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.pid = 5; + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; + sdls_frame.pdu.hdr.pid = PID_MODIFY_KEY; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.pid = 6; + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; + sdls_frame.pdu.hdr.pid = PID_MODIFY_ACTIVE_TM; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); // TODO: (RB) Disabled for now. Key Inventory needs to be re-worked. - Not currently using EP - // sdls_frame.pdu.hdr.pid = 7; - // status = Crypto_PDU(ingest, &tc_frame); - // ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; + sdls_frame.pdu.hdr.pid = PID_MODIFY_VCID; + status = Crypto_PDU(ingest, &tc_frame); + ASSERT_EQ(status, CRYPTO_LIB_ERROR); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = 8; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); + sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.hdr.type = 1; sdls_frame.pdu.hdr.pid = 8; status = Crypto_PDU(ingest, &tc_frame); @@ -360,4 +387,48 @@ UTEST(CRYPTO_C, GET_ECS_ALGO_KEY_LEN) ASSERT_EQ(algo_keylen, 32); } +UTEST(CRYPTO_C, STRUCT_SIZE_VERIFICATION) +{ + ASSERT_EQ(CRYPTO_GVCID_SIZE, (size_t)4); + ASSERT_EQ(SA_SIZE, (size_t)2348); + ASSERT_EQ(SDLS_FSR_SIZE, (size_t)4); + 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_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_RPLY_BLK_SIZE, (size_t)50); + 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_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); + ASSERT_EQ(TC_FRAME_SECHEADER_SIZE, (size_t)70); + ASSERT_EQ(TC_FRAME_SECTRAILER_SIZE, (size_t)19); + ASSERT_EQ(TC_SIZE, (size_t)(5 + 70 + 19 + 2 + 1019)); + ASSERT_EQ(CCSDS_HDR_SIZE, (size_t)6); + ASSERT_EQ(CCSDS_PUS_SIZE, (size_t)4); + ASSERT_EQ(CCSDS_SIZE, (size_t)(6 + 4 + 497)); + ASSERT_EQ(TELEMETRY_FRAME_OCF_CLCW_SIZE, (size_t)4); + ASSERT_EQ(TELEMETRY_FRAME_OCF_FSR_SIZE, (size_t)4); + ASSERT_EQ(TM_FRAME_PRIMARYHEADER_SIZE, (size_t)6); + ASSERT_EQ(TM_FRAME_SECHEADER_SIZE, (size_t)18); + ASSERT_EQ(TM_FRAME_SECTRAILER_SIZE, (size_t)22); + ASSERT_EQ(TM_SIZE, (size_t)(6 + 18 + 1786 + 22)); + ASSERT_EQ(AOS_FRAME_PRIMARYHEADER_SIZE, (size_t)8); + ASSERT_EQ(AOS_FRAME_SECHEADER_SIZE, (size_t)18); + ASSERT_EQ(AOS_FRAME_SECTRAILER_SIZE, (size_t)22); + ASSERT_EQ(AOS_SIZE, (size_t)(8 + 18 + 1786 + 22)); +} + UTEST_MAIN(); \ No newline at end of file From 14a6668bc6d9b82c5f09d34f51dfd8e1dd3d73ef Mon Sep 17 00:00:00 2001 From: Donnie-Ice Date: Tue, 29 Oct 2024 20:44:26 +0000 Subject: [PATCH 2/3] [nasa/cryptolib#332] Removed TODO --- test/unit/ut_crypto.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/unit/ut_crypto.c b/test/unit/ut_crypto.c index 20d6ff52..902466cc 100644 --- a/test/unit/ut_crypto.c +++ b/test/unit/ut_crypto.c @@ -280,8 +280,6 @@ UTEST(CRYPTO_C, PDU_SWITCH) status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - // TODO: (RB) Disabled for now. Key Inventory needs to be re-worked. - Not currently using EP - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_MODIFY_VCID; status = Crypto_PDU(ingest, &tc_frame); From e96dcbaf376865c969f07d18876121ba3c9ec51e Mon Sep 17 00:00:00 2001 From: Donnie-Ice Date: Tue, 29 Oct 2024 21:01:39 +0000 Subject: [PATCH 3/3] [nasa/cryptolib#332] Set sdls_frame.pdu.hdr.type back to 0 after prepping reply --- src/core/crypto.c | 1 + test/unit/ut_crypto.c | 36 +----------------------------------- 2 files changed, 2 insertions(+), 35 deletions(-) diff --git a/src/core/crypto.c b/src/core/crypto.c index 1b9eaf81..15b40df8 100644 --- a/src/core/crypto.c +++ b/src/core/crypto.c @@ -287,6 +287,7 @@ uint8_t Crypto_Prep_Reply(uint8_t *reply, uint8_t appID) reply[count++] = (sdls_frame.pdu.hdr.pdu_len & 0xFF00) >> 8; reply[count++] = (sdls_frame.pdu.hdr.pdu_len & 0x00FF); + sdls_frame.pdu.hdr.type = 0; return count; } diff --git a/test/unit/ut_crypto.c b/test/unit/ut_crypto.c index 902466cc..9c209c54 100644 --- a/test/unit/ut_crypto.c +++ b/test/unit/ut_crypto.c @@ -123,175 +123,141 @@ UTEST(CRYPTO_C, PDU_SWITCH) status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_KEY_ACTIVATION; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_KEY_DEACTIVATION; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - //sdls_frame.pdu.hdr.pdu_len = 0; - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_KEY_VERIFICATION; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_KEY_DESTRUCTION; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_KEY_INVENTORY; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTOGRAPHY_UNSUPPORTED_OPERATION_FOR_KEY_RING); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = SG_KEY_MGMT; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); printf("SG_SA_MGMT\n"); sdls_frame.pdu.hdr.sg = SG_SA_MGMT; - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_CREATE_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_DELETE_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_SET_ARSNW; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_REKEY_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_EXPIRE_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_SET_ARSN; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_START_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_STOP_SA; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_READ_ARSN; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_ERROR); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_SA_STATUS; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_ERROR); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = 0b111; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); printf("SG_SEC_MON_CTRL\n"); sdls_frame.pdu.hdr.sg = SG_SEC_MON_CTRL; - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_LOG_STATUS; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_ERROR); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_DUMP_LOG; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_ERROR); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_ERASE_LOG; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_ERROR); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_SELF_TEST; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_ERROR); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_ALARM_FLAG; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = 0b1111; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); printf("UF_TRUE\n"); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.uf = PDU_USER_FLAG_TRUE; sdls_frame.pdu.hdr.pid = PID_IDLE_FRAME_TRIGGER; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_TOGGLE_BAD_SPI; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_TOGGLE_BAD_IV; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_TOGGLE_BAD_MAC; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_TOGGLE_BAD_FECF; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_MODIFY_KEY; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_MODIFY_ACTIVE_TM; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = PID_MODIFY_VCID; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_ERROR); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; sdls_frame.pdu.hdr.pid = 8; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS); - sdls_frame.pdu.hdr.type = PDU_TYPE_COMMAND; - sdls_frame.hdr.type = 1; + sdls_frame.hdr.type = PDU_TYPE_REPLY; sdls_frame.pdu.hdr.pid = 8; status = Crypto_PDU(ingest, &tc_frame); ASSERT_EQ(status, CRYPTO_LIB_SUCCESS);