Skip to content

Commit d3ccd23

Browse files
authored
Merge pull request #328 from nasa/316-cryptoc-cleanup
316 cryptoc cleanup
2 parents 7fb1b16 + 17d6806 commit d3ccd23

File tree

4 files changed

+536
-566
lines changed

4 files changed

+536
-566
lines changed

include/crypto.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ void clean_akref(SecurityAssociation_t* sa);
235235
// Determine Payload Data Unit
236236
int32_t Crypto_Process_Extended_Procedure_Pdu(TC_t* tc_sdls_processed_frame, uint8_t* ingest);
237237
int32_t Crypto_PDU(uint8_t* ingest, TC_t* tc_frame);
238-
239-
// Helper length functions
240-
int32_t Crypto_Get_Security_Header_Length(SecurityAssociation_t* sa_ptr);
241-
int32_t Crypto_Get_Security_Trailer_Length(SecurityAssociation_t* sa_ptr);
238+
int32_t Crypto_SG_KEY_MGMT(uint8_t* ingest, TC_t* tc_frame);
239+
int32_t Crypto_SG_SA_MGMT(uint8_t* ingest, TC_t* tc_frame);
240+
int32_t Crypto_SEC_MON_CTRL(uint8_t* ingest);
241+
int32_t Crypto_USER_DEFINED_CMD(uint8_t* ingest);
242242

243243
// Managed Parameter Functions
244244
int32_t Crypto_Get_Managed_Parameters_For_Gvcid(uint8_t tfvn, uint16_t scid, uint8_t vcid,

include/crypto_config.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
// Max Frame Size
4848
#define TC_MAX_FRAME_SIZE 1024
49+
#define TM_MAX_FRAME_SIZE 1786
50+
#define AOS_MAX_FRAME_SIZE 1786
4951

5052
// Spacecraft Defines
5153
#define SCID 0x0003
@@ -88,6 +90,17 @@
8890
#define KEY_DESTROYED 3
8991
#define KEY_CORRUPTED 4
9092

93+
// Key Length Defines
94+
// ECS
95+
#define AES256_GCM_KEYLEN 32
96+
#define AES256_GCM_SIV_KEYLEN 32
97+
#define AES256_CBC_KEYLEN 32
98+
#define AES256_CCM_KEYLEN 32
99+
// ACS
100+
#define CMAC_AES256_KEYLEN 32
101+
#define HMAC_SHA256_KEYLEN 32
102+
#define HMAC_SHA512_KEYLEN 64
103+
91104
// SA Service Types
92105
#define SA_PLAINTEXT 0
93106
#define SA_AUTHENTICATION 1
@@ -117,14 +130,23 @@
117130
#define PAD_SIZE 32 /* bytes */
118131
#define CHALLENGE_SIZE 16 /* bytes */
119132
#define CHALLENGE_MAC_SIZE 16 /* bytes */
133+
#define BYTE_LEN 8 /* bits */
120134

121135
// Monitoring and Control Defines
122136
#define EMV_SIZE 4 /* bytes */
123137
#define LOG_SIZE 50 /* packets */
124138
#define ST_OK 0x00
125139
#define ST_NOK 0xFF
126140

127-
// Procedure Identification (PID)
141+
// Protocol Data Unit (PDU)
142+
// PDU Type
143+
#define PDU_TYPE_COMMAND 0
144+
#define PDU_TYPE_REPLY 1
145+
// PDU User Flag
146+
#define PDU_USER_FLAG_TRUE 1
147+
#define PDU_USER_FLAG_FALSE 0
148+
149+
// Procedure Identification (PID) - CCSDS Defined Commands
128150
// Service Group - Key Management
129151
#define SG_KEY_MGMT 0x00 // 0b00
130152
#define PID_OTAR 0x01 // 0b0001
@@ -154,6 +176,16 @@
154176
#define PID_SELF_TEST 0x05 // 0b0101
155177
#define PID_ALARM_FLAG 0x07 // 0b0111
156178

179+
// Procedure Identification (PID) - User Defined Commands
180+
#define PID_IDLE_FRAME_TRIGGER 0
181+
#define PID_TOGGLE_BAD_SPI 1
182+
#define PID_TOGGLE_BAD_IV 2
183+
#define PID_TOGGLE_BAD_MAC 3
184+
#define PID_TOGGLE_BAD_FECF 4
185+
#define PID_MODIFY_KEY 5
186+
#define PID_MODIFY_ACTIVE_TM 6
187+
#define PID_MODIFY_VCID 7
188+
157189
// TC Defines
158190
#define TC_SH_SIZE 8 /* bits */
159191
#define TC_SN_SIZE 2

include/crypto_error.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
#define CRYPTO_LIB_ERR_KEY_VALIDATION (-55)
129129
#define CRYPTO_LIB_ERR_SPI_INDEX_OOB (-56)
130130
#define CRYPTO_LIB_ERR_SA_NOT_OPERATIONAL (-57)
131+
#define CRYPTO_LIB_ERR_IV_GREATER_THAN_MAX_LENGTH (-58)
131132

132133
// Define codes for returning MDB Strings, and determining error based on strings
133134
#define CAM_ERROR_CODES 600

0 commit comments

Comments
 (0)