blob: ddf2665d9a8a2c2784ccb79375d31cabfa8bcf1f [file] [log] [blame]
Summer Qin153f3df2022-11-17 15:51:02 +08001/*
2 * Copyright (c) 2023, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Summer Qin46f1c982022-12-14 15:24:50 +08008#include <stdint.h>
Summer Qin153f3df2022-11-17 15:51:02 +08009#include <stdio.h>
Summer Qin46f1c982022-12-14 15:24:50 +080010#include <string.h>
Summer Qin153f3df2022-11-17 15:51:02 +080011#include "erpc_port.h"
12#include "erpc_client_start.h"
13#include "tfm_erpc_psa_client_api.h"
Summer Qin46f1c982022-12-14 15:24:50 +080014#include "tfm_crypto_defs.h"
15#include "psa/client.h"
16#include "psa/crypto.h"
17
18static void test_call(void)
19{
20 psa_status_t status;
21 uint8_t hash[PSA_HASH_LENGTH(PSA_ALG_SHA_256)] = {0};
22 size_t hash_size = sizeof(hash);
23 const uint8_t *msg = "test";
24
25 status = psa_hash_compute(PSA_ALG_SHA_256, msg, strlen(msg), hash, hash_size, &hash_size);
26
27 printf("psa_hash_compute: %d\r\n", status);
28 printf("> hash_size = %zu\r\n", hash_size);
29 printf("> hash = ");
30 for (size_t i = 0; i < sizeof(hash); ++i) {
31 printf("%02hhX", hash[i]);
32 }
33 printf("\r\n");
34}
Summer Qin153f3df2022-11-17 15:51:02 +080035
36int main(int argc, char *argv[])
37{
38 erpc_transport_t transport;
39
40#ifdef ERPC_TRANSPORT_UART
41 transport = erpc_transport_serial_init(PORT_NAME, 115200);
42#elif defined(ERPC_TRANSPORT_TCP)
43 transport = erpc_transport_tcp_init(ERPC_HOST, ERPC_PORT, false);
44#else
45#error "No valid transportation layer selected."
46#endif
47
48 if (!transport) {
49 printf("eRPC transport init failed!\r\n");
50 return 1;
51 }
52
53 erpc_client_start(transport);
54
55 printf("psa_framework_version: %d\r\n", psa_framework_version());
56
Summer Qin46f1c982022-12-14 15:24:50 +080057 test_call();
58
Summer Qin153f3df2022-11-17 15:51:02 +080059 return 0;
60}