40
40
41
41
using namespace utest::v1;
42
42
43
- uint8_t seed[MBEDTLS_ENTROPY_MAX_SEED_SIZE+ 2 ] = {0 };
43
+ uint8_t seed[MBEDTLS_ENTROPY_MAX_SEED_SIZE + 2 ] = {0 };
44
44
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)
49
49
{
50
50
psa_status_t status;
51
51
uint8_t output[32 ] = { 0 };
52
52
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 );
60
60
}
61
61
62
- void run_entropy_inject_with_crypto_init ( )
62
+ void run_entropy_inject_with_crypto_init ()
63
63
{
64
64
psa_its_status_t its_status;
65
65
psa_status_t status;
66
66
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);
70
70
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 ();
75
75
/* 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);
78
78
}
79
79
80
80
@@ -88,7 +88,7 @@ utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
88
88
89
89
static void injection_small_good ()
90
90
{
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);
92
92
}
93
93
94
94
static void injection_big_good ()
@@ -113,14 +113,14 @@ static void injection_and_init_deinit()
113
113
114
114
115
115
116
- /* **************************************************************************************/
116
+ /* **************************************************************************************/
117
117
118
118
utest::v1::status_t case_teardown_handler (const Case *const source, const size_t passed, const size_t failed, const failure_t reason)
119
119
{
120
120
psa_status_t status;
121
121
status = test_psa_its_reset ();
122
122
TEST_ASSERT_EQUAL (PSA_ITS_SUCCESS, status);
123
- mbedtls_psa_crypto_free ( );
123
+ mbedtls_psa_crypto_free ();
124
124
return greentea_case_teardown_handler (source, passed, failed, reason);
125
125
}
126
126
@@ -130,8 +130,7 @@ utest::v1::status_t case_setup_handler(const Case *const source, const size_t in
130
130
status = test_psa_its_reset ();
131
131
TEST_ASSERT_EQUAL (PSA_ITS_SUCCESS, status);
132
132
/* 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) {
135
134
seed[i] = i;
136
135
}
137
136
return greentea_case_setup_handler (source, index_of_case);
0 commit comments