1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-01 10:06:53 +03:00

suite_psa_crypto_util: add more testing for mbedtls_ecdsa_raw_to_der()

A new test function is added, ecdsa_raw_to_der_incremental, that tests
incremental output DER buffer sizes checking that only the correct one
(tested at last) works correctly.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
Valerio Setti
2024-01-29 17:34:07 +01:00
parent 9b9b5a52d9
commit ee5238fcf4
2 changed files with 36 additions and 0 deletions

View File

@ -25,6 +25,30 @@ exit:
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_PSA_UTIL_HAVE_ECDSA */
void ecdsa_raw_to_der_incremental(int key_bits, data_t *input, data_t *exp_result)
{
unsigned char *tmp_buf = NULL;
size_t tmp_buf_len = exp_result->len;
size_t ret_len;
size_t i;
TEST_CALLOC(tmp_buf, tmp_buf_len);
for (i = 0; i < tmp_buf_len; i++) {
TEST_ASSERT(mbedtls_ecdsa_raw_to_der(input->x, input->len,
tmp_buf, i, &ret_len,
key_bits) != 0);
}
TEST_EQUAL(mbedtls_ecdsa_raw_to_der(input->x, input->len,
tmp_buf, i, &ret_len,
key_bits), 0);
exit:
mbedtls_free(tmp_buf);
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_PSA_UTIL_HAVE_ECDSA */
void ecdsa_der_to_raw(int key_bits, data_t *input, data_t *exp_result, int exp_ret)
{