Skip to content

Commit

Permalink
[#341] Attempt to manually fix const suggestions, formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
Donnie-Ice committed Nov 4, 2024
1 parent c77aba3 commit a0ac542
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 179 deletions.
27 changes: 8 additions & 19 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments:
Enabled: true
AcrossComments: true
AlignCompound: true
AlignConsecutiveDeclarations:
Enabled: true
AcrossComments: true
AlignFunctionPointers: true
AlignFunctionDeclarations: true
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
AcrossComments: false
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignConsecutiveMacros: AcrossComments
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
Expand All @@ -27,7 +17,7 @@ AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: true
BinPackParameters: BinPack
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
Expand All @@ -46,8 +36,7 @@ IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLines:
AtStartOfBlock: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
Expand All @@ -59,7 +48,7 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: Always
ReflowComments: true
SortIncludes: Never
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
Expand All @@ -68,8 +57,8 @@ SpaceInEmptyParentheses: false
SpaceBeforeCpp11BracedList: true
SpacesBeforeTrailingComments: 1
SpacesInCStyleCastParentheses: false
SpacesInParens: Never
SpaceInEmptyParentheses: false
SpacesInSquareBrackets: false
Standard: c++11
Standard: Latest
TabWidth: 8
UseTab: Never
20 changes: 10 additions & 10 deletions include/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ extern int32_t Crypto_Init_AOS_Unit_Test(void); // Initialize CryptoLib with uni
extern int32_t Crypto_Shutdown(void); // Free all allocated memory

// Telecommand (TC)
extern int32_t Crypto_TC_ApplySecurity(const uint8_t *p_in_frame, uint16_t in_frame_length,
uint8_t **pp_enc_frame, uint16_t *p_enc_frame_len);
extern int32_t Crypto_TC_ApplySecurity(const uint8_t *p_in_frame, uint16_t in_frame_length, uint8_t **pp_enc_frame,
uint16_t *p_enc_frame_len);
extern int32_t Crypto_TC_ProcessSecurity(uint8_t *ingest, int *len_ingest, TC_t *tc_sdls_processed_frame);
extern int32_t Crypto_TC_ApplySecurity_Cam(const uint8_t *p_in_frame, uint16_t in_frame_length,
uint8_t **pp_enc_frame, uint16_t *p_enc_frame_len, char *cam_cookies);
extern int32_t Crypto_TC_ApplySecurity_Cam(const uint8_t *p_in_frame, uint16_t in_frame_length, uint8_t **pp_enc_frame,
uint16_t *p_enc_frame_len, char *cam_cookies);
extern int32_t Crypto_TC_ProcessSecurity_Cam(uint8_t *ingest, int *len_ingest, TC_t *tc_sdls_processed_frame,
char *cam_cookies);

Expand Down Expand Up @@ -174,7 +174,7 @@ extern int32_t Crypto_AOS_ProcessSecurity(uint8_t *p_ingest, uint16_t len_ingest
uint16_t *p_decrypted_length);

// Crypo Error Support Functions
extern char *Crypto_Get_Error_Code_Enum_String(int32_t crypto_error_code);
extern const char *Crypto_Get_Error_Code_Enum_String(int32_t crypto_error_code);

/*
** Internal Prototypes
Expand Down Expand Up @@ -226,7 +226,7 @@ int32_t Crypto_Get_tmLength(int len);
uint8_t Crypto_Is_AEAD_Algorithm(uint32_t cipher_suite_id);
void Crypto_TM_updatePDU(uint8_t *ingest, int len_ingest);
void Crypto_TM_updateOCF(Telemetry_Frame_Ocf_Fsr_t *report, TM_t *tm_frame);
uint8_t *Crypto_Prepare_TC_AAD(uint8_t *buffer, uint16_t len_aad, uint8_t *abm_buffer);
uint8_t *Crypto_Prepare_TC_AAD(uint8_t *buffer, uint16_t len_aad, uint8_t *abm_buffer);
uint32_t Crypto_Prepare_TM_AAD(const uint8_t *buffer, uint16_t len_aad, const uint8_t *abm_buffer, uint8_t *aad);
uint32_t Crypto_Prepare_AOS_AAD(const uint8_t *buffer, uint16_t len_aad, const uint8_t *abm_buffer, uint8_t *aad);
void Crypto_Local_Config(void);
Expand Down Expand Up @@ -312,11 +312,11 @@ extern AOS_FrameSecurityHeader_t aos_frame_sec_hdr; // Used to reduce bit math d

// Global configuration structs
extern CryptoConfig_t crypto_config;
extern SadbMariaDBConfig_t *sa_mariadb_config;
extern SadbMariaDBConfig_t *sa_mariadb_config;
extern CryptographyKmcCryptoServiceConfig_t *cryptography_kmc_crypto_config;
extern CamConfig_t *cam_config;
extern GvcidManagedParameters_t *gvcid_managed_parameters;
extern GvcidManagedParameters_t *current_managed_parameters;
extern CamConfig_t *cam_config;
extern GvcidManagedParameters_t *gvcid_managed_parameters;
extern GvcidManagedParameters_t *current_managed_parameters;
extern GvcidManagedParameters_t gvcid_managed_parameters_array[GVCID_MAX_PARAM_SIZE];
extern GvcidManagedParameters_t current_managed_parameters_struct;
extern int gvcid_counter;
Expand Down
64 changes: 32 additions & 32 deletions include/crypto_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@
#define SA_KEYED 2
#define SA_OPERATIONAL 3
// SA State Transitions
#define SA_CREATE 5
#define SA_REKEY 6
#define SA_START 7
#define SA_STOP 2
#define SA_EXPIRE 1
#define SA_DELETE 0
#define SA_CREATE 5
#define SA_REKEY 6
#define SA_START 7
#define SA_STOP 2
#define SA_EXPIRE 1
#define SA_DELETE 0
// SA Additional Directives
#define SA_STATUS 8
#define SA_SETARSN 9
#define SA_SETARSNW 10
#define SA_STATUS 8
#define SA_SETARSN 9
#define SA_SETARSNW 10

// Key State Defines
#define KEY_PREACTIVE 0
Expand All @@ -97,9 +97,9 @@
#define AES256_CBC_KEYLEN 32
#define AES256_CCM_KEYLEN 32
// ACS
#define CMAC_AES256_KEYLEN 32
#define HMAC_SHA256_KEYLEN 32
#define HMAC_SHA512_KEYLEN 64
#define CMAC_AES256_KEYLEN 32
#define HMAC_SHA256_KEYLEN 32
#define HMAC_SHA512_KEYLEN 64

// SA Service Types
#define SA_PLAINTEXT 0
Expand Down Expand Up @@ -140,8 +140,8 @@

// Protocol Data Unit (PDU)
// PDU Type
#define PDU_TYPE_COMMAND 0
#define PDU_TYPE_REPLY 1
#define PDU_TYPE_COMMAND 0
#define PDU_TYPE_REPLY 1
// PDU User Flag
#define PDU_USER_FLAG_TRUE 1
#define PDU_USER_FLAG_FALSE 0
Expand All @@ -156,25 +156,25 @@
#define PID_KEY_DESTRUCTION 0x06 // 0b0110
#define PID_KEY_INVENTORY 0x07 // 0b0111
// Service Group - Security Association Management
#define SG_SA_MGMT 0x01 // 0b01
#define PID_CREATE_SA 0x01 // 0b0001
#define PID_REKEY_SA 0x06 // 0b0110
#define PID_START_SA 0x0B // 0b1011
#define PID_STOP_SA 0x0E // 0b1110
#define PID_EXPIRE_SA 0x09 // 0b1001
#define PID_DELETE_SA 0x04 // 0b0100
#define PID_SET_ARSN 0x0A // 0b1010
#define PID_SET_ARSNW 0x05 // 0b0101
#define PID_READ_ARSN 0x00 // 0b0000
#define PID_SA_STATUS 0x0F // 0b1111
#define SG_SA_MGMT 0x01 // 0b01
#define PID_CREATE_SA 0x01 // 0b0001
#define PID_REKEY_SA 0x06 // 0b0110
#define PID_START_SA 0x0B // 0b1011
#define PID_STOP_SA 0x0E // 0b1110
#define PID_EXPIRE_SA 0x09 // 0b1001
#define PID_DELETE_SA 0x04 // 0b0100
#define PID_SET_ARSN 0x0A // 0b1010
#define PID_SET_ARSNW 0x05 // 0b0101
#define PID_READ_ARSN 0x00 // 0b0000
#define PID_SA_STATUS 0x0F // 0b1111
// Service Group - Security Monitoring & Control
#define SG_SEC_MON_CTRL 0x03 // 0b11
#define PID_PING 0x01 // 0b0001
#define PID_LOG_STATUS 0x02 // 0b0010
#define PID_DUMP_LOG 0x03 // 0b0011
#define PID_ERASE_LOG 0x04 // 0b0100
#define PID_SELF_TEST 0x05 // 0b0101
#define PID_ALARM_FLAG 0x07 // 0b0111
#define SG_SEC_MON_CTRL 0x03 // 0b11
#define PID_PING 0x01 // 0b0001
#define PID_LOG_STATUS 0x02 // 0b0010
#define PID_DUMP_LOG 0x03 // 0b0011
#define PID_ERASE_LOG 0x04 // 0b0100
#define PID_SELF_TEST 0x05 // 0b0101
#define PID_ALARM_FLAG 0x07 // 0b0111

// Procedure Identification (PID) - User Defined Commands
#define PID_IDLE_FRAME_TRIGGER 0
Expand Down
1 change: 0 additions & 1 deletion src/core/crypto_aos.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,6 @@ int32_t Crypto_AOS_ProcessSecurity(uint8_t *p_ingest, uint16_t len_ingest, uint8

if (sa_service_type != SA_PLAINTEXT && ecs_is_aead_algorithm == CRYPTO_TRUE)
{

if (sa_service_type == SA_ENCRYPTION)
{
status = cryptography_if->cryptography_decrypt(p_new_dec_frame + byte_idx, // plaintext output
Expand Down
Loading

0 comments on commit a0ac542

Please sign in to comment.