blob: 83048d0d805bfa1b12626e0894a761c6c4313be2 [file] [log] [blame]
Dave Rodgman27a37852023-12-08 15:27:49 +00001/*
2 * Copyright (c) 2018-2023, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
Aditya Deshpande16a62e32023-04-11 16:25:02 +01007/**
8 * \file psa/crypto_config.h
9 * \brief PSA crypto configuration options (set of defines)
10 *
11 */
Aditya Deshpande16a62e32023-04-11 16:25:02 +010012
13#ifndef PROFILE_M_PSA_CRYPTO_CONFIG_H
14#define PROFILE_M_PSA_CRYPTO_CONFIG_H
15
Ronald Cron26540812024-12-05 16:52:17 +010016/**
17 * \name SECTION: Platform abstraction layer
18 *
19 * This section sets platform specific settings.
20 * \{
21 */
22
23/**
24 * \def MBEDTLS_MEMORY_BUFFER_ALLOC_C
25 *
26 * Enable the buffer allocator implementation that makes use of a (stack)
27 * based buffer to 'allocate' dynamic memory. (replaces calloc() and free()
28 * calls)
29 *
30 * Module: library/memory_buffer_alloc.c
31 *
32 * Requires: MBEDTLS_PLATFORM_C
33 * MBEDTLS_PLATFORM_MEMORY (to use it within Mbed TLS)
34 *
35 * Enable this module to enable the buffer memory allocator.
36 */
37#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
38
39/**
40 * \def MBEDTLS_PLATFORM_C
41 *
42 * Enable the platform abstraction layer that allows you to re-assign
43 * functions like calloc(), free(), snprintf(), printf(), fprintf(), exit().
44 *
45 * Enabling MBEDTLS_PLATFORM_C enables to use of MBEDTLS_PLATFORM_XXX_ALT
46 * or MBEDTLS_PLATFORM_XXX_MACRO directives, allowing the functions mentioned
47 * above to be specified at runtime or compile time respectively.
48 *
49 * \note This abstraction layer must be enabled on Windows (including MSYS2)
50 * as other modules rely on it for a fixed snprintf implementation.
51 *
52 * Module: library/platform.c
53 * Caller: Most other .c files
54 *
55 * This module enables abstraction of common (libc) functions.
56 */
57#define MBEDTLS_PLATFORM_C
58
59/**
60 * \def MBEDTLS_PLATFORM_MEMORY
61 *
62 * Enable the memory allocation layer.
63 *
64 * By default Mbed TLS uses the system-provided calloc() and free().
65 * This allows different allocators (self-implemented or provided) to be
66 * provided to the platform abstraction layer.
67 *
68 * Enabling #MBEDTLS_PLATFORM_MEMORY without the
69 * MBEDTLS_PLATFORM_{FREE,CALLOC}_MACROs will provide
70 * "mbedtls_platform_set_calloc_free()" allowing you to set an alternative calloc() and
71 * free() function pointer at runtime.
72 *
73 * Enabling #MBEDTLS_PLATFORM_MEMORY and specifying
74 * MBEDTLS_PLATFORM_{CALLOC,FREE}_MACROs will allow you to specify the
75 * alternate function at compile time.
76 *
77 * An overview of how the value of mbedtls_calloc is determined:
78 *
79 * - if !MBEDTLS_PLATFORM_MEMORY
80 * - mbedtls_calloc = calloc
81 * - if MBEDTLS_PLATFORM_MEMORY
82 * - if (MBEDTLS_PLATFORM_CALLOC_MACRO && MBEDTLS_PLATFORM_FREE_MACRO):
83 * - mbedtls_calloc = MBEDTLS_PLATFORM_CALLOC_MACRO
84 * - if !(MBEDTLS_PLATFORM_CALLOC_MACRO && MBEDTLS_PLATFORM_FREE_MACRO):
85 * - Dynamic setup via mbedtls_platform_set_calloc_free is now possible with a default value MBEDTLS_PLATFORM_STD_CALLOC.
86 * - How is MBEDTLS_PLATFORM_STD_CALLOC handled?
87 * - if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS:
88 * - MBEDTLS_PLATFORM_STD_CALLOC is not set to anything;
89 * - MBEDTLS_PLATFORM_STD_MEM_HDR can be included if present;
90 * - if !MBEDTLS_PLATFORM_NO_STD_FUNCTIONS:
91 * - if MBEDTLS_PLATFORM_STD_CALLOC is present:
92 * - User-defined MBEDTLS_PLATFORM_STD_CALLOC is respected;
93 * - if !MBEDTLS_PLATFORM_STD_CALLOC:
94 * - MBEDTLS_PLATFORM_STD_CALLOC = calloc
95 *
96 * - At this point the presence of MBEDTLS_PLATFORM_STD_CALLOC is checked.
97 * - if !MBEDTLS_PLATFORM_STD_CALLOC
98 * - MBEDTLS_PLATFORM_STD_CALLOC = uninitialized_calloc
99 *
100 * - mbedtls_calloc = MBEDTLS_PLATFORM_STD_CALLOC.
101 *
102 * Defining MBEDTLS_PLATFORM_CALLOC_MACRO and #MBEDTLS_PLATFORM_STD_CALLOC at the same time is not possible.
103 * MBEDTLS_PLATFORM_CALLOC_MACRO and MBEDTLS_PLATFORM_FREE_MACRO must both be defined or undefined at the same time.
104 * #MBEDTLS_PLATFORM_STD_CALLOC and #MBEDTLS_PLATFORM_STD_FREE do not have to be defined at the same time, as, if they are used,
105 * dynamic setup of these functions is possible. See the tree above to see how are they handled in all cases.
106 * An uninitialized #MBEDTLS_PLATFORM_STD_CALLOC always fails, returning a null pointer.
107 * An uninitialized #MBEDTLS_PLATFORM_STD_FREE does not do anything.
108 *
109 * Requires: MBEDTLS_PLATFORM_C
110 *
111 * Enable this layer to allow use of alternative memory allocators.
112 */
113#define MBEDTLS_PLATFORM_MEMORY
114
115/**
116 * \def MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
117 *
118 * Do not assign standard functions in the platform layer (e.g. calloc() to
119 * MBEDTLS_PLATFORM_STD_CALLOC and printf() to MBEDTLS_PLATFORM_STD_PRINTF)
120 *
121 * This makes sure there are no linking errors on platforms that do not support
122 * these functions. You will HAVE to provide alternatives, either at runtime
123 * via the platform_set_xxx() functions or at compile time by setting
124 * the MBEDTLS_PLATFORM_STD_XXX defines, or enabling a
125 * MBEDTLS_PLATFORM_XXX_MACRO.
126 *
127 * Requires: MBEDTLS_PLATFORM_C
128 *
129 * Uncomment to prevent default assignment of standard functions in the
130 * platform layer.
131 */
132#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
133
134#define MBEDTLS_PLATFORM_PRINTF_ALT
135
136/* To use the following function macros, MBEDTLS_PLATFORM_C must be enabled. */
137/* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */
138
139#include <stdio.h>
140
141#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf
142#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE
143#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS
144
145#define MBEDTLS_PLATFORM_STD_MEM_HDR <stdlib.h>
146
147/** \} name SECTION: Platform abstraction layer */
148
149/**
150 * \name SECTION: SECTION Cryptographic mechanism selection (PSA API)
151 *
152 * This section sets PSA API settings.
153 * \{
154 */
Aditya Deshpande16a62e32023-04-11 16:25:02 +0100155/*
156 * CBC-MAC is not yet supported via the PSA API in Mbed TLS.
157 */
158//#define PSA_WANT_ALG_CBC_MAC 1
159//#define PSA_WANT_ALG_CBC_NO_PADDING 1
160//#define PSA_WANT_ALG_CBC_PKCS7 1
161#define PSA_WANT_ALG_CCM 1
162//#define PSA_WANT_ALG_CMAC 1
163//#define PSA_WANT_ALG_CFB 1
164//#define PSA_WANT_ALG_CHACHA20_POLY1305 1
165//#define PSA_WANT_ALG_CTR 1
Dave Rodgman4edcf692023-11-15 12:23:29 +0000166//#define PSA_WANT_ALG_DETERMINISTIC_ECDSA 1
Aditya Deshpande16a62e32023-04-11 16:25:02 +0100167//#define PSA_WANT_ALG_ECB_NO_PADDING 1
168#define PSA_WANT_ALG_ECDH 1
169#define PSA_WANT_ALG_ECDSA 1
170//#define PSA_WANT_ALG_GCM 1
171#define PSA_WANT_ALG_HKDF 1
172#define PSA_WANT_ALG_HMAC 1
173//#define PSA_WANT_ALG_MD5 1
174//#define PSA_WANT_ALG_OFB 1
175/* PBKDF2-HMAC is not yet supported via the PSA API in Mbed TLS.
176 * Note: when adding support, also adjust include/mbedtls/config_psa.h */
177//#define PSA_WANT_ALG_PBKDF2_HMAC 1
178//#define PSA_WANT_ALG_RIPEMD160 1
179//#define PSA_WANT_ALG_RSA_OAEP 1
180//#define PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1
181//#define PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1
182//#define PSA_WANT_ALG_RSA_PSS 1
183//#define PSA_WANT_ALG_SHA_1 1
184#define PSA_WANT_ALG_SHA_224 1
185#define PSA_WANT_ALG_SHA_256 1
186//#define PSA_WANT_ALG_SHA_384 1
187//#define PSA_WANT_ALG_SHA_512 1
188//#define PSA_WANT_ALG_STREAM_CIPHER 1
189#define PSA_WANT_ALG_TLS12_PRF 1
190#define PSA_WANT_ALG_TLS12_PSK_TO_MS 1
191/* PBKDF2-HMAC is not yet supported via the PSA API in Mbed TLS.
192 * Note: when adding support, also adjust include/mbedtls/config_psa.h */
193//#define PSA_WANT_ALG_XTS 1
194
195//#define PSA_WANT_ECC_BRAINPOOL_P_R1_256 1
196//#define PSA_WANT_ECC_BRAINPOOL_P_R1_384 1
197//#define PSA_WANT_ECC_BRAINPOOL_P_R1_512 1
198//#define PSA_WANT_ECC_MONTGOMERY_255 1
199//#define PSA_WANT_ECC_MONTGOMERY_448 1
200//#define PSA_WANT_ECC_SECP_K1_192 1
Aditya Deshpande16a62e32023-04-11 16:25:02 +0100201//#define PSA_WANT_ECC_SECP_K1_256 1
202//#define PSA_WANT_ECC_SECP_R1_192 1
203//#define PSA_WANT_ECC_SECP_R1_224 1
204#define PSA_WANT_ECC_SECP_R1_256 1
205//#define PSA_WANT_ECC_SECP_R1_384 1
206//#define PSA_WANT_ECC_SECP_R1_521 1
207
208#define PSA_WANT_KEY_TYPE_DERIVE 1
209#define PSA_WANT_KEY_TYPE_HMAC 1
210#define PSA_WANT_KEY_TYPE_AES 1
211//#define PSA_WANT_KEY_TYPE_ARIA 1
212//#define PSA_WANT_KEY_TYPE_CAMELLIA 1
213//#define PSA_WANT_KEY_TYPE_CHACHA20 1
214//#define PSA_WANT_KEY_TYPE_DES 1
Dave Rodgman4edcf692023-11-15 12:23:29 +0000215//#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR 1 /* Deprecated */
216#define PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
217#define PSA_WANT_KEY_TYPE_RAW_DATA 1
218//#define PSA_WANT_KEY_TYPE_RSA_KEY_PAIR 1 /* Deprecated */
219//#define PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1
220
221/*
222 * The following symbols extend and deprecate the legacy
223 * PSA_WANT_KEY_TYPE_xxx_KEY_PAIR ones. They include the usage of that key in
224 * the name's suffix. "_USE" is the most generic and it can be used to describe
225 * a generic suport, whereas other ones add more features on top of that and
226 * they are more specific.
227 */
228#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC 1
Valerio Settiae064432023-06-26 12:13:38 +0200229#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT 1
230#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT 1
231#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE 1
Dave Rodgman4edcf692023-11-15 12:23:29 +0000232//#define PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE 1
Aditya Deshpande16a62e32023-04-11 16:25:02 +0100233
Ronald Cron26540812024-12-05 16:52:17 +0100234/** \} name SECTION Cryptographic mechanism selection (PSA API) */
235
236/**
237 * \name SECTION: PSA core
238 *
239 * This section sets PSA specific settings.
240 * \{
241 */
242
243/**
244 * \def MBEDTLS_ENTROPY_C
245 *
246 * Enable the platform-specific entropy code.
247 *
248 * Module: library/entropy.c
249 * Caller:
250 *
251 * Requires: MBEDTLS_SHA512_C or MBEDTLS_SHA256_C
252 *
253 * This module provides a generic entropy pool
254 */
255#define MBEDTLS_ENTROPY_C
256
257/**
258 * \def MBEDTLS_ENTROPY_NV_SEED
259 *
260 * Enable the non-volatile (NV) seed file-based entropy source.
261 * (Also enables the NV seed read/write functions in the platform layer)
262 *
263 * This is crucial (if not required) on systems that do not have a
264 * cryptographic entropy source (in hardware or kernel) available.
265 *
266 * Requires: MBEDTLS_ENTROPY_C, MBEDTLS_PLATFORM_C
267 *
268 * \note The read/write functions that are used by the entropy source are
269 * determined in the platform layer, and can be modified at runtime and/or
270 * compile-time depending on the flags (MBEDTLS_PLATFORM_NV_SEED_*) used.
271 *
272 * \note If you use the default implementation functions that read a seedfile
273 * with regular fopen(), please make sure you make a seedfile with the
274 * proper name (defined in MBEDTLS_PLATFORM_STD_NV_SEED_FILE) and at
275 * least MBEDTLS_ENTROPY_BLOCK_SIZE bytes in size that can be read from
276 * and written to or you will get an entropy source error! The default
277 * implementation will only use the first MBEDTLS_ENTROPY_BLOCK_SIZE
278 * bytes from the file.
279 *
280 * \note The entropy collector will write to the seed file before entropy is
281 * given to an external source, to update it.
282 */
283#define MBEDTLS_ENTROPY_NV_SEED
284
285/**
286 * \def MBEDTLS_NO_PLATFORM_ENTROPY
287 *
288 * Do not use built-in platform entropy functions.
289 * This is useful if your platform does not support
290 * standards like the /dev/urandom or Windows CryptoAPI.
291 *
292 * Uncomment this macro to disable the built-in platform entropy functions.
293 */
294#define MBEDTLS_NO_PLATFORM_ENTROPY
295
296/**
297 * \def MBEDTLS_PSA_CRYPTO_C
298 *
299 * Enable the Platform Security Architecture cryptography API.
300 *
301 * Module: library/psa_crypto.c
302 *
303 * Requires: either MBEDTLS_CTR_DRBG_C and MBEDTLS_ENTROPY_C,
304 * or MBEDTLS_HMAC_DRBG_C and MBEDTLS_ENTROPY_C,
305 * or MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG.
306 * Auto-enables: MBEDTLS_CIPHER_C if any unauthenticated (ie, non-AEAD) cipher
307 * is enabled in PSA (unless it's fully accelerated, see
308 * docs/driver-only-builds.md about that).
309 */
310#define MBEDTLS_PSA_CRYPTO_C
311
312/**
313 * \def MBEDTLS_PSA_CRYPTO_SPM
314 *
315 * When MBEDTLS_PSA_CRYPTO_SPM is defined, the code is built for SPM (Secure
316 * Partition Manager) integration which separates the code into two parts: a
317 * NSPE (Non-Secure Process Environment) and an SPE (Secure Process
318 * Environment).
319 *
320 * If you enable this option, your build environment must include a header
321 * file `"crypto_spe.h"` (either in the `psa` subdirectory of the Mbed TLS
322 * header files, or in another directory on the compiler's include search
323 * path). Alternatively, your platform may customize the header
324 * `psa/crypto_platform.h`, in which case it can skip or replace the
325 * inclusion of `"crypto_spe.h"`.
326 *
327 * Module: library/psa_crypto.c
328 * Requires: MBEDTLS_PSA_CRYPTO_C
329 *
330 */
331#define MBEDTLS_PSA_CRYPTO_SPM
332
333/**
334 * \def MBEDTLS_PSA_CRYPTO_STORAGE_C
335 *
336 * Enable the Platform Security Architecture persistent key storage.
337 *
338 * Module: library/psa_crypto_storage.c
339 *
340 * Requires: MBEDTLS_PSA_CRYPTO_C,
341 * either MBEDTLS_PSA_ITS_FILE_C or a native implementation of
342 * the PSA ITS interface
343 */
344#define MBEDTLS_PSA_CRYPTO_STORAGE_C
345
346/** \} name SECTION: PSA core */
347
348/**
349 * \name SECTION: Builtin drivers
350 *
351 * This section sets driver specific settings.
352 * \{
353 */
354
355/**
356 * \def MBEDTLS_AES_ROM_TABLES
357 *
358 * Use precomputed AES tables stored in ROM.
359 *
360 * Uncomment this macro to use precomputed AES tables stored in ROM.
361 * Comment this macro to generate AES tables in RAM at runtime.
362 *
363 * Tradeoff: Using precomputed ROM tables reduces RAM usage by ~8kb
364 * (or ~2kb if \c MBEDTLS_AES_FEWER_TABLES is used) and reduces the
365 * initialization time before the first AES operation can be performed.
366 * It comes at the cost of additional ~8kb ROM use (resp. ~2kb if \c
367 * MBEDTLS_AES_FEWER_TABLES below is used), and potentially degraded
368 * performance if ROM access is slower than RAM access.
369 *
370 * This option is independent of \c MBEDTLS_AES_FEWER_TABLES.
371 */
372#define MBEDTLS_AES_ROM_TABLES
373
374/**
375 * \def MBEDTLS_AES_FEWER_TABLES
376 *
377 * Use less ROM/RAM for AES tables.
378 *
379 * Uncommenting this macro omits 75% of the AES tables from
380 * ROM / RAM (depending on the value of \c MBEDTLS_AES_ROM_TABLES)
381 * by computing their values on the fly during operations
382 * (the tables are entry-wise rotations of one another).
383 *
384 * Tradeoff: Uncommenting this reduces the RAM / ROM footprint
385 * by ~6kb but at the cost of more arithmetic operations during
386 * runtime. Specifically, one has to compare 4 accesses within
387 * different tables to 4 accesses with additional arithmetic
388 * operations within the same table. The performance gain/loss
389 * depends on the system and memory details.
390 *
391 * This option is independent of \c MBEDTLS_AES_ROM_TABLES.
392 */
393#define MBEDTLS_AES_FEWER_TABLES
394
395/**
396 * \def MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH
397 *
398 * Use only 128-bit keys in AES operations to save ROM.
399 *
400 * Uncomment this macro to remove support for AES operations that use 192-
401 * or 256-bit keys.
402 *
403 * Uncommenting this macro reduces the size of AES code by ~300 bytes
404 * on v8-M/Thumb2.
405 *
406 * Module: library/aes.c
407 *
408 * Requires: MBEDTLS_AES_C
409 */
410#define MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH
411
412/**
413 * \def MBEDTLS_ECP_NIST_OPTIM
414 *
415 * Enable specific 'modulo p' routines for each NIST prime.
416 * Depending on the prime and architecture, makes operations 4 to 8 times
417 * faster on the corresponding curve.
418 *
419 * Comment this macro to disable NIST curves optimisation.
420 */
421#define MBEDTLS_ECP_NIST_OPTIM
422
423/**
424 * \def MBEDTLS_HAVE_ASM
425 *
426 * The compiler has support for asm().
427 *
428 * Requires support for asm() in compiler.
429 *
430 * Used in:
431 * library/aesni.h
432 * library/aria.c
433 * library/bn_mul.h
434 * library/constant_time.c
435 *
436 * Required by:
437 * MBEDTLS_AESCE_C
438 * MBEDTLS_AESNI_C (on some platforms)
439 *
440 * Comment to disable the use of assembly code.
441 */
442#define MBEDTLS_HAVE_ASM
443
444/**
445 * Uncomment to enable p256-m. This is an alternative implementation of
446 * key generation, ECDH and (randomized) ECDSA on the curve SECP256R1.
447 * Compared to the default implementation:
448 *
449 * - p256-m has a much smaller code size and RAM footprint.
450 * - p256-m is only available via the PSA API. This includes the pk module.
451 * - p256-m does not support deterministic ECDSA, EC-JPAKE, custom protocols
452 * over the core arithmetic, or deterministic derivation of keys.
453 *
454 * We recommend enabling this option if your application uses the PSA API
455 * and the only elliptic curve support it needs is ECDH and ECDSA over
456 * SECP256R1.
457 *
458 * If you enable this option, you do not need to enable any ECC-related
459 * MBEDTLS_xxx option. You do need to separately request support for the
460 * cryptographic mechanisms through the PSA API:
461 * - #MBEDTLS_PSA_CRYPTO_C for PSA-based configuration;
462 * - #PSA_WANT_ECC_SECP_R1_256;
463 * - #PSA_WANT_ALG_ECDH and/or #PSA_WANT_ALG_ECDSA as needed;
464 * - #PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY, #PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC,
465 * #PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT,
466 * #PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT and/or
467 * #PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE as needed.
468 *
469 * \note To benefit from the smaller code size of p256-m, make sure that you
470 * do not enable any ECC-related option not supported by p256-m: this
471 * would cause the built-in ECC implementation to be built as well, in
472 * order to provide the required option.
473 * Make sure #PSA_WANT_ALG_DETERMINISTIC_ECDSA, #PSA_WANT_ALG_JPAKE and
474 * #PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE, and curves other than
475 * SECP256R1 are disabled as they are not supported by this driver.
476 * Also, avoid defining #MBEDTLS_PK_PARSE_EC_COMPRESSED or
477 * #MBEDTLS_PK_PARSE_EC_EXTENDED as those currently require a subset of
478 * the built-in ECC implementation, see docs/driver-only-builds.md.
479 */
480#define MBEDTLS_PSA_P256M_DRIVER_ENABLED
481
482/**
483 * \def MBEDTLS_SHA256_SMALLER
484 *
485 * Enable an implementation of SHA-256 that has lower ROM footprint but also
486 * lower performance.
487 *
488 * The default implementation is meant to be a reasonable compromise between
489 * performance and size. This version optimizes more aggressively for size at
490 * the expense of performance. Eg on Cortex-M4 it reduces the size of
491 * mbedtls_sha256_process() from ~2KB to ~0.5KB for a performance hit of about
492 * 30%.
493 *
494 * Uncomment to enable the smaller implementation of SHA256.
495 */
496#define MBEDTLS_SHA256_SMALLER
497
498/* ECP options */
499#define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Disable fixed-point speed-up */
500
501/** \} name SECTION: Builtin drivers */
502
503/**
504 * \name SECTION: Legacy cryptography
505 *
506 * This section sets legacy settings.
507 * \{
508 */
509
510/**
511 * \def MBEDTLS_AES_C
512 *
513 * Enable the AES block cipher.
514 *
515 * Module: library/aes.c
516 * Caller: library/cipher.c
517 * library/pem.c
518 * library/ctr_drbg.c
519 *
520 * This module enables the following ciphersuites (if other requisites are
521 * enabled as well):
522 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
523 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
524 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
525 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
526 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
527 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
528 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
529 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
530 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
531 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
532 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
533 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
534 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
535 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
536 * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
537 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
538 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
539 * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
540 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
541 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
542 * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA
543 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
544 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
545 * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
546 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
547 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
548 * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
549 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
550 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
551 * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA
Ronald Cron26540812024-12-05 16:52:17 +0100552 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384
Ronald Cron26540812024-12-05 16:52:17 +0100553 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA
Ronald Cron26540812024-12-05 16:52:17 +0100554 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256
Ronald Cron26540812024-12-05 16:52:17 +0100555 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA
Ronald Cron26540812024-12-05 16:52:17 +0100556 * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384
557 * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256
558 * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA
559 * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256
560 * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256
561 * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA
562 * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384
563 * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384
564 * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA
565 * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256
566 * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256
567 * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA
568 *
569 * PEM_PARSE uses AES for decrypting encrypted keys.
570 */
571#define MBEDTLS_AES_C
572
573/**
574 * \def MBEDTLS_CIPHER_C
575 *
576 * Enable the generic cipher layer.
577 *
578 * Module: library/cipher.c
579 * Caller: library/ccm.c
580 * library/cmac.c
581 * library/gcm.c
582 * library/nist_kw.c
583 * library/pkcs12.c
584 * library/pkcs5.c
585 * library/psa_crypto_aead.c
586 * library/psa_crypto_mac.c
587 * library/ssl_ciphersuites.c
588 * library/ssl_msg.c
589 * Auto-enabled by: MBEDTLS_PSA_CRYPTO_C depending on which ciphers are enabled
590 * (see the documentation of that option for details).
591 *
592 * Uncomment to enable generic cipher wrappers.
593 */
594#define MBEDTLS_CIPHER_C
595
596/**
597 * \def MBEDTLS_CTR_DRBG_C
598 *
599 * Enable the CTR_DRBG AES-based random generator.
600 * The CTR_DRBG generator uses AES-256 by default.
601 * To use AES-128 instead, enable \c MBEDTLS_CTR_DRBG_USE_128_BIT_KEY above.
602 *
603 * AES support can either be achieved through builtin (MBEDTLS_AES_C) or PSA.
604 * Builtin is the default option when MBEDTLS_AES_C is defined otherwise PSA
605 * is used.
606 *
607 * \warning When using PSA, the user should call `psa_crypto_init()` before
608 * using any CTR_DRBG operation (except `mbedtls_ctr_drbg_init()`).
609 *
610 * \note AES-128 will be used if \c MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH is set.
611 *
612 * \note To achieve a 256-bit security strength with CTR_DRBG,
613 * you must use AES-256 *and* use sufficient entropy.
614 * See ctr_drbg.h for more details.
615 *
616 * Module: library/ctr_drbg.c
617 * Caller:
618 *
619 * Requires: MBEDTLS_AES_C or
620 * (PSA_WANT_KEY_TYPE_AES and PSA_WANT_ALG_ECB_NO_PADDING and
621 * MBEDTLS_PSA_CRYPTO_C)
622 *
623 * This module provides the CTR_DRBG AES random number generator.
624 */
625#define MBEDTLS_CTR_DRBG_C
626/** \} name SECTION: Legacy cryptography */
627
Minos Galanakisbca85e62024-11-01 17:32:54 +0000628/***********************************************************/
629/* Tweak the configuration to remove dependencies on TF-M. */
630/***********************************************************/
631
632/* MBEDTLS_PSA_CRYPTO_SPM needs third-party files, so disable it. */
633#undef MBEDTLS_PSA_CRYPTO_SPM
634
635/* Disable buffer-based memory allocator. This isn't strictly required,
636 * but using the native allocator is faster and works better with
637 * memory management analysis frameworks such as ASan. */
638#undef MBEDTLS_MEMORY_BUFFER_ALLOC_C
639
640// This macro is enabled in TFM Medium but is disabled here because it is
641// incompatible with baremetal builds in Mbed TLS.
642#undef MBEDTLS_PSA_CRYPTO_STORAGE_C
643
644// This macro is enabled in TFM Medium but is disabled here because it is
645// incompatible with baremetal builds in Mbed TLS.
646#undef MBEDTLS_ENTROPY_NV_SEED
647
648// These platform-related TF-M settings are not useful here.
649#undef MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
650#undef MBEDTLS_PLATFORM_STD_MEM_HDR
651#undef MBEDTLS_PLATFORM_SNPRINTF_MACRO
652#undef MBEDTLS_PLATFORM_PRINTF_ALT
653#undef MBEDTLS_PLATFORM_STD_EXIT_SUCCESS
654#undef MBEDTLS_PLATFORM_STD_EXIT_FAILURE
655
656/*
657 * In order to get an example config that works cleanly out-of-the-box
658 * for both baremetal and non-baremetal builds, we detect baremetal builds
659 * (either IAR, Arm compiler or __ARM_EABI__ defined), and adjust some
660 * variables accordingly.
661 */
662#if defined(__IAR_SYSTEMS_ICC__) || defined(__ARMCC_VERSION) || defined(__ARM_EABI__)
663#define MBEDTLS_NO_PLATFORM_ENTROPY
664#else
665/* Use built-in platform entropy functions (TF-M provides its own). */
666#undef MBEDTLS_NO_PLATFORM_ENTROPY
667#endif
668
669/***********************************************************************
670 * Local changes to crypto config below this delimiter
671 **********************************************************************/
672
673// We expect TF-M to pick this up soon
674#define MBEDTLS_BLOCK_CIPHER_NO_DECRYPT
675
676/* CCM is the only cipher/AEAD enabled in TF-M configuration files, but it
677 * does not need CIPHER_C to be enabled, so we can disable it in order
678 * to reduce code size further. */
679#undef MBEDTLS_CIPHER_C
680
Ronald Cron26540812024-12-05 16:52:17 +0100681#if CRYPTO_NV_SEED
682#include "tfm_mbedcrypto_config_extra_nv_seed.h"
683#endif /* CRYPTO_NV_SEED */
684
685#if !defined(CRYPTO_HW_ACCELERATOR) && defined(MBEDTLS_ENTROPY_NV_SEED)
686#include "mbedtls_entropy_nv_seed_config.h"
687#endif
688
Dave Rodgman4edcf692023-11-15 12:23:29 +0000689#ifdef CRYPTO_HW_ACCELERATOR
690#include "crypto_accelerator_config.h"
691#endif
Valerio Setti52e0fb42023-08-02 09:55:21 +0200692
Aditya Deshpande16a62e32023-04-11 16:25:02 +0100693#endif /* PROFILE_M_PSA_CRYPTO_CONFIG_H */