blob: d48498e68245939e3507330687202048af44b4d1 [file] [log] [blame]
Valerio Setti4f4ade92024-05-03 17:28:04 +02001/* 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
12extern "C" {
13#endif
14
15#include <stdint.h>
16#include <stddef.h>
17
Valerio Setti655b9792024-05-09 12:20:40 +020018#include "psa/crypto.h"
19
Valerio Setti66fb1c12024-05-10 06:51:16 +020020#include "error_ext.h"
Valerio Setti4f4ade92024-05-03 17:28:04 +020021/*********************** 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 */
41typedef 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 */
49typedef struct psa_outvec {
50 void *base;
51 size_t len;
52} psa_outvec;
53
54/*************************** PSA Client API **********************************/
55
56uint32_t psa_framework_version(void);
57
58uint32_t psa_version(uint32_t sid);
59
60psa_handle_t psa_connect(uint32_t sid, uint32_t version);
61
62psa_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
69void psa_close(psa_handle_t handle);
70
71#ifdef __cplusplus
72}
73#endif
74
75#endif /* __PSA_CLIENT_H__ */