blob: d143d7351f7d93332d717aa1fbf33a1f03bf93cf [file] [log] [blame]
Juan Castilloa57a4d52015-04-02 15:44:20 +01001/*
John Tsichritzis30f89642018-06-07 16:31:34 +01002 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
Juan Castilloa57a4d52015-04-02 15:44:20 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Juan Castilloa57a4d52015-04-02 15:44:20 +01005 */
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00006#ifndef MBEDTLS_CONFIG_H
7#define MBEDTLS_CONFIG_H
Juan Castilloa57a4d52015-04-02 15:44:20 +01008
9/*
Juan Castillobae6b2a2015-11-05 09:24:53 +000010 * Key algorithms currently supported on mbed TLS libraries
Juan Castilloa57a4d52015-04-02 15:44:20 +010011 */
Qixiang Xu1c2aef12017-08-24 15:12:20 +080012#define TF_MBEDTLS_RSA 1
13#define TF_MBEDTLS_ECDSA 2
Qixiang Xuaa05eea2017-08-24 15:26:39 +080014#define TF_MBEDTLS_RSA_AND_ECDSA 3
Juan Castilloa57a4d52015-04-02 15:44:20 +010015
16/*
Qixiang Xu1a1f2912017-11-09 13:56:29 +080017 * Hash algorithms currently supported on mbed TLS libraries
18 */
19#define TF_MBEDTLS_SHA256 1
20#define TF_MBEDTLS_SHA384 2
21#define TF_MBEDTLS_SHA512 3
22
23/*
Juan Castillobae6b2a2015-11-05 09:24:53 +000024 * Configuration file to build mbed TLS with the required features for
Juan Castilloa57a4d52015-04-02 15:44:20 +010025 * Trusted Boot
26 */
27
Juan Castillobae6b2a2015-11-05 09:24:53 +000028#define MBEDTLS_PLATFORM_MEMORY
29#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
Antonio Nino Diaz6b90f5e2017-05-19 11:37:22 +010030/* Prevent mbed TLS from using snprintf so that it can use tf_snprintf. */
31#define MBEDTLS_PLATFORM_SNPRINTF_ALT
Juan Castilloa57a4d52015-04-02 15:44:20 +010032
Juan Castillobae6b2a2015-11-05 09:24:53 +000033#define MBEDTLS_PKCS1_V21
Juan Castilloa57a4d52015-04-02 15:44:20 +010034
Juan Castillobae6b2a2015-11-05 09:24:53 +000035#define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
36#define MBEDTLS_X509_CHECK_KEY_USAGE
37#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE
Juan Castilloa57a4d52015-04-02 15:44:20 +010038
Juan Castillobae6b2a2015-11-05 09:24:53 +000039#define MBEDTLS_ASN1_PARSE_C
40#define MBEDTLS_ASN1_WRITE_C
Juan Castilloa57a4d52015-04-02 15:44:20 +010041
Juan Castillobae6b2a2015-11-05 09:24:53 +000042#define MBEDTLS_BASE64_C
43#define MBEDTLS_BIGNUM_C
Juan Castilloa57a4d52015-04-02 15:44:20 +010044
Juan Castillobae6b2a2015-11-05 09:24:53 +000045#define MBEDTLS_ERROR_C
46#define MBEDTLS_MD_C
Juan Castilloa57a4d52015-04-02 15:44:20 +010047
Juan Castillobae6b2a2015-11-05 09:24:53 +000048#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
49#define MBEDTLS_OID_C
Juan Castilloa57a4d52015-04-02 15:44:20 +010050
Juan Castillobae6b2a2015-11-05 09:24:53 +000051#define MBEDTLS_PK_C
52#define MBEDTLS_PK_PARSE_C
53#define MBEDTLS_PK_WRITE_C
Juan Castilloa57a4d52015-04-02 15:44:20 +010054
Juan Castillobae6b2a2015-11-05 09:24:53 +000055#define MBEDTLS_PLATFORM_C
Juan Castilloa57a4d52015-04-02 15:44:20 +010056
David Cunadoc7a1b192017-05-10 16:38:44 +010057#if (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_ECDSA)
Juan Castillobae6b2a2015-11-05 09:24:53 +000058#define MBEDTLS_ECDSA_C
59#define MBEDTLS_ECP_C
60#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
David Cunadoc7a1b192017-05-10 16:38:44 +010061#elif (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA)
Juan Castillobae6b2a2015-11-05 09:24:53 +000062#define MBEDTLS_RSA_C
Qixiang Xu1c2aef12017-08-24 15:12:20 +080063#define MBEDTLS_X509_RSASSA_PSS_SUPPORT
Qixiang Xuaa05eea2017-08-24 15:26:39 +080064#elif (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA_AND_ECDSA)
65#define MBEDTLS_RSA_C
66#define MBEDTLS_X509_RSASSA_PSS_SUPPORT
67#define MBEDTLS_ECDSA_C
68#define MBEDTLS_ECP_C
69#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
Juan Castilloa57a4d52015-04-02 15:44:20 +010070#endif
71
Juan Castillobae6b2a2015-11-05 09:24:53 +000072#define MBEDTLS_SHA256_C
Qixiang Xu1a1f2912017-11-09 13:56:29 +080073#if (TF_MBEDTLS_HASH_ALG_ID != TF_MBEDTLS_SHA256)
74#define MBEDTLS_SHA512_C
75#endif
Juan Castilloa57a4d52015-04-02 15:44:20 +010076
Juan Castillobae6b2a2015-11-05 09:24:53 +000077#define MBEDTLS_VERSION_C
Juan Castilloa57a4d52015-04-02 15:44:20 +010078
Juan Castillobae6b2a2015-11-05 09:24:53 +000079#define MBEDTLS_X509_USE_C
80#define MBEDTLS_X509_CRT_PARSE_C
Juan Castilloa57a4d52015-04-02 15:44:20 +010081
82/* MPI / BIGNUM options */
Juan Castillobae6b2a2015-11-05 09:24:53 +000083#define MBEDTLS_MPI_WINDOW_SIZE 2
84#define MBEDTLS_MPI_MAX_SIZE 256
Juan Castilloa57a4d52015-04-02 15:44:20 +010085
86/* Memory buffer allocator options */
Juan Castillobae6b2a2015-11-05 09:24:53 +000087#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 8
Juan Castilloa57a4d52015-04-02 15:44:20 +010088
Qixiang Xude431b12017-10-13 09:23:42 +080089#ifndef __ASSEMBLY__
90/* System headers required to build mbed TLS with the current configuration */
91#include <stdlib.h>
Juan Castillobae6b2a2015-11-05 09:24:53 +000092#include "mbedtls/check_config.h"
Qixiang Xude431b12017-10-13 09:23:42 +080093#endif
Juan Castilloa57a4d52015-04-02 15:44:20 +010094
John Tsichritzis30f89642018-06-07 16:31:34 +010095/*
96 * Determine Mbed TLS heap size
97 * 13312 = 13*1024
98 * 7168 = 7*1024
99 */
100#if (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_ECDSA) \
101 || (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA_AND_ECDSA)
102#define TF_MBEDTLS_HEAP_SIZE U(13312)
103#elif (TF_MBEDTLS_KEY_ALG_ID == TF_MBEDTLS_RSA)
104#define TF_MBEDTLS_HEAP_SIZE U(7168)
105#endif
106
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +0000107#endif /* MBEDTLS_CONFIG_H */