Skip to content

CryptoLib: Usage

Robert Brown edited this page Mar 8, 2022 · 14 revisions

Apply/Process Functions

Crypto_TC_ApplySecurity

int32 Crypto_TC_ApplySecurity(const uint8* p_in_frame, const uint16 in_frame_length, uint8 **pp_in_frame, uint16 *p_enc_frame_len)

Performs various types of encryption on the passed input frame. This could be, Encryption only, Authentication only, and Authenticated Encryption.

Function inputs:

p_in_frame: Frame to be encrypted. Must match an expected format, and properly activated security association. Proper formatting includes valid transfer frame version number. Valid Spacecraft Id, Virtual Channel ID, Map ID, Command Control Flag, and an operational Security Association.

in_frame_length: The int16 length of p_in_frame.

pp_in_frame: pointer to pointer of a uint8 buffer where data will be stored once fully encrypted.

p_enc_frame_len: pointer to uint16 that will store the length of the pointed to pp_in_frame.

Function Return: Error / Success codes of function:

Success / Error Code Description Constant
Success / No Error CRYPTO_LIB_SUCCESS (0)
General Error CRYPTO_LIB_ERROR (-1)
No Initialization CRYPTO_LIB_ERR_NO_INIT (-2)
Invalid Transfer Frame Version Number CRYPTO_LIB_ERR_INVALID_TFVN (-3)
Invalid Spacecraft ID CRYPTO_LIB_ERR_INVALID_SCID (-4)
Invalid Virtual Channel ID CRYPTO_LIB_ERR_INVALID_VCID (-5)
Invalid Map ID CRYPTO_LIB_ERR_INVALID_MAPID (-6)
Invalid Command Control Flag CRYPTO_LIB_ERR_INVALID_CC_FLAG (-7)
No Operational Security Association CRYPTO_LIB_ERR_NO_OPERATIONAL_SA (-8)
Null Buffer CRYPTO_LIB_ERR_NULL_BUFFER (-9)
UT Byte Mismatch CRYPTO_LIB_ERR_NULL_BUFFER (-10)
No Configuration Set CRYPTO_LIB_ERR_NULL_BUFFER (-11)
Invalid FECF CRYPTO_LIB_ERR_NULL_BUFFER (-12)
Bad Antireplay Window CRYPTO_LIB_ERR_NULL_BUFFER (-13)
LibGCrypt Error CRYPTO_LIB_ERR_NULL_BUFFER (-14)
Authentication Error CRYPTO_LIB_ERR_NULL_BUFFER (-15)
Null IV CRYPTO_LIB_ERR_NULL_BUFFER (-16)
Null ABM CRYPTO_LIB_ERR_NULL_BUFFER (-17)
Decrypt Error CRYPTO_LIB_ERR_NULL_BUFFER (-18)
ABM too short for AAD CRYPTO_LIB_ERR_NULL_BUFFER (-19)
MAC Retrieval Error CRYPTO_LIB_ERR_NULL_BUFFER (-20)
MAC Validation Error CRYPTO_LIB_ERR_NULL_BUFFER (-21)
Invalid Header CRYPTO_LIB_ERR_NULL_BUFFER (-22)

Crypto_TC_ProcessSecurity

int32 Crypto_TC_ProcessSecurity(char* ingest, int* len_ingest, TC_t* tc_sdls_processed_frame)

Loads the ingest frame into the global tc_frame while performing various types of decryption. This could be decryption only, authentication only, or authenticated decryption.

Function Inputs:

ingest: Pointer to a character array that holds the encrypted ingest frame.

len_ingest: Pointer to the integer that holds the length of the ingest frame.

tc_sdls_processed_frame: Pointer to the TC_t structure that holds the header, sec_header, pdu, pdu_len, and sec_trailer. Many of these structure types themselves that are used to break apart and give various specific information about the processed frame.

Function Return Values:

The return values for TC_ProcessSecurity are the same as those mentioned above for the Apply Security funciton.


Clone this wiki locally