1 /* PSA Firmware Framework client header for psasim. */
2 
3 /*
4  *  Copyright The Mbed TLS Contributors
5  *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
6  */
7 
8 #ifndef __PSA_CLIENT_H__
9 #define __PSA_CLIENT_H__
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include <stdint.h>
16 #include <stddef.h>
17 
18 #include "psa/crypto.h"
19 
20 #include "error_ext.h"
21 /*********************** PSA Client Macros and Types *************************/
22 
23 #define PSA_FRAMEWORK_VERSION  (0x0100)
24 
25 #define PSA_VERSION_NONE       (0)
26 
27 /* PSA response types */
28 #define PSA_CONNECTION_REFUSED PSA_ERROR_CONNECTION_REFUSED
29 #define PSA_CONNECTION_BUSY    PSA_ERROR_CONNECTION_BUSY
30 #define PSA_DROP_CONNECTION    PSA_ERROR_PROGRAMMER_ERROR
31 
32 /* PSA message handles */
33 #define PSA_NULL_HANDLE        ((psa_handle_t) 0)
34 
35 #define PSA_HANDLE_IS_VALID(handle) ((psa_handle_t) (handle) > 0)
36 #define PSA_HANDLE_TO_ERROR(handle) ((psa_status_t) (handle))
37 
38 /**
39  * A read-only input memory region provided to an RoT Service.
40  */
41 typedef struct psa_invec {
42     const void *base;
43     size_t len;
44 } psa_invec;
45 
46 /**
47  * A writable output memory region provided to an RoT Service.
48  */
49 typedef struct psa_outvec {
50     void *base;
51     size_t len;
52 } psa_outvec;
53 
54 /*************************** PSA Client API **********************************/
55 
56 uint32_t psa_framework_version(void);
57 
58 uint32_t psa_version(uint32_t sid);
59 
60 psa_handle_t psa_connect(uint32_t sid, uint32_t version);
61 
62 psa_status_t psa_call(psa_handle_t handle,
63                       int32_t type,
64                       const psa_invec *in_vec,
65                       size_t in_len,
66                       psa_outvec *out_vec,
67                       size_t out_len);
68 
69 void psa_close(psa_handle_t handle);
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif /* __PSA_CLIENT_H__ */
76