|
| 1 | +/* user_settings_baremetal.h |
| 2 | + * |
| 3 | + * Copyright (C) 2006-2025 wolfSSL Inc. |
| 4 | + * |
| 5 | + * This file is part of wolfSSL. |
| 6 | + * |
| 7 | + * wolfSSL is free software; you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License as published by |
| 9 | + * the Free Software Foundation; either version 3 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * wolfSSL is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License |
| 18 | + * along with this program; if not, write to the Free Software |
| 19 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
| 20 | + */ |
| 21 | + |
| 22 | +/* Bare metal configuration for systems without an OS. |
| 23 | + * No filesystem, no malloc (static memory), minimal footprint. |
| 24 | + * Suitable for deeply embedded systems and bootloaders. |
| 25 | + * |
| 26 | + * Build and test: |
| 27 | + * cp ./examples/configs/user_settings_baremetal.h user_settings.h |
| 28 | + * ./configure --enable-usersettings --disable-examples |
| 29 | + * make |
| 30 | + * ./wolfcrypt/test/testwolfcrypt |
| 31 | + */ |
| 32 | + |
| 33 | +#ifndef WOLFSSL_USER_SETTINGS_H |
| 34 | +#define WOLFSSL_USER_SETTINGS_H |
| 35 | + |
| 36 | +#ifdef __cplusplus |
| 37 | +extern "C" { |
| 38 | +#endif |
| 39 | + |
| 40 | +/* ------------------------------------------------- */ |
| 41 | +/* Platform - Bare Metal */ |
| 42 | +/* ------------------------------------------------- */ |
| 43 | +#define SINGLE_THREADED |
| 44 | +#define NO_FILESYSTEM |
| 45 | +#define NO_WRITEV |
| 46 | +#define WOLFSSL_NO_SOCK |
| 47 | +#define WOLFSSL_IGNORE_FILE_WARN |
| 48 | +#define WOLFSSL_GENERAL_ALIGNMENT 4 |
| 49 | +#define SIZEOF_LONG_LONG 8 |
| 50 | + |
| 51 | +/* TLS transport requires setting IO callbacks */ |
| 52 | +#define WOLFSSL_USER_IO |
| 53 | + |
| 54 | +/* ------------------------------------------------- */ |
| 55 | +/* Memory */ |
| 56 | +/* ------------------------------------------------- */ |
| 57 | +#if 1 /* stack memory */ |
| 58 | + |
| 59 | +#elif 1 /* small stack */ |
| 60 | + /* Small stack - allocate large variables from static pool */ |
| 61 | + #define WOLFSSL_SMALL_STACK |
| 62 | +#else /* static memory */ |
| 63 | + #define WOLFSSL_STATIC_MEMORY |
| 64 | + #define WOLFSSL_NO_MALLOC |
| 65 | + #define WOLFSSL_SP_NO_MALLOC |
| 66 | + #define WOLFSSL_MALLOC_CHECK |
| 67 | + #define NO_WOLFSSL_MEMORY |
| 68 | +#endif |
| 69 | + |
| 70 | +/* ------------------------------------------------- */ |
| 71 | +/* Math - Single Precision (smallest) */ |
| 72 | +/* ------------------------------------------------- */ |
| 73 | +#define WOLFSSL_SP_MATH |
| 74 | +#define WOLFSSL_SP_SMALL |
| 75 | +#define TFM_TIMING_RESISTANT |
| 76 | + |
| 77 | +/* ------------------------------------------------- */ |
| 78 | +/* TLS (optional - disable for crypto-only) */ |
| 79 | +/* ------------------------------------------------- */ |
| 80 | +#if 0 /* TLS support */ |
| 81 | + #define WOLFSSL_TLS13 |
| 82 | + #define WOLFSSL_NO_TLS12 |
| 83 | + #define NO_OLD_TLS |
| 84 | + #define HAVE_TLS_EXTENSIONS |
| 85 | + #define HAVE_SUPPORTED_CURVES |
| 86 | + #define HAVE_HKDF |
| 87 | +#else |
| 88 | + #define WOLFCRYPT_ONLY |
| 89 | +#endif |
| 90 | + |
| 91 | +/* ------------------------------------------------- */ |
| 92 | +/* ECC (smallest asymmetric option) */ |
| 93 | +/* ------------------------------------------------- */ |
| 94 | +#if 1 /* ECC support */ |
| 95 | + #define HAVE_ECC |
| 96 | + #define WOLFSSL_HAVE_SP_ECC |
| 97 | + |
| 98 | + #define ECC_USER_CURVES /* P-256 only */ |
| 99 | + #undef NO_ECC256 |
| 100 | + #define ECC_TIMING_RESISTANT |
| 101 | + /* Disable for smaller size */ |
| 102 | + #if 0 /* ECC Shamir (faster, more code) */ |
| 103 | + #define ECC_SHAMIR |
| 104 | + #endif |
| 105 | +#endif |
| 106 | + |
| 107 | +/* ECC Feature Reduction */ |
| 108 | +#if 0 /* Verify only (no signing/keygen) */ |
| 109 | + #define NO_ECC_SIGN |
| 110 | + #define NO_ECC_DHE |
| 111 | + #define NO_ECC_KEY_EXPORT |
| 112 | +#endif |
| 113 | + |
| 114 | +/* ------------------------------------------------- */ |
| 115 | +/* RSA (disable for smallest size) */ |
| 116 | +/* ------------------------------------------------- */ |
| 117 | +#if 0 /* RSA support */ |
| 118 | + #undef NO_RSA |
| 119 | + #define WOLFSSL_HAVE_SP_RSA |
| 120 | + #define WC_RSA_BLINDING |
| 121 | + #define RSA_LOW_MEM |
| 122 | + #if 0 /* Verify only */ |
| 123 | + #define WOLFSSL_RSA_PUBLIC_ONLY |
| 124 | + #define WOLFSSL_RSA_VERIFY_INLINE |
| 125 | + #define NO_CHECK_PRIVATE_KEY |
| 126 | + #endif |
| 127 | +#else |
| 128 | + #define NO_RSA |
| 129 | +#endif |
| 130 | + |
| 131 | +/* ------------------------------------------------- */ |
| 132 | +/* Symmetric Ciphers */ |
| 133 | +/* ------------------------------------------------- */ |
| 134 | +#if 1 /* AES */ |
| 135 | + #define HAVE_AESGCM |
| 136 | + #define GCM_SMALL |
| 137 | + #define WOLFSSL_AES_SMALL_TABLES |
| 138 | + #define WOLFSSL_AES_NO_UNROLL |
| 139 | + #define NO_AES_192 |
| 140 | + #define NO_AES_256 |
| 141 | + #if 0 /* AES-CBC */ |
| 142 | + #undef NO_AES_CBC |
| 143 | + #else |
| 144 | + #define NO_AES_CBC |
| 145 | + #endif |
| 146 | +#else |
| 147 | + #define NO_AES |
| 148 | +#endif |
| 149 | + |
| 150 | +#if 0 /* ChaCha20-Poly1305 */ |
| 151 | + #define HAVE_CHACHA |
| 152 | + #define HAVE_POLY1305 |
| 153 | +#endif |
| 154 | + |
| 155 | +/* ------------------------------------------------- */ |
| 156 | +/* Hashing */ |
| 157 | +/* ------------------------------------------------- */ |
| 158 | +/* SHA-256 only (required) */ |
| 159 | +#define USE_SLOW_SHA256 |
| 160 | + |
| 161 | +#if 0 /* SHA-1 (legacy) */ |
| 162 | + #undef NO_SHA |
| 163 | +#else |
| 164 | + #define NO_SHA |
| 165 | +#endif |
| 166 | + |
| 167 | +/* ------------------------------------------------- */ |
| 168 | +/* RNG */ |
| 169 | +/* ------------------------------------------------- */ |
| 170 | +#if 1 /* Hash-based DRBG */ |
| 171 | + #define HAVE_HASHDRBG |
| 172 | +#else |
| 173 | + /* Use hardware RNG directly */ |
| 174 | + #define WC_NO_HASHDRBG |
| 175 | + extern int my_rng_gen_block(unsigned char* output, unsigned int sz); |
| 176 | + #define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block |
| 177 | +#endif |
| 178 | + |
| 179 | +/* ------------------------------------------------- */ |
| 180 | +/* ASN / Certificates */ |
| 181 | +/* ------------------------------------------------- */ |
| 182 | +#define WOLFSSL_ASN_TEMPLATE |
| 183 | + |
| 184 | +#if 0 /* Disable certificates for smallest size */ |
| 185 | + #define NO_ASN |
| 186 | + #define NO_CERTS |
| 187 | + #define NO_CODING |
| 188 | +#endif |
| 189 | + |
| 190 | +/* ------------------------------------------------- */ |
| 191 | +/* Disabled Algorithms */ |
| 192 | +/* ------------------------------------------------- */ |
| 193 | +#define NO_DH |
| 194 | +#define NO_DSA |
| 195 | +#define NO_RC4 |
| 196 | +#define NO_MD4 |
| 197 | +#define NO_MD5 |
| 198 | +#define NO_DES3 |
| 199 | +#define NO_DES3_TLS_SUITES |
| 200 | +#define NO_PSK |
| 201 | +#define NO_PWDBASED |
| 202 | +#define NO_PKCS8 |
| 203 | +#define NO_PKCS12 |
| 204 | + |
| 205 | +/* ------------------------------------------------- */ |
| 206 | +/* Disabled Features */ |
| 207 | +/* ------------------------------------------------- */ |
| 208 | +#define NO_SIG_WRAPPER |
| 209 | +#define NO_SESSION_CACHE |
| 210 | +#define NO_ERROR_STRINGS |
| 211 | +#define NO_OLD_RNGNAME |
| 212 | +#define NO_WOLFSSL_DIR |
| 213 | +#define BENCH_EMBEDDED |
| 214 | + |
| 215 | +/* ------------------------------------------------- */ |
| 216 | +/* Custom Time (bare metal has no RTC typically) */ |
| 217 | +/* ------------------------------------------------- */ |
| 218 | +#if 1 /* Custom time function */ |
| 219 | + #define NO_ASN_TIME |
| 220 | + /* Or provide custom time: |
| 221 | + * #define USER_TIME |
| 222 | + * extern unsigned long my_time(unsigned long* timer); |
| 223 | + * #define XTIME my_time |
| 224 | + */ |
| 225 | +#endif |
| 226 | + |
| 227 | +#ifdef __cplusplus |
| 228 | +} |
| 229 | +#endif |
| 230 | + |
| 231 | +#endif /* WOLFSSL_USER_SETTINGS_H */ |
0 commit comments