Skip to content

Commit 9912149

Browse files
authored
Merge pull request #419 from nasa/310-clean-up-commented-code
310 clean up commented code
2 parents ab83e91 + 879dfba commit 9912149

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+166
-6457
lines changed

include/crypto.h

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ int32_t Crypto_TC_Accio_Buffer(uint8_t **p_new_enc_frame, uint16_t *p_enc_frame_
138138
int32_t Crypto_TC_ACS_Algo_Check(SecurityAssociation_t *sa_ptr);
139139
int32_t Crypto_TC_Check_IV_Setup(SecurityAssociation_t *sa_ptr, uint8_t *p_new_enc_frame, uint16_t *index);
140140
int32_t Crypto_TC_Encrypt(uint8_t sa_service_type, SecurityAssociation_t *sa_ptr, uint16_t *mac_loc,
141-
uint16_t tf_payload_len, uint8_t segment_hdr_len, uint8_t *p_new_enc_frame,
142-
crypto_key_t *ekp, uint8_t **aad, uint8_t ecs_is_aead_algorithm,
143-
uint16_t *index_p, const uint8_t *p_in_frame, char *cam_cookies,
144-
uint32_t pkcs_padding);
141+
uint16_t tf_payload_len, uint8_t segment_hdr_len, uint8_t *p_new_enc_frame, crypto_key_t *ekp,
142+
uint8_t **aad, uint8_t ecs_is_aead_algorithm, uint16_t *index_p, const uint8_t *p_in_frame,
143+
char *cam_cookies, uint32_t pkcs_padding);
145144
void Crypto_TC_Increment_IV_ARSN(uint8_t sa_service_type, SecurityAssociation_t *sa_ptr);
146145
int32_t Crypto_TC_Do_Encrypt(uint8_t sa_service_type, SecurityAssociation_t *sa_ptr, uint16_t *mac_loc,
147146
uint16_t tf_payload_len, uint8_t segment_hdr_len, uint8_t *p_new_enc_frame,
@@ -319,7 +318,7 @@ extern TM_FrameSecurityHeader_t tm_frame_sec_hdr; // Used to reduce bit math dup
319318
// exterm AOS_t aos_frame
320319
extern AOS_FramePrimaryHeader_t aos_frame_pri_hdr;
321320
extern AOS_FrameSecurityHeader_t aos_frame_sec_hdr; // Used to reduce bit math duplication
322-
extern uint8_t parity[4]; // Used in FHECF calc
321+
extern uint8_t parity[4]; // Used in FHECF calc
323322

324323
// Global configuration structs
325324
extern CryptoConfig_t crypto_config;
@@ -361,14 +360,10 @@ extern uint32_t crc32Table[CRC32TBL_SIZE];
361360
extern uint16_t crc16Table[CRC16TBL_SIZE];
362361

363362
// GF(2^4) field and logarithm tables
364-
static const uint8_t gf_exp[30] = {
365-
1, 2, 4, 8, 3, 6, 12, 11, 5, 10, 7, 14, 15, 13, 9, 1,
366-
2, 4, 8, 3, 6, 12, 11, 5, 10, 7, 14, 15, 13, 9
367-
};
368-
369-
static const uint8_t gf_log[GF_SIZE] = {
370-
0, 0, 1, 4, 2, 8, 5, 10, 3, 14, 9, 7, 6, 13, 11, 12
371-
};
363+
static const uint8_t gf_exp[30] = {1, 2, 4, 8, 3, 6, 12, 11, 5, 10, 7, 14, 15, 13, 9,
364+
1, 2, 4, 8, 3, 6, 12, 11, 5, 10, 7, 14, 15, 13, 9};
365+
366+
static const uint8_t gf_log[GF_SIZE] = {0, 0, 1, 4, 2, 8, 5, 10, 3, 14, 9, 7, 6, 13, 11, 12};
372367

373368
// Generator polynomial coefficients for g(x) = x^4 + a^3x^3 + ax^2 + a^3x + 1
374369
static const uint8_t gen_poly[RS_PARITY + 1] = {1, 8, 2, 8, 1};

include/crypto_config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@
235235

236236
// AOS Behavior Defines
237237
// FHECF Calculation
238-
#define RS_SYMS 10 // Total symbols in codeword
239-
#define RS_DATA 6 // Data symbols
238+
#define RS_SYMS 10 // Total symbols in codeword
239+
#define RS_DATA 6 // Data symbols
240240
#define RS_PARITY 4 // Parity symbols
241-
#define GF_SIZE 16 // 2^4
241+
#define GF_SIZE 16 // 2^4
242242

243243
// Logic Behavior Defines
244244
#define CRYPTO_FALSE 0

include/sa_interface.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,5 @@ typedef struct
5252
SaInterface get_sa_interface_custom(void);
5353
SaInterface get_sa_interface_inmemory(void);
5454
SaInterface get_sa_interface_mariadb(void);
55-
// SaInterface init_parse_sa_routine(uint8_t* );
5655

5756
#endif // CRYPTOLIB_SA_INTERFACE_H

src/core/crypto.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ CFS_MODULE_DECLARE_LIB(crypto);
3232
/*
3333
** Global Variables
3434
*/
35-
// crypto_key_t ak_ring[NUM_KEYS];
3635
// SDLS Replies
3736
SDLS_KEYV_RPLY_t sdls_ep_keyv_reply; // Reply block for challenged keys
3837
uint8_t sdls_ep_reply[TC_MAX_FRAME_SIZE];
3938
CCSDS_t sdls_frame;
40-
// TM_t tm_frame;
39+
// TM
4140
uint8_t tm_frame[TM_MAX_FRAME_SIZE]; // TM Global Frame
4241
TM_FramePrimaryHeader_t tm_frame_pri_hdr; // Used to reduce bit math duplication
4342
TM_FrameSecurityHeader_t tm_frame_sec_hdr; // Used to reduce bit math duplication
44-
// AOS_t aos_frame
43+
// AOS
4544
uint8_t aos_frame[AOS_MAX_FRAME_SIZE]; // AOS Global Frame
4645
AOS_FramePrimaryHeader_t aos_frame_pri_hdr; // Used to reduce bit math duplication
4746
AOS_FrameSecurityHeader_t aos_frame_sec_hdr; // Used to reduce bit math duplication
@@ -404,9 +403,9 @@ uint16_t Crypto_Calc_CRC16(uint8_t *data, int size)
404403
return crc;
405404
}
406405

407-
uint8_t gf_mul(uint8_t a, uint8_t b)
406+
uint8_t gf_mul(uint8_t a, uint8_t b)
408407
{
409-
if (a == 0 || b == 0)
408+
if (a == 0 || b == 0)
410409
{
411410
return 0;
412411
}
@@ -420,20 +419,20 @@ uint8_t gf_mul(uint8_t a, uint8_t b)
420419
// Reference: CCSDS 732.0-B-4 (AOS Space Data Link Protocol) Section 4.1.2.6
421420
uint16_t Crypto_Calc_FHECF(uint8_t *data)
422421
{
423-
uint8_t feedback = 0;
424-
uint16_t result = 0;
425-
int i = 0;
426-
int j = 0;
422+
uint8_t feedback = 0;
423+
uint16_t result = 0;
424+
int i = 0;
425+
int j = 0;
427426

428427
// RS encoding
429428
memset(parity, 0, RS_PARITY);
430-
for (i = 0; i < RS_DATA; i++)
429+
for (i = 0; i < RS_DATA; i++)
431430
{
432431
feedback = data[i] ^ parity[0];
433432
memmove(&parity[0], &parity[1], RS_PARITY - 1);
434433
parity[RS_PARITY - 1] = 0;
435434

436-
for (j = 0; j < RS_PARITY; j++)
435+
for (j = 0; j < RS_PARITY; j++)
437436
{
438437
parity[j] ^= gf_mul(feedback, gen_poly[j + 1]);
439438
}

0 commit comments

Comments
 (0)