from pathlib import Path Import("env") PROJECT_DIR = Path(env.subst("$PROJECT_DIR")) MARKER = "/* CrossPoint wolfSSL compatibility overrides */" OVERRIDES = f""" {MARKER} #undef NO_DH #ifndef HAVE_FFDHE_2048 #define HAVE_FFDHE_2048 #endif /* MEMFIX-PORT: 8192 handles up to RSA-4096 keys (the public-CA maximum, ISRG Root X1 included) with half the per-bignum heap of 16384: with WOLFSSL_SMALL_STACK each fast-math temp is FP_MAX_BITS/8 * 2 bytes on the heap, and TLS cert verification allocates dozens at once. */ #undef FP_MAX_BITS #define FP_MAX_BITS 8192 """ def patch_user_settings(path: Path) -> None: text = path.read_text() if MARKER in text: text = text.split(MARKER, 1)[0].rstrip() path.write_text(text + OVERRIDES + "\n") print(f"Patched wolfSSL settings: {path.relative_to(PROJECT_DIR)}") for settings in PROJECT_DIR.glob(".pio/libdeps/*/Arduino-wolfSSL/src/user_settings.h"): patch_user_settings(settings)