Bence Szépkúti | 5ab7303 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 1 | /** |
Ronald Cron | 135f2ae | 2023-02-08 12:25:38 +0100 | [diff] [blame] | 2 | * \file mbedtls/build_info.h |
Bence Szépkúti | 5ab7303 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 3 | * |
| 4 | * \brief Build-time configuration info |
| 5 | * |
| 6 | * Include this file if you need to depend on the |
Bence Szépkúti | e55a821 | 2021-06-28 15:15:56 +0100 | [diff] [blame] | 7 | * configuration options defined in mbedtls_config.h or MBEDTLS_CONFIG_FILE |
Bence Szépkúti | 5ab7303 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 8 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 9 | /* |
| 10 | * Copyright The Mbed TLS Contributors |
Dave Rodgman | 16799db | 2023-11-02 19:47:20 +0000 | [diff] [blame] | 11 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 12 | */ |
Bence Szépkúti | 5ab7303 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 13 | |
| 14 | #ifndef MBEDTLS_BUILD_INFO_H |
| 15 | #define MBEDTLS_BUILD_INFO_H |
| 16 | |
Bence Szépkúti | 04982f7 | 2021-06-21 14:40:51 +0200 | [diff] [blame] | 17 | /* |
| 18 | * This set of compile-time defines can be used to determine the version number |
Bence Szépkúti | 1b2a883 | 2021-06-28 10:26:11 +0100 | [diff] [blame] | 19 | * of the Mbed TLS library used. Run-time variables for the same can be found in |
Bence Szépkúti | 04982f7 | 2021-06-21 14:40:51 +0200 | [diff] [blame] | 20 | * version.h |
| 21 | */ |
| 22 | |
| 23 | /** |
| 24 | * The version number x.y.z is split into three parts. |
| 25 | * Major, Minor, Patchlevel |
| 26 | */ |
Dave Rodgman | 1bc9e93 | 2021-07-01 09:20:13 +0100 | [diff] [blame] | 27 | #define MBEDTLS_VERSION_MAJOR 3 |
Minos Galanakis | 4492dbd | 2024-03-21 15:52:49 +0000 | [diff] [blame] | 28 | #define MBEDTLS_VERSION_MINOR 6 |
| 29 | #define MBEDTLS_VERSION_PATCH 0 |
Bence Szépkúti | 04982f7 | 2021-06-21 14:40:51 +0200 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * The single version number has the following structure: |
| 33 | * MMNNPP00 |
| 34 | * Major version | Minor version | Patch version |
| 35 | */ |
Minos Galanakis | 4492dbd | 2024-03-21 15:52:49 +0000 | [diff] [blame] | 36 | #define MBEDTLS_VERSION_NUMBER 0x03060000 |
| 37 | #define MBEDTLS_VERSION_STRING "3.6.0" |
| 38 | #define MBEDTLS_VERSION_STRING_FULL "Mbed TLS 3.6.0" |
Bence Szépkúti | 04982f7 | 2021-06-21 14:40:51 +0200 | [diff] [blame] | 39 | |
Jerry Yu | 926221a | 2023-08-18 15:09:02 +0800 | [diff] [blame] | 40 | /* 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 Yu | 926221a | 2023-08-18 15:09:02 +0800 | [diff] [blame] | 64 | |
Dave Rodgman | 3e52184 | 2023-09-18 10:36:21 +0100 | [diff] [blame] | 65 | #if !defined(MBEDTLS_PLATFORM_IS_WINDOWS_ON_ARM64) && \ |
| 66 | (defined(_M_ARM64) || defined(_M_ARM64EC)) |
Dave Rodgman | 0a48717 | 2023-09-15 11:52:06 +0100 | [diff] [blame] | 67 | #define MBEDTLS_PLATFORM_IS_WINDOWS_ON_ARM64 |
| 68 | #endif |
| 69 | |
Dave Rodgman | fe9fda8 | 2023-10-10 14:51:06 +0100 | [diff] [blame] | 70 | /* 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 Rodgman | 5ed7b2d | 2023-10-03 18:00:44 +0100 | [diff] [blame] | 76 | #endif |
Dave Rodgman | fe9fda8 | 2023-10-10 14:51:06 +0100 | [diff] [blame] | 77 | #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 Rodgman | 5ed7b2d | 2023-10-03 18:00:44 +0100 | [diff] [blame] | 83 | #endif |
| 84 | #endif |
| 85 | |
Dave Rodgman | 336efee | 2024-01-19 16:38:53 +0000 | [diff] [blame] | 86 | #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úti | c5c9eb4 | 2021-05-27 23:31:30 +0200 | [diff] [blame] | 94 | #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) |
| 95 | #define _CRT_SECURE_NO_DEPRECATE 1 |
| 96 | #endif |
| 97 | |
Gilles Peskine | 6157fee | 2022-11-23 16:13:13 +0100 | [diff] [blame] | 98 | /* Define `inline` on some non-C99-compliant compilers. */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 99 | #if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && \ |
Gilles Peskine | 6157fee | 2022-11-23 16:13:13 +0100 | [diff] [blame] | 100 | !defined(inline) && !defined(__cplusplus) |
| 101 | #define inline __inline |
| 102 | #endif |
| 103 | |
Gilles Peskine | a4e97fc | 2024-05-16 14:44:15 +0200 | [diff] [blame^] | 104 | #undef MBEDTLS_CONFIG_FILES_READ |
| 105 | #undef MBEDTLS_CONFIG_IS_FINALIZED |
| 106 | |
Gilles Peskine | a458d48 | 2023-05-17 23:13:06 +0200 | [diff] [blame] | 107 | /* X.509, TLS and non-PSA crypto configuration */ |
Bence Szépkúti | 5ab7303 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 108 | #if !defined(MBEDTLS_CONFIG_FILE) |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 109 | #include "mbedtls/mbedtls_config.h" |
Bence Szépkúti | 5ab7303 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 110 | #else |
| 111 | #include MBEDTLS_CONFIG_FILE |
| 112 | #endif |
| 113 | |
Bence Szépkúti | 1cafe5c | 2021-06-22 09:30:08 +0200 | [diff] [blame] | 114 | #if defined(MBEDTLS_CONFIG_VERSION) && ( \ |
| 115 | MBEDTLS_CONFIG_VERSION < 0x03000000 || \ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 116 | MBEDTLS_CONFIG_VERSION > MBEDTLS_VERSION_NUMBER) |
Bence Szépkúti | b2e23de | 2021-06-21 15:53:07 +0200 | [diff] [blame] | 117 | #error "Invalid config version, defined value of MBEDTLS_CONFIG_VERSION is unsupported" |
Bence Szépkúti | ba7248a | 2021-05-31 16:53:56 +0200 | [diff] [blame] | 118 | #endif |
| 119 | |
Bence Szépkúti | c5c9eb4 | 2021-05-27 23:31:30 +0200 | [diff] [blame] | 120 | /* Target and application specific configurations |
| 121 | * |
| 122 | * Allow user to override any previous default. |
| 123 | * |
| 124 | */ |
| 125 | #if defined(MBEDTLS_USER_CONFIG_FILE) |
| 126 | #include MBEDTLS_USER_CONFIG_FILE |
| 127 | #endif |
| 128 | |
Gilles Peskine | a458d48 | 2023-05-17 23:13:06 +0200 | [diff] [blame] | 129 | /* PSA crypto configuration */ |
| 130 | #if defined(MBEDTLS_PSA_CRYPTO_CONFIG) |
| 131 | #if defined(MBEDTLS_PSA_CRYPTO_CONFIG_FILE) |
| 132 | #include MBEDTLS_PSA_CRYPTO_CONFIG_FILE |
| 133 | #else |
| 134 | #include "psa/crypto_config.h" |
| 135 | #endif |
Gilles Peskine | a458d48 | 2023-05-17 23:13:06 +0200 | [diff] [blame] | 136 | #if defined(MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE) |
| 137 | #include MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE |
| 138 | #endif |
Gilles Peskine | 7b7ecf5 | 2023-05-17 23:15:31 +0200 | [diff] [blame] | 139 | #endif /* defined(MBEDTLS_PSA_CRYPTO_CONFIG) */ |
Gilles Peskine | a458d48 | 2023-05-17 23:13:06 +0200 | [diff] [blame] | 140 | |
Gilles Peskine | a4e97fc | 2024-05-16 14:44:15 +0200 | [diff] [blame^] | 141 | /* Indicate that all configuration files have been read. |
| 142 | * It is now time to adjust the configuration (follow through on dependencies, |
| 143 | * make PSA and legacy crypto consistent, etc.). |
| 144 | */ |
| 145 | #define MBEDTLS_CONFIG_FILES_READ |
| 146 | |
Yanray Wang | 1ed226f | 2023-05-05 11:31:11 +0800 | [diff] [blame] | 147 | /* Auto-enable MBEDTLS_CTR_DRBG_USE_128_BIT_KEY if |
| 148 | * MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH and MBEDTLS_CTR_DRBG_C defined |
| 149 | * to ensure a 128-bit key size in CTR_DRBG. |
| 150 | */ |
| 151 | #if defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) && defined(MBEDTLS_CTR_DRBG_C) |
| 152 | #define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY |
| 153 | #endif |
| 154 | |
Manuel Pégourié-Gonnard | 49e67f8 | 2023-03-16 11:39:20 +0100 | [diff] [blame] | 155 | /* Auto-enable MBEDTLS_MD_C if needed by a module that didn't require it |
| 156 | * in a previous release, to ensure backwards compatibility. |
| 157 | */ |
| 158 | #if defined(MBEDTLS_PKCS5_C) |
| 159 | #define MBEDTLS_MD_C |
| 160 | #endif |
| 161 | |
Yanray Wang | 419a55e | 2023-05-17 18:22:00 +0800 | [diff] [blame] | 162 | /* PSA crypto specific configuration options |
| 163 | * - If config_psa.h reads a configuration option in preprocessor directive, |
Yanray Wang | 37db332 | 2023-05-22 16:50:35 +0800 | [diff] [blame] | 164 | * this symbol should be set before its inclusion. (e.g. MBEDTLS_MD_C) |
Yanray Wang | 419a55e | 2023-05-17 18:22:00 +0800 | [diff] [blame] | 165 | * - If config_psa.h writes a configuration option in conditional directive, |
| 166 | * this symbol should be consulted after its inclusion. |
| 167 | * (e.g. MBEDTLS_MD_LIGHT) |
| 168 | */ |
Yanray Wang | 6397673 | 2023-05-17 12:41:25 +0800 | [diff] [blame] | 169 | #if defined(MBEDTLS_PSA_CRYPTO_CONFIG) /* PSA_WANT_xxx influences MBEDTLS_xxx */ || \ |
Antonio de Angelis | 058c9a3 | 2024-02-08 10:24:06 +0000 | [diff] [blame] | 170 | defined(MBEDTLS_PSA_CRYPTO_C) /* MBEDTLS_xxx influences PSA_WANT_xxx */ || \ |
| 171 | defined(MBEDTLS_PSA_CRYPTO_CLIENT) /* The same as the previous, but with separation only */ |
Yanray Wang | 6397673 | 2023-05-17 12:41:25 +0800 | [diff] [blame] | 172 | #include "mbedtls/config_psa.h" |
| 173 | #endif |
| 174 | |
Gilles Peskine | 9d6a63b | 2023-09-04 17:49:07 +0200 | [diff] [blame] | 175 | #include "mbedtls/config_adjust_legacy_crypto.h" |
Valerio Setti | 7c494e7 | 2023-07-27 14:58:53 +0200 | [diff] [blame] | 176 | |
Gilles Peskine | dc720b0 | 2023-09-04 17:50:28 +0200 | [diff] [blame] | 177 | #include "mbedtls/config_adjust_x509.h" |
| 178 | |
Gilles Peskine | edc2379 | 2023-09-04 17:53:11 +0200 | [diff] [blame] | 179 | #include "mbedtls/config_adjust_ssl.h" |
Ronald Cron | d8d2ea5 | 2022-10-04 15:48:06 +0200 | [diff] [blame] | 180 | |
Gilles Peskine | a4e97fc | 2024-05-16 14:44:15 +0200 | [diff] [blame^] | 181 | /* Indicate that all configuration symbols are set, |
| 182 | * even the ones that are calculated programmatically. |
| 183 | * It is now safe to query the configuration (to check it, to size buffers, |
| 184 | * etc.). |
| 185 | */ |
| 186 | #define MBEDTLS_CONFIG_IS_FINALIZED |
| 187 | |
Bence Szépkúti | c5c9eb4 | 2021-05-27 23:31:30 +0200 | [diff] [blame] | 188 | #include "mbedtls/check_config.h" |
| 189 | |
Bence Szépkúti | 5ab7303 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 190 | #endif /* MBEDTLS_BUILD_INFO_H */ |