1a8e1175bSopenharmony_ci/** 2a8e1175bSopenharmony_ci * \file config.h 3a8e1175bSopenharmony_ci * 4a8e1175bSopenharmony_ci * \brief Configuration options (set of defines) 5a8e1175bSopenharmony_ci * 6a8e1175bSopenharmony_ci * This set of compile-time options may be used to enable 7a8e1175bSopenharmony_ci * or disable features selectively, and reduce the global 8a8e1175bSopenharmony_ci * memory footprint. 9a8e1175bSopenharmony_ci */ 10a8e1175bSopenharmony_ci/* 11a8e1175bSopenharmony_ci * Copyright (C) 2006-2023, ARM Limited, All Rights Reserved 12a8e1175bSopenharmony_ci * SPDX-License-Identifier: Apache-2.0 13a8e1175bSopenharmony_ci * 14a8e1175bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); you may 15a8e1175bSopenharmony_ci * not use this file except in compliance with the License. 16a8e1175bSopenharmony_ci * You may obtain a copy of the License at 17a8e1175bSopenharmony_ci * 18a8e1175bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 19a8e1175bSopenharmony_ci * 20a8e1175bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 21a8e1175bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 22a8e1175bSopenharmony_ci * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23a8e1175bSopenharmony_ci * See the License for the specific language governing permissions and 24a8e1175bSopenharmony_ci * limitations under the License. 25a8e1175bSopenharmony_ci * 26a8e1175bSopenharmony_ci * This file is part of mbed TLS (https://tls.mbed.org) 27a8e1175bSopenharmony_ci */ 28a8e1175bSopenharmony_ci 29a8e1175bSopenharmony_ci#ifndef PROFILE_M_MBEDTLS_CONFIG_H 30a8e1175bSopenharmony_ci#define PROFILE_M_MBEDTLS_CONFIG_H 31a8e1175bSopenharmony_ci 32a8e1175bSopenharmony_ci#include "config_tfm.h" 33a8e1175bSopenharmony_ci 34a8e1175bSopenharmony_ci#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) 35a8e1175bSopenharmony_ci#define _CRT_SECURE_NO_DEPRECATE 1 36a8e1175bSopenharmony_ci#endif 37a8e1175bSopenharmony_ci 38a8e1175bSopenharmony_ci/** 39a8e1175bSopenharmony_ci * \name SECTION: System support 40a8e1175bSopenharmony_ci * 41a8e1175bSopenharmony_ci * This section sets system specific settings. 42a8e1175bSopenharmony_ci * \{ 43a8e1175bSopenharmony_ci */ 44a8e1175bSopenharmony_ci 45a8e1175bSopenharmony_ci/** 46a8e1175bSopenharmony_ci * \def MBEDTLS_HAVE_ASM 47a8e1175bSopenharmony_ci * 48a8e1175bSopenharmony_ci * The compiler has support for asm(). 49a8e1175bSopenharmony_ci * 50a8e1175bSopenharmony_ci * Requires support for asm() in compiler. 51a8e1175bSopenharmony_ci * 52a8e1175bSopenharmony_ci * Used in: 53a8e1175bSopenharmony_ci * library/aria.c 54a8e1175bSopenharmony_ci * library/timing.c 55a8e1175bSopenharmony_ci * include/mbedtls/bn_mul.h 56a8e1175bSopenharmony_ci * 57a8e1175bSopenharmony_ci * Required by: 58a8e1175bSopenharmony_ci * MBEDTLS_AESNI_C 59a8e1175bSopenharmony_ci * MBEDTLS_PADLOCK_C 60a8e1175bSopenharmony_ci * 61a8e1175bSopenharmony_ci * Comment to disable the use of assembly code. 62a8e1175bSopenharmony_ci */ 63a8e1175bSopenharmony_ci#define MBEDTLS_HAVE_ASM 64a8e1175bSopenharmony_ci 65a8e1175bSopenharmony_ci/** 66a8e1175bSopenharmony_ci * \def MBEDTLS_PLATFORM_MEMORY 67a8e1175bSopenharmony_ci * 68a8e1175bSopenharmony_ci * Enable the memory allocation layer. 69a8e1175bSopenharmony_ci * 70a8e1175bSopenharmony_ci * By default mbed TLS uses the system-provided calloc() and free(). 71a8e1175bSopenharmony_ci * This allows different allocators (self-implemented or provided) to be 72a8e1175bSopenharmony_ci * provided to the platform abstraction layer. 73a8e1175bSopenharmony_ci * 74a8e1175bSopenharmony_ci * Enabling MBEDTLS_PLATFORM_MEMORY without the 75a8e1175bSopenharmony_ci * MBEDTLS_PLATFORM_{FREE,CALLOC}_MACROs will provide 76a8e1175bSopenharmony_ci * "mbedtls_platform_set_calloc_free()" allowing you to set an alternative calloc() and 77a8e1175bSopenharmony_ci * free() function pointer at runtime. 78a8e1175bSopenharmony_ci * 79a8e1175bSopenharmony_ci * Enabling MBEDTLS_PLATFORM_MEMORY and specifying 80a8e1175bSopenharmony_ci * MBEDTLS_PLATFORM_{CALLOC,FREE}_MACROs will allow you to specify the 81a8e1175bSopenharmony_ci * alternate function at compile time. 82a8e1175bSopenharmony_ci * 83a8e1175bSopenharmony_ci * Requires: MBEDTLS_PLATFORM_C 84a8e1175bSopenharmony_ci * 85a8e1175bSopenharmony_ci * Enable this layer to allow use of alternative memory allocators. 86a8e1175bSopenharmony_ci */ 87a8e1175bSopenharmony_ci#define MBEDTLS_PLATFORM_MEMORY 88a8e1175bSopenharmony_ci 89a8e1175bSopenharmony_ci/* \} name SECTION: System support */ 90a8e1175bSopenharmony_ci 91a8e1175bSopenharmony_ci/** 92a8e1175bSopenharmony_ci * \name SECTION: mbed TLS feature support 93a8e1175bSopenharmony_ci * 94a8e1175bSopenharmony_ci * This section sets support for features that are or are not needed 95a8e1175bSopenharmony_ci * within the modules that are enabled. 96a8e1175bSopenharmony_ci * \{ 97a8e1175bSopenharmony_ci */ 98a8e1175bSopenharmony_ci 99a8e1175bSopenharmony_ci/** 100a8e1175bSopenharmony_ci * \def MBEDTLS_AES_ROM_TABLES 101a8e1175bSopenharmony_ci * 102a8e1175bSopenharmony_ci * Use precomputed AES tables stored in ROM. 103a8e1175bSopenharmony_ci * 104a8e1175bSopenharmony_ci * Uncomment this macro to use precomputed AES tables stored in ROM. 105a8e1175bSopenharmony_ci * Comment this macro to generate AES tables in RAM at runtime. 106a8e1175bSopenharmony_ci * 107a8e1175bSopenharmony_ci * Tradeoff: Using precomputed ROM tables reduces RAM usage by ~8kb 108a8e1175bSopenharmony_ci * (or ~2kb if \c MBEDTLS_AES_FEWER_TABLES is used) and reduces the 109a8e1175bSopenharmony_ci * initialization time before the first AES operation can be performed. 110a8e1175bSopenharmony_ci * It comes at the cost of additional ~8kb ROM use (resp. ~2kb if \c 111a8e1175bSopenharmony_ci * MBEDTLS_AES_FEWER_TABLES below is used), and potentially degraded 112a8e1175bSopenharmony_ci * performance if ROM access is slower than RAM access. 113a8e1175bSopenharmony_ci * 114a8e1175bSopenharmony_ci * This option is independent of \c MBEDTLS_AES_FEWER_TABLES. 115a8e1175bSopenharmony_ci * 116a8e1175bSopenharmony_ci */ 117a8e1175bSopenharmony_ci#define MBEDTLS_AES_ROM_TABLES 118a8e1175bSopenharmony_ci 119a8e1175bSopenharmony_ci/** 120a8e1175bSopenharmony_ci * \def MBEDTLS_AES_FEWER_TABLES 121a8e1175bSopenharmony_ci * 122a8e1175bSopenharmony_ci * Use less ROM/RAM for AES tables. 123a8e1175bSopenharmony_ci * 124a8e1175bSopenharmony_ci * Uncommenting this macro omits 75% of the AES tables from 125a8e1175bSopenharmony_ci * ROM / RAM (depending on the value of \c MBEDTLS_AES_ROM_TABLES) 126a8e1175bSopenharmony_ci * by computing their values on the fly during operations 127a8e1175bSopenharmony_ci * (the tables are entry-wise rotations of one another). 128a8e1175bSopenharmony_ci * 129a8e1175bSopenharmony_ci * Tradeoff: Uncommenting this reduces the RAM / ROM footprint 130a8e1175bSopenharmony_ci * by ~6kb but at the cost of more arithmetic operations during 131a8e1175bSopenharmony_ci * runtime. Specifically, one has to compare 4 accesses within 132a8e1175bSopenharmony_ci * different tables to 4 accesses with additional arithmetic 133a8e1175bSopenharmony_ci * operations within the same table. The performance gain/loss 134a8e1175bSopenharmony_ci * depends on the system and memory details. 135a8e1175bSopenharmony_ci * 136a8e1175bSopenharmony_ci * This option is independent of \c MBEDTLS_AES_ROM_TABLES. 137a8e1175bSopenharmony_ci * 138a8e1175bSopenharmony_ci */ 139a8e1175bSopenharmony_ci#define MBEDTLS_AES_FEWER_TABLES 140a8e1175bSopenharmony_ci 141a8e1175bSopenharmony_ci/** 142a8e1175bSopenharmony_ci * \def MBEDTLS_ECP_NIST_OPTIM 143a8e1175bSopenharmony_ci * 144a8e1175bSopenharmony_ci * Enable specific 'modulo p' routines for each NIST prime. 145a8e1175bSopenharmony_ci * Depending on the prime and architecture, makes operations 4 to 8 times 146a8e1175bSopenharmony_ci * faster on the corresponding curve. 147a8e1175bSopenharmony_ci * 148a8e1175bSopenharmony_ci * Comment this macro to disable NIST curves optimisation. 149a8e1175bSopenharmony_ci */ 150a8e1175bSopenharmony_ci#define MBEDTLS_ECP_NIST_OPTIM 151a8e1175bSopenharmony_ci 152a8e1175bSopenharmony_ci/** 153a8e1175bSopenharmony_ci * \def MBEDTLS_NO_PLATFORM_ENTROPY 154a8e1175bSopenharmony_ci * 155a8e1175bSopenharmony_ci * Do not use built-in platform entropy functions. 156a8e1175bSopenharmony_ci * This is useful if your platform does not support 157a8e1175bSopenharmony_ci * standards like the /dev/urandom or Windows CryptoAPI. 158a8e1175bSopenharmony_ci * 159a8e1175bSopenharmony_ci * Uncomment this macro to disable the built-in platform entropy functions. 160a8e1175bSopenharmony_ci */ 161a8e1175bSopenharmony_ci#define MBEDTLS_NO_PLATFORM_ENTROPY 162a8e1175bSopenharmony_ci 163a8e1175bSopenharmony_ci/** 164a8e1175bSopenharmony_ci * \def MBEDTLS_ENTROPY_NV_SEED 165a8e1175bSopenharmony_ci * 166a8e1175bSopenharmony_ci * Enable the non-volatile (NV) seed file-based entropy source. 167a8e1175bSopenharmony_ci * (Also enables the NV seed read/write functions in the platform layer) 168a8e1175bSopenharmony_ci * 169a8e1175bSopenharmony_ci * This is crucial (if not required) on systems that do not have a 170a8e1175bSopenharmony_ci * cryptographic entropy source (in hardware or kernel) available. 171a8e1175bSopenharmony_ci * 172a8e1175bSopenharmony_ci * Requires: MBEDTLS_ENTROPY_C, MBEDTLS_PLATFORM_C 173a8e1175bSopenharmony_ci * 174a8e1175bSopenharmony_ci * \note The read/write functions that are used by the entropy source are 175a8e1175bSopenharmony_ci * determined in the platform layer, and can be modified at runtime and/or 176a8e1175bSopenharmony_ci * compile-time depending on the flags (MBEDTLS_PLATFORM_NV_SEED_*) used. 177a8e1175bSopenharmony_ci * 178a8e1175bSopenharmony_ci * \note If you use the default implementation functions that read a seedfile 179a8e1175bSopenharmony_ci * with regular fopen(), please make sure you make a seedfile with the 180a8e1175bSopenharmony_ci * proper name (defined in MBEDTLS_PLATFORM_STD_NV_SEED_FILE) and at 181a8e1175bSopenharmony_ci * least MBEDTLS_ENTROPY_BLOCK_SIZE bytes in size that can be read from 182a8e1175bSopenharmony_ci * and written to or you will get an entropy source error! The default 183a8e1175bSopenharmony_ci * implementation will only use the first MBEDTLS_ENTROPY_BLOCK_SIZE 184a8e1175bSopenharmony_ci * bytes from the file. 185a8e1175bSopenharmony_ci * 186a8e1175bSopenharmony_ci * \note The entropy collector will write to the seed file before entropy is 187a8e1175bSopenharmony_ci * given to an external source, to update it. 188a8e1175bSopenharmony_ci */ 189a8e1175bSopenharmony_ci#define MBEDTLS_ENTROPY_NV_SEED 190a8e1175bSopenharmony_ci 191a8e1175bSopenharmony_ci/** 192a8e1175bSopenharmony_ci * \def MBEDTLS_PSA_CRYPTO_SPM 193a8e1175bSopenharmony_ci * 194a8e1175bSopenharmony_ci * When MBEDTLS_PSA_CRYPTO_SPM is defined, the code is built for SPM (Secure 195a8e1175bSopenharmony_ci * Partition Manager) integration which separates the code into two parts: a 196a8e1175bSopenharmony_ci * NSPE (Non-Secure Process Environment) and an SPE (Secure Process 197a8e1175bSopenharmony_ci * Environment). 198a8e1175bSopenharmony_ci * 199a8e1175bSopenharmony_ci * Module: library/psa_crypto.c 200a8e1175bSopenharmony_ci * Requires: MBEDTLS_PSA_CRYPTO_C 201a8e1175bSopenharmony_ci * 202a8e1175bSopenharmony_ci */ 203a8e1175bSopenharmony_ci#define MBEDTLS_PSA_CRYPTO_SPM 204a8e1175bSopenharmony_ci 205a8e1175bSopenharmony_ci/** 206a8e1175bSopenharmony_ci * \def MBEDTLS_SHA256_SMALLER 207a8e1175bSopenharmony_ci * 208a8e1175bSopenharmony_ci * Enable an implementation of SHA-256 that has lower ROM footprint but also 209a8e1175bSopenharmony_ci * lower performance. 210a8e1175bSopenharmony_ci * 211a8e1175bSopenharmony_ci * The default implementation is meant to be a reasonnable compromise between 212a8e1175bSopenharmony_ci * performance and size. This version optimizes more aggressively for size at 213a8e1175bSopenharmony_ci * the expense of performance. Eg on Cortex-M4 it reduces the size of 214a8e1175bSopenharmony_ci * mbedtls_sha256_process() from ~2KB to ~0.5KB for a performance hit of about 215a8e1175bSopenharmony_ci * 30%. 216a8e1175bSopenharmony_ci * 217a8e1175bSopenharmony_ci * Uncomment to enable the smaller implementation of SHA256. 218a8e1175bSopenharmony_ci */ 219a8e1175bSopenharmony_ci#define MBEDTLS_SHA256_SMALLER 220a8e1175bSopenharmony_ci 221a8e1175bSopenharmony_ci/** 222a8e1175bSopenharmony_ci * \def MBEDTLS_PSA_CRYPTO_CONFIG 223a8e1175bSopenharmony_ci * 224a8e1175bSopenharmony_ci * This setting allows support for cryptographic mechanisms through the PSA 225a8e1175bSopenharmony_ci * API to be configured separately from support through the mbedtls API. 226a8e1175bSopenharmony_ci * 227a8e1175bSopenharmony_ci * When this option is disabled, the PSA API exposes the cryptographic 228a8e1175bSopenharmony_ci * mechanisms that can be implemented on top of the `mbedtls_xxx` API 229a8e1175bSopenharmony_ci * configured with `MBEDTLS_XXX` symbols. 230a8e1175bSopenharmony_ci * 231a8e1175bSopenharmony_ci * When this option is enabled, the PSA API exposes the cryptographic 232a8e1175bSopenharmony_ci * mechanisms requested by the `PSA_WANT_XXX` symbols defined in 233a8e1175bSopenharmony_ci * include/psa/crypto_config.h. The corresponding `MBEDTLS_XXX` settings are 234a8e1175bSopenharmony_ci * automatically enabled if required (i.e. if no PSA driver provides the 235a8e1175bSopenharmony_ci * mechanism). You may still freely enable additional `MBEDTLS_XXX` symbols 236a8e1175bSopenharmony_ci * in mbedtls_config.h. 237a8e1175bSopenharmony_ci * 238a8e1175bSopenharmony_ci * If the symbol #MBEDTLS_PSA_CRYPTO_CONFIG_FILE is defined, it specifies 239a8e1175bSopenharmony_ci * an alternative header to include instead of include/psa/crypto_config.h. 240a8e1175bSopenharmony_ci * 241a8e1175bSopenharmony_ci * This feature is still experimental and is not ready for production since 242a8e1175bSopenharmony_ci * it is not completed. 243a8e1175bSopenharmony_ci */ 244a8e1175bSopenharmony_ci#define MBEDTLS_PSA_CRYPTO_CONFIG 245a8e1175bSopenharmony_ci 246a8e1175bSopenharmony_ci/* \} name SECTION: mbed TLS feature support */ 247a8e1175bSopenharmony_ci 248a8e1175bSopenharmony_ci/** 249a8e1175bSopenharmony_ci * \name SECTION: mbed TLS modules 250a8e1175bSopenharmony_ci * 251a8e1175bSopenharmony_ci * This section enables or disables entire modules in mbed TLS 252a8e1175bSopenharmony_ci * \{ 253a8e1175bSopenharmony_ci */ 254a8e1175bSopenharmony_ci 255a8e1175bSopenharmony_ci/** 256a8e1175bSopenharmony_ci * \def MBEDTLS_AES_C 257a8e1175bSopenharmony_ci * 258a8e1175bSopenharmony_ci * Enable the AES block cipher. 259a8e1175bSopenharmony_ci * 260a8e1175bSopenharmony_ci * Module: library/aes.c 261a8e1175bSopenharmony_ci * Caller: library/cipher.c 262a8e1175bSopenharmony_ci * library/pem.c 263a8e1175bSopenharmony_ci * library/ctr_drbg.c 264a8e1175bSopenharmony_ci * 265a8e1175bSopenharmony_ci * This module is required to support the TLS ciphersuites that use the AES 266a8e1175bSopenharmony_ci * cipher. 267a8e1175bSopenharmony_ci * 268a8e1175bSopenharmony_ci * PEM_PARSE uses AES for decrypting encrypted keys. 269a8e1175bSopenharmony_ci */ 270a8e1175bSopenharmony_ci#define MBEDTLS_AES_C 271a8e1175bSopenharmony_ci 272a8e1175bSopenharmony_ci/** 273a8e1175bSopenharmony_ci * \def MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH 274a8e1175bSopenharmony_ci * 275a8e1175bSopenharmony_ci * Use only 128-bit keys in AES operations to save ROM. 276a8e1175bSopenharmony_ci * 277a8e1175bSopenharmony_ci * Uncomment this macro to remove support for AES operations that use 192- 278a8e1175bSopenharmony_ci * or 256-bit keys. 279a8e1175bSopenharmony_ci * 280a8e1175bSopenharmony_ci * Uncommenting this macro reduces the size of AES code by ~300 bytes 281a8e1175bSopenharmony_ci * on v8-M/Thumb2. 282a8e1175bSopenharmony_ci * 283a8e1175bSopenharmony_ci * Module: library/aes.c 284a8e1175bSopenharmony_ci * 285a8e1175bSopenharmony_ci * Requires: MBEDTLS_AES_C 286a8e1175bSopenharmony_ci */ 287a8e1175bSopenharmony_ci#define MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH 288a8e1175bSopenharmony_ci 289a8e1175bSopenharmony_ci/** 290a8e1175bSopenharmony_ci * \def MBEDTLS_CIPHER_C 291a8e1175bSopenharmony_ci * 292a8e1175bSopenharmony_ci * Enable the generic cipher layer. 293a8e1175bSopenharmony_ci * 294a8e1175bSopenharmony_ci * Module: library/cipher.c 295a8e1175bSopenharmony_ci * 296a8e1175bSopenharmony_ci * Uncomment to enable generic cipher wrappers. 297a8e1175bSopenharmony_ci */ 298a8e1175bSopenharmony_ci#define MBEDTLS_CIPHER_C 299a8e1175bSopenharmony_ci 300a8e1175bSopenharmony_ci/** 301a8e1175bSopenharmony_ci * \def MBEDTLS_CTR_DRBG_C 302a8e1175bSopenharmony_ci * 303a8e1175bSopenharmony_ci * Enable the CTR_DRBG AES-based random generator. 304a8e1175bSopenharmony_ci * The CTR_DRBG generator uses AES-256 by default. 305a8e1175bSopenharmony_ci * To use AES-128 instead, enable MBEDTLS_CTR_DRBG_USE_128_BIT_KEY below. 306a8e1175bSopenharmony_ci * 307a8e1175bSopenharmony_ci * Module: library/ctr_drbg.c 308a8e1175bSopenharmony_ci * Caller: 309a8e1175bSopenharmony_ci * 310a8e1175bSopenharmony_ci * Requires: MBEDTLS_AES_C 311a8e1175bSopenharmony_ci * 312a8e1175bSopenharmony_ci * This module provides the CTR_DRBG AES random number generator. 313a8e1175bSopenharmony_ci */ 314a8e1175bSopenharmony_ci#define MBEDTLS_CTR_DRBG_C 315a8e1175bSopenharmony_ci 316a8e1175bSopenharmony_ci/** 317a8e1175bSopenharmony_ci * \def MBEDTLS_ENTROPY_C 318a8e1175bSopenharmony_ci * 319a8e1175bSopenharmony_ci * Enable the platform-specific entropy code. 320a8e1175bSopenharmony_ci * 321a8e1175bSopenharmony_ci * Module: library/entropy.c 322a8e1175bSopenharmony_ci * Caller: 323a8e1175bSopenharmony_ci * 324a8e1175bSopenharmony_ci * Requires: MBEDTLS_SHA512_C or MBEDTLS_SHA256_C 325a8e1175bSopenharmony_ci * 326a8e1175bSopenharmony_ci * This module provides a generic entropy pool 327a8e1175bSopenharmony_ci */ 328a8e1175bSopenharmony_ci#define MBEDTLS_ENTROPY_C 329a8e1175bSopenharmony_ci 330a8e1175bSopenharmony_ci/** 331a8e1175bSopenharmony_ci * \def MBEDTLS_HKDF_C 332a8e1175bSopenharmony_ci * 333a8e1175bSopenharmony_ci * Enable the HKDF algorithm (RFC 5869). 334a8e1175bSopenharmony_ci * 335a8e1175bSopenharmony_ci * Module: library/hkdf.c 336a8e1175bSopenharmony_ci * Caller: 337a8e1175bSopenharmony_ci * 338a8e1175bSopenharmony_ci * Requires: MBEDTLS_MD_C 339a8e1175bSopenharmony_ci * 340a8e1175bSopenharmony_ci * This module adds support for the Hashed Message Authentication Code 341a8e1175bSopenharmony_ci * (HMAC)-based key derivation function (HKDF). 342a8e1175bSopenharmony_ci */ 343a8e1175bSopenharmony_ci//#define MBEDTLS_HKDF_C /* Used for HUK deriviation */ 344a8e1175bSopenharmony_ci 345a8e1175bSopenharmony_ci/** 346a8e1175bSopenharmony_ci * \def MBEDTLS_MEMORY_BUFFER_ALLOC_C 347a8e1175bSopenharmony_ci * 348a8e1175bSopenharmony_ci * Enable the buffer allocator implementation that makes use of a (stack) 349a8e1175bSopenharmony_ci * based buffer to 'allocate' dynamic memory. (replaces calloc() and free() 350a8e1175bSopenharmony_ci * calls) 351a8e1175bSopenharmony_ci * 352a8e1175bSopenharmony_ci * Module: library/memory_buffer_alloc.c 353a8e1175bSopenharmony_ci * 354a8e1175bSopenharmony_ci * Requires: MBEDTLS_PLATFORM_C 355a8e1175bSopenharmony_ci * MBEDTLS_PLATFORM_MEMORY (to use it within mbed TLS) 356a8e1175bSopenharmony_ci * 357a8e1175bSopenharmony_ci * Enable this module to enable the buffer memory allocator. 358a8e1175bSopenharmony_ci */ 359a8e1175bSopenharmony_ci#define MBEDTLS_MEMORY_BUFFER_ALLOC_C 360a8e1175bSopenharmony_ci 361a8e1175bSopenharmony_ci/** 362a8e1175bSopenharmony_ci * \def MBEDTLS_PLATFORM_C 363a8e1175bSopenharmony_ci * 364a8e1175bSopenharmony_ci * Enable the platform abstraction layer that allows you to re-assign 365a8e1175bSopenharmony_ci * functions like calloc(), free(), snprintf(), printf(), fprintf(), exit(). 366a8e1175bSopenharmony_ci * 367a8e1175bSopenharmony_ci * Enabling MBEDTLS_PLATFORM_C enables to use of MBEDTLS_PLATFORM_XXX_ALT 368a8e1175bSopenharmony_ci * or MBEDTLS_PLATFORM_XXX_MACRO directives, allowing the functions mentioned 369a8e1175bSopenharmony_ci * above to be specified at runtime or compile time respectively. 370a8e1175bSopenharmony_ci * 371a8e1175bSopenharmony_ci * \note This abstraction layer must be enabled on Windows (including MSYS2) 372a8e1175bSopenharmony_ci * as other module rely on it for a fixed snprintf implementation. 373a8e1175bSopenharmony_ci * 374a8e1175bSopenharmony_ci * Module: library/platform.c 375a8e1175bSopenharmony_ci * Caller: Most other .c files 376a8e1175bSopenharmony_ci * 377a8e1175bSopenharmony_ci * This module enables abstraction of common (libc) functions. 378a8e1175bSopenharmony_ci */ 379a8e1175bSopenharmony_ci#define MBEDTLS_PLATFORM_C 380a8e1175bSopenharmony_ci 381a8e1175bSopenharmony_ci#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS 382a8e1175bSopenharmony_ci#define MBEDTLS_PLATFORM_STD_MEM_HDR <stdlib.h> 383a8e1175bSopenharmony_ci 384a8e1175bSopenharmony_ci#include <stdio.h> 385a8e1175bSopenharmony_ci 386a8e1175bSopenharmony_ci#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf 387a8e1175bSopenharmony_ci#define MBEDTLS_PLATFORM_PRINTF_ALT 388a8e1175bSopenharmony_ci#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS 389a8e1175bSopenharmony_ci#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE 390a8e1175bSopenharmony_ci 391a8e1175bSopenharmony_ci/** 392a8e1175bSopenharmony_ci * \def MBEDTLS_PSA_CRYPTO_C 393a8e1175bSopenharmony_ci * 394a8e1175bSopenharmony_ci * Enable the Platform Security Architecture cryptography API. 395a8e1175bSopenharmony_ci * 396a8e1175bSopenharmony_ci * Module: library/psa_crypto.c 397a8e1175bSopenharmony_ci * 398a8e1175bSopenharmony_ci * Requires: MBEDTLS_CTR_DRBG_C, MBEDTLS_ENTROPY_C 399a8e1175bSopenharmony_ci * 400a8e1175bSopenharmony_ci */ 401a8e1175bSopenharmony_ci#define MBEDTLS_PSA_CRYPTO_C 402a8e1175bSopenharmony_ci 403a8e1175bSopenharmony_ci/** 404a8e1175bSopenharmony_ci * \def MBEDTLS_PSA_CRYPTO_STORAGE_C 405a8e1175bSopenharmony_ci * 406a8e1175bSopenharmony_ci * Enable the Platform Security Architecture persistent key storage. 407a8e1175bSopenharmony_ci * 408a8e1175bSopenharmony_ci * Module: library/psa_crypto_storage.c 409a8e1175bSopenharmony_ci * 410a8e1175bSopenharmony_ci * Requires: MBEDTLS_PSA_CRYPTO_C, 411a8e1175bSopenharmony_ci * either MBEDTLS_PSA_ITS_FILE_C or a native implementation of 412a8e1175bSopenharmony_ci * the PSA ITS interface 413a8e1175bSopenharmony_ci */ 414a8e1175bSopenharmony_ci#define MBEDTLS_PSA_CRYPTO_STORAGE_C 415a8e1175bSopenharmony_ci 416a8e1175bSopenharmony_ci/* \} name SECTION: mbed TLS modules */ 417a8e1175bSopenharmony_ci 418a8e1175bSopenharmony_ci/** 419a8e1175bSopenharmony_ci * \name SECTION: General configuration options 420a8e1175bSopenharmony_ci * 421a8e1175bSopenharmony_ci * This section contains Mbed TLS build settings that are not associated 422a8e1175bSopenharmony_ci * with a particular module. 423a8e1175bSopenharmony_ci * 424a8e1175bSopenharmony_ci * \{ 425a8e1175bSopenharmony_ci */ 426a8e1175bSopenharmony_ci 427a8e1175bSopenharmony_ci/** 428a8e1175bSopenharmony_ci * \def MBEDTLS_CONFIG_FILE 429a8e1175bSopenharmony_ci * 430a8e1175bSopenharmony_ci * If defined, this is a header which will be included instead of 431a8e1175bSopenharmony_ci * `"mbedtls/mbedtls_config.h"`. 432a8e1175bSopenharmony_ci * This header file specifies the compile-time configuration of Mbed TLS. 433a8e1175bSopenharmony_ci * Unlike other configuration options, this one must be defined on the 434a8e1175bSopenharmony_ci * compiler command line: a definition in `mbedtls_config.h` would have 435a8e1175bSopenharmony_ci * no effect. 436a8e1175bSopenharmony_ci * 437a8e1175bSopenharmony_ci * This macro is expanded after an <tt>\#include</tt> directive. This is a popular but 438a8e1175bSopenharmony_ci * non-standard feature of the C language, so this feature is only available 439a8e1175bSopenharmony_ci * with compilers that perform macro expansion on an <tt>\#include</tt> line. 440a8e1175bSopenharmony_ci * 441a8e1175bSopenharmony_ci * The value of this symbol is typically a path in double quotes, either 442a8e1175bSopenharmony_ci * absolute or relative to a directory on the include search path. 443a8e1175bSopenharmony_ci */ 444a8e1175bSopenharmony_ci//#define MBEDTLS_CONFIG_FILE "mbedtls/mbedtls_config.h" 445a8e1175bSopenharmony_ci 446a8e1175bSopenharmony_ci/** 447a8e1175bSopenharmony_ci * \def MBEDTLS_USER_CONFIG_FILE 448a8e1175bSopenharmony_ci * 449a8e1175bSopenharmony_ci * If defined, this is a header which will be included after 450a8e1175bSopenharmony_ci * `"mbedtls/mbedtls_config.h"` or #MBEDTLS_CONFIG_FILE. 451a8e1175bSopenharmony_ci * This allows you to modify the default configuration, including the ability 452a8e1175bSopenharmony_ci * to undefine options that are enabled by default. 453a8e1175bSopenharmony_ci * 454a8e1175bSopenharmony_ci * This macro is expanded after an <tt>\#include</tt> directive. This is a popular but 455a8e1175bSopenharmony_ci * non-standard feature of the C language, so this feature is only available 456a8e1175bSopenharmony_ci * with compilers that perform macro expansion on an <tt>\#include</tt> line. 457a8e1175bSopenharmony_ci * 458a8e1175bSopenharmony_ci * The value of this symbol is typically a path in double quotes, either 459a8e1175bSopenharmony_ci * absolute or relative to a directory on the include search path. 460a8e1175bSopenharmony_ci */ 461a8e1175bSopenharmony_ci//#define MBEDTLS_USER_CONFIG_FILE "/dev/null" 462a8e1175bSopenharmony_ci 463a8e1175bSopenharmony_ci/** 464a8e1175bSopenharmony_ci * \def MBEDTLS_PSA_CRYPTO_CONFIG_FILE 465a8e1175bSopenharmony_ci * 466a8e1175bSopenharmony_ci * If defined, this is a header which will be included instead of 467a8e1175bSopenharmony_ci * `"psa/crypto_config.h"`. 468a8e1175bSopenharmony_ci * This header file specifies which cryptographic mechanisms are available 469a8e1175bSopenharmony_ci * through the PSA API when #MBEDTLS_PSA_CRYPTO_CONFIG is enabled, and 470a8e1175bSopenharmony_ci * is not used when #MBEDTLS_PSA_CRYPTO_CONFIG is disabled. 471a8e1175bSopenharmony_ci * 472a8e1175bSopenharmony_ci * This macro is expanded after an <tt>\#include</tt> directive. This is a popular but 473a8e1175bSopenharmony_ci * non-standard feature of the C language, so this feature is only available 474a8e1175bSopenharmony_ci * with compilers that perform macro expansion on an <tt>\#include</tt> line. 475a8e1175bSopenharmony_ci * 476a8e1175bSopenharmony_ci * The value of this symbol is typically a path in double quotes, either 477a8e1175bSopenharmony_ci * absolute or relative to a directory on the include search path. 478a8e1175bSopenharmony_ci */ 479a8e1175bSopenharmony_ci//#define MBEDTLS_PSA_CRYPTO_CONFIG_FILE "psa/crypto_config.h" 480a8e1175bSopenharmony_ci 481a8e1175bSopenharmony_ci/** 482a8e1175bSopenharmony_ci * \def MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE 483a8e1175bSopenharmony_ci * 484a8e1175bSopenharmony_ci * If defined, this is a header which will be included after 485a8e1175bSopenharmony_ci * `"psa/crypto_config.h"` or #MBEDTLS_PSA_CRYPTO_CONFIG_FILE. 486a8e1175bSopenharmony_ci * This allows you to modify the default configuration, including the ability 487a8e1175bSopenharmony_ci * to undefine options that are enabled by default. 488a8e1175bSopenharmony_ci * 489a8e1175bSopenharmony_ci * This macro is expanded after an <tt>\#include</tt> directive. This is a popular but 490a8e1175bSopenharmony_ci * non-standard feature of the C language, so this feature is only available 491a8e1175bSopenharmony_ci * with compilers that perform macro expansion on an <tt>\#include</tt> line. 492a8e1175bSopenharmony_ci * 493a8e1175bSopenharmony_ci * The value of this symbol is typically a path in double quotes, either 494a8e1175bSopenharmony_ci * absolute or relative to a directory on the include search path. 495a8e1175bSopenharmony_ci */ 496a8e1175bSopenharmony_ci//#define MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE "/dev/null" 497a8e1175bSopenharmony_ci 498a8e1175bSopenharmony_ci/** \} name SECTION: General configuration options */ 499a8e1175bSopenharmony_ci 500a8e1175bSopenharmony_ci/** 501a8e1175bSopenharmony_ci * \name SECTION: Module configuration options 502a8e1175bSopenharmony_ci * 503a8e1175bSopenharmony_ci * This section allows for the setting of module specific sizes and 504a8e1175bSopenharmony_ci * configuration options. The default values are already present in the 505a8e1175bSopenharmony_ci * relevant header files and should suffice for the regular use cases. 506a8e1175bSopenharmony_ci * 507a8e1175bSopenharmony_ci * Our advice is to enable options and change their values here 508a8e1175bSopenharmony_ci * only if you have a good reason and know the consequences. 509a8e1175bSopenharmony_ci * 510a8e1175bSopenharmony_ci * Please check the respective header file for documentation on these 511a8e1175bSopenharmony_ci * parameters (to prevent duplicate documentation). 512a8e1175bSopenharmony_ci * \{ 513a8e1175bSopenharmony_ci */ 514a8e1175bSopenharmony_ci 515a8e1175bSopenharmony_ci/* ECP options */ 516a8e1175bSopenharmony_ci#define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Disable fixed-point speed-up */ 517a8e1175bSopenharmony_ci 518a8e1175bSopenharmony_ci/** 519a8e1175bSopenharmony_ci * Uncomment to enable p256-m. This is an alternative implementation of 520a8e1175bSopenharmony_ci * key generation, ECDH and (randomized) ECDSA on the curve SECP256R1. 521a8e1175bSopenharmony_ci * Compared to the default implementation: 522a8e1175bSopenharmony_ci * 523a8e1175bSopenharmony_ci * - p256-m has a much smaller code size and RAM footprint. 524a8e1175bSopenharmony_ci * - p256-m is only available via the PSA API. This includes the pk module 525a8e1175bSopenharmony_ci * when #MBEDTLS_USE_PSA_CRYPTO is enabled. 526a8e1175bSopenharmony_ci * - p256-m does not support deterministic ECDSA, EC-JPAKE, custom protocols 527a8e1175bSopenharmony_ci * over the core arithmetic, or deterministic derivation of keys. 528a8e1175bSopenharmony_ci * 529a8e1175bSopenharmony_ci * We recommend enabling this option if your application uses the PSA API 530a8e1175bSopenharmony_ci * and the only elliptic curve support it needs is ECDH and ECDSA over 531a8e1175bSopenharmony_ci * SECP256R1. 532a8e1175bSopenharmony_ci * 533a8e1175bSopenharmony_ci * If you enable this option, you do not need to enable any ECC-related 534a8e1175bSopenharmony_ci * MBEDTLS_xxx option. You do need to separately request support for the 535a8e1175bSopenharmony_ci * cryptographic mechanisms through the PSA API: 536a8e1175bSopenharmony_ci * - #MBEDTLS_PSA_CRYPTO_C and #MBEDTLS_PSA_CRYPTO_CONFIG for PSA-based 537a8e1175bSopenharmony_ci * configuration; 538a8e1175bSopenharmony_ci * - #MBEDTLS_USE_PSA_CRYPTO if you want to use p256-m from PK, X.509 or TLS; 539a8e1175bSopenharmony_ci * - #PSA_WANT_ECC_SECP_R1_256; 540a8e1175bSopenharmony_ci * - #PSA_WANT_ALG_ECDH and/or #PSA_WANT_ALG_ECDSA as needed; 541a8e1175bSopenharmony_ci * - #PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY, #PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC, 542a8e1175bSopenharmony_ci * #PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT, 543a8e1175bSopenharmony_ci * #PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT and/or 544a8e1175bSopenharmony_ci * #PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE as needed. 545a8e1175bSopenharmony_ci * 546a8e1175bSopenharmony_ci * \note To benefit from the smaller code size of p256-m, make sure that you 547a8e1175bSopenharmony_ci * do not enable any ECC-related option not supported by p256-m: this 548a8e1175bSopenharmony_ci * would cause the built-in ECC implementation to be built as well, in 549a8e1175bSopenharmony_ci * order to provide the required option. 550a8e1175bSopenharmony_ci * Make sure #PSA_WANT_ALG_DETERMINISTIC_ECDSA, #PSA_WANT_ALG_JPAKE and 551a8e1175bSopenharmony_ci * #PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE, and curves other than 552a8e1175bSopenharmony_ci * SECP256R1 are disabled as they are not supported by this driver. 553a8e1175bSopenharmony_ci * Also, avoid defining #MBEDTLS_PK_PARSE_EC_COMPRESSED or 554a8e1175bSopenharmony_ci * #MBEDTLS_PK_PARSE_EC_EXTENDED as those currently require a subset of 555a8e1175bSopenharmony_ci * the built-in ECC implementation, see docs/driver-only-builds.md. 556a8e1175bSopenharmony_ci */ 557a8e1175bSopenharmony_ci#define MBEDTLS_PSA_P256M_DRIVER_ENABLED 558a8e1175bSopenharmony_ci 559a8e1175bSopenharmony_ci/* \} name SECTION: Customisation configuration options */ 560a8e1175bSopenharmony_ci 561a8e1175bSopenharmony_ci#if CRYPTO_NV_SEED 562a8e1175bSopenharmony_ci#include "tfm_mbedcrypto_config_extra_nv_seed.h" 563a8e1175bSopenharmony_ci#endif /* CRYPTO_NV_SEED */ 564a8e1175bSopenharmony_ci 565a8e1175bSopenharmony_ci#if !defined(CRYPTO_HW_ACCELERATOR) && defined(MBEDTLS_ENTROPY_NV_SEED) 566a8e1175bSopenharmony_ci#include "mbedtls_entropy_nv_seed_config.h" 567a8e1175bSopenharmony_ci#endif 568a8e1175bSopenharmony_ci 569a8e1175bSopenharmony_ci#ifdef CRYPTO_HW_ACCELERATOR 570a8e1175bSopenharmony_ci#include "mbedtls_accelerator_config.h" 571a8e1175bSopenharmony_ci#endif 572a8e1175bSopenharmony_ci 573a8e1175bSopenharmony_ci#endif /* PROFILE_M_MBEDTLS_CONFIG_H */ 574