test_suite_psa_crypto_util: alloc/free buffer inside loop in ecdsa_raw_to_der_incremental()

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
Valerio Setti 2024-01-30 15:46:02 +01:00
parent 78da7468ca
commit 98e1931a0a

View file

@ -33,17 +33,19 @@ void ecdsa_raw_to_der_incremental(int key_bits, data_t *input, data_t *exp_resul
size_t ret_len;
size_t i;
TEST_CALLOC(tmp_buf, tmp_buf_len);
for (i = 0; i < tmp_buf_len; i++) {
for (i = 1; i < tmp_buf_len; i++) {
TEST_CALLOC(tmp_buf, i);
TEST_ASSERT(mbedtls_ecdsa_raw_to_der(input->x, input->len,
tmp_buf, i, &ret_len,
key_bits) != 0);
mbedtls_free(tmp_buf);
tmp_buf = NULL;
}
TEST_CALLOC(tmp_buf, i);
TEST_EQUAL(mbedtls_ecdsa_raw_to_der(input->x, input->len,
tmp_buf, i, &ret_len,
key_bits), 0);
exit:
mbedtls_free(tmp_buf);
}