blob: 9127a33df83436be2677fdc4112013f2b27d8b28 [file] [log] [blame]
Xinyu Zhangd755b822022-10-25 11:18:09 +08001/*
2 * Copyright (c) 2022, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __CONFIG_TEST_PSA_API_H__
9#define __CONFIG_TEST_PSA_API_H__
10
11/* Platform Partition Configs */
12
13/* Size of input buffer in platform service */
Andrej Butokab8f52d2023-06-06 15:51:41 +020014#ifndef PLATFORM_SERVICE_INPUT_BUFFER_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +080015#define PLATFORM_SERVICE_INPUT_BUFFER_SIZE 64
Andrej Butokab8f52d2023-06-06 15:51:41 +020016#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080017
18/* Size of output buffer in platform service */
Andrej Butokab8f52d2023-06-06 15:51:41 +020019#ifndef PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +080020#define PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE 64
Andrej Butokab8f52d2023-06-06 15:51:41 +020021#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080022
23/* The stack size of the Platform Secure Partition */
Andrej Butokab8f52d2023-06-06 15:51:41 +020024#ifndef PLATFORM_SP_STACK_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +080025#define PLATFORM_SP_STACK_SIZE 0x500
Andrej Butokab8f52d2023-06-06 15:51:41 +020026#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080027
28/* Disable Non-volatile counter module */
Andrej Butokab8f52d2023-06-06 15:51:41 +020029#ifndef PLATFORM_NV_COUNTER_MODULE_DISABLED
Xinyu Zhangd755b822022-10-25 11:18:09 +080030#define PLATFORM_NV_COUNTER_MODULE_DISABLED 0
Andrej Butokab8f52d2023-06-06 15:51:41 +020031#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080032
33/* Crypto Partition Configs */
34
35/*
36 * Heap size for the crypto backend
37 * CRYPTO_ENGINE_BUF_SIZE needs to be much larger for PSA API tests.
38 */
Andrej Butokab8f52d2023-06-06 15:51:41 +020039#ifndef CRYPTO_ENGINE_BUF_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +080040#define CRYPTO_ENGINE_BUF_SIZE 0x5000
Andrej Butokab8f52d2023-06-06 15:51:41 +020041#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 */
Andrej Butokab8f52d2023-06-06 15:51:41 +020044#ifndef CRYPTO_CONC_OPER_NUM
Xinyu Zhangd755b822022-10-25 11:18:09 +080045#define CRYPTO_CONC_OPER_NUM 8
Andrej Butokab8f52d2023-06-06 15:51:41 +020046#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080047
Jianliang Shen78ca8d42022-11-16 17:33:18 +080048/* Enable PSA Crypto random number generator module */
Andrej Butokab8f52d2023-06-06 15:51:41 +020049#ifndef CRYPTO_RNG_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080050#define CRYPTO_RNG_MODULE_ENABLED 1
Andrej Butokab8f52d2023-06-06 15:51:41 +020051#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080052
Jianliang Shen78ca8d42022-11-16 17:33:18 +080053/* Enable PSA Crypto Key module */
Andrej Butokab8f52d2023-06-06 15:51:41 +020054#ifndef CRYPTO_KEY_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080055#define CRYPTO_KEY_MODULE_ENABLED 1
Andrej Butokab8f52d2023-06-06 15:51:41 +020056#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080057
Jianliang Shen78ca8d42022-11-16 17:33:18 +080058/* Enable PSA Crypto AEAD module */
Andrej Butokab8f52d2023-06-06 15:51:41 +020059#ifndef CRYPTO_AEAD_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080060#define CRYPTO_AEAD_MODULE_ENABLED 1
Andrej Butokab8f52d2023-06-06 15:51:41 +020061#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080062
Jianliang Shen78ca8d42022-11-16 17:33:18 +080063/* Enable PSA Crypto MAC module */
Andrej Butokab8f52d2023-06-06 15:51:41 +020064#ifndef CRYPTO_MAC_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080065#define CRYPTO_MAC_MODULE_ENABLED 1
Andrej Butokab8f52d2023-06-06 15:51:41 +020066#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080067
Jianliang Shen78ca8d42022-11-16 17:33:18 +080068/* Enable PSA Crypto Hash module */
Andrej Butokab8f52d2023-06-06 15:51:41 +020069#ifndef CRYPTO_HASH_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080070#define CRYPTO_HASH_MODULE_ENABLED 1
Andrej Butokab8f52d2023-06-06 15:51:41 +020071#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080072
Jianliang Shen78ca8d42022-11-16 17:33:18 +080073/* Enable PSA Crypto Cipher module */
Andrej Butokab8f52d2023-06-06 15:51:41 +020074#ifndef CRYPTO_CIPHER_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080075#define CRYPTO_CIPHER_MODULE_ENABLED 1
Andrej Butokab8f52d2023-06-06 15:51:41 +020076#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080077
Jianliang Shen78ca8d42022-11-16 17:33:18 +080078/* Enable PSA Crypto asymmetric key signature module */
Andrej Butokab8f52d2023-06-06 15:51:41 +020079#ifndef CRYPTO_ASYM_SIGN_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080080#define CRYPTO_ASYM_SIGN_MODULE_ENABLED 1
Andrej Butokab8f52d2023-06-06 15:51:41 +020081#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080082
Jianliang Shen78ca8d42022-11-16 17:33:18 +080083/* Enable PSA Crypto asymmetric key encryption module */
Andrej Butokab8f52d2023-06-06 15:51:41 +020084#ifndef CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080085#define CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED 1
Andrej Butokab8f52d2023-06-06 15:51:41 +020086#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080087
Jianliang Shen78ca8d42022-11-16 17:33:18 +080088/* Enable PSA Crypto key derivation module */
Andrej Butokab8f52d2023-06-06 15:51:41 +020089#ifndef CRYPTO_KEY_DERIVATION_MODULE_ENABLED
Jianliang Shen78ca8d42022-11-16 17:33:18 +080090#define CRYPTO_KEY_DERIVATION_MODULE_ENABLED 1
Andrej Butokab8f52d2023-06-06 15:51:41 +020091#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080092
93/* Default size of the internal scratch buffer used for PSA FF IOVec allocations */
Andrej Butokab8f52d2023-06-06 15:51:41 +020094#ifndef CRYPTO_IOVEC_BUFFER_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +080095#define CRYPTO_IOVEC_BUFFER_SIZE 5120
Andrej Butokab8f52d2023-06-06 15:51:41 +020096#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +080097
98/* Use stored NV seed to provide entropy */
Andrej Butokab8f52d2023-06-06 15:51:41 +020099#ifndef CRYPTO_NV_SEED
Xinyu Zhangd755b822022-10-25 11:18:09 +0800100#define CRYPTO_NV_SEED 1
Andrej Butokab8f52d2023-06-06 15:51:41 +0200101#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 */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200107#ifndef CRYPTO_SINGLE_PART_FUNCS_DISABLED
Xinyu Zhangd755b822022-10-25 11:18:09 +0800108#define CRYPTO_SINGLE_PART_FUNCS_DISABLED 0
Andrej Butokab8f52d2023-06-06 15:51:41 +0200109#endif
Xinyu Zhangd755b822022-10-25 11:18:09 +0800110
111/* The stack size of the Crypto Secure Partition */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200112#ifndef CRYPTO_STACK_SIZE
Xinyu Zhangd755b822022-10-25 11:18:09 +0800113#define CRYPTO_STACK_SIZE 0x1B00
Andrej Butokab8f52d2023-06-06 15:51:41 +0200114#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 */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200119#ifndef TFM_FWU_BUF_SIZE
Xinyu Zhangff653722022-10-27 14:17:36 +0800120#define TFM_FWU_BUF_SIZE PSA_FWU_MAX_WRITE_SIZE
Andrej Butokab8f52d2023-06-06 15:51:41 +0200121#endif
Xinyu Zhangff653722022-10-27 14:17:36 +0800122
123/* The stack size of the Firmware Update Secure Partition */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200124#ifndef FWU_STACK_SIZE
Xinyu Zhangff653722022-10-27 14:17:36 +0800125#define FWU_STACK_SIZE 0x600
Andrej Butokab8f52d2023-06-06 15:51:41 +0200126#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 */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200131#ifndef ATTEST_INCLUDE_OPTIONAL_CLAIMS
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800132#define ATTEST_INCLUDE_OPTIONAL_CLAIMS 1
Andrej Butokab8f52d2023-06-06 15:51:41 +0200133#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800134
135/* Include COSE key-id in initial attestation token */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200136#ifndef ATTEST_INCLUDE_COSE_KEY_ID
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800137#define ATTEST_INCLUDE_COSE_KEY_ID 0
Andrej Butokab8f52d2023-06-06 15:51:41 +0200138#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800139
140/* The stack size of the Initial Attestation Secure Partition */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200141#ifndef ATTEST_STACK_SIZE
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800142#define ATTEST_STACK_SIZE 0x700
Andrej Butokab8f52d2023-06-06 15:51:41 +0200143#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800144
145/* Set the initial attestation token profile */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200146#ifndef ATTEST_TOKEN_PROFILE_PSA_IOT_1
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800147#define ATTEST_TOKEN_PROFILE_PSA_IOT_1 1
Andrej Butokab8f52d2023-06-06 15:51:41 +0200148#endif
Xinyu Zhangd15f99c2022-10-27 15:03:34 +0800149
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800150/* ITS Partition Configs */
151
152/* Create flash FS if it doesn't exist for Internal Trusted Storage partition */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200153#ifndef ITS_CREATE_FLASH_LAYOUT
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800154#define ITS_CREATE_FLASH_LAYOUT 1
Andrej Butokab8f52d2023-06-06 15:51:41 +0200155#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800156
157/* Enable emulated RAM FS for platforms that don't have flash for Internal Trusted Storage partition */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200158#ifndef ITS_RAM_FS
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800159#define ITS_RAM_FS 0
Andrej Butokab8f52d2023-06-06 15:51:41 +0200160#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800161
162/* Validate filesystem metadata every time it is read from flash */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200163#ifndef ITS_VALIDATE_METADATA_FROM_FLASH
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800164#define ITS_VALIDATE_METADATA_FROM_FLASH 1
Andrej Butokab8f52d2023-06-06 15:51:41 +0200165#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800166
167/* The maximum asset size to be stored in the Internal Trusted Storage */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200168#ifndef ITS_MAX_ASSET_SIZE
Kevin Pengf6721c72023-03-01 16:12:45 +0800169#ifdef PSA_API_TEST_CRYPTO
Xinyu Zhange7581b12022-11-23 14:19:02 +0800170/*
171 * When building for the PSA Crypto API tests, ensure the ITS max asset size is
172 * set to at least the size of the largest asset created by the tests.
173 */
174#define ITS_MAX_ASSET_SIZE 1229
175#else
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800176#define ITS_MAX_ASSET_SIZE 512
Xinyu Zhange7581b12022-11-23 14:19:02 +0800177#endif
Andrej Butokab8f52d2023-06-06 15:51:41 +0200178#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800179
180/*
181 * Size of the ITS internal data transfer buffer
182 * (Default to the max asset size so that all requests can be handled in one iteration.)
183 */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200184#ifndef ITS_BUF_SIZE
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800185#define ITS_BUF_SIZE ITS_MAX_ASSET_SIZE
Andrej Butokab8f52d2023-06-06 15:51:41 +0200186#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800187
188/* The maximum number of assets to be stored in the Internal Trusted Storage */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200189#ifndef ITS_NUM_ASSETS
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800190#define ITS_NUM_ASSETS 10
Andrej Butokab8f52d2023-06-06 15:51:41 +0200191#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800192
193/* The stack size of the Internal Trusted Storage Secure Partition */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200194#ifndef ITS_STACK_SIZE
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800195#define ITS_STACK_SIZE 0x720
Andrej Butokab8f52d2023-06-06 15:51:41 +0200196#endif
Xinyu Zhangc8fc2c02022-10-31 12:13:45 +0800197
Xinyu Zhang07152702022-10-31 12:35:49 +0800198/* PS Partition Configs */
199
200/* Create flash FS if it doesn't exist for Protected Storage partition */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200201#ifndef PS_CREATE_FLASH_LAYOUT
Xinyu Zhang07152702022-10-31 12:35:49 +0800202#define PS_CREATE_FLASH_LAYOUT 1
Andrej Butokab8f52d2023-06-06 15:51:41 +0200203#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800204
205/* Enable emulated RAM FS for platforms that don't have flash for Protected Storage partition */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200206#ifndef PS_RAM_FS
Xinyu Zhang07152702022-10-31 12:35:49 +0800207#define PS_RAM_FS 0
Andrej Butokab8f52d2023-06-06 15:51:41 +0200208#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800209
210/* Enable rollback protection for Protected Storage partition */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200211#ifndef PS_ROLLBACK_PROTECTION
Xinyu Zhang07152702022-10-31 12:35:49 +0800212#define PS_ROLLBACK_PROTECTION 1
Andrej Butokab8f52d2023-06-06 15:51:41 +0200213#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800214
215/* Validate filesystem metadata every time it is read from flash */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200216#ifndef PS_VALIDATE_METADATA_FROM_FLASH
Xinyu Zhang07152702022-10-31 12:35:49 +0800217#define PS_VALIDATE_METADATA_FROM_FLASH 1
Andrej Butokab8f52d2023-06-06 15:51:41 +0200218#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800219
220/* The maximum asset size to be stored in the Protected Storage */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200221#ifndef PS_MAX_ASSET_SIZE
Xinyu Zhang07152702022-10-31 12:35:49 +0800222#define PS_MAX_ASSET_SIZE 2048
Andrej Butokab8f52d2023-06-06 15:51:41 +0200223#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800224
225/* The maximum number of assets to be stored in the Protected Storage */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200226#ifndef PS_NUM_ASSETS
Xinyu Zhang07152702022-10-31 12:35:49 +0800227#define PS_NUM_ASSETS 10
Andrej Butokab8f52d2023-06-06 15:51:41 +0200228#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800229
230/* The stack size of the Protected Storage Secure Partition */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200231#ifndef PS_STACK_SIZE
Xinyu Zhang07152702022-10-31 12:35:49 +0800232#define PS_STACK_SIZE 0x700
Andrej Butokab8f52d2023-06-06 15:51:41 +0200233#endif
Xinyu Zhang07152702022-10-31 12:35:49 +0800234
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800235/* SPM Partition Configs */
236
237/* The maximal number of secure services that are connected or requested at the same time */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200238#ifndef CONFIG_TFM_CONN_HANDLE_MAX_NUM
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800239#define CONFIG_TFM_CONN_HANDLE_MAX_NUM 8
Andrej Butokab8f52d2023-06-06 15:51:41 +0200240#endif
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800241
Xinyu Zhang44dbfa62022-11-23 14:22:32 +0800242/* Set the doorbell APIs */
Andrej Butokab8f52d2023-06-06 15:51:41 +0200243#ifndef CONFIG_TFM_DOORBELL_API
Kevin Pengf6721c72023-03-01 16:12:45 +0800244#ifdef PSA_API_TEST_IPC
Xinyu Zhang44dbfa62022-11-23 14:22:32 +0800245/* IPC test suite uses IPC backend */
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800246#define CONFIG_TFM_DOORBELL_API 1
Xinyu Zhang44dbfa62022-11-23 14:22:32 +0800247#else
248#define CONFIG_TFM_DOORBELL_API 0
249#endif
Andrej Butokab8f52d2023-06-06 15:51:41 +0200250#endif
Xinyu Zhangcdbe3622022-10-31 14:34:25 +0800251
Xinyu Zhangd755b822022-10-25 11:18:09 +0800252#endif /* __CONFIG_TEST_PSA_API_H__ */