blob: c0b724c835fe026b5a058178a10ff06c3235458e [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
Dave Rodgman16799db2023-11-02 19:47:20 +000011 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Gilles Peskine449bd832023-01-11 14:50:10 +010012 */
Bence Szépkúti5ab73032021-05-27 11:25:03 +020013
14#ifndef MBEDTLS_BUILD_INFO_H
15#define MBEDTLS_BUILD_INFO_H
16
Bence Szépkúti04982f72021-06-21 14:40:51 +020017/*
18 * This set of compile-time defines can be used to determine the version number
Bence Szépkúti1b2a8832021-06-28 10:26:11 +010019 * 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 +020020 * version.h
21 */
22
23/**
24 * The version number x.y.z is split into three parts.
25 * Major, Minor, Patchlevel
26 */
Dave Rodgman1bc9e932021-07-01 09:20:13 +010027#define MBEDTLS_VERSION_MAJOR 3
Minos Galanakis31ca3132023-10-03 22:02:18 +010028#define MBEDTLS_VERSION_MINOR 5
Dave Rodgman28d40932023-11-03 12:46:57 +000029#define MBEDTLS_VERSION_PATCH 1
Bence Szépkúti04982f72021-06-21 14:40:51 +020030
31/**
32 * The single version number has the following structure:
33 * MMNNPP00
34 * Major version | Minor version | Patch version
35 */
Dave Rodgman28d40932023-11-03 12:46:57 +000036#define MBEDTLS_VERSION_NUMBER 0x03050100
37#define MBEDTLS_VERSION_STRING "3.5.1"
38#define MBEDTLS_VERSION_STRING_FULL "Mbed TLS 3.5.1"
Bence Szépkúti04982f72021-06-21 14:40:51 +020039
Jerry Yu926221a2023-08-18 15:09:02 +080040/* Macros for build-time platform detection */
41
42#if !defined(MBEDTLS_ARCH_IS_ARM64) && \
43 (defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC))
44#define MBEDTLS_ARCH_IS_ARM64
45#endif
46
47#if !defined(MBEDTLS_ARCH_IS_ARM32) && \
48 (defined(__arm__) || defined(_M_ARM) || \
49 defined(_M_ARMT) || defined(__thumb__) || defined(__thumb2__))
50#define MBEDTLS_ARCH_IS_ARM32
51#endif
52
53#if !defined(MBEDTLS_ARCH_IS_X64) && \
54 (defined(__amd64__) || defined(__x86_64__) || \
55 ((defined(_M_X64) || defined(_M_AMD64)) && !defined(_M_ARM64EC)))
56#define MBEDTLS_ARCH_IS_X64
57#endif
58
59#if !defined(MBEDTLS_ARCH_IS_X86) && \
60 (defined(__i386__) || defined(_X86_) || \
61 (defined(_M_IX86) && !defined(_M_I86)))
62#define MBEDTLS_ARCH_IS_X86
63#endif
Jerry Yu926221a2023-08-18 15:09:02 +080064
Dave Rodgman3e521842023-09-18 10:36:21 +010065#if !defined(MBEDTLS_PLATFORM_IS_WINDOWS_ON_ARM64) && \
66 (defined(_M_ARM64) || defined(_M_ARM64EC))
Dave Rodgman0a487172023-09-15 11:52:06 +010067#define MBEDTLS_PLATFORM_IS_WINDOWS_ON_ARM64
68#endif
69
Dave Rodgmanfe9fda82023-10-10 14:51:06 +010070/* This is defined if the architecture is Armv8-A, or higher */
71#if !defined(MBEDTLS_ARCH_IS_ARMV8_A)
72#if defined(__ARM_ARCH) && defined(__ARM_ARCH_PROFILE)
73#if (__ARM_ARCH >= 8) && (__ARM_ARCH_PROFILE == 'A')
74/* GCC, clang, armclang and IAR */
75#define MBEDTLS_ARCH_IS_ARMV8_A
Dave Rodgman5ed7b2d2023-10-03 18:00:44 +010076#endif
Dave Rodgmanfe9fda82023-10-10 14:51:06 +010077#elif defined(__ARM_ARCH_8A)
78/* Alternative defined by clang */
79#define MBEDTLS_ARCH_IS_ARMV8_A
80#elif defined(_M_ARM64) || defined(_M_ARM64EC)
81/* MSVC ARM64 is at least Armv8.0-A */
82#define MBEDTLS_ARCH_IS_ARMV8_A
Dave Rodgman5ed7b2d2023-10-03 18:00:44 +010083#endif
84#endif
85
Dave Rodgman336efee2024-01-19 16:38:53 +000086#if defined(__GNUC__) && !defined(__ARMCC_VERSION) && !defined(__clang__) \
87 && !defined(__llvm__) && !defined(__INTEL_COMPILER)
88/* Defined if the compiler really is gcc and not clang, etc */
89#define MBEDTLS_COMPILER_IS_GCC
90#define MBEDTLS_GCC_VERSION \
91 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
92#endif
93
Bence Szépkútic5c9eb42021-05-27 23:31:30 +020094#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
95#define _CRT_SECURE_NO_DEPRECATE 1
96#endif
97
Gilles Peskine6157fee2022-11-23 16:13:13 +010098/* Define `inline` on some non-C99-compliant compilers. */
Gilles Peskine449bd832023-01-11 14:50:10 +010099#if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && \
Gilles Peskine6157fee2022-11-23 16:13:13 +0100100 !defined(inline) && !defined(__cplusplus)
101#define inline __inline
102#endif
103
Gilles Peskinea458d482023-05-17 23:13:06 +0200104/* X.509, TLS and non-PSA crypto configuration */
Bence Szépkúti5ab73032021-05-27 11:25:03 +0200105#if !defined(MBEDTLS_CONFIG_FILE)
Bence Szépkútibb0cfeb2021-05-28 09:42:25 +0200106#include "mbedtls/mbedtls_config.h"
Bence Szépkúti5ab73032021-05-27 11:25:03 +0200107#else
108#include MBEDTLS_CONFIG_FILE
109#endif
110
Bence Szépkúti1cafe5c2021-06-22 09:30:08 +0200111#if defined(MBEDTLS_CONFIG_VERSION) && ( \
112 MBEDTLS_CONFIG_VERSION < 0x03000000 || \
Gilles Peskine449bd832023-01-11 14:50:10 +0100113 MBEDTLS_CONFIG_VERSION > MBEDTLS_VERSION_NUMBER)
Bence Szépkútib2e23de2021-06-21 15:53:07 +0200114#error "Invalid config version, defined value of MBEDTLS_CONFIG_VERSION is unsupported"
Bence Szépkútiba7248a2021-05-31 16:53:56 +0200115#endif
116
Bence Szépkútic5c9eb42021-05-27 23:31:30 +0200117/* Target and application specific configurations
118 *
119 * Allow user to override any previous default.
120 *
121 */
122#if defined(MBEDTLS_USER_CONFIG_FILE)
123#include MBEDTLS_USER_CONFIG_FILE
124#endif
125
Gilles Peskinea458d482023-05-17 23:13:06 +0200126/* PSA crypto configuration */
127#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
128#if defined(MBEDTLS_PSA_CRYPTO_CONFIG_FILE)
129#include MBEDTLS_PSA_CRYPTO_CONFIG_FILE
130#else
131#include "psa/crypto_config.h"
132#endif
Gilles Peskinea458d482023-05-17 23:13:06 +0200133#if defined(MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE)
134#include MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE
135#endif
Gilles Peskine7b7ecf52023-05-17 23:15:31 +0200136#endif /* defined(MBEDTLS_PSA_CRYPTO_CONFIG) */
Gilles Peskinea458d482023-05-17 23:13:06 +0200137
Yanray Wang1ed226f2023-05-05 11:31:11 +0800138/* Auto-enable MBEDTLS_CTR_DRBG_USE_128_BIT_KEY if
139 * MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH and MBEDTLS_CTR_DRBG_C defined
140 * to ensure a 128-bit key size in CTR_DRBG.
141 */
142#if defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) && defined(MBEDTLS_CTR_DRBG_C)
143#define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
144#endif
145
Manuel Pégourié-Gonnard49e67f82023-03-16 11:39:20 +0100146/* Auto-enable MBEDTLS_MD_C if needed by a module that didn't require it
147 * in a previous release, to ensure backwards compatibility.
148 */
149#if defined(MBEDTLS_PKCS5_C)
150#define MBEDTLS_MD_C
151#endif
152
Yanray Wang419a55e2023-05-17 18:22:00 +0800153/* PSA crypto specific configuration options
154 * - If config_psa.h reads a configuration option in preprocessor directive,
Yanray Wang37db3322023-05-22 16:50:35 +0800155 * this symbol should be set before its inclusion. (e.g. MBEDTLS_MD_C)
Yanray Wang419a55e2023-05-17 18:22:00 +0800156 * - If config_psa.h writes a configuration option in conditional directive,
157 * this symbol should be consulted after its inclusion.
158 * (e.g. MBEDTLS_MD_LIGHT)
159 */
Yanray Wang63976732023-05-17 12:41:25 +0800160#if defined(MBEDTLS_PSA_CRYPTO_CONFIG) /* PSA_WANT_xxx influences MBEDTLS_xxx */ || \
161 defined(MBEDTLS_PSA_CRYPTO_C) /* MBEDTLS_xxx influences PSA_WANT_xxx */
162#include "mbedtls/config_psa.h"
163#endif
164
Gilles Peskine9d6a63b2023-09-04 17:49:07 +0200165#include "mbedtls/config_adjust_legacy_crypto.h"
Valerio Setti7c494e72023-07-27 14:58:53 +0200166
Gilles Peskinedc720b02023-09-04 17:50:28 +0200167#include "mbedtls/config_adjust_x509.h"
168
Gilles Peskineedc23792023-09-04 17:53:11 +0200169#include "mbedtls/config_adjust_ssl.h"
Ronald Crond8d2ea52022-10-04 15:48:06 +0200170
Przemek Stekiela06787a2022-09-02 14:41:44 +0200171/* Make sure all configuration symbols are set before including check_config.h,
172 * even the ones that are calculated programmatically. */
Bence Szépkútic5c9eb42021-05-27 23:31:30 +0200173#include "mbedtls/check_config.h"
174
Bence Szépkúti5ab73032021-05-27 11:25:03 +0200175#endif /* MBEDTLS_BUILD_INFO_H */