Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: BSD-2-Clause |
| 2 | /* |
Julian Hall | a544317 | 2022-05-30 11:52:11 +0100 | [diff] [blame] | 3 | * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved. |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 4 | */ |
| 5 | |
Julian Hall | a544317 | 2022-05-30 11:52:11 +0100 | [diff] [blame] | 6 | #include <cstdio> |
Julian Hall | 7a70340 | 2021-08-04 09:20:43 +0100 | [diff] [blame] | 7 | #include <service/crypto/client/cpp/protocol/packed-c/packedc_crypto_client.h> |
julhal01 | c3f4e9a | 2020-12-15 13:39:01 +0000 | [diff] [blame] | 8 | #include <protocols/rpc/common/packed-c/encoding.h> |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 9 | #include <app/ts-demo/ts-demo.h> |
| 10 | #include <service_locator.h> |
| 11 | #include <rpc_caller.h> |
| 12 | |
| 13 | int main(int argc, char *argv[]) { |
| 14 | (void) argc; |
| 15 | (void) argv; |
| 16 | |
| 17 | int status = -1; |
| 18 | struct service_context *crypto_service_context = NULL; |
| 19 | |
| 20 | service_locator_init(); |
| 21 | |
Imre Kis | b059afa | 2023-08-02 14:36:21 +0200 | [diff] [blame] | 22 | crypto_service_context = service_locator_query("sn:trustedfirmware.org:crypto:0"); |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 23 | |
| 24 | if (crypto_service_context) { |
| 25 | |
Imre Kis | b059afa | 2023-08-02 14:36:21 +0200 | [diff] [blame] | 26 | struct rpc_caller_session *session = NULL; |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 27 | |
Imre Kis | b059afa | 2023-08-02 14:36:21 +0200 | [diff] [blame] | 28 | session = service_context_open(crypto_service_context); |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 29 | |
Imre Kis | b059afa | 2023-08-02 14:36:21 +0200 | [diff] [blame] | 30 | if (session) { |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 31 | |
Imre Kis | b059afa | 2023-08-02 14:36:21 +0200 | [diff] [blame] | 32 | packedc_crypto_client crypto_client(session); |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 33 | |
| 34 | status = run_ts_demo(&crypto_client, true); |
| 35 | |
| 36 | if (status != 0) { |
| 37 | printf("run_ts_demo failed\n"); |
| 38 | } |
| 39 | |
Imre Kis | b059afa | 2023-08-02 14:36:21 +0200 | [diff] [blame] | 40 | service_context_close(crypto_service_context, session); |
Julian Hall | eff4b28 | 2020-11-23 18:24:12 +0100 | [diff] [blame] | 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 | } |