Skip to content

Commit a0ac542

Browse files
committed
[#341] Attempt to manually fix const suggestions, formatted
1 parent c77aba3 commit a0ac542

15 files changed

+177
-179
lines changed

.clang-format

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,9 @@
22
Language: Cpp
33
AccessModifierOffset: -4
44
AlignAfterOpenBracket: Align
5-
AlignConsecutiveAssignments:
6-
Enabled: true
7-
AcrossComments: true
8-
AlignCompound: true
9-
AlignConsecutiveDeclarations:
10-
Enabled: true
11-
AcrossComments: true
12-
AlignFunctionPointers: true
13-
AlignFunctionDeclarations: true
14-
AlignConsecutiveMacros:
15-
Enabled: true
16-
AcrossEmptyLines: true
17-
AcrossComments: false
5+
AlignConsecutiveAssignments: true
6+
AlignConsecutiveDeclarations: true
7+
AlignConsecutiveMacros: AcrossComments
188
AlignEscapedNewlines: Left
199
AlignOperands: true
2010
AlignTrailingComments: true
@@ -27,7 +17,7 @@ AllowShortLoopsOnASingleLine: false
2717
AlwaysBreakAfterReturnType: None
2818
AlwaysBreakBeforeMultilineStrings: false
2919
BinPackArguments: true
30-
BinPackParameters: BinPack
20+
BinPackParameters: true
3121
BreakBeforeBinaryOperators: None
3222
BreakBeforeBraces: Allman
3323
BreakBeforeTernaryOperators: true
@@ -46,8 +36,7 @@ IncludeIsMainRegex: '$'
4636
IndentCaseLabels: true
4737
IndentPPDirectives: None
4838
IndentWidth: 4
49-
KeepEmptyLines:
50-
AtStartOfBlock: true
39+
KeepEmptyLinesAtTheStartOfBlocks: false
5140
MacroBlockBegin: ''
5241
MacroBlockEnd: ''
5342
MaxEmptyLinesToKeep: 1
@@ -59,7 +48,7 @@ PenaltyBreakString: 1000
5948
PenaltyExcessCharacter: 1000000
6049
PenaltyReturnTypeOnItsOwnLine: 60
6150
PointerAlignment: Right
62-
ReflowComments: Always
51+
ReflowComments: true
6352
SortIncludes: Never
6453
SpaceAfterCStyleCast: false
6554
SpaceBeforeAssignmentOperators: true
@@ -68,8 +57,8 @@ SpaceInEmptyParentheses: false
6857
SpaceBeforeCpp11BracedList: true
6958
SpacesBeforeTrailingComments: 1
7059
SpacesInCStyleCastParentheses: false
71-
SpacesInParens: Never
60+
SpaceInEmptyParentheses: false
7261
SpacesInSquareBrackets: false
73-
Standard: c++11
62+
Standard: Latest
7463
TabWidth: 8
7564
UseTab: Never

include/crypto.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ extern int32_t Crypto_Init_AOS_Unit_Test(void); // Initialize CryptoLib with uni
9595
extern int32_t Crypto_Shutdown(void); // Free all allocated memory
9696

9797
// Telecommand (TC)
98-
extern int32_t Crypto_TC_ApplySecurity(const uint8_t *p_in_frame, uint16_t in_frame_length,
99-
uint8_t **pp_enc_frame, uint16_t *p_enc_frame_len);
98+
extern int32_t Crypto_TC_ApplySecurity(const uint8_t *p_in_frame, uint16_t in_frame_length, uint8_t **pp_enc_frame,
99+
uint16_t *p_enc_frame_len);
100100
extern int32_t Crypto_TC_ProcessSecurity(uint8_t *ingest, int *len_ingest, TC_t *tc_sdls_processed_frame);
101-
extern int32_t Crypto_TC_ApplySecurity_Cam(const uint8_t *p_in_frame, uint16_t in_frame_length,
102-
uint8_t **pp_enc_frame, uint16_t *p_enc_frame_len, char *cam_cookies);
101+
extern int32_t Crypto_TC_ApplySecurity_Cam(const uint8_t *p_in_frame, uint16_t in_frame_length, uint8_t **pp_enc_frame,
102+
uint16_t *p_enc_frame_len, char *cam_cookies);
103103
extern int32_t Crypto_TC_ProcessSecurity_Cam(uint8_t *ingest, int *len_ingest, TC_t *tc_sdls_processed_frame,
104104
char *cam_cookies);
105105

@@ -174,7 +174,7 @@ extern int32_t Crypto_AOS_ProcessSecurity(uint8_t *p_ingest, uint16_t len_ingest
174174
uint16_t *p_decrypted_length);
175175

176176
// Crypo Error Support Functions
177-
extern char *Crypto_Get_Error_Code_Enum_String(int32_t crypto_error_code);
177+
extern const char *Crypto_Get_Error_Code_Enum_String(int32_t crypto_error_code);
178178

179179
/*
180180
** Internal Prototypes
@@ -226,7 +226,7 @@ int32_t Crypto_Get_tmLength(int len);
226226
uint8_t Crypto_Is_AEAD_Algorithm(uint32_t cipher_suite_id);
227227
void Crypto_TM_updatePDU(uint8_t *ingest, int len_ingest);
228228
void Crypto_TM_updateOCF(Telemetry_Frame_Ocf_Fsr_t *report, TM_t *tm_frame);
229-
uint8_t *Crypto_Prepare_TC_AAD(uint8_t *buffer, uint16_t len_aad, uint8_t *abm_buffer);
229+
uint8_t *Crypto_Prepare_TC_AAD(uint8_t *buffer, uint16_t len_aad, uint8_t *abm_buffer);
230230
uint32_t Crypto_Prepare_TM_AAD(const uint8_t *buffer, uint16_t len_aad, const uint8_t *abm_buffer, uint8_t *aad);
231231
uint32_t Crypto_Prepare_AOS_AAD(const uint8_t *buffer, uint16_t len_aad, const uint8_t *abm_buffer, uint8_t *aad);
232232
void Crypto_Local_Config(void);
@@ -312,11 +312,11 @@ extern AOS_FrameSecurityHeader_t aos_frame_sec_hdr; // Used to reduce bit math d
312312

313313
// Global configuration structs
314314
extern CryptoConfig_t crypto_config;
315-
extern SadbMariaDBConfig_t *sa_mariadb_config;
315+
extern SadbMariaDBConfig_t *sa_mariadb_config;
316316
extern CryptographyKmcCryptoServiceConfig_t *cryptography_kmc_crypto_config;
317-
extern CamConfig_t *cam_config;
318-
extern GvcidManagedParameters_t *gvcid_managed_parameters;
319-
extern GvcidManagedParameters_t *current_managed_parameters;
317+
extern CamConfig_t *cam_config;
318+
extern GvcidManagedParameters_t *gvcid_managed_parameters;
319+
extern GvcidManagedParameters_t *current_managed_parameters;
320320
extern GvcidManagedParameters_t gvcid_managed_parameters_array[GVCID_MAX_PARAM_SIZE];
321321
extern GvcidManagedParameters_t current_managed_parameters_struct;
322322
extern int gvcid_counter;

include/crypto_config.h

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,16 @@
7272
#define SA_KEYED 2
7373
#define SA_OPERATIONAL 3
7474
// SA State Transitions
75-
#define SA_CREATE 5
76-
#define SA_REKEY 6
77-
#define SA_START 7
78-
#define SA_STOP 2
79-
#define SA_EXPIRE 1
80-
#define SA_DELETE 0
75+
#define SA_CREATE 5
76+
#define SA_REKEY 6
77+
#define SA_START 7
78+
#define SA_STOP 2
79+
#define SA_EXPIRE 1
80+
#define SA_DELETE 0
8181
// SA Additional Directives
82-
#define SA_STATUS 8
83-
#define SA_SETARSN 9
84-
#define SA_SETARSNW 10
82+
#define SA_STATUS 8
83+
#define SA_SETARSN 9
84+
#define SA_SETARSNW 10
8585

8686
// Key State Defines
8787
#define KEY_PREACTIVE 0
@@ -97,9 +97,9 @@
9797
#define AES256_CBC_KEYLEN 32
9898
#define AES256_CCM_KEYLEN 32
9999
// ACS
100-
#define CMAC_AES256_KEYLEN 32
101-
#define HMAC_SHA256_KEYLEN 32
102-
#define HMAC_SHA512_KEYLEN 64
100+
#define CMAC_AES256_KEYLEN 32
101+
#define HMAC_SHA256_KEYLEN 32
102+
#define HMAC_SHA512_KEYLEN 64
103103

104104
// SA Service Types
105105
#define SA_PLAINTEXT 0
@@ -140,8 +140,8 @@
140140

141141
// Protocol Data Unit (PDU)
142142
// PDU Type
143-
#define PDU_TYPE_COMMAND 0
144-
#define PDU_TYPE_REPLY 1
143+
#define PDU_TYPE_COMMAND 0
144+
#define PDU_TYPE_REPLY 1
145145
// PDU User Flag
146146
#define PDU_USER_FLAG_TRUE 1
147147
#define PDU_USER_FLAG_FALSE 0
@@ -156,25 +156,25 @@
156156
#define PID_KEY_DESTRUCTION 0x06 // 0b0110
157157
#define PID_KEY_INVENTORY 0x07 // 0b0111
158158
// Service Group - Security Association Management
159-
#define SG_SA_MGMT 0x01 // 0b01
160-
#define PID_CREATE_SA 0x01 // 0b0001
161-
#define PID_REKEY_SA 0x06 // 0b0110
162-
#define PID_START_SA 0x0B // 0b1011
163-
#define PID_STOP_SA 0x0E // 0b1110
164-
#define PID_EXPIRE_SA 0x09 // 0b1001
165-
#define PID_DELETE_SA 0x04 // 0b0100
166-
#define PID_SET_ARSN 0x0A // 0b1010
167-
#define PID_SET_ARSNW 0x05 // 0b0101
168-
#define PID_READ_ARSN 0x00 // 0b0000
169-
#define PID_SA_STATUS 0x0F // 0b1111
159+
#define SG_SA_MGMT 0x01 // 0b01
160+
#define PID_CREATE_SA 0x01 // 0b0001
161+
#define PID_REKEY_SA 0x06 // 0b0110
162+
#define PID_START_SA 0x0B // 0b1011
163+
#define PID_STOP_SA 0x0E // 0b1110
164+
#define PID_EXPIRE_SA 0x09 // 0b1001
165+
#define PID_DELETE_SA 0x04 // 0b0100
166+
#define PID_SET_ARSN 0x0A // 0b1010
167+
#define PID_SET_ARSNW 0x05 // 0b0101
168+
#define PID_READ_ARSN 0x00 // 0b0000
169+
#define PID_SA_STATUS 0x0F // 0b1111
170170
// Service Group - Security Monitoring & Control
171-
#define SG_SEC_MON_CTRL 0x03 // 0b11
172-
#define PID_PING 0x01 // 0b0001
173-
#define PID_LOG_STATUS 0x02 // 0b0010
174-
#define PID_DUMP_LOG 0x03 // 0b0011
175-
#define PID_ERASE_LOG 0x04 // 0b0100
176-
#define PID_SELF_TEST 0x05 // 0b0101
177-
#define PID_ALARM_FLAG 0x07 // 0b0111
171+
#define SG_SEC_MON_CTRL 0x03 // 0b11
172+
#define PID_PING 0x01 // 0b0001
173+
#define PID_LOG_STATUS 0x02 // 0b0010
174+
#define PID_DUMP_LOG 0x03 // 0b0011
175+
#define PID_ERASE_LOG 0x04 // 0b0100
176+
#define PID_SELF_TEST 0x05 // 0b0101
177+
#define PID_ALARM_FLAG 0x07 // 0b0111
178178

179179
// Procedure Identification (PID) - User Defined Commands
180180
#define PID_IDLE_FRAME_TRIGGER 0

src/core/crypto_aos.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,6 @@ int32_t Crypto_AOS_ProcessSecurity(uint8_t *p_ingest, uint16_t len_ingest, uint8
12731273

12741274
if (sa_service_type != SA_PLAINTEXT && ecs_is_aead_algorithm == CRYPTO_TRUE)
12751275
{
1276-
12771276
if (sa_service_type == SA_ENCRYPTION)
12781277
{
12791278
status = cryptography_if->cryptography_decrypt(p_new_dec_frame + byte_idx, // plaintext output

0 commit comments

Comments
 (0)