1 /*
2 * Copyright (c) 2021 Nordic Semiconductor ASA.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <tfm_ns_interface.h>
8
9 #include "dummy_partition.h"
10
11 #if defined(CONFIG_TFM_IPC)
12 #include "psa/client.h"
13 #include "psa_manifest/sid.h"
14
dp_secret_digest(uint32_t secret_index,void * p_digest,size_t digest_size)15 psa_status_t dp_secret_digest(uint32_t secret_index,
16 void *p_digest,
17 size_t digest_size)
18 {
19 psa_status_t status;
20 psa_handle_t handle;
21
22 psa_invec in_vec[] = {
23 { .base = &secret_index, .len = sizeof(secret_index) },
24 };
25
26 psa_outvec out_vec[] = {
27 { .base = p_digest, .len = digest_size }
28 };
29
30 handle = psa_connect(TFM_DP_SECRET_DIGEST_SID,
31 TFM_DP_SECRET_DIGEST_VERSION);
32 if (!PSA_HANDLE_IS_VALID(handle)) {
33 return PSA_ERROR_GENERIC_ERROR;
34 }
35
36 status = psa_call(handle, PSA_IPC_CALL, in_vec, IOVEC_LEN(in_vec),
37 out_vec, IOVEC_LEN(out_vec));
38
39 psa_close(handle);
40
41 return status;
42 }
43 #else /* defined(CONFIG_TFM_IPC) */
dp_secret_digest(uint32_t secret_index,void * p_digest,size_t digest_size)44 psa_status_t dp_secret_digest(uint32_t secret_index,
45 void *p_digest,
46 size_t digest_size)
47 {
48 psa_status_t status;
49 psa_invec in_vec[] = {
50 { .base = &secret_index, .len = sizeof(secret_index) },
51 };
52
53 psa_outvec out_vec[] = {
54 { .base = p_digest, .len = digest_size }
55 };
56
57 status = tfm_ns_interface_dispatch(
58 (veneer_fn)tfm_dp_secret_digest_req_veneer,
59 (uint32_t)in_vec, IOVEC_LEN(in_vec),
60 (uint32_t)out_vec, IOVEC_LEN(out_vec));
61
62 return status;
63 }
64 #endif /* defined(CONFIG_TFM_IPC) */
65