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

Merge 77 Cryptolib Load_Config Save -> Dev #237

Merged
merged 8 commits into from
May 2, 2024
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ option(SUPPORT "Support" OFF)
option(SYSTEM_INSTALL "SystemInstall" OFF)
option(TEST "Test" OFF)
option(TEST_ENC "Tests - Encryption" OFF)
option(SA_FILE "Save Security Association to File" OFF)

OPTION(KMC_MDB_RH "KMC-MDB-RedHat-Integration-Testing" OFF) #Disabled by default, enable with: -DKMC_MDB_RH=ON
OPTION(KMC_MDB_DB "KMC-MDB-Debian-Integration-Testing" OFF) #Disabled by default, enable with: -DKMC_MDB_DB=ON
Expand All @@ -53,6 +54,10 @@ if(CODECOV)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
endif()

if(SA_FILE)
add_definitions(-DSA_FILE)
endif()

if(DEBUG)
add_definitions(-DDEBUG -DOCF_DEBUG -DFECF_DEBUG -DSA_DEBUG -DPDU_DEBUG -DCCSDS_DEBUG -DTC_DEBUG -DMAC_DEBUG -DTM_DEBUG -DAOS_DEBUG)
add_compile_options(-ggdb)
Expand Down
8 changes: 8 additions & 0 deletions include/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
#define CRYPTO_LIB_REVISION 2
#define CRYPTO_LIB_MISSION_REV 0

/*
** SAVE FILE NAME/LOCATION
*/
#define CRYPTO_SA_SAVE "sa_save_file.bin"

/*
** TC_BLOCK_SIZE
*/
Expand Down Expand Up @@ -230,6 +235,9 @@ int32_t Crypto_User_ModifyKey(void);
int32_t Crypto_User_ModifyActiveTM(void);
int32_t Crypto_User_ModifyVCID(void);

// SA Save Functions
int32_t sa_perform_save(SecurityAssociation_t* sa);

// Determine Payload Data Unit
int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t* tc_sdls_processed_frame, uint8_t* ingest);
int32_t Crypto_PDU(uint8_t* ingest, TC_t* tc_frame);
Expand Down
2 changes: 2 additions & 0 deletions include/crypto_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
#define CRYPTO_LIB_ERR_INPUT_FRAME_TOO_SHORT_FOR_AOS_STANDARD (-49)
#define CRYPTO_LIB_ERR_TC_ENUM_USED_FOR_AOS_CONFIG (-50)
#define CRYPTO_LIB_ERR_INVALID_SA_SERVICE_TYPE (-51)
#define CRYPTO_LIB_ERR_FAIL_SA_SAVE (-52)
#define CRYPTO_LIB_ERR_FAIL_SA_LOAD (-53)

extern char *crypto_enum_errlist_core[];
extern char *crypto_enum_errlist_config[];
Expand Down
2 changes: 2 additions & 0 deletions src/core/crypto_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ char *crypto_enum_errlist_core[] =
(char*) "CRYPTO_LIB_ERR_INPUT_FRAME_TOO_SHORT_FOR_AOS_STANDARD",
(char*) "CRYPTO_LIB_ERR_TC_ENUM_USED_FOR_AOS_CONFIG",
(char*) "CRYPTO_LIB_ERR_INVALID_SA_SERVICE_TYPE",
(char*) "CRYPTO_LIB_ERR_FAIL_SA_SAVE",
(char*) "CRYPTO_LIB_ERR_FAIL_SA_LOAD",
};

char *crypto_enum_errlist_config[] =
Expand Down
6 changes: 3 additions & 3 deletions src/core/crypto_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ void Crypto_saPrint(SecurityAssociation_t* sa)
}
}
printf("\t ekid = %d \n", sa->ekid);
printf("\t ek_ref = %s \n", sa->ek_ref);
//printf("\t ek_ref = %s \n", sa->ek_ref);
printf("\t akid = %d \n", sa->akid);
printf("\t ak_ref = %s \n", sa->ak_ref);
printf("\t iv_len = %d \n", sa->shivf_len);
//printf("\t ak_ref = %s \n", sa->ak_ref);
printf("\t iv_len = %d \n", sa->iv_len);
if (sa->iv_len > 0)
{
for (i = 0; i < sa->iv_len; i++)
Expand Down
Loading
Loading