blob: 9b9f5f2ac99886080017b6976af52650f35866a4 [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"
Gilles Peskinee820c0a2023-08-03 17:45:20 +020050#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
Jerry Yu926221a2023-08-18 15:09:02 +080076
Dave Rodgman5ed7b2d2023-10-03 18:00:44 +010077/* This is defined if the architecture is Armv8, or higher */
78#if !defined(MBEDTLS_ARCH_IS_ARMV8)
79#if defined(__ARM_ARCH)
80#if __ARM_ARCH >= 8
81#define MBEDTLS_ARCH_IS_ARMV8
82#endif
83#elif defined(MBEDTLS_ARCH_IS_ARM64)
84#define MBEDTLS_ARCH_IS_ARMV8
85#endif
86#endif
87
Bence Szépkútic5c9eb42021-05-27 23:31:30 +020088#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
89#define _CRT_SECURE_NO_DEPRECATE 1
90#endif
91
Gilles Peskine6157fee2022-11-23 16:13:13 +010092/* Define `inline` on some non-C99-compliant compilers. */
Gilles Peskine449bd832023-01-11 14:50:10 +010093#if (defined(__ARMCC_VERSION) || defined(_MSC_VER)) && \
Gilles Peskine6157fee2022-11-23 16:13:13 +010094 !defined(inline) && !defined(__cplusplus)
95#define inline __inline
96#endif
97
Gilles Peskinea458d482023-05-17 23:13:06 +020098/* X.509, TLS and non-PSA crypto configuration */
Bence Szépkúti5ab73032021-05-27 11:25:03 +020099#if !defined(MBEDTLS_CONFIG_FILE)
Bence Szépkútibb0cfeb2021-05-28 09:42:25 +0200100#include "mbedtls/mbedtls_config.h"
Bence Szépkúti5ab73032021-05-27 11:25:03 +0200101#else
102#include MBEDTLS_CONFIG_FILE
103#endif
104
Bence Szépkúti1cafe5c2021-06-22 09:30:08 +0200105#if defined(MBEDTLS_CONFIG_VERSION) && ( \
106 MBEDTLS_CONFIG_VERSION < 0x03000000 || \
Gilles Peskine449bd832023-01-11 14:50:10 +0100107 MBEDTLS_CONFIG_VERSION > MBEDTLS_VERSION_NUMBER)
Bence Szépkútib2e23de2021-06-21 15:53:07 +0200108#error "Invalid config version, defined value of MBEDTLS_CONFIG_VERSION is unsupported"
Bence Szépkútiba7248a2021-05-31 16:53:56 +0200109#endif
110
Bence Szépkútic5c9eb42021-05-27 23:31:30 +0200111/* Target and application specific configurations
112 *
113 * Allow user to override any previous default.
114 *
115 */
116#if defined(MBEDTLS_USER_CONFIG_FILE)
117#include MBEDTLS_USER_CONFIG_FILE
118#endif
119
Gilles Peskinea458d482023-05-17 23:13:06 +0200120/* PSA crypto configuration */
121#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
122#if defined(MBEDTLS_PSA_CRYPTO_CONFIG_FILE)
123#include MBEDTLS_PSA_CRYPTO_CONFIG_FILE
124#else
125#include "psa/crypto_config.h"
126#endif
Gilles Peskinea458d482023-05-17 23:13:06 +0200127#if defined(MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE)
128#include MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE
129#endif
Gilles Peskine7b7ecf52023-05-17 23:15:31 +0200130#endif /* defined(MBEDTLS_PSA_CRYPTO_CONFIG) */
Gilles Peskinea458d482023-05-17 23:13:06 +0200131
Yanray Wang1ed226f2023-05-05 11:31:11 +0800132/* Auto-enable MBEDTLS_CTR_DRBG_USE_128_BIT_KEY if
133 * MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH and MBEDTLS_CTR_DRBG_C defined
134 * to ensure a 128-bit key size in CTR_DRBG.
135 */
136#if defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) && defined(MBEDTLS_CTR_DRBG_C)
137#define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
138#endif
139
Manuel Pégourié-Gonnard49e67f82023-03-16 11:39:20 +0100140/* Auto-enable MBEDTLS_MD_C if needed by a module that didn't require it
141 * in a previous release, to ensure backwards compatibility.
142 */
143#if defined(MBEDTLS_PKCS5_C)
144#define MBEDTLS_MD_C
145#endif
146
Yanray Wang419a55e2023-05-17 18:22:00 +0800147/* PSA crypto specific configuration options
148 * - If config_psa.h reads a configuration option in preprocessor directive,
Yanray Wang37db3322023-05-22 16:50:35 +0800149 * this symbol should be set before its inclusion. (e.g. MBEDTLS_MD_C)
Yanray Wang419a55e2023-05-17 18:22:00 +0800150 * - If config_psa.h writes a configuration option in conditional directive,
151 * this symbol should be consulted after its inclusion.
152 * (e.g. MBEDTLS_MD_LIGHT)
153 */
Yanray Wang63976732023-05-17 12:41:25 +0800154#if defined(MBEDTLS_PSA_CRYPTO_CONFIG) /* PSA_WANT_xxx influences MBEDTLS_xxx */ || \
155 defined(MBEDTLS_PSA_CRYPTO_C) /* MBEDTLS_xxx influences PSA_WANT_xxx */
156#include "mbedtls/config_psa.h"
157#endif
158
Gilles Peskine9d6a63b2023-09-04 17:49:07 +0200159#include "mbedtls/config_adjust_legacy_crypto.h"
Valerio Setti7c494e72023-07-27 14:58:53 +0200160
Gilles Peskinedc720b02023-09-04 17:50:28 +0200161#include "mbedtls/config_adjust_x509.h"
162
Gilles Peskineedc23792023-09-04 17:53:11 +0200163#include "mbedtls/config_adjust_ssl.h"
Ronald Crond8d2ea52022-10-04 15:48:06 +0200164
Przemek Stekiela06787a2022-09-02 14:41:44 +0200165/* Make sure all configuration symbols are set before including check_config.h,
166 * even the ones that are calculated programmatically. */
Bence Szépkútic5c9eb42021-05-27 23:31:30 +0200167#include "mbedtls/check_config.h"
168
Bence Szépkúti5ab73032021-05-27 11:25:03 +0200169#endif /* MBEDTLS_BUILD_INFO_H */