Skip to content

Commit

Permalink
Merge pull request #237 from nasa/77-cryptolib_load_config-save
Browse files Browse the repository at this point in the history
Merge 77 Cryptolib Load_Config Save -> Dev
  • Loading branch information
rjbrown2 committed May 2, 2024
2 parents 318c371 + f335be3 commit dad3686
Show file tree
Hide file tree
Showing 23 changed files with 1,217 additions and 56 deletions.
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

0 comments on commit dad3686

Please sign in to comment.