Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nasa/nos3#202] TC commanding and SSP telemetry in NOS3 #236

Merged
merged 8 commits into from
Apr 30, 2024
2 changes: 1 addition & 1 deletion include/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ extern int32_t Crypto_Init_With_Configs(
CryptoConfig_t* crypto_config_p, GvcidManagedParameters_t* gvcid_managed_parameters_p,
SadbMariaDBConfig_t* sa_mariadb_config_p,
CryptographyKmcCryptoServiceConfig_t* cryptography_kmc_crypto_config_p); // Initialize CryptoLib With Application Defined Configuration
extern int32_t Crypto_TC_Init(void);
extern int32_t Crypto_SC_Init(void); // Initialize CryptoLib with Spacecraft default Configurations
extern int32_t Crypto_Init_TC_Unit_Test(void); // Initialize CryptoLib with unit test default Configurations
extern int32_t Crypto_Init_TM_Unit_Test(void); // Initialize CryptoLib with unit test default Configurations
extern int32_t Crypto_Init_AOS_Unit_Test(void); // Initialize CryptoLib with unit test default Configurations
Expand Down
8 changes: 4 additions & 4 deletions src/core/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ uint16_t Crypto_Calc_FECF(const uint8_t* ingest, int len_ingest)
}
}
// Check if Testing
if (badFECF == 1)
{
fecf++;
}
//if (badFECF == 1)
//{
// fecf++;
//}

#ifdef FECF_DEBUG
int x;
Expand Down
16 changes: 13 additions & 3 deletions src/core/crypto_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,21 @@ int32_t crypto_free_config_structs(void);
* @brief Function: Crypto_Init_TC_Unit_Test
* @return int32: status
**/
int32_t Crypto_TC_Init(void)
int32_t Crypto_SC_Init(void)
{
int32_t status = CRYPTO_LIB_SUCCESS;
status = Crypto_Init_TC_Unit_Test();
Crypto_Config_CryptoLib(KEY_TYPE_INTERNAL, MC_TYPE_INTERNAL, SA_TYPE_INMEMORY, CRYPTOGRAPHY_TYPE_LIBGCRYPT,
IV_INTERNAL, CRYPTO_TC_CREATE_FECF_TRUE, TC_PROCESS_SDLS_PDUS_TRUE,
TC_HAS_PUS_HDR, TC_IGNORE_SA_STATE_FALSE, TC_IGNORE_ANTI_REPLAY_FALSE,
TC_UNIQUE_SA_PER_MAP_ID_FALSE, TC_CHECK_FECF_TRUE, 0x3F,
SA_INCREMENT_NONTRANSMITTED_IV_TRUE);
// TC
Crypto_Config_Add_Gvcid_Managed_Parameter(0, 0x0003, 0, TC_HAS_FECF, TC_HAS_SEGMENT_HDRS, 1024, AOS_FHEC_NA, AOS_IZ_NA, 0);
Crypto_Config_Add_Gvcid_Managed_Parameter(0, 0x0003, 4, TC_HAS_FECF, TC_HAS_SEGMENT_HDRS, 1024, AOS_FHEC_NA, AOS_IZ_NA, 0);

// TM
Crypto_Config_Add_Gvcid_Managed_Parameter(0, 0x0003, 1, TM_HAS_FECF, TM_SEGMENT_HDRS_NA, 1786, AOS_FHEC_NA, AOS_IZ_NA, 0);
status = Crypto_Init();
return status;
}

Expand All @@ -75,7 +86,6 @@ int32_t Crypto_Init_TC_Unit_Test(void)
Crypto_Config_Add_Gvcid_Managed_Parameter(0, 0x0003, 1, TC_HAS_FECF, TC_HAS_SEGMENT_HDRS, 1024, AOS_FHEC_NA, AOS_IZ_NA, 0);
Crypto_Config_Add_Gvcid_Managed_Parameter(0, 0x0003, 4, TC_HAS_FECF, TC_HAS_SEGMENT_HDRS, 1024, AOS_FHEC_NA, AOS_IZ_NA, 0);
status = Crypto_Init();
printf("Crypto_Init TC Called.\n");
return status;
}

Expand Down
26 changes: 11 additions & 15 deletions src/sa/internal/sa_interface_inmemory.template.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ int32_t sa_config(void)
int32_t status = CRYPTO_LIB_SUCCESS;

// Security Associations
// SA 1 - CLEAR MODE
// SA 1 VC0/1 is now SA 1-VC0, SA 8-VC1
// SA 1 - TC CLEAR MODE
sa[1].spi = 1;
sa[1].sa_state = SA_OPERATIONAL;
sa[1].est = 0;
Expand All @@ -89,21 +88,18 @@ int32_t sa_config(void)
sa[1].gvcid_blk.vcid = 0;
sa[1].gvcid_blk.mapid = TYPE_TC;

// SA 2 - KEYED; ARSNW:5; AES-GCM; IV:00...00; IV-len:12; MAC-len:16; Key-ID: 128
sa[2].spi = 2;
sa[2].ekid = 128;
sa[2].sa_state = SA_KEYED;
sa[2].est = 1;
sa[2].ast = 1;
sa[2].ecs_len = 1;
sa[2].ecs = CRYPTO_CIPHER_AES256_GCM;
sa[2].shivf_len = 12;
sa[2].iv_len = 12;
*(sa[2].iv + sa[2].shivf_len - 1) = 0;
sa[2].abm_len = ABM_SIZE; // 20
// SA 2 - TM CLEAR MODE
sa[2].spi = 8;
sa[2].sa_state = SA_OPERATIONAL;
sa[2].est = 0;
sa[2].ast = 0;
sa[2].arsn_len = 1;
sa[2].arsnw_len = 1;
sa[2].arsnw = 5;
sa[2].arsn_len = (sa[2].arsnw * 2) + 1;
sa[2].gvcid_blk.tfvn = 0;
sa[2].gvcid_blk.scid = SCID & 0x3FF;
sa[2].gvcid_blk.vcid = 1;
sa[2].gvcid_blk.mapid = TYPE_TM;

// SA 3 - KEYED; ARSNW:5; AES-GCM; IV:00...00; IV-len:12; MAC-len:16; Key-ID: 129
sa[3].spi = 3;
Expand Down
Loading
Loading