Skip to content

Commit

Permalink
[nasa/nos3#202] Updated sa_service_type check that caused error print…
Browse files Browse the repository at this point in the history
…s and made standalone TC calculate FECF;
  • Loading branch information
jlucas9 committed Mar 20, 2024
1 parent 174e896 commit dd6065a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/crypto_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,10 @@ int32_t Crypto_TC_ApplySecurity_Cam(const uint8_t* p_in_frame, const uint16_t in
}
}

if (sa_service_type != (SA_PLAINTEXT || SA_AUTHENTICATED_ENCRYPTION || SA_ENCRYPTION || SA_AUTHENTICATION))
if ((sa_service_type != SA_PLAINTEXT) &&
(sa_service_type != SA_AUTHENTICATED_ENCRYPTION) &&
(sa_service_type != SA_ENCRYPTION) &&
(sa_service_type != SA_AUTHENTICATION))
{
printf(KRED "Unknown SA Service Type Detected!" RESET);
}
Expand Down
6 changes: 6 additions & 0 deletions support/standalone/standalone.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ void *crypto_standalone_tc_apply(void* socks)
uint16_t tc_in_len = 0;
uint8_t* tc_out_ptr;
uint16_t tc_out_len = 0;
uint16_t fecf;

#ifdef CRYPTO_STANDALONE_HANDLE_FRAMING
uint8_t tc_framed[TC_MAX_FRAME_SIZE];
Expand Down Expand Up @@ -392,6 +393,11 @@ void *crypto_standalone_tc_apply(void* socks)
status = Crypto_TC_ApplySecurity(tc_apply_in, tc_in_len, &tc_out_ptr, &tc_out_len);
if (status == CRYPTO_LIB_SUCCESS)
{
/* Calculate FECF */
fecf = Crypto_Calc_FECF(tc_out_ptr, tc_out_len - 2);
tc_out_ptr[tc_out_len - 2] = (uint8_t)((fecf & 0xFF00) >> 8);
tc_out_ptr[tc_out_len - 1] = (uint8_t)(fecf & 0x00FF);

if (tc_debug == 1)
{
printf("crypto_standalone_tc_apply - status = %d, encrypted[%d]: 0x", status, tc_out_len);
Expand Down

0 comments on commit dd6065a

Please sign in to comment.