From 2c2243dc0b750743c4a1eaf5dca5891b5b07908f Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 24 Jun 2019 13:47:24 +0200 Subject: [PATCH] Smoke test for secure element driver registration --- tests/CMakeLists.txt | 1 + .../test_suite_psa_crypto_se_driver_hal.data | 2 ++ ...st_suite_psa_crypto_se_driver_hal.function | 29 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 tests/suites/test_suite_psa_crypto_se_driver_hal.data create mode 100644 tests/suites/test_suite_psa_crypto_se_driver_hal.function diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 42d99d623..323ad2dc6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -135,6 +135,7 @@ add_test_suite(psa_crypto_hash) add_test_suite(psa_crypto_init) add_test_suite(psa_crypto_metadata) add_test_suite(psa_crypto_persistent_key) +add_test_suite(psa_crypto_se_driver_hal) add_test_suite(psa_crypto_slot_management) add_test_suite(psa_its) add_test_suite(shax) diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal.data b/tests/suites/test_suite_psa_crypto_se_driver_hal.data new file mode 100644 index 000000000..1d27fb9b6 --- /dev/null +++ b/tests/suites/test_suite_psa_crypto_se_driver_hal.data @@ -0,0 +1,2 @@ +Register SE driver: good +register_one:2:PSA_DRV_SE_HAL_VERSION:PSA_SUCCESS diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal.function b/tests/suites/test_suite_psa_crypto_se_driver_hal.function new file mode 100644 index 000000000..efbbd4e36 --- /dev/null +++ b/tests/suites/test_suite_psa_crypto_se_driver_hal.function @@ -0,0 +1,29 @@ +/* BEGIN_HEADER */ +#include "psa_crypto_helpers.h" +#include "psa/crypto_se_driver.h" + +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_PSA_CRYPTO_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE */ +void register_one( int lifetime, int version, int expected_status_arg ) +{ + psa_status_t expected_status = expected_status_arg; + psa_drv_se_t driver; + + memset( &driver, 0, sizeof( driver ) ); + driver.hal_version = version; + + TEST_EQUAL( psa_register_se_driver( lifetime, &driver ), + expected_status ); + + PSA_ASSERT( psa_crypto_init( ) ); + +exit: + PSA_DONE( ); +} +/* END_CASE */