blob: 81d18cb4b54e0a1d9f386253a3db876f518cf6b6 [file] [log] [blame]
Julian Hall5e3626f2022-04-07 14:05:08 +01001Libraries
2=========
Julian Hall4287cec2022-04-08 09:00:48 +01003Some deployments build common functionality into libraries that may be used by
4other deployments or external applications. The following library deployments
5are currently supported:
Julian Hall5e3626f2022-04-07 14:05:08 +01006
Gyorgy Szinga6c95df2022-11-25 11:15:51 +01007.. _libs-libts:
8
Julian Hall4287cec2022-04-08 09:00:48 +01009libts
10-----
11Userspace applications that depend on trusted services may use *libts* for handling
12service discovery and RPC messaging. A major benefit to application developers is
13that *libts* entirely decouples client applications from details of where a service
14provider is deployed and how to communicate with it. All TS test executables and
15tools that interact with service providers use *libts*.
16
17To facilitate test and development within a native PC environment, the *libts*
18deployment for the *linux-pc* environment integrates a set of service providers
19into the library itself. From a client application's perspective, this looks
20exactly the same as when running on a target platform with service providers
21deployed in secure processing environments. For more information, see:
22:ref:`Service Locator`.
23
24.. list-table::
25 :widths: 1 2
26 :header-rows: 0
27
28 * - Supported Environments
29 - * | *linux-pc* - service providers integrated into library
30 * | *arm-linux* - communicates with service providers in secure processing environment
31 * - Used by
32 - * Userspace applications
33
Gabor Toth841b0b62023-05-22 10:28:29 +020034.. _libs-libpsa:
35
36libpsa
37------
38Trusted Services implements the `PSA Certified APIs`_. Libpsa encapsulates the service client implementations
39which implement this API. Linux uuser-space applications can use libpsa to easily access the PSA services
40implemented by the project. Libpsa depends on libts for RPC and service discovery services.
41
42.. list-table::
43 :widths: 1 2
44 :header-rows: 0
45
46 * - Supported Environments
47 - * | *linux-pc*
48 * | *arm-linux*
49 * - Used by
50 - * Userspace applications
51 * - Depends on
52 - * `libts`_ library
53
54Build and integration examples
55..............................
56
57Build as shared library::
58
59 cmake -S ./trusted-services/deployments/libpsa/linux-pc/ -B ./build
60 make -C build && make -C build install
61
62.. warning::
63 Building as static library is not yet supported.
64
65To integrate the library libts shall also be integrated. To achieve this add the listed
66lines to the application's cmake files::
67
68 find_package(libpsa "1.0.0" REQUIRED PATHS "<install path>")
69 find_package(libts "2.0.0" REQUIRED PATHS "<install path>")
70 target_link_libraries(ts-demo PRIVATE libpsa::psa)
71
72Initialization
73..............
74
75Before calling any function from libpsa the proper part of the library has to be initialized.
76Before exiting the application (or when PSA services are no longer needed) the initialized
77parts must be deinitialized. To access the library **libpsa.h** must be included::
78
79 psa_status_t libpsa_init_crypto_context(const char *service_name);
80 void libpsa_deinit_crypto_context(void);
81
82 psa_status_t libpsa_init_attestation_context(const char *service_name);
83 void libpsa_deinit_attestation_context(void);
84
85 psa_status_t libpsa_init_its_context(const char *service_name);
86 void libpsa_deinit_its_context(void);
87
88 psa_status_t libpsa_init_ps_context(const char *service_name);
89 void libpsa_deinit_ps_context(void);
90
91The example below initializes and then deinitializes crypto::
92
93 psa_status_t psa_status = libpsa_init_crypto_context("sn:trustedfirmware.org:crypto:0");
94 if (psa_status) {
95 printf("libpsa_init_crypto_context failed: %d\n", psa_status);
96 return PSA_ERROR_GENERIC_ERROR;
97 }
98
99 libpsa_deinit_crypto_context();
100
101Known issues and Limitations
102............................
103
104| The library is single client.
105| The library is not thread safe.
106| Only linux user-space is supported currently.
107
Gyorgy Szinga6c95df2022-11-25 11:15:51 +0100108.. _libs-libsp:
109
Julian Hall4287cec2022-04-08 09:00:48 +0100110libsp
111-----
112*libsp* provides a functional interface for using FF-A messaging and memory
113management facilities. *libsp* is used in SP deployments. For more information, see:
114:ref:`libsp`.
115
116.. list-table::
117 :widths: 1 2
118 :header-rows: 0
119
120 * - Supported Environments
121 - * | *opteesp*
122 * - Used by
123 - * Secure partitions
Julian Hall5e3626f2022-04-07 14:05:08 +0100124
Gabor Toth841b0b62023-05-22 10:28:29 +0200125Known issues and Limitations
126............................
127
128| The library is single client.
129| The library is not thread safe.
130| Only linux user-space is supported currently.
131
Julian Hall5e3626f2022-04-07 14:05:08 +0100132--------------
133
Gabor Toth841b0b62023-05-22 10:28:29 +0200134.. _`PSA Certified APIs`: https://arm-software.github.io/psa-api/
135
136*Copyright (c) 2022-2023, Arm Limited and Contributors. All rights reserved.*
Julian Hall5e3626f2022-04-07 14:05:08 +0100137
138SPDX-License-Identifier: BSD-3-Clause