Skip to content

Commit

Permalink
[nasa/nos3#483] Change CryptoLib App ID to 1980, fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Donnie-Ice committed Feb 13, 2025
1 parent cd772d8 commit 33caa4d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/core/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ int32_t Crypto_Get_Managed_Parameters_For_Gvcid(uint8_t tfvn, uint16_t scid, uin
* @return int32: Success/Failure
* @note TODO - Actually update based on variable config
* @note Allows EPs to be processed one of two ways.
* @note - 1) By using a packet layer with APID 0x1880
* @note - 1) By using a packet layer with APID 0x1980
* @note - 2) By using a defined Virtual Channel ID
* @note Requires this to happen on either SPI_MIN (0) or SPI_MAX (configurable)
**/
Expand All @@ -794,7 +794,7 @@ int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t *tc_sdls_processed_frame, uin
if (status == CRYPTO_LIB_SUCCESS)
{
// Check for specific App ID for EPs - the CryptoLib Apid in this case
if ((tc_sdls_processed_frame->tc_pdu[0] == 0x18) && (tc_sdls_processed_frame->tc_pdu[1] == 0x80))
if ((tc_sdls_processed_frame->tc_pdu[0] == 0x19) && (tc_sdls_processed_frame->tc_pdu[1] == 0x80))
{

#ifdef CRYPTO_EPROC
Expand Down
10 changes: 5 additions & 5 deletions test/unit/ut_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
UTEST(CRYPTO_C, CALC_CRC16)
{
remove("sa_save_file.bin");
char *data_h = "2003002000ff000100001880d2c9000e197f0b001b0004000400003040d95e";
char *data_h = "2003002000ff000100001980d2c9000e197f0b001b0004000400003040d95e";
uint8_t *data_b = NULL;
int data_b_len = 0;
Crypto_Init_TC_Unit_Test();
Expand All @@ -40,10 +40,10 @@ UTEST(CRYPTO_C, CALC_CRC16)

int size = 31;
uint16_t crc = 0x00;
uint16_t validated_crc = 0xA61A;
uint16_t validated_crc = 0x73EC;
crc = Crypto_Calc_CRC16(data_b, size);

// printf("CRC = 0x%04x\n", crc);
printf("CRC = 0x%04x\n", crc);
ASSERT_EQ(crc, validated_crc);
}

Expand All @@ -68,7 +68,7 @@ UTEST(CRYPTO_C, BAD_CC_FLAG)
Crypto_Config_Add_Gvcid_Managed_Parameters(TC_UT_Managed_Parameters);

Crypto_Init();
char *raw_tc_sdls_ping_h = "3003002000ff000100001880d2c9000e197f0b001b0004000400003040d95ea61a";
char *raw_tc_sdls_ping_h = "3003002000ff000100001980d2c9000e197f0b001b0004000400003040d95ea61a";
char *raw_tc_sdls_ping_b = NULL;
int raw_tc_sdls_ping_len = 0;

Expand Down Expand Up @@ -424,7 +424,7 @@ UTEST(CRYPTO_C, OTAR_0_140_142_FAIL_TEST)
char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F";
// char* buffer_nist_iv_h = "b6ac8e4963f49207ffd6374b"; // The last valid IV that was seen by the SA
char *buffer_OTAR_h =
"2003009e00ff000000001880d037008c197f0b000100840000344892bbc54f5395297d4c37172f2a3c46f6a81c1349e9e26ac80985d8bb"
"2003009e00ff000000001980d037008c197f0b000100840001344892bbc54f5395297d4c37172f2a3c46f6a81c1349e9e26ac80985d8bb"
"d55a5814c662e49fba52f99ba09558cd21cf268b8e50b2184137e80f76122034c580464e2f06d2659a50508bdfe9e9a55990ba4148af89"
"6d8a6eebe8b5d2258685d4ce217a20174fdd4f0efac62758c51b04e55710a47209c923b641d19a39001f9e986166f5ffd95555";

Expand Down
24 changes: 12 additions & 12 deletions test/unit/ut_ep_key_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ UTEST(EP_KEY_MGMT, OTAR_0_140_142)
char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F";
// char* buffer_nist_iv_h = "b6ac8e4963f49207ffd6374b"; // The last valid IV that was seen by the SA
char *buffer_OTAR_h =
"2003009e00ff000000001880d037008c197f0b000100840000344892bbc54f5395297d4c37172f2a3c46f6a81c1349e9e26ac80985d8bb"
"2003009e00ff000000001980d037008c197f0b000100840000344892bbc54f5395297d4c37172f2a3c46f6a81c1349e9e26ac80985d8bb"
"d55a5814c662e49fba52f99ba09558cd21cf268b8e50b2184137e80f76122034c580464e2f06d2659a50508bdfe9e9a55990ba4148af89"
"6d8a6eebe8b5d2258685d4ce217a20174fdd4f0efac62758c51b04e55710a47209c923b641d19a39001f9e986166f5ffd95555";

Expand Down Expand Up @@ -100,7 +100,7 @@ UTEST(EP_KEY_MGMT, ACTIVATE_141_142)
// NOTE: Added Transfer Frame header to the plaintext
char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F";
char *buffer_nist_iv_h = "b6ac8e4963f49207ffd6374b"; // The last valid IV that was seen by the SA
char *buffer_ACTIVATE_h = "2003001e00ff000000001880d038000c197f0b00020004008d008e82ebe4fc55555555";
char *buffer_ACTIVATE_h = "2003001e00ff000000001980d038000c197f0b00020004008d008e82ebe4fc55555555";

uint8_t *buffer_nist_iv_b, *buffer_nist_key_b, *buffer_ACTIVATE_b = NULL;
int buffer_nist_iv_len, buffer_nist_key_len, buffer_ACTIVATE_len = 0;
Expand Down Expand Up @@ -175,7 +175,7 @@ UTEST(EP_KEY_MGMT, DEACTIVATE_142)
// NOTE: Added Transfer Frame header to the plaintext
char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F";
char *buffer_nist_iv_h = "b6ac8e4963f49207ffd6374b"; // The last valid IV that was seen by the SA
char *buffer_DEACTIVATE_h = "2003001c00ff000000001880d039000a197f0b00030002008e1f6d21c4555555555555";
char *buffer_DEACTIVATE_h = "2003001c00ff000000001980d039000a197f0b00030002008e1f6d21c4555555555555";

uint8_t *buffer_nist_iv_b, *buffer_nist_key_b, *buffer_DEACTIVATE_b = NULL;
int buffer_nist_iv_len, buffer_nist_key_len, buffer_DEACTIVATE_len = 0;
Expand Down Expand Up @@ -249,7 +249,7 @@ UTEST(EP_KEY_MGMT, INVENTORY_132_134)
// NOTE: Added Transfer Frame header to the plaintext
char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F";
char *buffer_nist_iv_h = "000000000000000000000000"; // The last valid IV that was seen by the SA
char *buffer_INVENTORY_h = "2003001e00ff000000001880d03b000a197f0b00070004008400861f6d82ebe4fc55555555";
char *buffer_INVENTORY_h = "2003001e00ff000000001980d03b000a197f0b00070004008400861f6d82ebe4fc55555555";

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;
Expand Down Expand Up @@ -345,7 +345,7 @@ UTEST(EP_KEY_MGMT, VERIFY_132_134)

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F";
char *buffer_VERIFY_h = "2003003e00ff000000001880d03a002c197f0b00040024008471fc3ad5b1c36ad56bd5a5432315cdab008675c0"
char *buffer_VERIFY_h = "2003003e00ff000000001980d03a002c197f0b00040024008471fc3ad5b1c36ad56bd5a5432315cdab008675c0"
"6302465bc6d5091a29957eebed35c00a6ed8";
// TRUTH PDU
char *buffer_TRUTH_RESPONSE_h =
Expand Down Expand Up @@ -458,14 +458,14 @@ UTEST(EP_KEY_MGMT, OTAR_0_140_142_MK_NOT_ACTIVE)
char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F";
// char* buffer_nist_iv_h = "b6ac8e4963f49207ffd6374b"; // The last valid IV that was seen by the SA
char *buffer_OTAR_h =
"2003009e00ff000000001880d037008c197f0b00010084007F344892bbc54f5395297d4c37172f2a3c46f6a81c1349e9e26ac80985d8bb"
"2003009e00ff000000001980d037008c197f0b00010084007F344892bbc54f5395297d4c37172f2a3c46f6a81c1349e9e26ac80985d8bb"
"d55a5814c662e49fba52f99ba09558cd21cf268b8e50b2184137e80f76122034c580464e2f06d2659a50508bdfe9e9a55990ba4148af89"
"6d8a6eebe8b5d2258685d4ce217a20174fdd4f0efac62758c51b04e55710a47209c923b641d19a39001f9e986366f5ffd95555";
// |2003009e00| = Primary Header
// |ff| = Ext. Procs
// |0000| = SPI
// |0000| = ARSN
// |1880| = CryptoLib App ID
// |1980| = CryptoLib App ID
// |d037| = seq, pktid
// |008c| = pkt_length
// |197f| = pusv, ack, st
Expand Down Expand Up @@ -563,14 +563,14 @@ UTEST(EP_KEY_MGMT, OTAR_0_140_142_BAD_DECRYPT)
char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F";
// char* buffer_nist_iv_h = "b6ac8e4963f49207ffd6374b"; // The last valid IV that was seen by the SA
char *buffer_OTAR_h =
"2003009e00ff000000001880d037008c197f0b00010084007F344892bbc54f5395297d4c37172f2a3c46f6a81c1349e9e26ac80985d8bb"
"2003009e00ff000000001980d037008c197f0b00010084007F344892bbc54f5395297d4c37172f2a3c46f6a81c1349e9e26ac80985d8bb"
"d55a5814c662e49fba52f99ba09558cd21cf268b8e50b2184137e80f76122034c580464e2f06d2659a50508bdfe9e9a55990ba4148af89"
"6d8a6eebe8b5d2258685d4ce217a20174fdd4f0efac62758c51b04e55710a47209c923b641d19a39001f9e986366f5ffd95555";
// |2003009e00| = Primary Header
// |ff| = Ext. Procs
// |0000| = SPI
// |0000| = ARSN
// |1880| = CryptoLib App ID
// |1980| = CryptoLib App ID
// |d037| = seq, pktid
// |008c| = pkt_length
// |197f| = pusv, ack, st
Expand Down Expand Up @@ -663,7 +663,7 @@ UTEST(EP_KEY_MGMT, DEACTIVATE_142_NO_PUS)
// NOTE: Added Transfer Frame header to the plaintext
char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F";
char *buffer_nist_iv_h = "b6ac8e4963f49207ffd6374b"; // The last valid IV that was seen by the SA
char *buffer_DEACTIVATE_h = "2003001c00ff000000001880d039000a030002008e1f6d21c4555555555555";
char *buffer_DEACTIVATE_h = "2003001c00ff000000001980d039000a030002008e1f6d21c4555555555555";

uint8_t *buffer_nist_iv_b, *buffer_nist_key_b, *buffer_DEACTIVATE_b = NULL;
int buffer_nist_iv_len, buffer_nist_key_len, buffer_DEACTIVATE_len = 0;
Expand Down Expand Up @@ -744,7 +744,7 @@ UTEST(EP_KEY_MGMT, DEACTIVATE_142_NO_PUS_BAD_TLV)
// NOTE: Added Transfer Frame header to the plaintext
char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F";
char *buffer_nist_iv_h = "b6ac8e4963f49207ffd6374b"; // The last valid IV that was seen by the SA
char *buffer_DEACTIVATE_h = "2003001c00ff000000001880d039FFFF030002008e1f6d21c4555555555555";
char *buffer_DEACTIVATE_h = "2003001c00ff000000001980d039FFFF030002008e1f6d21c4555555555555";

uint8_t *buffer_nist_iv_b, *buffer_nist_key_b, *buffer_DEACTIVATE_b = NULL;
int buffer_nist_iv_len, buffer_nist_key_len, buffer_DEACTIVATE_len = 0;
Expand Down Expand Up @@ -821,7 +821,7 @@ UTEST(EP_KEY_MGMT, DEACTIVATE_142_PUS_BAD_TLV)
// NOTE: Added Transfer Frame header to the plaintext
char *buffer_nist_key_h = "000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F";
char *buffer_nist_iv_h = "b6ac8e4963f49207ffd6374b"; // The last valid IV that was seen by the SA
char *buffer_DEACTIVATE_h = "2003001c00ff000000001880d039FFFF197f0b00030002008e1f6d21c4555555555555";
char *buffer_DEACTIVATE_h = "2003001c00ff000000001980d039FFFF197f0b00030002008e1f6d21c4555555555555";

uint8_t *buffer_nist_iv_b, *buffer_nist_key_b, *buffer_DEACTIVATE_b = NULL;
int buffer_nist_iv_len, buffer_nist_key_len, buffer_DEACTIVATE_len = 0;
Expand Down
14 changes: 7 additions & 7 deletions test/unit/ut_ep_mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ UTEST(EP_MC, MC_REGULAR_PING)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_PING_h = "2003001a00ff000000001880d2c70008197f0b00310000b1fe312855";
char *buffer_PING_h = "2003001a00ff000000001980d2c70008197f0b00310000b1fe312855";
// |2003001a00| = Primary Header
// |ff| = Ext. Procs
// |0000| = SPI
// |0000| = ARSN
// |1880| = CryptoLib App ID
// |1980| = CryptoLib App ID
// |d2c7| = seq, pktid
// |0008| = pkt_length
// |197f| = pusv, ack, st
Expand Down Expand Up @@ -120,7 +120,7 @@ UTEST(EP_MC, MC_STATUS)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_STATUS_h = "2003001a00ff000000001880d2c70008197f0b00320000b1fe312855";
char *buffer_STATUS_h = "2003001a00ff000000001980d2c70008197f0b00320000b1fe312855";

uint8_t *buffer_STATUS_b = NULL;
int buffer_STATUS_len = 0;
Expand Down Expand Up @@ -201,7 +201,7 @@ UTEST(EP_MC, MC_DUMP)

int status = CRYPTO_LIB_SUCCESS;

char *buffer_DUMP_h = "2003001a00ff000000001880d2c70008197f0b00330000b1fe312855";
char *buffer_DUMP_h = "2003001a00ff000000001980d2c70008197f0b00330000b1fe312855";

uint8_t *buffer_DUMP_b = NULL;
int buffer_DUMP_len = 0;
Expand Down Expand Up @@ -285,7 +285,7 @@ UTEST(EP_MC, MC_ERASE)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_ERASE_h = "2003001a00ff000000001880d2c70008197f0b00340000b1fe312855";
char *buffer_ERASE_h = "2003001a00ff000000001980d2c70008197f0b00340000b1fe312855";

uint8_t *buffer_ERASE_b = NULL;
int buffer_ERASE_len = 0;
Expand Down Expand Up @@ -367,7 +367,7 @@ UTEST(EP_MC, MC_SELF_TEST)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_SELF_h = "2003001a00ff000000001880d2c70008197f0b00350000b1fe312855";
char *buffer_SELF_h = "2003001a00ff000000001980d2c70008197f0b00350000b1fe312855";

uint8_t *buffer_SELF_b = NULL;
int buffer_SELF_len = 0;
Expand Down Expand Up @@ -450,7 +450,7 @@ UTEST(EP_MC, MC_ALARM_FLAG_RESET)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_ALARM_h = "2003001a00ff000000001880d2c70008197f0b00370000b1fe312855";
char *buffer_ALARM_h = "2003001a00ff000000001980d2c70008197f0b00370000b1fe312855";

uint8_t *buffer_ALARM_b = NULL;
int buffer_ALARM_len = 0;
Expand Down
22 changes: 11 additions & 11 deletions test/unit/ut_ep_sa_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ UTEST(EP_SA_MGMT, SA_6_REKEY_133)

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_REKEY_h =
"2003002a00ff000000001880d0ac0018197f0b0016000c00060085000000000000000000000000da959fc8555555555555";
"2003002a00ff000000001980d0ac0018197f0b0016000c00060085000000000000000000000000da959fc8555555555555";

uint8_t *buffer_REKEY_b = NULL;
int buffer_REKEY_len = 0;
Expand Down Expand Up @@ -83,7 +83,7 @@ UTEST(EP_SA_MGMT, SA_START_6)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_START_h = "2003002000ff000000001880d0ad000e197f0b001b0004000600003040f6f7a61a5555";
char *buffer_START_h = "2003002000ff000000001980d0ad000e197f0b001b0004000600003040f6f7a61a5555";

uint8_t *buffer_START_b = NULL;
int buffer_START_len = 0;
Expand Down Expand Up @@ -136,7 +136,7 @@ UTEST(EP_SA_MGMT, SA_6_READ_ARSN)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_READ_h = "2003001c00ff000000001880d0b0000a197f0b001000020006555555555555";
char *buffer_READ_h = "2003001c00ff000000001980d0b0000a197f0b001000020006555555555555";

uint8_t *buffer_READ_b = NULL;
int buffer_READ_len = 0;
Expand Down Expand Up @@ -224,7 +224,7 @@ UTEST(EP_SA_MGMT, SA_6_SET_ARSNW)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_SET_h = "2003001a00ff000000001880d0b1000a197f0b0015000400060955";
char *buffer_SET_h = "2003001a00ff000000001980d0b1000a197f0b0015000400060955";

uint8_t *buffer_SET_b = NULL;
int buffer_SET_len = 0;
Expand Down Expand Up @@ -283,7 +283,7 @@ UTEST(EP_SA_MGMT, SA_6_SET_ARSN)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_SET_h = "2003002800ff000000001880d0b10016197f0b001a000a0007112233445566778899AABB6413b5983e55";
char *buffer_SET_h = "2003002800ff000000001980d0b10016197f0b001a000a0007112233445566778899AABB6413b5983e55";

uint8_t *buffer_SET_b = NULL;
int buffer_SET_len = 0;
Expand Down Expand Up @@ -346,12 +346,12 @@ UTEST(EP_SA_MGMT, SA_6_STATUS)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_STATUS_h = "2003001800ff000000001880d0b00008197f0b001f00020006";
char *buffer_STATUS_h = "2003001800ff000000001980d0b00008197f0b001f00020006";
// |2003002000| = Primary Header
// |ff| = Ext. Procs
// |0000| = SPI
// |0000| = ARSN
// |1880| = CryptoLib App ID
// |1980| = CryptoLib App ID
// |d0b0| = seq, pktid
// |000e| = pkt_length
// |197f| = pusv, ack, st
Expand Down Expand Up @@ -438,7 +438,7 @@ UTEST(EP_SA_MGMT, SA_STOP_6)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_STOP_h = "2003001c00ff000000001880d0b6000a197f0b001e00020006938f21c4555555555555";
char *buffer_STOP_h = "2003001c00ff000000001980d0b6000a197f0b001e00020006938f21c4555555555555";

uint8_t *buffer_STOP_b = NULL;
int buffer_STOP_len = 0;
Expand Down Expand Up @@ -494,12 +494,12 @@ UTEST(EP_SA_MGMT, SA_EXPIRE_6)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_EXPIRE_h = "2003001c00ff000000001880d0b7000a197f0b001900020006f72e21c4555555555555";
char *buffer_EXPIRE_h = "2003001c00ff000000001980d0b7000a197f0b001900020006f72e21c4555555555555";
// |2003001c00| = Primary Header
// |ff| = Ext. Procs
// |0000| = SPI
// |0000| = ARSN
// |1880| = CryptoLib App ID
// |1980| = CryptoLib App ID
// |d0b7| = seq, pktid
// |000a| = pkt_length
// |197f| = pusv, ack, st
Expand Down Expand Up @@ -559,7 +559,7 @@ UTEST(EP_SA_MGMT, SA_STOP_SELF)
int status = CRYPTO_LIB_SUCCESS;

// NOTE: Added Transfer Frame header to the plaintext
char *buffer_STOP_h = "2003001c00ff000000001880d0b6000a197f0b001e00020000938f21c4555555555555";
char *buffer_STOP_h = "2003001c00ff000000001980d0b6000a197f0b001e00020000938f21c4555555555555";

uint8_t *buffer_STOP_b = NULL;
int buffer_STOP_len = 0;
Expand Down
Loading

0 comments on commit 33caa4d

Please sign in to comment.