Test: Add erpc test case
Add psa_hash_compute test case.
Signed-off-by: Summer Qin <summer.qin@arm.com>
Change-Id: I210a4799846b7a825ee994ae6e1ecce4baa04c30
diff --git a/erpc/host_example/CMakeLists.txt b/erpc/host_example/CMakeLists.txt
index 3caf2b2..626e08a 100644
--- a/erpc/host_example/CMakeLists.txt
+++ b/erpc/host_example/CMakeLists.txt
@@ -39,6 +39,7 @@
$<$<STREQUAL:${ERPC_TRANSPORT},UART>:${ERPC_REPO_PATH}/erpc_c/transports/erpc_serial_transport.cpp>
$<$<STREQUAL:${ERPC_TRANSPORT},TCP>:${ERPC_REPO_PATH}/erpc_c/setup/erpc_setup_tcp.cpp>
$<$<STREQUAL:${ERPC_TRANSPORT},TCP>:${ERPC_REPO_PATH}/erpc_c/transports/erpc_tcp_transport.cpp>
+ ${TFM_INSTALL_PATH}/interface/src/tfm_crypto_api.c
)
target_link_libraries(erpc_main
@@ -54,4 +55,5 @@
$<$<AND:$<STREQUAL:${ERPC_TRANSPORT},UART>,$<BOOL:${PORT_NAME}>>:PORT_NAME="${PORT_NAME}">
$<$<AND:$<STREQUAL:${ERPC_TRANSPORT},TCP>,$<BOOL:${ERPC_HOST}>>:ERPC_HOST="${ERPC_HOST}">
$<$<AND:$<STREQUAL:${ERPC_TRANSPORT},TCP>,$<BOOL:${ERPC_PORT}>>:ERPC_PORT=${ERPC_PORT}>
+ PLATFORM_DEFAULT_CRYPTO_KEYS
)
diff --git a/erpc/host_example/README.rst b/erpc/host_example/README.rst
index a00b024..d0e25f1 100644
--- a/erpc/host_example/README.rst
+++ b/erpc/host_example/README.rst
@@ -13,7 +13,7 @@
.. code-block:: bash
cd <TF-M base folder>
- cmake -G"Unix Makefiles" -S . -B cmake_build -DTFM_PLATFORM=musca_s1 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug -DCONFIG_TFM_ERPC_TEST_FRAMEWORK=ON ../
+ cmake -G"Unix Makefiles" -S . -B cmake_build -DTFM_PLATFORM=musca_s1 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug -DCONFIG_TFM_ERPC_TEST_FRAMEWORK=ON -DTFM_PARTITION_CRYPTO=ON -DTFM_PARTITION_INTERNAL_TRUSTED_STORAGE=ON ../
cmake --build cmake_build/ -- install -j32
Build instructions on the host
@@ -42,7 +42,7 @@
.. code-block:: bash
cd <TF-M base folder>
- cmake -G"Unix Makefiles" -S . -B cmake_build -DTFM_PLATFORM=an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug -DCONFIG_TFM_ERPC_TEST_FRAMEWORK=ON ../
+ cmake -G"Unix Makefiles" -S . -B cmake_build -DTFM_PLATFORM=an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug -DCONFIG_TFM_ERPC_TEST_FRAMEWORK=ON -DTFM_PARTITION_CRYPTO=ON -DTFM_PARTITION_INTERNAL_TRUSTED_STORAGE=ON ../
cmake --build cmake_build/ -- install -j32
Build instructions on the host
diff --git a/erpc/host_example/main.c b/erpc/host_example/main.c
index b46ab27..ddf2665 100644
--- a/erpc/host_example/main.c
+++ b/erpc/host_example/main.c
@@ -5,10 +5,33 @@
*
*/
+#include <stdint.h>
#include <stdio.h>
+#include <string.h>
#include "erpc_port.h"
#include "erpc_client_start.h"
#include "tfm_erpc_psa_client_api.h"
+#include "tfm_crypto_defs.h"
+#include "psa/client.h"
+#include "psa/crypto.h"
+
+static void test_call(void)
+{
+ psa_status_t status;
+ uint8_t hash[PSA_HASH_LENGTH(PSA_ALG_SHA_256)] = {0};
+ size_t hash_size = sizeof(hash);
+ const uint8_t *msg = "test";
+
+ status = psa_hash_compute(PSA_ALG_SHA_256, msg, strlen(msg), hash, hash_size, &hash_size);
+
+ printf("psa_hash_compute: %d\r\n", status);
+ printf("> hash_size = %zu\r\n", hash_size);
+ printf("> hash = ");
+ for (size_t i = 0; i < sizeof(hash); ++i) {
+ printf("%02hhX", hash[i]);
+ }
+ printf("\r\n");
+}
int main(int argc, char *argv[])
{
@@ -31,5 +54,7 @@
printf("psa_framework_version: %d\r\n", psa_framework_version());
+ test_call();
+
return 0;
}