Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: BSD-3-Clause |
| 3 | # SPDX-FileCopyrightText: Copyright TF-RMM Contributors. |
| 4 | # |
| 5 | |
Mate Toth-Pal | 83a45bd | 2023-09-01 11:17:19 +0200 | [diff] [blame] | 6 | # The t_cose library is not included in the CBMC analysis |
| 7 | if(RMM_CBMC_STATIC_ANALYSIS) |
| 8 | add_library(t_cose INTERFACE) |
| 9 | return() |
| 10 | endif() |
| 11 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 12 | add_library(t_cose) |
| 13 | |
| 14 | set(T_COSE_SOURCE_DIR "${RMM_SOURCE_DIR}/ext/t_cose") |
| 15 | |
Tamas Ban | fac904c | 2024-09-11 16:02:30 +0200 | [diff] [blame] | 16 | # Patch t_cose |
| 17 | set(T_COSE_PATCH_DIR "${RMM_SOURCE_DIR}/configs/t_cose") |
| 18 | set(T_COSE_PATCH_FILES |
Soby Mathew | e307b0a | 2024-10-03 12:12:52 +0100 | [diff] [blame^] | 19 | "${T_COSE_PATCH_DIR}/0001-Add-t_cose_key_encode-API.patch" |
| 20 | "${T_COSE_PATCH_DIR}/0001-Add-compile-time-option-for-el3-signing.patch") |
Tamas Ban | fac904c | 2024-09-11 16:02:30 +0200 | [diff] [blame] | 21 | |
| 22 | Git_Apply_Patches(${T_COSE_SOURCE_DIR} "${T_COSE_PATCH_FILES}") |
| 23 | |
Mate Toth-Pal | fda673a | 2023-06-13 12:25:43 +0200 | [diff] [blame] | 24 | #TODO: Eliminate warning suppression once the t_cose submodule is updated to |
| 25 | # a released version. |
| 26 | target_compile_options(t_cose |
| 27 | PRIVATE |
| 28 | "-Wno-maybe-uninitialized" |
| 29 | "-Wno-cpp" |
| 30 | "-Wno-unused-variable") |
| 31 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 32 | target_compile_definitions(t_cose |
Soby Mathew | e307b0a | 2024-10-03 12:12:52 +0100 | [diff] [blame^] | 33 | PUBLIC |
| 34 | "ATTEST_EL3_TOKEN_SIGN=$<IF:$<BOOL:${ATTEST_EL3_TOKEN_SIGN}>,1,0>" |
Mate Toth-Pal | c69951d | 2023-03-17 17:30:50 +0100 | [diff] [blame] | 35 | PRIVATE |
| 36 | "T_COSE_USE_PSA_CRYPTO=1" |
| 37 | "T_COSE_DISABLE_HPKE=1" |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 38 | ) |
| 39 | |
| 40 | target_link_libraries(t_cose |
| 41 | PRIVATE |
| 42 | rmm-lib-common |
| 43 | rmm-lib-libc |
| 44 | ) |
| 45 | |
| 46 | target_link_libraries(t_cose |
| 47 | PUBLIC |
Soby Mathew | 73dad84 | 2022-12-16 12:51:01 +0000 | [diff] [blame] | 48 | rmm-mbedtls |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 49 | qcbor |
| 50 | ) |
| 51 | |
| 52 | target_include_directories(t_cose |
| 53 | PUBLIC |
Soby Mathew | e307b0a | 2024-10-03 12:12:52 +0100 | [diff] [blame^] | 54 | "include" |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 55 | "${T_COSE_SOURCE_DIR}/inc" |
Mate Toth-Pal | c69951d | 2023-03-17 17:30:50 +0100 | [diff] [blame] | 56 | "${T_COSE_SOURCE_DIR}/crypto_adapters" |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 57 | PRIVATE |
| 58 | "${T_COSE_SOURCE_DIR}/src" |
| 59 | ) |
| 60 | |
| 61 | target_sources(t_cose |
| 62 | PRIVATE |
Soby Mathew | 4d4c21a | 2023-06-29 14:52:41 +0200 | [diff] [blame] | 63 | "${T_COSE_SOURCE_DIR}/crypto_adapters/t_cose_psa_crypto.c" |
Mate Toth-Pal | fda673a | 2023-06-13 12:25:43 +0200 | [diff] [blame] | 64 | "${T_COSE_SOURCE_DIR}/src/t_cose_parameters.c" |
| 65 | "${T_COSE_SOURCE_DIR}/src/t_cose_sign_sign.c" |
| 66 | "${T_COSE_SOURCE_DIR}/src/t_cose_signature_sign_restart.c" |
| 67 | "${T_COSE_SOURCE_DIR}/src/t_cose_util.c" |
Tamas Ban | fac904c | 2024-09-11 16:02:30 +0200 | [diff] [blame] | 68 | "${T_COSE_SOURCE_DIR}/src/t_cose_key.c" |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 69 | ) |
Soby Mathew | e307b0a | 2024-10-03 12:12:52 +0100 | [diff] [blame^] | 70 | |
| 71 | if (ATTEST_EL3_TOKEN_SIGN) |
| 72 | target_compile_definitions(t_cose |
| 73 | PRIVATE |
| 74 | "T_COSE_DISABLE_COSE_SIGN=1") |
| 75 | |
| 76 | target_sources(t_cose |
| 77 | PRIVATE |
| 78 | "src/t_cose_el3_token_sign.c") |
| 79 | |
| 80 | target_link_libraries(t_cose |
| 81 | PRIVATE |
| 82 | rmm-lib-arch |
| 83 | rmm-lib-debug) |
| 84 | endif() |