Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
Gabor Mezei | 9f2b817 | 2024-08-06 12:02:18 +0200 | [diff] [blame] | 3 | """Mbed TLS and PSA configuration file manipulation library and tool |
Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 4 | |
Fredrik Hesse | cc207bc | 2021-09-28 21:06:08 +0200 | [diff] [blame] | 5 | Basic usage, to read the Mbed TLS configuration: |
Gabor Mezei | 9f2b817 | 2024-08-06 12:02:18 +0200 | [diff] [blame] | 6 | config = CombinedConfigFile() |
Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 7 | if 'MBEDTLS_RSA_C' in config: print('RSA is enabled') |
| 8 | """ |
| 9 | |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 10 | ## Copyright The Mbed TLS Contributors |
Dave Rodgman | 16799db | 2023-11-02 19:47:20 +0000 | [diff] [blame] | 11 | ## SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 12 | ## |
Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 13 | |
Gilles Peskine | 208e4ec | 2019-07-29 23:43:20 +0200 | [diff] [blame] | 14 | import os |
Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 15 | import re |
Gabor Mezei | 24d7cc7 | 2024-08-06 15:11:24 +0200 | [diff] [blame] | 16 | import sys |
Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 17 | |
Gabor Mezei | 0e9e4cb | 2024-09-10 16:16:35 +0200 | [diff] [blame] | 18 | import framework_scripts_path # pylint: disable=unused-import |
| 19 | from mbedtls_framework import config_common |
Gabor Mezei | d53080d | 2024-08-27 14:06:54 +0200 | [diff] [blame] | 20 | |
Gabor Mezei | a12ed6b | 2024-09-09 17:20:49 +0200 | [diff] [blame] | 21 | |
Gilles Peskine | 53d41ae | 2019-07-27 23:31:53 +0200 | [diff] [blame] | 22 | def is_full_section(section): |
Gabor Mezei | de6e192 | 2024-06-28 17:10:50 +0200 | [diff] [blame] | 23 | """Is this section affected by "config.py full" and friends? |
| 24 | |
| 25 | In a config file where the sections are not used the whole config file |
| 26 | is an empty section (with value None) and the whole file is affected. |
| 27 | """ |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 28 | return section is None or section.endswith('support') or section.endswith('modules') |
Gilles Peskine | 53d41ae | 2019-07-27 23:31:53 +0200 | [diff] [blame] | 29 | |
| 30 | def realfull_adapter(_name, active, section): |
Gilles Peskine | ba4162a | 2022-04-11 17:04:38 +0200 | [diff] [blame] | 31 | """Activate all symbols found in the global and boolean feature sections. |
| 32 | |
| 33 | This is intended for building the documentation, including the |
| 34 | documentation of settings that are activated by defining an optional |
| 35 | preprocessor macro. |
| 36 | |
| 37 | Do not activate definitions in the section containing symbols that are |
| 38 | supposed to be defined and documented in their own module. |
| 39 | """ |
| 40 | if section == 'Module configuration options': |
Gilles Peskine | 53d41ae | 2019-07-27 23:31:53 +0200 | [diff] [blame] | 41 | return active |
Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 42 | return True |
| 43 | |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 44 | PSA_UNSUPPORTED_FEATURE = frozenset([ |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 45 | 'PSA_WANT_ALG_CBC_MAC', |
| 46 | 'PSA_WANT_ALG_XTS', |
| 47 | 'PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_DERIVE', |
| 48 | 'PSA_WANT_KEY_TYPE_DH_KEY_PAIR_DERIVE' |
| 49 | ]) |
| 50 | |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 51 | PSA_DEPRECATED_FEATURE = frozenset([ |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 52 | 'PSA_WANT_KEY_TYPE_ECC_KEY_PAIR', |
| 53 | 'PSA_WANT_KEY_TYPE_RSA_KEY_PAIR' |
| 54 | ]) |
| 55 | |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 56 | PSA_UNSTABLE_FEATURE = frozenset([ |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 57 | 'PSA_WANT_ECC_SECP_K1_224' |
| 58 | ]) |
| 59 | |
Gabor Mezei | 9b0f9e7 | 2024-06-26 18:08:17 +0200 | [diff] [blame] | 60 | EXCLUDE_FROM_CRYPTO = PSA_UNSUPPORTED_FEATURE | \ |
| 61 | PSA_DEPRECATED_FEATURE | \ |
| 62 | PSA_UNSTABLE_FEATURE |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 63 | |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 64 | # The goal of the full configuration is to have everything that can be tested |
| 65 | # together. This includes deprecated or insecure options. It excludes: |
| 66 | # * Options that require additional build dependencies or unusual hardware. |
| 67 | # * Options that make testing less effective. |
Gilles Peskine | c9d0433 | 2020-04-16 20:50:17 +0200 | [diff] [blame] | 68 | # * Options that are incompatible with other options, or more generally that |
| 69 | # interact with other parts of the code in such a way that a bulk enabling |
| 70 | # is not a good way to test them. |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 71 | # * Options that remove features. |
Gilles Peskine | bbaa2b7 | 2020-04-12 13:33:57 +0200 | [diff] [blame] | 72 | EXCLUDE_FROM_FULL = frozenset([ |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 73 | #pylint: disable=line-too-long |
Yanray Wang | a870467 | 2023-04-20 17:16:48 +0800 | [diff] [blame] | 74 | 'MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH', # interacts with CTR_DRBG_128_BIT_KEY |
Gilles Peskine | a8861e0 | 2023-09-05 20:20:51 +0200 | [diff] [blame] | 75 | 'MBEDTLS_AES_USE_HARDWARE_ONLY', # hardware dependency |
Yanray Wang | 42be1ba | 2023-11-23 14:28:47 +0800 | [diff] [blame] | 76 | 'MBEDTLS_BLOCK_CIPHER_NO_DECRYPT', # incompatible with ECB in PSA, CBC/XTS/NIST_KW/DES |
Gilles Peskine | c9d0433 | 2020-04-16 20:50:17 +0200 | [diff] [blame] | 77 | 'MBEDTLS_CTR_DRBG_USE_128_BIT_KEY', # interacts with ENTROPY_FORCE_SHA256 |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 78 | 'MBEDTLS_DEPRECATED_REMOVED', # conflicts with deprecated options |
Gilles Peskine | 90581ee | 2020-04-12 14:02:47 +0200 | [diff] [blame] | 79 | 'MBEDTLS_DEPRECATED_WARNING', # conflicts with deprecated options |
Gilles Peskine | c9d0433 | 2020-04-16 20:50:17 +0200 | [diff] [blame] | 80 | 'MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED', # influences the use of ECDH in TLS |
Janos Follath | 5b7c38f | 2023-08-01 08:51:12 +0100 | [diff] [blame] | 81 | 'MBEDTLS_ECP_WITH_MPI_UINT', # disables the default ECP and is experimental |
Gilles Peskine | c9d0433 | 2020-04-16 20:50:17 +0200 | [diff] [blame] | 82 | 'MBEDTLS_ENTROPY_FORCE_SHA256', # interacts with CTR_DRBG_128_BIT_KEY |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 83 | 'MBEDTLS_HAVE_SSE2', # hardware dependency |
| 84 | 'MBEDTLS_MEMORY_BACKTRACE', # depends on MEMORY_BUFFER_ALLOC_C |
| 85 | 'MBEDTLS_MEMORY_BUFFER_ALLOC_C', # makes sanitizers (e.g. ASan) less effective |
| 86 | 'MBEDTLS_MEMORY_DEBUG', # depends on MEMORY_BUFFER_ALLOC_C |
Gilles Peskine | c9d0433 | 2020-04-16 20:50:17 +0200 | [diff] [blame] | 87 | 'MBEDTLS_NO_64BIT_MULTIPLICATION', # influences anything that uses bignum |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 88 | 'MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES', # removes a feature |
| 89 | 'MBEDTLS_NO_PLATFORM_ENTROPY', # removes a feature |
Gilles Peskine | c9d0433 | 2020-04-16 20:50:17 +0200 | [diff] [blame] | 90 | 'MBEDTLS_NO_UDBL_DIVISION', # influences anything that uses bignum |
Gilles Peskine | efaee9a | 2023-09-20 20:49:47 +0200 | [diff] [blame] | 91 | 'MBEDTLS_PSA_P256M_DRIVER_ENABLED', # influences SECP256R1 KeyGen/ECDH/ECDSA |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 92 | 'MBEDTLS_PLATFORM_NO_STD_FUNCTIONS', # removes a feature |
David Horstmann | 6f8c95b | 2024-03-14 14:52:45 +0000 | [diff] [blame] | 93 | 'MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS', # removes a feature |
Gilles Peskine | f08b3f8 | 2020-11-13 17:36:48 +0100 | [diff] [blame] | 94 | 'MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG', # behavior change + build dependency |
Ronald Cron | c3623db | 2020-10-29 10:51:32 +0100 | [diff] [blame] | 95 | 'MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER', # incompatible with USE_PSA_CRYPTO |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 96 | 'MBEDTLS_PSA_CRYPTO_SPM', # platform dependency (PSA SPM) |
Gilles Peskine | a08def9 | 2023-04-28 21:01:49 +0200 | [diff] [blame] | 97 | 'MBEDTLS_PSA_INJECT_ENTROPY', # conflicts with platform entropy sources |
Gilles Peskine | c9d0433 | 2020-04-16 20:50:17 +0200 | [diff] [blame] | 98 | 'MBEDTLS_RSA_NO_CRT', # influences the use of RSA in X.509 and TLS |
Tom Cosgrove | 87fbfb5 | 2022-03-15 10:51:52 +0000 | [diff] [blame] | 99 | 'MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY', # interacts with *_USE_A64_CRYPTO_IF_PRESENT |
Dave Rodgman | 9be3cf0 | 2023-10-11 14:47:55 +0100 | [diff] [blame] | 100 | 'MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY', # interacts with *_USE_ARMV8_A_CRYPTO_IF_PRESENT |
Tom Cosgrove | 87fbfb5 | 2022-03-15 10:51:52 +0000 | [diff] [blame] | 101 | 'MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY', # interacts with *_USE_A64_CRYPTO_IF_PRESENT |
Dave Rodgman | 7cb635a | 2023-10-12 16:14:51 +0100 | [diff] [blame] | 102 | 'MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT', # setting *_USE_ARMV8_A_CRYPTO is sufficient |
Manuel Pégourié-Gonnard | 6240def | 2020-07-10 09:35:54 +0200 | [diff] [blame] | 103 | 'MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN', # build dependency (clang+memsan) |
Manuel Pégourié-Gonnard | 73afa37 | 2020-08-19 10:27:38 +0200 | [diff] [blame] | 104 | 'MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND', # build dependency (valgrind headers) |
Hanno Becker | e111356 | 2019-06-12 13:59:14 +0100 | [diff] [blame] | 105 | 'MBEDTLS_X509_REMOVE_INFO', # removes a feature |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 106 | *PSA_UNSUPPORTED_FEATURE, |
| 107 | *PSA_DEPRECATED_FEATURE, |
| 108 | *PSA_UNSTABLE_FEATURE |
Gilles Peskine | bbaa2b7 | 2020-04-12 13:33:57 +0200 | [diff] [blame] | 109 | ]) |
| 110 | |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 111 | def is_seamless_alt(name): |
Gilles Peskine | c34faba | 2020-04-20 15:44:14 +0200 | [diff] [blame] | 112 | """Whether the xxx_ALT symbol should be included in the full configuration. |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 113 | |
Gilles Peskine | c34faba | 2020-04-20 15:44:14 +0200 | [diff] [blame] | 114 | Include alternative implementations of platform functions, which are |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 115 | configurable function pointers that default to the built-in function. |
| 116 | This way we test that the function pointers exist and build correctly |
| 117 | without changing the behavior, and tests can verify that the function |
| 118 | pointers are used by modifying those pointers. |
| 119 | |
| 120 | Exclude alternative implementations of library functions since they require |
| 121 | an implementation of the relevant functions and an xxx_alt.h header. |
| 122 | """ |
Gilles Peskine | a8861e0 | 2023-09-05 20:20:51 +0200 | [diff] [blame] | 123 | if name in ( |
| 124 | 'MBEDTLS_PLATFORM_GMTIME_R_ALT', |
| 125 | 'MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT', |
| 126 | 'MBEDTLS_PLATFORM_MS_TIME_ALT', |
| 127 | 'MBEDTLS_PLATFORM_ZEROIZE_ALT', |
| 128 | ): |
Gilles Peskine | c34faba | 2020-04-20 15:44:14 +0200 | [diff] [blame] | 129 | # Similar to non-platform xxx_ALT, requires platform_alt.h |
| 130 | return False |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 131 | return name.startswith('MBEDTLS_PLATFORM_') |
| 132 | |
Gilles Peskine | 53d41ae | 2019-07-27 23:31:53 +0200 | [diff] [blame] | 133 | def include_in_full(name): |
| 134 | """Rules for symbols in the "full" configuration.""" |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 135 | if name in EXCLUDE_FROM_FULL: |
Gilles Peskine | 53d41ae | 2019-07-27 23:31:53 +0200 | [diff] [blame] | 136 | return False |
| 137 | if name.endswith('_ALT'): |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 138 | return is_seamless_alt(name) |
Gilles Peskine | 53d41ae | 2019-07-27 23:31:53 +0200 | [diff] [blame] | 139 | return True |
| 140 | |
| 141 | def full_adapter(name, active, section): |
| 142 | """Config adapter for "full".""" |
| 143 | if not is_full_section(section): |
| 144 | return active |
| 145 | return include_in_full(name) |
| 146 | |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 147 | # The baremetal configuration excludes options that require a library or |
| 148 | # operating system feature that is typically not present on bare metal |
| 149 | # systems. Features that are excluded from "full" won't be in "baremetal" |
| 150 | # either (unless explicitly turned on in baremetal_adapter) so they don't |
| 151 | # need to be repeated here. |
Gilles Peskine | bbaa2b7 | 2020-04-12 13:33:57 +0200 | [diff] [blame] | 152 | EXCLUDE_FROM_BAREMETAL = frozenset([ |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 153 | #pylint: disable=line-too-long |
Gilles Peskine | 98f8f95 | 2020-04-20 15:38:39 +0200 | [diff] [blame] | 154 | 'MBEDTLS_ENTROPY_NV_SEED', # requires a filesystem and FS_IO or alternate NV seed hooks |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 155 | 'MBEDTLS_FS_IO', # requires a filesystem |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 156 | 'MBEDTLS_HAVE_TIME', # requires a clock |
| 157 | 'MBEDTLS_HAVE_TIME_DATE', # requires a clock |
| 158 | 'MBEDTLS_NET_C', # requires POSIX-like networking |
| 159 | 'MBEDTLS_PLATFORM_FPRINTF_ALT', # requires FILE* from stdio.h |
Gilles Peskine | 98f8f95 | 2020-04-20 15:38:39 +0200 | [diff] [blame] | 160 | 'MBEDTLS_PLATFORM_NV_SEED_ALT', # requires a filesystem and ENTROPY_NV_SEED |
| 161 | 'MBEDTLS_PLATFORM_TIME_ALT', # requires a clock and HAVE_TIME |
| 162 | 'MBEDTLS_PSA_CRYPTO_SE_C', # requires a filesystem and PSA_CRYPTO_STORAGE_C |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 163 | 'MBEDTLS_PSA_CRYPTO_STORAGE_C', # requires a filesystem |
| 164 | 'MBEDTLS_PSA_ITS_FILE_C', # requires a filesystem |
| 165 | 'MBEDTLS_THREADING_C', # requires a threading interface |
| 166 | 'MBEDTLS_THREADING_PTHREAD', # requires pthread |
| 167 | 'MBEDTLS_TIMING_C', # requires a clock |
Dave Rodgman | 9be3cf0 | 2023-10-11 14:47:55 +0100 | [diff] [blame] | 168 | 'MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT', # requires an OS for runtime-detection |
Dave Rodgman | 5b89c55 | 2023-10-10 14:59:02 +0100 | [diff] [blame] | 169 | 'MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT', # requires an OS for runtime-detection |
Dave Rodgman | be7915a | 2023-10-11 10:46:38 +0100 | [diff] [blame] | 170 | 'MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT', # requires an OS for runtime-detection |
Gilles Peskine | bbaa2b7 | 2020-04-12 13:33:57 +0200 | [diff] [blame] | 171 | ]) |
| 172 | |
Gilles Peskine | 53d41ae | 2019-07-27 23:31:53 +0200 | [diff] [blame] | 173 | def keep_in_baremetal(name): |
| 174 | """Rules for symbols in the "baremetal" configuration.""" |
Gilles Peskine | bbaa2b7 | 2020-04-12 13:33:57 +0200 | [diff] [blame] | 175 | if name in EXCLUDE_FROM_BAREMETAL: |
Gilles Peskine | 53d41ae | 2019-07-27 23:31:53 +0200 | [diff] [blame] | 176 | return False |
| 177 | return True |
| 178 | |
| 179 | def baremetal_adapter(name, active, section): |
| 180 | """Config adapter for "baremetal".""" |
| 181 | if not is_full_section(section): |
| 182 | return active |
| 183 | if name == 'MBEDTLS_NO_PLATFORM_ENTROPY': |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 184 | # No OS-provided entropy source |
Gilles Peskine | 53d41ae | 2019-07-27 23:31:53 +0200 | [diff] [blame] | 185 | return True |
| 186 | return include_in_full(name) and keep_in_baremetal(name) |
| 187 | |
Gilles Peskine | 120f29d | 2021-09-01 19:51:19 +0200 | [diff] [blame] | 188 | # This set contains options that are mostly for debugging or test purposes, |
| 189 | # and therefore should be excluded when doing code size measurements. |
| 190 | # Options that are their own module (such as MBEDTLS_ERROR_C) are not listed |
| 191 | # and therefore will be included when doing code size measurements. |
| 192 | EXCLUDE_FOR_SIZE = frozenset([ |
| 193 | 'MBEDTLS_DEBUG_C', # large code size increase in TLS |
| 194 | 'MBEDTLS_SELF_TEST', # increases the size of many modules |
| 195 | 'MBEDTLS_TEST_HOOKS', # only useful with the hosted test framework, increases code size |
| 196 | ]) |
| 197 | |
| 198 | def baremetal_size_adapter(name, active, section): |
| 199 | if name in EXCLUDE_FOR_SIZE: |
| 200 | return False |
| 201 | return baremetal_adapter(name, active, section) |
| 202 | |
Gilles Peskine | 31987c6 | 2020-01-31 14:23:30 +0100 | [diff] [blame] | 203 | def include_in_crypto(name): |
| 204 | """Rules for symbols in a crypto configuration.""" |
| 205 | if name.startswith('MBEDTLS_X509_') or \ |
| 206 | name.startswith('MBEDTLS_SSL_') or \ |
| 207 | name.startswith('MBEDTLS_KEY_EXCHANGE_'): |
| 208 | return False |
| 209 | if name in [ |
Gilles Peskine | cfffc28 | 2020-04-12 13:55:45 +0200 | [diff] [blame] | 210 | 'MBEDTLS_DEBUG_C', # part of libmbedtls |
| 211 | 'MBEDTLS_NET_C', # part of libmbedtls |
Nayna Jain | c9deb18 | 2020-11-16 19:03:12 +0000 | [diff] [blame] | 212 | 'MBEDTLS_PKCS7_C', # part of libmbedx509 |
Gilles Peskine | 31987c6 | 2020-01-31 14:23:30 +0100 | [diff] [blame] | 213 | ]: |
| 214 | return False |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 215 | if name in EXCLUDE_FROM_CRYPTO: |
| 216 | return False |
Gilles Peskine | 31987c6 | 2020-01-31 14:23:30 +0100 | [diff] [blame] | 217 | return True |
| 218 | |
| 219 | def crypto_adapter(adapter): |
| 220 | """Modify an adapter to disable non-crypto symbols. |
| 221 | |
| 222 | ``crypto_adapter(adapter)(name, active, section)`` is like |
| 223 | ``adapter(name, active, section)``, but unsets all X.509 and TLS symbols. |
| 224 | """ |
| 225 | def continuation(name, active, section): |
| 226 | if not include_in_crypto(name): |
| 227 | return False |
| 228 | if adapter is None: |
| 229 | return active |
| 230 | return adapter(name, active, section) |
| 231 | return continuation |
| 232 | |
Gilles Peskine | ed5c21d | 2022-06-27 23:02:09 +0200 | [diff] [blame] | 233 | DEPRECATED = frozenset([ |
| 234 | 'MBEDTLS_PSA_CRYPTO_SE_C', |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 235 | *PSA_DEPRECATED_FEATURE |
Gilles Peskine | ed5c21d | 2022-06-27 23:02:09 +0200 | [diff] [blame] | 236 | ]) |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 237 | def no_deprecated_adapter(adapter): |
Gilles Peskine | be1d609 | 2020-04-12 14:17:16 +0200 | [diff] [blame] | 238 | """Modify an adapter to disable deprecated symbols. |
| 239 | |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 240 | ``no_deprecated_adapter(adapter)(name, active, section)`` is like |
Gilles Peskine | be1d609 | 2020-04-12 14:17:16 +0200 | [diff] [blame] | 241 | ``adapter(name, active, section)``, but unsets all deprecated symbols |
| 242 | and sets ``MBEDTLS_DEPRECATED_REMOVED``. |
| 243 | """ |
| 244 | def continuation(name, active, section): |
| 245 | if name == 'MBEDTLS_DEPRECATED_REMOVED': |
| 246 | return True |
Gilles Peskine | ed5c21d | 2022-06-27 23:02:09 +0200 | [diff] [blame] | 247 | if name in DEPRECATED: |
| 248 | return False |
Gilles Peskine | be1d609 | 2020-04-12 14:17:16 +0200 | [diff] [blame] | 249 | if adapter is None: |
| 250 | return active |
| 251 | return adapter(name, active, section) |
| 252 | return continuation |
| 253 | |
Paul Elliott | fb81f77 | 2023-10-18 17:44:59 +0100 | [diff] [blame] | 254 | def no_platform_adapter(adapter): |
| 255 | """Modify an adapter to disable platform symbols. |
| 256 | |
| 257 | ``no_platform_adapter(adapter)(name, active, section)`` is like |
| 258 | ``adapter(name, active, section)``, but unsets all platform symbols other |
| 259 | ``than MBEDTLS_PLATFORM_C. |
| 260 | """ |
| 261 | def continuation(name, active, section): |
| 262 | # Allow MBEDTLS_PLATFORM_C but remove all other platform symbols. |
| 263 | if name.startswith('MBEDTLS_PLATFORM_') and name != 'MBEDTLS_PLATFORM_C': |
| 264 | return False |
| 265 | if adapter is None: |
| 266 | return active |
| 267 | return adapter(name, active, section) |
| 268 | return continuation |
| 269 | |
Gabor Mezei | a12ed6b | 2024-09-09 17:20:49 +0200 | [diff] [blame] | 270 | |
Gabor Mezei | 0e9e4cb | 2024-09-10 16:16:35 +0200 | [diff] [blame] | 271 | class MbedTLSConfigFile(config_common.ConfigFile): |
Gabor Mezei | 62a9bd0 | 2024-06-07 13:44:40 +0200 | [diff] [blame] | 272 | """Representation of an MbedTLS configuration file.""" |
| 273 | |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 274 | _path_in_tree = 'include/mbedtls/mbedtls_config.h' |
| 275 | default_path = [_path_in_tree, |
| 276 | os.path.join(os.path.dirname(__file__), |
| 277 | os.pardir, |
| 278 | _path_in_tree), |
| 279 | os.path.join(os.path.dirname(os.path.abspath(os.path.dirname(__file__))), |
| 280 | _path_in_tree)] |
| 281 | |
| 282 | def __init__(self, filename=None): |
Gabor Mezei | 93a6d1f | 2024-06-26 18:01:09 +0200 | [diff] [blame] | 283 | super().__init__(self.default_path, 'Mbed TLS', filename) |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 284 | self.current_section = 'header' |
| 285 | |
Gabor Mezei | a12ed6b | 2024-09-09 17:20:49 +0200 | [diff] [blame] | 286 | |
Gabor Mezei | 0e9e4cb | 2024-09-10 16:16:35 +0200 | [diff] [blame] | 287 | class CryptoConfigFile(config_common.ConfigFile): |
Gabor Mezei | 4706fe7 | 2024-07-08 17:00:55 +0200 | [diff] [blame] | 288 | """Representation of a Crypto configuration file.""" |
Gabor Mezei | 62a9bd0 | 2024-06-07 13:44:40 +0200 | [diff] [blame] | 289 | |
Gabor Mezei | 3de6586 | 2024-07-08 16:14:10 +0200 | [diff] [blame] | 290 | # Temporary, while Mbed TLS does not just rely on the TF-PSA-Crypto |
| 291 | # build system to build its crypto library. When it does, the |
| 292 | # condition can just be removed. |
Gabor Mezei | 776ee90 | 2024-09-09 17:00:50 +0200 | [diff] [blame] | 293 | _path_in_tree = ('include/psa/crypto_config.h' |
| 294 | if not os.path.isdir(os.path.join(os.path.dirname(__file__), |
| 295 | os.pardir, |
| 296 | 'tf-psa-crypto')) else |
| 297 | 'tf-psa-crypto/include/psa/crypto_config.h') |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 298 | default_path = [_path_in_tree, |
| 299 | os.path.join(os.path.dirname(__file__), |
| 300 | os.pardir, |
| 301 | _path_in_tree), |
| 302 | os.path.join(os.path.dirname(os.path.abspath(os.path.dirname(__file__))), |
| 303 | _path_in_tree)] |
| 304 | |
| 305 | def __init__(self, filename=None): |
Gabor Mezei | 93a6d1f | 2024-06-26 18:01:09 +0200 | [diff] [blame] | 306 | super().__init__(self.default_path, 'Crypto', filename) |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 307 | |
Gabor Mezei | a12ed6b | 2024-09-09 17:20:49 +0200 | [diff] [blame] | 308 | |
Gabor Mezei | 0e9e4cb | 2024-09-10 16:16:35 +0200 | [diff] [blame] | 309 | class MbedTLSConfig(config_common.Config): |
Gabor Mezei | 62a9bd0 | 2024-06-07 13:44:40 +0200 | [diff] [blame] | 310 | """Representation of the Mbed TLS configuration. |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 311 | |
| 312 | See the documentation of the `Config` class for methods to query |
| 313 | and modify the configuration. |
| 314 | """ |
Gabor Mezei | 4706fe7 | 2024-07-08 17:00:55 +0200 | [diff] [blame] | 315 | |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 316 | def __init__(self, filename=None): |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 317 | """Read the Mbed TLS configuration file.""" |
Gabor Mezei | 4706fe7 | 2024-07-08 17:00:55 +0200 | [diff] [blame] | 318 | |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 319 | super().__init__() |
Gabor Mezei | d53080d | 2024-08-27 14:06:54 +0200 | [diff] [blame] | 320 | configfile = MbedTLSConfigFile(filename) |
| 321 | self.configfiles.append(configfile) |
Gabor Mezei | 0e9e4cb | 2024-09-10 16:16:35 +0200 | [diff] [blame] | 322 | self.settings.update({name: config_common.Setting(configfile, active, name, value, section) |
Gabor Mezei | 92065ed | 2024-06-07 13:47:59 +0200 | [diff] [blame] | 323 | for (active, name, value, section) |
Gabor Mezei | d53080d | 2024-08-27 14:06:54 +0200 | [diff] [blame] | 324 | in configfile.parse_file()}) |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 325 | |
| 326 | def set(self, name, value=None): |
Gabor Mezei | 4706fe7 | 2024-07-08 17:00:55 +0200 | [diff] [blame] | 327 | """Set name to the given value and make it active.""" |
| 328 | |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 329 | if name not in self.settings: |
Gabor Mezei | d53080d | 2024-08-27 14:06:54 +0200 | [diff] [blame] | 330 | self._get_configfile().templates.append((name, '', '#define ' + name + ' ')) |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 331 | |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 332 | super().set(name, value) |
Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 333 | |
Gabor Mezei | a12ed6b | 2024-09-09 17:20:49 +0200 | [diff] [blame] | 334 | |
Gabor Mezei | 0e9e4cb | 2024-09-10 16:16:35 +0200 | [diff] [blame] | 335 | class CryptoConfig(config_common.Config): |
Gabor Mezei | 62a9bd0 | 2024-06-07 13:44:40 +0200 | [diff] [blame] | 336 | """Representation of the PSA crypto configuration. |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 337 | |
| 338 | See the documentation of the `Config` class for methods to query |
| 339 | and modify the configuration. |
| 340 | """ |
Gabor Mezei | 4706fe7 | 2024-07-08 17:00:55 +0200 | [diff] [blame] | 341 | |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 342 | def __init__(self, filename=None): |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 343 | """Read the PSA crypto configuration file.""" |
Gabor Mezei | 4706fe7 | 2024-07-08 17:00:55 +0200 | [diff] [blame] | 344 | |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 345 | super().__init__() |
Gabor Mezei | d53080d | 2024-08-27 14:06:54 +0200 | [diff] [blame] | 346 | configfile = CryptoConfigFile(filename) |
| 347 | self.configfiles.append(configfile) |
Gabor Mezei | 0e9e4cb | 2024-09-10 16:16:35 +0200 | [diff] [blame] | 348 | self.settings.update({name: config_common.Setting(configfile, active, name, value, section) |
Gabor Mezei | 92065ed | 2024-06-07 13:47:59 +0200 | [diff] [blame] | 349 | for (active, name, value, section) |
Gabor Mezei | d53080d | 2024-08-27 14:06:54 +0200 | [diff] [blame] | 350 | in configfile.parse_file()}) |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 351 | |
Gabor Mezei | d723b51 | 2024-06-07 15:31:52 +0200 | [diff] [blame] | 352 | def set(self, name, value='1'): |
Gabor Mezei | 4706fe7 | 2024-07-08 17:00:55 +0200 | [diff] [blame] | 353 | """Set name to the given value and make it active.""" |
| 354 | |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 355 | if name in PSA_UNSUPPORTED_FEATURE: |
Gabor Mezei | 92065ed | 2024-06-07 13:47:59 +0200 | [diff] [blame] | 356 | raise ValueError(f'Feature is unsupported: \'{name}\'') |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 357 | if name in PSA_UNSTABLE_FEATURE: |
Gabor Mezei | 92065ed | 2024-06-07 13:47:59 +0200 | [diff] [blame] | 358 | raise ValueError(f'Feature is unstable: \'{name}\'') |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 359 | |
| 360 | if name not in self.settings: |
Gabor Mezei | d53080d | 2024-08-27 14:06:54 +0200 | [diff] [blame] | 361 | self._get_configfile().templates.append((name, '', '#define ' + name + ' ')) |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 362 | |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 363 | super().set(name, value) |
| 364 | |
Gabor Mezei | a12ed6b | 2024-09-09 17:20:49 +0200 | [diff] [blame] | 365 | |
Gabor Mezei | 0e9e4cb | 2024-09-10 16:16:35 +0200 | [diff] [blame] | 366 | class CombinedConfig(config_common.Config): |
Gabor Mezei | 62a9bd0 | 2024-06-07 13:44:40 +0200 | [diff] [blame] | 367 | """Representation of MbedTLS and PSA crypto configuration |
| 368 | |
| 369 | See the documentation of the `Config` class for methods to query |
| 370 | and modify the configuration. |
| 371 | """ |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 372 | |
Gabor Mezei | 3e2a550 | 2024-06-28 17:27:19 +0200 | [diff] [blame] | 373 | def __init__(self, *configs): |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 374 | super().__init__() |
Gabor Mezei | 3e2a550 | 2024-06-28 17:27:19 +0200 | [diff] [blame] | 375 | for config in configs: |
| 376 | if isinstance(config, MbedTLSConfigFile): |
| 377 | self.mbedtls_configfile = config |
| 378 | elif isinstance(config, CryptoConfigFile): |
| 379 | self.crypto_configfile = config |
| 380 | else: |
| 381 | raise ValueError(f'Invalid configfile: {config}') |
Gabor Mezei | d53080d | 2024-08-27 14:06:54 +0200 | [diff] [blame] | 382 | self.configfiles.append(config) |
Gabor Mezei | 3e2a550 | 2024-06-28 17:27:19 +0200 | [diff] [blame] | 383 | |
Gabor Mezei | 0e9e4cb | 2024-09-10 16:16:35 +0200 | [diff] [blame] | 384 | self.settings.update({name: config_common.Setting(configfile, active, name, value, section) |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 385 | for configfile in [self.mbedtls_configfile, self.crypto_configfile] |
| 386 | for (active, name, value, section) in configfile.parse_file()}) |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 387 | |
| 388 | _crypto_regexp = re.compile(r'$PSA_.*') |
Gabor Mezei | d53080d | 2024-08-27 14:06:54 +0200 | [diff] [blame] | 389 | def _get_configfile(self, name=None): |
Gabor Mezei | 4706fe7 | 2024-07-08 17:00:55 +0200 | [diff] [blame] | 390 | """Find a config type for a setting name""" |
| 391 | |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 392 | if name in self.settings: |
| 393 | return self.settings[name].configfile |
| 394 | elif re.match(self._crypto_regexp, name): |
| 395 | return self.crypto_configfile |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 396 | else: |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 397 | return self.mbedtls_configfile |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 398 | |
| 399 | def set(self, name, value=None): |
Gabor Mezei | 4706fe7 | 2024-07-08 17:00:55 +0200 | [diff] [blame] | 400 | """Set name to the given value and make it active.""" |
| 401 | |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 402 | configfile = self._get_configfile(name) |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 403 | |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 404 | if configfile == self.crypto_configfile: |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 405 | if name in PSA_UNSUPPORTED_FEATURE: |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 406 | raise ValueError(f'Feature is unsupported: \'{name}\'') |
Gabor Mezei | 542fd38 | 2024-06-10 14:07:42 +0200 | [diff] [blame] | 407 | if name in PSA_UNSTABLE_FEATURE: |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 408 | raise ValueError(f'Feature is unstable: \'{name}\'') |
| 409 | |
Gabor Mezei | d723b51 | 2024-06-07 15:31:52 +0200 | [diff] [blame] | 410 | # The default value in the crypto config is '1' |
| 411 | if not value: |
| 412 | value = '1' |
| 413 | |
Gabor Mezei | c659c1b | 2024-08-06 17:37:55 +0200 | [diff] [blame] | 414 | if name not in self.settings: |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 415 | configfile.templates.append((name, '', '#define ' + name + ' ')) |
| 416 | |
Gabor Mezei | d53080d | 2024-08-27 14:06:54 +0200 | [diff] [blame] | 417 | super().set(name, value) |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 418 | |
Gabor Mezei | daf807f | 2024-08-14 11:33:46 +0200 | [diff] [blame] | 419 | #pylint: disable=arguments-differ |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 420 | def write(self, mbedtls_file=None, crypto_file=None): |
Gabor Mezei | 62a9bd0 | 2024-06-07 13:44:40 +0200 | [diff] [blame] | 421 | """Write the whole configuration to the file it was read from. |
| 422 | |
| 423 | If mbedtls_file or crypto_file is specified, write the specific configuration |
| 424 | to the corresponding file instead. |
Gabor Mezei | f5f1308 | 2024-09-18 13:02:16 +0200 | [diff] [blame^] | 425 | |
| 426 | The parameter name is differ from the definition of the super class to handle |
| 427 | two different config files. |
Gabor Mezei | 62a9bd0 | 2024-06-07 13:44:40 +0200 | [diff] [blame] | 428 | """ |
Gabor Mezei | 4706fe7 | 2024-07-08 17:00:55 +0200 | [diff] [blame] | 429 | |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 430 | self.mbedtls_configfile.write(self.settings, mbedtls_file) |
| 431 | self.crypto_configfile.write(self.settings, crypto_file) |
Gabor Mezei | 3678dee | 2024-06-04 19:58:43 +0200 | [diff] [blame] | 432 | |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 433 | def filename(self, name=None): |
Gabor Mezei | f5f1308 | 2024-09-18 13:02:16 +0200 | [diff] [blame^] | 434 | """Get the name of the config files. |
Gabor Mezei | 4706fe7 | 2024-07-08 17:00:55 +0200 | [diff] [blame] | 435 | |
| 436 | If 'name' is specified return the name of the config file where it is defined. |
| 437 | """ |
| 438 | |
Gabor Mezei | ee521b6 | 2024-06-07 13:50:41 +0200 | [diff] [blame] | 439 | if not name: |
| 440 | return [config.filename for config in [self.mbedtls_configfile, self.crypto_configfile]] |
| 441 | |
| 442 | return self._get_configfile(name).filename |
Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 443 | |
Gabor Mezei | 24d7cc7 | 2024-08-06 15:11:24 +0200 | [diff] [blame] | 444 | |
Gabor Mezei | 0e9e4cb | 2024-09-10 16:16:35 +0200 | [diff] [blame] | 445 | class MbedTLSConfigTool(config_common.ConfigTool): |
Gabor Mezei | 24d7cc7 | 2024-08-06 15:11:24 +0200 | [diff] [blame] | 446 | """Command line mbedtls_config.h and crypto_config.h manipulation tool.""" |
| 447 | |
| 448 | def __init__(self): |
| 449 | super().__init__(MbedTLSConfigFile) |
| 450 | self.config = CombinedConfig(MbedTLSConfigFile(self.parser_args.file), |
| 451 | CryptoConfigFile(self.parser_args.cryptofile)) |
| 452 | |
| 453 | def custom_parser_options(self): |
| 454 | """Adds MbedTLS specific options for the parser.""" |
| 455 | |
Gabor Mezei | a12ed6b | 2024-09-09 17:20:49 +0200 | [diff] [blame] | 456 | self.parser.add_argument( |
| 457 | '--cryptofile', '-c', |
| 458 | help="""Crypto file to read (and modify if requested). Default: {}.""" |
| 459 | .format(CryptoConfigFile.default_path)) |
Gabor Mezei | 24d7cc7 | 2024-08-06 15:11:24 +0200 | [diff] [blame] | 460 | |
Gabor Mezei | a12ed6b | 2024-09-09 17:20:49 +0200 | [diff] [blame] | 461 | self.add_adapter( |
| 462 | 'baremetal', baremetal_adapter, |
| 463 | """Like full, but exclude features that require platform features |
| 464 | such as file input-output. |
| 465 | """) |
| 466 | self.add_adapter( |
| 467 | 'baremetal_size', baremetal_size_adapter, |
| 468 | """Like baremetal, but exclude debugging features. Useful for code size measurements. |
| 469 | """) |
| 470 | self.add_adapter( |
| 471 | 'full', full_adapter, |
| 472 | """Uncomment most features. |
| 473 | Exclude alternative implementations and platform support options, as well as |
| 474 | some options that are awkward to test. |
| 475 | """) |
| 476 | self.add_adapter( |
| 477 | 'full_no_deprecated', no_deprecated_adapter(full_adapter), |
| 478 | """Uncomment most non-deprecated features. |
| 479 | Like "full", but without deprecated features. |
| 480 | """) |
| 481 | self.add_adapter( |
| 482 | 'full_no_platform', no_platform_adapter(full_adapter), |
| 483 | """Uncomment most non-platform features. Like "full", but without platform features. |
| 484 | """) |
| 485 | self.add_adapter( |
| 486 | 'realfull', realfull_adapter, |
| 487 | """Uncomment all boolean #defines. |
| 488 | Suitable for generating documentation, but not for building. |
| 489 | """) |
| 490 | self.add_adapter( |
| 491 | 'crypto', crypto_adapter(None), |
| 492 | """Only include crypto features. Exclude X.509 and TLS.""") |
| 493 | self.add_adapter( |
| 494 | 'crypto_baremetal', crypto_adapter(baremetal_adapter), |
| 495 | """Like baremetal, but with only crypto features, excluding X.509 and TLS.""") |
| 496 | self.add_adapter( |
| 497 | 'crypto_full', crypto_adapter(full_adapter), |
| 498 | """Like full, but with only crypto features, excluding X.509 and TLS.""") |
Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 499 | |
Gilles Peskine | b406389 | 2019-07-27 21:36:44 +0200 | [diff] [blame] | 500 | |
Gabor Mezei | 24d7cc7 | 2024-08-06 15:11:24 +0200 | [diff] [blame] | 501 | if __name__ == '__main__': |
| 502 | sys.exit(MbedTLSConfigTool().main()) |