blob: eb6d1074220e21ab6a4031a4dccb526d40e20a8e [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 Tothee2e7cb2024-10-07 17:02:56 +020034.. _libs-libpsats:
Gabor Toth841b0b62023-05-22 10:28:29 +020035
Gabor Tothee2e7cb2024-10-07 17:02:56 +020036libpsats
Gyorgy Szing1ea699a2024-10-24 17:17:36 +020037--------
Gabor Tothee2e7cb2024-10-07 17:02:56 +020038Trusted Services implements the `PSA Certified APIs`_. Libpsats encapsulates the service client implementations
39which implement this API. Linux uuser-space applications can use libpsats to easily access the PSA services
40implemented by the project. Libpsats depends on libts for RPC and service discovery services.
Gabor Toth841b0b62023-05-22 10:28:29 +020041
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
Gabor Tothee2e7cb2024-10-07 17:02:56 +020059 cmake -S ./trusted-services/deployments/libpsats/linux-pc/ -B ./build
Gabor Toth841b0b62023-05-22 10:28:29 +020060 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
Gabor Tothee2e7cb2024-10-07 17:02:56 +020068 find_package(libpsats "1.0.0" REQUIRED PATHS "<install path>")
Gabor Toth841b0b62023-05-22 10:28:29 +020069 find_package(libts "2.0.0" REQUIRED PATHS "<install path>")
Gabor Tothee2e7cb2024-10-07 17:02:56 +020070 target_link_libraries(ts-demo PRIVATE libpsats::psats)
Gabor Toth841b0b62023-05-22 10:28:29 +020071
72Initialization
73..............
74
Gabor Tothee2e7cb2024-10-07 17:02:56 +020075Before calling any function from libpsats the proper part of the library has to be initialized.
Gabor Toth841b0b62023-05-22 10:28:29 +020076Before exiting the application (or when PSA services are no longer needed) the initialized
Gabor Tothee2e7cb2024-10-07 17:02:56 +020077parts must be deinitialized. To access the library **libpsats.h** must be included::
Gabor Toth841b0b62023-05-22 10:28:29 +020078
Gabor Tothee2e7cb2024-10-07 17:02:56 +020079 psa_status_t libpsats_init_crypto_context(const char *service_name);
80 void libpsats_deinit_crypto_context(void);
Gabor Toth841b0b62023-05-22 10:28:29 +020081
Gabor Tothee2e7cb2024-10-07 17:02:56 +020082 psa_status_t libpsats_init_attestation_context(const char *service_name);
83 void libpsats_deinit_attestation_context(void);
Gabor Toth841b0b62023-05-22 10:28:29 +020084
Gabor Tothee2e7cb2024-10-07 17:02:56 +020085 psa_status_t libpsats_init_its_context(const char *service_name);
86 void libpsats_deinit_its_context(void);
Gabor Toth841b0b62023-05-22 10:28:29 +020087
Gabor Tothee2e7cb2024-10-07 17:02:56 +020088 psa_status_t libpsats_init_ps_context(const char *service_name);
89 void libpsats_deinit_ps_context(void);
Gabor Toth841b0b62023-05-22 10:28:29 +020090
91The example below initializes and then deinitializes crypto::
92
Gabor Tothee2e7cb2024-10-07 17:02:56 +020093 psa_status_t psa_status = libpsats_init_crypto_context("sn:trustedfirmware.org:crypto:0");
Gabor Toth841b0b62023-05-22 10:28:29 +020094 if (psa_status) {
Gabor Tothee2e7cb2024-10-07 17:02:56 +020095 printf("libpsats_init_crypto_context failed: %d\n", psa_status);
Gabor Toth841b0b62023-05-22 10:28:29 +020096 return PSA_ERROR_GENERIC_ERROR;
97 }
98
Gabor Tothee2e7cb2024-10-07 17:02:56 +020099 libpsats_deinit_crypto_context();
Gabor Toth841b0b62023-05-22 10:28:29 +0200100
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