Skip to content

Commit bcaebc1

Browse files
Donnie-Icegithub-actions[bot]
authored andcommitted
style: auto-format via clang-format
1 parent e4b4c8c commit bcaebc1

7 files changed

Lines changed: 95 additions & 90 deletions

File tree

src/core/crypto_aos.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,10 +806,12 @@ int32_t Crypto_AOS_ApplySecurity(uint8_t *pTfBuffer, uint16_t len_ingest)
806806

807807
int32_t Crypto_AOS_Verify_Frame_Lengths(uint16_t len_ingest)
808808
{
809-
uint8_t fhec_len = aos_current_managed_parameters_struct.aos_has_fhec == AOS_HAS_FHEC ? FHECF_SIZE : 0;
810-
uint16_t iz_len = aos_current_managed_parameters_struct.aos_has_iz == AOS_HAS_IZ ? aos_current_managed_parameters_struct.aos_iz_len : 0;
811-
uint8_t ocf_len = aos_current_managed_parameters_struct.has_ocf == AOS_HAS_OCF ? OCF_SIZE : 0;
812-
uint8_t fecf_len = aos_current_managed_parameters_struct.has_fecf == AOS_HAS_FECF ? FECF_SIZE : 0;
809+
uint8_t fhec_len = aos_current_managed_parameters_struct.aos_has_fhec == AOS_HAS_FHEC ? FHECF_SIZE : 0;
810+
uint16_t iz_len = aos_current_managed_parameters_struct.aos_has_iz == AOS_HAS_IZ
811+
? aos_current_managed_parameters_struct.aos_iz_len
812+
: 0;
813+
uint8_t ocf_len = aos_current_managed_parameters_struct.has_ocf == AOS_HAS_OCF ? OCF_SIZE : 0;
814+
uint8_t fecf_len = aos_current_managed_parameters_struct.has_fecf == AOS_HAS_FECF ? FECF_SIZE : 0;
813815
uint16_t expected_frame_length = AOS_MIN_SIZE + fhec_len + SPI_LEN + iz_len + ocf_len + fecf_len;
814816
if (len_ingest < expected_frame_length)
815817
{
@@ -908,7 +910,7 @@ int32_t Crypto_AOS_ProcessSecurity(uint8_t *p_ingest, uint16_t len_ingest, AOS_t
908910
{
909911
return status;
910912
}
911-
913+
912914
// Increment to end of Primary Header start, depends on FHECF presence
913915
byte_idx = 6;
914916
if (aos_current_managed_parameters_struct.aos_has_fhec == AOS_HAS_FHEC)

src/core/crypto_config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ int32_t Crypto_Config_Cam(uint8_t cam_enabled, char *cookie_file_path, char *key
752752
{
753753
int32_t status = CRYPTO_LIB_SUCCESS;
754754

755-
cam_config = (CamConfig_t *)calloc(1, CAM_CONFIG_SIZE);
755+
cam_config = (CamConfig_t *)calloc(1, CAM_CONFIG_SIZE);
756756
if (cam_config == NULL)
757757
{
758758
return CRYPTO_LIB_ERROR;
@@ -764,7 +764,7 @@ int32_t Crypto_Config_Cam(uint8_t cam_enabled, char *cookie_file_path, char *key
764764
cam_config = NULL;
765765
return CAM_CONFIG_NOT_SUPPORTED_ERROR;
766766
}
767-
767+
768768
if (Crypto_is_safe_path(keytab_file_path) != CRYPTO_LIB_SUCCESS)
769769
{
770770
free(cam_config);

src/crypto/kmc/base64url.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,15 @@ int32_t base64urlDecode(const char_t *input, size_t inputLen, void *output, size
217217
return ERROR_INVALID_PARAMETER;
218218

219219
// Empty input is valid; produce empty output
220-
if (inputLen == 0) {
220+
if (inputLen == 0)
221+
{
221222
*outputLen = 0;
222223
return NO_ERROR;
223224
}
224225

225226
// Safely strip optional '=' padding
226-
while (inputLen > 0 && input[inputLen - 1] == '=') {
227+
while (inputLen > 0 && input[inputLen - 1] == '=')
228+
{
227229
inputLen--;
228230
}
229231

src/crypto/kmc/cryptography_interface_kmc_crypto_service.template.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
// JSON marshalling libraries
3030
#include "jsmn.h"
3131

32-
#define CAM_MAX_AUTH_RETRIES 4
32+
#define CAM_MAX_AUTH_RETRIES 4
3333
#define KMC_MAX_RESPONSE_BYTES (1024 * 1024) // 1MB
3434

3535
// libcurl call-back response handling Structures
@@ -1344,7 +1344,7 @@ static int32_t cryptography_aead_encrypt(uint8_t *data_out, size_t len_data_out,
13441344
free(chunk_read);
13451345
if (encrypt_payload != NULL && aad_bool == CRYPTO_TRUE) // only needs freed if it has aad
13461346
free(encrypt_payload);
1347-
1347+
13481348
return status;
13491349
}
13501350

@@ -1898,9 +1898,9 @@ static int32_t get_auth_algorithm_from_acs(uint8_t acs_enum, const char **algo_p
18981898
// libcurl local functions
18991899
static size_t write_callback(void *data, size_t size, size_t nmemb, void *userp)
19001900
{
1901-
memory_write *mem = (memory_write *)userp;
1902-
size_t realsize = 0;
1903-
char *ptr;
1901+
memory_write *mem = (memory_write *)userp;
1902+
size_t realsize = 0;
1903+
char *ptr;
19041904

19051905
if (nmemb != 0 && size > SIZE_MAX / nmemb)
19061906
return 0;

src/sa/mariadb/sa_interface_mariadb.template.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -616,28 +616,28 @@ static int32_t parse_sa_from_mysql_query(char *query, SecurityAssociation_t **se
616616

617617
static int32_t convert_hexstring_to_byte_array(char *source_str, uint8_t *dest_buffer, uint16_t max_len)
618618
{ // https://stackoverflow.com/questions/3408706/hexadecimal-string-to-byte-array-in-c/56247335#56247335
619-
int offset;
620-
unsigned int read_byte;
621-
uint32_t data_len = 0;
622-
623-
if (dest_buffer == NULL || source_str == NULL)
624-
{
625-
return CRYPTO_LIB_ERROR;
626-
}
627-
628-
uint32_t source_len = (strlen(source_str) / 2);
629-
if (source_len > max_len)
630-
{
631-
return CRYPTO_LIB_ERROR;
632-
}
633-
634-
while (sscanf(source_str, " %02x%n", &read_byte, &offset) == 1)
635-
{
636-
dest_buffer[data_len++] = read_byte;
637-
source_str += offset;
638-
}
639-
640-
return CRYPTO_LIB_SUCCESS;
619+
int offset;
620+
unsigned int read_byte;
621+
uint32_t data_len = 0;
622+
623+
if (dest_buffer == NULL || source_str == NULL)
624+
{
625+
return CRYPTO_LIB_ERROR;
626+
}
627+
628+
uint32_t source_len = (strlen(source_str) / 2);
629+
if (source_len > max_len)
630+
{
631+
return CRYPTO_LIB_ERROR;
632+
}
633+
634+
while (sscanf(source_str, " %02x%n", &read_byte, &offset) == 1)
635+
{
636+
dest_buffer[data_len++] = read_byte;
637+
source_str += offset;
638+
}
639+
640+
return CRYPTO_LIB_SUCCESS;
641641
}
642642

643643
static void convert_byte_array_to_hexstring(void *src_buffer, size_t buffer_length, char *dest_str)

test/core/shared_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ void hex_conversion(char *buffer_h, char **buffer_b, int *buffer_b_length)
9292
{
9393
// Convert input plaintext
9494
uint16_t dest_len = (strlen(buffer_h) / 2);
95-
*buffer_b = (char *)malloc(dest_len * sizeof(char));
96-
*buffer_b_length = convert_hexstring_to_byte_array(buffer_h, *buffer_b);
95+
*buffer_b = (char *)malloc(dest_len * sizeof(char));
96+
*buffer_b_length = convert_hexstring_to_byte_array(buffer_h, *buffer_b);
9797
}
9898

9999
#ifdef DEBUG

test/kmc/ut_mariadb.c

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -25,62 +25,63 @@
2525
// local copy of function from mariadb interface
2626
static int32_t convert_hexstring_to_byte_array(char *source_str, uint8_t *dest_buffer, uint16_t max_len)
2727
{ // https://stackoverflow.com/questions/3408706/hexadecimal-string-to-byte-array-in-c/56247335#56247335
28-
int offset;
29-
unsigned int read_byte;
30-
uint32_t data_len = 0;
31-
32-
if (dest_buffer == NULL || source_str == NULL)
33-
{
34-
return CRYPTO_LIB_ERROR;
35-
}
36-
37-
uint32_t source_len = (strlen(source_str) / 2);
38-
if (source_len > max_len)
39-
{
40-
return CRYPTO_LIB_ERROR;
41-
}
42-
43-
while (sscanf(source_str, " %02x%n", &read_byte, &offset) == 1)
44-
{
45-
dest_buffer[data_len++] = read_byte;
46-
source_str += offset;
47-
}
48-
49-
return CRYPTO_LIB_SUCCESS;
28+
int offset;
29+
unsigned int read_byte;
30+
uint32_t data_len = 0;
31+
32+
if (dest_buffer == NULL || source_str == NULL)
33+
{
34+
return CRYPTO_LIB_ERROR;
35+
}
36+
37+
uint32_t source_len = (strlen(source_str) / 2);
38+
if (source_len > max_len)
39+
{
40+
return CRYPTO_LIB_ERROR;
41+
}
42+
43+
while (sscanf(source_str, " %02x%n", &read_byte, &offset) == 1)
44+
{
45+
dest_buffer[data_len++] = read_byte;
46+
source_str += offset;
47+
}
48+
49+
return CRYPTO_LIB_SUCCESS;
5050
}
5151

5252
UTEST(CRYPTO_MDB, HEXSTRING_TO_BYTE_ARRAY)
5353
{
54-
int32_t status = CRYPTO_LIB_SUCCESS;
55-
uint16_t max_len = IV_SIZE;
56-
uint8_t *dest_buffer = malloc(IV_SIZE);
57-
uint8_t *dest_buffer_null = NULL;
58-
59-
// Failure Case, wrong source length
60-
char *source_str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
61-
status = convert_hexstring_to_byte_array(source_str, dest_buffer, max_len);
62-
printf("Status: %d\n", status);
63-
ASSERT_EQ(status, CRYPTO_LIB_ERROR);
64-
65-
// Failure Case, null dest_buffer
66-
source_str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
67-
status = convert_hexstring_to_byte_array(source_str, dest_buffer_null, max_len);
68-
printf("Status: %d\n", status);
69-
ASSERT_EQ(status, CRYPTO_LIB_ERROR);
70-
71-
// Failure Case, null source_str
72-
source_str = NULL;
73-
status = convert_hexstring_to_byte_array(source_str, dest_buffer, max_len);
74-
printf("Status: %d\n", status);
75-
ASSERT_EQ(status, CRYPTO_LIB_ERROR);
76-
77-
// Success case, correct length source string and max
78-
source_str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
79-
status = convert_hexstring_to_byte_array(source_str, dest_buffer, max_len);
80-
printf("Status: %d\n", status);
81-
ASSERT_EQ(status, CRYPTO_LIB_SUCCESS);
82-
83-
free(dest_buffer);
54+
int32_t status = CRYPTO_LIB_SUCCESS;
55+
uint16_t max_len = IV_SIZE;
56+
uint8_t *dest_buffer = malloc(IV_SIZE);
57+
uint8_t *dest_buffer_null = NULL;
58+
59+
// Failure Case, wrong source length
60+
char *source_str =
61+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
62+
status = convert_hexstring_to_byte_array(source_str, dest_buffer, max_len);
63+
printf("Status: %d\n", status);
64+
ASSERT_EQ(status, CRYPTO_LIB_ERROR);
65+
66+
// Failure Case, null dest_buffer
67+
source_str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
68+
status = convert_hexstring_to_byte_array(source_str, dest_buffer_null, max_len);
69+
printf("Status: %d\n", status);
70+
ASSERT_EQ(status, CRYPTO_LIB_ERROR);
71+
72+
// Failure Case, null source_str
73+
source_str = NULL;
74+
status = convert_hexstring_to_byte_array(source_str, dest_buffer, max_len);
75+
printf("Status: %d\n", status);
76+
ASSERT_EQ(status, CRYPTO_LIB_ERROR);
77+
78+
// Success case, correct length source string and max
79+
source_str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
80+
status = convert_hexstring_to_byte_array(source_str, dest_buffer, max_len);
81+
printf("Status: %d\n", status);
82+
ASSERT_EQ(status, CRYPTO_LIB_SUCCESS);
83+
84+
free(dest_buffer);
8485
}
8586

8687
// #ifdef KMC_MDB_RH

0 commit comments

Comments
 (0)