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

@ -83,3 +83,15 @@ ecdsa_raw_to_der:528:"1111111111111111111111111111111111111111111111111111111111
ECDSA DER -> Raw, 521bit, Success
depends_on:PSA_WANT_ECC_SECP_R1_521
ecdsa_der_to_raw:528:"30818802421111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110242222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222":"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222":0
ECDSA Raw -> DER, 256bit, Incremental DER buffer sizes
depends_on:PSA_WANT_ECC_SECP_K1_256
ecdsa_raw_to_der_incremental:256:"91111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222222222222222222":"3045022100911111111111111111111111111111111111111111111111111111111111111102202222222222222222222222222222222222222222222222222222222222222222"
ECDSA Raw -> DER, 512bit, Incremental DER buffer sizes
depends_on:PSA_WANT_ECC_BRAINPOOL_P_R1_512
ecdsa_raw_to_der_incremental:512:"9111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222":"30818502410091111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111024022222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"
ECDSA Raw -> DER, 521bit, Incremental DER buffer sizes
depends_on:PSA_WANT_ECC_SECP_R1_521
ecdsa_raw_to_der_incremental:528:"911111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222":"3081890243009111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110242222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222"

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)
{