Skip to content

Commit

Permalink
[#196] Update Doxygen boilerplate, add prototypes to crypto.h from cr…
Browse files Browse the repository at this point in the history
…ypto.c
  • Loading branch information
rjbrown6 committed Mar 26, 2024
1 parent 26729a4 commit 687addd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
4 changes: 4 additions & 0 deletions include/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ int32_t Crypto_Check_Anti_Replay(SecurityAssociation_t *sa_ptr, uint8_t *arsn, u
int32_t Crypto_Get_ECS_Algo_Keylen(uint8_t algo);
int32_t Crypto_Get_ACS_Algo_Keylen(uint8_t algo);

int32_t Crypto_Check_Anti_Replay_Verify_Pointers(SecurityAssociation_t* sa_ptr, uint8_t* arsn, uint8_t* iv);
int32_t Crypto_Check_Anti_Replay_ARSNW(SecurityAssociation_t* sa_ptr, uint8_t* arsn, int8_t* arsn_valid);
int32_t Crypto_Check_Anti_Replay_GCM(SecurityAssociation_t* sa_ptr, uint8_t* iv, int8_t* iv_valid);

// Key Management Functions
int32_t Crypto_Key_OTAR(void);
int32_t Crypto_Key_update(uint8_t state);
Expand Down
60 changes: 49 additions & 11 deletions src/core/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,14 @@ int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t* tc_sdls_processed_frame, uin
return status;
} // End Process SDLS PDU


/**
* @brief Function: Crypto_Check_Anti_Replay_Verify_Pointers
* Sanity Check, validates pointers, verifies non-null
* @param sa_ptr: SecurityAssociation_t*
* @param arsn: uint8_t*
* @param iv: uint8_t*
**/
int32_t Crypto_Check_Anti_Replay_Verify_Pointers(SecurityAssociation_t* sa_ptr, uint8_t* arsn, uint8_t* iv)
{
int32_t status = CRYPTO_LIB_SUCCESS;
Expand All @@ -827,6 +835,13 @@ int32_t Crypto_Check_Anti_Replay_Verify_Pointers(SecurityAssociation_t* sa_ptr,
return status;
}

/**
* @brief Function: Crypto_Check_Anti_Replay_ARSNW
* Sanity Check, validates ARSN within window
* @param sa_ptr: SecurityAssociation_t*
* @param arsn: uint8_t*
* @param arsn_valid: uint8_t*
**/
int32_t Crypto_Check_Anti_Replay_ARSNW(SecurityAssociation_t* sa_ptr, uint8_t* arsn, int8_t* arsn_valid)
{
int32_t status = CRYPTO_LIB_SUCCESS;
Expand Down Expand Up @@ -862,6 +877,13 @@ int32_t Crypto_Check_Anti_Replay_ARSNW(SecurityAssociation_t* sa_ptr, uint8_t* a
return status;
}

/**
* @brief Function: Crypto_Check_Anti_Replay_GCM
* Sanity Check, validates IV within window
* @param sa_ptr: SecurityAssociation_t*
* @param iv: uint8_t*
* @param iv_valid: uint8_t*
**/
int32_t Crypto_Check_Anti_Replay_GCM(SecurityAssociation_t* sa_ptr, uint8_t* iv, int8_t* iv_valid)
{
int32_t status = CRYPTO_LIB_SUCCESS;
Expand Down Expand Up @@ -905,9 +927,13 @@ int32_t Crypto_Check_Anti_Replay_GCM(SecurityAssociation_t* sa_ptr, uint8_t* iv,
return status;
}

/*
** @brief: Check IVs and ARSNs to ensure within valid positive window if applicable
*/
/**
* @brief Function: Crypto_Check_Anti_Replay
* Verifies data within window.
* @param sa_ptr: SecurityAssociation_t*
* @param arsn: uint8_t*
* @param iv: uint8_t*
**/
int32_t Crypto_Check_Anti_Replay(SecurityAssociation_t* sa_ptr, uint8_t* arsn, uint8_t* iv)
{
int32_t status = CRYPTO_LIB_SUCCESS;
Expand Down Expand Up @@ -960,10 +986,11 @@ int32_t Crypto_Check_Anti_Replay(SecurityAssociation_t* sa_ptr, uint8_t* arsn, u
return status;
}

/*
** @brief: For a given algorithm, return the associated key length in bytes
** @param: algo
*/
/**
* @brief: Function: Crypto_Get_ECS_Algo_Keylen
* For a given algorithm, return the associated key length in bytes
* @param algo: uint8_t
**/
int32_t Crypto_Get_ECS_Algo_Keylen(uint8_t algo)
{
int32_t retval = -1;
Expand All @@ -986,10 +1013,11 @@ int32_t Crypto_Get_ECS_Algo_Keylen(uint8_t algo)
return retval;
}

/*
** @brief: For a given algorithm, return the associated key length in bytes
** @param: algo
*/
/**
* @brief: Function: Crypto_Get_ACS_Algo_Keylen
* For a given algorithm, return the associated key length in bytes
* @param algo: uint8_t
**/
int32_t Crypto_Get_ACS_Algo_Keylen(uint8_t algo)
{
int32_t retval = -1;
Expand All @@ -1012,6 +1040,11 @@ int32_t Crypto_Get_ACS_Algo_Keylen(uint8_t algo)
return retval;
}

/**
* @brief: Function: Crypto_Get_Security_Header_Length
* Return Security Header Length
* @param sa_ptr: SecurityAssociation_t*
**/
int32_t Crypto_Get_Security_Header_Length(SecurityAssociation_t* sa_ptr)
{
/* Narrator's Note: Leaving this here for future work
Expand All @@ -1035,6 +1068,11 @@ int32_t Crypto_Get_Security_Header_Length(SecurityAssociation_t* sa_ptr)
return securityHeaderLength;
}

/**
* @brief: Function: Crypto_Get_Security_Trailer_Length
* Return Security Header Length
* @param sa_ptr: SecurityAssociation_t*
**/
int32_t Crypto_Get_Security_Trailer_Length(SecurityAssociation_t* sa_ptr)
{
if (!sa_ptr)
Expand Down

0 comments on commit 687addd

Please sign in to comment.