blob: 198481363a95dc469289986ad6094a11e6514bd7 [file] [log] [blame]
Bence Szépkúti5ab73032021-05-27 11:25:03 +02001/**
Ronald Cron135f2ae2023-02-08 12:25:38 +01002 * \file mbedtls/build_info.h
Bence Szépkúti5ab73032021-05-27 11:25:03 +02003 *
4 * \brief Build-time configuration info
5 *
6 * Include this file if you need to depend on the
Bence Szépkútie55a8212021-06-28 15:15:56 +01007 * configuration options defined in mbedtls_config.h or MBEDTLS_CONFIG_FILE
Bence Szépkúti5ab73032021-05-27 11:25:03 +02008 */
Gilles Peskine449bd832023-01-11 14:50:10 +01009/*
10 * Copyright The Mbed TLS Contributors
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License"); you may
14 * not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
21 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 */
Bence Szépkúti5ab73032021-05-27 11:25:03 +020025
26#ifndef MBEDTLS_BUILD_INFO_H
27#define MBEDTLS_BUILD_INFO_H
28
Bence Szépkúti04982f72021-06-21 14:40:51 +020029/*
30 * This set of compile-time defines can be used to determine the version number
Bence Szépkúti1b2a8832021-06-28 10:26:11 +010031 * of the Mbed TLS library used. Run-time variables for the same can be found in
Bence Szépkúti04982f72021-06-21 14:40:51 +020032 * version.h
33 */
34
35/**
36 * The version number x.y.z is split into three parts.
37 * Major, Minor, Patchlevel
38 */
Dave Rodgman1bc9e932021-07-01 09:20:13 +010039#define MBEDTLS_VERSION_MAJOR 3
Paul Elliottdb67e992023-03-23 10:57:39 +000040#define MBEDTLS_VERSION_MINOR 4
Gilles Peskine550d1472023-08-02 12:50:23 +020041#define MBEDTLS_VERSION_PATCH 1
Bence Szépkúti04982f72021-06-21 14:40:51 +020042
43/**
44 * The single version number has the following structure:
45 * MMNNPP00
46 * Major version | Minor version | Patch version
47 */
Gilles Peskine550d1472023-08-02 12:50:23 +020048#define MBEDTLS_VERSION_NUMBER 0x03040100
49#define MBEDTLS_VERSION_STRING "3.4.1"
50#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 3.4.1"
Bence Szépkúti04982f72021-06-21 14:40:51 +020051
Jerry Yu926221a2023-08-18 15:09:02 +080052/* Macros for build-time platform detection */
53
54#if !defined(MBEDTLS_ARCH_IS_ARM64) && \
55 (defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC))
56#define MBEDTLS_ARCH_IS_ARM64
57#endif
58
59#if !defined(MBEDTLS_ARCH_IS_ARM32) && \
60 (defined(__arm__) || defined(_M_ARM) || \
61 defined(_M_ARMT) || defined(__thumb__) || defined(__thumb2__))
62#define MBEDTLS_ARCH_IS_ARM32
63#endif
64
65#if !defined(MBEDTLS_ARCH_IS_X64) && \
66 (defined(__amd64__) || defined(__x86_64__) || \
67 ((defined(_M_X64) || defined(_M_AMD64)) && !defined(_M_ARM64EC)))
68#define MBEDTLS_ARCH_IS_X64
69#endif
70
71#if !defined(MBEDTLS_ARCH_IS_X86) && \
72 (defined(__i386__) || defined(_X86_) || \
73 (defined(_M_IX86) && !defined(_M_I86)))
74#define MBEDTLS_ARCH_IS_X86
75#endif
76/* Macros for build-time platform detection */
77
78#if !defined(MBEDTLS_ARCH_IS_ARM64) && \
79 (defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC))
80#define MBEDTLS_ARCH_IS_ARM64
81#endif
82
83#if !defined(MBEDTLS_ARCH_IS_ARM32) && \
84 (defined(__arm__) || defined(_M_ARM) || \
85 defined(_M_ARMT) || defined(__thumb__) || defined(__thumb2__))
86#define MBEDTLS_ARCH_IS_ARM32
87#endif
88
89#if !defined(MBEDTLS_ARCH_IS_X64) && \
90 (defined(__amd64__) || defined(__x86_64__) || \
91 ((defined(_M_X64) || defined(_M_AMD64)) && !defined(_M_ARM64EC)))
92#define MBEDTLS_ARCH_IS_X64
93#endif
94
95#if !defined(MBEDTLS_ARCH_IS_X86) && \
96 (defined(__i386__) || defined(_X86_) || \
97 (defined(_M_IX86) && !defined(_M_I86)))
98#define MBEDTLS_ARCH_IS_X86
99#endif
100
Bence Szépkútic5c9eb42021-05-27 23:31:30 +0200101#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
102#define _CRT_SECURE_NO_DEPRECATE 1
103#endif
104
Gilles Peskine6157fee2022-11-23 16:13:13 +0100105/* Define `inline` on some non-C99-compliant compilers. */
Gilles Peskine449bd832023-01-11 14:50:10 +0100106#if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && \
Gilles Peskine6157fee2022-11-23 16:13:13 +0100107 !defined(inline) && !defined(__cplusplus)
108#define inline __inline
109#endif
110
Gilles Peskinea458d482023-05-17 23:13:06 +0200111/* X.509, TLS and non-PSA crypto configuration */
Bence Szépkúti5ab73032021-05-27 11:25:03 +0200112#if !defined(MBEDTLS_CONFIG_FILE)
Bence Szépkútibb0cfeb2021-05-28 09:42:25 +0200113#include "mbedtls/mbedtls_config.h"
Bence Szépkúti5ab73032021-05-27 11:25:03 +0200114#else
115#include MBEDTLS_CONFIG_FILE
116#endif
117
Bence Szépkúti1cafe5c2021-06-22 09:30:08 +0200118#if defined(MBEDTLS_CONFIG_VERSION) && ( \
119 MBEDTLS_CONFIG_VERSION < 0x03000000 || \
Gilles Peskine449bd832023-01-11 14:50:10 +0100120 MBEDTLS_CONFIG_VERSION > MBEDTLS_VERSION_NUMBER)
Bence Szépkútib2e23de2021-06-21 15:53:07 +0200121#error "Invalid config version, defined value of MBEDTLS_CONFIG_VERSION is unsupported"
Bence Szépkútiba7248a2021-05-31 16:53:56 +0200122#endif
123
Bence Szépkútic5c9eb42021-05-27 23:31:30 +0200124/* Target and application specific configurations
125 *
126 * Allow user to override any previous default.
127 *
128 */
129#if defined(MBEDTLS_USER_CONFIG_FILE)
130#include MBEDTLS_USER_CONFIG_FILE
131#endif
132
Gilles Peskinea458d482023-05-17 23:13:06 +0200133/* PSA crypto configuration */
134#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
135#if defined(MBEDTLS_PSA_CRYPTO_CONFIG_FILE)
136#include MBEDTLS_PSA_CRYPTO_CONFIG_FILE
137#else
138#include "psa/crypto_config.h"
139#endif
Gilles Peskinea458d482023-05-17 23:13:06 +0200140#if defined(MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE)
141#include MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE
142#endif
Gilles Peskine7b7ecf52023-05-17 23:15:31 +0200143#endif /* defined(MBEDTLS_PSA_CRYPTO_CONFIG) */
Gilles Peskinea458d482023-05-17 23:13:06 +0200144
Yanray Wang1ed226f2023-05-05 11:31:11 +0800145/* Auto-enable MBEDTLS_CTR_DRBG_USE_128_BIT_KEY if
146 * MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH and MBEDTLS_CTR_DRBG_C defined
147 * to ensure a 128-bit key size in CTR_DRBG.
148 */
149#if defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) && defined(MBEDTLS_CTR_DRBG_C)
150#define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
151#endif
152
Manuel Pégourié-Gonnard49e67f82023-03-16 11:39:20 +0100153/* Auto-enable MBEDTLS_MD_C if needed by a module that didn't require it
154 * in a previous release, to ensure backwards compatibility.
155 */
156#if defined(MBEDTLS_PKCS5_C)
157#define MBEDTLS_MD_C
158#endif
159
Yanray Wang419a55e2023-05-17 18:22:00 +0800160/* PSA crypto specific configuration options
161 * - If config_psa.h reads a configuration option in preprocessor directive,
Yanray Wang37db3322023-05-22 16:50:35 +0800162 * this symbol should be set before its inclusion. (e.g. MBEDTLS_MD_C)
Yanray Wang419a55e2023-05-17 18:22:00 +0800163 * - If config_psa.h writes a configuration option in conditional directive,
164 * this symbol should be consulted after its inclusion.
165 * (e.g. MBEDTLS_MD_LIGHT)
166 */
Yanray Wang63976732023-05-17 12:41:25 +0800167#if defined(MBEDTLS_PSA_CRYPTO_CONFIG) /* PSA_WANT_xxx influences MBEDTLS_xxx */ || \
168 defined(MBEDTLS_PSA_CRYPTO_C) /* MBEDTLS_xxx influences PSA_WANT_xxx */
169#include "mbedtls/config_psa.h"
170#endif
171
Manuel Pégourié-Gonnardb9b630d2023-02-16 19:07:31 +0100172/* Auto-enable MBEDTLS_MD_LIGHT based on MBEDTLS_MD_C.
173 * This allows checking for MD_LIGHT rather than MD_LIGHT || MD_C.
174 */
175#if defined(MBEDTLS_MD_C)
176#define MBEDTLS_MD_LIGHT
177#endif
178
Manuel Pégourié-Gonnard49e67f82023-03-16 11:39:20 +0100179/* Auto-enable MBEDTLS_MD_LIGHT if needed by a module that didn't require it
180 * in a previous release, to ensure backwards compatibility.
Manuel Pégourié-Gonnard83162092023-03-06 23:58:50 +0100181 */
Manuel Pégourié-Gonnard41bc8b62023-03-14 23:59:24 +0100182#if defined(MBEDTLS_ECJPAKE_C) || \
183 defined(MBEDTLS_PEM_PARSE_C) || \
Manuel Pégourié-Gonnard5cd4b642023-02-02 13:14:59 +0100184 defined(MBEDTLS_ENTROPY_C) || \
Manuel Pégourié-Gonnard9b41eb82023-03-28 11:14:24 +0200185 defined(MBEDTLS_PK_C) || \
Manuel Pégourié-Gonnardbe97afe2023-03-16 10:00:54 +0100186 defined(MBEDTLS_PKCS12_C) || \
Manuel Pégourié-Gonnard9b41eb82023-03-28 11:14:24 +0200187 defined(MBEDTLS_RSA_C) || \
Manuel Pégourié-Gonnard2d6d9932023-03-28 11:38:08 +0200188 defined(MBEDTLS_SSL_TLS_C) || \
189 defined(MBEDTLS_X509_USE_C) || \
190 defined(MBEDTLS_X509_CREATE_C)
Manuel Pégourié-Gonnard83162092023-03-06 23:58:50 +0100191#define MBEDTLS_MD_LIGHT
192#endif
193
Valerio Setti4922ba12023-06-14 11:30:30 +0200194/* MBEDTLS_ECP_LIGHT is auto-enabled by the following symbols:
195 * - MBEDTLS_ECP_C because now it consists of MBEDTLS_ECP_LIGHT plus functions
196 * for curve arithmetic. As a consequence if MBEDTLS_ECP_C is required for
197 * some reason, then MBEDTLS_ECP_LIGHT should be enabled as well.
198 * - MBEDTLS_PK_PARSE_EC_EXTENDED and MBEDTLS_PK_PARSE_EC_COMPRESSED because
199 * these features are not supported in PSA so the only way to have them is
200 * to enable the built-in solution.
Valerio Settia18385b2023-06-19 11:34:28 +0200201 * Both of them are temporary dependencies:
202 * - PK_PARSE_EC_EXTENDED will be removed after #7779 and #7789
203 * - support for compressed points should also be added to PSA, but in this
204 * case there is no associated issue to track it yet.
Valerio Setti4922ba12023-06-14 11:30:30 +0200205 * - PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE because Weierstrass key derivation
Valerio Settia18385b2023-06-19 11:34:28 +0200206 * still depends on ECP_LIGHT.
Valerio Setti4922ba12023-06-14 11:30:30 +0200207 * - PK_C + USE_PSA + PSA_WANT_ALG_ECDSA is a temporary dependency which will
Valerio Settia18385b2023-06-19 11:34:28 +0200208 * be fixed by #7453.
Valerio Setti4922ba12023-06-14 11:30:30 +0200209 */
210#if defined(MBEDTLS_ECP_C) || \
211 defined(MBEDTLS_PK_PARSE_EC_EXTENDED) || \
212 defined(MBEDTLS_PK_PARSE_EC_COMPRESSED) || \
Valerio Settif54ca352023-06-15 12:09:30 +0200213 defined(MBEDTLS_PSA_BUILTIN_KEY_TYPE_ECC_KEY_PAIR_DERIVE)
Valerio Settifd122f42023-04-05 18:15:32 +0200214#define MBEDTLS_ECP_LIGHT
215#endif
216
Valerio Settifdf15dd2023-06-16 12:50:34 +0200217/* MBEDTLS_PK_PARSE_EC_COMPRESSED is introduced in MbedTLS version 3.5, while
218 * in previous version compressed points were automatically supported as long
219 * as PK_PARSE_C and ECP_C were enabled. As a consequence, for backward
220 * compatibility, we auto-enable PK_PARSE_EC_COMPRESSED when these conditions
221 * are met. */
222#if defined(MBEDTLS_PK_PARSE_C) && defined(MBEDTLS_ECP_C)
223#define MBEDTLS_PK_PARSE_EC_COMPRESSED
224#endif
225
Valerio Settiaa7cbd62023-07-07 17:22:17 +0200226/* Helper symbol to state that there is support for ECDH, either through
227 * library implementation (ECDH_C) or through PSA. */
Valerio Settia15078b2023-07-06 14:52:45 +0200228#if (defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_ECDH)) || \
229 (!defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_ECDH_C))
Valerio Settiaa7cbd62023-07-07 17:22:17 +0200230#define MBEDTLS_CAN_ECDH
Valerio Settia15078b2023-07-06 14:52:45 +0200231#endif
232
Valerio Settiaa7cbd62023-07-07 17:22:17 +0200233/* PK module can achieve ECDSA functionalities by means of either software
234 * implementations (ECDSA_C) or through a PSA driver. The following defines
235 * are meant to list these capabilities in a general way which abstracts how
236 * they are implemented under the hood. */
Valerio Settia15078b2023-07-06 14:52:45 +0200237#if !defined(MBEDTLS_USE_PSA_CRYPTO)
238#if defined(MBEDTLS_ECDSA_C)
239#define MBEDTLS_PK_CAN_ECDSA_SIGN
240#define MBEDTLS_PK_CAN_ECDSA_VERIFY
241#endif /* MBEDTLS_ECDSA_C */
242#else /* MBEDTLS_USE_PSA_CRYPTO */
243#if defined(PSA_WANT_ALG_ECDSA)
244#if defined(PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC)
245#define MBEDTLS_PK_CAN_ECDSA_SIGN
246#endif /* PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC */
247#if defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY)
248#define MBEDTLS_PK_CAN_ECDSA_VERIFY
249#endif /* PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY */
250#endif /* PSA_WANT_ALG_ECDSA */
251#endif /* MBEDTLS_USE_PSA_CRYPTO */
252
253#if defined(MBEDTLS_PK_CAN_ECDSA_VERIFY) || defined(MBEDTLS_PK_CAN_ECDSA_SIGN)
254#define MBEDTLS_PK_CAN_ECDSA_SOME
255#endif
256
Gilles Peskine95c91522023-02-22 22:20:24 +0100257/* If MBEDTLS_PSA_CRYPTO_C is defined, make sure MBEDTLS_PSA_CRYPTO_CLIENT
258 * is defined as well to include all PSA code.
259 */
260#if defined(MBEDTLS_PSA_CRYPTO_C)
261#define MBEDTLS_PSA_CRYPTO_CLIENT
262#endif /* MBEDTLS_PSA_CRYPTO_C */
263
Gilles Peskinefd943042022-10-11 20:59:29 +0200264/* The PK wrappers need pk_write functions to format RSA key objects
265 * when they are dispatching to the PSA API. This happens under USE_PSA_CRYPTO,
Gilles Peskinebbccdd42022-10-04 23:00:42 +0200266 * and also even without USE_PSA_CRYPTO for mbedtls_pk_sign_ext(). */
Gilles Peskinefd943042022-10-11 20:59:29 +0200267#if defined(MBEDTLS_PSA_CRYPTO_C) && defined(MBEDTLS_RSA_C)
268#define MBEDTLS_PK_C
269#define MBEDTLS_PK_WRITE_C
Gilles Peskinefcee7402022-10-11 21:15:24 +0200270#define MBEDTLS_PK_PARSE_C
Gilles Peskinefd943042022-10-11 20:59:29 +0200271#endif
272
Valerio Setti7c494e72023-07-27 14:58:53 +0200273/* Helper symbol to state that the PK module has support for EC keys. This
274 * can either be provided through the legacy ECP solution or through the
Valerio Setti0f6d5652023-07-28 16:42:58 +0200275 * PSA friendly MBEDTLS_PK_USE_PSA_EC_DATA (see pk.h for its description). */
276#if defined(MBEDTLS_ECP_C) || \
277 (defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY))
Valerio Setti7c494e72023-07-27 14:58:53 +0200278#define MBEDTLS_PK_HAVE_ECC_KEYS
279#endif /* MBEDTLS_PK_USE_PSA_EC_DATA || MBEDTLS_ECP_C */
280
Manuel Pégourié-Gonnard5a51d0d2023-03-22 13:04:08 +0100281/* The following blocks make it easier to disable all of TLS,
282 * or of TLS 1.2 or 1.3 or DTLS, without having to manually disable all
Manuel Pégourié-Gonnard70a1b6d2023-03-24 10:30:40 +0100283 * key exchanges, options and extensions related to them. */
Manuel Pégourié-Gonnard5a51d0d2023-03-22 13:04:08 +0100284
285#if !defined(MBEDTLS_SSL_TLS_C)
286#undef MBEDTLS_SSL_CLI_C
287#undef MBEDTLS_SSL_SRV_C
288#undef MBEDTLS_SSL_PROTO_TLS1_3
289#undef MBEDTLS_SSL_PROTO_TLS1_2
290#undef MBEDTLS_SSL_PROTO_DTLS
291#endif
292
293#if !defined(MBEDTLS_SSL_PROTO_DTLS)
294#undef MBEDTLS_SSL_DTLS_ANTI_REPLAY
295#undef MBEDTLS_SSL_DTLS_CONNECTION_ID
296#undef MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT
297#undef MBEDTLS_SSL_DTLS_HELLO_VERIFY
298#undef MBEDTLS_SSL_DTLS_SRTP
299#undef MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE
300#endif
301
Ronald Cron571f1ff2022-10-04 09:33:27 +0200302#if !defined(MBEDTLS_SSL_PROTO_TLS1_2)
Manuel Pégourié-Gonnard5a51d0d2023-03-22 13:04:08 +0100303#undef MBEDTLS_SSL_ENCRYPT_THEN_MAC
304#undef MBEDTLS_SSL_EXTENDED_MASTER_SECRET
305#undef MBEDTLS_SSL_RENEGOTIATION
Ronald Cron571f1ff2022-10-04 09:33:27 +0200306#undef MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
307#undef MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
308#undef MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
309#undef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
310#undef MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
311#undef MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
312#undef MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
313#undef MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
314#undef MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
315#undef MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
316#undef MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
317#endif
318
Ronald Crond8d2ea52022-10-04 15:48:06 +0200319#if !defined(MBEDTLS_SSL_PROTO_TLS1_3)
320#undef MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
321#undef MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
322#undef MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED
Xiaokang Qian4ef4c892022-10-25 13:39:16 +0000323#undef MBEDTLS_SSL_EARLY_DATA
Ronald Crond8d2ea52022-10-04 15:48:06 +0200324#endif
325
Przemek Stekiel98d79332023-06-26 12:44:33 +0200326#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
327 (defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
328 defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED))
329#define MBEDTLS_SSL_TLS1_2_SOME_ECC
Ronald Crond8d2ea52022-10-04 15:48:06 +0200330#endif
331
Przemek Stekiela06787a2022-09-02 14:41:44 +0200332/* Make sure all configuration symbols are set before including check_config.h,
333 * even the ones that are calculated programmatically. */
Bence Szépkútic5c9eb42021-05-27 23:31:30 +0200334#include "mbedtls/check_config.h"
335
Bence Szépkúti5ab73032021-05-27 11:25:03 +0200336#endif /* MBEDTLS_BUILD_INFO_H */