Skip to content

Commit

Permalink
[#77] SA_SAVE - Filename define
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbrown2 committed Apr 30, 2024
1 parent 624dd1a commit a9a6cf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 5 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
12 changes: 4 additions & 8 deletions src/sa/internal/sa_interface_inmemory.template.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int32_t sa_load_file()
int32_t status = CRYPTO_LIB_SUCCESS;
int success_flag = 0;

sa_save_file = fopen("sa_save_file.bin", "rb+"); // Should this be rb instead of wb+
sa_save_file = fopen(CRYPTO_SA_SAVE, "rb+"); // Should this be rb instead of wb+

if (sa_save_file == NULL)
{
Expand Down Expand Up @@ -172,7 +172,7 @@ int32_t sa_perform_save(SecurityAssociation_t* sa_ptr)

update_sa_from_ptr(sa_ptr);

sa_save_file = fopen("sa_save_file.bin", "wb");
sa_save_file = fopen(CRYPTO_SA_SAVE, "wb");

if (sa_save_file == NULL)
{
Expand Down Expand Up @@ -218,11 +218,7 @@ static int32_t sa_save_sa(SecurityAssociation_t* sa)
status = sa_perform_save(sa);
ignore_save = 0;
#endif
if (ignore_save) sa = sa; // TODO - use argument

// We could do a memory copy of the SA into the sa[NUM_SA] array at the given SPI, however, the inmemory code
// currently updates in place so no need for that.
// If we change the in-place update logic, we should update this function to actually update the SA.
if (ignore_save) sa = sa;
return status;
}

Expand Down Expand Up @@ -586,7 +582,7 @@ int32_t sa_init(void)
#ifdef SA_FILE
use_internal = 0;
status = sa_load_file();
if (status != CRYPTO_LIB_SUCCESS) //Do we error out here, or is it ok to do as below and populate with internal on failure.
if (status != CRYPTO_LIB_SUCCESS)
{
#ifdef DEBUG
printf("SA Load Failure!\n");
Expand Down

0 comments on commit a9a6cf0

Please sign in to comment.