Summer Qin | 153f3df | 2022-11-17 15:51:02 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
Summer Qin | 46f1c98 | 2022-12-14 15:24:50 +0800 | [diff] [blame^] | 8 | #include <stdint.h> |
Summer Qin | 153f3df | 2022-11-17 15:51:02 +0800 | [diff] [blame] | 9 | #include <stdio.h> |
Summer Qin | 46f1c98 | 2022-12-14 15:24:50 +0800 | [diff] [blame^] | 10 | #include <string.h> |
Summer Qin | 153f3df | 2022-11-17 15:51:02 +0800 | [diff] [blame] | 11 | #include "erpc_port.h" |
| 12 | #include "erpc_client_start.h" |
| 13 | #include "tfm_erpc_psa_client_api.h" |
Summer Qin | 46f1c98 | 2022-12-14 15:24:50 +0800 | [diff] [blame^] | 14 | #include "tfm_crypto_defs.h" |
| 15 | #include "psa/client.h" |
| 16 | #include "psa/crypto.h" |
| 17 | |
| 18 | static 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 Qin | 153f3df | 2022-11-17 15:51:02 +0800 | [diff] [blame] | 35 | |
| 36 | int 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 Qin | 46f1c98 | 2022-12-14 15:24:50 +0800 | [diff] [blame^] | 57 | test_call(); |
| 58 | |
Summer Qin | 153f3df | 2022-11-17 15:51:02 +0800 | [diff] [blame] | 59 | return 0; |
| 60 | } |