blob: 7ccd7ddd7c42a43a6ba84e782f15fd8b71f9c403 [file] [log] [blame]
Julian Halleff4b282020-11-23 18:24:12 +01001// SPDX-License-Identifier: BSD-2-Clause
2/*
julhal01c3f4e9a2020-12-15 13:39:01 +00003 * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
Julian Halleff4b282020-11-23 18:24:12 +01004 */
5
Julian Hall7a703402021-08-04 09:20:43 +01006#include <service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.h>
julhal01c3f4e9a2020-12-15 13:39:01 +00007#include <protocols/rpc/common/packed-c/encoding.h>
Julian Halleff4b282020-11-23 18:24:12 +01008#include <app/ts-demo/ts-demo.h>
9#include <service_locator.h>
10#include <rpc_caller.h>
11
12int main(int argc, char *argv[]) {
13 (void) argc;
14 (void) argv;
15
16 int status = -1;
17 struct service_context *crypto_service_context = NULL;
18
19 service_locator_init();
20
21 crypto_service_context = service_locator_query("sn:trustedfirmware.org:crypto:0", &status);
22
23 if (crypto_service_context) {
24
25 struct rpc_caller *caller;
26 rpc_session_handle rpc_session_handle;
27
julhal01734dbad2020-12-21 10:27:41 +000028 rpc_session_handle = service_context_open(crypto_service_context, TS_RPC_ENCODING_PACKED_C, &caller);
Julian Halleff4b282020-11-23 18:24:12 +010029
30 if (rpc_session_handle) {
31
julhal01734dbad2020-12-21 10:27:41 +000032 packedc_crypto_client crypto_client(caller);
Julian Halleff4b282020-11-23 18:24:12 +010033
34 status = run_ts_demo(&crypto_client, true);
35
36 if (status != 0) {
37 printf("run_ts_demo failed\n");
38 }
39
40 service_context_close(crypto_service_context, rpc_session_handle);
41 }
42 else {
43 printf("Failed to open rpc session\n");
44 }
45
46 service_context_relinquish(crypto_service_context);
47 }
48 else {
49 printf("Failed to discover crypto service\n");
50 }
51
52 return status;
53}