Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 1 | /* |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 2 | * Query Mbed TLS compile time configurations from mbedtls_config.h |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 3 | * |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 4 | * Copyright The Mbed TLS Contributors |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 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. |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 18 | */ |
| 19 | |
Bence Szépkúti | c662b36 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 20 | #include "mbedtls/build_info.h" |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 21 | |
Gilles Peskine | c772b18 | 2021-01-12 15:55:10 +0100 | [diff] [blame] | 22 | #include "query_config.h" |
| 23 | |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 24 | #if defined(MBEDTLS_PLATFORM_C) |
| 25 | #include "mbedtls/platform.h" |
| 26 | #else |
Andres Amaya Garcia | 2fdc2c2 | 2018-10-29 18:38:36 +0000 | [diff] [blame] | 27 | #include <stdio.h> |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 28 | #define mbedtls_printf printf |
| 29 | #endif /* MBEDTLS_PLATFORM_C */ |
| 30 | |
Andres Amaya Garcia | c28da7e | 2018-10-29 18:58:41 +0000 | [diff] [blame] | 31 | /* |
| 32 | * Include all the headers with public APIs in case they define a macro to its |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 33 | * default value when that configuration is not set in the mbedtls_config.h. |
Andres Amaya Garcia | c28da7e | 2018-10-29 18:58:41 +0000 | [diff] [blame] | 34 | */ |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 35 | #include "mbedtls/aes.h" |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 36 | #include "mbedtls/aria.h" |
| 37 | #include "mbedtls/asn1.h" |
| 38 | #include "mbedtls/asn1write.h" |
| 39 | #include "mbedtls/base64.h" |
| 40 | #include "mbedtls/bignum.h" |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 41 | #include "mbedtls/camellia.h" |
| 42 | #include "mbedtls/ccm.h" |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 43 | #include "mbedtls/chacha20.h" |
| 44 | #include "mbedtls/chachapoly.h" |
| 45 | #include "mbedtls/cipher.h" |
| 46 | #include "mbedtls/cmac.h" |
| 47 | #include "mbedtls/ctr_drbg.h" |
| 48 | #include "mbedtls/debug.h" |
| 49 | #include "mbedtls/des.h" |
| 50 | #include "mbedtls/dhm.h" |
| 51 | #include "mbedtls/ecdh.h" |
| 52 | #include "mbedtls/ecdsa.h" |
| 53 | #include "mbedtls/ecjpake.h" |
| 54 | #include "mbedtls/ecp.h" |
| 55 | #include "mbedtls/entropy.h" |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 56 | #include "mbedtls/error.h" |
| 57 | #include "mbedtls/gcm.h" |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 58 | #include "mbedtls/hkdf.h" |
| 59 | #include "mbedtls/hmac_drbg.h" |
| 60 | #include "mbedtls/md.h" |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 61 | #include "mbedtls/md5.h" |
| 62 | #include "mbedtls/memory_buffer_alloc.h" |
| 63 | #include "mbedtls/net_sockets.h" |
| 64 | #include "mbedtls/nist_kw.h" |
| 65 | #include "mbedtls/oid.h" |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 66 | #include "mbedtls/pem.h" |
| 67 | #include "mbedtls/pk.h" |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 68 | #include "mbedtls/pkcs12.h" |
| 69 | #include "mbedtls/pkcs5.h" |
| 70 | #include "mbedtls/platform_time.h" |
| 71 | #include "mbedtls/platform_util.h" |
| 72 | #include "mbedtls/poly1305.h" |
| 73 | #include "mbedtls/ripemd160.h" |
| 74 | #include "mbedtls/rsa.h" |
| 75 | #include "mbedtls/sha1.h" |
| 76 | #include "mbedtls/sha256.h" |
| 77 | #include "mbedtls/sha512.h" |
| 78 | #include "mbedtls/ssl.h" |
| 79 | #include "mbedtls/ssl_cache.h" |
| 80 | #include "mbedtls/ssl_ciphersuites.h" |
| 81 | #include "mbedtls/ssl_cookie.h" |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 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" |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 90 | |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 91 | #include <string.h> |
| 92 | |
Andres Amaya Garcia | 27b3372 | 2018-12-05 10:47:31 +0000 | [diff] [blame] | 93 | /* |
| 94 | * Helper macros to convert a macro or its expansion into a string |
| 95 | * WARNING: This does not work for expanding function-like macros. However, |
| 96 | * Mbed TLS does not currently have configuration options used in this fashion. |
| 97 | */ |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 98 | #define MACRO_EXPANSION_TO_STR(macro) MACRO_NAME_TO_STR(macro) |
Andres Amaya Garcia | 27b3372 | 2018-12-05 10:47:31 +0000 | [diff] [blame] | 99 | #define MACRO_NAME_TO_STR(macro) \ |
| 100 | mbedtls_printf( "%s", strlen( #macro "" ) > 0 ? #macro "\n" : "" ) |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 101 | |
Jerry Yu | 84e63a7 | 2021-12-06 13:40:37 +0800 | [diff] [blame^] | 102 | #define NAME_TO_STR(macro) #macro |
| 103 | #define OUTPUT_MACRO_NAME_VALUE(macro) mbedtls_printf( #macro "%s\n", \ |
| 104 | strlen( NAME_TO_STR(macro) "") > 0 ? "=" NAME_TO_STR(macro) : "" ) |
| 105 | |
Andres Amaya Garcia | 17c53c5 | 2019-01-24 09:55:14 +0000 | [diff] [blame] | 106 | #if defined(_MSC_VER) |
| 107 | /* |
| 108 | * Visual Studio throws the warning 4003 because many Mbed TLS feature macros |
| 109 | * are defined empty. This means that from the preprocessor's point of view |
| 110 | * the macro MBEDTLS_EXPANSION_TO_STR is being invoked without arguments as |
| 111 | * some macros expand to nothing. We suppress that specific warning to get a |
| 112 | * clean build and to ensure that tests treating warnings as errors do not |
| 113 | * fail. |
| 114 | */ |
| 115 | #pragma warning(push) |
| 116 | #pragma warning(disable:4003) |
| 117 | #endif /* _MSC_VER */ |
| 118 | |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 119 | int query_config( const char *config ) |
| 120 | { |
Andres Amaya Garcia | c28da7e | 2018-10-29 18:58:41 +0000 | [diff] [blame] | 121 | CHECK_CONFIG /* If the symbol is not found, return an error */ |
| 122 | return( 1 ); |
Andres Amaya Garcia | 88121a9 | 2018-10-16 22:00:13 +0100 | [diff] [blame] | 123 | } |
Andres Amaya Garcia | 17c53c5 | 2019-01-24 09:55:14 +0000 | [diff] [blame] | 124 | |
Jerry Yu | 84e63a7 | 2021-12-06 13:40:37 +0800 | [diff] [blame^] | 125 | void list_config( void ) |
| 126 | { |
| 127 | LIST_CONFIG |
| 128 | } |
Andres Amaya Garcia | 17c53c5 | 2019-01-24 09:55:14 +0000 | [diff] [blame] | 129 | #if defined(_MSC_VER) |
| 130 | #pragma warning(pop) |
| 131 | #endif /* _MSC_VER */ |