Skip to content

Commit 88f4f48

Browse files
committed
Astyle fixes for the source
Used running: astyle -n --options=.astylerc
1 parent 5c2cf07 commit 88f4f48

File tree

6 files changed

+1476
-1486
lines changed

6 files changed

+1476
-1486
lines changed

TESTS/psa/crypto_init/main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ static void check_multi_crypto_init_deinit()
5252
uint8_t output[TEST_RANDOM_SIZE] = {0};
5353
uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = {0};
5454
/* inject some a seed for test*/
55-
for(int i; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i)
55+
for (int i; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i) {
5656
seed[i] = i;
57+
}
5758
/* don't really care if this succeed this is just to make crypto init pass*/
58-
mbedtls_psa_inject_entropy( seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE );
59+
mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
5960
psa_status_t status = psa_crypto_init();
6061
TEST_ASSERT_EQUAL(PSA_SUCCESS, status);
6162
status = psa_crypto_init();
@@ -76,10 +77,11 @@ static void check_crypto_init_deinit()
7677
uint8_t output[TEST_RANDOM_SIZE] = {0};
7778
uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = {0};
7879
/* inject some a seed for test*/
79-
for(int i; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i)
80+
for (int i; i < MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE; ++i) {
8081
seed[i] = i;
82+
}
8183
/* don't really care if this succeed this is just to make crypto init pass*/
82-
mbedtls_psa_inject_entropy( seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE );
84+
mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
8385
status = psa_generate_random(output, sizeof(output));
8486
TEST_ASSERT_EQUAL(PSA_ERROR_BAD_STATE, status);
8587
status = psa_crypto_init();

TESTS/psa/entropy_inject/main.cpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,41 +40,41 @@
4040

4141
using namespace utest::v1;
4242

43-
uint8_t seed[MBEDTLS_ENTROPY_MAX_SEED_SIZE+2] = {0};
43+
uint8_t seed[MBEDTLS_ENTROPY_MAX_SEED_SIZE + 2] = {0};
4444

45-
void validate_entropy_seed_injection( int seed_length_a,
46-
int expected_status_a,
47-
int seed_length_b,
48-
int expected_status_b )
45+
void validate_entropy_seed_injection(int seed_length_a,
46+
int expected_status_a,
47+
int seed_length_b,
48+
int expected_status_b)
4949
{
5050
psa_status_t status;
5151
uint8_t output[32] = { 0 };
5252
uint8_t zeros[32] = { 0 };
53-
status = mbedtls_psa_inject_entropy( seed, seed_length_a );
54-
TEST_ASSERT( status == expected_status_a );
55-
status = mbedtls_psa_inject_entropy( seed, seed_length_b );
56-
TEST_ASSERT( status == expected_status_b );
57-
TEST_ASSERT( psa_crypto_init( ) == PSA_SUCCESS );
58-
TEST_ASSERT( psa_generate_random( output, sizeof( output ) ) == PSA_SUCCESS );
59-
TEST_ASSERT( memcmp( output , zeros, sizeof( output ) ) != 0 );
53+
status = mbedtls_psa_inject_entropy(seed, seed_length_a);
54+
TEST_ASSERT(status == expected_status_a);
55+
status = mbedtls_psa_inject_entropy(seed, seed_length_b);
56+
TEST_ASSERT(status == expected_status_b);
57+
TEST_ASSERT(psa_crypto_init() == PSA_SUCCESS);
58+
TEST_ASSERT(psa_generate_random(output, sizeof(output)) == PSA_SUCCESS);
59+
TEST_ASSERT(memcmp(output, zeros, sizeof(output)) != 0);
6060
}
6161

62-
void run_entropy_inject_with_crypto_init( )
62+
void run_entropy_inject_with_crypto_init()
6363
{
6464
psa_its_status_t its_status;
6565
psa_status_t status;
6666
status = psa_crypto_init();
67-
TEST_ASSERT( status == PSA_ERROR_INSUFFICIENT_ENTROPY );
68-
status = mbedtls_psa_inject_entropy( seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE );
69-
TEST_ASSERT( status == PSA_SUCCESS );
67+
TEST_ASSERT(status == PSA_ERROR_INSUFFICIENT_ENTROPY);
68+
status = mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
69+
TEST_ASSERT(status == PSA_SUCCESS);
7070
status = psa_crypto_init();
71-
TEST_ASSERT( status == PSA_SUCCESS );
72-
status = mbedtls_psa_inject_entropy( seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE );
73-
TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED );
74-
mbedtls_psa_crypto_free( );
71+
TEST_ASSERT(status == PSA_SUCCESS);
72+
status = mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
73+
TEST_ASSERT(status == PSA_ERROR_NOT_PERMITTED);
74+
mbedtls_psa_crypto_free();
7575
/* The seed is written by nv_seed callback functions therefore the injection will fail */
76-
status = mbedtls_psa_inject_entropy( seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE );
77-
TEST_ASSERT( status == PSA_ERROR_NOT_PERMITTED );
76+
status = mbedtls_psa_inject_entropy(seed, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE);
77+
TEST_ASSERT(status == PSA_ERROR_NOT_PERMITTED);
7878
}
7979

8080

@@ -88,7 +88,7 @@ utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
8888

8989
static void injection_small_good()
9090
{
91-
validate_entropy_seed_injection( MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE, PSA_SUCCESS, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE, PSA_ERROR_NOT_PERMITTED);
91+
validate_entropy_seed_injection(MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE, PSA_SUCCESS, MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE, PSA_ERROR_NOT_PERMITTED);
9292
}
9393

9494
static void injection_big_good()
@@ -113,14 +113,14 @@ static void injection_and_init_deinit()
113113

114114

115115

116-
/***************************************************************************************/
116+
/***************************************************************************************/
117117

118118
utest::v1::status_t case_teardown_handler(const Case *const source, const size_t passed, const size_t failed, const failure_t reason)
119119
{
120120
psa_status_t status;
121121
status = test_psa_its_reset();
122122
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
123-
mbedtls_psa_crypto_free( );
123+
mbedtls_psa_crypto_free();
124124
return greentea_case_teardown_handler(source, passed, failed, reason);
125125
}
126126

@@ -130,8 +130,7 @@ utest::v1::status_t case_setup_handler(const Case *const source, const size_t in
130130
status = test_psa_its_reset();
131131
TEST_ASSERT_EQUAL(PSA_ITS_SUCCESS, status);
132132
/* fill seed in some data */
133-
for( size_t i = 0; i < MBEDTLS_ENTROPY_MAX_SEED_SIZE+2; ++i)
134-
{
133+
for (size_t i = 0; i < MBEDTLS_ENTROPY_MAX_SEED_SIZE + 2; ++i) {
135134
seed[i] = i;
136135
}
137136
return greentea_case_setup_handler(source, index_of_case);

components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/crypto_platform_spe.h

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
*/
3939

4040
/** \brief psa_s_function_t enum defines for all the available functions in PSA Crypto. */
41-
typedef enum psa_sec_function_s
42-
{
41+
typedef enum psa_sec_function_s {
4342
PSA_CRYPTO_INVALID,
4443
PSA_CRYPTO_INIT,
4544
PSA_IMPORT_KEY,
@@ -87,7 +86,7 @@ typedef enum psa_sec_function_s
8786
PSA_GENERATOR_ABORT,
8887
PSA_KEY_DERIVATION,
8988
PSA_KEY_AGREEMENT
90-
}psa_sec_function_t;
89+
} psa_sec_function_t;
9190

9291
/**@}*/
9392

@@ -101,8 +100,7 @@ typedef enum psa_sec_function_s
101100
* pack them together.
102101
*/
103102

104-
typedef struct psa_crypto_ipc_s
105-
{
103+
typedef struct psa_crypto_ipc_s {
106104
psa_sec_function_t func;
107105
psa_key_slot_t key;
108106
psa_algorithm_t alg;
@@ -113,8 +111,7 @@ typedef struct psa_crypto_ipc_s
113111
* and in order to use the existing infrastructure of the SPM-IPC we provide a struct to
114112
* pack them together.
115113
*/
116-
typedef struct psa_crypto_derivation_ipc_s
117-
{
114+
typedef struct psa_crypto_derivation_ipc_s {
118115
psa_sec_function_t func;
119116
psa_key_slot_t key;
120117
psa_algorithm_t alg;
@@ -127,8 +124,7 @@ typedef struct psa_crypto_derivation_ipc_s
127124
* pack them together.
128125
*/
129126

130-
typedef struct psa_key_mng_ipc_s
131-
{
127+
typedef struct psa_key_mng_ipc_s {
132128
psa_key_slot_t key;
133129
psa_key_type_t type;
134130
psa_sec_function_t func;
@@ -142,8 +138,7 @@ typedef struct psa_key_mng_ipc_s
142138

143139
// Max length supported for nonce is 16 bytes.
144140
#define PSA_AEAD_MAX_NONCE_SIZE 16
145-
typedef struct psa_crypto_ipc_aead_s
146-
{
141+
typedef struct psa_crypto_ipc_aead_s {
147142
psa_sec_function_t func;
148143
psa_key_slot_t key;
149144
psa_algorithm_t alg;
@@ -158,8 +153,7 @@ typedef struct psa_crypto_ipc_aead_s
158153
* and in order to use the existing infrastructure of the SPM-IPC we provide a struct to
159154
* pack them together.
160155
*/
161-
typedef struct psa_crypto_ipc_asymmetric_s
162-
{
156+
typedef struct psa_crypto_ipc_asymmetric_s {
163157
psa_sec_function_t func;
164158
psa_key_slot_t key;
165159
psa_algorithm_t alg;

components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/crypto_struct_ipc.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,33 @@
2727
#ifndef PSA_CRYPTO_STRUCT_H
2828
#define PSA_CRYPTO_STRUCT_H
2929

30-
struct psa_hash_operation_s
31-
{
30+
struct psa_hash_operation_s {
3231
psa_handle_t handle;
3332
};
3433

35-
struct psa_mac_operation_s
36-
{
34+
struct psa_mac_operation_s {
3735
psa_handle_t handle;
3836
};
3937

40-
struct psa_cipher_operation_s
41-
{
38+
struct psa_cipher_operation_s {
4239
psa_handle_t handle;
4340
};
4441

45-
struct psa_aead_operation_s
46-
{
42+
struct psa_aead_operation_s {
4743
psa_handle_t handle;
4844
};
4945

50-
struct psa_crypto_generator_s
51-
{
46+
struct psa_crypto_generator_s {
5247
psa_handle_t handle;
5348
};
5449

55-
static inline struct psa_crypto_generator_s psa_crypto_generator_init( void )
50+
static inline struct psa_crypto_generator_s psa_crypto_generator_init(void)
5651
{
5752
const struct psa_crypto_generator_s v = { 0 };
58-
return( v );
53+
return (v);
5954
}
6055

61-
struct psa_key_policy_s
62-
{
56+
struct psa_key_policy_s {
6357
psa_key_usage_t usage;
6458
psa_algorithm_t alg;
6559
};

0 commit comments

Comments
 (0)