• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
6 *
7 *  Licensed under the Apache License, Version 2.0 (the "License"); you may
8 *  not use this file except in compliance with the License.
9 *  You may obtain a copy of the License at
10 *
11 *  http://www.apache.org/licenses/LICENSE-2.0
12 *
13 *  Unless required by applicable law or agreed to in writing, software
14 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 *  See the License for the specific language governing permissions and
17 *  limitations under the License.
18 */
19
20#include "mbedtls/build_info.h"
21
22#include "query_config.h"
23
24#include "mbedtls/platform.h"
25
26/*
27 * Include all the headers with public APIs in case they define a macro to its
28 * default value when that configuration is not set in mbedtls_config.h, or
29 * for PSA_WANT macros, in case they're auto-defined based on mbedtls_config.h
30 * rather than defined directly in crypto_config.h.
31 */
32#include "psa/crypto.h"
33
34#include "mbedtls/aes.h"
35#include "mbedtls/aria.h"
36#include "mbedtls/asn1.h"
37#include "mbedtls/asn1write.h"
38#include "mbedtls/base64.h"
39#include "mbedtls/bignum.h"
40#include "mbedtls/camellia.h"
41#include "mbedtls/ccm.h"
42#include "mbedtls/chacha20.h"
43#include "mbedtls/chachapoly.h"
44#include "mbedtls/cipher.h"
45#include "mbedtls/cmac.h"
46#include "mbedtls/ctr_drbg.h"
47#include "mbedtls/debug.h"
48#include "mbedtls/des.h"
49#include "mbedtls/dhm.h"
50#include "mbedtls/ecdh.h"
51#include "mbedtls/ecdsa.h"
52#include "mbedtls/ecjpake.h"
53#include "mbedtls/ecp.h"
54#include "mbedtls/entropy.h"
55#include "mbedtls/error.h"
56#include "mbedtls/gcm.h"
57#include "mbedtls/hkdf.h"
58#include "mbedtls/hmac_drbg.h"
59#include "mbedtls/md.h"
60#include "mbedtls/md5.h"
61#include "mbedtls/memory_buffer_alloc.h"
62#include "mbedtls/net_sockets.h"
63#include "mbedtls/nist_kw.h"
64#include "mbedtls/oid.h"
65#include "mbedtls/pem.h"
66#include "mbedtls/pk.h"
67#include "mbedtls/pkcs12.h"
68#include "mbedtls/pkcs5.h"
69#if defined(MBEDTLS_HAVE_TIME)
70#include "mbedtls/platform_time.h"
71#endif
72#include "mbedtls/platform_util.h"
73#include "mbedtls/poly1305.h"
74#include "mbedtls/ripemd160.h"
75#include "mbedtls/rsa.h"
76#include "mbedtls/sha1.h"
77#include "mbedtls/sha256.h"
78#include "mbedtls/sha512.h"
79#include "mbedtls/ssl.h"
80#include "mbedtls/ssl_cache.h"
81#include "mbedtls/ssl_ciphersuites.h"
82#include "mbedtls/ssl_cookie.h"
83#include "mbedtls/ssl_ticket.h"
84#include "mbedtls/threading.h"
85#include "mbedtls/timing.h"
86#include "mbedtls/version.h"
87#include "mbedtls/x509.h"
88#include "mbedtls/x509_crl.h"
89#include "mbedtls/x509_crt.h"
90#include "mbedtls/x509_csr.h"
91
92#include <string.h>
93
94/*
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 */
99#define MACRO_EXPANSION_TO_STR(macro)   MACRO_NAME_TO_STR(macro)
100#define MACRO_NAME_TO_STR(macro)                                        \
101    mbedtls_printf("%s", strlen( #macro "") > 0 ? #macro "\n" : "")
102
103#define STRINGIFY(macro)  #macro
104#define OUTPUT_MACRO_NAME_VALUE(macro) mbedtls_printf( #macro "%s\n",   \
105                                                       (STRINGIFY(macro) "")[0] != 0 ? "=" STRINGIFY( \
106                                                           macro) : "")
107
108#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
121int query_config(const char *config)
122{
123    CHECK_CONFIG /* If the symbol is not found, return an error */
124    return 1;
125}
126
127void list_config(void)
128{
129    LIST_CONFIG
130}
131#if defined(_MSC_VER)
132#pragma warning(pop)
133#endif /* _MSC_VER */
134