Skip to content

Commit ea36a89

Browse files
author
itayzafrir
committed
Fix crypto compliance tests
Prevent passing null buffer with size which is non-zero.
1 parent 774294d commit ea36a89

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

components/TARGET_PSA/TESTS/compliance_crypto/test_c024/test_c024.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,18 @@ int32_t psa_aead_encrypt_test(security_t caller)
9090
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5));
9191

9292
if (is_buffer_empty(check1[i].nonce, check1[i].nonce_length) == TRUE)
93+
{
9394
nonce = NULL;
95+
check1[i].nonce_length = 0;
96+
}
9497
else
9598
nonce = check1[i].nonce;
9699

97100
if (is_buffer_empty(check1[i].additional_data, check1[i].additional_data_length) == TRUE)
101+
{
98102
additional_data = NULL;
103+
check1[i].additional_data_length = 0;
104+
}
99105
else
100106
additional_data = check1[i].additional_data;
101107

@@ -152,12 +158,18 @@ int32_t psa_aead_encrypt_negative_test(security_t caller)
152158
check2[i].key_alg);
153159

154160
if (is_buffer_empty(check2[i].nonce, check2[i].nonce_length) == TRUE)
161+
{
155162
nonce = NULL;
163+
check2[i].nonce_length = 0;
164+
}
156165
else
157166
nonce = check2[i].nonce;
158167

159168
if (is_buffer_empty(check2[i].additional_data, check2[i].additional_data_length) == TRUE)
169+
{
160170
additional_data = NULL;
171+
check2[i].additional_data_length = 0;
172+
}
161173
else
162174
additional_data = check2[i].additional_data;
163175

components/TARGET_PSA/TESTS/compliance_crypto/test_c025/test_c025.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,18 @@ int32_t psa_aead_decrypt_test(security_t caller)
8989
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5));
9090

9191
if (is_buffer_empty(check1[i].nonce, check1[i].nonce_length) == TRUE)
92+
{
9293
nonce = NULL;
94+
check1[i].nonce_length = 0;
95+
}
9396
else
9497
nonce = check1[i].nonce;
9598

9699
if (is_buffer_empty(check1[i].additional_data, check1[i].additional_data_length) == TRUE)
100+
{
97101
additional_data = NULL;
102+
check1[i].additional_data_length = 0;
103+
}
98104
else
99105
additional_data = check1[i].additional_data;
100106

@@ -149,12 +155,18 @@ int32_t psa_aead_decrypt_negative_test(security_t caller)
149155
check2[i].key_alg);
150156

151157
if (is_buffer_empty(check2[i].nonce, check2[i].nonce_length) == TRUE)
158+
{
152159
nonce = NULL;
160+
check2[i].nonce_length = 0;
161+
}
153162
else
154163
nonce = check2[i].nonce;
155164

156165
if (is_buffer_empty(check2[i].additional_data, check2[i].additional_data_length) == TRUE)
166+
{
157167
additional_data = NULL;
168+
check2[i].additional_data_length = 0;
169+
}
158170
else
159171
additional_data = check2[i].additional_data;
160172

components/TARGET_PSA/TESTS/compliance_crypto/test_c039/test_c039.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ int32_t psa_asymmetric_encrypt_test(security_t caller)
128128
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5));
129129

130130
if (is_buffer_empty(check1[i].salt, check1[i].salt_length) == TRUE)
131+
{
131132
salt = NULL;
133+
check1[i].salt_length = 0;
134+
}
132135
else
133136
salt = check1[i].salt;
134137

@@ -223,7 +226,10 @@ int32_t psa_asymmetric_encrypt_negative_test(security_t caller)
223226
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6));
224227

225228
if (is_buffer_empty(check1[i].salt, check1[i].salt_length) == TRUE)
229+
{
226230
salt = NULL;
231+
check1[i].salt_length = 0;
232+
}
227233
else
228234
salt = check1[i].salt;
229235

components/TARGET_PSA/TESTS/compliance_crypto/test_c040/test_c040.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ int32_t psa_asymmetric_decrypt_test(security_t caller)
128128
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(5));
129129

130130
if (is_buffer_empty(check1[i].salt, check1[i].salt_length) == TRUE)
131+
{
131132
salt = NULL;
133+
check1[i].salt_length = 0;
134+
}
132135
else
133136
salt = check1[i].salt;
134137

@@ -209,7 +212,10 @@ int32_t psa_asymmetric_decrypt_negative_test(security_t caller)
209212
TEST_ASSERT_EQUAL(status, PSA_SUCCESS, TEST_CHECKPOINT_NUM(6));
210213

211214
if (is_buffer_empty(check1[i].salt, check1[i].salt_length) == TRUE)
215+
{
212216
salt = NULL;
217+
check1[i].salt_length = 0;
218+
}
213219
else
214220
salt = check1[i].salt;
215221

0 commit comments

Comments
 (0)