blob: 8f572dbcee8614e64ae5e8d0afe632f2a71c5356 [file] [log] [blame]
Xinyu Zhanga2fab0e2022-10-24 15:37:46 +08001/*
2 * Copyright (c) 2022, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __CONFIG_BASE_H__
9#define __CONFIG_BASE_H__
10
Xinyu Zhang77668dd2022-10-24 16:17:37 +080011/* Platform Partition Configs */
12
13/* Size of input buffer in platform service */
David Hu6d1a9b62023-02-22 16:54:04 +080014#ifndef PLATFORM_SERVICE_INPUT_BUFFER_SIZE
Xinyu Zhang77668dd2022-10-24 16:17:37 +080015#define PLATFORM_SERVICE_INPUT_BUFFER_SIZE 64
David Hu6d1a9b62023-02-22 16:54:04 +080016#endif
Xinyu Zhang77668dd2022-10-24 16:17:37 +080017
18/* Size of output buffer in platform service */
David Hu6d1a9b62023-02-22 16:54:04 +080019#ifndef PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE
Xinyu Zhang77668dd2022-10-24 16:17:37 +080020#define PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE 64
David Hu6d1a9b62023-02-22 16:54:04 +080021#endif
Xinyu Zhang77668dd2022-10-24 16:17:37 +080022
23/* The stack size of the Platform Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +080024#ifndef PLATFORM_SP_STACK_SIZE
Xinyu Zhang77668dd2022-10-24 16:17:37 +080025#define PLATFORM_SP_STACK_SIZE 0x500
David Hu6d1a9b62023-02-22 16:54:04 +080026#endif
Xinyu Zhang77668dd2022-10-24 16:17:37 +080027
28/* Disable Non-volatile counter module */
David Hu6d1a9b62023-02-22 16:54:04 +080029#ifndef PLATFORM_NV_COUNTER_MODULE_DISABLED
Xinyu Zhang77668dd2022-10-24 16:17:37 +080030#define PLATFORM_NV_COUNTER_MODULE_DISABLED 0
David Hu6d1a9b62023-02-22 16:54:04 +080031#endif
Xinyu Zhang77668dd2022-10-24 16:17:37 +080032
Xinyu Zhangd755b822022-10-25 11:18:09 +080033/* Crypto Partition Configs */
34
35/*
36 * Heap size for the crypto backend
37 * CRYPTO_ENGINE_BUF_SIZE needs to be >8KB for EC signing by attest module.
38 */
David Hu6d1a9b62023-02-22 16:54:04 +080039#ifndef CRYPTO_ENGINE_BUF_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +080040#define CRYPTO_ENGINE_BUF_SIZE 0x2080
David Hu6d1a9b62023-02-22 16:54:04 +080041#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080042
43/* The max number of concurrent operations that can be active (allocated) at any time in Crypto */
David Hu6d1a9b62023-02-22 16:54:04 +080044#ifndef CRYPTO_CONC_OPER_NUM
Xinyu Zhangd755b822022-10-25 11:18:09 +080045#define CRYPTO_CONC_OPER_NUM 8
David Hu6d1a9b62023-02-22 16:54:04 +080046#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080047
Jianliang Shen78ca8d42022-11-16 17:33:18 +080048/* Enable PSA Crypto random number generator module */
David Hu6d1a9b62023-02-22 16:54:04 +080049#ifndef CRYPTO_RNG_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080050#define CRYPTO_RNG_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080051#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080052
Jianliang Shen78ca8d42022-11-16 17:33:18 +080053/* Enable PSA Crypto Key module */
David Hu6d1a9b62023-02-22 16:54:04 +080054#ifndef CRYPTO_KEY_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080055#define CRYPTO_KEY_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080056#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080057
Jianliang Shen78ca8d42022-11-16 17:33:18 +080058/* Enable PSA Crypto AEAD module */
David Hu6d1a9b62023-02-22 16:54:04 +080059#ifndef CRYPTO_AEAD_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080060#define CRYPTO_AEAD_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080061#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080062
Jianliang Shen78ca8d42022-11-16 17:33:18 +080063/* Enable PSA Crypto MAC module */
David Hu6d1a9b62023-02-22 16:54:04 +080064#ifndef CRYPTO_MAC_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080065#define CRYPTO_MAC_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080066#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080067
Jianliang Shen78ca8d42022-11-16 17:33:18 +080068/* Enable PSA Crypto Hash module */
David Hu6d1a9b62023-02-22 16:54:04 +080069#ifndef CRYPTO_HASH_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080070#define CRYPTO_HASH_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080071#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080072
Jianliang Shen78ca8d42022-11-16 17:33:18 +080073/* Enable PSA Crypto Cipher module */
David Hu6d1a9b62023-02-22 16:54:04 +080074#ifndef CRYPTO_CIPHER_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080075#define CRYPTO_CIPHER_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080076#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080077
Jianliang Shen78ca8d42022-11-16 17:33:18 +080078/* Enable PSA Crypto asymmetric key signature module */
David Hu6d1a9b62023-02-22 16:54:04 +080079#ifndef CRYPTO_ASYM_SIGN_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080080#define CRYPTO_ASYM_SIGN_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080081#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080082
Jianliang Shen78ca8d42022-11-16 17:33:18 +080083/* Enable PSA Crypto asymmetric key encryption module */
David Hu6d1a9b62023-02-22 16:54:04 +080084#ifndef CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080085#define CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080086#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080087
Jianliang Shen78ca8d42022-11-16 17:33:18 +080088/* Enable PSA Crypto key derivation module */
David Hu6d1a9b62023-02-22 16:54:04 +080089#ifndef CRYPTO_KEY_DERIVATION_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080090#define CRYPTO_KEY_DERIVATION_MODULE_ENABLED 1
David Hu6d1a9b62023-02-22 16:54:04 +080091#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080092
93/* Default size of the internal scratch buffer used for PSA FF IOVec allocations */
David Hu6d1a9b62023-02-22 16:54:04 +080094#ifndef CRYPTO_IOVEC_BUFFER_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +080095#define CRYPTO_IOVEC_BUFFER_SIZE 5120
David Hu6d1a9b62023-02-22 16:54:04 +080096#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080097
98/* Use stored NV seed to provide entropy */
David Hu6d1a9b62023-02-22 16:54:04 +080099#ifndef CRYPTO_NV_SEED
Xinyu Zhangd755b822022-10-25 11:18:09 +0800100#define CRYPTO_NV_SEED 1
David Hu6d1a9b62023-02-22 16:54:04 +0800101#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +0800102
103/*
104 * Only enable multi-part operations in Hash, MAC, AEAD and symmetric ciphers,
105 * to optimize memory footprint in resource-constrained devices.
106 */
David Hu6d1a9b62023-02-22 16:54:04 +0800107#ifndef CRYPTO_SINGLE_PART_FUNCS_DISABLED
Xinyu Zhangd755b822022-10-25 11:18:09 +0800108#define CRYPTO_SINGLE_PART_FUNCS_DISABLED 0
David Hu6d1a9b62023-02-22 16:54:04 +0800109#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +0800110
111/* The stack size of the Crypto Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800112#ifndef CRYPTO_STACK_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +0800113#define CRYPTO_STACK_SIZE 0x1B00
David Hu6d1a9b62023-02-22 16:54:04 +0800114#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +0800115
Xinyu Zhangff653722022-10-27 14:17:36 +0800116/* FWU Partition Configs */
117
118/* Size of the FWU internal data transfer buffer */
David Hu6d1a9b62023-02-22 16:54:04 +0800119#ifndef TFM_FWU_BUF_SIZE
Xinyu Zhangff653722022-10-27 14:17:36 +0800120#define TFM_FWU_BUF_SIZE PSA_FWU_MAX_WRITE_SIZE
David Hu6d1a9b62023-02-22 16:54:04 +0800121#endif
Xinyu Zhangff653722022-10-27 14:17:36 +0800122
123/* The stack size of the Firmware Update Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800124#ifndef FWU_STACK_SIZE
Xinyu Zhangff653722022-10-27 14:17:36 +0800125#define FWU_STACK_SIZE 0x600
David Hu6d1a9b62023-02-22 16:54:04 +0800126#endif
Xinyu Zhangff653722022-10-27 14:17:36 +0800127
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800128/* Attest Partition Configs */
129
130/* Include optional claims in initial attestation token */
David Hu6d1a9b62023-02-22 16:54:04 +0800131#ifndef ATTEST_INCLUDE_OPTIONAL_CLAIMS
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800132#define ATTEST_INCLUDE_OPTIONAL_CLAIMS 1
David Hu6d1a9b62023-02-22 16:54:04 +0800133#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800134
135/* Include COSE key-id in initial attestation token */
David Hu6d1a9b62023-02-22 16:54:04 +0800136#ifndef ATTEST_INCLUDE_COSE_KEY_ID
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800137#define ATTEST_INCLUDE_COSE_KEY_ID 0
David Hu6d1a9b62023-02-22 16:54:04 +0800138#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800139
140/* The stack size of the Initial Attestation Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800141#ifndef ATTEST_STACK_SIZE
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800142#define ATTEST_STACK_SIZE 0x700
David Hu6d1a9b62023-02-22 16:54:04 +0800143#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800144
145/* Set the initial attestation token profile */
David Hu6d1a9b62023-02-22 16:54:04 +0800146#if (!ATTEST_TOKEN_PROFILE_PSA_IOT_1) && \
147 (!ATTEST_TOKEN_PROFILE_PSA_2_0_0) && \
148 (!ATTEST_TOKEN_PROFILE_ARM_CCA)
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800149#define ATTEST_TOKEN_PROFILE_PSA_IOT_1 1
David Hu6d1a9b62023-02-22 16:54:04 +0800150#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800151
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800152/* ITS Partition Configs */
153
154/* Create flash FS if it doesn't exist for Internal Trusted Storage partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800155#ifndef ITS_CREATE_FLASH_LAYOUT
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800156#define ITS_CREATE_FLASH_LAYOUT 1
David Hu6d1a9b62023-02-22 16:54:04 +0800157#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800158
159/* Enable emulated RAM FS for platforms that don't have flash for Internal Trusted Storage partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800160#ifndef ITS_RAM_FS
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800161#define ITS_RAM_FS 0
David Hu6d1a9b62023-02-22 16:54:04 +0800162#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800163
164/* Validate filesystem metadata every time it is read from flash */
David Hu6d1a9b62023-02-22 16:54:04 +0800165#ifndef ITS_VALIDATE_METADATA_FROM_FLASH
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800166#define ITS_VALIDATE_METADATA_FROM_FLASH 1
David Hu6d1a9b62023-02-22 16:54:04 +0800167#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800168
169/* The maximum asset size to be stored in the Internal Trusted Storage */
David Hu6d1a9b62023-02-22 16:54:04 +0800170#ifndef ITS_MAX_ASSET_SIZE
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800171#define ITS_MAX_ASSET_SIZE 512
David Hu6d1a9b62023-02-22 16:54:04 +0800172#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800173
174/*
175 * Size of the ITS internal data transfer buffer
176 * (Default to the max asset size so that all requests can be handled in one iteration.)
177 */
David Hu6d1a9b62023-02-22 16:54:04 +0800178#ifndef ITS_BUF_SIZE
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800179#define ITS_BUF_SIZE ITS_MAX_ASSET_SIZE
David Hu6d1a9b62023-02-22 16:54:04 +0800180#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800181
182/* The maximum number of assets to be stored in the Internal Trusted Storage */
David Hu6d1a9b62023-02-22 16:54:04 +0800183#ifndef ITS_NUM_ASSETS
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800184#define ITS_NUM_ASSETS 10
David Hu6d1a9b62023-02-22 16:54:04 +0800185#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800186
187/* The stack size of the Internal Trusted Storage Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800188#ifndef ITS_STACK_SIZE
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800189#define ITS_STACK_SIZE 0x720
David Hu6d1a9b62023-02-22 16:54:04 +0800190#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800191
Xinyu Zhang07152702022-10-31 12:35:49 +0800192/* PS Partition Configs */
193
194/* Create flash FS if it doesn't exist for Protected Storage partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800195#ifndef PS_CREATE_FLASH_LAYOUT
Xinyu Zhang07152702022-10-31 12:35:49 +0800196#define PS_CREATE_FLASH_LAYOUT 1
David Hu6d1a9b62023-02-22 16:54:04 +0800197#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800198
199/* Enable emulated RAM FS for platforms that don't have flash for Protected Storage partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800200#ifndef PS_RAM_FS
Xinyu Zhang07152702022-10-31 12:35:49 +0800201#define PS_RAM_FS 0
David Hu6d1a9b62023-02-22 16:54:04 +0800202#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800203
204/* Enable rollback protection for Protected Storage partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800205#ifndef PS_ROLLBACK_PROTECTION
Xinyu Zhang07152702022-10-31 12:35:49 +0800206#define PS_ROLLBACK_PROTECTION 1
David Hu6d1a9b62023-02-22 16:54:04 +0800207#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800208
209/* Validate filesystem metadata every time it is read from flash */
David Hu6d1a9b62023-02-22 16:54:04 +0800210#ifndef PS_VALIDATE_METADATA_FROM_FLASH
Xinyu Zhang07152702022-10-31 12:35:49 +0800211#define PS_VALIDATE_METADATA_FROM_FLASH 1
David Hu6d1a9b62023-02-22 16:54:04 +0800212#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800213
214/* The maximum asset size to be stored in the Protected Storage */
David Hu6d1a9b62023-02-22 16:54:04 +0800215#ifndef PS_MAX_ASSET_SIZE
Xinyu Zhang07152702022-10-31 12:35:49 +0800216#define PS_MAX_ASSET_SIZE 2048
David Hu6d1a9b62023-02-22 16:54:04 +0800217#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800218
219/* The maximum number of assets to be stored in the Protected Storage */
David Hu6d1a9b62023-02-22 16:54:04 +0800220#ifndef PS_NUM_ASSETS
Xinyu Zhang07152702022-10-31 12:35:49 +0800221#define PS_NUM_ASSETS 10
David Hu6d1a9b62023-02-22 16:54:04 +0800222#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800223
224/* The stack size of the Protected Storage Secure Partition */
David Hu6d1a9b62023-02-22 16:54:04 +0800225#ifndef PS_STACK_SIZE
Xinyu Zhang07152702022-10-31 12:35:49 +0800226#define PS_STACK_SIZE 0x700
David Hu6d1a9b62023-02-22 16:54:04 +0800227#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800228
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800229/* SPM Partition Configs */
230
231/* The maximal number of secure services that are connected or requested at the same time */
David Hu6d1a9b62023-02-22 16:54:04 +0800232#ifndef CONFIG_TFM_CONN_HANDLE_MAX_NUM
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800233#define CONFIG_TFM_CONN_HANDLE_MAX_NUM 8
David Hu6d1a9b62023-02-22 16:54:04 +0800234#endif
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800235
Xinyu Zhang44dbfa62022-11-23 14:22:32 +0800236/* Disable the doorbell APIs */
David Hu6d1a9b62023-02-22 16:54:04 +0800237#ifndef CONFIG_TFM_DOORBELL_API
Xinyu Zhang44dbfa62022-11-23 14:22:32 +0800238#define CONFIG_TFM_DOORBELL_API 0
David Hu6d1a9b62023-02-22 16:54:04 +0800239#endif
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800240
Xinyu Zhanga2fab0e2022-10-24 15:37:46 +0800241#endif /* __CONFIG_BASE_H__ */