blob: 8a0e2760dcf2dc91971635b2905b7abbc646cb76 [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 Szing2a95ac92024-10-24 19:59:23 +02007The libraries will have a build type-specific suffix added to the base name of
8their binaries, allowing multiple binaries to be installed in the same tree.
9(See :ref:`Selecting the build type`) This differentiation applies to the
10``Debug`` and ``DebugCoverage`` build types. The system integrator must choose
11which single ``Release<XXX>`` build type is to be supported in the system.
12Package managers and mutually exclusive release packages can be used to add
13further flexibility.
14
Gyorgy Szinga6c95df2022-11-25 11:15:51 +010015.. _libs-libts:
16
Julian Hall4287cec2022-04-08 09:00:48 +010017libts
18-----
Gyorgy Szing2a95ac92024-10-24 19:59:23 +020019
Julian Hall4287cec2022-04-08 09:00:48 +010020Userspace applications that depend on trusted services may use *libts* for handling
21service discovery and RPC messaging. A major benefit to application developers is
22that *libts* entirely decouples client applications from details of where a service
23provider is deployed and how to communicate with it. All TS test executables and
24tools that interact with service providers use *libts*.
25
26To facilitate test and development within a native PC environment, the *libts*
27deployment for the *linux-pc* environment integrates a set of service providers
28into the library itself. From a client application's perspective, this looks
29exactly the same as when running on a target platform with service providers
30deployed in secure processing environments. For more information, see:
31:ref:`Service Locator`.
32
33.. list-table::
34 :widths: 1 2
35 :header-rows: 0
36
37 * - Supported Environments
38 - * | *linux-pc* - service providers integrated into library
39 * | *arm-linux* - communicates with service providers in secure processing environment
40 * - Used by
Gyorgy Szing2a95ac92024-10-24 19:59:23 +020041 - * Userspace applications.
42
Julian Hall4287cec2022-04-08 09:00:48 +010043
Gabor Tothee2e7cb2024-10-07 17:02:56 +020044.. _libs-libpsats:
Gabor Toth841b0b62023-05-22 10:28:29 +020045
Gabor Tothee2e7cb2024-10-07 17:02:56 +020046libpsats
Gyorgy Szing1ea699a2024-10-24 17:17:36 +020047--------
Gyorgy Szing2a95ac92024-10-24 19:59:23 +020048
Gabor Tothee2e7cb2024-10-07 17:02:56 +020049Trusted Services implements the `PSA Certified APIs`_. Libpsats encapsulates the service client implementations
50which implement this API. Linux uuser-space applications can use libpsats to easily access the PSA services
51implemented by the project. Libpsats depends on libts for RPC and service discovery services.
Gabor Toth841b0b62023-05-22 10:28:29 +020052
53.. list-table::
54 :widths: 1 2
55 :header-rows: 0
56
57 * - Supported Environments
58 - * | *linux-pc*
59 * | *arm-linux*
60 * - Used by
61 - * Userspace applications
62 * - Depends on
63 - * `libts`_ library
64
65Build and integration examples
66..............................
67
68Build as shared library::
69
Gabor Tothee2e7cb2024-10-07 17:02:56 +020070 cmake -S ./trusted-services/deployments/libpsats/linux-pc/ -B ./build
Gabor Toth841b0b62023-05-22 10:28:29 +020071 make -C build && make -C build install
72
73.. warning::
74 Building as static library is not yet supported.
75
76To integrate the library libts shall also be integrated. To achieve this add the listed
77lines to the application's cmake files::
78
Gabor Tothee2e7cb2024-10-07 17:02:56 +020079 find_package(libpsats "1.0.0" REQUIRED PATHS "<install path>")
Gabor Toth841b0b62023-05-22 10:28:29 +020080 find_package(libts "2.0.0" REQUIRED PATHS "<install path>")
Gabor Tothee2e7cb2024-10-07 17:02:56 +020081 target_link_libraries(ts-demo PRIVATE libpsats::psats)
Gabor Toth841b0b62023-05-22 10:28:29 +020082
83Initialization
84..............
85
Gabor Tothee2e7cb2024-10-07 17:02:56 +020086Before calling any function from libpsats the proper part of the library has to be initialized.
Gabor Toth841b0b62023-05-22 10:28:29 +020087Before exiting the application (or when PSA services are no longer needed) the initialized
Gabor Tothee2e7cb2024-10-07 17:02:56 +020088parts must be deinitialized. To access the library **libpsats.h** must be included::
Gabor Toth841b0b62023-05-22 10:28:29 +020089
Gabor Tothee2e7cb2024-10-07 17:02:56 +020090 psa_status_t libpsats_init_crypto_context(const char *service_name);
91 void libpsats_deinit_crypto_context(void);
Gabor Toth841b0b62023-05-22 10:28:29 +020092
Gabor Tothee2e7cb2024-10-07 17:02:56 +020093 psa_status_t libpsats_init_attestation_context(const char *service_name);
94 void libpsats_deinit_attestation_context(void);
Gabor Toth841b0b62023-05-22 10:28:29 +020095
Gabor Tothee2e7cb2024-10-07 17:02:56 +020096 psa_status_t libpsats_init_its_context(const char *service_name);
97 void libpsats_deinit_its_context(void);
Gabor Toth841b0b62023-05-22 10:28:29 +020098
Gabor Tothee2e7cb2024-10-07 17:02:56 +020099 psa_status_t libpsats_init_ps_context(const char *service_name);
100 void libpsats_deinit_ps_context(void);
Gabor Toth841b0b62023-05-22 10:28:29 +0200101
102The example below initializes and then deinitializes crypto::
103
Gabor Tothee2e7cb2024-10-07 17:02:56 +0200104 psa_status_t psa_status = libpsats_init_crypto_context("sn:trustedfirmware.org:crypto:0");
Gabor Toth841b0b62023-05-22 10:28:29 +0200105 if (psa_status) {
Gabor Tothee2e7cb2024-10-07 17:02:56 +0200106 printf("libpsats_init_crypto_context failed: %d\n", psa_status);
Gabor Toth841b0b62023-05-22 10:28:29 +0200107 return PSA_ERROR_GENERIC_ERROR;
108 }
109
Gabor Tothee2e7cb2024-10-07 17:02:56 +0200110 libpsats_deinit_crypto_context();
Gabor Toth841b0b62023-05-22 10:28:29 +0200111
112Known issues and Limitations
113............................
114
115| The library is single client.
116| The library is not thread safe.
117| Only linux user-space is supported currently.
118
Gyorgy Szinga6c95df2022-11-25 11:15:51 +0100119.. _libs-libsp:
120
Julian Hall4287cec2022-04-08 09:00:48 +0100121libsp
122-----
Gyorgy Szing2a95ac92024-10-24 19:59:23 +0200123
Julian Hall4287cec2022-04-08 09:00:48 +0100124*libsp* provides a functional interface for using FF-A messaging and memory
125management facilities. *libsp* is used in SP deployments. For more information, see:
126:ref:`libsp`.
127
128.. list-table::
129 :widths: 1 2
130 :header-rows: 0
131
132 * - Supported Environments
133 - * | *opteesp*
134 * - Used by
135 - * Secure partitions
Julian Hall5e3626f2022-04-07 14:05:08 +0100136
Gabor Toth841b0b62023-05-22 10:28:29 +0200137Known issues and Limitations
138............................
139
140| The library is single client.
141| The library is not thread safe.
142| Only linux user-space is supported currently.
143
Julian Hall5e3626f2022-04-07 14:05:08 +0100144--------------
145
Gabor Toth841b0b62023-05-22 10:28:29 +0200146.. _`PSA Certified APIs`: https://arm-software.github.io/psa-api/
147
148*Copyright (c) 2022-2023, Arm Limited and Contributors. All rights reserved.*
Julian Hall5e3626f2022-04-07 14:05:08 +0100149
150SPDX-License-Identifier: BSD-3-Clause