aboutsummaryrefslogtreecommitdiff
path: root/deployments/ts-demo
diff options
context:
space:
mode:
Diffstat (limited to 'deployments/ts-demo')
-rw-r--r--deployments/ts-demo/arm-linux/.gitignore1
-rw-r--r--deployments/ts-demo/arm-linux/CMakeLists.txt33
-rw-r--r--deployments/ts-demo/linux-pc/CMakeLists.txt26
-rw-r--r--deployments/ts-demo/ts-demo.cmake65
-rw-r--r--deployments/ts-demo/ts-demo.cpp52
5 files changed, 177 insertions, 0 deletions
diff --git a/deployments/ts-demo/arm-linux/.gitignore b/deployments/ts-demo/arm-linux/.gitignore
new file mode 100644
index 0000000..378eac2
--- /dev/null
+++ b/deployments/ts-demo/arm-linux/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/deployments/ts-demo/arm-linux/CMakeLists.txt b/deployments/ts-demo/arm-linux/CMakeLists.txt
new file mode 100644
index 0000000..8b2fcf4
--- /dev/null
+++ b/deployments/ts-demo/arm-linux/CMakeLists.txt
@@ -0,0 +1,33 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.16)
+include(../../deployment.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# The CMakeLists.txt for building the ts-demo deployment for arm-linux
+#
+# Used for building and running service level tests from Linux user-space
+# on an Arm platform with real deployments of trusted services.
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/environments/arm-linux/env.cmake)
+project(trusted-services LANGUAGES CXX C)
+add_executable(ts-demo)
+target_include_directories(ts-demo PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+
+#-------------------------------------------------------------------------------
+# Extend with components that are common across all deployments of
+# ts-demo
+#
+#-------------------------------------------------------------------------------
+include(../ts-demo.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# Define library options and dependencies.
+#
+#-------------------------------------------------------------------------------
+env_set_link_options(TGT ts-demo)
+target_link_libraries(ts-demo PRIVATE stdc++ gcc m)
diff --git a/deployments/ts-demo/linux-pc/CMakeLists.txt b/deployments/ts-demo/linux-pc/CMakeLists.txt
new file mode 100644
index 0000000..4d49adc
--- /dev/null
+++ b/deployments/ts-demo/linux-pc/CMakeLists.txt
@@ -0,0 +1,26 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.16)
+include(../../deployment.cmake REQUIRED)
+
+#-------------------------------------------------------------------------------
+# The CMakeLists.txt for building the ts-demo deployment for linux-pc
+#
+# Used for building and running service level tests from Linux user-space
+# on an Arm platform with real deployments of trusted services.
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/environments/linux-pc/env.cmake)
+project(trusted-services LANGUAGES CXX C)
+add_executable(ts-demo)
+target_include_directories(ts-demo PRIVATE "${TOP_LEVEL_INCLUDE_DIRS}")
+
+#-------------------------------------------------------------------------------
+# Extend with components that are common across all deployments of
+# ts-demo
+#
+#-------------------------------------------------------------------------------
+include(../ts-demo.cmake REQUIRED)
diff --git a/deployments/ts-demo/ts-demo.cmake b/deployments/ts-demo/ts-demo.cmake
new file mode 100644
index 0000000..4c85a40
--- /dev/null
+++ b/deployments/ts-demo/ts-demo.cmake
@@ -0,0 +1,65 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# The base build file shared between deployments of 'ts-demo' for
+# different environments. Demonstrates use of trusted services by a
+# client application.
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Use libts for locating and accessing services. An appropriate version of
+# libts will be imported for the enviroment in which service tests are
+# deployed.
+#-------------------------------------------------------------------------------
+include(${TS_ROOT}/deployments/libts/libts-import.cmake)
+target_link_libraries(ts-demo PRIVATE libts)
+
+#-------------------------------------------------------------------------------
+# Common main for all deployments
+#
+#-------------------------------------------------------------------------------
+target_sources(ts-demo PRIVATE
+ "${CMAKE_CURRENT_LIST_DIR}/ts-demo.cpp"
+)
+
+#-------------------------------------------------------------------------------
+# Components that are common accross all deployments
+#
+#-------------------------------------------------------------------------------
+add_components(
+ TARGET "ts-demo"
+ BASE_DIR ${TS_ROOT}
+ COMPONENTS
+ "components/app/ts-demo"
+ "components/service/crypto/client/cpp"
+ "components/service/common/serializer/protobuf"
+ "protocols/service/crypto/protobuf"
+)
+
+#-------------------------------------------------------------------------------
+# Components used from external projects
+#
+#-------------------------------------------------------------------------------
+
+# Nanopb
+include(${TS_ROOT}/external/nanopb/nanopb.cmake)
+target_link_libraries(ts-demo PRIVATE nanopb::protobuf-nanopb-static)
+protobuf_generate_all(TGT "ts-demo" NAMESPACE "protobuf" BASE_DIR "${TS_ROOT}/protocols")
+
+# Mbedcrypto
+include(${TS_ROOT}/external/mbed-crypto/mbedcrypto.cmake)
+target_link_libraries(ts-demo PRIVATE mbedcrypto)
+
+#-------------------------------------------------------------------------------
+# Define install content.
+#
+#-------------------------------------------------------------------------------
+if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "location to install build output to." FORCE)
+endif()
+install(TARGETS ts-demo RUNTIME DESTINATION bin) \ No newline at end of file
diff --git a/deployments/ts-demo/ts-demo.cpp b/deployments/ts-demo/ts-demo.cpp
new file mode 100644
index 0000000..e055bad
--- /dev/null
+++ b/deployments/ts-demo/ts-demo.cpp
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/*
+ * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+ */
+
+#include <service/crypto/client/cpp/crypto_client.h>
+#include <app/ts-demo/ts-demo.h>
+#include <service_locator.h>
+#include <rpc_caller.h>
+
+int main(int argc, char *argv[]) {
+ (void) argc;
+ (void) argv;
+
+ int status = -1;
+ struct service_context *crypto_service_context = NULL;
+
+ service_locator_init();
+
+ crypto_service_context = service_locator_query("sn:trustedfirmware.org:crypto:0", &status);
+
+ if (crypto_service_context) {
+
+ struct rpc_caller *caller;
+ rpc_session_handle rpc_session_handle;
+
+ rpc_session_handle = service_context_open(crypto_service_context, &caller);
+
+ if (rpc_session_handle) {
+
+ crypto_client crypto_client(caller);
+
+ status = run_ts_demo(&crypto_client, true);
+
+ if (status != 0) {
+ printf("run_ts_demo failed\n");
+ }
+
+ service_context_close(crypto_service_context, rpc_session_handle);
+ }
+ else {
+ printf("Failed to open rpc session\n");
+ }
+
+ service_context_relinquish(crypto_service_context);
+ }
+ else {
+ printf("Failed to discover crypto service\n");
+ }
+
+ return status;
+}