1/* 2 * Query Mbed TLS compile time configurations from mbedtls_config.h 3 * 4 * Copyright The Mbed TLS Contributors 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 6 */ 7 8#include "mbedtls/build_info.h" 9 10#include "query_config.h" 11 12#include "mbedtls/platform.h" 13 14/* 15 * Include all the headers with public APIs in case they define a macro to its 16 * default value when that configuration is not set in mbedtls_config.h, or 17 * for PSA_WANT macros, in case they're auto-defined based on mbedtls_config.h 18 * rather than defined directly in crypto_config.h. 19 */ 20#include "psa/crypto.h" 21 22#include "mbedtls/aes.h" 23#include "mbedtls/aria.h" 24#include "mbedtls/asn1.h" 25#include "mbedtls/asn1write.h" 26#include "mbedtls/base64.h" 27#include "mbedtls/bignum.h" 28#include "mbedtls/camellia.h" 29#include "mbedtls/ccm.h" 30#include "mbedtls/chacha20.h" 31#include "mbedtls/chachapoly.h" 32#include "mbedtls/cipher.h" 33#include "mbedtls/cmac.h" 34#include "mbedtls/ctr_drbg.h" 35#include "mbedtls/debug.h" 36#include "mbedtls/des.h" 37#include "mbedtls/dhm.h" 38#include "mbedtls/ecdh.h" 39#include "mbedtls/ecdsa.h" 40#include "mbedtls/ecjpake.h" 41#include "mbedtls/ecp.h" 42#include "mbedtls/entropy.h" 43#include "mbedtls/error.h" 44#include "mbedtls/gcm.h" 45#include "mbedtls/hkdf.h" 46#include "mbedtls/hmac_drbg.h" 47#include "mbedtls/md.h" 48#include "mbedtls/md5.h" 49#include "mbedtls/memory_buffer_alloc.h" 50#include "mbedtls/net_sockets.h" 51#include "mbedtls/nist_kw.h" 52#include "mbedtls/oid.h" 53#include "mbedtls/pem.h" 54#include "mbedtls/pk.h" 55#include "mbedtls/pkcs12.h" 56#include "mbedtls/pkcs5.h" 57#if defined(MBEDTLS_HAVE_TIME) 58#include "mbedtls/platform_time.h" 59#endif 60#include "mbedtls/platform_util.h" 61#include "mbedtls/poly1305.h" 62#include "mbedtls/ripemd160.h" 63#include "mbedtls/rsa.h" 64#include "mbedtls/sha1.h" 65#include "mbedtls/sha256.h" 66#include "mbedtls/sha512.h" 67#include "mbedtls/ssl.h" 68#include "mbedtls/ssl_cache.h" 69#include "mbedtls/ssl_ciphersuites.h" 70#include "mbedtls/ssl_cookie.h" 71#include "mbedtls/ssl_ticket.h" 72#include "mbedtls/threading.h" 73#include "mbedtls/timing.h" 74#include "mbedtls/version.h" 75#include "mbedtls/x509.h" 76#include "mbedtls/x509_crl.h" 77#include "mbedtls/x509_crt.h" 78#include "mbedtls/x509_csr.h" 79 80#include <string.h> 81 82/* 83 * Helper macros to convert a macro or its expansion into a string 84 * WARNING: This does not work for expanding function-like macros. However, 85 * Mbed TLS does not currently have configuration options used in this fashion. 86 */ 87#define MACRO_EXPANSION_TO_STR(macro) MACRO_NAME_TO_STR(macro) 88#define MACRO_NAME_TO_STR(macro) \ 89 mbedtls_printf("%s", strlen( #macro "") > 0 ? #macro "\n" : "") 90 91#define STRINGIFY(macro) #macro 92#define OUTPUT_MACRO_NAME_VALUE(macro) mbedtls_printf( #macro "%s\n", \ 93 (STRINGIFY(macro) "")[0] != 0 ? "=" STRINGIFY( \ 94 macro) : "") 95 96#if defined(_MSC_VER) 97/* 98 * Visual Studio throws the warning 4003 because many Mbed TLS feature macros 99 * are defined empty. This means that from the preprocessor's point of view 100 * the macro MBEDTLS_EXPANSION_TO_STR is being invoked without arguments as 101 * some macros expand to nothing. We suppress that specific warning to get a 102 * clean build and to ensure that tests treating warnings as errors do not 103 * fail. 104 */ 105#pragma warning(push) 106#pragma warning(disable:4003) 107#endif /* _MSC_VER */ 108 109int query_config(const char *config) 110{ 111 CHECK_CONFIG /* If the symbol is not found, return an error */ 112 return 1; 113} 114 115void list_config(void) 116{ 117 LIST_CONFIG 118} 119#if defined(_MSC_VER) 120#pragma warning(pop) 121#endif /* _MSC_VER */ 122