blob: 82db635ddfb23fd7e462b30b62146fb8f05f861c [file] [log] [blame]
Andres Amaya Garcia88121a92018-10-16 22:00:13 +01001/*
Andres Amaya Garciac28da7e2018-10-29 18:58:41 +00002 * Query Mbed TLS compile time configurations from config.h
Andres Amaya Garcia88121a92018-10-16 22:00:13 +01003 *
Bence Szépkúti1e148272020-08-07 13:07:28 +02004 * Copyright The Mbed TLS Contributors
Dave Rodgman7ff79652023-11-03 12:04:52 +00005 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Andres Amaya Garcia88121a92018-10-16 22:00:13 +01006 */
7
8#if !defined(MBEDTLS_CONFIG_FILE)
9#include "mbedtls/config.h"
10#else
11#include MBEDTLS_CONFIG_FILE
12#endif
13
Gilles Peskinec772b182021-01-12 15:55:10 +010014#include "query_config.h"
15
Andres Amaya Garcia88121a92018-10-16 22:00:13 +010016#include "mbedtls/platform.h"
Andres Amaya Garcia88121a92018-10-16 22:00:13 +010017
Andres Amaya Garciac28da7e2018-10-29 18:58:41 +000018/*
19 * Include all the headers with public APIs in case they define a macro to its
20 * default value when that configuration is not set in the config.h.
21 */
Andres Amaya Garcia88121a92018-10-16 22:00:13 +010022#include "mbedtls/aes.h"
23#include "mbedtls/aesni.h"
24#include "mbedtls/arc4.h"
25#include "mbedtls/aria.h"
26#include "mbedtls/asn1.h"
27#include "mbedtls/asn1write.h"
28#include "mbedtls/base64.h"
29#include "mbedtls/bignum.h"
30#include "mbedtls/blowfish.h"
31#include "mbedtls/camellia.h"
32#include "mbedtls/ccm.h"
33#include "mbedtls/certs.h"
34#include "mbedtls/chacha20.h"
35#include "mbedtls/chachapoly.h"
36#include "mbedtls/cipher.h"
37#include "mbedtls/cmac.h"
38#include "mbedtls/ctr_drbg.h"
39#include "mbedtls/debug.h"
40#include "mbedtls/des.h"
41#include "mbedtls/dhm.h"
42#include "mbedtls/ecdh.h"
43#include "mbedtls/ecdsa.h"
44#include "mbedtls/ecjpake.h"
45#include "mbedtls/ecp.h"
46#include "mbedtls/entropy.h"
47#include "mbedtls/entropy_poll.h"
48#include "mbedtls/error.h"
49#include "mbedtls/gcm.h"
50#include "mbedtls/havege.h"
51#include "mbedtls/hkdf.h"
52#include "mbedtls/hmac_drbg.h"
53#include "mbedtls/md.h"
54#include "mbedtls/md2.h"
55#include "mbedtls/md4.h"
56#include "mbedtls/md5.h"
57#include "mbedtls/memory_buffer_alloc.h"
58#include "mbedtls/net_sockets.h"
59#include "mbedtls/nist_kw.h"
60#include "mbedtls/oid.h"
61#include "mbedtls/padlock.h"
62#include "mbedtls/pem.h"
63#include "mbedtls/pk.h"
64#include "mbedtls/pkcs11.h"
65#include "mbedtls/pkcs12.h"
66#include "mbedtls/pkcs5.h"
Daniel Axtens301db662020-05-28 11:43:41 +100067#if defined(MBEDTLS_HAVE_TIME)
Andres Amaya Garcia88121a92018-10-16 22:00:13 +010068#include "mbedtls/platform_time.h"
Daniel Axtens301db662020-05-28 11:43:41 +100069#endif
Andres Amaya Garcia88121a92018-10-16 22:00:13 +010070#include "mbedtls/platform_util.h"
71#include "mbedtls/poly1305.h"
72#include "mbedtls/ripemd160.h"
73#include "mbedtls/rsa.h"
74#include "mbedtls/sha1.h"
75#include "mbedtls/sha256.h"
76#include "mbedtls/sha512.h"
77#include "mbedtls/ssl.h"
78#include "mbedtls/ssl_cache.h"
79#include "mbedtls/ssl_ciphersuites.h"
80#include "mbedtls/ssl_cookie.h"
81#include "mbedtls/ssl_internal.h"
82#include "mbedtls/ssl_ticket.h"
83#include "mbedtls/threading.h"
84#include "mbedtls/timing.h"
85#include "mbedtls/version.h"
86#include "mbedtls/x509.h"
87#include "mbedtls/x509_crl.h"
88#include "mbedtls/x509_crt.h"
89#include "mbedtls/x509_csr.h"
90#include "mbedtls/xtea.h"
91
Andres Amaya Garcia88121a92018-10-16 22:00:13 +010092#include <string.h>
93
Andres Amaya Garcia27b33722018-12-05 10:47:31 +000094/*
95 * Helper macros to convert a macro or its expansion into a string
96 * WARNING: This does not work for expanding function-like macros. However,
97 * Mbed TLS does not currently have configuration options used in this fashion.
98 */
Andres Amaya Garcia88121a92018-10-16 22:00:13 +010099#define MACRO_EXPANSION_TO_STR(macro) MACRO_NAME_TO_STR(macro)
Andres Amaya Garcia27b33722018-12-05 10:47:31 +0000100#define MACRO_NAME_TO_STR(macro) \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100101 mbedtls_printf("%s", strlen( #macro "") > 0 ? #macro "\n" : "")
Andres Amaya Garcia88121a92018-10-16 22:00:13 +0100102
Jerry Yu969c01a2021-12-10 20:29:02 +0800103#define STRINGIFY(macro) #macro
Jerry Yu0abd6772021-12-06 13:40:37 +0800104#define OUTPUT_MACRO_NAME_VALUE(macro) mbedtls_printf( #macro "%s\n", \
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100105 (STRINGIFY(macro) "")[0] != 0 ? "=" STRINGIFY( \
106 macro) : "")
Jerry Yu0abd6772021-12-06 13:40:37 +0800107
Andres Amaya Garcia17c53c52019-01-24 09:55:14 +0000108#if defined(_MSC_VER)
109/*
110 * Visual Studio throws the warning 4003 because many Mbed TLS feature macros
111 * are defined empty. This means that from the preprocessor's point of view
112 * the macro MBEDTLS_EXPANSION_TO_STR is being invoked without arguments as
113 * some macros expand to nothing. We suppress that specific warning to get a
114 * clean build and to ensure that tests treating warnings as errors do not
115 * fail.
116 */
117#pragma warning(push)
118#pragma warning(disable:4003)
119#endif /* _MSC_VER */
120
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100121int query_config(const char *config)
Andres Amaya Garcia88121a92018-10-16 22:00:13 +0100122{
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100123 CHECK_CONFIG /* If the symbol is not found, return an error */
124 return 1;
Andres Amaya Garcia88121a92018-10-16 22:00:13 +0100125}
Andres Amaya Garcia17c53c52019-01-24 09:55:14 +0000126
Gilles Peskine1b6c09a2023-01-11 14:52:35 +0100127void list_config(void)
Jerry Yu0abd6772021-12-06 13:40:37 +0800128{
129 LIST_CONFIG
130}
Andres Amaya Garcia17c53c52019-01-24 09:55:14 +0000131#if defined(_MSC_VER)
132#pragma warning(pop)
133#endif /* _MSC_VER */