Julian Hall | 5e3626f | 2022-04-07 14:05:08 +0100 | [diff] [blame] | 1 | Libraries |
| 2 | ========= |
Julian Hall | 4287cec | 2022-04-08 09:00:48 +0100 | [diff] [blame] | 3 | Some deployments build common functionality into libraries that may be used by |
| 4 | other deployments or external applications. The following library deployments |
| 5 | are currently supported: |
Julian Hall | 5e3626f | 2022-04-07 14:05:08 +0100 | [diff] [blame] | 6 | |
Gyorgy Szing | 2a95ac9 | 2024-10-24 19:59:23 +0200 | [diff] [blame] | 7 | The libraries will have a build type-specific suffix added to the base name of |
| 8 | their 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 |
| 11 | which single ``Release<XXX>`` build type is to be supported in the system. |
| 12 | Package managers and mutually exclusive release packages can be used to add |
| 13 | further flexibility. |
| 14 | |
Gyorgy Szing | a6c95df | 2022-11-25 11:15:51 +0100 | [diff] [blame] | 15 | .. _libs-libts: |
| 16 | |
Julian Hall | 4287cec | 2022-04-08 09:00:48 +0100 | [diff] [blame] | 17 | libts |
| 18 | ----- |
Gyorgy Szing | 2a95ac9 | 2024-10-24 19:59:23 +0200 | [diff] [blame] | 19 | |
Julian Hall | 4287cec | 2022-04-08 09:00:48 +0100 | [diff] [blame] | 20 | Userspace applications that depend on trusted services may use *libts* for handling |
| 21 | service discovery and RPC messaging. A major benefit to application developers is |
| 22 | that *libts* entirely decouples client applications from details of where a service |
| 23 | provider is deployed and how to communicate with it. All TS test executables and |
| 24 | tools that interact with service providers use *libts*. |
| 25 | |
| 26 | To facilitate test and development within a native PC environment, the *libts* |
| 27 | deployment for the *linux-pc* environment integrates a set of service providers |
| 28 | into the library itself. From a client application's perspective, this looks |
| 29 | exactly the same as when running on a target platform with service providers |
| 30 | deployed 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 Szing | 2a95ac9 | 2024-10-24 19:59:23 +0200 | [diff] [blame] | 41 | - * Userspace applications. |
| 42 | |
Julian Hall | 4287cec | 2022-04-08 09:00:48 +0100 | [diff] [blame] | 43 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 44 | .. _libs-libpsats: |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 45 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 46 | libpsats |
Gyorgy Szing | 1ea699a | 2024-10-24 17:17:36 +0200 | [diff] [blame] | 47 | -------- |
Gyorgy Szing | 2a95ac9 | 2024-10-24 19:59:23 +0200 | [diff] [blame] | 48 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 49 | Trusted Services implements the `PSA Certified APIs`_. Libpsats encapsulates the service client implementations |
| 50 | which implement this API. Linux uuser-space applications can use libpsats to easily access the PSA services |
| 51 | implemented by the project. Libpsats depends on libts for RPC and service discovery services. |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 52 | |
| 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 | |
| 65 | Build and integration examples |
| 66 | .............................. |
| 67 | |
| 68 | Build as shared library:: |
| 69 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 70 | cmake -S ./trusted-services/deployments/libpsats/linux-pc/ -B ./build |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 71 | make -C build && make -C build install |
| 72 | |
| 73 | .. warning:: |
| 74 | Building as static library is not yet supported. |
| 75 | |
| 76 | To integrate the library libts shall also be integrated. To achieve this add the listed |
| 77 | lines to the application's cmake files:: |
| 78 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 79 | find_package(libpsats "1.0.0" REQUIRED PATHS "<install path>") |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 80 | find_package(libts "2.0.0" REQUIRED PATHS "<install path>") |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 81 | target_link_libraries(ts-demo PRIVATE libpsats::psats) |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 82 | |
| 83 | Initialization |
| 84 | .............. |
| 85 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 86 | Before calling any function from libpsats the proper part of the library has to be initialized. |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 87 | Before exiting the application (or when PSA services are no longer needed) the initialized |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 88 | parts must be deinitialized. To access the library **libpsats.h** must be included:: |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 89 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 90 | psa_status_t libpsats_init_crypto_context(const char *service_name); |
| 91 | void libpsats_deinit_crypto_context(void); |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 92 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 93 | psa_status_t libpsats_init_attestation_context(const char *service_name); |
| 94 | void libpsats_deinit_attestation_context(void); |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 95 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 96 | psa_status_t libpsats_init_its_context(const char *service_name); |
| 97 | void libpsats_deinit_its_context(void); |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 98 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 99 | psa_status_t libpsats_init_ps_context(const char *service_name); |
| 100 | void libpsats_deinit_ps_context(void); |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 101 | |
| 102 | The example below initializes and then deinitializes crypto:: |
| 103 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 104 | psa_status_t psa_status = libpsats_init_crypto_context("sn:trustedfirmware.org:crypto:0"); |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 105 | if (psa_status) { |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 106 | printf("libpsats_init_crypto_context failed: %d\n", psa_status); |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 107 | return PSA_ERROR_GENERIC_ERROR; |
| 108 | } |
| 109 | |
Gabor Toth | ee2e7cb | 2024-10-07 17:02:56 +0200 | [diff] [blame] | 110 | libpsats_deinit_crypto_context(); |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 111 | |
| 112 | Known 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 Szing | a6c95df | 2022-11-25 11:15:51 +0100 | [diff] [blame] | 119 | .. _libs-libsp: |
| 120 | |
Julian Hall | 4287cec | 2022-04-08 09:00:48 +0100 | [diff] [blame] | 121 | libsp |
| 122 | ----- |
Gyorgy Szing | 2a95ac9 | 2024-10-24 19:59:23 +0200 | [diff] [blame] | 123 | |
Julian Hall | 4287cec | 2022-04-08 09:00:48 +0100 | [diff] [blame] | 124 | *libsp* provides a functional interface for using FF-A messaging and memory |
| 125 | management 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 Hall | 5e3626f | 2022-04-07 14:05:08 +0100 | [diff] [blame] | 136 | |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 137 | Known 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 Hall | 5e3626f | 2022-04-07 14:05:08 +0100 | [diff] [blame] | 144 | -------------- |
| 145 | |
Gabor Toth | 841b0b6 | 2023-05-22 10:28:29 +0200 | [diff] [blame] | 146 | .. _`PSA Certified APIs`: https://arm-software.github.io/psa-api/ |
| 147 | |
| 148 | *Copyright (c) 2022-2023, Arm Limited and Contributors. All rights reserved.* |
Julian Hall | 5e3626f | 2022-04-07 14:05:08 +0100 | [diff] [blame] | 149 | |
| 150 | SPDX-License-Identifier: BSD-3-Clause |