#ifndef PSA_CRYPTO_CONFIG_H
#define PSA_CRYPTO_CONFIG_H
// -----------------------------------------------------------------------------
// User exposed config options
// <<< Use Configuration Wizard in Context Menu >>>
// Key management configuration
// PSA User Maximum Open Keys Count <0-128>
// Maximum amount of keys that the user application will have open
// simultaneously. In context of PSA Crypto, an open key means any key
// either stored in RAM (lifetime set to PSA_KEY_LIFETIME_VOLATILE), or
// used as part of a cryptographic operation.
// When using a key for a multi-part (setup/update/finish) operation, a key
// is considered to be open from the moment the operation is successfully
// setup, until it finishes or aborts.
// When an application tries to open more keys than this value accounts for,
// the PSA API may return PSA_ERROR_INSUFFICIENT_MEMORY. Keep in mind that
// other software included in the application (e.g. wireless protocol stacks)
// also can have a need to have open keys in PSA Crypto. This could lead to
// a race condition when the application key slot count is set too low for
// the actual usage of the application, as a software stack may not fail
// gracefully in case an application opens more than its declared amount of
// keys, thereby precluding the stack from functioning.
// Default: 4
#define SL_PSA_KEY_USER_SLOT_COUNT (4)
// PSA Maximum User Persistent Keys Count <0-1024>
// Maximum amount of keys (or other files) that can be stored persistently
// by the application through the PSA interface, when persistent storage
// support for PSA Crypto is included in the project.
// Due to caching logic, this setting does have an impact on static RAM usage.
// Note that this number is added to the potential requirements from other
// software components in the project, such that the total amount of keys
// which can be stored through the ITS backend can be higher than what is
// configured here.
//
// WARNING: When changing this setting on an application that is already
// deployed, and thus will get the change through an application upgrade,
// care should be taken to ensure that the setting is only ever increased,
// and never decreased. Decreasing this setting might cause previously
// stored keys/files to become inaccessible.
//
// It is not possible to change this setting when using V3 ITS Driver.
// The file-storage indexing is dependent on the maximum number of files,
// and if SL_PSA_ITS_USER_MAX_FILES is changed, ITS should be cleared and
// all files need to be stored again.
// Default: 128
#define SL_PSA_ITS_USER_MAX_FILES (128)
// Enable V1 Format Support For ITS Files <0-1>
// Devices that used PSA ITS together with gecko_sdk_3.1.x or earlier
// might have keys (or other files) stored in V1 format.
// If no v1 files are used, its support can be disabled for space
// optimization.
// Default: 0
#define SL_PSA_ITS_SUPPORT_V1_DRIVER 0
// Enable V2 ITS Driver Support <0-1>
// Devices that have used GSDK 4.1.x and earlier, and used ITS have the keys
// (or other files) stored using different address range. Enabling this
// config option adds upgrade code which converts V2 (and V1 if
// supported) format ITS keys/files to the latest V3 format. Update is
// fully automatic, needs to be run once and require extra flash space of
// approximately the size of the largest key.
// V1 ITS driver support can be disabled if the device has never used ITS
// driver before in GSDK 4.1.x and earlier, or the keys has been already
// migrated.
// Default: 0
#define SL_PSA_ITS_SUPPORT_V2_DRIVER 0
// Enable support for V3 ITS Driver <0-1>
// Devices that have used GSDK 4.1.x and earlier, and used ITS have the keys
// (or other files) stored using different address range. In rare case
// that those devices have full nvm3 and not enough space for the
// upgrade, (that requires an extra space to store largest key in memory
// twice), this config option can disable v3 driver and use v2 one.
// To upgrade the device, make space for the upgrade, and enable v3 driver again.
//
// WARNING: When using V3 driver, it is not possible to increase or decrease
// the value of SL_PSA_ITS_USER_MAX_FILES. If the change of
// SL_PSA_ITS_USER_MAX_FILES is required, ITS should be cleared and
// all files need to be stored again.
// Default: 1
#define SL_PSA_ITS_SUPPORT_V3_DRIVER 1
// Built-in AES Key Mode of Operation
// CTR Mode
// CFB Mode
// OFB Mode
// ECB Mode
// CBC Mode (no padding)
// CBC Mode (PKCS#7 padding)
// PSA Crypto only allows one specific usage algorithm per built-in key ID.
// Default: PSA_ALG_CTR
#define SL_SE_BUILTIN_KEY_AES128_ALG_CONFIG (PSA_ALG_CTR)
#ifndef SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG
// Built-in PUF Key Algorithm
// PBKDF2 (CMAC-AES-128-PRF)
// CMAC
// PSA Crypto only allows one specific usage algorithm per built-in key ID.
// It is recommended to only use the PUF key for deriving further key
// material.
// Default: PSA_ALG_PBKDF2_AES_CMAC_PRF_128
#define SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG (PSA_ALG_PBKDF2_AES_CMAC_PRF_128)
#endif // SL_CRYPTOACC_BUILTIN_KEY_PUF_ALG
//
// Power optimization configuration
// Store already-generated random bytes before putting the device to sleep
// Using the hardware TRNG (for example through psa_generate_random()) will
// consume a non-negligible amount of power. A start-up routine must pass
// and a relatively large minimum amount of random bytes will be generated.
// Use cases where the device is frequently entering EM2/EM3 and thereafter
// consumes a small amount of data from the TRNG may benefit from buffering
// the existing random bytes before putting the device to sleep. These
// buffered bytes are then consumed until exhaustion before the TRNG needs
// to be initialized and used again.
//
// NOTE: this configuration option is only applicable for devices with a
// Virtual Secure Engine (VSE), and requires the 'Power Manager' component
// to be included in the project.
//
// Default: 0
#define SL_VSE_BUFFER_TRNG_DATA_DURING_SLEEP (0)
// Number of random words to buffer before putting the device to sleep <1-63>
// This option can be used to decrease the amount of random words that
// (if enabled) are buffered before the device enters EM2/EM3. Lowering this
// number will result in less static RAM usage, but also means that the TRNG
// potentially has to be initialized more times--leading to increased power
// consumption. By default this option in configured to buffer as much TRNG
// data as possible (limited by the depth of the TRNG FIFO).
//
// NOTE: this configuration option is only applicable when
// SL_VSE_BUFFER_TRNG_DATA_DURING_SLEEP is enabled.
//
// Default: 63
#define SL_VSE_MAX_TRNG_WORDS_BUFFERED_DURING_SLEEP (63)
//
//
// <<< end of configuration section >>>
// -----------------------------------------------------------------------------
// Sub-files
#if defined(SLI_PSA_CONFIG_AUTOGEN_OVERRIDE_FILE)
#include SLI_PSA_CONFIG_AUTOGEN_OVERRIDE_FILE
#else
#include "sli_psa_config_autogen.h"
#endif
#if defined(TFM_CONFIG_SL_SECURE_LIBRARY)
#include "sli_psa_tfm_translation.h"
#endif
#if SL_MBEDTLS_DRIVERS_ENABLED
#include "sli_psa_acceleration.h"
#endif
#include "sli_psa_builtin_config_autogen.h"
#endif // PSA_CRYPTO_CONFIG_H