From 816cf7051b7e0ff973314b480f74b4d59d0b6af8 Mon Sep 17 00:00:00 2001 From: Ioannis Karachalios Date: Fri, 17 May 2024 18:58:24 +0300 Subject: [PATCH] tests: crypto: crypto_hash: Add support for Smartbond Pro DevKit This commit should add support for the DA1469x Pro DevKit. Signed-off-by: Ioannis Karachalios --- .../crypto_hash/boards/da1469x_dk_pro.overlay | 9 ++++++++ tests/crypto/crypto_hash/prj.conf | 10 ++------- tests/crypto/crypto_hash/prj_mtls_shim.conf | 10 +++++++++ tests/crypto/crypto_hash/src/main.c | 21 +++++++++++++++++++ tests/crypto/crypto_hash/testcase.yaml | 1 + 5 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 tests/crypto/crypto_hash/boards/da1469x_dk_pro.overlay create mode 100644 tests/crypto/crypto_hash/prj_mtls_shim.conf diff --git a/tests/crypto/crypto_hash/boards/da1469x_dk_pro.overlay b/tests/crypto/crypto_hash/boards/da1469x_dk_pro.overlay new file mode 100644 index 00000000000..873bafe029d --- /dev/null +++ b/tests/crypto/crypto_hash/boards/da1469x_dk_pro.overlay @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2023 Renesas Electronics Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&crypto { + status = "okay"; +}; diff --git a/tests/crypto/crypto_hash/prj.conf b/tests/crypto/crypto_hash/prj.conf index 5aba0ef5c39..68f464029a2 100644 --- a/tests/crypto/crypto_hash/prj.conf +++ b/tests/crypto/crypto_hash/prj.conf @@ -1,15 +1,9 @@ CONFIG_ZTEST_STACK_SIZE=4096 CONFIG_ZTEST=y +CONFIG_LOG=y +CONFIG_LOG_MODE_MINIMAL=y -CONFIG_MBEDTLS=y -CONFIG_MBEDTLS_BUILTIN=y -CONFIG_MBEDTLS_TEST=y - -CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y -CONFIG_MBEDTLS_CIPHER_GCM_ENABLED=y -CONFIG_MBEDTLS_HEAP_SIZE=512 CONFIG_MAIN_STACK_SIZE=4096 CONFIG_CRYPTO=y -CONFIG_CRYPTO_MBEDTLS_SHIM=y CONFIG_CRYPTO_LOG_LEVEL_DBG=y diff --git a/tests/crypto/crypto_hash/prj_mtls_shim.conf b/tests/crypto/crypto_hash/prj_mtls_shim.conf new file mode 100644 index 00000000000..6e4896e57a1 --- /dev/null +++ b/tests/crypto/crypto_hash/prj_mtls_shim.conf @@ -0,0 +1,10 @@ +CONFIG_MBEDTLS=y +CONFIG_MBEDTLS_BUILTIN=y +CONFIG_MBEDTLS_TEST=y + +CONFIG_MBEDTLS_HEAP_SIZE=512 + +CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y +CONFIG_MBEDTLS_CIPHER_GCM_ENABLED=y + +CONFIG_CRYPTO_MBEDTLS_SHIM=y diff --git a/tests/crypto/crypto_hash/src/main.c b/tests/crypto/crypto_hash/src/main.c index 90ce205c010..ea1229dda6d 100644 --- a/tests/crypto/crypto_hash/src/main.c +++ b/tests/crypto/crypto_hash/src/main.c @@ -6,8 +6,16 @@ #include #include +#include +#include +#ifdef CONFIG_CRYPTO_MBEDTLS_SHIM #define CRYPTO_DRV_NAME CONFIG_CRYPTO_MBEDTLS_SHIM_DRV_NAME +#elif DT_HAS_COMPAT_STATUS_OKAY(renesas_smartbond_crypto) +#define CRYPTO_DEV_COMPAT renesas_smartbond_crypto +#else +#error "You need to enable one crypto device" +#endif /* Following test are part of mbedTLS */ @@ -128,8 +136,21 @@ ZTEST_USER(crypto_hash, test_hash) { int ret; struct hash_ctx ctx; + +#ifdef CRYPTO_DRV_NAME const struct device *dev = device_get_binding(CRYPTO_DRV_NAME); + if (!dev) { + zassert(0, "Crypto device is not ready"); + } +#else + const struct device *dev = DEVICE_DT_GET_ONE(CRYPTO_DEV_COMPAT); + + if (!device_is_ready(dev)) { + zassert(0, "Crypto device is not ready"); + } +#endif + ctx.flags = CAP_SYNC_OPS | CAP_SEPARATE_IO_BUFS; ret = hash_begin_session(dev, &ctx, CRYPTO_HASH_ALGO_SHA256); diff --git a/tests/crypto/crypto_hash/testcase.yaml b/tests/crypto/crypto_hash/testcase.yaml index 8821234d03c..99eeb3e59f2 100644 --- a/tests/crypto/crypto_hash/testcase.yaml +++ b/tests/crypto/crypto_hash/testcase.yaml @@ -5,4 +5,5 @@ tests: - native_sim integration_platforms: - native_sim + extra_args: EXTRA_CONF_FILE=prj_mtls_shim.conf tags: crypto