1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

test_suite_block_cipher: add new data file for PSA/legacy dispatch test

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
Valerio Setti
2023-12-12 15:34:25 +01:00
parent 10e9aa26c5
commit 1cf81c3c80
2 changed files with 73 additions and 0 deletions

View File

@ -92,3 +92,37 @@ exit:
mbedtls_block_cipher_free(&ctx);
}
/* END_CASE */
/* BEGIN_CASE */
void block_cipher_psa_dynamic_dispatch(int cipher_type, int pre_psa_ret, int post_psa_engine)
{
mbedtls_block_cipher_context_t ctx;
/* Intentionally no PSA init here! (Will be done later.) */
mbedtls_block_cipher_init(&ctx);
/* Before PSA crypto init */
TEST_EQUAL(pre_psa_ret, mbedtls_block_cipher_setup(&ctx, cipher_type));
#if defined(MBEDTLS_BLOCK_CIPHER_SOME_PSA)
TEST_EQUAL(ctx.engine, MBEDTLS_BLOCK_CIPHER_ENGINE_LEGACY);
#endif
mbedtls_block_cipher_free(&ctx);
/* Now initilize PSA Crypto */
BLOCK_CIPHER_PSA_INIT();
mbedtls_block_cipher_init(&ctx);
/* After PSA Crypto init */
TEST_EQUAL(0, mbedtls_block_cipher_setup(&ctx, cipher_type));
#if defined(MBEDTLS_BLOCK_CIPHER_SOME_PSA)
TEST_EQUAL(ctx.engine, post_psa_engine);
#endif
exit:
mbedtls_block_cipher_free(&ctx);
BLOCK_CIPHER_PSA_DONE();
}
/* END_CASE */