From 84468111e42cb72bdbd78724c4ef2c60f50b43ee Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Wed, 21 Oct 2026 14:11:05 -0500 Subject: [PATCH 01/95] Build the Elite II / C64 Ultimate control module (u64ctrl) with ESP-IDF 6.0.3 u64ctrl moves to ESP-IDF 6.0.3 (mbedTLS 4) and bumps the module version so the updater installs it. This changes the toolchain of the C64 Ultimate's power controller, not only of its WiFi: the module runs power, button and keepalive handling. It is one commit because none of its parts builds alone: the CMake check stops CI's ESP-IDF 5.3.1 build, and the recovery code does not compile under mbedTLS 4. - my_uart.c: uart_periph.h moved from soc/ to hal/, and uart_isr_handle_t (a typedef of intr_handle_t) is gone. The same two changes #996 makes for raw_u64. - CMakeLists.txt: configure stops on an ESP-IDF older than 6. - sdkconfig: regenerated by idf.py build from the ESP-IDF 5.3.1 file. Values present in both versions are carried; of the 1498 options in the 5.3.1 file only the esptool before/after spelling, DHCP option length (68 to 69), X509 trusted cert callback and ESP_NETIF_RECEIVE_REPORT_ERRORS changed value (SOC_ constants aside). Options that are new take ESP-IDF 6's defaults, among them picolibc instead of newlib and the FreeRTOS and ring-buffer functions running from flash rather than IRAM. Brownout level 7 and the 100 Hz tick are carried. - rpc_dispatch.h: the module version is the next minor above master's, see the history line. The maintainer assigns the number at merge. - CI builds u64ctrl in espressif/idf:v6.0.3, pinned by digest in $IDF6_IMAGE; raw_u64 and raw_c3 stay in my_docker_image. The ESP32 cache key names both images. README.txt and software/u64ctrl/README.md say how to build it. The recovery code from the Wi-Fi recovery change is ported to mbedTLS 4 and PSA Crypto, because it did not compile: mbedTLS 4 has no public mbedtls/sha256.h and no mbedtls_pk_get_type(). The mbedTLS 4 port is of code written for mbedTLS 3. - recovery_verify.c: the key type comes from mbedtls_pk_get_key_type() (an ECC public key); the manifest hash is psa_hash_compute(); psa_crypto_init() is always called, so the init does not depend on MBEDTLS_USE_PSA_CRYPTO, which is still defined as a legacy symbol that is slated for removal. A failure to start is reported as RECOVERY_ERR_CRYPTO ("crypto library failed"), not as a bad signature. The signature itself is still checked by mbedtls_pk_verify() with a DER ECDSA signature, as before. - recovery_verify.h, recovery_verify.c: the streaming hash of a downloaded file moves out of recovery.c into recovery_hash_*(), on psa_hash_*(), so the host test can run it. It also holds the compare with the manifest's hash, reported as RECOVERY_ERR_HASH_MISMATCH. - recovery.c: stream_file() uses it. The checks, their order and the log line for a differing hash are as before; a failure of the crypto library is logged by name. - Two result codes are added after the existing ones; nothing that was returned before changes. - The host test links TF-PSA-Crypto from ESP-IDF 6, so it moves out of make host_tests, which CI runs in ESP-IDF 5.3.1, into host_tests_idf6 and its own CI step in $IDF6_IMAGE. Tests, written first and red against the unported code (recovery_verify.c cannot include mbedtls/sha256.h under ESP-IDF 6), check by the error each case names: - a valid manifest is accepted; - the wrong key, a tampered manifest, and a manifest correctly signed by an RSA key (rsa512.manifest) are refused as a bad signature; - a changed or truncated image or bitstream is refused as a hash mismatch, and so is a file whose manifest hash differs in its first, middle or last byte, which a compare that stopped early would accept; - a crypto library that will not start, or a hash that fails in its update or finish, is reported as such, never as a bad signature or a match. The test forces these through --wrap=psa_crypto_init, psa_hash_update and psa_hash_finish, so the product code carries no test hook. The signed vectors are unchanged; the two RSA files are new. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/build.yml | 25 +- Makefile | 8 +- README.txt | 8 +- .../recovery_manifest_test.c | 180 ++ .../recovery_manifest/vectors/rsa512.manifest | 11 + .../recovery_manifest/vectors/rsa512.pub.pem | 4 + software/u64ctrl/CMakeLists.txt | 3 + software/u64ctrl/README.md | 24 + software/u64ctrl/main/my_uart.c | 4 +- software/u64ctrl/main/recovery.c | 32 +- software/u64ctrl/main/recovery_manifest.c | 2 + software/u64ctrl/main/recovery_manifest.h | 5 +- software/u64ctrl/main/recovery_verify.c | 52 +- software/u64ctrl/main/recovery_verify.h | 40 + software/u64ctrl/main/rpc_dispatch.h | 5 +- software/u64ctrl/sdkconfig | 1724 +++++++++++++---- target/pc/linux/recoverymanifest/Makefile | 27 +- 17 files changed, 1706 insertions(+), 448 deletions(-) create mode 100644 software/test/recovery_manifest/vectors/rsa512.manifest create mode 100644 software/test/recovery_manifest/vectors/rsa512.pub.pem create mode 100644 software/u64ctrl/README.md create mode 100644 software/u64ctrl/main/recovery_verify.h diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2593b2dbf..4d5d3cce3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,6 +10,9 @@ jobs: # commit twice, without restricting which branches build on push. if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository runs-on: self-hosted + env: + # u64ctrl needs ESP-IDF 6, so it builds here; raw_u64 and raw_c3 stay on my_docker_image's 5.3.1 + IDF6_IMAGE: espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 steps: - name: Checkout repository uses: actions/checkout@v7 @@ -174,6 +177,13 @@ jobs: -v /opt/build-tools:/mnt/build-tools:ro \ -v $GITHUB_WORKSPACE:/mnt/project:rw my_docker_image /bin/bash -c "cd /mnt/project && make host_tests" + # In the ESP-IDF 6 image, because the control module's signature check is + # built against the crypto library that image ships. + - name: Test Recovery Manifest Signature Check + run: | + docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp \ + -v $GITHUB_WORKSPACE:/mnt/project:rw --workdir /mnt/project $IDF6_IMAGE make host_tests_idf6 + - name: Cache U2 FPGA id: cache-u2 uses: actions/cache@v6 @@ -208,6 +218,13 @@ jobs: restore-keys: | ${{ runner.os }}-u2pl-${{ hashFiles('target/fpga/depends/u2pl.txt') }} + # The ESP32 cache key names both build images, so a rebuilt my_docker_image misses too + - name: Identify ESP32 Build Images + run: | + image_id=$(docker image inspect --format '{{.Id}}' my_docker_image) + test -n "$image_id" + echo "ESP32_IMAGE_ID=$image_id" >> $GITHUB_ENV + - name: Cache ESP32 Targets id: cache-esp32 uses: actions/cache@v6 @@ -222,16 +239,18 @@ jobs: software/wifi/raw_u64/build/bridge.bin software/wifi/raw_u64/build/bootloader/bootloader.bin software/wifi/raw_u64/build/partition_table/partition-table.bin - key: ${{ runner.os }}-esp32-${{ hashFiles('software/esp_depends.txt') }} + key: ${{ runner.os }}-esp32-${{ env.ESP32_IMAGE_ID }}-${{ env.IDF6_IMAGE }}-${{ hashFiles('software/esp_depends.txt') }} restore-keys: | - ${{ runner.os }}-esp32-${{ hashFiles('software/esp_depends.txt') }} + ${{ runner.os }}-esp32-${{ env.ESP32_IMAGE_ID }}-${{ env.IDF6_IMAGE }}-${{ hashFiles('software/esp_depends.txt') }} - if: steps.cache-esp32.outputs.cache-hit != 'true' name: Build ESP32 Software (skipped if available in cache) run: | docker run --rm --net=custom_network --mac-address=4c:cc:6a:06:b3:79 \ -v /opt/build-tools:/mnt/build-tools:ro \ - -v $GITHUB_WORKSPACE:/mnt/project:rw my_docker_image /bin/bash -c "cd /mnt/project && make esp32" + -v $GITHUB_WORKSPACE:/mnt/project:rw my_docker_image /bin/bash -c "cd /mnt/project && make esp32_raw_u64 esp32_raw_c3" + docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp \ + -v $GITHUB_WORKSPACE:/mnt/project:rw --workdir /mnt/project/software/u64ctrl $IDF6_IMAGE idf.py build - if: steps.cache-u2.outputs.cache-hit != 'true' name: Build U2 including FPGAs diff --git a/Makefile b/Makefile index cdba15b66..dbcfb32ff 100755 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ OPENAPI = python3 tools/openapi/generate.py # make openapi_validate PYTHON=/path/to/venv/bin/python PYTHON ?= python3 -.PHONY: all app_space app_space_test d81_tracks_test observability_test lint_test host_tests openapi openapi_check openapi_test openapi_validate +.PHONY: all app_space app_space_test d81_tracks_test observability_test lint_test host_tests host_tests_idf6 openapi openapi_check openapi_test openapi_validate all: esp32 u2_rv u2plus u2pl u64 u64ii @$(APP_SPACE) report @@ -67,6 +67,11 @@ openapi_validate: exit 2; } @$(PYTHON) -m openapi_spec_validator --validation-errors all `$(OPENAPI) paths` +# The recovery manifest check is built against the crypto library of ESP-IDF 6, +# so it runs in that image (IDF_PATH of an ESP-IDF 6), apart from the rest. +host_tests_idf6: + @$(MAKE) -C target/pc/linux/recoverymanifest test + # Unit tests that run on the build host rather than on the device. Kept out of # the firmware targets deliberately: those build with a cross compiler, and # these need a host g++. @@ -77,7 +82,6 @@ host_tests: @$(MAKE) -C target/pc/linux/powerstate test @$(MAKE) -C target/pc/linux/wolmagic test @$(MAKE) -C target/pc/linux/wifireply test - @$(MAKE) -C target/pc/linux/recoverymanifest test @$(MAKE) -C target/pc/linux/recoveryimage test @$(MAKE) -C target/pc/linux/recoveryurl test diff --git a/README.txt b/README.txt index 9b092b117..320ce855c 100644 --- a/README.txt +++ b/README.txt @@ -26,7 +26,7 @@ U64: U64E-II: - RiscV GNU C/C++ Compiler (for RV32I), same as for U2/RiscV. -- Espressif IDF 5.x +- Espressif IDF 6.x Environment variables @@ -40,7 +40,7 @@ In this file, you need to set the location of your Xilinx ISE toolchain. Building targets ================ -ALL targets can be built by just typing 'make' in the root of the repository. +ALL targets can be built by just typing 'make' in the root of the repository (see the U64E-II note below). In order to build for U2 only, use the 'u2_rv' target in the top level makefile. This will build the FPGAs as well as the RiscV based software, including all updaters. @@ -55,6 +55,10 @@ For the U2+L, you can build the 'u2pl' target. The U64 firmware can be built by typing 'make u64'. The U64E-II firmware can be built by typing 'make u64ii' +Its control module firmware (software/u64ctrl) needs ESP-IDF 6, while software/wifi/raw_u64 and raw_c3 +still need 5.3.1. So 'make u64ii' needs IDF_PATH to be an ESP-IDF 6, 'make u64' and 'make u2pl' need 5.3.1, +and 'make' (all), 'make esp32' and 'make clean' cannot complete with a single IDF_PATH. Build the control +module as software/u64ctrl/README.md shows, and then run 'make u64ii_no_esp'. ==> When using the top level makefile, the results are copied into the root of the project. diff --git a/software/test/recovery_manifest/recovery_manifest_test.c b/software/test/recovery_manifest/recovery_manifest_test.c index 89a73c24e..07edb54e5 100644 --- a/software/test/recovery_manifest/recovery_manifest_test.c +++ b/software/test/recovery_manifest/recovery_manifest_test.c @@ -8,11 +8,17 @@ * is the code that runs on the board. The signed manifests and the serial * patterns in vectors/ were written by the recovery server's manifest.py and * Python's fnmatch; see make_vectors.py. + * + * The library is linked with --wrap=psa_crypto_init, --wrap=psa_hash_update and + * --wrap=psa_hash_finish, so a test can make the crypto library's start-up or a + * hash fail; see the __wrap_ functions below. */ #include #include #include +#include "psa/crypto.h" #include "recovery_manifest.h" +#include "recovery_verify.h" #ifndef VECTORS_DIR #define VECTORS_DIR "vectors" @@ -171,6 +177,179 @@ static void test_signed_vectors(void) free(other_key); } +/* A failing psa_crypto_init() on demand, for the checks that the verifier says + so rather than calling the manifest badly signed. The Makefile links with + --wrap=psa_crypto_init, so the calls recovery_verify.c makes land here. */ +psa_status_t __real_psa_crypto_init(void); +psa_status_t __real_psa_hash_update(psa_hash_operation_t *operation, const uint8_t *input, size_t input_length); +psa_status_t __real_psa_hash_finish(psa_hash_operation_t *operation, uint8_t *hash, size_t hash_size, + size_t *hash_length); +static psa_status_t crypto_init_forced = PSA_SUCCESS; +static psa_status_t hash_update_forced = PSA_SUCCESS; +static psa_status_t hash_finish_forced = PSA_SUCCESS; +static int crypto_init_calls; + +psa_status_t __wrap_psa_hash_update(psa_hash_operation_t *operation, const uint8_t *input, size_t input_length) +{ + if (hash_update_forced != PSA_SUCCESS) { + return hash_update_forced; + } + return __real_psa_hash_update(operation, input, input_length); +} + +psa_status_t __wrap_psa_hash_finish(psa_hash_operation_t *operation, uint8_t *hash, size_t hash_size, + size_t *hash_length) +{ + if (hash_finish_forced != PSA_SUCCESS) { + return hash_finish_forced; + } + return __real_psa_hash_finish(operation, hash, hash_size, hash_length); +} + +psa_status_t __wrap_psa_crypto_init(void) +{ + crypto_init_calls++; + if (crypto_init_forced != PSA_SUCCESS) { + return crypto_init_forced; + } + return __real_psa_crypto_init(); +} + +/* Each way a manifest or an image is refused, by the name it logs. */ +static void test_refusals_by_name(void) +{ + size_t len, fpga_len, image_len; + char *text = read_file("valid.manifest", &len); + char *test_key = read_file("test_key.pub.pem", NULL); + char *other_key = read_file("other_key.pub.pem", NULL); + char *fpga = read_file("fake.bit", &fpga_len); + char *image = read_file("fake.ue2", &image_len); + const char *trusted[] = { test_key }; + const char *untrusted[] = { other_key }; + recovery_manifest_t m; + recovery_signature_t sig; + recovery_result_t r; + + printf("Refusals, by the error they name\n"); + r = load(text, len, trusted, 1, &m); + check(r == RECOVERY_OK && strcmp(recovery_result_name(r), "ok") == 0, "a valid manifest is accepted"); + r = load(text, len, untrusted, 1, &m); + check(r == RECOVERY_ERR_BAD_SIGNATURE && strcmp(recovery_result_name(r), "bad signature") == 0, + "a wrong key is refused as a bad signature"); + recovery_manifest_split(text, len, &sig); + char *at = strstr(text, "test-1.0"); + check(at != NULL && at < text + sig.signed_len, "the package line is in the signed text"); + *at ^= 0x01; + r = load(text, len, trusted, 1, &m); + check(r == RECOVERY_ERR_BAD_SIGNATURE && strcmp(recovery_result_name(r), "bad signature") == 0, + "a tampered manifest is refused as a bad signature"); + *at ^= 0x01; + + // The hashes the manifest holds were made from these files. + recovery_manifest_t good; + check_result(load(text, len, trusted, 1, &good), RECOVERY_OK, "the manifest verifies again once restored"); + const struct { const recovery_file_t *file; char *data; size_t len; const char *what; } files[] = { + { &good.image, image, image_len, "image" }, + { &good.fpga, fpga, fpga_len, "bitstream" }, + }; + for (int i = 0; i < 2; i++) { + char what[96]; + recovery_hash_t h; + snprintf(what, sizeof(what), "the %s hashes to what its manifest says", files[i].what); + check(files[i].len == files[i].file->size, "the vector is the size its manifest says"); + check(recovery_hash_start(&h) == RECOVERY_OK, "a hash starts"); + // In three pieces, as the download hands it over. + size_t a = files[i].len / 3, b = 2 * files[i].len / 3; + recovery_hash_update(&h, (const uint8_t *)files[i].data, a); + recovery_hash_update(&h, (const uint8_t *)files[i].data + a, b - a); + recovery_hash_update(&h, (const uint8_t *)files[i].data + b, files[i].len - b); + check_result(recovery_hash_finish(&h, files[i].file), RECOVERY_OK, what); + + snprintf(what, sizeof(what), "a changed byte in the %s is refused as a hash mismatch", files[i].what); + files[i].data[files[i].len / 2] ^= 0x01; + recovery_hash_start(&h); + recovery_hash_update(&h, (const uint8_t *)files[i].data, files[i].len); + r = recovery_hash_finish(&h, files[i].file); + check(r == RECOVERY_ERR_HASH_MISMATCH && strcmp(recovery_result_name(r), "hash differs") == 0, what); + files[i].data[files[i].len / 2] ^= 0x01; + + // A compare that stopped early would still see the file change, which + // changes every byte of the hash; the manifest's hash changing in one + // byte, at its start, middle or end, is what shows it. + static const int flips[] = { 0, 16, 31 }; + for (int f = 0; f < 3; f++) { + recovery_file_t wrong = *files[i].file; + wrong.sha256[flips[f]] ^= 0x01; + snprintf(what, sizeof(what), "the %s is refused when byte %d of its manifest hash differs", files[i].what, + flips[f]); + recovery_hash_start(&h); + recovery_hash_update(&h, (const uint8_t *)files[i].data, files[i].len); + check_result(recovery_hash_finish(&h, &wrong), RECOVERY_ERR_HASH_MISMATCH, what); + } + + snprintf(what, sizeof(what), "a %s cut short is refused as a hash mismatch", files[i].what); + recovery_hash_start(&h); + recovery_hash_update(&h, (const uint8_t *)files[i].data, files[i].len - 1); + check_result(recovery_hash_finish(&h, files[i].file), RECOVERY_ERR_HASH_MISMATCH, what); + } + + // A hash that fails part-way is a crypto error, never "matches": the + // image whose hash was not computed must not be accepted. + for (int i = 0; i < 2; i++) { + recovery_hash_t fh; + char what[96]; + recovery_hash_start(&fh); + if (i == 0) { + hash_update_forced = PSA_ERROR_HARDWARE_FAILURE; + r = recovery_hash_update(&fh, (const uint8_t *)image, image_len); + hash_update_forced = PSA_SUCCESS; + snprintf(what, sizeof(what), "a hash update that fails is reported as a crypto library failure"); + check(r == RECOVERY_ERR_CRYPTO && strcmp(recovery_result_name(r), "crypto library failed") == 0, what); + recovery_hash_abort(&fh); + } else { + recovery_hash_update(&fh, (const uint8_t *)image, image_len); + hash_finish_forced = PSA_ERROR_HARDWARE_FAILURE; + r = recovery_hash_finish(&fh, &good.image); + hash_finish_forced = PSA_SUCCESS; + snprintf(what, sizeof(what), "a hash finish that fails is a crypto library failure, not a match"); + check(r == RECOVERY_ERR_CRYPTO && strcmp(recovery_result_name(r), "crypto library failed") == 0, what); + } + } + + // A trusted key that is not an EC key is refused, even with a signature + // that is valid for it: rsa512.manifest holds the signed text of + // valid.manifest with a PKCS#1 v1.5 SHA-256 signature by the RSA-512 key in + // rsa512.pub.pem (openssl genrsa 512; openssl dgst -sha256 -sign). + size_t rsa_len; + char *rsa_text = read_file("rsa512.manifest", &rsa_len); + char *rsa_key = read_file("rsa512.pub.pem", NULL); + const char *rsa_trusted[] = { rsa_key }; + r = load(rsa_text, rsa_len, rsa_trusted, 1, &m); + check(r == RECOVERY_ERR_BAD_SIGNATURE && strcmp(recovery_result_name(r), "bad signature") == 0, + "a manifest correctly signed by an RSA key is refused as a bad signature"); + free(rsa_text); + free(rsa_key); + + // The crypto library failing to start is not a bad signature. + crypto_init_forced = PSA_ERROR_INSUFFICIENT_MEMORY; + crypto_init_calls = 0; + r = load(text, len, trusted, 1, &m); + check(crypto_init_calls > 0, "the verifier initialises the crypto library itself"); + check(r == RECOVERY_ERR_CRYPTO && strcmp(recovery_result_name(r), "crypto library failed") == 0, + "a crypto library that will not start is named, with a valid manifest"); + check(r != RECOVERY_ERR_BAD_SIGNATURE, "and is not called a bad signature"); + recovery_hash_t h; + check_result(recovery_hash_start(&h), RECOVERY_ERR_CRYPTO, "a hash cannot start either"); + crypto_init_forced = PSA_SUCCESS; + check_result(load(text, len, trusted, 1, &m), RECOVERY_OK, "and the manifest verifies once it starts"); + + free(text); + free(test_key); + free(other_key); + free(fpga); + free(image); +} + static void test_split(void) { recovery_signature_t sig; @@ -281,6 +460,7 @@ static void test_serial_patterns(void) int main(void) { test_signed_vectors(); + test_refusals_by_name(); test_split(); test_parse(); test_board(); diff --git a/software/test/recovery_manifest/vectors/rsa512.manifest b/software/test/recovery_manifest/vectors/rsa512.manifest new file mode 100644 index 000000000..d52157a75 --- /dev/null +++ b/software/test/recovery_manifest/vectors/rsa512.manifest @@ -0,0 +1,11 @@ +format=1 +package=test-1.0 +idcode=0362c093 +serial=U64E2-1* +fpga.file=fake.bit +fpga.size=88 +fpga.sha256=53ee5bc784105e3444f8810df9c0b13ea5542d8ce5e112bfafcdf0cd49088408 +image.file=fake.ue2 +image.size=28 +image.sha256=e3989004d19d6ccedafac4b3d6ed7531ed17a26eb4a389a2a5e8050777aa1162 +sig=aebip2VIXnU8CC2yuSAKFNXczOZvuSgd0BIYw58QuryLpRLoeZ/QGxP15u1bR5WhNU4waJHDhXZweC1FyM0WWg== diff --git a/software/test/recovery_manifest/vectors/rsa512.pub.pem b/software/test/recovery_manifest/vectors/rsa512.pub.pem new file mode 100644 index 000000000..d32a3c06e --- /dev/null +++ b/software/test/recovery_manifest/vectors/rsa512.pub.pem @@ -0,0 +1,4 @@ +-----BEGIN PUBLIC KEY----- +MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAK/ZCRMQmkgLGfmu2X25Fo2TddpkyeOP +mfBYQhM4ngzNRy1vsWjtdwfJuGn2AqFqVXKoEHTp6gLRL93ZBtVsC40CAwEAAQ== +-----END PUBLIC KEY----- diff --git a/software/u64ctrl/CMakeLists.txt b/software/u64ctrl/CMakeLists.txt index 139b3260c..5b32e4f2b 100755 --- a/software/u64ctrl/CMakeLists.txt +++ b/software/u64ctrl/CMakeLists.txt @@ -3,5 +3,8 @@ cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) +if(IDF_VERSION_MAJOR LESS 6) + message(FATAL_ERROR "u64ctrl needs ESP-IDF 6, not ${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR} (see software/u64ctrl/README.md)") +endif() project(u64ctrl) # target_add_binary_data(u64ctrl.elf "/home/gideon/proj/ult64/target/u64_artix/u64_artix.runs/impl_1/u64_mk2_artix.bit" BINARY) diff --git a/software/u64ctrl/README.md b/software/u64ctrl/README.md new file mode 100644 index 000000000..8ab889bd9 --- /dev/null +++ b/software/u64ctrl/README.md @@ -0,0 +1,24 @@ +# Control module firmware (u64ctrl) + +The ESP32-S3 module of the Ultimate 64 Elite II and the C64 Ultimate: WiFi, power and button control. + +## Building + +The module needs ESP-IDF 6 (CI uses v6.0.3); `CMakeLists.txt` stops an older one at configure. +raw_u64 and raw_c3 still build with ESP-IDF 5.3.1, as in `docker/Dockerfile`, so CI builds this +project in `espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. Locally, from +the top of the repository, the same way as CI: + + docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp -v "$PWD":/project -w /project/software/u64ctrl \ + espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 idf.py build + +then `make u64ii_no_esp` packs `build/u64ctrl.bin` into the update files. `make esp32_u64ctrl` and +`make u64ii` work only where `IDF_PATH` is an ESP-IDF 6, and `make` (all) cannot complete with one +`IDF_PATH`, because raw_u64 and raw_c3 need 5.3.1. Once `build/` exists here, +`make clean` also needs ESP-IDF 6; otherwise delete `software/u64ctrl/build` by hand. + +`software/io/uart/cmd_buffer.c` is compiled into all three ESP32 projects, so a change to it has to +build on both ESP-IDF 5.3.1 and 6. + +`sdkconfig` marks values that follow ESP-IDF's defaults with `# default:`; a reconfigure on a newer +ESP-IDF takes its new defaults there. After any ESP-IDF update, diff the values, not just the build. diff --git a/software/u64ctrl/main/my_uart.c b/software/u64ctrl/main/my_uart.c index b8c54fe1c..6d48029f1 100644 --- a/software/u64ctrl/main/my_uart.c +++ b/software/u64ctrl/main/my_uart.c @@ -23,7 +23,7 @@ #include "freertos/ringbuf.h" #include "hal/uart_hal.h" #include "hal/gpio_hal.h" -#include "soc/uart_periph.h" +#include "hal/uart_periph.h" #include "soc/rtc_cntl_reg.h" #include "driver/uart.h" #include "driver/gpio.h" @@ -368,7 +368,7 @@ BaseType_t my_uart_get_buffer(uint8_t uart_num, command_buf_t **buf, TickType_t } #include "esp_check.h" -esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void *), void *arg, int intr_alloc_flags, uart_isr_handle_t *handle) +esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void *), void *arg, int intr_alloc_flags, intr_handle_t *handle) { int ret; ESP_RETURN_ON_FALSE((uart_num < UART_NUM_MAX), ESP_FAIL, UART_TAG, "uart_num error"); diff --git a/software/u64ctrl/main/recovery.c b/software/u64ctrl/main/recovery.c index 1100aa644..a9b5bf983 100644 --- a/software/u64ctrl/main/recovery.c +++ b/software/u64ctrl/main/recovery.c @@ -18,7 +18,6 @@ #include "esp_http_client.h" #include "esp_log.h" #include "esp_netif.h" -#include "mbedtls/sha256.h" #include "nvs.h" #include "button_handler.h" #include "jtag.h" @@ -27,6 +26,7 @@ #include "recovery_image.h" #include "recovery_manifest.h" #include "recovery_url.h" +#include "recovery_verify.h" #include "rpc_dispatch.h" static const char *TAG = "recovery"; @@ -322,9 +322,12 @@ static bool stream_file(const char *get_url, const recovery_file_t *file, sink_f return false; } - mbedtls_sha256_context sha; - mbedtls_sha256_init(&sha); - mbedtls_sha256_starts(&sha, 0); + recovery_hash_t sha; + if (recovery_hash_start(&sha) != RECOVERY_OK) { + ESP_LOGW(TAG, "%s: cannot start a hash", get_url); + close_client(client); + return false; + } uint32_t total = 0; uint32_t since_yield = 0; bool ok = true; @@ -345,7 +348,11 @@ static bool stream_file(const char *get_url, const recovery_file_t *file, sink_f ok = false; break; } - mbedtls_sha256_update(&sha, read_buf, n); + if (recovery_hash_update(&sha, read_buf, n) != RECOVERY_OK) { + ESP_LOGW(TAG, "%s: cannot hash", get_url); + ok = false; + break; + } ok = sink(ctx, total, read_buf, n); total += n; since_yield += n; @@ -356,19 +363,22 @@ static bool stream_file(const char *get_url, const recovery_file_t *file, sink_f } close_client(client); - uint8_t hash[32]; - mbedtls_sha256_finish(&sha, hash); - mbedtls_sha256_free(&sha); if (cancelled) { + recovery_hash_abort(&sha); return false; } if (ok && total != file->size) { ESP_LOGW(TAG, "%s: %lu bytes, its manifest says %lu", get_url, (unsigned long)total, (unsigned long)file->size); ok = false; } - if (ok && memcmp(hash, file->sha256, sizeof(hash)) != 0) { - ESP_LOGW(TAG, "%s: hash differs from its manifest", get_url); - ok = false; + if (ok) { + recovery_result_t r = recovery_hash_finish(&sha, file); + if (r != RECOVERY_OK) { + ESP_LOGW(TAG, "%s: %s", get_url, r == RECOVERY_ERR_HASH_MISMATCH ? "hash differs from its manifest" : recovery_result_name(r)); + ok = false; + } + } else { + recovery_hash_abort(&sha); } if (ok) { uint32_t ms = (xTaskGetTickCount() - started) * portTICK_PERIOD_MS; diff --git a/software/u64ctrl/main/recovery_manifest.c b/software/u64ctrl/main/recovery_manifest.c index 1016b0439..6fbfc82a9 100644 --- a/software/u64ctrl/main/recovery_manifest.c +++ b/software/u64ctrl/main/recovery_manifest.c @@ -24,6 +24,8 @@ const char *recovery_result_name(recovery_result_t result) case RECOVERY_ERR_DUPLICATE_KEY: return "duplicate key"; case RECOVERY_ERR_MISSING_KEY: return "missing key"; case RECOVERY_ERR_BAD_VALUE: return "bad value"; + case RECOVERY_ERR_CRYPTO: return "crypto library failed"; + case RECOVERY_ERR_HASH_MISMATCH: return "hash differs"; } return "unknown result"; } diff --git a/software/u64ctrl/main/recovery_manifest.h b/software/u64ctrl/main/recovery_manifest.h index bb4b177ef..6a59152a0 100644 --- a/software/u64ctrl/main/recovery_manifest.h +++ b/software/u64ctrl/main/recovery_manifest.h @@ -32,7 +32,8 @@ * checks it, and only then does recovery_manifest_parse() read the signed text. * Only the split and the verify ever see unauthenticated input. * - * Everything but recovery_manifest_verify() is free of ESP-IDF and mbedtls. + * Everything but recovery_manifest_verify() is free of ESP-IDF and the crypto + * library; recovery_verify.h has the hashing of the files the manifest names. */ #ifndef SOFTWARE_U64CTRL_MAIN_RECOVERY_MANIFEST_H_ @@ -63,6 +64,8 @@ typedef enum { RECOVERY_ERR_DUPLICATE_KEY, RECOVERY_ERR_MISSING_KEY, RECOVERY_ERR_BAD_VALUE, + RECOVERY_ERR_CRYPTO, // the crypto library would not start or hash + RECOVERY_ERR_HASH_MISMATCH, // a downloaded file is not the one the manifest names } recovery_result_t; typedef struct { diff --git a/software/u64ctrl/main/recovery_verify.c b/software/u64ctrl/main/recovery_verify.c index 071e1c322..81247f5aa 100644 --- a/software/u64ctrl/main/recovery_verify.c +++ b/software/u64ctrl/main/recovery_verify.c @@ -8,11 +8,9 @@ #include #include "mbedtls/base64.h" #include "mbedtls/pk.h" -#include "mbedtls/sha256.h" -#if defined(MBEDTLS_USE_PSA_CRYPTO) #include "psa/crypto.h" -#endif #include "recovery_manifest.h" +#include "recovery_verify.h" static bool verify_with_key(const char *key_pem, const uint8_t *hash, const uint8_t *sig, size_t sig_len) { @@ -20,7 +18,7 @@ static bool verify_with_key(const char *key_pem, const uint8_t *hash, const uint mbedtls_pk_init(&pk); // The PEM parser wants the terminating NUL counted in the length. bool ok = mbedtls_pk_parse_public_key(&pk, (const unsigned char *)key_pem, strlen(key_pem) + 1) == 0 && - mbedtls_pk_get_type(&pk) == MBEDTLS_PK_ECKEY && + PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(mbedtls_pk_get_key_type(&pk)) && mbedtls_pk_verify(&pk, MBEDTLS_MD_SHA256, hash, 32, sig, sig_len) == 0; mbedtls_pk_free(&pk); return ok; @@ -36,16 +34,16 @@ recovery_result_t recovery_manifest_verify(const char *text, const recovery_sign return RECOVERY_ERR_BAD_SIGNATURE; } -#if defined(MBEDTLS_USE_PSA_CRYPTO) - // pk verifies through PSA in this configuration; repeated calls are harmless. + // pk and the hash both go through PSA; repeated calls are harmless. if (psa_crypto_init() != PSA_SUCCESS) { - return RECOVERY_ERR_BAD_SIGNATURE; + return RECOVERY_ERR_CRYPTO; } -#endif uint8_t hash[32]; - if (mbedtls_sha256((const unsigned char *)text, sig->signed_len, hash, 0) != 0) { - return RECOVERY_ERR_BAD_SIGNATURE; + size_t hash_len = 0; + if (psa_hash_compute(PSA_ALG_SHA_256, (const uint8_t *)text, sig->signed_len, hash, sizeof(hash), + &hash_len) != PSA_SUCCESS || hash_len != sizeof(hash)) { + return RECOVERY_ERR_CRYPTO; } for (int i = 0; i < n_keys; i++) { if (verify_with_key(keys_pem[i], hash, der, der_len)) { @@ -54,3 +52,37 @@ recovery_result_t recovery_manifest_verify(const char *text, const recovery_sign } return RECOVERY_ERR_BAD_SIGNATURE; } + +recovery_result_t recovery_hash_start(recovery_hash_t *h) +{ + h->op = (psa_hash_operation_t)PSA_HASH_OPERATION_INIT; + if (psa_crypto_init() != PSA_SUCCESS || psa_hash_setup(&h->op, PSA_ALG_SHA_256) != PSA_SUCCESS) { + return RECOVERY_ERR_CRYPTO; + } + return RECOVERY_OK; +} + +recovery_result_t recovery_hash_update(recovery_hash_t *h, const uint8_t *data, size_t len) +{ + if (psa_hash_update(&h->op, data, len) != PSA_SUCCESS) { + psa_hash_abort(&h->op); + return RECOVERY_ERR_CRYPTO; + } + return RECOVERY_OK; +} + +recovery_result_t recovery_hash_finish(recovery_hash_t *h, const recovery_file_t *expected) +{ + uint8_t hash[32]; + size_t hash_len = 0; + if (psa_hash_finish(&h->op, hash, sizeof(hash), &hash_len) != PSA_SUCCESS || hash_len != sizeof(hash)) { + psa_hash_abort(&h->op); + return RECOVERY_ERR_CRYPTO; + } + return memcmp(hash, expected->sha256, sizeof(hash)) == 0 ? RECOVERY_OK : RECOVERY_ERR_HASH_MISMATCH; +} + +void recovery_hash_abort(recovery_hash_t *h) +{ + psa_hash_abort(&h->op); +} diff --git a/software/u64ctrl/main/recovery_verify.h b/software/u64ctrl/main/recovery_verify.h new file mode 100644 index 000000000..1dada90c9 --- /dev/null +++ b/software/u64ctrl/main/recovery_verify.h @@ -0,0 +1,40 @@ +/* + * recovery_verify.h + * + * What the recovery needs from the crypto library: the signature check of + * recovery_manifest.h, and the SHA-256 of a downloaded file checked against + * the manifest entry for it. Both are built on PSA Crypto (mbedTLS 4), and both + * start it themselves, so neither depends on who initialised it first. + * + * Unlike recovery_manifest.h this needs the crypto library's headers, so + * only the files that hash include it. + */ + +#ifndef SOFTWARE_U64CTRL_MAIN_RECOVERY_VERIFY_H_ +#define SOFTWARE_U64CTRL_MAIN_RECOVERY_VERIFY_H_ + +#include "psa/crypto.h" +#include "recovery_manifest.h" + +typedef struct { + psa_hash_operation_t op; +} recovery_hash_t; + +/* Starts hashing a file. RECOVERY_ERR_CRYPTO when the crypto library will not + start or will not hash. */ +recovery_result_t recovery_hash_start(recovery_hash_t *h); + +/* Adds the next `len` bytes of the file. RECOVERY_ERR_CRYPTO on a failure, + which ends the hash. */ +recovery_result_t recovery_hash_update(recovery_hash_t *h, const uint8_t *data, size_t len); + +/* Ends the hash and compares it with the manifest's. RECOVERY_OK when they are + equal, RECOVERY_ERR_HASH_MISMATCH when they differ, RECOVERY_ERR_CRYPTO on a + failure. Either way the hash is over. */ +recovery_result_t recovery_hash_finish(recovery_hash_t *h, const recovery_file_t *expected); + +/* Ends a hash that is not going to be finished, e.g. a download that failed. + Harmless on a hash that is already over. */ +void recovery_hash_abort(recovery_hash_t *h); + +#endif /* SOFTWARE_U64CTRL_MAIN_RECOVERY_VERIFY_H_ */ diff --git a/software/u64ctrl/main/rpc_dispatch.h b/software/u64ctrl/main/rpc_dispatch.h index 990b8ba48..285b96df4 100644 --- a/software/u64ctrl/main/rpc_dispatch.h +++ b/software/u64ctrl/main/rpc_dispatch.h @@ -26,8 +26,9 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.21" +#define IDENT_STRING "ESP32 WiFi Bridge V1.22" #define IDENT_MAJOR 1 +// 1.22: built with ESP-IDF 6.0.3; the recovery code uses PSA Crypto (mbedTLS 4). // 1.21: a recovery trusts Mozilla's root list of 2026-10-20 (software/u64ctrl/ca), which // no longer holds the emSign roots G3, C1 and C3, instead of the one in ESP-IDF 5.3.1. // 1.20: terminates 32-character SSIDs and 64-character passwords, and reads @@ -42,7 +43,7 @@ void send_keepalive(); // when this is higher than what the module reports, so a module change that // does not bump it is silently never installed, and an older release never // replaces a newer module. -#define IDENT_MINOR 21 +#define IDENT_MINOR 22 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 diff --git a/software/u64ctrl/sdkconfig b/software/u64ctrl/sdkconfig index 690e00ced..334a465a7 100644 --- a/software/u64ctrl/sdkconfig +++ b/software/u64ctrl/sdkconfig @@ -1,365 +1,658 @@ # # Automatically generated file. DO NOT EDIT. -# Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Configuration +# Espressif IoT Development Framework (ESP-IDF) 6.0.3 Project Configuration # -CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000 -CONFIG_SOC_MPU_REGIONS_MAX_NUM=8 +# default: CONFIG_SOC_ADC_SUPPORTED=y +# default: CONFIG_SOC_UART_SUPPORTED=y +# default: CONFIG_SOC_PCNT_SUPPORTED=y +# default: CONFIG_SOC_PHY_SUPPORTED=y +# default: CONFIG_SOC_WIFI_SUPPORTED=y +# default: CONFIG_SOC_TWAI_SUPPORTED=y +# default: CONFIG_SOC_GDMA_SUPPORTED=y +# default: +CONFIG_SOC_UHCI_SUPPORTED=y +# default: CONFIG_SOC_AHB_GDMA_SUPPORTED=y +# default: CONFIG_SOC_GPTIMER_SUPPORTED=y -CONFIG_SOC_LCDCAM_SUPPORTED=y +# default: +CONFIG_SOC_LCDCAM_CAM_SUPPORTED=y +# default: +CONFIG_SOC_LCDCAM_I80_LCD_SUPPORTED=y +# default: +CONFIG_SOC_LCDCAM_RGB_LCD_SUPPORTED=y +# default: +CONFIG_SOC_LCD_I80_SUPPORTED=y +# default: +CONFIG_SOC_LCD_RGB_SUPPORTED=y +# default: CONFIG_SOC_MCPWM_SUPPORTED=y +# default: CONFIG_SOC_DEDICATED_GPIO_SUPPORTED=y +# default: CONFIG_SOC_CACHE_SUPPORT_WRAP=y +# default: CONFIG_SOC_ULP_SUPPORTED=y +# default: CONFIG_SOC_ULP_FSM_SUPPORTED=y +# default: CONFIG_SOC_RISCV_COPROC_SUPPORTED=y +# default: CONFIG_SOC_BT_SUPPORTED=y +# default: CONFIG_SOC_USB_OTG_SUPPORTED=y +# default: CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED=y +# default: CONFIG_SOC_CCOMP_TIMER_SUPPORTED=y +# default: CONFIG_SOC_ASYNC_MEMCPY_SUPPORTED=y +# default: CONFIG_SOC_SUPPORTS_SECURE_DL_MODE=y +# default: CONFIG_SOC_EFUSE_KEY_PURPOSE_FIELD=y +# default: CONFIG_SOC_EFUSE_SUPPORTED=y +# default: CONFIG_SOC_SDMMC_HOST_SUPPORTED=y +# default: CONFIG_SOC_RTC_FAST_MEM_SUPPORTED=y +# default: CONFIG_SOC_RTC_SLOW_MEM_SUPPORTED=y +# default: CONFIG_SOC_RTC_MEM_SUPPORTED=y +# default: +CONFIG_SOC_RTC_TIMER_V1_SUPPORTED=y +# default: CONFIG_SOC_PSRAM_DMA_CAPABLE=y +# default: CONFIG_SOC_XT_WDT_SUPPORTED=y +# default: CONFIG_SOC_I2S_SUPPORTED=y +# default: CONFIG_SOC_RMT_SUPPORTED=y +# default: CONFIG_SOC_SDM_SUPPORTED=y +# default: CONFIG_SOC_GPSPI_SUPPORTED=y +# default: CONFIG_SOC_LEDC_SUPPORTED=y +# default: CONFIG_SOC_I2C_SUPPORTED=y +# default: CONFIG_SOC_SYSTIMER_SUPPORTED=y +# default: CONFIG_SOC_SUPPORT_COEXISTENCE=y +# default: CONFIG_SOC_TEMP_SENSOR_SUPPORTED=y +# default: CONFIG_SOC_AES_SUPPORTED=y +# default: CONFIG_SOC_MPI_SUPPORTED=y +# default: CONFIG_SOC_SHA_SUPPORTED=y +# default: CONFIG_SOC_HMAC_SUPPORTED=y +# default: CONFIG_SOC_DIG_SIGN_SUPPORTED=y +# default: CONFIG_SOC_FLASH_ENC_SUPPORTED=y +# default: CONFIG_SOC_SECURE_BOOT_SUPPORTED=y +# default: CONFIG_SOC_MEMPROT_SUPPORTED=y +# default: CONFIG_SOC_TOUCH_SENSOR_SUPPORTED=y +# default: CONFIG_SOC_BOD_SUPPORTED=y +# default: CONFIG_SOC_CLK_TREE_SUPPORTED=y +# default: CONFIG_SOC_MPU_SUPPORTED=y +# default: CONFIG_SOC_WDT_SUPPORTED=y +# default: CONFIG_SOC_SPI_FLASH_SUPPORTED=y +# default: CONFIG_SOC_RNG_SUPPORTED=y +# default: CONFIG_SOC_LIGHT_SLEEP_SUPPORTED=y +# default: CONFIG_SOC_DEEP_SLEEP_SUPPORTED=y +# default: CONFIG_SOC_LP_PERIPH_SHARE_INTERRUPT=y +# default: CONFIG_SOC_PM_SUPPORTED=y +# default: +CONFIG_SOC_SIMD_INSTRUCTION_SUPPORTED=y +# default: CONFIG_SOC_XTAL_SUPPORT_40M=y +# default: CONFIG_SOC_APPCPU_HAS_CLOCK_GATING_BUG=y +# default: CONFIG_SOC_ADC_RTC_CTRL_SUPPORTED=y +# default: CONFIG_SOC_ADC_DIG_CTRL_SUPPORTED=y +# default: CONFIG_SOC_ADC_ARBITER_SUPPORTED=y +# default: CONFIG_SOC_ADC_DIG_IIR_FILTER_SUPPORTED=y +# default: CONFIG_SOC_ADC_MONITOR_SUPPORTED=y +# default: CONFIG_SOC_ADC_DMA_SUPPORTED=y +# default: CONFIG_SOC_ADC_PERIPH_NUM=2 +# default: CONFIG_SOC_ADC_MAX_CHANNEL_NUM=10 +# default: CONFIG_SOC_ADC_ATTEN_NUM=4 +# default: CONFIG_SOC_ADC_DIGI_CONTROLLER_NUM=2 +# default: CONFIG_SOC_ADC_PATT_LEN_MAX=24 +# default: CONFIG_SOC_ADC_DIGI_MIN_BITWIDTH=12 +# default: CONFIG_SOC_ADC_DIGI_MAX_BITWIDTH=12 +# default: CONFIG_SOC_ADC_DIGI_RESULT_BYTES=4 +# default: CONFIG_SOC_ADC_DIGI_DATA_BYTES_PER_CONV=4 +# default: CONFIG_SOC_ADC_DIGI_IIR_FILTER_NUM=2 +# default: CONFIG_SOC_ADC_DIGI_MONITOR_NUM=2 +# default: CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_HIGH=83333 +# default: CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_LOW=611 +# default: CONFIG_SOC_ADC_RTC_MIN_BITWIDTH=12 +# default: CONFIG_SOC_ADC_RTC_MAX_BITWIDTH=12 +# default: CONFIG_SOC_ADC_CALIBRATION_V1_SUPPORTED=y +# default: CONFIG_SOC_ADC_SELF_HW_CALI_SUPPORTED=y +# default: CONFIG_SOC_ADC_SHARED_POWER=y +# default: CONFIG_SOC_APB_BACKUP_DMA=y +# default: CONFIG_SOC_BROWNOUT_RESET_SUPPORTED=y +# default: CONFIG_SOC_CACHE_WRITEBACK_SUPPORTED=y +# default: CONFIG_SOC_CACHE_FREEZE_SUPPORTED=y +# default: +CONFIG_SOC_CACHE_ACS_INVALID_STATE_ON_PANIC=y +# default: CONFIG_SOC_CPU_CORES_NUM=2 +# default: CONFIG_SOC_CPU_INTR_NUM=32 +# default: CONFIG_SOC_CPU_HAS_FPU=y +# default: CONFIG_SOC_HP_CPU_HAS_MULTIPLE_CORES=y +# default: CONFIG_SOC_CPU_BREAKPOINTS_NUM=2 +# default: CONFIG_SOC_CPU_WATCHPOINTS_NUM=2 -CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=64 +# default: +CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=0x40 +# default: +CONFIG_SOC_SIMD_PREFERRED_DATA_ALIGNMENT=16 +# default: CONFIG_SOC_DS_SIGNATURE_MAX_BIT_LEN=4096 +# default: CONFIG_SOC_DS_KEY_PARAM_MD_IV_LENGTH=16 +# default: CONFIG_SOC_DS_KEY_CHECK_MAX_WAIT_US=1100 +# default: CONFIG_SOC_AHB_GDMA_VERSION=1 -CONFIG_SOC_GDMA_NUM_GROUPS_MAX=1 -CONFIG_SOC_GDMA_PAIRS_PER_GROUP=5 -CONFIG_SOC_GDMA_PAIRS_PER_GROUP_MAX=5 -CONFIG_SOC_AHB_GDMA_SUPPORT_PSRAM=y +# default: CONFIG_SOC_GPIO_PORT=1 +# default: CONFIG_SOC_GPIO_PIN_COUNT=49 +# default: CONFIG_SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER=y -CONFIG_SOC_GPIO_FILTER_CLK_SUPPORT_APB=y -CONFIG_SOC_GPIO_SUPPORT_RTC_INDEPENDENT=y +# default: CONFIG_SOC_GPIO_SUPPORT_FORCE_HOLD=y +# default: CONFIG_SOC_GPIO_VALID_GPIO_MASK=0x1FFFFFFFFFFFF +# default: CONFIG_SOC_GPIO_IN_RANGE_MAX=48 +# default: CONFIG_SOC_GPIO_OUT_RANGE_MAX=48 +# default: CONFIG_SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK=0x0001FFFFFC000000 +# default: CONFIG_SOC_GPIO_CLOCKOUT_BY_IO_MUX=y +# default: CONFIG_SOC_GPIO_CLOCKOUT_CHANNEL_NUM=3 -CONFIG_SOC_DEDIC_GPIO_OUT_CHANNELS_NUM=8 -CONFIG_SOC_DEDIC_GPIO_IN_CHANNELS_NUM=8 -CONFIG_SOC_DEDIC_GPIO_OUT_AUTO_ENABLE=y +# default: CONFIG_SOC_I2C_NUM=2 +# default: CONFIG_SOC_HP_I2C_NUM=2 -CONFIG_SOC_I2C_FIFO_LEN=32 -CONFIG_SOC_I2C_CMD_REG_NUM=8 -CONFIG_SOC_I2C_SUPPORT_SLAVE=y -CONFIG_SOC_I2C_SUPPORT_HW_CLR_BUS=y +# default: CONFIG_SOC_I2C_SUPPORT_XTAL=y +# default: CONFIG_SOC_I2C_SUPPORT_RTC=y +# default: CONFIG_SOC_I2C_SUPPORT_10BIT_ADDR=y +# default: +CONFIG_SOC_I2C_SUPPORT_SLAVE=y +# default: CONFIG_SOC_I2C_SLAVE_SUPPORT_BROADCAST=y -CONFIG_SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS=y -CONFIG_SOC_I2S_NUM=2 +# default: +CONFIG_SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE=y +# default: CONFIG_SOC_I2S_HW_VERSION_2=y -CONFIG_SOC_I2S_SUPPORTS_XTAL=y -CONFIG_SOC_I2S_SUPPORTS_PLL_F160M=y +# default: CONFIG_SOC_I2S_SUPPORTS_PCM=y +# default: CONFIG_SOC_I2S_SUPPORTS_PDM=y +# default: CONFIG_SOC_I2S_SUPPORTS_PDM_TX=y -CONFIG_SOC_I2S_PDM_MAX_TX_LINES=2 +# default: +CONFIG_SOC_I2S_SUPPORTS_PCM2PDM=y +# default: CONFIG_SOC_I2S_SUPPORTS_PDM_RX=y +# default: +CONFIG_SOC_I2S_SUPPORTS_PDM2PCM=y +# default: +CONFIG_SOC_I2S_PDM_MAX_TX_LINES=2 +# default: CONFIG_SOC_I2S_PDM_MAX_RX_LINES=4 +# default: CONFIG_SOC_I2S_SUPPORTS_TDM=y +# default: CONFIG_SOC_LEDC_SUPPORT_APB_CLOCK=y +# default: CONFIG_SOC_LEDC_SUPPORT_XTAL_CLOCK=y +# default: +CONFIG_SOC_LEDC_TIMER_NUM=4 +# default: CONFIG_SOC_LEDC_CHANNEL_NUM=8 +# default: CONFIG_SOC_LEDC_TIMER_BIT_WIDTH=14 +# default: CONFIG_SOC_LEDC_SUPPORT_FADE_STOP=y -CONFIG_SOC_MCPWM_GROUPS=2 -CONFIG_SOC_MCPWM_TIMERS_PER_GROUP=3 -CONFIG_SOC_MCPWM_OPERATORS_PER_GROUP=3 -CONFIG_SOC_MCPWM_COMPARATORS_PER_OPERATOR=2 -CONFIG_SOC_MCPWM_GENERATORS_PER_OPERATOR=2 -CONFIG_SOC_MCPWM_TRIGGERS_PER_OPERATOR=2 -CONFIG_SOC_MCPWM_GPIO_FAULTS_PER_GROUP=3 -CONFIG_SOC_MCPWM_CAPTURE_TIMERS_PER_GROUP=y -CONFIG_SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER=3 -CONFIG_SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP=3 +# default: CONFIG_SOC_MCPWM_SWSYNC_CAN_PROPAGATE=y +# default: CONFIG_SOC_MMU_LINEAR_ADDRESS_REGION_NUM=1 +# default: CONFIG_SOC_MMU_PERIPH_NUM=1 -CONFIG_SOC_PCNT_GROUPS=1 -CONFIG_SOC_PCNT_UNITS_PER_GROUP=4 -CONFIG_SOC_PCNT_CHANNELS_PER_UNIT=2 -CONFIG_SOC_PCNT_THRES_POINT_PER_UNIT=2 -CONFIG_SOC_RMT_GROUPS=1 -CONFIG_SOC_RMT_TX_CANDIDATES_PER_GROUP=4 -CONFIG_SOC_RMT_RX_CANDIDATES_PER_GROUP=4 -CONFIG_SOC_RMT_CHANNELS_PER_GROUP=8 +# default: +CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000 +# default: +CONFIG_SOC_MPU_REGIONS_MAX_NUM=8 +# default: CONFIG_SOC_RMT_MEM_WORDS_PER_CHANNEL=48 +# default: CONFIG_SOC_RMT_SUPPORT_RX_PINGPONG=y -CONFIG_SOC_RMT_SUPPORT_RX_DEMODULATION=y -CONFIG_SOC_RMT_SUPPORT_TX_ASYNC_STOP=y +# default: CONFIG_SOC_RMT_SUPPORT_TX_LOOP_COUNT=y +# default: CONFIG_SOC_RMT_SUPPORT_TX_LOOP_AUTO_STOP=y -CONFIG_SOC_RMT_SUPPORT_TX_SYNCHRO=y -CONFIG_SOC_RMT_SUPPORT_TX_CARRIER_DATA_ONLY=y -CONFIG_SOC_RMT_SUPPORT_XTAL=y -CONFIG_SOC_RMT_SUPPORT_RC_FAST=y -CONFIG_SOC_RMT_SUPPORT_APB=y +# default: CONFIG_SOC_RMT_SUPPORT_DMA=y -CONFIG_SOC_LCD_I80_SUPPORTED=y -CONFIG_SOC_LCD_RGB_SUPPORTED=y -CONFIG_SOC_LCD_I80_BUSES=1 -CONFIG_SOC_LCD_RGB_PANELS=1 -CONFIG_SOC_LCD_I80_BUS_WIDTH=16 -CONFIG_SOC_LCD_RGB_DATA_WIDTH=16 -CONFIG_SOC_LCD_SUPPORT_RGB_YUV_CONV=y +# default: CONFIG_SOC_RTC_CNTL_CPU_PD_DMA_BUS_WIDTH=128 +# default: CONFIG_SOC_RTC_CNTL_CPU_PD_REG_FILE_NUM=549 +# default: CONFIG_SOC_RTC_CNTL_TAGMEM_PD_DMA_BUS_WIDTH=128 +# default: +CONFIG_SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS=y +# default: CONFIG_SOC_RTCIO_PIN_COUNT=22 +# default: CONFIG_SOC_RTCIO_INPUT_OUTPUT_SUPPORTED=y +# default: CONFIG_SOC_RTCIO_HOLD_SUPPORTED=y +# default: CONFIG_SOC_RTCIO_WAKE_SUPPORTED=y -CONFIG_SOC_SDM_GROUPS=y -CONFIG_SOC_SDM_CHANNELS_PER_GROUP=8 -CONFIG_SOC_SDM_CLK_SUPPORT_APB=y +# default: +CONFIG_SOC_LP_IO_CLOCK_IS_INDEPENDENT=y +# default: CONFIG_SOC_SPI_PERIPH_NUM=3 +# default: CONFIG_SOC_SPI_MAX_CS_NUM=6 +# default: CONFIG_SOC_SPI_MAXIMUM_BUFFER_SIZE=64 +# default: CONFIG_SOC_SPI_SUPPORT_DDRCLK=y +# default: CONFIG_SOC_SPI_SLAVE_SUPPORT_SEG_TRANS=y +# default: CONFIG_SOC_SPI_SUPPORT_CD_SIG=y +# default: CONFIG_SOC_SPI_SUPPORT_CONTINUOUS_TRANS=y +# default: CONFIG_SOC_SPI_SUPPORT_SLAVE_HD_VER2=y +# default: CONFIG_SOC_SPI_SUPPORT_CLK_APB=y +# default: CONFIG_SOC_SPI_SUPPORT_CLK_XTAL=y +# default: CONFIG_SOC_SPI_PERIPH_SUPPORT_CONTROL_DUMMY_OUT=y +# default: CONFIG_SOC_MEMSPI_IS_INDEPENDENT=y +# default: CONFIG_SOC_SPI_MAX_PRE_DIVIDER=16 +# default: CONFIG_SOC_SPI_SUPPORT_OCT=y +# default: CONFIG_SOC_SPI_SCT_SUPPORTED=y +# default: CONFIG_SOC_SPI_SCT_REG_NUM=14 +# default: CONFIG_SOC_SPI_SCT_BUFFER_NUM_MAX=y +# default: CONFIG_SOC_SPI_SCT_CONF_BITLEN_MAX=0x3FFFA -CONFIG_SOC_MEMSPI_SRC_FREQ_120M=y -CONFIG_SOC_MEMSPI_SRC_FREQ_80M_SUPPORTED=y -CONFIG_SOC_MEMSPI_SRC_FREQ_40M_SUPPORTED=y -CONFIG_SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED=y +# default: CONFIG_SOC_SPIRAM_SUPPORTED=y +# default: CONFIG_SOC_SPIRAM_XIP_SUPPORTED=y +# default: CONFIG_SOC_SYSTIMER_COUNTER_NUM=2 +# default: CONFIG_SOC_SYSTIMER_ALARM_NUM=3 +# default: CONFIG_SOC_SYSTIMER_BIT_WIDTH_LO=32 +# default: CONFIG_SOC_SYSTIMER_BIT_WIDTH_HI=20 +# default: CONFIG_SOC_SYSTIMER_FIXED_DIVIDER=y +# default: CONFIG_SOC_SYSTIMER_INT_LEVEL=y +# default: CONFIG_SOC_SYSTIMER_ALARM_MISS_COMPENSATE=y -CONFIG_SOC_TIMER_GROUPS=2 -CONFIG_SOC_TIMER_GROUP_TIMERS_PER_GROUP=2 -CONFIG_SOC_TIMER_GROUP_COUNTER_BIT_WIDTH=54 -CONFIG_SOC_TIMER_GROUP_SUPPORT_XTAL=y -CONFIG_SOC_TIMER_GROUP_SUPPORT_APB=y -CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=4 +# default: +CONFIG_SOC_LP_TIMER_BIT_WIDTH_LO=32 +# default: +CONFIG_SOC_LP_TIMER_BIT_WIDTH_HI=16 +# default: CONFIG_SOC_TOUCH_SENSOR_VERSION=2 -CONFIG_SOC_TOUCH_SENSOR_NUM=15 +# default: +CONFIG_SOC_TOUCH_MIN_CHAN_ID=1 +# default: +CONFIG_SOC_TOUCH_MAX_CHAN_ID=14 +# default: +CONFIG_SOC_TOUCH_SUPPORT_BENCHMARK=y +# default: CONFIG_SOC_TOUCH_SUPPORT_SLEEP_WAKEUP=y +# default: CONFIG_SOC_TOUCH_SUPPORT_WATERPROOF=y +# default: CONFIG_SOC_TOUCH_SUPPORT_PROX_SENSING=y +# default: +CONFIG_SOC_TOUCH_SUPPORT_DENOISE_CHAN=y +# default: CONFIG_SOC_TOUCH_PROXIMITY_CHANNEL_NUM=3 -CONFIG_SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED=y +# default: CONFIG_SOC_TOUCH_SAMPLE_CFG_NUM=1 +# default: CONFIG_SOC_TWAI_CONTROLLER_NUM=1 -CONFIG_SOC_TWAI_CLK_SUPPORT_APB=y -CONFIG_SOC_TWAI_BRP_MIN=2 -CONFIG_SOC_TWAI_BRP_MAX=16384 -CONFIG_SOC_TWAI_SUPPORTS_RX_STATUS=y +# default: +CONFIG_SOC_TWAI_MASK_FILTER_NUM=1 +# default: CONFIG_SOC_UART_NUM=3 +# default: CONFIG_SOC_UART_HP_NUM=3 +# default: CONFIG_SOC_UART_FIFO_LEN=128 +# default: CONFIG_SOC_UART_BITRATE_MAX=5000000 -CONFIG_SOC_UART_SUPPORT_FSM_TX_WAIT_SEND=y +# default: CONFIG_SOC_UART_SUPPORT_WAKEUP_INT=y +# default: CONFIG_SOC_UART_SUPPORT_APB_CLK=y +# default: CONFIG_SOC_UART_SUPPORT_RTC_CLK=y +# default: CONFIG_SOC_UART_SUPPORT_XTAL_CLK=y +# default: +CONFIG_SOC_UART_WAKEUP_SUPPORT_ACTIVE_THRESH_MODE=y +# default: +CONFIG_SOC_UHCI_NUM=1 +# default: CONFIG_SOC_USB_OTG_PERIPH_NUM=1 +# default: +CONFIG_SOC_USB_FSLS_PHY_NUM=1 +# default: CONFIG_SOC_SHA_DMA_MAX_BUFFER_SIZE=3968 +# default: CONFIG_SOC_SHA_SUPPORT_DMA=y +# default: CONFIG_SOC_SHA_SUPPORT_RESUME=y +# default: CONFIG_SOC_SHA_GDMA=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA1=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA224=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA256=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA384=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA512=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA512_224=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA512_256=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA512_T=y +# default: CONFIG_SOC_MPI_MEM_BLOCKS_NUM=4 +# default: CONFIG_SOC_MPI_OPERATIONS_NUM=3 +# default: CONFIG_SOC_RSA_MAX_BIT_LEN=4096 +# default: CONFIG_SOC_AES_SUPPORT_DMA=y +# default: CONFIG_SOC_AES_GDMA=y +# default: CONFIG_SOC_AES_SUPPORT_AES_128=y +# default: CONFIG_SOC_AES_SUPPORT_AES_256=y +# default: CONFIG_SOC_PM_SUPPORT_EXT0_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_EXT1_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_EXT_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_WIFI_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_BT_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_CPU_PD=y +# default: CONFIG_SOC_PM_SUPPORT_TAGMEM_PD=y +# default: CONFIG_SOC_PM_SUPPORT_RTC_PERIPH_PD=y +# default: CONFIG_SOC_PM_SUPPORT_RC_FAST_PD=y +# default: CONFIG_SOC_PM_SUPPORT_VDDSDIO_PD=y +# default: CONFIG_SOC_PM_SUPPORT_MAC_BB_PD=y +# default: CONFIG_SOC_PM_SUPPORT_MODEM_PD=y +# default: CONFIG_SOC_CONFIGURABLE_VDDSDIO_SUPPORTED=y +# default: CONFIG_SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY=y +# default: CONFIG_SOC_PM_CPU_RETENTION_BY_RTCCNTL=y +# default: CONFIG_SOC_PM_MODEM_RETENTION_BY_BACKUPDMA=y +# default: +CONFIG_SOC_PM_MODEM_PD_BY_SW=y +# default: CONFIG_SOC_CLK_RC_FAST_D256_SUPPORTED=y +# default: CONFIG_SOC_RTC_SLOW_CLK_SUPPORT_RC_FAST_D256=y +# default: CONFIG_SOC_CLK_RC_FAST_SUPPORT_CALIBRATION=y +# default: CONFIG_SOC_CLK_XTAL32K_SUPPORTED=y +# default: +CONFIG_SOC_CLK_LP_FAST_SUPPORT_XTAL_D2=y +# default: CONFIG_SOC_EFUSE_DIS_DOWNLOAD_ICACHE=y +# default: CONFIG_SOC_EFUSE_DIS_DOWNLOAD_DCACHE=y +# default: CONFIG_SOC_EFUSE_HARD_DIS_JTAG=y +# default: CONFIG_SOC_EFUSE_DIS_USB_JTAG=y +# default: CONFIG_SOC_EFUSE_SOFT_DIS_JTAG=y +# default: CONFIG_SOC_EFUSE_DIS_DIRECT_BOOT=y +# default: CONFIG_SOC_EFUSE_DIS_ICACHE=y +# default: CONFIG_SOC_EFUSE_BLOCK9_KEY_PURPOSE_QUIRK=y +# default: +CONFIG_SOC_EFUSE_XTS_AES_KEY_128=y +# default: +CONFIG_SOC_EFUSE_XTS_AES_KEY_256=y +# default: CONFIG_SOC_SECURE_BOOT_V2_RSA=y +# default: CONFIG_SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS=3 +# default: CONFIG_SOC_EFUSE_REVOKE_BOOT_KEY_DIGESTS=y +# default: CONFIG_SOC_SUPPORT_SECURE_BOOT_REVOKE_KEY=y +# default: CONFIG_SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX=64 +# default: CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES=y +# default: CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES_OPTIONS=y +# default: CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES_128=y +# default: CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES_256=y +# default: CONFIG_SOC_MEMPROT_CPU_PREFETCH_PAD_SIZE=16 +# default: CONFIG_SOC_MEMPROT_MEM_ALIGN_SIZE=256 +# default: CONFIG_SOC_PHY_DIG_REGS_MEM_SIZE=21 +# default: CONFIG_SOC_MAC_BB_PD_MEM_SIZE=192 +# default: CONFIG_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH=12 +# default: CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_SUSPEND=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_RESUME=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_SW_SUSPEND=y -CONFIG_SOC_SPI_MEM_SUPPORT_OPI_MODE=y +# default: +CONFIG_SOC_SPI_MEM_SUPPORT_FLASH_OPI_MODE=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_TIMING_TUNING=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_WRAP=y +# default: CONFIG_SOC_MEMSPI_TIMING_TUNING_BY_MSPI_DELAY=y +# default: CONFIG_SOC_MEMSPI_CORE_CLK_SHARED_WITH_PSRAM=y +# default: +CONFIG_SOC_SPI_MEM_SUPPORT_CACHE_32BIT_ADDR_MAP=y +# default: +CONFIG_SOC_SPI_MEM_FLASH_SUPPORT_HPM=y +# default: +CONFIG_SOC_MEMSPI_ENCRYPTION_ALIGNMENT=16 +# default: CONFIG_SOC_COEX_HW_PTI=y +# default: CONFIG_SOC_EXTERNAL_COEX_LEADER_TX_LINE=y +# default: CONFIG_SOC_SDMMC_USE_GPIO_MATRIX=y +# default: CONFIG_SOC_SDMMC_NUM_SLOTS=2 -CONFIG_SOC_SDMMC_SUPPORT_XTAL_CLOCK=y +# default: +CONFIG_SOC_SDMMC_DATA_WIDTH_MAX=8 +# default: CONFIG_SOC_SDMMC_DELAY_PHASE_NUM=4 +# default: CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC=y +# default: CONFIG_SOC_WIFI_HW_TSF=y +# default: CONFIG_SOC_WIFI_FTM_SUPPORT=y +# default: CONFIG_SOC_WIFI_GCMP_SUPPORT=y +# default: CONFIG_SOC_WIFI_WAPI_SUPPORT=y +# default: +CONFIG_SOC_WIFI_TXOP_SUPPORT=y +# default: CONFIG_SOC_WIFI_CSI_SUPPORT=y +# default: CONFIG_SOC_WIFI_MESH_SUPPORT=y +# default: CONFIG_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y +# default: CONFIG_SOC_WIFI_PHY_NEEDS_USB_WORKAROUND=y +# default: CONFIG_SOC_BLE_SUPPORTED=y +# default: CONFIG_SOC_BLE_MESH_SUPPORTED=y +# default: CONFIG_SOC_BLE_50_SUPPORTED=y +# default: CONFIG_SOC_BLE_DEVICE_PRIVACY_SUPPORTED=y +# default: CONFIG_SOC_BLUFI_SUPPORTED=y +# default: CONFIG_SOC_ULP_HAS_ADC=y +# default: CONFIG_SOC_PHY_COMBO_MODULE=y +# default: +CONFIG_SOC_LCDCAM_CAM_SUPPORT_RGB_YUV_CONV=y +# default: CONFIG_IDF_CMAKE=y +# default: CONFIG_IDF_TOOLCHAIN="gcc" +# default: +CONFIG_IDF_TOOLCHAIN_GCC=y +# default: CONFIG_IDF_TARGET_ARCH_XTENSA=y +# default: CONFIG_IDF_TARGET_ARCH="xtensa" +# default: CONFIG_IDF_TARGET="esp32s3" +# default: CONFIG_IDF_INIT_VERSION="5.3.1" +# default: CONFIG_IDF_TARGET_ESP32S3=y +# default: CONFIG_IDF_FIRMWARE_CHIP_ID=0x0009 # @@ -367,13 +660,21 @@ CONFIG_IDF_FIRMWARE_CHIP_ID=0x0009 # CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y # CONFIG_APP_BUILD_TYPE_RAM is not set +# default: CONFIG_APP_BUILD_GENERATE_BINARIES=y +# default: CONFIG_APP_BUILD_BOOTLOADER=y +# default: CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y # CONFIG_APP_REPRODUCIBLE_BUILD is not set # CONFIG_APP_NO_BLOBS is not set # end of Build type +# +# App Update config +# +# end of App Update config + # # Bootloader config # @@ -385,19 +686,61 @@ CONFIG_BOOTLOADER_COMPILE_TIME_DATE=y CONFIG_BOOTLOADER_PROJECT_VER=1 # end of Bootloader manager +# +# Application Rollback +# +# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set +# end of Application Rollback + +# +# Recovery Bootloader and Rollback +# +# end of Recovery Bootloader and Rollback + +# default: CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set + +# +# Log +# +# default: +CONFIG_BOOTLOADER_LOG_VERSION_1=y +# default: +CONFIG_BOOTLOADER_LOG_VERSION=1 # CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set # CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set +# default: CONFIG_BOOTLOADER_LOG_LEVEL=3 +# +# Format +# +# default: +# CONFIG_BOOTLOADER_LOG_COLORS is not set +# default: +CONFIG_BOOTLOADER_LOG_TIMESTAMP_SOURCE_CPU_TICKS=y +# end of Format + +# +# Settings +# +# default: +CONFIG_BOOTLOADER_LOG_MODE_TEXT_EN=y +# default: +CONFIG_BOOTLOADER_LOG_MODE_TEXT=y +# end of Settings +# end of Log + +# default: +CONFIG_BOOTLOADER_CPU_CLK_FREQ_MHZ=80 + # # Serial Flash Configurations # @@ -412,10 +755,10 @@ CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE=y CONFIG_BOOTLOADER_WDT_ENABLE=y # CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set CONFIG_BOOTLOADER_WDT_TIME_MS=9000 -# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set # CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set # CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set # CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set +# default: CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 # CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set # end of Bootloader config @@ -423,11 +766,18 @@ CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 # # Security features # +# default: CONFIG_SECURE_BOOT_V2_RSA_SUPPORTED=y +# default: CONFIG_SECURE_BOOT_V2_PREFERRED=y # CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set +# default: +CONFIG_SECURE_BOOT_IMAGE_DIGEST_LEN=32 +# default: +CONFIG_SECURE_BOOT_ROM_FAST_WAKE_RESERVE_SIZE=0 # CONFIG_SECURE_BOOT is not set # CONFIG_SECURE_FLASH_ENC_ENABLED is not set +# default: CONFIG_SECURE_ROM_DL_MODE_ENABLED=y # end of Security features @@ -441,33 +791,66 @@ CONFIG_APP_COMPILE_TIME_DATE=y CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 # end of Application manager +# default: CONFIG_ESP_ROM_HAS_CRC_LE=y +# default: CONFIG_ESP_ROM_HAS_CRC_BE=y +# default: CONFIG_ESP_ROM_HAS_MZ_CRC32=y +# default: CONFIG_ESP_ROM_HAS_JPEG_DECODE=y +# default: CONFIG_ESP_ROM_UART_CLK_IS_XTAL=y +# default: CONFIG_ESP_ROM_HAS_RETARGETABLE_LOCKING=y +# default: CONFIG_ESP_ROM_USB_OTG_NUM=3 +# default: CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM=4 +# default: CONFIG_ESP_ROM_HAS_ERASE_0_REGION_BUG=y +# default: CONFIG_ESP_ROM_HAS_ENCRYPTED_WRITES_USING_LEGACY_DRV=y +# default: CONFIG_ESP_ROM_GET_CLK_FREQ=y +# default: CONFIG_ESP_ROM_HAS_HAL_WDT=y +# default: CONFIG_ESP_ROM_NEEDS_SWSETUP_WORKAROUND=y +# default: CONFIG_ESP_ROM_HAS_LAYOUT_TABLE=y +# default: CONFIG_ESP_ROM_HAS_SPI_FLASH=y +# default: +CONFIG_ESP_ROM_HAS_SPI_FLASH_MMAP=y +# default: CONFIG_ESP_ROM_HAS_ETS_PRINTF_BUG=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB_NANO_FORMAT=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB_32BIT_TIME=y +# default: CONFIG_ESP_ROM_NEEDS_SET_CACHE_MMU_SIZE=y +# default: CONFIG_ESP_ROM_RAM_APP_NEEDS_MMU_INIT=y +# default: CONFIG_ESP_ROM_HAS_FLASH_COUNT_PAGES_BUG=y +# default: CONFIG_ESP_ROM_HAS_CACHE_SUSPEND_WAITI_BUG=y +# default: CONFIG_ESP_ROM_HAS_CACHE_WRITEBACK_BUG=y +# default: CONFIG_ESP_ROM_HAS_SW_FLOAT=y +# default: CONFIG_ESP_ROM_HAS_VERSION=y +# default: CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y +# default: +CONFIG_ESP_ROM_HAS_OUTPUT_PUTC_FUNC=y +# default: +CONFIG_ESP_ROM_CONSOLE_OUTPUT_SECONDARY=y # # Boot ROM Behavior @@ -489,12 +872,13 @@ CONFIG_ESPTOOLPY_FLASH_MODE_AUTO_DETECT=y CONFIG_ESPTOOLPY_FLASHMODE_DIO=y # CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y +# default: CONFIG_ESPTOOLPY_FLASHMODE="dio" # CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set CONFIG_ESPTOOLPY_FLASHFREQ_80M=y # CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -CONFIG_ESPTOOLPY_FLASHFREQ_80M_DEFAULT=y +# default: CONFIG_ESPTOOLPY_FLASHFREQ="80m" # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set @@ -504,14 +888,18 @@ CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y # CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set +# default: CONFIG_ESPTOOLPY_FLASHSIZE="8MB" # CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE is not set CONFIG_ESPTOOLPY_BEFORE_RESET=y # CONFIG_ESPTOOLPY_BEFORE_NORESET is not set -CONFIG_ESPTOOLPY_BEFORE="default_reset" +# default: +CONFIG_ESPTOOLPY_BEFORE="default-reset" CONFIG_ESPTOOLPY_AFTER_RESET=y # CONFIG_ESPTOOLPY_AFTER_NORESET is not set -CONFIG_ESPTOOLPY_AFTER="hard_reset" +# default: +CONFIG_ESPTOOLPY_AFTER="hard-reset" +# default: CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 # end of Serial flasher config @@ -521,8 +909,10 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 # CONFIG_PARTITION_TABLE_SINGLE_APP is not set # CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set # CONFIG_PARTITION_TABLE_TWO_OTA is not set +# CONFIG_PARTITION_TABLE_TWO_OTA_LARGE is not set CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +# default: CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y @@ -531,9 +921,13 @@ CONFIG_PARTITION_TABLE_MD5=y # # Example Configuration # +# default: CONFIG_ENV_GPIO_RANGE_MIN=0 +# default: CONFIG_ENV_GPIO_RANGE_MAX=48 +# default: CONFIG_ENV_GPIO_IN_RANGE_MAX=48 +# default: CONFIG_ENV_GPIO_OUT_RANGE_MAX=48 CONFIG_BLINK_GPIO=18 CONFIG_BLINK_PERIOD=1000 @@ -549,7 +943,10 @@ CONFIG_COMPILER_OPTIMIZATION_DEBUG=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +# default: +# CONFIG_COMPILER_ASSERT_NDEBUG_EVALUATE is not set CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB=y +# default: CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 # CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set CONFIG_COMPILER_HIDE_PATHS_MACROS=y @@ -559,117 +956,120 @@ CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y # CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set # CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set # CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set +# default: +# CONFIG_COMPILER_NO_MERGE_CONSTANTS is not set # CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +# default: +# CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS is not set # CONFIG_COMPILER_DISABLE_GCC12_WARNINGS is not set # CONFIG_COMPILER_DISABLE_GCC13_WARNINGS is not set +# default: +# CONFIG_COMPILER_DISABLE_GCC14_WARNINGS is not set +# default: +# CONFIG_COMPILER_DISABLE_GCC15_WARNINGS is not set # CONFIG_COMPILER_DUMP_RTL_FILES is not set CONFIG_COMPILER_RT_LIB_GCCLIB=y +# default: CONFIG_COMPILER_RT_LIB_NAME="gcc" +# CONFIG_COMPILER_ORPHAN_SECTIONS_ERROR is not set # CONFIG_COMPILER_ORPHAN_SECTIONS_WARNING is not set CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y +# default: +# CONFIG_COMPILER_STATIC_ANALYZER is not set +# default: +CONFIG_COMPILER_CXX_GLIBCXX_CONSTEXPR_NO_CHANGE=y +# default: +# CONFIG_COMPILER_CXX_GLIBCXX_CONSTEXPR_COLD_CONSTEXPR is not set +# default: +# CONFIG_COMPILER_CXX_GLIBCXX_CONSTEXPR_COLD is not set # end of Compiler options # # Component config # -# -# Application Level Tracing -# -# CONFIG_APPTRACE_DEST_JTAG is not set -CONFIG_APPTRACE_DEST_NONE=y -# CONFIG_APPTRACE_DEST_UART1 is not set -# CONFIG_APPTRACE_DEST_UART2 is not set -# CONFIG_APPTRACE_DEST_USB_CDC is not set -CONFIG_APPTRACE_DEST_UART_NONE=y -CONFIG_APPTRACE_UART_TASK_PRIO=1 -CONFIG_APPTRACE_LOCK_ENABLE=y -# end of Application Level Tracing - # # Bluetooth # # CONFIG_BT_ENABLED is not set -CONFIG_BT_ALARM_MAX_NUM=50 -# end of Bluetooth - -# -# Console Library -# -# CONFIG_CONSOLE_SORTED_HELP is not set -# end of Console Library # -# Driver Configurations +# Common Options # # -# TWAI Configuration +# BT Logs # -# CONFIG_TWAI_ISR_IN_IRAM is not set -CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM=y -# end of TWAI Configuration # -# Legacy ADC Driver Configuration +# Log Sources # -# CONFIG_ADC_SUPPRESS_DEPRECATE_WARN is not set +# end of Log Sources -# -# Legacy ADC Calibration Configuration -# -# CONFIG_ADC_CALI_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy ADC Calibration Configuration -# end of Legacy ADC Driver Configuration +# default: +# CONFIG_BT_LOG_CRITICAL_ONLY is not set +# default: +# CONFIG_BLE_LOG_ENABLED is not set # -# Legacy MCPWM Driver Configurations +# Legacy SPI Log Output (Deprecated - use BT Log Async Output instead) # -# CONFIG_MCPWM_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy MCPWM Driver Configurations +# default: +# CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED is not set +# end of Legacy SPI Log Output (Deprecated - use BT Log Async Output instead) +# end of BT Logs -# -# Legacy Timer Group Driver Configurations -# -# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy Timer Group Driver Configurations +# default: +# CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED is not set +# end of Common Options +# end of Bluetooth # -# Legacy RMT Driver Configurations +# Console Library # -# CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy RMT Driver Configurations +# CONFIG_CONSOLE_SORTED_HELP is not set +# end of Console Library # -# Legacy I2S Driver Configurations +# Legacy Driver Configurations # -# CONFIG_I2S_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy I2S Driver Configurations # -# Legacy PCNT Driver Configurations +# Legacy TWAI Driver Configurations # -# CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy PCNT Driver Configurations +# default: +# CONFIG_TWAI_ISR_IN_IRAM_LEGACY is not set +# default: +# CONFIG_TWAI_SUPPRESS_DEPRECATE_WARN is not set +# default: +# CONFIG_TWAI_SKIP_LEGACY_CONFLICT_CHECK is not set +# end of Legacy TWAI Driver Configurations # -# Legacy SDM Driver Configurations +# Legacy I2C Driver Configurations # -# CONFIG_SDM_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy SDM Driver Configurations +# default: +# CONFIG_I2C_SUPPRESS_DEPRECATE_WARN is not set +# default: +# CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK is not set +# end of Legacy I2C Driver Configurations # -# Legacy Temperature Sensor Driver Configurations +# Legacy Touch Sensor Driver Configurations # -# CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy Temperature Sensor Driver Configurations -# end of Driver Configurations +# default: +# CONFIG_TOUCH_SUPPRESS_DEPRECATE_WARN is not set +# default: +# CONFIG_TOUCH_SKIP_LEGACY_CONFLICT_CHECK is not set +# end of Legacy Touch Sensor Driver Configurations +# end of Legacy Driver Configurations # # eFuse Bit Manager # # CONFIG_EFUSE_CUSTOM_TABLE is not set # CONFIG_EFUSE_VIRTUAL is not set +# default: CONFIG_EFUSE_MAX_BLK_LEN=256 # end of eFuse Bit Manager @@ -677,6 +1077,7 @@ CONFIG_EFUSE_MAX_BLK_LEN=256 # ESP-TLS # CONFIG_ESP_TLS_USING_MBEDTLS=y +# CONFIG_ESP_TLS_CUSTOM_STACK is not set CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y # CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set # CONFIG_ESP_TLS_SERVER_SESSION_TICKETS is not set @@ -684,6 +1085,8 @@ CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y # CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL is not set # CONFIG_ESP_TLS_PSK_VERIFICATION is not set # CONFIG_ESP_TLS_INSECURE is not set +# default: +CONFIG_ESP_TLS_DYN_BUF_STRATEGY_SUPPORTED=y # end of ESP-TLS # @@ -698,8 +1101,11 @@ CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y # # Wireless Coexistence # +# default: CONFIG_ESP_COEX_ENABLED=y # CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE is not set +# default: +# CONFIG_ESP_COEX_GPIO_DEBUG is not set # end of Wireless Coexistence # @@ -708,6 +1114,24 @@ CONFIG_ESP_COEX_ENABLED=y CONFIG_ESP_ERR_TO_NAME_LOOKUP=y # end of Common ESP-related +# +# ESP-Driver:Camera Controller Configurations +# +# default: +# CONFIG_CAM_CTLR_DVP_CAM_ISR_CACHE_SAFE is not set +# end of ESP-Driver:Camera Controller Configurations + +# +# GDMA Configurations +# +CONFIG_GDMA_CTRL_FUNC_IN_IRAM=y +# default: +CONFIG_GDMA_ISR_HANDLER_IN_IRAM=y +# default: +CONFIG_GDMA_OBJ_DRAM_SAFE=y +# CONFIG_GDMA_ENABLE_DEBUG_LOG is not set +# end of GDMA Configurations + # # ESP-Driver:GPIO Configurations # @@ -719,7 +1143,9 @@ CONFIG_ESP_ERR_TO_NAME_LOOKUP=y # CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set -# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set +# CONFIG_GPTIMER_ISR_CACHE_SAFE is not set +# default: +CONFIG_GPTIMER_OBJ_CACHE_SAFE=y # CONFIG_GPTIMER_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:GPTimer Configurations @@ -728,15 +1154,30 @@ CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # # CONFIG_I2C_ISR_IRAM_SAFE is not set # CONFIG_I2C_ENABLE_DEBUG_LOG is not set +# default: +CONFIG_I2C_MASTER_ISR_HANDLER_IN_IRAM=y # end of ESP-Driver:I2C Configurations # # ESP-Driver:I2S Configurations # # CONFIG_I2S_ISR_IRAM_SAFE is not set +# default: +# CONFIG_I2S_CTRL_FUNC_IN_IRAM is not set # CONFIG_I2S_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:I2S Configurations +# +# ESP-Driver:I3C Master Configurations +# +# default: +# CONFIG_I3C_MASTER_ISR_CACHE_SAFE is not set +# default: +# CONFIG_I3C_MASTER_ENABLE_DEBUG_LOG is not set +# default: +# CONFIG_I3C_MASTER_ISR_HANDLER_IN_IRAM is not set +# end of ESP-Driver:I3C Master Configurations + # # ESP-Driver:LEDC Configurations # @@ -746,8 +1187,12 @@ CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # # ESP-Driver:MCPWM Configurations # -# CONFIG_MCPWM_ISR_IRAM_SAFE is not set +# default: +CONFIG_MCPWM_ISR_HANDLER_IN_IRAM=y +# CONFIG_MCPWM_ISR_CACHE_SAFE is not set # CONFIG_MCPWM_CTRL_FUNC_IN_IRAM is not set +# default: +CONFIG_MCPWM_OBJ_CACHE_SAFE=y # CONFIG_MCPWM_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:MCPWM Configurations @@ -762,9 +1207,21 @@ CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # # ESP-Driver:RMT Configurations # -# CONFIG_RMT_ISR_IRAM_SAFE is not set +# default: +CONFIG_RMT_ENCODER_FUNC_IN_IRAM=y +# default: +CONFIG_RMT_TX_ISR_HANDLER_IN_IRAM=y +# default: +CONFIG_RMT_RX_ISR_HANDLER_IN_IRAM=y # CONFIG_RMT_RECV_FUNC_IN_IRAM is not set +# default: +# CONFIG_RMT_TX_ISR_CACHE_SAFE is not set +# default: +# CONFIG_RMT_RX_ISR_CACHE_SAFE is not set +# default: +CONFIG_RMT_OBJ_CACHE_SAFE=y # CONFIG_RMT_ENABLE_DEBUG_LOG is not set +# CONFIG_RMT_ISR_IRAM_SAFE is not set # end of ESP-Driver:RMT Configurations # @@ -774,10 +1231,16 @@ CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # CONFIG_SDM_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:Sigma Delta Modulator Configurations +# +# ESP-Driver:SD Host SDMMC Controller Configurations +# +# default: +# CONFIG_SD_HOST_SDMMC_ISR_CACHE_SAFE is not set +# end of ESP-Driver:SD Host SDMMC Controller Configurations + # # ESP-Driver:SPI Configurations # -# CONFIG_SPI_MASTER_IN_IRAM is not set CONFIG_SPI_MASTER_ISR_IN_IRAM=y # CONFIG_SPI_SLAVE_IN_IRAM is not set CONFIG_SPI_SLAVE_ISR_IN_IRAM=y @@ -789,6 +1252,8 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y # CONFIG_TOUCH_CTRL_FUNC_IN_IRAM is not set # CONFIG_TOUCH_ISR_IRAM_SAFE is not set # CONFIG_TOUCH_ENABLE_DEBUG_LOG is not set +# default: +# CONFIG_TOUCH_SKIP_FSM_CHECK is not set # end of ESP-Driver:Touch Sensor Configurations # @@ -797,12 +1262,35 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y # CONFIG_TEMP_SENSOR_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:Temperature Sensor Configurations +# +# ESP-Driver:TWAI Configurations +# +# CONFIG_TWAI_ISR_IN_IRAM is not set +# default: +# CONFIG_TWAI_IO_FUNC_IN_IRAM is not set +# default: +# CONFIG_TWAI_ISR_CACHE_SAFE is not set +# default: +# CONFIG_TWAI_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:TWAI Configurations + # # ESP-Driver:UART Configurations # # CONFIG_UART_ISR_IN_IRAM is not set # end of ESP-Driver:UART Configurations +# +# ESP-Driver:UHCI Configurations +# +# default: +# CONFIG_UHCI_ISR_HANDLER_IN_IRAM is not set +# default: +# CONFIG_UHCI_ISR_CACHE_SAFE is not set +# default: +# CONFIG_UHCI_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:UHCI Configurations + # # ESP-Driver:USB Serial/JTAG Configuration # @@ -812,11 +1300,9 @@ CONFIG_USJ_ENABLE_USB_SERIAL_JTAG=y # # Ethernet # +# default: CONFIG_ETH_ENABLED=y CONFIG_ETH_USE_SPI_ETHERNET=y -# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set -# CONFIG_ETH_SPI_ETHERNET_W5500 is not set -# CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set # CONFIG_ETH_USE_OPENETH is not set # CONFIG_ETH_TRANSMIT_MUTEX is not set # end of Ethernet @@ -832,12 +1318,22 @@ CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y # # GDB Stub # +# default: CONFIG_ESP_GDBSTUB_ENABLED=y # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set CONFIG_ESP_GDBSTUB_SUPPORT_TASKS=y CONFIG_ESP_GDBSTUB_MAX_TASKS=32 # end of GDB Stub +# +# ESP HID +# +# default: +CONFIG_ESPHID_TASK_SIZE_BT=2048 +# default: +CONFIG_ESPHID_TASK_SIZE_BLE=4096 +# end of ESP HID + # # ESP HTTP client # @@ -845,6 +1341,14 @@ CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y # CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set # CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH is not set # CONFIG_ESP_HTTP_CLIENT_ENABLE_CUSTOM_TRANSPORT is not set +# default: +# CONFIG_ESP_HTTP_CLIENT_ENABLE_GET_CONTENT_RANGE is not set +# default: +CONFIG_ESP_HTTP_CLIENT_EVENT_POST_TIMEOUT=2000 +# default: +# CONFIG_ESP_HTTP_CLIENT_SAVE_RESPONSE_HEADERS is not set +# default: +CONFIG_ESP_HTTP_CLIENT_STRICT_HEADER_BUFFER=y # end of ESP HTTP client # @@ -857,6 +1361,10 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32 # CONFIG_HTTPD_LOG_PURGE_DATA is not set # CONFIG_HTTPD_WS_SUPPORT is not set # CONFIG_HTTPD_QUEUE_WORK_BLOCKING is not set +# default: +CONFIG_HTTPD_ENABLE_EVENTS=y +# default: +CONFIG_HTTPD_SERVER_EVENT_POST_TIMEOUT=2000 # end of HTTP Server # @@ -864,17 +1372,25 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32 # # CONFIG_ESP_HTTPS_OTA_DECRYPT_CB is not set # CONFIG_ESP_HTTPS_OTA_ALLOW_HTTP is not set +# default: +CONFIG_ESP_HTTPS_OTA_EVENT_POST_TIMEOUT=2000 +# default: +# CONFIG_ESP_HTTPS_OTA_ENABLE_PARTIAL_DOWNLOAD is not set # end of ESP HTTPS OTA # # ESP HTTPS server # # CONFIG_ESP_HTTPS_SERVER_ENABLE is not set +# default: +# CONFIG_ESP_HTTPS_SERVER_CERT_SELECT_HOOK is not set # end of ESP HTTPS server # # Hardware Settings # +# default: +CONFIG_ESP_HW_SUPPORT_FUNC_IN_IRAM=y # # Chip revision @@ -882,27 +1398,46 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32 CONFIG_ESP32S3_REV_MIN_0=y # CONFIG_ESP32S3_REV_MIN_1 is not set # CONFIG_ESP32S3_REV_MIN_2 is not set +# default: CONFIG_ESP32S3_REV_MIN_FULL=0 +# default: CONFIG_ESP_REV_MIN_FULL=0 # # Maximum Supported ESP32-S3 Revision (Rev v0.99) # +# default: CONFIG_ESP32S3_REV_MAX_FULL=99 +# default: CONFIG_ESP_REV_MAX_FULL=99 +# default: +CONFIG_ESP_EFUSE_BLOCK_REV_MIN_FULL=0 +# default: +CONFIG_ESP_EFUSE_BLOCK_REV_MAX_FULL=199 + +# +# Maximum Supported ESP32-S3 eFuse Block Revision (eFuse Block Rev v1.99) +# # end of Chip revision # # MAC Config # +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y +# default: CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES_FOUR=y +# default: CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES=4 # CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_TWO is not set CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_FOUR=y +# default: CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES=4 # CONFIG_ESP_MAC_USE_CUSTOM_MAC_AS_BASE_MAC is not set # end of MAC Config @@ -913,6 +1448,7 @@ CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES=4 # CONFIG_ESP_SLEEP_POWER_DOWN_FLASH is not set CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND=y CONFIG_ESP_SLEEP_MSPI_NEED_ALL_IO_PU=y +# default: CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y CONFIG_ESP_SLEEP_WAIT_FLASH_READY_EXTRA_DELAY=2000 @@ -929,60 +1465,118 @@ CONFIG_RTC_CLK_SRC_INT_RC=y # CONFIG_RTC_CLK_SRC_EXT_OSC is not set # CONFIG_RTC_CLK_SRC_INT_8MD256 is not set CONFIG_RTC_CLK_CAL_CYCLES=1024 +# default: +CONFIG_RTC_CLK_FUNC_IN_IRAM=y +# default: +CONFIG_RTC_TIME_FUNC_IN_IRAM=y # end of RTC Clock Config # # Peripheral Control # -CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y +CONFIG_ESP_PERIPH_CTRL_FUNC_IN_IRAM=y +# default: +CONFIG_ESP_REGI2C_CTRL_FUNC_IN_IRAM=y # end of Peripheral Control -# -# GDMA Configurations -# -CONFIG_GDMA_CTRL_FUNC_IN_IRAM=y -# CONFIG_GDMA_ISR_IRAM_SAFE is not set -# CONFIG_GDMA_ENABLE_DEBUG_LOG is not set -# end of GDMA Configurations - # # Main XTAL Config # CONFIG_XTAL_FREQ_40=y +# default: CONFIG_XTAL_FREQ=40 # end of Main XTAL Config -CONFIG_ESP_SPI_BUS_LOCK_ISR_FUNCS_IN_IRAM=y -# end of Hardware Settings - # -# LCD and Touch Panel +# Power Supplier # # -# LCD Touch Drivers are maintained in the IDF Component Registry +# Brownout Detector # +CONFIG_ESP_BROWNOUT_DET=y +CONFIG_ESP_BROWNOUT_DET_LVL_SEL_7=y +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_1 is not set +# default: +CONFIG_ESP_BROWNOUT_DET_LVL=7 +# default: +CONFIG_ESP_BROWNOUT_USE_INTR=y +# end of Brownout Detector +# end of Power Supplier + +# default: +CONFIG_ESP_SPI_BUS_LOCK_ISR_FUNCS_IN_IRAM=y +# default: +CONFIG_ESP_INTR_IN_IRAM=y +# end of Hardware Settings # -# LCD Peripheral Configuration +# ESP-Driver:LCD Controller Configurations # -CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32 -# CONFIG_LCD_ENABLE_DEBUG_LOG is not set # CONFIG_LCD_RGB_ISR_IRAM_SAFE is not set # CONFIG_LCD_RGB_RESTART_IN_VSYNC is not set -# end of LCD Peripheral Configuration -# end of LCD and Touch Panel +# CONFIG_LCD_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:LCD Controller Configurations + +# +# LibC +# +# default: +# CONFIG_LIBC_NEWLIB is not set +# default: +CONFIG_LIBC_PICOLIBC=y +# default: +CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY=y +# default: +CONFIG_LIBC_MISC_IN_IRAM=y +# default: +CONFIG_LIBC_LOCKS_PLACE_IN_IRAM=y +CONFIG_LIBC_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_LIBC_STDOUT_LINE_ENDING_LF is not set +# CONFIG_LIBC_STDOUT_LINE_ENDING_CR is not set +# CONFIG_LIBC_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_LIBC_STDIN_LINE_ENDING_LF is not set +CONFIG_LIBC_STDIN_LINE_ENDING_CR=y +CONFIG_LIBC_TIME_SYSCALL_USE_RTC_HRT=y +# CONFIG_LIBC_TIME_SYSCALL_USE_RTC is not set +# CONFIG_LIBC_TIME_SYSCALL_USE_HRT is not set +# CONFIG_LIBC_TIME_SYSCALL_USE_NONE is not set +# default: +CONFIG_LIBC_ASSERT_BUFFER_SIZE=200 +# end of LibC + +# +# ESP-MM: Memory Management Configurations +# +# default: +# CONFIG_ESP_MM_CACHE_MSYNC_C2M_CHUNKED_OPS is not set +# end of ESP-MM: Memory Management Configurations # # ESP NETIF Adapter # +# default: +CONFIG_ESP_NETIF_LOST_IP_TIMER_ENABLE=y CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 +# default: +# CONFIG_ESP_NETIF_PROVIDE_CUSTOM_IMPLEMENTATION is not set CONFIG_ESP_NETIF_TCPIP_LWIP=y # CONFIG_ESP_NETIF_LOOPBACK is not set +# default: CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y -# CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS is not set +# default: +CONFIG_ESP_NETIF_REPORT_DATA_TRAFFIC=y +# default: +CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS=y # CONFIG_ESP_NETIF_L2_TAP is not set # CONFIG_ESP_NETIF_BRIDGE_EN is not set +# default: +# CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF is not set # end of ESP NETIF Adapter # @@ -993,10 +1587,12 @@ CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y # # PHY # +# default: CONFIG_ESP_PHY_ENABLED=y CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y # CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 +# default: CONFIG_ESP_PHY_MAX_TX_POWER=20 # CONFIG_ESP_PHY_REDUCE_TX_POWER is not set CONFIG_ESP_PHY_ENABLE_USB=y @@ -1004,16 +1600,33 @@ CONFIG_ESP_PHY_ENABLE_USB=y CONFIG_ESP_PHY_RF_CAL_PARTIAL=y # CONFIG_ESP_PHY_RF_CAL_NONE is not set # CONFIG_ESP_PHY_RF_CAL_FULL is not set +# default: CONFIG_ESP_PHY_CALIBRATION_MODE=0 +# default: +CONFIG_ESP_PHY_PLL_TRACK_PERIOD_MS=1000 # CONFIG_ESP_PHY_PLL_TRACK_DEBUG is not set +# default: +# CONFIG_ESP_PHY_RECORD_USED_TIME is not set +# default: +CONFIG_ESP_PHY_IRAM_OPT=y +# default: +# CONFIG_ESP_PHY_DEBUG is not set +# default: +CONFIG_ESP_PHY_ENABLE_VERSION_PRINT=y # end of PHY # # Power Management # +# default: +# CONFIG_PM_SLEEP_FUNC_IN_IRAM is not set # CONFIG_PM_ENABLE is not set +# default: +# CONFIG_PM_SLP_IRAM_OPT is not set CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y CONFIG_PM_RESTORE_CACHE_TAGMEM_AFTER_LIGHT_SLEEP=y +# default: +CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU=y # end of Power Management # @@ -1025,15 +1638,52 @@ CONFIG_PM_RESTORE_CACHE_TAGMEM_AFTER_LIGHT_SLEEP=y # # ESP Ringbuf # -# CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH is not set +# default: +# CONFIG_RINGBUF_IN_IRAM is not set +# default: +# CONFIG_RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH is not set # end of ESP Ringbuf +# +# ESP-ROM +# +# default: +CONFIG_ESP_ROM_PRINT_IN_IRAM=y +# end of ESP-ROM + +# +# ESP Security Specific +# +# end of ESP Security Specific + +# +# ESP-STDIO +# +CONFIG_ESP_CONSOLE_UART_DEFAULT=y +# CONFIG_ESP_CONSOLE_USB_CDC is not set +# CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set +# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_NONE is not set +# CONFIG_ESP_CONSOLE_SECONDARY_NONE is not set +CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y +# default: +CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y +# default: +CONFIG_ESP_CONSOLE_UART=y +# default: +CONFIG_ESP_CONSOLE_UART_NUM=0 +# default: +CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +# end of ESP-STDIO + # # ESP System Settings # # CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80 is not set CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160=y # CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240 is not set +# default: CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=160 # @@ -1041,23 +1691,29 @@ CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=160 # CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB=y # CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB is not set +# default: CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE=0x4000 # CONFIG_ESP32S3_INSTRUCTION_CACHE_4WAYS is not set CONFIG_ESP32S3_INSTRUCTION_CACHE_8WAYS=y +# default: CONFIG_ESP32S3_ICACHE_ASSOCIATED_WAYS=8 # CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_16B is not set CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_32B=y +# default: CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_SIZE=32 # CONFIG_ESP32S3_DATA_CACHE_16KB is not set CONFIG_ESP32S3_DATA_CACHE_32KB=y # CONFIG_ESP32S3_DATA_CACHE_64KB is not set +# default: CONFIG_ESP32S3_DATA_CACHE_SIZE=0x8000 # CONFIG_ESP32S3_DATA_CACHE_4WAYS is not set CONFIG_ESP32S3_DATA_CACHE_8WAYS=y +# default: CONFIG_ESP32S3_DCACHE_ASSOCIATED_WAYS=8 # CONFIG_ESP32S3_DATA_CACHE_LINE_16B is not set CONFIG_ESP32S3_DATA_CACHE_LINE_32B=y # CONFIG_ESP32S3_DATA_CACHE_LINE_64B is not set +# default: CONFIG_ESP32S3_DATA_CACHE_LINE_SIZE=32 # end of Cache config @@ -1072,44 +1728,33 @@ CONFIG_ESP32S3_DATA_CACHE_LINE_SIZE=32 # Trace memory # # CONFIG_ESP32S3_TRAX is not set +# default: CONFIG_ESP32S3_TRACEMEM_RESERVE_DRAM=0x0 # end of Trace memory +# default: +CONFIG_ESP_SYSTEM_IN_IRAM=y # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS=0 +# default: CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y - -# -# Memory protection -# -CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=y -CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK=y -# end of Memory protection - +CONFIG_ESP_SYSTEM_MEMPROT=y +# default: +CONFIG_ESP_SYSTEM_MEMPROT_PMS=y +CONFIG_ESP_SYSTEM_MEMPROT_PMS_LOCK=y CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y # CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1 is not set # CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set +# default: CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 -CONFIG_ESP_CONSOLE_UART_DEFAULT=y -# CONFIG_ESP_CONSOLE_USB_CDC is not set -# CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set -# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set -# CONFIG_ESP_CONSOLE_NONE is not set -# CONFIG_ESP_CONSOLE_SECONDARY_NONE is not set -CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y -CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y -CONFIG_ESP_CONSOLE_UART=y -CONFIG_ESP_CONSOLE_UART_NUM=0 -CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 -CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 CONFIG_ESP_INT_WDT=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 CONFIG_ESP_INT_WDT_CHECK_CPU1=y @@ -1123,61 +1768,74 @@ CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y # CONFIG_ESP_DEBUG_STUBS_ENABLE is not set CONFIG_ESP_DEBUG_OCDAWARE=y CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y - -# -# Brownout Detector -# -CONFIG_ESP_BROWNOUT_DET=y -CONFIG_ESP_BROWNOUT_DET_LVL_SEL_7=y -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_1 is not set -CONFIG_ESP_BROWNOUT_DET_LVL=7 -# end of Brownout Detector - -CONFIG_ESP_SYSTEM_BROWNOUT_INTR=y CONFIG_ESP_SYSTEM_BBPLL_RECALIB=y # end of ESP System Settings # # IPC (Inter-Processor Call) # +# default: +CONFIG_ESP_IPC_ENABLE=y CONFIG_ESP_IPC_TASK_STACK_SIZE=1280 CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y +# default: CONFIG_ESP_IPC_ISR_ENABLE=y # end of IPC (Inter-Processor Call) # # ESP Timer (High Resolution Timer) # +# default: +CONFIG_ESP_TIMER_IN_IRAM=y # CONFIG_ESP_TIMER_PROFILING is not set +# default: CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y +# default: CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 # CONFIG_ESP_TIMER_SHOW_EXPERIMENTAL is not set +# default: CONFIG_ESP_TIMER_TASK_AFFINITY=0x0 CONFIG_ESP_TIMER_TASK_AFFINITY_CPU0=y CONFIG_ESP_TIMER_ISR_AFFINITY_CPU0=y # CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set +# default: CONFIG_ESP_TIMER_IMPL_SYSTIMER=y # end of ESP Timer (High Resolution Timer) +# +# ESP Trace Configuration +# +# default: +# CONFIG_ESP_TRACE_LIB_EXTERNAL is not set +# default: +CONFIG_ESP_TRACE_LIB_NONE=y +# default: +CONFIG_ESP_TRACE_LIB_NAME="none" +# default: +# CONFIG_ESP_TRACE_TRANSPORT_APPTRACE is not set +# default: +CONFIG_ESP_TRACE_TRANSPORT_NONE=y +# default: +CONFIG_ESP_TRACE_TRANSPORT_NAME="none" +# end of ESP Trace Configuration + # # Wi-Fi # +# default: CONFIG_ESP_WIFI_ENABLED=y CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32 # CONFIG_ESP_WIFI_STATIC_TX_BUFFER is not set CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER=y +# default: CONFIG_ESP_WIFI_TX_BUFFER_TYPE=1 CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=32 CONFIG_ESP_WIFI_STATIC_RX_MGMT_BUFFER=y # CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER is not set +# default: CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0 CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF=5 # CONFIG_ESP_WIFI_CSI_ENABLED is not set @@ -1194,11 +1852,17 @@ CONFIG_ESP_WIFI_IRAM_OPT=y # CONFIG_ESP_WIFI_EXTRA_IRAM_OPT is not set CONFIG_ESP_WIFI_RX_IRAM_OPT=y CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y +# default: +CONFIG_ESP_WIFI_ENABLE_SAE_H2E=y CONFIG_ESP_WIFI_ENABLE_SAE_PK=y CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT=y CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y +# default: +CONFIG_ESP_WIFI_WPA3_COMPATIBLE_SUPPORT=y # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set CONFIG_ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME=50 +# default: +# CONFIG_ESP_WIFI_BSS_MAX_IDLE_SUPPORT is not set CONFIG_ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME=10 CONFIG_ESP_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME=15 # CONFIG_ESP_WIFI_FTM_ENABLE is not set @@ -1223,12 +1887,15 @@ CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y # # CONFIG_ESP_WIFI_WPS_STRICT is not set # CONFIG_ESP_WIFI_WPS_PASSPHRASE is not set +# default: +# CONFIG_ESP_WIFI_WPS_RECONNECT_ON_FAIL is not set # end of WPS Configuration Options # CONFIG_ESP_WIFI_DEBUG_PRINT is not set -# CONFIG_ESP_WIFI_TESTING_OPTIONS is not set CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=y # CONFIG_ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER is not set +# default: +# CONFIG_ESP_WIFI_PASSIVE_HIDDEN_AP_SUPPORT is not set # end of Wi-Fi # @@ -1270,15 +1937,33 @@ CONFIG_FATFS_CODEPAGE_437=y # CONFIG_FATFS_CODEPAGE_936 is not set # CONFIG_FATFS_CODEPAGE_949 is not set # CONFIG_FATFS_CODEPAGE_950 is not set +# default: CONFIG_FATFS_CODEPAGE=437 CONFIG_FATFS_FS_LOCK=0 CONFIG_FATFS_TIMEOUT_MS=10000 CONFIG_FATFS_PER_FILE_CACHE=y # CONFIG_FATFS_USE_FASTSEEK is not set +# default: +CONFIG_FATFS_USE_STRFUNC_NONE=y +# default: +# CONFIG_FATFS_USE_STRFUNC_WITHOUT_CRLF_CONV is not set +# default: +# CONFIG_FATFS_USE_STRFUNC_WITH_CRLF_CONV is not set CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0 # CONFIG_FATFS_IMMEDIATE_FSYNC is not set # CONFIG_FATFS_USE_LABEL is not set CONFIG_FATFS_LINK_LOCK=y +# default: +CONFIG_FATFS_USE_DYN_BUFFERS=y + +# +# File system free space calculation behavior +# +# default: +CONFIG_FATFS_DONT_TRUST_FREE_CLUSTER_CNT=0 +# default: +CONFIG_FATFS_DONT_TRUST_LAST_ALLOC=0 +# end of File system free space calculation behavior # end of FAT Filesystem support # @@ -1300,10 +1985,13 @@ CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 # CONFIG_FREERTOS_USE_TICK_HOOK is not set CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 # CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY is not set +# default: +CONFIG_FREERTOS_USE_TIMERS=y CONFIG_FREERTOS_TIMER_SERVICE_TASK_NAME="Tmr Svc" # CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU0 is not set # CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU1 is not set CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY=y +# default: CONFIG_FREERTOS_TIMER_SERVICE_TASK_CORE_AFFINITY=0x7FFFFFFF CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 @@ -1323,24 +2011,37 @@ CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y # CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS=y # CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK is not set -# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set +# default: CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y CONFIG_FREERTOS_ISR_STACKSIZE=1536 CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y +# default: +# CONFIG_FREERTOS_FPU_IN_ISR is not set +# default: CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER=y CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y # CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL3 is not set +# default: CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER=y -# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set +# default: +# CONFIG_FREERTOS_IN_IRAM is not set # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set # end of Port +# +# Extra +# +# end of Extra + +# default: CONFIG_FREERTOS_PORT=y +# default: CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +# default: CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y +# default: CONFIG_FREERTOS_DEBUG_OCDAWARE=y -CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y -CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y +# default: CONFIG_FREERTOS_NUMBER_OF_CORES=2 # end of FreeRTOS @@ -1351,10 +2052,11 @@ CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y # CONFIG_HAL_ASSERTION_DISABLE is not set # CONFIG_HAL_ASSERTION_SILENT is not set # CONFIG_HAL_ASSERTION_ENABLE is not set +# default: CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 CONFIG_HAL_WDT_USE_ROM_IMPL=y -CONFIG_HAL_SPI_MASTER_FUNC_IN_IRAM=y -CONFIG_HAL_SPI_SLAVE_FUNC_IN_IRAM=y +# default: +CONFIG_HAL_GPIO_USE_ROM_IMPL=y # end of Hardware Abstraction Layer (HAL) and Low Level (LL) # @@ -1373,7 +2075,17 @@ CONFIG_HEAP_TRACING_OFF=y # end of Heap memory debugging # -# Log output +# Log +# +# default: +CONFIG_LOG_VERSION_1=y +# default: +# CONFIG_LOG_VERSION_2 is not set +# default: +CONFIG_LOG_VERSION=1 + +# +# Log Level # # CONFIG_LOG_DEFAULT_LEVEL_NONE is not set # CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set @@ -1381,23 +2093,61 @@ CONFIG_HEAP_TRACING_OFF=y CONFIG_LOG_DEFAULT_LEVEL_INFO=y # CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set +# default: CONFIG_LOG_DEFAULT_LEVEL=3 CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y # CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set # CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set +# default: CONFIG_LOG_MAXIMUM_LEVEL=3 + +# +# Level Settings +# # CONFIG_LOG_MASTER_LEVEL is not set +# default: +CONFIG_LOG_DYNAMIC_LEVEL_CONTROL=y +# default: +# CONFIG_LOG_TAG_LEVEL_IMPL_NONE is not set +# default: +# CONFIG_LOG_TAG_LEVEL_IMPL_LINKED_LIST is not set +# default: +CONFIG_LOG_TAG_LEVEL_IMPL_CACHE_AND_LINKED_LIST=y +# default: +# CONFIG_LOG_TAG_LEVEL_CACHE_ARRAY is not set +# default: +CONFIG_LOG_TAG_LEVEL_CACHE_BINARY_MIN_HEAP=y +# default: +CONFIG_LOG_TAG_LEVEL_IMPL_CACHE_SIZE=31 +# end of Level Settings +# end of Log Level + +# +# Format +# CONFIG_LOG_COLORS=y CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y # CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set -# end of Log output +# end of Format + +# +# Settings +# +# default: +CONFIG_LOG_MODE_TEXT_EN=y +# default: +CONFIG_LOG_MODE_TEXT=y +# end of Settings + +# default: +CONFIG_LOG_IN_IRAM=y +# end of Log # # LWIP # CONFIG_LWIP_ENABLE=y CONFIG_LWIP_LOCAL_HOSTNAME="espressif" -# CONFIG_LWIP_NETIF_API is not set CONFIG_LWIP_TCPIP_TASK_PRIO=18 # CONFIG_LWIP_TCPIP_CORE_LOCKING is not set # CONFIG_LWIP_CHECK_THREAD_SAFETY is not set @@ -1421,6 +2171,8 @@ CONFIG_LWIP_IP6_FRAG=y # CONFIG_LWIP_IP4_REASSEMBLY is not set # CONFIG_LWIP_IP6_REASSEMBLY is not set CONFIG_LWIP_IP_REASS_MAX_PBUFS=10 +# default: +CONFIG_LWIP_IPV6_DUP_DETECT_ATTEMPTS=1 # CONFIG_LWIP_IP_FORWARD is not set # CONFIG_LWIP_STATS is not set CONFIG_LWIP_ESP_GRATUITOUS_ARP=y @@ -1429,10 +2181,12 @@ CONFIG_LWIP_ESP_MLDV6_REPORT=y CONFIG_LWIP_MLDV6_TMR_INTERVAL=40 CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +# CONFIG_LWIP_DHCP_DOES_ACD_CHECK is not set +# CONFIG_LWIP_DHCP_DOES_NOT_CHECK_OFFERED_IP is not set # CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y # CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set -CONFIG_LWIP_DHCP_OPTIONS_LEN=68 +CONFIG_LWIP_DHCP_OPTIONS_LEN=69 CONFIG_LWIP_NUM_NETIF_CLIENT_DATA=0 CONFIG_LWIP_DHCP_COARSE_TIMER_SECS=1 @@ -1440,8 +2194,12 @@ CONFIG_LWIP_DHCP_COARSE_TIMER_SECS=1 # DHCP server # CONFIG_LWIP_DHCPS=y +# default: +CONFIG_LWIP_DHCPS_REPORT_CLIENT_HOSTNAME=y CONFIG_LWIP_DHCPS_LEASE_UNIT=60 CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 +# default: +CONFIG_LWIP_DHCPS_MAX_HOSTNAME_LEN=64 CONFIG_LWIP_DHCPS_STATIC_ENTRIES=y # end of DHCP server @@ -1452,6 +2210,8 @@ CONFIG_LWIP_IPV6=y CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 # CONFIG_LWIP_IPV6_FORWARD is not set # CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set +# default: +# CONFIG_LWIP_NETIF_LINK_CALLBACK is not set CONFIG_LWIP_NETIF_LOOPBACK=y CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 @@ -1500,10 +2260,19 @@ CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y # CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set # CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set +# default: CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF -# CONFIG_LWIP_PPP_SUPPORT is not set CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 +# default: +CONFIG_LWIP_IPV6_ND6_NUM_PREFIXES=5 +# default: +CONFIG_LWIP_IPV6_ND6_NUM_ROUTERS=3 +# default: +CONFIG_LWIP_IPV6_ND6_NUM_DESTINATIONS=10 +# default: +# CONFIG_LWIP_IPV6_ND6_ROUTE_INFO_OPTION_SUPPORT is not set +# CONFIG_LWIP_PPP_SUPPORT is not set # CONFIG_LWIP_SLIP_SUPPORT is not set # @@ -1533,8 +2302,14 @@ CONFIG_LWIP_SNTP_MAXIMUM_STARTUP_DELAY=5000 # # DNS # +# default: +CONFIG_LWIP_DNS_MAX_HOST_IP=1 CONFIG_LWIP_DNS_MAX_SERVERS=3 # CONFIG_LWIP_FALLBACK_DNS_SERVER_SUPPORT is not set +# default: +# CONFIG_LWIP_DNS_SETSERVER_WITH_NETIF is not set +# default: +# CONFIG_LWIP_USE_ESP_GETADDRINFO is not set # end of DNS CONFIG_LWIP_BRIDGEIF_MAX_PORTS=7 @@ -1555,9 +2330,19 @@ CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_NONE=y # CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_DEFAULT is not set # CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_CUSTOM is not set +# default: +CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_NONE=y +# default: +# CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_DEFAULT is not set +# default: +# CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_CUSTOM is not set CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y # CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set # CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set +# default: +CONFIG_LWIP_HOOK_DNS_EXT_RESOLVE_NONE=y +# default: +# CONFIG_LWIP_HOOK_DNS_EXT_RESOLVE_CUSTOM is not set CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y # CONFIG_LWIP_HOOK_IP6_INPUT_DEFAULT is not set # CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM is not set @@ -1569,6 +2354,29 @@ CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y # # mbedTLS # + +# +# Core Configuration +# +# default: +CONFIG_MBEDTLS_VER_4_X_SUPPORT=y +# default: +# CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_NONE is not set +# default: +CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_SIZE=y +# default: +# CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_PERF is not set +# default: +CONFIG_MBEDTLS_FS_IO=y +# default: +# CONFIG_MBEDTLS_PSA_ITS_CUSTOM_STORAGE_BACKEND is not set +# CONFIG_MBEDTLS_THREADING_C is not set +CONFIG_MBEDTLS_ERROR_STRINGS=y +# default: +CONFIG_MBEDTLS_VERSION_C=y +CONFIG_MBEDTLS_HAVE_TIME=y +# CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set +# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y # CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set # CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set @@ -1576,159 +2384,257 @@ CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 # CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set +# default: +# CONFIG_MBEDTLS_VERSION_FEATURES is not set # CONFIG_MBEDTLS_DEBUG is not set +# default: +CONFIG_MBEDTLS_SELF_TEST=y +# end of Core Configuration # -# mbedTLS v3.x related +# Certificates # -# CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 is not set -# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set -# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set -# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set -CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y -CONFIG_MBEDTLS_PKCS7_C=y -# end of mbedTLS v3.x related +# default: +CONFIG_MBEDTLS_X509_USE_C=y +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +# default: +CONFIG_MBEDTLS_PK_C=y +# default: +CONFIG_MBEDTLS_PK_PARSE_C=y +# default: +CONFIG_MBEDTLS_PK_WRITE_C=y +# default: +# CONFIG_MBEDTLS_X509_REMOVE_INFO is not set +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +# default: +CONFIG_MBEDTLS_X509_CRT_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +# default: +# CONFIG_MBEDTLS_X509_CREATE_C is not set +# default: +CONFIG_MBEDTLS_X509_RSASSA_PSS_SUPPORT=y +CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK=y +# default: +CONFIG_MBEDTLS_ASN1_PARSE_C=y +# default: +CONFIG_MBEDTLS_ASN1_WRITE_C=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y # -# Certificate Bundle +# Certificate Bundle Configuration # -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL is not set # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="ca/cacert.pem" CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 -# end of Certificate Bundle +# end of Certificate Bundle Configuration -# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set -CONFIG_MBEDTLS_CMAC_C=y -CONFIG_MBEDTLS_HARDWARE_AES=y -CONFIG_MBEDTLS_AES_USE_INTERRUPT=y -CONFIG_MBEDTLS_AES_INTERRUPT_LEVEL=0 -CONFIG_MBEDTLS_GCM_SUPPORT_NON_AES_CIPHER=y -CONFIG_MBEDTLS_HARDWARE_MPI=y -# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set -CONFIG_MBEDTLS_MPI_USE_INTERRUPT=y -CONFIG_MBEDTLS_MPI_INTERRUPT_LEVEL=0 -CONFIG_MBEDTLS_HARDWARE_SHA=y -CONFIG_MBEDTLS_ROM_MD5=y -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set -CONFIG_MBEDTLS_HAVE_TIME=y -# CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set -# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set -CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y -CONFIG_MBEDTLS_SHA512_C=y +# default: +# CONFIG_MBEDTLS_ALLOW_WEAK_CERTIFICATE_VERIFICATION is not set +# default: +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y +# end of Certificates + +CONFIG_MBEDTLS_TLS_ENABLED=y + +# +# TLS Protocol Configuration +# +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 is not set +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set +# default: +CONFIG_MBEDTLS_TLS_SERVER=y +# default: +CONFIG_MBEDTLS_TLS_CLIENT=y CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y # CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set # CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set -# CONFIG_MBEDTLS_TLS_DISABLED is not set -CONFIG_MBEDTLS_TLS_SERVER=y -CONFIG_MBEDTLS_TLS_CLIENT=y -CONFIG_MBEDTLS_TLS_ENABLED=y +CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y +# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set +# default: +CONFIG_MBEDTLS_SSL_CACHE_C=y +# default: +CONFIG_MBEDTLS_SSL_ALL_ALERT_MESSAGES=y # -# TLS Key Exchange Methods +# TLS Key Exchange Configuration # # CONFIG_MBEDTLS_PSK_MODES is not set CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y -# end of TLS Key Exchange Methods +# end of TLS Key Exchange Configuration -CONFIG_MBEDTLS_SSL_RENEGOTIATION=y -CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y -# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set -# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +# default: +CONFIG_MBEDTLS_SSL_SERVER_NAME_INDICATION=y CONFIG_MBEDTLS_SSL_ALPN=y +# default: +CONFIG_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH=y +# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y +# default: +# CONFIG_MBEDTLS_SSL_KEYING_MATERIAL_EXPORT is not set +# end of TLS Protocol Configuration + +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set # # Symmetric Ciphers # CONFIG_MBEDTLS_AES_C=y # CONFIG_MBEDTLS_CAMELLIA_C is not set +# default: +# CONFIG_MBEDTLS_ARIA_C is not set # CONFIG_MBEDTLS_DES_C is not set -# CONFIG_MBEDTLS_BLOWFISH_C is not set -# CONFIG_MBEDTLS_XTEA_C is not set CONFIG_MBEDTLS_CCM_C=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_CBC=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_CFB=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_CTR=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_OFB=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_XTS=y CONFIG_MBEDTLS_GCM_C=y # CONFIG_MBEDTLS_NIST_KW_C is not set +# default: +CONFIG_MBEDTLS_AES_ROM_TABLES=y +# default: +# CONFIG_MBEDTLS_AES_FEWER_TABLES is not set +# default: +# CONFIG_MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH is not set +CONFIG_MBEDTLS_CMAC_C=y # end of Symmetric Ciphers -# CONFIG_MBEDTLS_RIPEMD160_C is not set - # -# Certificates +# Asymmetric Ciphers # -CONFIG_MBEDTLS_PEM_PARSE_C=y -CONFIG_MBEDTLS_PEM_WRITE_C=y -CONFIG_MBEDTLS_X509_CRL_PARSE_C=y -CONFIG_MBEDTLS_X509_CSR_PARSE_C=y -# end of Certificates - +# default: +CONFIG_MBEDTLS_RSA_C=y CONFIG_MBEDTLS_ECP_C=y -# CONFIG_MBEDTLS_DHM_C is not set -CONFIG_MBEDTLS_ECDH_C=y -CONFIG_MBEDTLS_ECDSA_C=y -# CONFIG_MBEDTLS_ECJPAKE_C is not set -CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y + +# +# Supported Curves +# CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +# end of Supported Curves + +# +# Elliptic Curve Ciphers Configuration +# CONFIG_MBEDTLS_ECP_NIST_OPTIM=y CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y -# CONFIG_MBEDTLS_POLY1305_C is not set -# CONFIG_MBEDTLS_CHACHA20_C is not set -# CONFIG_MBEDTLS_HKDF_C is not set -# CONFIG_MBEDTLS_THREADING_C is not set -CONFIG_MBEDTLS_ERROR_STRINGS=y -# end of mbedTLS +# CONFIG_MBEDTLS_DHM_C is not set +CONFIG_MBEDTLS_ECDH_C=y +# CONFIG_MBEDTLS_ECJPAKE_C is not set +CONFIG_MBEDTLS_ECDSA_C=y +# default: +CONFIG_MBEDTLS_PK_PARSE_EC_EXTENDED=y +# default: +CONFIG_MBEDTLS_PK_PARSE_EC_COMPRESSED=y +CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y +# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set +# end of Elliptic Curve Ciphers Configuration +# end of Asymmetric Ciphers # -# ESP-MQTT Configurations +# Hash functions # -CONFIG_MQTT_PROTOCOL_311=y -# CONFIG_MQTT_PROTOCOL_5 is not set -CONFIG_MQTT_TRANSPORT_SSL=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y -# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set -# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set -# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set -# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set -# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set -# CONFIG_MQTT_CUSTOM_OUTBOX is not set -# end of ESP-MQTT Configurations +# CONFIG_MBEDTLS_RIPEMD160_C is not set +# default: +CONFIG_MBEDTLS_MD_C=y +# default: +CONFIG_MBEDTLS_MD5_C=y +# default: +CONFIG_MBEDTLS_SHA1_C=y +# default: +# CONFIG_MBEDTLS_SHA224_C is not set +# default: +CONFIG_MBEDTLS_SHA256_C=y +# default: +CONFIG_MBEDTLS_SHA384_C=y +CONFIG_MBEDTLS_SHA512_C=y +# default: +# CONFIG_MBEDTLS_SHA3_C is not set +CONFIG_MBEDTLS_ROM_MD5=y +# end of Hash functions # -# Newlib +# Hardware Acceleration # -CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set -CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y -# CONFIG_NEWLIB_NANO_FORMAT is not set -CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y -# CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC is not set -# CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT is not set -# CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE is not set -# end of Newlib +CONFIG_MBEDTLS_HARDWARE_SHA=y +CONFIG_MBEDTLS_HARDWARE_MPI=y +# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set +CONFIG_MBEDTLS_MPI_USE_INTERRUPT=y +CONFIG_MBEDTLS_MPI_INTERRUPT_LEVEL=0 + +# +# Security hardening +# +# default: +# CONFIG_MBEDTLS_CONSTANT_TIME_PRIME_GEN is not set +# end of Security hardening + +CONFIG_MBEDTLS_HARDWARE_AES=y +# default: +# CONFIG_MBEDTLS_AES_SOFT_FALLBACK is not set +CONFIG_MBEDTLS_GCM_SUPPORT_NON_AES_CIPHER=y +CONFIG_MBEDTLS_AES_USE_INTERRUPT=y +CONFIG_MBEDTLS_AES_INTERRUPT_LEVEL=0 +# default: +CONFIG_MBEDTLS_AES_HW_SMALL_DATA_LEN_OPTIM=y +# CONFIG_MBEDTLS_SECURE_ELEMENT_DRIVER_ENABLED is not set +# default: +CONFIG_MBEDTLS_HARDWARE_RSA_DS_PERIPHERAL=y +# end of Hardware Acceleration + +# +# Entropy and Random Number Generation +# +# default: +# CONFIG_MBEDTLS_ENTROPY_FORCE_SHA256 is not set +# default: +CONFIG_MBEDTLS_CTR_DRBG_C=y +# default: +CONFIG_MBEDTLS_HMAC_DRBG_C=y +# end of Entropy and Random Number Generation + +# +# Encoding/Decoding +# +# default: +CONFIG_MBEDTLS_BASE64_C=y +# default: +CONFIG_MBEDTLS_PKCS5_C=y +CONFIG_MBEDTLS_PKCS7_C=y +# default: +CONFIG_MBEDTLS_PKCS1_V15=y +# default: +CONFIG_MBEDTLS_PKCS1_V21=y +# end of Encoding/Decoding + +# +# Stream Cipher +# +# CONFIG_MBEDTLS_CHACHA20_C is not set +# end of Stream Cipher +# end of mbedTLS # # NVS @@ -1736,6 +2642,10 @@ CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y # CONFIG_NVS_ENCRYPTION is not set # CONFIG_NVS_ASSERT_ERROR_CHECK is not set # CONFIG_NVS_LEGACY_DUP_KEYS_COMPATIBILITY is not set +# default: +# CONFIG_NVS_BDL_STACK is not set +# default: +# CONFIG_NVS_FLASH_VERIFY_ERASE is not set # end of NVS # @@ -1744,25 +2654,13 @@ CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y # CONFIG_OPENTHREAD_ENABLED is not set # -# Thread Operational Dataset +# OpenThread Spinel # -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread-ESP" -CONFIG_OPENTHREAD_MESH_LOCAL_PREFIX="fd00:db8:a0:0::/64" -CONFIG_OPENTHREAD_NETWORK_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_PANID=0x1234 -CONFIG_OPENTHREAD_NETWORK_EXTPANID="dead00beef00cafe" -CONFIG_OPENTHREAD_NETWORK_MASTERKEY="00112233445566778899aabbccddeeff" -CONFIG_OPENTHREAD_NETWORK_PSKC="104810e2315100afd6bc9215a6bfac53" -# end of Thread Operational Dataset - -CONFIG_OPENTHREAD_XTAL_ACCURACY=130 # CONFIG_OPENTHREAD_SPINEL_ONLY is not set -CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE=y +# end of OpenThread Spinel -# -# Thread Address Query Config -# -# end of Thread Address Query Config +# default: +# CONFIG_OPENTHREAD_DEBUG is not set # end of OpenThread # @@ -1771,6 +2669,8 @@ CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=y +# default: +CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_PATCH_VERSION=y # end of Protocomm # @@ -1782,15 +2682,26 @@ CONFIG_PTHREAD_STACK_MIN=768 CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y # CONFIG_PTHREAD_DEFAULT_CORE_0 is not set # CONFIG_PTHREAD_DEFAULT_CORE_1 is not set +# default: CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # end of PThreads +# +# SD Protocol Layer Configuration +# +# default: +CONFIG_SD_ENABLE_SDIO_SUPPORT=y +# end of SD Protocol Layer Configuration + # # MMU Config # +# default: CONFIG_MMU_PAGE_SIZE_64KB=y +# default: CONFIG_MMU_PAGE_MODE="64KB" +# default: CONFIG_MMU_PAGE_SIZE=0x10000 # end of MMU Config @@ -1802,6 +2713,7 @@ CONFIG_MMU_PAGE_SIZE=0x10000 # SPI Flash behavior when brownout # CONFIG_SPI_FLASH_BROWNOUT_RESET_XMC=y +# default: CONFIG_SPI_FLASH_BROWNOUT_RESET=y # end of SPI Flash behavior when brownout @@ -1815,12 +2727,18 @@ CONFIG_SPI_FLASH_BROWNOUT_RESET=y # CONFIG_SPI_FLASH_HPM_ENA is not set CONFIG_SPI_FLASH_HPM_AUTO=y # CONFIG_SPI_FLASH_HPM_DIS is not set +# default: CONFIG_SPI_FLASH_HPM_ON=y CONFIG_SPI_FLASH_HPM_DC_AUTO=y # CONFIG_SPI_FLASH_HPM_DC_DISABLE is not set -CONFIG_SPI_FLASH_SUSPEND_QVL_SUPPORTED=y # CONFIG_SPI_FLASH_AUTO_SUSPEND is not set CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50 +# default: +# CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND is not set +# default: +# CONFIG_SPI_FLASH_FORCE_ENABLE_C6_H2_SUSPEND is not set +# default: +CONFIG_SPI_FLASH_PLACE_FUNCTIONS_IN_IRAM=y # end of Optional and Experimental Features (READ DOCS FIRST) # end of Main Flash configuration @@ -1829,7 +2747,6 @@ CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50 # # CONFIG_SPI_FLASH_VERIFY_WRITE is not set # CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set -CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y # CONFIG_SPI_FLASH_ROM_IMPL is not set CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y # CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set @@ -1846,13 +2763,20 @@ CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 # # Auto-detect flash chips # -CONFIG_SPI_FLASH_VENDOR_XMC_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_GD_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_ISSI_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_MXIC_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_WINBOND_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_BOYA_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_TH_SUPPORTED=y +# default: +CONFIG_SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED=y CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y @@ -1937,27 +2861,6 @@ CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y # CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set # end of Unity unit testing library -# -# USB-OTG -# -CONFIG_USB_HOST_CONTROL_TRANSFER_MAX_SIZE=256 -CONFIG_USB_HOST_HW_BUFFER_BIAS_BALANCED=y -# CONFIG_USB_HOST_HW_BUFFER_BIAS_IN is not set -# CONFIG_USB_HOST_HW_BUFFER_BIAS_PERIODIC_OUT is not set - -# -# Root Hub configuration -# -CONFIG_USB_HOST_DEBOUNCE_DELAY_MS=250 -CONFIG_USB_HOST_RESET_HOLD_MS=30 -CONFIG_USB_HOST_RESET_RECOVERY_MS=30 -CONFIG_USB_HOST_SET_ADDR_RECOVERY_MS=10 -# end of Root Hub configuration - -# CONFIG_USB_HOST_ENABLE_ENUM_FILTER_CALLBACK is not set -CONFIG_USB_OTG_SUPPORTED=y -# end of USB-OTG - # # Virtual file system # @@ -1968,12 +2871,17 @@ CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y # CONFIG_VFS_SELECT_IN_RAM is not set CONFIG_VFS_SUPPORT_TERMIOS=y CONFIG_VFS_MAX_COUNT=8 +# default: +# CONFIG_VFS_SUPPRESS_CTX_DEPRECATION is not set # # Host File System I/O (Semihosting) # CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 # end of Host File System I/O (Semihosting) + +# default: +CONFIG_VFS_INITIALIZE_DEV_NULL=y # end of Virtual file system # @@ -1981,18 +2889,9 @@ CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 # # CONFIG_WL_SECTOR_SIZE_512 is not set CONFIG_WL_SECTOR_SIZE_4096=y +# default: CONFIG_WL_SECTOR_SIZE=4096 # end of Wear Levelling - -# -# Wi-Fi Provisioning Manager -# -CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 -CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 -# CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION is not set -CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y -# CONFIG_WIFI_PROV_STA_FAST_SCAN is not set -# end of Wi-Fi Provisioning Manager # end of Component config # CONFIG_IDF_EXPERIMENTAL_FEATURES is not set @@ -2000,6 +2899,8 @@ CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y # Deprecated options for backward compatibility # CONFIG_APP_BUILD_TYPE_ELF_RAM is not set # CONFIG_NO_BLOBS is not set +# CONFIG_APP_ROLLBACK_ENABLE is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set # CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set # CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set # CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set @@ -2007,7 +2908,6 @@ CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y # CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set # CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set CONFIG_LOG_BOOTLOADER_LEVEL=3 -# CONFIG_APP_ROLLBACK_ENABLE is not set # CONFIG_FLASH_ENCRYPTION_ENABLED is not set # CONFIG_FLASHMODE_QIO is not set # CONFIG_FLASHMODE_QOUT is not set @@ -2029,12 +2929,11 @@ CONFIG_STACK_CHECK_NONE=y # CONFIG_STACK_CHECK_STRONG is not set # CONFIG_STACK_CHECK_ALL is not set # CONFIG_WARN_WRITE_STRINGS is not set -# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set -CONFIG_ESP32_APPTRACE_DEST_NONE=y -CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y # CONFIG_EXTERNAL_COEX_ENABLE is not set # CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE is not set -# CONFIG_MCPWM_ISR_IN_IRAM is not set +# CONFIG_CAM_CTLR_DVP_CAM_ISR_IRAM_SAFE is not set +# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set +# CONFIG_MCPWM_ISR_IRAM_SAFE is not set # CONFIG_EVENT_LOOP_PROFILING is not set CONFIG_POST_EVENTS_FROM_ISR=y CONFIG_POST_EVENTS_FROM_IRAM_ISR=y @@ -2049,6 +2948,42 @@ CONFIG_ESP32S3_RTC_CLK_SRC_INT_RC=y # CONFIG_ESP32S3_RTC_CLK_SRC_EXT_OSC is not set # CONFIG_ESP32S3_RTC_CLK_SRC_INT_8MD256 is not set CONFIG_ESP32S3_RTC_CLK_CAL_CYCLES=1024 +CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y +CONFIG_BROWNOUT_DET=y +CONFIG_ESP32S3_BROWNOUT_DET=y +CONFIG_BROWNOUT_DET_LVL_SEL_7=y +CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_7=y +# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_1 is not set +CONFIG_BROWNOUT_DET_LVL=7 +CONFIG_ESP32S3_BROWNOUT_DET_LVL=7 +CONFIG_ESP_SYSTEM_BROWNOUT_INTR=y +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set +CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y +CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y +CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_SYSTIMER=y +CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_FRC1=y +# CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC is not set +# CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT is not set +# CONFIG_ESP32S3_TIME_SYSCALL_USE_SYSTIMER is not set +# CONFIG_ESP32S3_TIME_SYSCALL_USE_FRC1 is not set +# CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE is not set +# CONFIG_ESP32S3_TIME_SYSCALL_USE_NONE is not set CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y # CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 @@ -2058,13 +2993,6 @@ CONFIG_ESP32_PHY_MAX_TX_POWER=20 CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU=y CONFIG_PM_POWER_DOWN_TAGMEM_IN_LIGHT_SLEEP=y # CONFIG_ESP32S3_SPIRAM_SUPPORT is not set -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_80 is not set -CONFIG_ESP32S3_DEFAULT_CPU_FREQ_160=y -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240 is not set -CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=160 -CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 -CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 -CONFIG_MAIN_TASK_STACK_SIZE=3584 CONFIG_CONSOLE_UART_DEFAULT=y # CONFIG_CONSOLE_UART_CUSTOM is not set # CONFIG_CONSOLE_UART_NONE is not set @@ -2072,6 +3000,17 @@ CONFIG_CONSOLE_UART_DEFAULT=y CONFIG_CONSOLE_UART=y CONFIG_CONSOLE_UART_NUM=0 CONFIG_CONSOLE_UART_BAUDRATE=115200 +# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_80 is not set +CONFIG_ESP32S3_DEFAULT_CPU_FREQ_160=y +# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240 is not set +CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=160 +CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT=y +CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_VIA_TEE=y +CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=y +CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK=y +CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_MAIN_TASK_STACK_SIZE=3584 CONFIG_INT_WDT=y CONFIG_INT_WDT_TIMEOUT_MS=300 CONFIG_INT_WDT_CHECK_CPU1=y @@ -2083,27 +3022,9 @@ CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y # CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set CONFIG_ESP32S3_DEBUG_OCDAWARE=y -CONFIG_BROWNOUT_DET=y -CONFIG_ESP32S3_BROWNOUT_DET=y -CONFIG_ESP32S3_BROWNOUT_DET=y -CONFIG_BROWNOUT_DET_LVL_SEL_7=y -CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_7=y -# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_1 is not set -# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_1 is not set -CONFIG_BROWNOUT_DET_LVL=7 -CONFIG_ESP32S3_BROWNOUT_DET_LVL=7 CONFIG_IPC_TASK_STACK_SIZE=1280 CONFIG_TIMER_TASK_STACK_SIZE=3584 +# CONFIG_ESP32_APPTRACE_ENABLE is not set CONFIG_ESP32_WIFI_ENABLED=y CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 @@ -2115,8 +3036,6 @@ CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y CONFIG_ESP32_WIFI_TX_BA_WIN=6 CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y -CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y -CONFIG_ESP32_WIFI_RX_BA_WIN=6 CONFIG_ESP32_WIFI_RX_BA_WIN=6 CONFIG_ESP32_WIFI_NVS_ENABLED=y CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y @@ -2138,7 +3057,6 @@ CONFIG_WPA_MBEDTLS_TLS_CLIENT=y # CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set # CONFIG_WPA_WPS_STRICT is not set # CONFIG_WPA_DEBUG_PRINT is not set -# CONFIG_WPA_TESTING_OPTIONS is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y @@ -2169,12 +3087,8 @@ CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y # CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF # CONFIG_PPP_SUPPORT is not set -CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_SYSTIMER=y -CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_FRC1=y -# CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC is not set -# CONFIG_ESP32S3_TIME_SYSCALL_USE_SYSTIMER is not set -# CONFIG_ESP32S3_TIME_SYSCALL_USE_FRC1 is not set -# CONFIG_ESP32S3_TIME_SYSCALL_USE_NONE is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 CONFIG_ESP32_PTHREAD_STACK_MIN=768 diff --git a/target/pc/linux/recoverymanifest/Makefile b/target/pc/linux/recoverymanifest/Makefile index aad0925ec..e17d49a18 100644 --- a/target/pc/linux/recoverymanifest/Makefile +++ b/target/pc/linux/recoverymanifest/Makefile @@ -1,7 +1,9 @@ # # Host build of the recovery manifest reader of the control module. The -# signature check is built against the mbedtls that ESP-IDF ships, compiled -# here for the host, so the test needs IDF_PATH but no ESP32 toolchain. +# signature check is built against the TF-PSA-Crypto that ESP-IDF 6 ships +# (mbedTLS 4), compiled here for the host, so the test needs IDF_PATH but no +# ESP32 toolchain. The control module is built against that same library, so +# this must run with an ESP-IDF 6 checkout, not the 5.3.1 of my_docker_image. # # make build # make test build and run @@ -12,15 +14,15 @@ OUTPUT = output PATH_SW = ../../../../software IDF_PATH ?= $(HOME)/esp/esp-idf -MBEDTLS = $(IDF_PATH)/components/mbedtls/mbedtls -LIBMBED = $(OUTPUT)/mbedtls/library/libmbedcrypto.a +TFPSA = $(IDF_PATH)/components/mbedtls/mbedtls/tf-psa-crypto +LIBMBED = $(OUTPUT)/tfpsa/core/libtfpsacrypto.a VPATH = $(PATH_SW)/u64ctrl/main $(PATH_SW)/test/recovery_manifest CC = gcc COPTIONS = -std=c99 -g -O0 -Wall -Wextra -Wno-unused-parameter \ -DVECTORS_DIR=\"$(abspath $(PATH_SW)/test/recovery_manifest/vectors)\" \ - $(addprefix -I, $(VPATH)) -I$(MBEDTLS)/include + $(addprefix -I, $(VPATH)) -I$(TFPSA)/include -I$(TFPSA)/drivers/builtin/include SRCS_C = recovery_manifest.c recovery_verify.c recovery_manifest_test.c OBJS = $(addprefix $(OUTPUT)/, $(SRCS_C:%.c=%.o)) @@ -30,10 +32,15 @@ OBJS = $(addprefix $(OUTPUT)/, $(SRCS_C:%.c=%.o)) all: $(RESULT)/$(PRJ) $(LIBMBED): - @test -f $(MBEDTLS)/CMakeLists.txt || { echo "mbedtls not found; set IDF_PATH to an ESP-IDF checkout"; exit 2; } - @cmake -S $(MBEDTLS) -B $(OUTPUT)/mbedtls -DENABLE_TESTING=OFF -DENABLE_PROGRAMS=OFF \ - -DCMAKE_BUILD_TYPE=Release >/dev/null - @cmake --build $(OUTPUT)/mbedtls --target mbedcrypto -j8 >/dev/null + @test -f $(TFPSA)/CMakeLists.txt || { echo "TF-PSA-Crypto not found; set IDF_PATH to an ESP-IDF 6 checkout"; exit 2; } + @# This ESP-IDF's bignum.c and ecp.c include mbedtls/bignum.h and mbedtls/ecp.h, + @# which only ESP-IDF's own port provides; the shims stand in for it. The + @# pre-generated sources stand in for GEN_FILES, which needs python's jsonschema. + @mkdir -p $(OUTPUT)/shim/mbedtls + @for h in bignum ecp; do echo "#include \"mbedtls/private/$$h.h\"" > $(OUTPUT)/shim/mbedtls/$$h.h; done + @cmake -S $(TFPSA) -B $(OUTPUT)/tfpsa -DENABLE_TESTING=OFF -DENABLE_PROGRAMS=OFF -DGEN_FILES=OFF \ + -DCMAKE_C_FLAGS=-I$(abspath $(OUTPUT))/shim -DCMAKE_BUILD_TYPE=Release >/dev/null + @cmake --build $(OUTPUT)/tfpsa --target tfpsacrypto -j8 >/dev/null $(OUTPUT)/%.o: %.c $(LIBMBED) @mkdir -p $(OUTPUT) @@ -41,7 +48,7 @@ $(OUTPUT)/%.o: %.c $(LIBMBED) $(RESULT)/$(PRJ): $(OBJS) $(LIBMBED) @mkdir -p $(RESULT) - $(CC) -o $@ $(OBJS) $(LIBMBED) + $(CC) -o $@ $(OBJS) $(LIBMBED) -Wl,--wrap=psa_crypto_init -Wl,--wrap=psa_hash_update -Wl,--wrap=psa_hash_finish test: all @$(RESULT)/$(PRJ) From 68cc7f091b1b8e3700b80243b673dd336b9b5835 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Wed, 21 Oct 2026 11:41:09 -0500 Subject: [PATCH 02/95] Lock the mbedTLS key store in the control module (MBEDTLS_THREADING_C) On mbedTLS 4, PSA's key slots are protected by a mutex only with MBEDTLS_THREADING_C. It is ESP-IDF 6's default; the regenerated sdkconfig had carried 5.3.1's "not set". The WiFi supplicant (ESP_WIFI_MBEDTLS_CRYPTO, on in this project) imports and destroys PSA keys now, and it runs next to anything else that uses PSA. The pthread implementation comes with it. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/sdkconfig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/software/u64ctrl/sdkconfig b/software/u64ctrl/sdkconfig index 334a465a7..40125aa76 100644 --- a/software/u64ctrl/sdkconfig +++ b/software/u64ctrl/sdkconfig @@ -2370,7 +2370,11 @@ CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_SIZE=y CONFIG_MBEDTLS_FS_IO=y # default: # CONFIG_MBEDTLS_PSA_ITS_CUSTOM_STORAGE_BACKEND is not set -# CONFIG_MBEDTLS_THREADING_C is not set +CONFIG_MBEDTLS_THREADING_C=y +# default: +# CONFIG_MBEDTLS_THREADING_ALT is not set +# default: +CONFIG_MBEDTLS_THREADING_PTHREAD=y CONFIG_MBEDTLS_ERROR_STRINGS=y # default: CONFIG_MBEDTLS_VERSION_C=y From f5340365d718414a7326abe603d4fddb63156849 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Wed, 21 Oct 2026 11:41:09 -0500 Subject: [PATCH 03/95] Keep dropping WiFi packets quietly when the control module has no UART buffer When no UART buffer is free, the receive hook returned ERR_BUF and wlanif_input() freed the packet. On ESP-IDF 5.3.1 the WiFi driver was then told ESP_OK; on ESP-IDF 6 esp_netif_receive() passes the error on, so the driver would see ESP_FAIL on this path. Stock ESP-IDF 6 already returns ESP_FAIL whenever lwIP's input mailbox is full, so the driver handles it; free the packet here and return ERR_OK only to leave this path exactly as before. The packet is dropped either way. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/main/wifi_modem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/software/u64ctrl/main/wifi_modem.c b/software/u64ctrl/main/wifi_modem.c index 6b1020a98..2247fe9dc 100644 --- a/software/u64ctrl/main/wifi_modem.c +++ b/software/u64ctrl/main/wifi_modem.c @@ -120,7 +120,8 @@ static err_t hacked_recv(struct pbuf *p, struct netif *inp) return ERR_OK; } else { ESP_LOGW(TAG, "No buffer to send packet."); - return ERR_BUF; + pbuf_free(p); // dropped, and reported as handled + return ERR_OK; } } else { // dropped, wrong mac and no broadcast pbuf_free(p); From 36eaa6f834d42a7ffea765cd74450aa8e3511603 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Wed, 21 Oct 2026 11:41:17 -0500 Subject: [PATCH 04/95] Keep the pull-ups on the control module's UART RX and CTS pins UART1 is routed to the FPGA pins in two places: at boot, in setup_modem(), and whenever the machine is switched on, in regulator_enable(). Before either, the pins hold their reset state or, after check_fpga() or a power off, a pull-down (check_fpga() sets it on RXD only; the power-off path sets it on all four). ESP-IDF 5.3.1's uart_set_pin() put a pull-up on RXD and CTS before connecting them, replacing it. ESP-IDF 6's uart_set_pin() never touches pulls, so RXD would stay pulled down and CTS at its reset state while the FPGA configures, reading as a break and as clear to send where 5.3.1 read idle and not clear. One helper, my_uart_connect_pins(), sets the pull-ups and then routes the pins, in that order as 5.3.1 did, and both places call it. While the machine is off RX and CTS stay routed, pulled down; a boot that stays off has the pull-ups on for about 100 ms until regulator_enable(0), the same as on 5.3.1. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/main/button_handler.c | 3 ++- software/u64ctrl/main/my_uart.c | 13 +++++++++++++ software/u64ctrl/main/my_uart.h | 2 ++ software/u64ctrl/main/wifi_modem.c | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/software/u64ctrl/main/button_handler.c b/software/u64ctrl/main/button_handler.c index 6d60fbb41..78254709f 100644 --- a/software/u64ctrl/main/button_handler.c +++ b/software/u64ctrl/main/button_handler.c @@ -7,6 +7,7 @@ #include "esp_err.h" #include "pinout.h" #include "button_handler.h" +#include "my_uart.h" #include "rpc_dispatch.h" #include "jtag.h" #include "wifi_modem.h" @@ -58,7 +59,7 @@ static void regulator_enable(int enable, int delay) vTaskDelay(100 / portTICK_PERIOD_MS); if (enable) { - ESP_ERROR_CHECK( uart_set_pin(UART_NUM_1, IO_UART_TXD, IO_UART_RXD, IO_UART_RTS, IO_UART_CTS)); + my_uart_connect_pins(); } } diff --git a/software/u64ctrl/main/my_uart.c b/software/u64ctrl/main/my_uart.c index 6d48029f1..7f423bb0e 100644 --- a/software/u64ctrl/main/my_uart.c +++ b/software/u64ctrl/main/my_uart.c @@ -35,6 +35,7 @@ #include "rpc_dispatch.h" #include "dump_hex.h" #include "my_uart.h" +#include "pinout.h" #if CONFIG_IDF_TARGET_ESP32 #include "esp32/clk.h" @@ -378,6 +379,18 @@ esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void *), void *arg, return ret; } +void my_uart_connect_pins(void) +{ + // ESP-IDF 5.3.1's uart_set_pin() put a pull-up on RX and CTS before connecting them, replacing + // the pull-downs left by check_fpga() and the power-off path; ESP-IDF 6 never touches pulls, so + // do it here, ahead of the routing, as 5.3.1 did. While the machine is off RX and CTS stay routed + // to UART1 and pulled down; a boot that stays off has the pull-ups on for about 100 ms, until + // regulator_enable(0), the same as on 5.3.1. + ESP_ERROR_CHECK( gpio_set_pull_mode(IO_UART_RXD, GPIO_PULLUP_ONLY) ); + ESP_ERROR_CHECK( gpio_set_pull_mode(IO_UART_CTS, GPIO_PULLUP_ONLY) ); + ESP_ERROR_CHECK( uart_set_pin(UART_NUM_1, IO_UART_TXD, IO_UART_RXD, IO_UART_RTS, IO_UART_CTS) ); +} + esp_err_t my_uart_init(command_buf_context_t *buffers, uint8_t uart_num) { UART_CHECK((uart_num < UART_NUM_MAX), "uart_num error", ESP_FAIL); diff --git a/software/u64ctrl/main/my_uart.h b/software/u64ctrl/main/my_uart.h index 69b2da0e1..cc69f1fa9 100644 --- a/software/u64ctrl/main/my_uart.h +++ b/software/u64ctrl/main/my_uart.h @@ -17,6 +17,8 @@ #define UART_DEBUG_RX 0 #define UART_DEBUG_IRQ 0 +// Routes UART1 to the FPGA pins. Call it for every connection, so the RX and CTS idle levels are the same everywhere. +void my_uart_connect_pins(void); esp_err_t my_uart_init(command_buf_context_t *buffers, uint8_t uart_num); BaseType_t my_uart_get_buffer(uint8_t uart_num, command_buf_t **buf, TickType_t ticks); BaseType_t my_uart_transmit_packet(uint8_t uart_num, command_buf_t *buf); diff --git a/software/u64ctrl/main/wifi_modem.c b/software/u64ctrl/main/wifi_modem.c index 2247fe9dc..994ee0a01 100644 --- a/software/u64ctrl/main/wifi_modem.c +++ b/software/u64ctrl/main/wifi_modem.c @@ -1079,7 +1079,7 @@ void setup_modem() ESP_LOGI(TAG, "dispatch... switching UART pins!"); vTaskDelay(100 / portTICK_PERIOD_MS); ESP_ERROR_CHECK( uart_set_pin(UART_NUM_0, 0, -1, -1, -1)); - ESP_ERROR_CHECK( uart_set_pin(UART_NUM_1, IO_UART_TXD, IO_UART_RXD, IO_UART_RTS, IO_UART_CTS)); + my_uart_connect_pins(); start_dispatch(work_buffers.receivedQueue); } From df14b6eda9ca7da1ad6e5b1f4d5358bb92de44e3 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Wed, 21 Oct 2026 11:41:18 -0500 Subject: [PATCH 05/95] Stop UART1 flow control in the brownout interrupt ESP-IDF 6's brownout interrupt waits for every enabled UART's transmitter to drain before it resets the chip; 5.3.1 reset at once. UART1 honours CTS, and CTS idles high through its pull-up when the FPGA loses power with the machine, so bytes left in the transmit FIFO would never leave and the wait would last until the 300 ms interrupt watchdog, ending in a panic reset instead of a brownout reset. Register a brownout callback, which runs in IRAM ahead of that wait, that turns CTS flow control off so the FIFO drains. A failed registration is logged and does not stop the boot. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/main/my_uart.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/software/u64ctrl/main/my_uart.c b/software/u64ctrl/main/my_uart.c index 7f423bb0e..05008f3f3 100644 --- a/software/u64ctrl/main/my_uart.c +++ b/software/u64ctrl/main/my_uart.c @@ -36,6 +36,8 @@ #include "dump_hex.h" #include "my_uart.h" #include "pinout.h" +#include "esp_brownout.h" +#include "hal/uart_ll.h" #if CONFIG_IDF_TARGET_ESP32 #include "esp32/clk.h" @@ -391,6 +393,15 @@ void my_uart_connect_pins(void) ESP_ERROR_CHECK( uart_set_pin(UART_NUM_1, IO_UART_TXD, IO_UART_RXD, IO_UART_RTS, IO_UART_CTS) ); } +// ESP-IDF 6's brownout interrupt waits for every enabled UART's transmitter to drain before it resets +// (5.3.1 reset at once). With CTS held high by its pull-up, because the FPGA lost power with the +// machine, bytes in the UART1 FIFO would never leave and the wait would last until the interrupt +// watchdog. Runs in the brownout ISR, ahead of that wait: stop honouring CTS so the FIFO drains. +static IRAM_ATTR void uart1_brownout_callback(void) +{ + uart_ll_set_hw_flow_ctrl(UART_LL_GET_HW(UART_NUM_1), UART_HW_FLOWCTRL_DISABLE, 0); +} + esp_err_t my_uart_init(command_buf_context_t *buffers, uint8_t uart_num) { UART_CHECK((uart_num < UART_NUM_MAX), "uart_num error", ESP_FAIL); @@ -421,6 +432,12 @@ esp_err_t my_uart_init(command_buf_context_t *buffers, uint8_t uart_num) .rx_flow_ctrl_thresh = 122, }; + // Not worth stopping the boot over: without it a brownout resets after the interrupt watchdog. + esp_err_t bo = esp_brownout_register_callback(uart1_brownout_callback); + if (bo != ESP_OK) { + ESP_LOGW(UART_TAG, "brownout callback not registered: %s", esp_err_to_name(bo)); + } + // Configure UART parameters esp_err_t ret = uart_param_config(uart_num, &uart_config); if (ret == ESP_OK) { From e097583820fd7c9d3fb2012182fc1ea0ece8b399 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 22 Oct 2026 21:03:40 -0500 Subject: [PATCH 06/95] Test the keys the control module ships with The host test only used keys of its own. Load every key in recovery_trusted_keys as an EC public key, require a spare next to the main key, require that no two shipped keys are the same, and check that a manifest is verified by a key placed behind all of them. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../recovery_manifest_test.c | 49 +++++++++++++++++++ target/pc/linux/recoverymanifest/Makefile | 4 +- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/software/test/recovery_manifest/recovery_manifest_test.c b/software/test/recovery_manifest/recovery_manifest_test.c index 07edb54e5..ea847248a 100644 --- a/software/test/recovery_manifest/recovery_manifest_test.c +++ b/software/test/recovery_manifest/recovery_manifest_test.c @@ -16,6 +16,7 @@ #include #include #include +#include "mbedtls/pk.h" #include "psa/crypto.h" #include "recovery_manifest.h" #include "recovery_verify.h" @@ -24,6 +25,9 @@ #define VECTORS_DIR "vectors" #endif +/* recovery_trust.c, the keys the board ships with. */ +extern const char *const recovery_trusted_keys[]; + static int failures; static int checks; @@ -457,6 +461,50 @@ static void test_serial_patterns(void) free(text); } +/* The keys the board ships with, main and spare: each must load as an EC public + key, no two may be the same (a spare pasted as a copy of the main key rotates + nothing), and a manifest must be verified by a key behind all of them. */ +static void test_shipped_keys(void) +{ + int n = 0; + while (recovery_trusted_keys[n]) { + mbedtls_pk_context pk; + mbedtls_pk_init(&pk); + check(psa_crypto_init() == PSA_SUCCESS, "the crypto library starts"); + check(mbedtls_pk_parse_public_key(&pk, (const unsigned char *)recovery_trusted_keys[n], + strlen(recovery_trusted_keys[n]) + 1) == 0 && + PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(mbedtls_pk_get_key_type(&pk)), + "a shipped key loads as an EC public key"); + mbedtls_pk_free(&pk); + n++; + } + check(n >= 2, "a spare key ships next to the main key"); + int distinct = 1; + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + distinct &= strcmp(recovery_trusted_keys[i], recovery_trusted_keys[j]) != 0; + } + } + check(distinct, "the shipped keys are all different"); + + size_t len; + char *text = read_file("valid.manifest", &len); + char *test_key = read_file("test_key.pub.pem", NULL); + const char *list[16]; + int count = 0; + for (int i = 0; i < n && i < 15; i++) { + list[count++] = recovery_trusted_keys[i]; + } + recovery_manifest_t m; + check_result(load(text, len, list, count, &m), RECOVERY_ERR_BAD_SIGNATURE, + "a manifest signed by a test key is refused by the shipped keys"); + list[count++] = test_key; + check_result(load(text, len, list, count, &m), RECOVERY_OK, + "a manifest is verified by a key behind every shipped key"); + free(text); + free(test_key); +} + int main(void) { test_signed_vectors(); @@ -465,6 +513,7 @@ int main(void) test_parse(); test_board(); test_serial_patterns(); + test_shipped_keys(); // last: it starts the crypto library, which the tests above leave to the code under test printf("\n%d checks, %d failed\n", checks, failures); return failures ? 1 : 0; diff --git a/target/pc/linux/recoverymanifest/Makefile b/target/pc/linux/recoverymanifest/Makefile index e17d49a18..ee64a7fbb 100644 --- a/target/pc/linux/recoverymanifest/Makefile +++ b/target/pc/linux/recoverymanifest/Makefile @@ -22,9 +22,9 @@ VPATH = $(PATH_SW)/u64ctrl/main $(PATH_SW)/test/recovery_manifest CC = gcc COPTIONS = -std=c99 -g -O0 -Wall -Wextra -Wno-unused-parameter \ -DVECTORS_DIR=\"$(abspath $(PATH_SW)/test/recovery_manifest/vectors)\" \ - $(addprefix -I, $(VPATH)) -I$(TFPSA)/include -I$(TFPSA)/drivers/builtin/include + $(addprefix -I, $(VPATH)) -I$(PATH_SW)/test/stubs/esp -I$(TFPSA)/include -I$(TFPSA)/drivers/builtin/include -SRCS_C = recovery_manifest.c recovery_verify.c recovery_manifest_test.c +SRCS_C = recovery_manifest.c recovery_verify.c recovery_trust.c recovery_manifest_test.c OBJS = $(addprefix $(OUTPUT)/, $(SRCS_C:%.c=%.o)) .PHONY: all test clean From 7034f352b105658e68f0f0783a77571de6bb505e Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Sat, 24 Oct 2026 23:22:13 -0500 Subject: [PATCH 07/95] Keep FreeRTOS and the ring buffer in IRAM in the U64 control module ESP-IDF 6 moved the FreeRTOS queue/task and ring buffer functions to flash by default (CONFIG_FREERTOS_IN_IRAM and CONFIG_RINGBUF_IN_IRAM are off); ESP-IDF 5.3.1 had them in IRAM. Every frame passes xQueueGenericSend, xQueueReceive and xRingbufferReceive in both directions, so each call can wait on a flash cache miss. Set both options to put them back in IRAM (12,140 B more shared IRAM/DRAM, 157,151 B of 341,760 stay free; flash code drops by 13,024 B). The effect was measured on the U64E's classic ESP32 module only (raw_u64: writemem p50/p90/p99 back in the IDF 5.3.1 range, the REST probe and FTP get not fully). On this module it is not measured yet; the C64U bench run is pending. The change is the same two sdkconfig lines. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/sdkconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/software/u64ctrl/sdkconfig b/software/u64ctrl/sdkconfig index 40125aa76..01b9bc086 100644 --- a/software/u64ctrl/sdkconfig +++ b/software/u64ctrl/sdkconfig @@ -1241,6 +1241,8 @@ CONFIG_RMT_OBJ_CACHE_SAFE=y # # ESP-Driver:SPI Configurations # +# default: +# CONFIG_SPI_MASTER_IN_IRAM is not set CONFIG_SPI_MASTER_ISR_IN_IRAM=y # CONFIG_SPI_SLAVE_IN_IRAM is not set CONFIG_SPI_SLAVE_ISR_IN_IRAM=y @@ -1639,9 +1641,7 @@ CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU=y # ESP Ringbuf # # default: -# CONFIG_RINGBUF_IN_IRAM is not set -# default: -# CONFIG_RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH is not set +CONFIG_RINGBUF_IN_IRAM=y # end of ESP Ringbuf # @@ -2024,7 +2024,7 @@ CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y # default: CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER=y # default: -# CONFIG_FREERTOS_IN_IRAM is not set +CONFIG_FREERTOS_IN_IRAM=y # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set # end of Port From 494a6e53bcf8b2983f5468f05433bfc948184d12 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 19:54:37 -0500 Subject: [PATCH 08/95] Run the U64 control module's UART ISR and dispatch on core 1, out of flash The WiFi task runs on core 0. esp_intr_alloc() binds an interrupt to the core it is called on, so my_uart_init() now runs from a short task pinned to core 1, which keeps the UART ISR off the core the WiFi driver is using. The ISR, the UART buffer code, hacked_recv(), dispatch() and cmd_send_eth_packet() move to IRAM with a linker fragment (noflash). The ISR flags stay 0, so the interrupt is masked while the flash cache is off (NVS writes) and nothing in the handler has to be safe to run then; the overflow branch calls the flash function uart_hal_rxfifo_rst(), but RXFIFO_OVF is not in the enable mask, so it does not run. The dispatch task is pinned to core 1 at priority 19 so it runs where the ISR feeds it. Also check the init semaphore and the task create. The whole of my_uart.c is noflash, so my_uart_connect_pins() and the brownout callback now sit in IRAM too (the callback already was IRAM_ATTR), and the callback is registered from the core 1 task. Neither depends on the core: the brownout interrupt is a separate system interrupt, and the pin routing is called as before from task context. This is harmless. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/main/CMakeLists.txt | 3 ++- software/u64ctrl/main/linker.lf | 8 ++++++++ software/u64ctrl/main/rpc_dispatch.c | 3 ++- software/u64ctrl/main/wifi_modem.c | 18 +++++++++++++++++- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 software/u64ctrl/main/linker.lf diff --git a/software/u64ctrl/main/CMakeLists.txt b/software/u64ctrl/main/CMakeLists.txt index 63e55f4f8..26e7c9a13 100755 --- a/software/u64ctrl/main/CMakeLists.txt +++ b/software/u64ctrl/main/CMakeLists.txt @@ -1,3 +1,4 @@ set(EXTERNAL "../../io/uart") idf_component_register(SRCS "button_handler.c" "control_main.c" "my_uart.c" "dump_hex.c" "rpc_dispatch.c" "wifi_modem.c" "button_handler.c" "jtag.c" "sntp.c" "power_state.c" "wol_magic.c" "recovery_manifest.c" "recovery_verify.c" "recovery_image.c" "recovery_url.c" "recovery.c" "recovery_trust.c" ${EXTERNAL}/cmd_buffer.c - INCLUDE_DIRS "." ${EXTERNAL}) + INCLUDE_DIRS "." ${EXTERNAL} + LDFRAGMENTS "linker.lf") diff --git a/software/u64ctrl/main/linker.lf b/software/u64ctrl/main/linker.lf new file mode 100644 index 000000000..02ef254b8 --- /dev/null +++ b/software/u64ctrl/main/linker.lf @@ -0,0 +1,8 @@ +[mapping:u64ctrl_hot] +archive: libmain.a +entries: + my_uart (noflash) + cmd_buffer (noflash) + wifi_modem:hacked_recv (noflash) + rpc_dispatch:dispatch (noflash) + rpc_dispatch:cmd_send_eth_packet (noflash) diff --git a/software/u64ctrl/main/rpc_dispatch.c b/software/u64ctrl/main/rpc_dispatch.c index db3771ce2..6a717f227 100644 --- a/software/u64ctrl/main/rpc_dispatch.c +++ b/software/u64ctrl/main/rpc_dispatch.c @@ -548,7 +548,8 @@ void dispatch(void *ct) void start_dispatch(QueueHandle_t queue) { - xTaskCreate( dispatch, "Dispatch Task", DISPATCHER_STACK, queue, tskIDLE_PRIORITY + 1, NULL ); + // Core 1, above the system tasks: the UART ISR that feeds this queue runs on core 1 too + xTaskCreatePinnedToCore( dispatch, "Dispatch Task", DISPATCHER_STACK, queue, 19, NULL, 1 ); } #if MULTITHREADED diff --git a/software/u64ctrl/main/wifi_modem.c b/software/u64ctrl/main/wifi_modem.c index 994ee0a01..16b33cf0a 100644 --- a/software/u64ctrl/main/wifi_modem.c +++ b/software/u64ctrl/main/wifi_modem.c @@ -1045,6 +1045,18 @@ static void start_connector() xTaskCreate(connect_thread, "Connector", 4096, NULL, tskIDLE_PRIORITY + 1, NULL); } +static SemaphoreHandle_t uart_init_done; +static esp_err_t uart_init_result; + +// esp_intr_alloc() binds the interrupt to the core it is called on. The UART ISR must not share +// core 0 with the WiFi task, so the init runs on core 1. +static void uart_init_task(void *a) +{ + uart_init_result = my_uart_init(&work_buffers, UART_NUM_1); + xSemaphoreGive(uart_init_done); + vTaskDelete(NULL); +} + void setup_modem() { // Initialize NVS @@ -1069,7 +1081,11 @@ void setup_modem() #endif ESP_LOGI(TAG, "my_uart_init..."); // Now install the driver for UART1. We use our own buffer mechanism and interrupt routine - ESP_ERROR_CHECK(my_uart_init(&work_buffers, UART_NUM_1)); + uart_init_done = xSemaphoreCreateBinary(); + ESP_ERROR_CHECK(uart_init_done ? ESP_OK : ESP_ERR_NO_MEM); + ESP_ERROR_CHECK(xTaskCreatePinnedToCore(uart_init_task, "uart_init", 3072, NULL, tskIDLE_PRIORITY + 2, NULL, 1) == pdPASS ? ESP_OK : ESP_ERR_NO_MEM); + xSemaphoreTake(uart_init_done, portMAX_DELAY); + ESP_ERROR_CHECK(uart_init_result); ESP_LOGI(TAG, "wifi_init..."); wifi_init(); From b5150618e1d681bd83b79c8fef30d9212b43b22d Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:00:33 -0500 Subject: [PATCH 09/95] Lower the U64 control module UART FIFO thresholds The RX full threshold drops from 120 to 64 and the TX empty threshold from 10 to 64 (the hardware flow control threshold of 122 is unchanged). At 5 Mbaud the interrupt latency budget before RTS asserts goes from 2 bytes (4 us) to 58 bytes (116 us), and the TX FIFO has 128 us instead of 20 us to be refilled. The margin after RTS asserts stays 6 bytes. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/main/my_uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/software/u64ctrl/main/my_uart.c b/software/u64ctrl/main/my_uart.c index 05008f3f3..1a7f98d60 100644 --- a/software/u64ctrl/main/my_uart.c +++ b/software/u64ctrl/main/my_uart.c @@ -419,8 +419,8 @@ esp_err_t my_uart_init(command_buf_context_t *buffers, uint8_t uart_num) const uart_intr_config_t interrupt_config = { .intr_enable_mask = UART_INTR_RXFIFO_TOUT | UART_INTR_RXFIFO_FULL, .rx_timeout_thresh = 2, - .txfifo_empty_intr_thresh = 10, - .rxfifo_full_thresh = 120, + .txfifo_empty_intr_thresh = 64, + .rxfifo_full_thresh = 64, }; const uart_config_t uart_config = { From 1bf10d3670be32dc2d70625f9d3dac373e96d902 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:00:33 -0500 Subject: [PATCH 10/95] Keep more of the WiFi driver in IRAM in the U64 control module (ESP_WIFI_EXTRA_IRAM_OPT) The option is off by default for the ESP32-S3 and places more of the WiFi driver send and receive code in IRAM. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/sdkconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/u64ctrl/sdkconfig b/software/u64ctrl/sdkconfig index 01b9bc086..f89a3a326 100644 --- a/software/u64ctrl/sdkconfig +++ b/software/u64ctrl/sdkconfig @@ -1849,7 +1849,7 @@ CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0=y CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN=752 CONFIG_ESP_WIFI_MGMT_SBUF_NUM=32 CONFIG_ESP_WIFI_IRAM_OPT=y -# CONFIG_ESP_WIFI_EXTRA_IRAM_OPT is not set +CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y CONFIG_ESP_WIFI_RX_IRAM_OPT=y CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y # default: From 5b96672cdb78090c87afd38511f59e1ba35bd16e Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:00:34 -0500 Subject: [PATCH 11/95] Run the netif, pbuf and heap path of the U64 control module from IRAM Place esp_netif_transmit/receive/free_rx_buffer, wlanif_input, esp_pbuf_allocate/free, wifi_transmit/free, esp_wifi_internal_free_rx_buffer, pbuf_free, pbuf_alloced_custom, pbuf_init_alloced_pbuf, mem_malloc, mem_free, sys_arch_protect/unprotect and sys_mutex_lock/unlock in IRAM (noflash), so the per-packet path between the WiFi driver and the UART bridge no longer calls flash-resident code. What is left in flash is off that path: the one-time sys_mutex_new, the esp_event_post calls guarded by the runtime tx_rx_events_enabled flag, and the command handlers that dispatch() calls for non-packet commands. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/main/linker.lf | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/software/u64ctrl/main/linker.lf b/software/u64ctrl/main/linker.lf index 02ef254b8..22e104b6f 100644 --- a/software/u64ctrl/main/linker.lf +++ b/software/u64ctrl/main/linker.lf @@ -6,3 +6,37 @@ entries: wifi_modem:hacked_recv (noflash) rpc_dispatch:dispatch (noflash) rpc_dispatch:cmd_send_eth_packet (noflash) + +[mapping:u64ctrl_netif] +archive: libesp_netif.a +entries: + esp_netif_lwip:esp_netif_transmit (noflash) + esp_netif_lwip:esp_netif_receive (noflash) + esp_netif_lwip:esp_netif_free_rx_buffer (noflash) + wlanif:wlanif_input (noflash) + esp_pbuf_ref:esp_pbuf_allocate (noflash) + esp_pbuf_ref:esp_pbuf_free (noflash) + +[mapping:u64ctrl_wifi_netif] +archive: libesp_wifi.a +entries: + wifi_netif:wifi_transmit (noflash) + wifi_netif:wifi_free (noflash) + +[mapping:u64ctrl_pp] +archive: libpp.a +entries: + if_hwctrl:esp_wifi_internal_free_rx_buffer (noflash) + +[mapping:u64ctrl_lwip] +archive: liblwip.a +entries: + pbuf:pbuf_free (noflash) + pbuf:pbuf_alloced_custom (noflash) + pbuf:pbuf_init_alloced_pbuf (noflash) + mem:mem_malloc (noflash) + mem:mem_free (noflash) + sys_arch:sys_arch_protect (noflash) + sys_arch:sys_arch_unprotect (noflash) + sys_arch:sys_mutex_lock (noflash) + sys_arch:sys_mutex_unlock (noflash) From fe96e6bd676ba64ec73949b750d911b73ba01765 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 2 Oct 2026 11:25:02 -0500 Subject: [PATCH 12/95] Build the U64 WiFi bridge (raw_u64) with ESP-IDF 6.0.3 raw_u64 moves to ESP-IDF 6.0.3 (mbedTLS 4) and reports V1.7, so the updater installs it. raw_c3 stays on ESP-IDF 5.3.1 in my_docker_image, unchanged. - my_uart.c: uart_periph.h moved from soc/ to hal/, and uart_isr_handle_t (a typedef of intr_handle_t) is gone. - CMakeLists.txt: CMake 3.16, since the CMake 4 that ESP-IDF 6 ships warns that 3.5 is deprecated; configure stops on an ESP-IDF older than 6. - sdkconfig: regenerated by idf.py reconfigure from the 5.3.1 file. Values present in both versions are carried unless ESP-IDF 6 forces them. Options that are new in ESP-IDF 6 take its defaults, and some of those change behaviour: picolibc replaces newlib, FreeRTOS and ring-buffer functions other than the ISR ones run from flash instead of IRAM, WPA3-compatible mode is compiled in (SAE H2E stays compiled in, as in 5.3.1), and esp_netif_receive() now always returns errors to the WiFi driver. The toolchain goes from GCC 13.2 to 15.2. A second reconfigure and a build leave sdkconfig unchanged. - rpc_dispatch.h: V1.7, the next minor after master's 1.6. The open GET_RANDOM change (#953) also wants a minor; whichever of the two lands second adapts its number and history line. - CI builds raw_u64 next to u64ctrl in the espressif/idf:v6.0.3 image, pinned by digest, and raw_c3 in my_docker_image as before. - README.txt, raw_u64/README.md and u64ctrl/README.md say which ESP-IDF each module needs and how to build it. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/build.yml | 6 +- README.txt | 14 +- software/u64ctrl/README.md | 6 +- software/wifi/raw_u64/CMakeLists.txt | 5 +- software/wifi/raw_u64/README.md | 23 +- software/wifi/raw_u64/main/my_uart.c | 4 +- software/wifi/raw_u64/main/rpc_dispatch.h | 5 +- software/wifi/raw_u64/sdkconfig | 1474 ++++++++++++++++----- 8 files changed, 1159 insertions(+), 378 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d5d3cce3..84f7d05f1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository runs-on: self-hosted env: - # u64ctrl needs ESP-IDF 6, so it builds here; raw_u64 and raw_c3 stay on my_docker_image's 5.3.1 + # u64ctrl and raw_u64 need ESP-IDF 6, so they build here; raw_c3 stays on my_docker_image's 5.3.1 IDF6_IMAGE: espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 steps: - name: Checkout repository @@ -248,9 +248,11 @@ jobs: run: | docker run --rm --net=custom_network --mac-address=4c:cc:6a:06:b3:79 \ -v /opt/build-tools:/mnt/build-tools:ro \ - -v $GITHUB_WORKSPACE:/mnt/project:rw my_docker_image /bin/bash -c "cd /mnt/project && make esp32_raw_u64 esp32_raw_c3" + -v $GITHUB_WORKSPACE:/mnt/project:rw my_docker_image /bin/bash -c "cd /mnt/project && make esp32_raw_c3" docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp \ -v $GITHUB_WORKSPACE:/mnt/project:rw --workdir /mnt/project/software/u64ctrl $IDF6_IMAGE idf.py build + docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp \ + -v $GITHUB_WORKSPACE:/mnt/project:rw --workdir /mnt/project/software/wifi/raw_u64 $IDF6_IMAGE idf.py build - if: steps.cache-u2.outputs.cache-hit != 'true' name: Build U2 including FPGAs diff --git a/README.txt b/README.txt index 320ce855c..1156133ba 100644 --- a/README.txt +++ b/README.txt @@ -22,7 +22,7 @@ U2+L: U64: - Altera Quartus (tested with 18.1 Lite Edition) - for the Nios-II compiler only. -- Espressif IDF 5.x +- Espressif IDF 6.x U64E-II: - RiscV GNU C/C++ Compiler (for RV32I), same as for U2/RiscV. @@ -40,7 +40,7 @@ In this file, you need to set the location of your Xilinx ISE toolchain. Building targets ================ -ALL targets can be built by just typing 'make' in the root of the repository (see the U64E-II note below). +ALL targets can be built by just typing 'make' in the root of the repository (see the ESP32 module notes below). In order to build for U2 only, use the 'u2_rv' target in the top level makefile. This will build the FPGAs as well as the RiscV based software, including all updaters. @@ -53,12 +53,12 @@ target 'niosapps'. This target will only succeed if you have already successfull For the U2+L, you can build the 'u2pl' target. The U64 firmware can be built by typing 'make u64'. - The U64E-II firmware can be built by typing 'make u64ii' -Its control module firmware (software/u64ctrl) needs ESP-IDF 6, while software/wifi/raw_u64 and raw_c3 -still need 5.3.1. So 'make u64ii' needs IDF_PATH to be an ESP-IDF 6, 'make u64' and 'make u2pl' need 5.3.1, -and 'make' (all), 'make esp32' and 'make clean' cannot complete with a single IDF_PATH. Build the control -module as software/u64ctrl/README.md shows, and then run 'make u64ii_no_esp'. +The ESP32 module firmware of the U64 (software/wifi/raw_u64) and of the U64E-II (software/u64ctrl) needs ESP-IDF 6, +while the one of the U2+L (software/wifi/raw_c3) still needs 5.3.1. So 'make u64' and 'make u64ii' need IDF_PATH to +be an ESP-IDF 6, 'make u2pl' needs 5.3.1, and 'make' (all), 'make esp32' and 'make clean' cannot complete with a +single IDF_PATH. Build the modules as software/wifi/raw_u64/README.md and software/u64ctrl/README.md show, and then +run 'make u64_no_esp' and 'make u64ii_no_esp'. ==> When using the top level makefile, the results are copied into the root of the project. diff --git a/software/u64ctrl/README.md b/software/u64ctrl/README.md index 8ab889bd9..f98787863 100644 --- a/software/u64ctrl/README.md +++ b/software/u64ctrl/README.md @@ -5,8 +5,8 @@ The ESP32-S3 module of the Ultimate 64 Elite II and the C64 Ultimate: WiFi, powe ## Building The module needs ESP-IDF 6 (CI uses v6.0.3); `CMakeLists.txt` stops an older one at configure. -raw_u64 and raw_c3 still build with ESP-IDF 5.3.1, as in `docker/Dockerfile`, so CI builds this -project in `espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. Locally, from +raw_c3 still builds with ESP-IDF 5.3.1, as in `docker/Dockerfile`, so CI builds this +project (and raw_u64) in `espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. Locally, from the top of the repository, the same way as CI: docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp -v "$PWD":/project -w /project/software/u64ctrl \ @@ -14,7 +14,7 @@ the top of the repository, the same way as CI: then `make u64ii_no_esp` packs `build/u64ctrl.bin` into the update files. `make esp32_u64ctrl` and `make u64ii` work only where `IDF_PATH` is an ESP-IDF 6, and `make` (all) cannot complete with one -`IDF_PATH`, because raw_u64 and raw_c3 need 5.3.1. Once `build/` exists here, +`IDF_PATH`, because raw_c3 needs 5.3.1. Once `build/` exists here, `make clean` also needs ESP-IDF 6; otherwise delete `software/u64ctrl/build` by hand. `software/io/uart/cmd_buffer.c` is compiled into all three ESP32 projects, so a change to it has to diff --git a/software/wifi/raw_u64/CMakeLists.txt b/software/wifi/raw_u64/CMakeLists.txt index a8abcf637..ecffda6a1 100644 --- a/software/wifi/raw_u64/CMakeLists.txt +++ b/software/wifi/raw_u64/CMakeLists.txt @@ -1,6 +1,9 @@ # The following lines of boilerplate have to be in your project's CMakeLists # in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) +if(IDF_VERSION_MAJOR LESS 6) + message(FATAL_ERROR "raw_u64 needs ESP-IDF 6, not ${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR} (see software/wifi/raw_u64/README.md)") +endif() project(bridge) diff --git a/software/wifi/raw_u64/README.md b/software/wifi/raw_u64/README.md index dec4d5ebb..b1160d591 100644 --- a/software/wifi/raw_u64/README.md +++ b/software/wifi/raw_u64/README.md @@ -1,4 +1,25 @@ -# Wifi SCAN Example +# ESP32 WiFi bridge (raw_u64) + +## Building + +The bridge needs ESP-IDF 6 (CI uses v6.0.3); `CMakeLists.txt` stops an older one at configure. +raw_c3 still builds with ESP-IDF 5.3.1, as in `docker/Dockerfile`, so CI builds this +project (and u64ctrl) in `espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. +Locally, from the top of the repository, the same way as CI: + + docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp -v "$PWD":/project -w /project/software/wifi/raw_u64 \ + espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 idf.py build + +then `make u64_no_esp` packs `build/bridge.bin` into `update.u64`. `make esp32_raw_u64` (and so +`make u64`) works only where `IDF_PATH` is an ESP-IDF 6; `make all` cannot complete with one `IDF_PATH`, +because raw_c3 needs 5.3.1. Once `build/` exists here, +`make clean` also needs ESP-IDF 6; otherwise delete `software/wifi/raw_u64/build` by hand. + +`software/io/uart/cmd_buffer.c` is compiled into all three ESP32 projects, so a change to it has to +build on both ESP-IDF 5.3.1 and 6. + +`sdkconfig` marks values that follow ESP-IDF's defaults with `# default:`; a reconfigure on a newer +ESP-IDF takes its new defaults there. After any ESP-IDF update, diff the values, not just the build. This example shows how to use the scan functionality of the Wi-Fi driver of ESP32. diff --git a/software/wifi/raw_u64/main/my_uart.c b/software/wifi/raw_u64/main/my_uart.c index 824c9d65a..5abd64960 100644 --- a/software/wifi/raw_u64/main/my_uart.c +++ b/software/wifi/raw_u64/main/my_uart.c @@ -23,7 +23,7 @@ #include "freertos/ringbuf.h" #include "hal/uart_hal.h" #include "hal/gpio_hal.h" -#include "soc/uart_periph.h" +#include "hal/uart_periph.h" #include "soc/rtc_cntl_reg.h" #include "driver/uart.h" #include "driver/gpio.h" @@ -368,7 +368,7 @@ BaseType_t my_uart_get_buffer(uint8_t uart_num, command_buf_t **buf, TickType_t } #include "esp_check.h" -esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void *), void *arg, int intr_alloc_flags, uart_isr_handle_t *handle) +esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void *), void *arg, int intr_alloc_flags, intr_handle_t *handle) { int ret; ESP_RETURN_ON_FALSE((uart_num < UART_NUM_MAX), ESP_FAIL, UART_TAG, "uart_num error"); diff --git a/software/wifi/raw_u64/main/rpc_dispatch.h b/software/wifi/raw_u64/main/rpc_dispatch.h index 596cd040f..d9479fbbf 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.h +++ b/software/wifi/raw_u64/main/rpc_dispatch.h @@ -26,15 +26,16 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.7" +#define IDENT_STRING "ESP32 WiFi Bridge V1.8" #define IDENT_MAJOR 1 +// 1.8: built with ESP-IDF 6.0.3. // 1.7: terminates 32-character SSIDs and 64-character passwords, and reads // them back from NVS whole. // 1.6: the connector retries after a dropped link instead of idling in // Disconnected forever. The Ultimate's updater only reflashes the module // when this differs from what the module reports, so a module change that // does not bump it is silently never installed. -#define IDENT_MINOR 7 +#define IDENT_MINOR 8 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 diff --git a/software/wifi/raw_u64/sdkconfig b/software/wifi/raw_u64/sdkconfig index c1c68ab8e..444b61c7d 100644 --- a/software/wifi/raw_u64/sdkconfig +++ b/software/wifi/raw_u64/sdkconfig @@ -1,246 +1,422 @@ # # Automatically generated file. DO NOT EDIT. -# Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Configuration +# Espressif IoT Development Framework (ESP-IDF) 6.0.3 Project Configuration # -CONFIG_SOC_BROWNOUT_RESET_SUPPORTED="Not determined" -CONFIG_SOC_TWAI_BRP_DIV_SUPPORTED="Not determined" -CONFIG_SOC_DPORT_WORKAROUND="Not determined" +# default: CONFIG_SOC_CAPS_ECO_VER_MAX=301 +# default: CONFIG_SOC_ADC_SUPPORTED=y +# default: CONFIG_SOC_DAC_SUPPORTED=y +# default: CONFIG_SOC_UART_SUPPORTED=y +# default: CONFIG_SOC_MCPWM_SUPPORTED=y +# default: CONFIG_SOC_GPTIMER_SUPPORTED=y +# default: CONFIG_SOC_SDMMC_HOST_SUPPORTED=y +# default: CONFIG_SOC_BT_SUPPORTED=y +# default: CONFIG_SOC_PCNT_SUPPORTED=y +# default: CONFIG_SOC_PHY_SUPPORTED=y +# default: CONFIG_SOC_WIFI_SUPPORTED=y +# default: CONFIG_SOC_SDIO_SLAVE_SUPPORTED=y +# default: CONFIG_SOC_TWAI_SUPPORTED=y +# default: CONFIG_SOC_EFUSE_SUPPORTED=y +# default: CONFIG_SOC_EMAC_SUPPORTED=y +# default: CONFIG_SOC_ULP_SUPPORTED=y +# default: CONFIG_SOC_CCOMP_TIMER_SUPPORTED=y +# default: CONFIG_SOC_RTC_FAST_MEM_SUPPORTED=y +# default: CONFIG_SOC_RTC_SLOW_MEM_SUPPORTED=y +# default: CONFIG_SOC_RTC_MEM_SUPPORTED=y +# default: +CONFIG_SOC_RTC_TIMER_V1_SUPPORTED=y +# default: CONFIG_SOC_I2S_SUPPORTED=y +# default: +CONFIG_SOC_I2S_I80_LCD_SUPPORTED=y +# default: +CONFIG_SOC_LCD_I80_SUPPORTED=y +# default: CONFIG_SOC_RMT_SUPPORTED=y +# default: CONFIG_SOC_SDM_SUPPORTED=y +# default: CONFIG_SOC_GPSPI_SUPPORTED=y +# default: CONFIG_SOC_LEDC_SUPPORTED=y +# default: CONFIG_SOC_I2C_SUPPORTED=y +# default: CONFIG_SOC_SUPPORT_COEXISTENCE=y +# default: CONFIG_SOC_AES_SUPPORTED=y +# default: CONFIG_SOC_MPI_SUPPORTED=y +# default: CONFIG_SOC_SHA_SUPPORTED=y +# default: CONFIG_SOC_FLASH_ENC_SUPPORTED=y +# default: CONFIG_SOC_SECURE_BOOT_SUPPORTED=y +# default: CONFIG_SOC_TOUCH_SENSOR_SUPPORTED=y +# default: CONFIG_SOC_BOD_SUPPORTED=y +# default: CONFIG_SOC_ULP_FSM_SUPPORTED=y +# default: CONFIG_SOC_CLK_TREE_SUPPORTED=y +# default: CONFIG_SOC_MPU_SUPPORTED=y +# default: CONFIG_SOC_WDT_SUPPORTED=y +# default: CONFIG_SOC_SPI_FLASH_SUPPORTED=y +# default: CONFIG_SOC_RNG_SUPPORTED=y +# default: CONFIG_SOC_LIGHT_SLEEP_SUPPORTED=y +# default: CONFIG_SOC_DEEP_SLEEP_SUPPORTED=y +# default: CONFIG_SOC_LP_PERIPH_SHARE_INTERRUPT=y +# default: CONFIG_SOC_PM_SUPPORTED=y +# default: CONFIG_SOC_DPORT_WORKAROUND_DIS_INTERRUPT_LVL=5 +# default: CONFIG_SOC_XTAL_SUPPORT_26M=y +# default: CONFIG_SOC_XTAL_SUPPORT_40M=y -CONFIG_SOC_XTAL_SUPPORT_AUTO_DETECT=y +# default: CONFIG_SOC_ADC_RTC_CTRL_SUPPORTED=y +# default: CONFIG_SOC_ADC_DIG_CTRL_SUPPORTED=y +# default: CONFIG_SOC_ADC_DMA_SUPPORTED=y +# default: CONFIG_SOC_ADC_PERIPH_NUM=2 +# default: CONFIG_SOC_ADC_MAX_CHANNEL_NUM=10 +# default: CONFIG_SOC_ADC_ATTEN_NUM=4 +# default: CONFIG_SOC_ADC_DIGI_CONTROLLER_NUM=2 +# default: CONFIG_SOC_ADC_PATT_LEN_MAX=16 +# default: CONFIG_SOC_ADC_DIGI_MIN_BITWIDTH=9 +# default: CONFIG_SOC_ADC_DIGI_MAX_BITWIDTH=12 +# default: CONFIG_SOC_ADC_DIGI_RESULT_BYTES=2 +# default: CONFIG_SOC_ADC_DIGI_DATA_BYTES_PER_CONV=4 +# default: CONFIG_SOC_ADC_DIGI_MONITOR_NUM=0 -CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_HIGH=2 -CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_LOW=20 +# default: +CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_HIGH=2000000 +# default: +CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_LOW=20000 +# default: CONFIG_SOC_ADC_RTC_MIN_BITWIDTH=9 +# default: CONFIG_SOC_ADC_RTC_MAX_BITWIDTH=12 +# default: CONFIG_SOC_ADC_SHARED_POWER=y +# default: +CONFIG_SOC_BROWNOUT_RESET_SUPPORTED=y +# default: CONFIG_SOC_SHARED_IDCACHE_SUPPORTED=y +# default: CONFIG_SOC_IDCACHE_PER_CORE=y +# default: CONFIG_SOC_CPU_CORES_NUM=2 +# default: CONFIG_SOC_CPU_INTR_NUM=32 +# default: CONFIG_SOC_CPU_HAS_FPU=y +# default: CONFIG_SOC_HP_CPU_HAS_MULTIPLE_CORES=y +# default: CONFIG_SOC_CPU_BREAKPOINTS_NUM=2 +# default: CONFIG_SOC_CPU_WATCHPOINTS_NUM=2 -CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=64 +# default: +CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=0x40 +# default: CONFIG_SOC_DAC_CHAN_NUM=2 +# default: CONFIG_SOC_DAC_RESOLUTION=8 +# default: CONFIG_SOC_DAC_DMA_16BIT_ALIGN=y +# default: CONFIG_SOC_GPIO_PORT=1 +# default: CONFIG_SOC_GPIO_PIN_COUNT=40 +# default: CONFIG_SOC_GPIO_VALID_GPIO_MASK=0xFFFFFFFFFF +# default: CONFIG_SOC_GPIO_IN_RANGE_MAX=39 +# default: CONFIG_SOC_GPIO_OUT_RANGE_MAX=33 +# default: CONFIG_SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK=0xEF0FEA +# default: CONFIG_SOC_GPIO_CLOCKOUT_BY_IO_MUX=y +# default: CONFIG_SOC_GPIO_CLOCKOUT_CHANNEL_NUM=3 +# default: CONFIG_SOC_I2C_NUM=2 +# default: CONFIG_SOC_HP_I2C_NUM=2 -CONFIG_SOC_I2C_FIFO_LEN=32 -CONFIG_SOC_I2C_CMD_REG_NUM=16 -CONFIG_SOC_I2C_SUPPORT_SLAVE=y +# default: CONFIG_SOC_I2C_SUPPORT_APB=y +# default: +CONFIG_SOC_I2C_SUPPORT_10BIT_ADDR=y +# default: +CONFIG_SOC_I2C_SUPPORT_SLAVE=y +# default: CONFIG_SOC_I2C_STOP_INDEPENDENT=y -CONFIG_SOC_I2S_NUM=2 +# default: CONFIG_SOC_I2S_HW_VERSION_1=y +# default: CONFIG_SOC_I2S_SUPPORTS_APLL=y -CONFIG_SOC_I2S_SUPPORTS_PLL_F160M=y +# default: CONFIG_SOC_I2S_SUPPORTS_PDM=y +# default: CONFIG_SOC_I2S_SUPPORTS_PDM_TX=y -CONFIG_SOC_I2S_PDM_MAX_TX_LINES=1 +# default: +CONFIG_SOC_I2S_SUPPORTS_PCM2PDM=y +# default: CONFIG_SOC_I2S_SUPPORTS_PDM_RX=y +# default: +CONFIG_SOC_I2S_SUPPORTS_PDM2PCM=y +# default: +CONFIG_SOC_I2S_PDM_MAX_TX_LINES=1 +# default: CONFIG_SOC_I2S_PDM_MAX_RX_LINES=1 -CONFIG_SOC_I2S_SUPPORTS_ADC_DAC=y -CONFIG_SOC_I2S_SUPPORTS_ADC=y -CONFIG_SOC_I2S_SUPPORTS_DAC=y -CONFIG_SOC_I2S_SUPPORTS_LCD_CAMERA=y -CONFIG_SOC_I2S_TRANS_SIZE_ALIGN_WORD=y -CONFIG_SOC_I2S_LCD_I80_VARIANT=y -CONFIG_SOC_LCD_I80_SUPPORTED=y -CONFIG_SOC_LCD_I80_BUSES=2 -CONFIG_SOC_LCD_I80_BUS_WIDTH=24 +# default: CONFIG_SOC_LEDC_HAS_TIMER_SPECIFIC_MUX=y +# default: CONFIG_SOC_LEDC_SUPPORT_APB_CLOCK=y +# default: CONFIG_SOC_LEDC_SUPPORT_REF_TICK=y +# default: CONFIG_SOC_LEDC_SUPPORT_HS_MODE=y +# default: +CONFIG_SOC_LEDC_TIMER_NUM=4 +# default: CONFIG_SOC_LEDC_CHANNEL_NUM=8 +# default: CONFIG_SOC_LEDC_TIMER_BIT_WIDTH=20 -CONFIG_SOC_MCPWM_GROUPS=2 -CONFIG_SOC_MCPWM_TIMERS_PER_GROUP=3 -CONFIG_SOC_MCPWM_OPERATORS_PER_GROUP=3 -CONFIG_SOC_MCPWM_COMPARATORS_PER_OPERATOR=2 -CONFIG_SOC_MCPWM_GENERATORS_PER_OPERATOR=2 -CONFIG_SOC_MCPWM_TRIGGERS_PER_OPERATOR=2 -CONFIG_SOC_MCPWM_GPIO_FAULTS_PER_GROUP=3 -CONFIG_SOC_MCPWM_CAPTURE_TIMERS_PER_GROUP=y -CONFIG_SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER=3 -CONFIG_SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP=3 +# default: CONFIG_SOC_MMU_PERIPH_NUM=2 +# default: CONFIG_SOC_MMU_LINEAR_ADDRESS_REGION_NUM=3 +# default: CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000 +# default: CONFIG_SOC_MPU_REGIONS_MAX_NUM=8 -CONFIG_SOC_PCNT_GROUPS=1 -CONFIG_SOC_PCNT_UNITS_PER_GROUP=8 -CONFIG_SOC_PCNT_CHANNELS_PER_UNIT=2 -CONFIG_SOC_PCNT_THRES_POINT_PER_UNIT=2 -CONFIG_SOC_RMT_GROUPS=1 -CONFIG_SOC_RMT_TX_CANDIDATES_PER_GROUP=8 -CONFIG_SOC_RMT_RX_CANDIDATES_PER_GROUP=8 -CONFIG_SOC_RMT_CHANNELS_PER_GROUP=8 +# default: CONFIG_SOC_RMT_MEM_WORDS_PER_CHANNEL=64 -CONFIG_SOC_RMT_SUPPORT_REF_TICK=y -CONFIG_SOC_RMT_SUPPORT_APB=y -CONFIG_SOC_RMT_CHANNEL_CLK_INDEPENDENT=y +# default: CONFIG_SOC_RTCIO_PIN_COUNT=18 +# default: CONFIG_SOC_RTCIO_INPUT_OUTPUT_SUPPORTED=y +# default: CONFIG_SOC_RTCIO_HOLD_SUPPORTED=y +# default: CONFIG_SOC_RTCIO_WAKE_SUPPORTED=y -CONFIG_SOC_SDM_GROUPS=1 -CONFIG_SOC_SDM_CHANNELS_PER_GROUP=8 -CONFIG_SOC_SDM_CLK_SUPPORT_APB=y +# default: +CONFIG_SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS=y +# default: CONFIG_SOC_SPI_HD_BOTH_INOUT_SUPPORTED=y +# default: CONFIG_SOC_SPI_AS_CS_SUPPORTED=y +# default: CONFIG_SOC_SPI_PERIPH_NUM=3 +# default: CONFIG_SOC_SPI_DMA_CHAN_NUM=2 +# default: CONFIG_SOC_SPI_MAX_CS_NUM=3 +# default: CONFIG_SOC_SPI_SUPPORT_CLK_APB=y +# default: CONFIG_SOC_SPI_MAXIMUM_BUFFER_SIZE=64 +# default: CONFIG_SOC_SPI_MAX_PRE_DIVIDER=8192 -CONFIG_SOC_MEMSPI_SRC_FREQ_80M_SUPPORTED=y -CONFIG_SOC_MEMSPI_SRC_FREQ_40M_SUPPORTED=y -CONFIG_SOC_MEMSPI_SRC_FREQ_26M_SUPPORTED=y -CONFIG_SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED=y -CONFIG_SOC_TIMER_GROUPS=2 -CONFIG_SOC_TIMER_GROUP_TIMERS_PER_GROUP=2 -CONFIG_SOC_TIMER_GROUP_COUNTER_BIT_WIDTH=64 -CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=4 -CONFIG_SOC_TIMER_GROUP_SUPPORT_APB=y +# default: +CONFIG_SOC_MEMSPI_ENCRYPTION_ALIGNMENT=16 +# default: +CONFIG_SOC_LP_TIMER_BIT_WIDTH_LO=32 +# default: +CONFIG_SOC_LP_TIMER_BIT_WIDTH_HI=16 +# default: CONFIG_SOC_TOUCH_SENSOR_VERSION=1 -CONFIG_SOC_TOUCH_SENSOR_NUM=10 +# default: +CONFIG_SOC_TOUCH_MIN_CHAN_ID=0 +# default: +CONFIG_SOC_TOUCH_MAX_CHAN_ID=9 +# default: +CONFIG_SOC_TOUCH_SUPPORT_SLEEP_WAKEUP=y +# default: CONFIG_SOC_TOUCH_SAMPLE_CFG_NUM=1 +# default: CONFIG_SOC_TWAI_CONTROLLER_NUM=1 -CONFIG_SOC_TWAI_BRP_MIN=2 -CONFIG_SOC_TWAI_CLK_SUPPORT_APB=y -CONFIG_SOC_TWAI_SUPPORT_MULTI_ADDRESS_LAYOUT=y +# default: +CONFIG_SOC_TWAI_MASK_FILTER_NUM=1 +# default: CONFIG_SOC_UART_NUM=3 +# default: CONFIG_SOC_UART_HP_NUM=3 +# default: CONFIG_SOC_UART_SUPPORT_APB_CLK=y +# default: CONFIG_SOC_UART_SUPPORT_REF_TICK=y +# default: CONFIG_SOC_UART_FIFO_LEN=128 +# default: CONFIG_SOC_UART_BITRATE_MAX=5000000 +# default: +CONFIG_SOC_UART_WAKEUP_SUPPORT_ACTIVE_THRESH_MODE=y +# default: CONFIG_SOC_SPIRAM_SUPPORTED=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE=y +# default: CONFIG_SOC_SHA_SUPPORT_PARALLEL_ENG=y +# default: CONFIG_SOC_SHA_ENDIANNESS_BE=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA1=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA256=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA384=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA512=y +# default: CONFIG_SOC_MPI_MEM_BLOCKS_NUM=4 -CONFIG_SOC_MPI_OPERATIONS_NUM=y +# default: +CONFIG_SOC_MPI_OPERATIONS_NUM=1 +# default: CONFIG_SOC_RSA_MAX_BIT_LEN=4096 +# default: CONFIG_SOC_AES_SUPPORT_AES_128=y +# default: CONFIG_SOC_AES_SUPPORT_AES_192=y +# default: CONFIG_SOC_AES_SUPPORT_AES_256=y +# default: CONFIG_SOC_SECURE_BOOT_V1=y -CONFIG_SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS=y +# default: +CONFIG_SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS=1 +# default: CONFIG_SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX=32 +# default: CONFIG_SOC_PHY_DIG_REGS_MEM_SIZE=21 +# default: CONFIG_SOC_PM_SUPPORT_EXT0_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_EXT1_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_EXT_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_RTC_PERIPH_PD=y +# default: CONFIG_SOC_PM_SUPPORT_RTC_FAST_MEM_PD=y +# default: CONFIG_SOC_PM_SUPPORT_RTC_SLOW_MEM_PD=y +# default: CONFIG_SOC_PM_SUPPORT_RC_FAST_PD=y +# default: CONFIG_SOC_PM_SUPPORT_VDDSDIO_PD=y +# default: CONFIG_SOC_PM_SUPPORT_MODEM_PD=y +# default: CONFIG_SOC_CONFIGURABLE_VDDSDIO_SUPPORTED=y +# default: +CONFIG_SOC_PM_MODEM_PD_BY_SW=y +# default: CONFIG_SOC_CLK_APLL_SUPPORTED=y +# default: CONFIG_SOC_CLK_RC_FAST_D256_SUPPORTED=y +# default: CONFIG_SOC_RTC_SLOW_CLK_SUPPORT_RC_FAST_D256=y +# default: CONFIG_SOC_CLK_RC_FAST_SUPPORT_CALIBRATION=y +# default: CONFIG_SOC_CLK_XTAL32K_SUPPORTED=y +# default: +CONFIG_SOC_CLK_LP_FAST_SUPPORT_XTAL_D4=y +# default: CONFIG_SOC_SDMMC_USE_IOMUX=y +# default: CONFIG_SOC_SDMMC_NUM_SLOTS=2 +# default: +CONFIG_SOC_SDMMC_DATA_WIDTH_MAX=8 +# default: CONFIG_SOC_WIFI_WAPI_SUPPORT=y +# default: CONFIG_SOC_WIFI_CSI_SUPPORT=y +# default: CONFIG_SOC_WIFI_MESH_SUPPORT=y +# default: CONFIG_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y +# default: CONFIG_SOC_WIFI_NAN_SUPPORT=y +# default: CONFIG_SOC_BLE_SUPPORTED=y +# default: CONFIG_SOC_BLE_MESH_SUPPORTED=y +# default: CONFIG_SOC_BT_CLASSIC_SUPPORTED=y +# default: CONFIG_SOC_BLUFI_SUPPORTED=y +# default: CONFIG_SOC_BT_H2C_ENC_KEY_CTRL_ENH_VSC_SUPPORTED=y +# default: +CONFIG_SOC_BLE_MULTI_CONN_OPTIMIZATION=y +# default: CONFIG_SOC_ULP_HAS_ADC=y +# default: CONFIG_SOC_PHY_COMBO_MODULE=y +# default: CONFIG_SOC_EMAC_RMII_CLK_OUT_INTERNAL_LOOPBACK=y +# default: CONFIG_IDF_CMAKE=y +# default: CONFIG_IDF_TOOLCHAIN="gcc" +# default: +CONFIG_IDF_TOOLCHAIN_GCC=y +# default: CONFIG_IDF_TARGET_ARCH_XTENSA=y +# default: CONFIG_IDF_TARGET_ARCH="xtensa" +# default: CONFIG_IDF_TARGET="esp32" +# default: CONFIG_IDF_INIT_VERSION="5.3.1" +# default: CONFIG_IDF_TARGET_ESP32=y +# default: CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 # @@ -248,8 +424,11 @@ CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 # CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y # CONFIG_APP_BUILD_TYPE_RAM is not set +# default: CONFIG_APP_BUILD_GENERATE_BINARIES=y +# default: CONFIG_APP_BUILD_BOOTLOADER=y +# default: CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y # CONFIG_APP_REPRODUCIBLE_BUILD is not set # CONFIG_APP_NO_BLOBS is not set @@ -257,6 +436,11 @@ CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y # CONFIG_APP_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set # end of Build type +# +# App Update config +# +# end of App Update config + # # Bootloader config # @@ -268,19 +452,61 @@ CONFIG_BOOTLOADER_COMPILE_TIME_DATE=y CONFIG_BOOTLOADER_PROJECT_VER=1 # end of Bootloader manager +# +# Application Rollback +# +# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set +# end of Application Rollback + +# +# Recovery Bootloader and Rollback +# +# end of Recovery Bootloader and Rollback + +# default: CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000 CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set + +# +# Log +# +# default: +CONFIG_BOOTLOADER_LOG_VERSION_1=y +# default: +CONFIG_BOOTLOADER_LOG_VERSION=1 # CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set # CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set +# default: CONFIG_BOOTLOADER_LOG_LEVEL=3 +# +# Format +# +# default: +# CONFIG_BOOTLOADER_LOG_COLORS is not set +# default: +CONFIG_BOOTLOADER_LOG_TIMESTAMP_SOURCE_CPU_TICKS=y +# end of Format + +# +# Settings +# +# default: +CONFIG_BOOTLOADER_LOG_MODE_TEXT_EN=y +# default: +CONFIG_BOOTLOADER_LOG_MODE_TEXT=y +# end of Settings +# end of Log + +# default: +CONFIG_BOOTLOADER_CPU_CLK_FREQ_MHZ=80 + # # Serial Flash Configurations # @@ -296,10 +522,10 @@ CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE=y CONFIG_BOOTLOADER_WDT_ENABLE=y # CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set CONFIG_BOOTLOADER_WDT_TIME_MS=9000 -# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set # CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set # CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set # CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set +# default: CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 # CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set # end of Bootloader config @@ -307,8 +533,13 @@ CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 # # Security features # +# default: CONFIG_SECURE_BOOT_V1_SUPPORTED=y # CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set +# default: +CONFIG_SECURE_BOOT_IMAGE_DIGEST_LEN=32 +# default: +CONFIG_SECURE_BOOT_ROM_FAST_WAKE_RESERVE_SIZE=0 # CONFIG_SECURE_BOOT is not set # CONFIG_SECURE_FLASH_ENC_ENABLED is not set # end of Security features @@ -323,19 +554,34 @@ CONFIG_APP_COMPILE_TIME_DATE=y CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 # end of Application manager +# default: CONFIG_ESP_ROM_HAS_CRC_LE=y +# default: CONFIG_ESP_ROM_HAS_CRC_BE=y +# default: CONFIG_ESP_ROM_HAS_MZ_CRC32=y +# default: CONFIG_ESP_ROM_HAS_JPEG_DECODE=y +# default: CONFIG_ESP_ROM_HAS_UART_BUF_SWITCH=y +# default: CONFIG_ESP_ROM_NEEDS_SWSETUP_WORKAROUND=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB_NANO_FORMAT=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB_32BIT_TIME=y +# default: CONFIG_ESP_ROM_HAS_SW_FLOAT=y +# default: CONFIG_ESP_ROM_USB_OTG_NUM=-1 +# default: CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM=-1 +# default: CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y +# default: +CONFIG_ESP_ROM_HAS_OUTPUT_PUTC_FUNC=y # # Serial flasher config @@ -346,11 +592,13 @@ CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y CONFIG_ESPTOOLPY_FLASHMODE_DIO=y # CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y +# default: CONFIG_ESPTOOLPY_FLASHMODE="dio" # CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set CONFIG_ESPTOOLPY_FLASHFREQ_40M=y # CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set +# default: CONFIG_ESPTOOLPY_FLASHFREQ="40m" # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y @@ -360,14 +608,18 @@ CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y # CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set +# default: CONFIG_ESPTOOLPY_FLASHSIZE="2MB" # CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE is not set CONFIG_ESPTOOLPY_BEFORE_RESET=y # CONFIG_ESPTOOLPY_BEFORE_NORESET is not set -CONFIG_ESPTOOLPY_BEFORE="default_reset" +# default: +CONFIG_ESPTOOLPY_BEFORE="default-reset" CONFIG_ESPTOOLPY_AFTER_RESET=y # CONFIG_ESPTOOLPY_AFTER_NORESET is not set -CONFIG_ESPTOOLPY_AFTER="hard_reset" +# default: +CONFIG_ESPTOOLPY_AFTER="hard-reset" +# default: CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 # end of Serial flasher config @@ -377,8 +629,10 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 CONFIG_PARTITION_TABLE_SINGLE_APP=y # CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set # CONFIG_PARTITION_TABLE_TWO_OTA is not set +# CONFIG_PARTITION_TABLE_TWO_OTA_LARGE is not set # CONFIG_PARTITION_TABLE_CUSTOM is not set CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +# default: CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y @@ -411,7 +665,10 @@ CONFIG_COMPILER_OPTIMIZATION_DEBUG=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +# default: +# CONFIG_COMPILER_ASSERT_NDEBUG_EVALUATE is not set CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB=y +# default: CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 # CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set CONFIG_COMPILER_HIDE_PATHS_MACROS=y @@ -421,118 +678,113 @@ CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y # CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set # CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set # CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set +# default: +# CONFIG_COMPILER_NO_MERGE_CONSTANTS is not set # CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +# default: +# CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS is not set # CONFIG_COMPILER_DISABLE_GCC12_WARNINGS is not set # CONFIG_COMPILER_DISABLE_GCC13_WARNINGS is not set +# default: +# CONFIG_COMPILER_DISABLE_GCC14_WARNINGS is not set +# default: +# CONFIG_COMPILER_DISABLE_GCC15_WARNINGS is not set # CONFIG_COMPILER_DUMP_RTL_FILES is not set CONFIG_COMPILER_RT_LIB_GCCLIB=y +# default: CONFIG_COMPILER_RT_LIB_NAME="gcc" +# CONFIG_COMPILER_ORPHAN_SECTIONS_ERROR is not set # CONFIG_COMPILER_ORPHAN_SECTIONS_WARNING is not set CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y +# default: +# CONFIG_COMPILER_STATIC_ANALYZER is not set +# default: +CONFIG_COMPILER_CXX_GLIBCXX_CONSTEXPR_NO_CHANGE=y +# default: +# CONFIG_COMPILER_CXX_GLIBCXX_CONSTEXPR_COLD_CONSTEXPR is not set +# default: +# CONFIG_COMPILER_CXX_GLIBCXX_CONSTEXPR_COLD is not set # end of Compiler options # # Component config # -# -# Application Level Tracing -# -# CONFIG_APPTRACE_DEST_JTAG is not set -CONFIG_APPTRACE_DEST_NONE=y -# CONFIG_APPTRACE_DEST_UART1 is not set -# CONFIG_APPTRACE_DEST_UART2 is not set -CONFIG_APPTRACE_DEST_UART_NONE=y -CONFIG_APPTRACE_UART_TASK_PRIO=1 -CONFIG_APPTRACE_LOCK_ENABLE=y -# end of Application Level Tracing - # # Bluetooth # # CONFIG_BT_ENABLED is not set -CONFIG_BT_ALARM_MAX_NUM=50 -# end of Bluetooth - -# -# Console Library -# -# CONFIG_CONSOLE_SORTED_HELP is not set -# end of Console Library # -# Driver Configurations +# Common Options # # -# TWAI Configuration +# BT Logs # -# CONFIG_TWAI_ISR_IN_IRAM is not set -# CONFIG_TWAI_ERRATA_FIX_BUS_OFF_REC is not set -# CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST is not set -# CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID is not set -# CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT is not set -CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM=y -# end of TWAI Configuration # -# Legacy ADC Driver Configuration +# Log Sources # -CONFIG_ADC_DISABLE_DAC=y -# CONFIG_ADC_SUPPRESS_DEPRECATE_WARN is not set +# end of Log Sources -# -# Legacy ADC Calibration Configuration -# -CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y -CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y -CONFIG_ADC_CAL_LUT_ENABLE=y -# CONFIG_ADC_CALI_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy ADC Calibration Configuration -# end of Legacy ADC Driver Configuration +# default: +# CONFIG_BT_LOG_CRITICAL_ONLY is not set +# default: +# CONFIG_BLE_LOG_ENABLED is not set # -# Legacy DAC Driver Configurations +# Legacy SPI Log Output (Deprecated - use BT Log Async Output instead) # -# CONFIG_DAC_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy DAC Driver Configurations +# default: +# CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED is not set +# end of Legacy SPI Log Output (Deprecated - use BT Log Async Output instead) +# end of BT Logs -# -# Legacy MCPWM Driver Configurations -# -# CONFIG_MCPWM_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy MCPWM Driver Configurations +# default: +# CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED is not set +# end of Common Options +# end of Bluetooth # -# Legacy Timer Group Driver Configurations +# Console Library # -# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy Timer Group Driver Configurations +# CONFIG_CONSOLE_SORTED_HELP is not set +# end of Console Library # -# Legacy RMT Driver Configurations +# Legacy Driver Configurations # -# CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy RMT Driver Configurations # -# Legacy I2S Driver Configurations +# Legacy TWAI Driver Configurations # -# CONFIG_I2S_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy I2S Driver Configurations +# default: +# CONFIG_TWAI_ISR_IN_IRAM_LEGACY is not set +# default: +# CONFIG_TWAI_SUPPRESS_DEPRECATE_WARN is not set +# default: +# CONFIG_TWAI_SKIP_LEGACY_CONFLICT_CHECK is not set +# end of Legacy TWAI Driver Configurations # -# Legacy PCNT Driver Configurations +# Legacy I2C Driver Configurations # -# CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy PCNT Driver Configurations +# default: +# CONFIG_I2C_SUPPRESS_DEPRECATE_WARN is not set +# default: +# CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK is not set +# end of Legacy I2C Driver Configurations # -# Legacy SDM Driver Configurations +# Legacy Touch Sensor Driver Configurations # -# CONFIG_SDM_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy SDM Driver Configurations -# end of Driver Configurations +# default: +# CONFIG_TOUCH_SUPPRESS_DEPRECATE_WARN is not set +# default: +# CONFIG_TOUCH_SKIP_LEGACY_CONFLICT_CHECK is not set +# end of Legacy Touch Sensor Driver Configurations +# end of Legacy Driver Configurations # # eFuse Bit Manager @@ -542,6 +794,7 @@ CONFIG_ADC_CAL_LUT_ENABLE=y # CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y # CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set +# default: CONFIG_EFUSE_MAX_BLK_LEN=192 # end of eFuse Bit Manager @@ -549,13 +802,15 @@ CONFIG_EFUSE_MAX_BLK_LEN=192 # ESP-TLS # CONFIG_ESP_TLS_USING_MBEDTLS=y -# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set +# CONFIG_ESP_TLS_CUSTOM_STACK is not set # CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set # CONFIG_ESP_TLS_SERVER_SESSION_TICKETS is not set # CONFIG_ESP_TLS_SERVER_CERT_SELECT_HOOK is not set # CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL is not set # CONFIG_ESP_TLS_PSK_VERIFICATION is not set # CONFIG_ESP_TLS_INSECURE is not set +# default: +CONFIG_ESP_TLS_DYN_BUF_STRATEGY_SUPPORTED=y # end of ESP-TLS # @@ -579,7 +834,10 @@ CONFIG_ADC_DISABLE_DAC_OUTPUT=y # # Wireless Coexistence # +# default: CONFIG_ESP_COEX_ENABLED=y +# default: +# CONFIG_ESP_COEX_GPIO_DEBUG is not set # end of Wireless Coexistence # @@ -600,7 +858,6 @@ CONFIG_DAC_DMA_AUTO_16BIT_ALIGN=y # # ESP-Driver:GPIO Configurations # -# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set # CONFIG_GPIO_CTRL_FUNC_IN_IRAM is not set # end of ESP-Driver:GPIO Configurations @@ -609,7 +866,9 @@ CONFIG_DAC_DMA_AUTO_16BIT_ALIGN=y # CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set -# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set +# CONFIG_GPTIMER_ISR_CACHE_SAFE is not set +# default: +CONFIG_GPTIMER_OBJ_CACHE_SAFE=y # CONFIG_GPTIMER_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:GPTimer Configurations @@ -618,15 +877,30 @@ CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # # CONFIG_I2C_ISR_IRAM_SAFE is not set # CONFIG_I2C_ENABLE_DEBUG_LOG is not set +# default: +CONFIG_I2C_MASTER_ISR_HANDLER_IN_IRAM=y # end of ESP-Driver:I2C Configurations # # ESP-Driver:I2S Configurations # # CONFIG_I2S_ISR_IRAM_SAFE is not set +# default: +# CONFIG_I2S_CTRL_FUNC_IN_IRAM is not set # CONFIG_I2S_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:I2S Configurations +# +# ESP-Driver:I3C Master Configurations +# +# default: +# CONFIG_I3C_MASTER_ISR_CACHE_SAFE is not set +# default: +# CONFIG_I3C_MASTER_ENABLE_DEBUG_LOG is not set +# default: +# CONFIG_I3C_MASTER_ISR_HANDLER_IN_IRAM is not set +# end of ESP-Driver:I3C Master Configurations + # # ESP-Driver:LEDC Configurations # @@ -636,8 +910,12 @@ CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # # ESP-Driver:MCPWM Configurations # -# CONFIG_MCPWM_ISR_IRAM_SAFE is not set +# default: +CONFIG_MCPWM_ISR_HANDLER_IN_IRAM=y +# CONFIG_MCPWM_ISR_CACHE_SAFE is not set # CONFIG_MCPWM_CTRL_FUNC_IN_IRAM is not set +# default: +CONFIG_MCPWM_OBJ_CACHE_SAFE=y # CONFIG_MCPWM_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:MCPWM Configurations @@ -652,9 +930,21 @@ CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # # ESP-Driver:RMT Configurations # -# CONFIG_RMT_ISR_IRAM_SAFE is not set +# default: +CONFIG_RMT_ENCODER_FUNC_IN_IRAM=y +# default: +CONFIG_RMT_TX_ISR_HANDLER_IN_IRAM=y +# default: +CONFIG_RMT_RX_ISR_HANDLER_IN_IRAM=y # CONFIG_RMT_RECV_FUNC_IN_IRAM is not set +# default: +# CONFIG_RMT_TX_ISR_CACHE_SAFE is not set +# default: +# CONFIG_RMT_RX_ISR_CACHE_SAFE is not set +# default: +CONFIG_RMT_OBJ_CACHE_SAFE=y # CONFIG_RMT_ENABLE_DEBUG_LOG is not set +# CONFIG_RMT_ISR_IRAM_SAFE is not set # end of ESP-Driver:RMT Configurations # @@ -664,10 +954,16 @@ CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # CONFIG_SDM_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:Sigma Delta Modulator Configurations +# +# ESP-Driver:SD Host SDMMC Controller Configurations +# +# default: +# CONFIG_SD_HOST_SDMMC_ISR_CACHE_SAFE is not set +# end of ESP-Driver:SD Host SDMMC Controller Configurations + # # ESP-Driver:SPI Configurations # -# CONFIG_SPI_MASTER_IN_IRAM is not set CONFIG_SPI_MASTER_ISR_IN_IRAM=y # CONFIG_SPI_SLAVE_IN_IRAM is not set CONFIG_SPI_SLAVE_ISR_IN_IRAM=y @@ -679,31 +975,50 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y # CONFIG_TOUCH_CTRL_FUNC_IN_IRAM is not set # CONFIG_TOUCH_ISR_IRAM_SAFE is not set # CONFIG_TOUCH_ENABLE_DEBUG_LOG is not set +# default: +# CONFIG_TOUCH_SKIP_FSM_CHECK is not set # end of ESP-Driver:Touch Sensor Configurations +# +# ESP-Driver:TWAI Configurations +# +# CONFIG_TWAI_ISR_IN_IRAM is not set +# default: +# CONFIG_TWAI_IO_FUNC_IN_IRAM is not set +# default: +# CONFIG_TWAI_ISR_CACHE_SAFE is not set +# default: +# CONFIG_TWAI_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:TWAI Configurations + # # ESP-Driver:UART Configurations # # CONFIG_UART_ISR_IN_IRAM is not set # end of ESP-Driver:UART Configurations +# +# ESP-Driver:UHCI Configurations +# +# default: +# CONFIG_UHCI_ISR_HANDLER_IN_IRAM is not set +# default: +# CONFIG_UHCI_ISR_CACHE_SAFE is not set +# default: +# CONFIG_UHCI_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:UHCI Configurations + # # Ethernet # +# default: CONFIG_ETH_ENABLED=y CONFIG_ETH_USE_ESP32_EMAC=y -CONFIG_ETH_PHY_INTERFACE_RMII=y -CONFIG_ETH_RMII_CLK_INPUT=y -# CONFIG_ETH_RMII_CLK_OUTPUT is not set -CONFIG_ETH_RMII_CLK_IN_GPIO=0 CONFIG_ETH_DMA_BUFFER_SIZE=512 CONFIG_ETH_DMA_RX_BUFFER_NUM=10 CONFIG_ETH_DMA_TX_BUFFER_NUM=10 # CONFIG_ETH_IRAM_OPTIMIZATION is not set CONFIG_ETH_USE_SPI_ETHERNET=y -# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set -# CONFIG_ETH_SPI_ETHERNET_W5500 is not set -# CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set # CONFIG_ETH_USE_OPENETH is not set # CONFIG_ETH_TRANSMIT_MUTEX is not set # end of Ethernet @@ -719,12 +1034,22 @@ CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y # # GDB Stub # +# default: CONFIG_ESP_GDBSTUB_ENABLED=y # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set CONFIG_ESP_GDBSTUB_SUPPORT_TASKS=y CONFIG_ESP_GDBSTUB_MAX_TASKS=32 # end of GDB Stub +# +# ESP HID +# +# default: +CONFIG_ESPHID_TASK_SIZE_BT=2048 +# default: +CONFIG_ESPHID_TASK_SIZE_BLE=4096 +# end of ESP HID + # # ESP HTTP client # @@ -732,6 +1057,14 @@ CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y # CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH=y # CONFIG_ESP_HTTP_CLIENT_ENABLE_CUSTOM_TRANSPORT is not set +# default: +# CONFIG_ESP_HTTP_CLIENT_ENABLE_GET_CONTENT_RANGE is not set +# default: +CONFIG_ESP_HTTP_CLIENT_EVENT_POST_TIMEOUT=2000 +# default: +# CONFIG_ESP_HTTP_CLIENT_SAVE_RESPONSE_HEADERS is not set +# default: +CONFIG_ESP_HTTP_CLIENT_STRICT_HEADER_BUFFER=y # end of ESP HTTP client # @@ -744,6 +1077,10 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32 # CONFIG_HTTPD_LOG_PURGE_DATA is not set # CONFIG_HTTPD_WS_SUPPORT is not set # CONFIG_HTTPD_QUEUE_WORK_BLOCKING is not set +# default: +CONFIG_HTTPD_ENABLE_EVENTS=y +# default: +CONFIG_HTTPD_SERVER_EVENT_POST_TIMEOUT=2000 # end of HTTP Server # @@ -751,17 +1088,25 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32 # # CONFIG_ESP_HTTPS_OTA_DECRYPT_CB is not set # CONFIG_ESP_HTTPS_OTA_ALLOW_HTTP is not set +# default: +CONFIG_ESP_HTTPS_OTA_EVENT_POST_TIMEOUT=2000 +# default: +# CONFIG_ESP_HTTPS_OTA_ENABLE_PARTIAL_DOWNLOAD is not set # end of ESP HTTPS OTA # # ESP HTTPS server # # CONFIG_ESP_HTTPS_SERVER_ENABLE is not set +# default: +# CONFIG_ESP_HTTPS_SERVER_CERT_SELECT_HOOK is not set # end of ESP HTTPS server # # Hardware Settings # +# default: +CONFIG_ESP_HW_SUPPORT_FUNC_IN_IRAM=y # # Chip revision @@ -772,28 +1117,48 @@ CONFIG_ESP32_REV_MIN_0=y # CONFIG_ESP32_REV_MIN_2 is not set # CONFIG_ESP32_REV_MIN_3 is not set # CONFIG_ESP32_REV_MIN_3_1 is not set +# default: CONFIG_ESP32_REV_MIN=0 +# default: CONFIG_ESP32_REV_MIN_FULL=0 +# default: CONFIG_ESP_REV_MIN_FULL=0 # # Maximum Supported ESP32 Revision (Rev v3.99) # +# default: CONFIG_ESP32_REV_MAX_FULL=399 +# default: CONFIG_ESP_REV_MAX_FULL=399 +# default: +CONFIG_ESP_EFUSE_BLOCK_REV_MIN_FULL=0 +# default: +CONFIG_ESP_EFUSE_BLOCK_REV_MAX_FULL=99 + +# +# Maximum Supported ESP32 eFuse Block Revision (eFuse Block Rev v0.99) +# # end of Chip revision # # MAC Config # +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y +# default: CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES_FOUR=y +# default: CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES=4 # CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y +# default: CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 # CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR is not set # CONFIG_ESP_MAC_USE_CUSTOM_MAC_AS_BASE_MAC is not set @@ -803,6 +1168,11 @@ CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 # Sleep Config # CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y +# default: +CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND=y +# default: +# CONFIG_ESP_SLEEP_MSPI_NEED_ALL_IO_PU is not set +# default: CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y CONFIG_ESP_SLEEP_WAIT_FLASH_READY_EXTRA_DELAY=2000 @@ -819,52 +1189,118 @@ CONFIG_RTC_CLK_SRC_INT_RC=y # CONFIG_RTC_CLK_SRC_EXT_OSC is not set # CONFIG_RTC_CLK_SRC_INT_8MD256 is not set CONFIG_RTC_CLK_CAL_CYCLES=1024 +# default: +CONFIG_RTC_CLK_FUNC_IN_IRAM=y +# default: +CONFIG_RTC_TIME_FUNC_IN_IRAM=y # end of RTC Clock Config # # Peripheral Control # -CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y +CONFIG_ESP_PERIPH_CTRL_FUNC_IN_IRAM=y +# default: +CONFIG_ESP_REGI2C_CTRL_FUNC_IN_IRAM=y # end of Peripheral Control # # Main XTAL Config # # CONFIG_XTAL_FREQ_26 is not set +# CONFIG_XTAL_FREQ_32 is not set CONFIG_XTAL_FREQ_40=y # CONFIG_XTAL_FREQ_AUTO is not set +# default: CONFIG_XTAL_FREQ=40 # end of Main XTAL Config +# +# Power Supplier +# + +# +# Brownout Detector +# +CONFIG_ESP_BROWNOUT_DET=y +CONFIG_ESP_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_7 is not set +# default: +CONFIG_ESP_BROWNOUT_DET_LVL=0 +# default: +CONFIG_ESP_BROWNOUT_USE_INTR=y +# end of Brownout Detector +# end of Power Supplier + +# default: CONFIG_ESP_SPI_BUS_LOCK_ISR_FUNCS_IN_IRAM=y +# default: +CONFIG_ESP_INTR_IN_IRAM=y # end of Hardware Settings # -# LCD and Touch Panel +# ESP-Driver:LCD Controller Configurations # +# CONFIG_LCD_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:LCD Controller Configurations # -# LCD Touch Drivers are maintained in the IDF Component Registry +# LibC # +# default: +# CONFIG_LIBC_NEWLIB is not set +# default: +CONFIG_LIBC_PICOLIBC=y +# default: +CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY=y +# default: +CONFIG_LIBC_MISC_IN_IRAM=y +# default: +CONFIG_LIBC_LOCKS_PLACE_IN_IRAM=y +CONFIG_LIBC_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_LIBC_STDOUT_LINE_ENDING_LF is not set +# CONFIG_LIBC_STDOUT_LINE_ENDING_CR is not set +# CONFIG_LIBC_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_LIBC_STDIN_LINE_ENDING_LF is not set +CONFIG_LIBC_STDIN_LINE_ENDING_CR=y +CONFIG_LIBC_TIME_SYSCALL_USE_RTC_HRT=y +# CONFIG_LIBC_TIME_SYSCALL_USE_RTC is not set +# CONFIG_LIBC_TIME_SYSCALL_USE_HRT is not set +# CONFIG_LIBC_TIME_SYSCALL_USE_NONE is not set +# default: +CONFIG_LIBC_ASSERT_BUFFER_SIZE=200 +# end of LibC # -# LCD Peripheral Configuration +# ESP-MM: Memory Management Configurations # -CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32 -# CONFIG_LCD_ENABLE_DEBUG_LOG is not set -# end of LCD Peripheral Configuration -# end of LCD and Touch Panel +# end of ESP-MM: Memory Management Configurations # # ESP NETIF Adapter # +# default: +CONFIG_ESP_NETIF_LOST_IP_TIMER_ENABLE=y CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 +# default: +# CONFIG_ESP_NETIF_PROVIDE_CUSTOM_IMPLEMENTATION is not set CONFIG_ESP_NETIF_TCPIP_LWIP=y # CONFIG_ESP_NETIF_LOOPBACK is not set +# default: CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y -# CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS is not set +# default: +CONFIG_ESP_NETIF_REPORT_DATA_TRAFFIC=y +# default: +CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS=y # CONFIG_ESP_NETIF_L2_TAP is not set # CONFIG_ESP_NETIF_BRIDGE_EN is not set +# default: +# CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF is not set # end of ESP NETIF Adapter # @@ -875,23 +1311,42 @@ CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y # # PHY # +# default: CONFIG_ESP_PHY_ENABLED=y CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y # CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 +# default: CONFIG_ESP_PHY_MAX_TX_POWER=20 CONFIG_ESP_PHY_REDUCE_TX_POWER=y +# default: +# CONFIG_ESP_PHY_ENABLE_CERT_TEST is not set CONFIG_ESP_PHY_RF_CAL_PARTIAL=y # CONFIG_ESP_PHY_RF_CAL_NONE is not set # CONFIG_ESP_PHY_RF_CAL_FULL is not set +# default: CONFIG_ESP_PHY_CALIBRATION_MODE=0 +# default: +CONFIG_ESP_PHY_PLL_TRACK_PERIOD_MS=1000 # CONFIG_ESP_PHY_PLL_TRACK_DEBUG is not set +# default: +# CONFIG_ESP_PHY_RECORD_USED_TIME is not set +# default: +CONFIG_ESP_PHY_IRAM_OPT=y +# default: +# CONFIG_ESP_PHY_DEBUG is not set +# default: +CONFIG_ESP_PHY_ENABLE_VERSION_PRINT=y # end of PHY # # Power Management # +# default: +# CONFIG_PM_SLEEP_FUNC_IN_IRAM is not set # CONFIG_PM_ENABLE is not set +# default: +CONFIG_PM_SLP_IRAM_OPT=y # end of Power Management # @@ -903,15 +1358,46 @@ CONFIG_ESP_PHY_CALIBRATION_MODE=0 # # ESP Ringbuf # -# CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH is not set +# default: +# CONFIG_RINGBUF_IN_IRAM is not set +# default: +# CONFIG_RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH is not set # end of ESP Ringbuf +# +# ESP-ROM +# +# default: +CONFIG_ESP_ROM_PRINT_IN_IRAM=y +# end of ESP-ROM + +# +# ESP Security Specific +# +# end of ESP Security Specific + +# +# ESP-STDIO +# +CONFIG_ESP_CONSOLE_UART_DEFAULT=y +# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_NONE is not set +# default: +CONFIG_ESP_CONSOLE_UART=y +# default: +CONFIG_ESP_CONSOLE_UART_NUM=0 +# default: +CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +# end of ESP-STDIO + # # ESP System Settings # # CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80 is not set CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160=y # CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240 is not set +# default: CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=160 # @@ -930,35 +1416,26 @@ CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=160 # Trace memory # # CONFIG_ESP32_TRAX is not set +# default: CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0 # end of Trace memory +# default: +CONFIG_ESP_SYSTEM_IN_IRAM=y # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS=0 - -# -# Memory protection -# -# end of Memory protection - CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y # CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1 is not set # CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set +# default: CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 -CONFIG_ESP_CONSOLE_UART_DEFAULT=y -# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set -# CONFIG_ESP_CONSOLE_NONE is not set -CONFIG_ESP_CONSOLE_UART=y -CONFIG_ESP_CONSOLE_UART_NUM=0 -CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 -CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 CONFIG_ESP_INT_WDT=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 CONFIG_ESP_INT_WDT_CHECK_CPU1=y @@ -973,62 +1450,74 @@ CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y CONFIG_ESP_DEBUG_OCDAWARE=y # CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5 is not set CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y - -# -# Brownout Detector -# -CONFIG_ESP_BROWNOUT_DET=y -CONFIG_ESP_BROWNOUT_DET_LVL_SEL_0=y -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_1 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_7 is not set -CONFIG_ESP_BROWNOUT_DET_LVL=0 -# end of Brownout Detector - # CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set -CONFIG_ESP_SYSTEM_BROWNOUT_INTR=y # end of ESP System Settings # # IPC (Inter-Processor Call) # +# default: +CONFIG_ESP_IPC_ENABLE=y CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y +# default: CONFIG_ESP_IPC_ISR_ENABLE=y # end of IPC (Inter-Processor Call) # # ESP Timer (High Resolution Timer) # +# default: +CONFIG_ESP_TIMER_IN_IRAM=y # CONFIG_ESP_TIMER_PROFILING is not set +# default: CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y +# default: CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 # CONFIG_ESP_TIMER_SHOW_EXPERIMENTAL is not set +# default: CONFIG_ESP_TIMER_TASK_AFFINITY=0x0 CONFIG_ESP_TIMER_TASK_AFFINITY_CPU0=y CONFIG_ESP_TIMER_ISR_AFFINITY_CPU0=y # CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set +# default: CONFIG_ESP_TIMER_IMPL_TG0_LAC=y # end of ESP Timer (High Resolution Timer) +# +# ESP Trace Configuration +# +# default: +# CONFIG_ESP_TRACE_LIB_EXTERNAL is not set +# default: +CONFIG_ESP_TRACE_LIB_NONE=y +# default: +CONFIG_ESP_TRACE_LIB_NAME="none" +# default: +# CONFIG_ESP_TRACE_TRANSPORT_APPTRACE is not set +# default: +CONFIG_ESP_TRACE_TRANSPORT_NONE=y +# default: +CONFIG_ESP_TRACE_TRANSPORT_NAME="none" +# end of ESP Trace Configuration + # # Wi-Fi # +# default: CONFIG_ESP_WIFI_ENABLED=y CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32 # CONFIG_ESP_WIFI_STATIC_TX_BUFFER is not set CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER=y +# default: CONFIG_ESP_WIFI_TX_BUFFER_TYPE=1 CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=32 CONFIG_ESP_WIFI_STATIC_RX_MGMT_BUFFER=y # CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER is not set +# default: CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0 CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF=5 # CONFIG_ESP_WIFI_CSI_ENABLED is not set @@ -1045,11 +1534,17 @@ CONFIG_ESP_WIFI_IRAM_OPT=y # CONFIG_ESP_WIFI_EXTRA_IRAM_OPT is not set CONFIG_ESP_WIFI_RX_IRAM_OPT=y CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y +# default: +CONFIG_ESP_WIFI_ENABLE_SAE_H2E=y CONFIG_ESP_WIFI_ENABLE_SAE_PK=y CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT=y CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y +# default: +CONFIG_ESP_WIFI_WPA3_COMPATIBLE_SUPPORT=y # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set CONFIG_ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME=50 +# default: +# CONFIG_ESP_WIFI_BSS_MAX_IDLE_SUPPORT is not set CONFIG_ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME=10 CONFIG_ESP_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME=15 # CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set @@ -1057,7 +1552,7 @@ CONFIG_ESP_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME=15 CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y # CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT is not set CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=7 -# CONFIG_ESP_WIFI_NAN_ENABLE is not set +# CONFIG_ESP_WIFI_NAN_SYNC_ENABLE is not set CONFIG_ESP_WIFI_MBEDTLS_CRYPTO=y CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y # CONFIG_ESP_WIFI_WAPI_PSK is not set @@ -1072,12 +1567,15 @@ CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y # # CONFIG_ESP_WIFI_WPS_STRICT is not set # CONFIG_ESP_WIFI_WPS_PASSPHRASE is not set +# default: +# CONFIG_ESP_WIFI_WPS_RECONNECT_ON_FAIL is not set # end of WPS Configuration Options # CONFIG_ESP_WIFI_DEBUG_PRINT is not set -# CONFIG_ESP_WIFI_TESTING_OPTIONS is not set CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=y # CONFIG_ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER is not set +# default: +# CONFIG_ESP_WIFI_PASSIVE_HIDDEN_AP_SUPPORT is not set # end of Wi-Fi # @@ -1119,15 +1617,33 @@ CONFIG_FATFS_CODEPAGE_437=y # CONFIG_FATFS_CODEPAGE_936 is not set # CONFIG_FATFS_CODEPAGE_949 is not set # CONFIG_FATFS_CODEPAGE_950 is not set +# default: CONFIG_FATFS_CODEPAGE=437 CONFIG_FATFS_FS_LOCK=0 CONFIG_FATFS_TIMEOUT_MS=10000 CONFIG_FATFS_PER_FILE_CACHE=y # CONFIG_FATFS_USE_FASTSEEK is not set +# default: +CONFIG_FATFS_USE_STRFUNC_NONE=y +# default: +# CONFIG_FATFS_USE_STRFUNC_WITHOUT_CRLF_CONV is not set +# default: +# CONFIG_FATFS_USE_STRFUNC_WITH_CRLF_CONV is not set CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0 # CONFIG_FATFS_IMMEDIATE_FSYNC is not set # CONFIG_FATFS_USE_LABEL is not set CONFIG_FATFS_LINK_LOCK=y +# default: +CONFIG_FATFS_USE_DYN_BUFFERS=y + +# +# File system free space calculation behavior +# +# default: +CONFIG_FATFS_DONT_TRUST_FREE_CLUSTER_CNT=0 +# default: +CONFIG_FATFS_DONT_TRUST_LAST_ALLOC=0 +# end of File system free space calculation behavior # end of FAT Filesystem support # @@ -1149,10 +1665,13 @@ CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 # CONFIG_FREERTOS_USE_TICK_HOOK is not set CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 # CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY is not set +# default: +CONFIG_FREERTOS_USE_TIMERS=y CONFIG_FREERTOS_TIMER_SERVICE_TASK_NAME="Tmr Svc" # CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU0 is not set # CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU1 is not set CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY=y +# default: CONFIG_FREERTOS_TIMER_SERVICE_TASK_CORE_AFFINITY=0x7FFFFFFF CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 @@ -1172,25 +1691,36 @@ CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y # CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS=y # CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK is not set -# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set +# default: CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y CONFIG_FREERTOS_ISR_STACKSIZE=1536 CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y # CONFIG_FREERTOS_FPU_IN_ISR is not set +# default: CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y CONFIG_FREERTOS_CORETIMER_0=y # CONFIG_FREERTOS_CORETIMER_1 is not set +# default: CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y -# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set +# default: +# CONFIG_FREERTOS_IN_IRAM is not set # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set # end of Port +# +# Extra +# +# end of Extra + +# default: CONFIG_FREERTOS_PORT=y +# default: CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +# default: CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y +# default: CONFIG_FREERTOS_DEBUG_OCDAWARE=y -CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y -CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y +# default: CONFIG_FREERTOS_NUMBER_OF_CORES=2 # end of FreeRTOS @@ -1201,14 +1731,17 @@ CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y # CONFIG_HAL_ASSERTION_DISABLE is not set # CONFIG_HAL_ASSERTION_SILENT is not set # CONFIG_HAL_ASSERTION_ENABLE is not set +# default: CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 -CONFIG_HAL_SPI_MASTER_FUNC_IN_IRAM=y -CONFIG_HAL_SPI_SLAVE_FUNC_IN_IRAM=y +# default: +CONFIG_HAL_GPIO_USE_ROM_IMPL=y # end of Hardware Abstraction Layer (HAL) and Low Level (LL) # # Heap memory debugging # +# default: +CONFIG_HEAP_HAS_EXEC_HEAP=y CONFIG_HEAP_POISONING_DISABLED=y # CONFIG_HEAP_POISONING_LIGHT is not set # CONFIG_HEAP_POISONING_COMPREHENSIVE is not set @@ -1222,7 +1755,17 @@ CONFIG_HEAP_TRACING_OFF=y # end of Heap memory debugging # -# Log output +# Log +# +# default: +CONFIG_LOG_VERSION_1=y +# default: +# CONFIG_LOG_VERSION_2 is not set +# default: +CONFIG_LOG_VERSION=1 + +# +# Log Level # # CONFIG_LOG_DEFAULT_LEVEL_NONE is not set # CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set @@ -1230,23 +1773,61 @@ CONFIG_HEAP_TRACING_OFF=y CONFIG_LOG_DEFAULT_LEVEL_INFO=y # CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set +# default: CONFIG_LOG_DEFAULT_LEVEL=3 CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y # CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set # CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set +# default: CONFIG_LOG_MAXIMUM_LEVEL=3 + +# +# Level Settings +# # CONFIG_LOG_MASTER_LEVEL is not set +# default: +CONFIG_LOG_DYNAMIC_LEVEL_CONTROL=y +# default: +# CONFIG_LOG_TAG_LEVEL_IMPL_NONE is not set +# default: +# CONFIG_LOG_TAG_LEVEL_IMPL_LINKED_LIST is not set +# default: +CONFIG_LOG_TAG_LEVEL_IMPL_CACHE_AND_LINKED_LIST=y +# default: +# CONFIG_LOG_TAG_LEVEL_CACHE_ARRAY is not set +# default: +CONFIG_LOG_TAG_LEVEL_CACHE_BINARY_MIN_HEAP=y +# default: +CONFIG_LOG_TAG_LEVEL_IMPL_CACHE_SIZE=31 +# end of Level Settings +# end of Log Level + +# +# Format +# CONFIG_LOG_COLORS=y CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y # CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set -# end of Log output +# end of Format + +# +# Settings +# +# default: +CONFIG_LOG_MODE_TEXT_EN=y +# default: +CONFIG_LOG_MODE_TEXT=y +# end of Settings + +# default: +CONFIG_LOG_IN_IRAM=y +# end of Log # # LWIP # CONFIG_LWIP_ENABLE=y CONFIG_LWIP_LOCAL_HOSTNAME="U64-WiFi" -# CONFIG_LWIP_NETIF_API is not set CONFIG_LWIP_TCPIP_TASK_PRIO=18 # CONFIG_LWIP_TCPIP_CORE_LOCKING is not set # CONFIG_LWIP_CHECK_THREAD_SAFETY is not set @@ -1270,6 +1851,8 @@ CONFIG_LWIP_IP6_FRAG=y # CONFIG_LWIP_IP4_REASSEMBLY is not set # CONFIG_LWIP_IP6_REASSEMBLY is not set CONFIG_LWIP_IP_REASS_MAX_PBUFS=10 +# default: +CONFIG_LWIP_IPV6_DUP_DETECT_ATTEMPTS=1 # CONFIG_LWIP_IP_FORWARD is not set # CONFIG_LWIP_STATS is not set CONFIG_LWIP_ESP_GRATUITOUS_ARP=y @@ -1278,10 +1861,12 @@ CONFIG_LWIP_ESP_MLDV6_REPORT=y CONFIG_LWIP_MLDV6_TMR_INTERVAL=40 CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +# CONFIG_LWIP_DHCP_DOES_ACD_CHECK is not set +# CONFIG_LWIP_DHCP_DOES_NOT_CHECK_OFFERED_IP is not set # CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y # CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set -CONFIG_LWIP_DHCP_OPTIONS_LEN=68 +CONFIG_LWIP_DHCP_OPTIONS_LEN=69 CONFIG_LWIP_NUM_NETIF_CLIENT_DATA=0 CONFIG_LWIP_DHCP_COARSE_TIMER_SECS=1 @@ -1298,6 +1883,8 @@ CONFIG_LWIP_IPV6=y CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 # CONFIG_LWIP_IPV6_FORWARD is not set # CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set +# default: +# CONFIG_LWIP_NETIF_LINK_CALLBACK is not set CONFIG_LWIP_NETIF_LOOPBACK=y CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 @@ -1346,10 +1933,19 @@ CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y # CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set # CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set +# default: CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF -# CONFIG_LWIP_PPP_SUPPORT is not set CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 +# default: +CONFIG_LWIP_IPV6_ND6_NUM_PREFIXES=5 +# default: +CONFIG_LWIP_IPV6_ND6_NUM_ROUTERS=3 +# default: +CONFIG_LWIP_IPV6_ND6_NUM_DESTINATIONS=10 +# default: +# CONFIG_LWIP_IPV6_ND6_ROUTE_INFO_OPTION_SUPPORT is not set +# CONFIG_LWIP_PPP_SUPPORT is not set # CONFIG_LWIP_SLIP_SUPPORT is not set # @@ -1379,8 +1975,14 @@ CONFIG_LWIP_SNTP_MAXIMUM_STARTUP_DELAY=5000 # # DNS # +# default: +CONFIG_LWIP_DNS_MAX_HOST_IP=1 CONFIG_LWIP_DNS_MAX_SERVERS=3 # CONFIG_LWIP_FALLBACK_DNS_SERVER_SUPPORT is not set +# default: +# CONFIG_LWIP_DNS_SETSERVER_WITH_NETIF is not set +# default: +# CONFIG_LWIP_USE_ESP_GETADDRINFO is not set # end of DNS CONFIG_LWIP_BRIDGEIF_MAX_PORTS=7 @@ -1401,9 +2003,19 @@ CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_NONE=y # CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_DEFAULT is not set # CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_CUSTOM is not set +# default: +CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_NONE=y +# default: +# CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_DEFAULT is not set +# default: +# CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_CUSTOM is not set CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y # CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set # CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set +# default: +CONFIG_LWIP_HOOK_DNS_EXT_RESOLVE_NONE=y +# default: +# CONFIG_LWIP_HOOK_DNS_EXT_RESOLVE_CUSTOM is not set CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y # CONFIG_LWIP_HOOK_IP6_INPUT_DEFAULT is not set # CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM is not set @@ -1415,6 +2027,27 @@ CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y # # mbedTLS # + +# +# Core Configuration +# +# default: +CONFIG_MBEDTLS_VER_4_X_SUPPORT=y +# default: +# CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_NONE is not set +# default: +CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_SIZE=y +# default: +# CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_PERF is not set +# default: +# CONFIG_MBEDTLS_PSA_ITS_CUSTOM_STORAGE_BACKEND is not set +# CONFIG_MBEDTLS_THREADING_C is not set +CONFIG_MBEDTLS_ERROR_STRINGS=y +# default: +CONFIG_MBEDTLS_VERSION_C=y +CONFIG_MBEDTLS_HAVE_TIME=y +# CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set +# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y # CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set # CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set @@ -1422,161 +2055,259 @@ CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 # CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set +# default: +# CONFIG_MBEDTLS_VERSION_FEATURES is not set # CONFIG_MBEDTLS_DEBUG is not set +# default: +CONFIG_MBEDTLS_SELF_TEST=y +# end of Core Configuration # -# mbedTLS v3.x related +# Certificates # -# CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 is not set -# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set -# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set -# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set -CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y -CONFIG_MBEDTLS_PKCS7_C=y -# end of mbedTLS v3.x related +# default: +CONFIG_MBEDTLS_X509_USE_C=y +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +# default: +CONFIG_MBEDTLS_PK_C=y +# default: +CONFIG_MBEDTLS_PK_PARSE_C=y +# default: +CONFIG_MBEDTLS_PK_WRITE_C=y +# default: +# CONFIG_MBEDTLS_X509_REMOVE_INFO is not set +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +# default: +CONFIG_MBEDTLS_X509_CRT_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +# default: +# CONFIG_MBEDTLS_X509_CREATE_C is not set +# default: +CONFIG_MBEDTLS_X509_RSASSA_PSS_SUPPORT=y +CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK=y +# default: +CONFIG_MBEDTLS_ASN1_PARSE_C=y +# default: +CONFIG_MBEDTLS_ASN1_WRITE_C=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y # -# Certificate Bundle +# Certificate Bundle Configuration # -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set # CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEPRECATED_LIST is not set CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 -# end of Certificate Bundle +# end of Certificate Bundle Configuration -# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set -CONFIG_MBEDTLS_CMAC_C=y -CONFIG_MBEDTLS_HARDWARE_AES=y -CONFIG_MBEDTLS_GCM_SUPPORT_NON_AES_CIPHER=y -CONFIG_MBEDTLS_HARDWARE_MPI=y -# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set -CONFIG_MBEDTLS_HARDWARE_SHA=y -CONFIG_MBEDTLS_ROM_MD5=y -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set -CONFIG_MBEDTLS_HAVE_TIME=y -# CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set -# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set -CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y -CONFIG_MBEDTLS_SHA512_C=y +# default: +# CONFIG_MBEDTLS_ALLOW_WEAK_CERTIFICATE_VERIFICATION is not set +# default: +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y +# end of Certificates + +CONFIG_MBEDTLS_TLS_ENABLED=y + +# +# TLS Protocol Configuration +# +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 is not set +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set +# default: +CONFIG_MBEDTLS_TLS_SERVER=y +# default: +CONFIG_MBEDTLS_TLS_CLIENT=y CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y # CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set # CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set -# CONFIG_MBEDTLS_TLS_DISABLED is not set -CONFIG_MBEDTLS_TLS_SERVER=y -CONFIG_MBEDTLS_TLS_CLIENT=y -CONFIG_MBEDTLS_TLS_ENABLED=y +CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y +# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set +# default: +CONFIG_MBEDTLS_SSL_CACHE_C=y +# default: +CONFIG_MBEDTLS_SSL_ALL_ALERT_MESSAGES=y # -# TLS Key Exchange Methods +# TLS Key Exchange Configuration # # CONFIG_MBEDTLS_PSK_MODES is not set CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y -# end of TLS Key Exchange Methods +# end of TLS Key Exchange Configuration -CONFIG_MBEDTLS_SSL_RENEGOTIATION=y -CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y -# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set -# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +# default: +CONFIG_MBEDTLS_SSL_SERVER_NAME_INDICATION=y CONFIG_MBEDTLS_SSL_ALPN=y +# default: +CONFIG_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH=y +# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y +# default: +# CONFIG_MBEDTLS_SSL_KEYING_MATERIAL_EXPORT is not set +# end of TLS Protocol Configuration + +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set # # Symmetric Ciphers # CONFIG_MBEDTLS_AES_C=y # CONFIG_MBEDTLS_CAMELLIA_C is not set +# default: +# CONFIG_MBEDTLS_ARIA_C is not set # CONFIG_MBEDTLS_DES_C is not set -# CONFIG_MBEDTLS_BLOWFISH_C is not set -# CONFIG_MBEDTLS_XTEA_C is not set CONFIG_MBEDTLS_CCM_C=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_CBC=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_CFB=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_CTR=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_OFB=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_XTS=y CONFIG_MBEDTLS_GCM_C=y # CONFIG_MBEDTLS_NIST_KW_C is not set +# default: +CONFIG_MBEDTLS_AES_ROM_TABLES=y +# default: +# CONFIG_MBEDTLS_AES_FEWER_TABLES is not set +# default: +# CONFIG_MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH is not set +CONFIG_MBEDTLS_CMAC_C=y # end of Symmetric Ciphers -# CONFIG_MBEDTLS_RIPEMD160_C is not set - # -# Certificates +# Asymmetric Ciphers # -CONFIG_MBEDTLS_PEM_PARSE_C=y -CONFIG_MBEDTLS_PEM_WRITE_C=y -CONFIG_MBEDTLS_X509_CRL_PARSE_C=y -CONFIG_MBEDTLS_X509_CSR_PARSE_C=y -# end of Certificates - +# default: +CONFIG_MBEDTLS_RSA_C=y CONFIG_MBEDTLS_ECP_C=y -# CONFIG_MBEDTLS_DHM_C is not set -CONFIG_MBEDTLS_ECDH_C=y -CONFIG_MBEDTLS_ECDSA_C=y -# CONFIG_MBEDTLS_ECJPAKE_C is not set -CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y + +# +# Supported Curves +# CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +# end of Supported Curves + +# +# Elliptic Curve Ciphers Configuration +# CONFIG_MBEDTLS_ECP_NIST_OPTIM=y CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y -# CONFIG_MBEDTLS_POLY1305_C is not set -# CONFIG_MBEDTLS_CHACHA20_C is not set -# CONFIG_MBEDTLS_HKDF_C is not set -# CONFIG_MBEDTLS_THREADING_C is not set -CONFIG_MBEDTLS_ERROR_STRINGS=y -# end of mbedTLS +# CONFIG_MBEDTLS_DHM_C is not set +CONFIG_MBEDTLS_ECDH_C=y +# CONFIG_MBEDTLS_ECJPAKE_C is not set +CONFIG_MBEDTLS_ECDSA_C=y +# default: +CONFIG_MBEDTLS_PK_PARSE_EC_EXTENDED=y +# default: +CONFIG_MBEDTLS_PK_PARSE_EC_COMPRESSED=y +CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y +# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set +# end of Elliptic Curve Ciphers Configuration +# end of Asymmetric Ciphers # -# ESP-MQTT Configurations +# Hash functions # -CONFIG_MQTT_PROTOCOL_311=y -# CONFIG_MQTT_PROTOCOL_5 is not set -CONFIG_MQTT_TRANSPORT_SSL=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y -# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set -# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set -# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set -# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set -# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set -# CONFIG_MQTT_CUSTOM_OUTBOX is not set -# end of ESP-MQTT Configurations +# CONFIG_MBEDTLS_RIPEMD160_C is not set +# default: +CONFIG_MBEDTLS_MD_C=y +# default: +CONFIG_MBEDTLS_MD5_C=y +# default: +CONFIG_MBEDTLS_SHA1_C=y +# default: +# CONFIG_MBEDTLS_SHA224_C is not set +# default: +CONFIG_MBEDTLS_SHA256_C=y +# default: +CONFIG_MBEDTLS_SHA384_C=y +CONFIG_MBEDTLS_SHA512_C=y +# default: +# CONFIG_MBEDTLS_SHA3_C is not set +CONFIG_MBEDTLS_ROM_MD5=y +# end of Hash functions # -# Newlib +# Hardware Acceleration # -CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set -CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y -# CONFIG_NEWLIB_NANO_FORMAT is not set -CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y -# CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC is not set -# CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT is not set -# CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE is not set -# end of Newlib +CONFIG_MBEDTLS_HARDWARE_SHA=y +CONFIG_MBEDTLS_HARDWARE_MPI=y +# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set + +# +# Security hardening +# +# default: +# CONFIG_MBEDTLS_CONSTANT_TIME_PRIME_GEN is not set +# end of Security hardening + +CONFIG_MBEDTLS_HARDWARE_AES=y +# default: +# CONFIG_MBEDTLS_AES_SOFT_FALLBACK is not set +CONFIG_MBEDTLS_GCM_SUPPORT_NON_AES_CIPHER=y +# CONFIG_MBEDTLS_SECURE_ELEMENT_DRIVER_ENABLED is not set +# end of Hardware Acceleration + +# +# Entropy and Random Number Generation +# +# default: +# CONFIG_MBEDTLS_ENTROPY_FORCE_SHA256 is not set +# default: +CONFIG_MBEDTLS_CTR_DRBG_C=y +# default: +CONFIG_MBEDTLS_HMAC_DRBG_C=y +# end of Entropy and Random Number Generation + +# +# Encoding/Decoding +# +# default: +CONFIG_MBEDTLS_BASE64_C=y +# default: +CONFIG_MBEDTLS_PKCS5_C=y +CONFIG_MBEDTLS_PKCS7_C=y +# default: +CONFIG_MBEDTLS_PKCS1_V15=y +# default: +CONFIG_MBEDTLS_PKCS1_V21=y +# end of Encoding/Decoding + +# +# Stream Cipher +# +# CONFIG_MBEDTLS_CHACHA20_C is not set +# end of Stream Cipher +# end of mbedTLS # # NVS # # CONFIG_NVS_ASSERT_ERROR_CHECK is not set # CONFIG_NVS_LEGACY_DUP_KEYS_COMPATIBILITY is not set +# default: +# CONFIG_NVS_BDL_STACK is not set +# default: +# CONFIG_NVS_FLASH_VERIFY_ERASE is not set # end of NVS # @@ -1585,25 +2316,13 @@ CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y # CONFIG_OPENTHREAD_ENABLED is not set # -# Thread Operational Dataset +# OpenThread Spinel # -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread-ESP" -CONFIG_OPENTHREAD_MESH_LOCAL_PREFIX="fd00:db8:a0:0::/64" -CONFIG_OPENTHREAD_NETWORK_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_PANID=0x1234 -CONFIG_OPENTHREAD_NETWORK_EXTPANID="dead00beef00cafe" -CONFIG_OPENTHREAD_NETWORK_MASTERKEY="00112233445566778899aabbccddeeff" -CONFIG_OPENTHREAD_NETWORK_PSKC="104810e2315100afd6bc9215a6bfac53" -# end of Thread Operational Dataset - -CONFIG_OPENTHREAD_XTAL_ACCURACY=130 # CONFIG_OPENTHREAD_SPINEL_ONLY is not set -CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE=y +# end of OpenThread Spinel -# -# Thread Address Query Config -# -# end of Thread Address Query Config +# default: +# CONFIG_OPENTHREAD_DEBUG is not set # end of OpenThread # @@ -1612,6 +2331,8 @@ CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=y +# default: +CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_PATCH_VERSION=y # end of Protocomm # @@ -1623,15 +2344,26 @@ CONFIG_PTHREAD_STACK_MIN=768 CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y # CONFIG_PTHREAD_DEFAULT_CORE_0 is not set # CONFIG_PTHREAD_DEFAULT_CORE_1 is not set +# default: CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # end of PThreads +# +# SD Protocol Layer Configuration +# +# default: +CONFIG_SD_ENABLE_SDIO_SUPPORT=y +# end of SD Protocol Layer Configuration + # # MMU Config # +# default: CONFIG_MMU_PAGE_SIZE_64KB=y +# default: CONFIG_MMU_PAGE_MODE="64KB" +# default: CONFIG_MMU_PAGE_SIZE=0x10000 # end of MMU Config @@ -1643,6 +2375,7 @@ CONFIG_MMU_PAGE_SIZE=0x10000 # SPI Flash behavior when brownout # CONFIG_SPI_FLASH_BROWNOUT_RESET_XMC=y +# default: CONFIG_SPI_FLASH_BROWNOUT_RESET=y # end of SPI Flash behavior when brownout @@ -1654,6 +2387,12 @@ CONFIG_SPI_FLASH_BROWNOUT_RESET=y # Features here require specific hardware (READ DOCS FIRST!) # CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50 +# default: +# CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND is not set +# default: +# CONFIG_SPI_FLASH_FORCE_ENABLE_C6_H2_SUSPEND is not set +# default: +CONFIG_SPI_FLASH_PLACE_FUNCTIONS_IN_IRAM=y # end of Optional and Experimental Features (READ DOCS FIRST) # end of Main Flash configuration @@ -1662,7 +2401,6 @@ CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50 # # CONFIG_SPI_FLASH_VERIFY_WRITE is not set # CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set -CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y # CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set # CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set @@ -1679,11 +2417,16 @@ CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 # # Auto-detect flash chips # -CONFIG_SPI_FLASH_VENDOR_XMC_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_GD_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_ISSI_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_MXIC_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_WINBOND_SUPPORTED=y +# default: +CONFIG_SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED=y CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y @@ -1777,12 +2520,17 @@ CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y # CONFIG_VFS_SELECT_IN_RAM is not set CONFIG_VFS_SUPPORT_TERMIOS=y CONFIG_VFS_MAX_COUNT=8 +# default: +# CONFIG_VFS_SUPPRESS_CTX_DEPRECATION is not set # # Host File System I/O (Semihosting) # CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 # end of Host File System I/O (Semihosting) + +# default: +CONFIG_VFS_INITIALIZE_DEV_NULL=y # end of Virtual file system # @@ -1790,18 +2538,9 @@ CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 # # CONFIG_WL_SECTOR_SIZE_512 is not set CONFIG_WL_SECTOR_SIZE_4096=y +# default: CONFIG_WL_SECTOR_SIZE=4096 # end of Wear Levelling - -# -# Wi-Fi Provisioning Manager -# -CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 -CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 -# CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION is not set -CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y -# CONFIG_WIFI_PROV_STA_FAST_SCAN is not set -# end of Wi-Fi Provisioning Manager # end of Component config # CONFIG_IDF_EXPERIMENTAL_FEATURES is not set @@ -1812,6 +2551,8 @@ CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y # CONFIG_ESP32_NO_BLOBS is not set # CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set # CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set +# CONFIG_APP_ROLLBACK_ENABLE is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set # CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set # CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set # CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set @@ -1819,7 +2560,6 @@ CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y # CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set # CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set CONFIG_LOG_BOOTLOADER_LEVEL=3 -# CONFIG_APP_ROLLBACK_ENABLE is not set # CONFIG_FLASH_ENCRYPTION_ENABLED is not set # CONFIG_FLASHMODE_QIO is not set # CONFIG_FLASHMODE_QOUT is not set @@ -1841,11 +2581,12 @@ CONFIG_STACK_CHECK_NONE=y # CONFIG_STACK_CHECK_STRONG is not set # CONFIG_STACK_CHECK_ALL is not set # CONFIG_WARN_WRITE_STRINGS is not set -# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set -CONFIG_ESP32_APPTRACE_DEST_NONE=y -CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y -CONFIG_ADC2_DISABLE_DAC=y -# CONFIG_MCPWM_ISR_IN_IRAM is not set +CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y +CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y +CONFIG_ADC_CAL_LUT_ENABLE=y +CONFIG_ADC_DISABLE_DAC=y +# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set +# CONFIG_MCPWM_ISR_IRAM_SAFE is not set # CONFIG_EVENT_LOOP_PROFILING is not set CONFIG_POST_EVENTS_FROM_ISR=y CONFIG_POST_EVENTS_FROM_IRAM_ISR=y @@ -1867,10 +2608,48 @@ CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y # CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set # CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256 is not set CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 +CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y # CONFIG_ESP32_XTAL_FREQ_26 is not set CONFIG_ESP32_XTAL_FREQ_40=y # CONFIG_ESP32_XTAL_FREQ_AUTO is not set CONFIG_ESP32_XTAL_FREQ=40 +CONFIG_BROWNOUT_DET=y +CONFIG_ESP32_BROWNOUT_DET=y +CONFIG_BROWNOUT_DET_LVL_SEL_0=y +CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_7 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set +CONFIG_BROWNOUT_DET_LVL=0 +CONFIG_ESP32_BROWNOUT_DET_LVL=0 +CONFIG_ESP_SYSTEM_BROWNOUT_INTR=y +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set +CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y +CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y +CONFIG_ESP32_TIME_SYSCALL_USE_RTC_HRT=y +CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y +# CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set +# CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_HRT is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set +# CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y # CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 @@ -1879,6 +2658,13 @@ CONFIG_REDUCE_PHY_TX_POWER=y CONFIG_ESP32_REDUCE_PHY_TX_POWER=y # CONFIG_SPIRAM_SUPPORT is not set # CONFIG_ESP32_SPIRAM_SUPPORT is not set +CONFIG_CONSOLE_UART_DEFAULT=y +# CONFIG_CONSOLE_UART_CUSTOM is not set +# CONFIG_CONSOLE_UART_NONE is not set +# CONFIG_ESP_CONSOLE_UART_NONE is not set +CONFIG_CONSOLE_UART=y +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_BAUDRATE=115200 # CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y # CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set @@ -1891,13 +2677,6 @@ CONFIG_ESP32_PANIC_PRINT_REBOOT=y CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 CONFIG_MAIN_TASK_STACK_SIZE=3584 -CONFIG_CONSOLE_UART_DEFAULT=y -# CONFIG_CONSOLE_UART_CUSTOM is not set -# CONFIG_CONSOLE_UART_NONE is not set -# CONFIG_ESP_CONSOLE_UART_NONE is not set -CONFIG_CONSOLE_UART=y -CONFIG_CONSOLE_UART_NUM=0 -CONFIG_CONSOLE_UART_BAUDRATE=115200 CONFIG_INT_WDT=y CONFIG_INT_WDT_TIMEOUT_MS=300 CONFIG_INT_WDT_CHECK_CPU1=y @@ -1909,29 +2688,10 @@ CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y # CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set CONFIG_ESP32_DEBUG_OCDAWARE=y -CONFIG_BROWNOUT_DET=y -CONFIG_ESP32_BROWNOUT_DET=y -CONFIG_BROWNOUT_DET_LVL_SEL_0=y -CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y -# CONFIG_BROWNOUT_DET_LVL_SEL_1 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_7 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set -CONFIG_BROWNOUT_DET_LVL=0 -CONFIG_ESP32_BROWNOUT_DET_LVL=0 # CONFIG_DISABLE_BASIC_ROM_CONSOLE is not set CONFIG_IPC_TASK_STACK_SIZE=1024 CONFIG_TIMER_TASK_STACK_SIZE=3584 +# CONFIG_ESP32_APPTRACE_ENABLE is not set CONFIG_ESP32_WIFI_ENABLED=y CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 @@ -1943,8 +2703,6 @@ CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y CONFIG_ESP32_WIFI_TX_BA_WIN=6 CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y -CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y -CONFIG_ESP32_WIFI_RX_BA_WIN=6 CONFIG_ESP32_WIFI_RX_BA_WIN=6 CONFIG_ESP32_WIFI_NVS_ENABLED=y CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y @@ -1955,6 +2713,7 @@ CONFIG_ESP32_WIFI_IRAM_OPT=y CONFIG_ESP32_WIFI_RX_IRAM_OPT=y CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA=y +# CONFIG_ESP_WIFI_NAN_ENABLE is not set CONFIG_WPA_MBEDTLS_CRYPTO=y CONFIG_WPA_MBEDTLS_TLS_CLIENT=y # CONFIG_WPA_WAPI_PSK is not set @@ -1965,7 +2724,6 @@ CONFIG_WPA_MBEDTLS_TLS_CLIENT=y # CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set # CONFIG_WPA_WPS_STRICT is not set # CONFIG_WPA_DEBUG_PRINT is not set -# CONFIG_WPA_TESTING_OPTIONS is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y @@ -1996,12 +2754,8 @@ CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y # CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF # CONFIG_PPP_SUPPORT is not set -CONFIG_ESP32_TIME_SYSCALL_USE_RTC_HRT=y -CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y -# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set -# CONFIG_ESP32_TIME_SYSCALL_USE_HRT is not set -# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set -# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 CONFIG_ESP32_PTHREAD_STACK_MIN=768 From c646a44b1fec527aa201474f4cf5c054545b46a7 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 2 Oct 2026 08:55:07 -0500 Subject: [PATCH 13/95] Lock the mbedTLS key store in the U64 WiFi bridge (MBEDTLS_THREADING_C) On mbedTLS 4, PSA's key slots are protected by a mutex only with MBEDTLS_THREADING_C. It is ESP-IDF 6's default; the regenerated sdkconfig had carried 5.3.1's "not set". It makes PSA safe with more than one PSA user: the WiFi supplicant (ESP_WIFI_MBEDTLS_CRYPTO, on in this project) imports and destroys PSA keys now, and a TLS engine would be another. The pthread implementation comes with it. Co-Authored-By: Claude Opus 5.5 (1M context) --- software/wifi/raw_u64/sdkconfig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/software/wifi/raw_u64/sdkconfig b/software/wifi/raw_u64/sdkconfig index 444b61c7d..56aeb77f4 100644 --- a/software/wifi/raw_u64/sdkconfig +++ b/software/wifi/raw_u64/sdkconfig @@ -2041,7 +2041,11 @@ CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_SIZE=y # CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_PERF is not set # default: # CONFIG_MBEDTLS_PSA_ITS_CUSTOM_STORAGE_BACKEND is not set -# CONFIG_MBEDTLS_THREADING_C is not set +CONFIG_MBEDTLS_THREADING_C=y +# default: +# CONFIG_MBEDTLS_THREADING_ALT is not set +# default: +CONFIG_MBEDTLS_THREADING_PTHREAD=y CONFIG_MBEDTLS_ERROR_STRINGS=y # default: CONFIG_MBEDTLS_VERSION_C=y From f5ce67f504b803ca64c7bd0914ed31e8e2aad4c2 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 2 Oct 2026 11:25:03 -0500 Subject: [PATCH 14/95] Keep dropping WiFi packets quietly when the bridge has no UART buffer When no UART buffer is free, the receive hook returned ERR_BUF and wlanif_input() freed the packet. On ESP-IDF 5.3.1 the WiFi driver was then told ESP_OK; on ESP-IDF 6 esp_netif_receive() passes the error on, so the driver would see ESP_FAIL on this path. Stock ESP-IDF 6 already returns ESP_FAIL whenever lwIP's input mailbox is full, so the driver handles it; free the packet here and return ERR_OK only to leave this path exactly as before. The packet is dropped either way. Co-Authored-By: Claude Opus 5.5 (1M context) --- software/wifi/raw_u64/main/wifi_modem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/software/wifi/raw_u64/main/wifi_modem.c b/software/wifi/raw_u64/main/wifi_modem.c index 9276dd70b..0edba58f6 100644 --- a/software/wifi/raw_u64/main/wifi_modem.c +++ b/software/wifi/raw_u64/main/wifi_modem.c @@ -112,7 +112,8 @@ static err_t hacked_recv(struct pbuf *p, struct netif *inp) return ERR_OK; } else { ESP_LOGW(TAG, "No buffer to send packet."); - return ERR_BUF; + pbuf_free(p); // dropped, and reported as handled + return ERR_OK; } } else { // dropped, wrong mac and no broadcast pbuf_free(p); From 4b3f7aaebe20cbf1aeff097d4631694fce4b0231 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Sat, 24 Oct 2026 22:19:52 -0500 Subject: [PATCH 15/95] Keep FreeRTOS and the ring buffer in IRAM in the U64 WiFi bridge ESP-IDF 6 moved the FreeRTOS queue/task and ring buffer functions to flash by default (CONFIG_FREERTOS_IN_IRAM and CONFIG_RINGBUF_IN_IRAM are off); ESP-IDF 5.3.1 had them in IRAM. Every frame passes xQueueGenericSend, xQueueReceive and xRingbufferReceive in both directions, so each call can wait on a flash cache miss. Set both options to put them back in IRAM (about 10.6 KB more IRAM; 31,197 B of 131,072 stay free). Measured on a U64E over WiFi, one leg per image (the same suite and commands in each): with these two options the writemem latency (p50, p90, p99 = 35.8, 82.5, 155.8 ms) is back in the range of the IDF 5.3.1 image (34.0-35.7, 75.6-85.0, 135.7-158.5 ms); without them it was 40.8, 102.2, 202.7 ms. The REST probe only moves part of the way back (p50 91.3 ms against 75.6-76.7 on 5.3.1 and 96.7 without), and the FTP get is not restored. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/sdkconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/software/wifi/raw_u64/sdkconfig b/software/wifi/raw_u64/sdkconfig index 56aeb77f4..2e6ce67be 100644 --- a/software/wifi/raw_u64/sdkconfig +++ b/software/wifi/raw_u64/sdkconfig @@ -964,6 +964,8 @@ CONFIG_RMT_OBJ_CACHE_SAFE=y # # ESP-Driver:SPI Configurations # +# default: +# CONFIG_SPI_MASTER_IN_IRAM is not set CONFIG_SPI_MASTER_ISR_IN_IRAM=y # CONFIG_SPI_SLAVE_IN_IRAM is not set CONFIG_SPI_SLAVE_ISR_IN_IRAM=y @@ -1359,9 +1361,7 @@ CONFIG_PM_SLP_IRAM_OPT=y # ESP Ringbuf # # default: -# CONFIG_RINGBUF_IN_IRAM is not set -# default: -# CONFIG_RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH is not set +CONFIG_RINGBUF_IN_IRAM=y # end of ESP Ringbuf # @@ -1703,7 +1703,7 @@ CONFIG_FREERTOS_CORETIMER_0=y # default: CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y # default: -# CONFIG_FREERTOS_IN_IRAM is not set +CONFIG_FREERTOS_IN_IRAM=y # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set # end of Port From 14630efe6e77a6ef40126c672227932a50e9ec85 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 20 Oct 2026 20:59:51 -0500 Subject: [PATCH 16/95] Build the U2+L WiFi bridge (raw_c3) with ESP-IDF 6.0.3 (build-only, untested) Same IDF 6 fixes as raw_u64: uart_periph.h moved to hal/, uart_isr_handle_t is gone, CMake 3.16 and an IDF >= 6 check, the receive hook frees the pbuf and returns ERR_OK when no UART buffer is free, and MBEDTLS_THREADING_C on. sdkconfig is regenerated by idf.py reconfigure. The version is bumped to 1.7 only to label the image: the U2+L updater does not compare it. Built only: no U2+L hardware, never flashed or run. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_c3/CMakeLists.txt | 5 +- software/wifi/raw_c3/main/my_uart.c | 4 +- software/wifi/raw_c3/main/rpc_dispatch.h | 5 +- software/wifi/raw_c3/main/wifi_modem.c | 3 +- software/wifi/raw_c3/sdkconfig | 1519 +++++++++++++++++----- 5 files changed, 1196 insertions(+), 340 deletions(-) diff --git a/software/wifi/raw_c3/CMakeLists.txt b/software/wifi/raw_c3/CMakeLists.txt index a8abcf637..8856ac62d 100644 --- a/software/wifi/raw_c3/CMakeLists.txt +++ b/software/wifi/raw_c3/CMakeLists.txt @@ -1,6 +1,9 @@ # The following lines of boilerplate have to be in your project's CMakeLists # in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) +if(IDF_VERSION_MAJOR LESS 6) + message(FATAL_ERROR "raw_c3 needs ESP-IDF 6, not ${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR} (see software/wifi/raw_c3/README.md)") +endif() project(bridge) diff --git a/software/wifi/raw_c3/main/my_uart.c b/software/wifi/raw_c3/main/my_uart.c index 3dadc9529..99a15f869 100644 --- a/software/wifi/raw_c3/main/my_uart.c +++ b/software/wifi/raw_c3/main/my_uart.c @@ -23,7 +23,7 @@ #include "freertos/ringbuf.h" #include "hal/uart_hal.h" #include "hal/gpio_hal.h" -#include "soc/uart_periph.h" +#include "hal/uart_periph.h" #include "soc/rtc_cntl_reg.h" #include "driver/uart.h" #include "driver/gpio.h" @@ -368,7 +368,7 @@ BaseType_t my_uart_get_buffer(uint8_t uart_num, command_buf_t **buf, TickType_t } #include "esp_check.h" -esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void *), void *arg, int intr_alloc_flags, uart_isr_handle_t *handle) +esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn)(void *), void *arg, int intr_alloc_flags, intr_handle_t *handle) { int ret; ESP_RETURN_ON_FALSE((uart_num < UART_NUM_MAX), ESP_FAIL, UART_TAG, "uart_num error"); diff --git a/software/wifi/raw_c3/main/rpc_dispatch.h b/software/wifi/raw_c3/main/rpc_dispatch.h index aad4296ad..ca36e1e81 100644 --- a/software/wifi/raw_c3/main/rpc_dispatch.h +++ b/software/wifi/raw_c3/main/rpc_dispatch.h @@ -24,15 +24,16 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.7" +#define IDENT_STRING "ESP32 WiFi Bridge V1.8" #define IDENT_MAJOR 1 +// 1.8: built with ESP-IDF 6.0.3. Labels the image; the U2+L updater does not compare it. // 1.7: terminates 32-character SSIDs and 64-character passwords, and reads // them back from NVS whole. // 1.6: the connector retries after a dropped link instead of idling in // Disconnected forever. The Ultimate's updater only reflashes the module // when this differs from what the module reports, so a module change that // does not bump it is silently never installed. -#define IDENT_MINOR 7 +#define IDENT_MINOR 8 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 diff --git a/software/wifi/raw_c3/main/wifi_modem.c b/software/wifi/raw_c3/main/wifi_modem.c index 9276dd70b..0edba58f6 100644 --- a/software/wifi/raw_c3/main/wifi_modem.c +++ b/software/wifi/raw_c3/main/wifi_modem.c @@ -112,7 +112,8 @@ static err_t hacked_recv(struct pbuf *p, struct netif *inp) return ERR_OK; } else { ESP_LOGW(TAG, "No buffer to send packet."); - return ERR_BUF; + pbuf_free(p); // dropped, and reported as handled + return ERR_OK; } } else { // dropped, wrong mac and no broadcast pbuf_free(p); diff --git a/software/wifi/raw_c3/sdkconfig b/software/wifi/raw_c3/sdkconfig index fccff6441..4ba9edecf 100644 --- a/software/wifi/raw_c3/sdkconfig +++ b/software/wifi/raw_c3/sdkconfig @@ -1,290 +1,528 @@ # # Automatically generated file. DO NOT EDIT. -# Espressif IoT Development Framework (ESP-IDF) 5.3.1 Project Configuration +# Espressif IoT Development Framework (ESP-IDF) 6.0.3 Project Configuration # +# default: CONFIG_SOC_ADC_SUPPORTED=y +# default: CONFIG_SOC_DEDICATED_GPIO_SUPPORTED=y +# default: CONFIG_SOC_UART_SUPPORTED=y +# default: CONFIG_SOC_GDMA_SUPPORTED=y +# default: +CONFIG_SOC_UHCI_SUPPORTED=y +# default: CONFIG_SOC_AHB_GDMA_SUPPORTED=y +# default: CONFIG_SOC_GPTIMER_SUPPORTED=y +# default: CONFIG_SOC_TWAI_SUPPORTED=y +# default: CONFIG_SOC_BT_SUPPORTED=y +# default: CONFIG_SOC_ASYNC_MEMCPY_SUPPORTED=y +# default: CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED=y +# default: CONFIG_SOC_TEMP_SENSOR_SUPPORTED=y +# default: CONFIG_SOC_XT_WDT_SUPPORTED=y +# default: CONFIG_SOC_PHY_SUPPORTED=y +# default: CONFIG_SOC_WIFI_SUPPORTED=y +# default: CONFIG_SOC_SUPPORTS_SECURE_DL_MODE=y +# default: CONFIG_SOC_EFUSE_KEY_PURPOSE_FIELD=y +# default: CONFIG_SOC_EFUSE_HAS_EFUSE_RST_BUG=y +# default: CONFIG_SOC_EFUSE_SUPPORTED=y +# default: CONFIG_SOC_RTC_FAST_MEM_SUPPORTED=y +# default: CONFIG_SOC_RTC_MEM_SUPPORTED=y +# default: +CONFIG_SOC_RTC_TIMER_V1_SUPPORTED=y +# default: CONFIG_SOC_I2S_SUPPORTED=y +# default: CONFIG_SOC_RMT_SUPPORTED=y +# default: CONFIG_SOC_SDM_SUPPORTED=y +# default: CONFIG_SOC_GPSPI_SUPPORTED=y +# default: CONFIG_SOC_LEDC_SUPPORTED=y +# default: CONFIG_SOC_I2C_SUPPORTED=y +# default: CONFIG_SOC_SYSTIMER_SUPPORTED=y +# default: CONFIG_SOC_SUPPORT_COEXISTENCE=y +# default: CONFIG_SOC_AES_SUPPORTED=y +# default: CONFIG_SOC_MPI_SUPPORTED=y +# default: CONFIG_SOC_SHA_SUPPORTED=y +# default: CONFIG_SOC_HMAC_SUPPORTED=y +# default: CONFIG_SOC_DIG_SIGN_SUPPORTED=y +# default: CONFIG_SOC_FLASH_ENC_SUPPORTED=y +# default: CONFIG_SOC_SECURE_BOOT_SUPPORTED=y +# default: CONFIG_SOC_MEMPROT_SUPPORTED=y +# default: CONFIG_SOC_BOD_SUPPORTED=y +# default: CONFIG_SOC_CLK_TREE_SUPPORTED=y +# default: CONFIG_SOC_ASSIST_DEBUG_SUPPORTED=y +# default: CONFIG_SOC_WDT_SUPPORTED=y +# default: CONFIG_SOC_SPI_FLASH_SUPPORTED=y +# default: CONFIG_SOC_RNG_SUPPORTED=y +# default: CONFIG_SOC_LIGHT_SLEEP_SUPPORTED=y +# default: CONFIG_SOC_DEEP_SLEEP_SUPPORTED=y +# default: CONFIG_SOC_LP_PERIPH_SHARE_INTERRUPT=y +# default: CONFIG_SOC_PM_SUPPORTED=y +# default: CONFIG_SOC_XTAL_SUPPORT_40M=y +# default: CONFIG_SOC_AES_SUPPORT_DMA=y +# default: CONFIG_SOC_AES_GDMA=y +# default: CONFIG_SOC_AES_SUPPORT_AES_128=y +# default: CONFIG_SOC_AES_SUPPORT_AES_256=y +# default: CONFIG_SOC_ADC_DIG_CTRL_SUPPORTED=y +# default: CONFIG_SOC_ADC_ARBITER_SUPPORTED=y +# default: CONFIG_SOC_ADC_DIG_IIR_FILTER_SUPPORTED=y +# default: CONFIG_SOC_ADC_MONITOR_SUPPORTED=y +# default: CONFIG_SOC_ADC_DMA_SUPPORTED=y +# default: CONFIG_SOC_ADC_PERIPH_NUM=2 +# default: CONFIG_SOC_ADC_MAX_CHANNEL_NUM=5 +# default: CONFIG_SOC_ADC_ATTEN_NUM=4 +# default: CONFIG_SOC_ADC_DIGI_CONTROLLER_NUM=1 +# default: CONFIG_SOC_ADC_PATT_LEN_MAX=8 +# default: CONFIG_SOC_ADC_DIGI_MIN_BITWIDTH=12 +# default: CONFIG_SOC_ADC_DIGI_MAX_BITWIDTH=12 +# default: CONFIG_SOC_ADC_DIGI_RESULT_BYTES=4 +# default: CONFIG_SOC_ADC_DIGI_DATA_BYTES_PER_CONV=4 +# default: CONFIG_SOC_ADC_DIGI_IIR_FILTER_NUM=2 +# default: CONFIG_SOC_ADC_DIGI_MONITOR_NUM=2 +# default: CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_HIGH=83333 +# default: CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_LOW=611 +# default: CONFIG_SOC_ADC_RTC_MIN_BITWIDTH=12 +# default: CONFIG_SOC_ADC_RTC_MAX_BITWIDTH=12 +# default: CONFIG_SOC_ADC_CALIBRATION_V1_SUPPORTED=y +# default: CONFIG_SOC_ADC_SELF_HW_CALI_SUPPORTED=y +# default: CONFIG_SOC_ADC_SHARED_POWER=y +# default: CONFIG_SOC_APB_BACKUP_DMA=y +# default: CONFIG_SOC_BROWNOUT_RESET_SUPPORTED=y +# default: CONFIG_SOC_SHARED_IDCACHE_SUPPORTED=y +# default: +CONFIG_SOC_CACHE_FREEZE_SUPPORTED=y +# default: CONFIG_SOC_CACHE_MEMORY_IBANK_SIZE=0x4000 +# default: CONFIG_SOC_CPU_CORES_NUM=1 +# default: CONFIG_SOC_CPU_INTR_NUM=32 +# default: CONFIG_SOC_CPU_HAS_FLEXIBLE_INTC=y +# default: CONFIG_SOC_CPU_HAS_CSR_PC=y +# default: CONFIG_SOC_CPU_BREAKPOINTS_NUM=8 +# default: CONFIG_SOC_CPU_WATCHPOINTS_NUM=8 +# default: CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=0x80000000 +# default: CONFIG_SOC_DS_SIGNATURE_MAX_BIT_LEN=3072 +# default: CONFIG_SOC_DS_KEY_PARAM_MD_IV_LENGTH=16 +# default: CONFIG_SOC_DS_KEY_CHECK_MAX_WAIT_US=1100 +# default: CONFIG_SOC_AHB_GDMA_VERSION=1 -CONFIG_SOC_GDMA_NUM_GROUPS_MAX=1 -CONFIG_SOC_GDMA_PAIRS_PER_GROUP_MAX=3 +# default: CONFIG_SOC_GPIO_PORT=1 +# default: CONFIG_SOC_GPIO_PIN_COUNT=22 +# default: CONFIG_SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER=y -CONFIG_SOC_GPIO_FILTER_CLK_SUPPORT_APB=y +# default: CONFIG_SOC_GPIO_SUPPORT_FORCE_HOLD=y -CONFIG_SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP=y +# default: +CONFIG_SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP=y +# default: CONFIG_SOC_GPIO_IN_RANGE_MAX=21 +# default: CONFIG_SOC_GPIO_OUT_RANGE_MAX=21 -CONFIG_SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK=0 -CONFIG_SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT=6 +# default: +CONFIG_SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK=0 +# default: +CONFIG_SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_PIN_CNT=6 +# default: CONFIG_SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK=0x00000000003FFFC0 +# default: CONFIG_SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX=y +# default: CONFIG_SOC_GPIO_CLOCKOUT_CHANNEL_NUM=3 -CONFIG_SOC_DEDIC_GPIO_OUT_CHANNELS_NUM=8 -CONFIG_SOC_DEDIC_GPIO_IN_CHANNELS_NUM=8 -CONFIG_SOC_DEDIC_PERIPH_ALWAYS_ENABLE=y +# default: CONFIG_SOC_I2C_NUM=1 +# default: CONFIG_SOC_HP_I2C_NUM=1 -CONFIG_SOC_I2C_FIFO_LEN=32 -CONFIG_SOC_I2C_CMD_REG_NUM=8 -CONFIG_SOC_I2C_SUPPORT_SLAVE=y -CONFIG_SOC_I2C_SUPPORT_HW_CLR_BUS=y +# default: CONFIG_SOC_I2C_SUPPORT_XTAL=y +# default: CONFIG_SOC_I2C_SUPPORT_RTC=y +# default: CONFIG_SOC_I2C_SUPPORT_10BIT_ADDR=y +# default: +CONFIG_SOC_I2C_SUPPORT_SLAVE=y +# default: CONFIG_SOC_I2C_SLAVE_SUPPORT_BROADCAST=y +# default: CONFIG_SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE=y -CONFIG_SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS=y -CONFIG_SOC_I2S_NUM=1 +# default: CONFIG_SOC_I2S_HW_VERSION_2=y -CONFIG_SOC_I2S_SUPPORTS_XTAL=y -CONFIG_SOC_I2S_SUPPORTS_PLL_F160M=y +# default: CONFIG_SOC_I2S_SUPPORTS_PCM=y +# default: CONFIG_SOC_I2S_SUPPORTS_PDM=y +# default: CONFIG_SOC_I2S_SUPPORTS_PDM_TX=y +# default: +CONFIG_SOC_I2S_SUPPORTS_PCM2PDM=y +# default: +CONFIG_SOC_I2S_SUPPORTS_PDM_RX=y +# default: CONFIG_SOC_I2S_PDM_MAX_TX_LINES=2 +# default: +CONFIG_SOC_I2S_PDM_MAX_RX_LINES=1 +# default: CONFIG_SOC_I2S_SUPPORTS_TDM=y +# default: CONFIG_SOC_LEDC_SUPPORT_APB_CLOCK=y +# default: CONFIG_SOC_LEDC_SUPPORT_XTAL_CLOCK=y +# default: +CONFIG_SOC_LEDC_TIMER_NUM=4 +# default: CONFIG_SOC_LEDC_CHANNEL_NUM=6 +# default: CONFIG_SOC_LEDC_TIMER_BIT_WIDTH=14 +# default: CONFIG_SOC_LEDC_SUPPORT_FADE_STOP=y +# default: CONFIG_SOC_MMU_LINEAR_ADDRESS_REGION_NUM=1 +# default: CONFIG_SOC_MMU_PERIPH_NUM=1 +# default: CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000 +# default: CONFIG_SOC_MPU_REGIONS_MAX_NUM=8 -CONFIG_SOC_RMT_GROUPS=1 -CONFIG_SOC_RMT_TX_CANDIDATES_PER_GROUP=2 -CONFIG_SOC_RMT_RX_CANDIDATES_PER_GROUP=2 -CONFIG_SOC_RMT_CHANNELS_PER_GROUP=4 +# default: CONFIG_SOC_RMT_MEM_WORDS_PER_CHANNEL=48 +# default: CONFIG_SOC_RMT_SUPPORT_RX_PINGPONG=y -CONFIG_SOC_RMT_SUPPORT_RX_DEMODULATION=y -CONFIG_SOC_RMT_SUPPORT_TX_ASYNC_STOP=y +# default: CONFIG_SOC_RMT_SUPPORT_TX_LOOP_COUNT=y -CONFIG_SOC_RMT_SUPPORT_TX_SYNCHRO=y -CONFIG_SOC_RMT_SUPPORT_TX_CARRIER_DATA_ONLY=y -CONFIG_SOC_RMT_SUPPORT_XTAL=y -CONFIG_SOC_RMT_SUPPORT_APB=y -CONFIG_SOC_RMT_SUPPORT_RC_FAST=y +# default: CONFIG_SOC_RTC_CNTL_CPU_PD_DMA_BUS_WIDTH=128 +# default: CONFIG_SOC_RTC_CNTL_CPU_PD_REG_FILE_NUM=108 +# default: +CONFIG_SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS=y +# default: CONFIG_SOC_SLEEP_SYSTIMER_STALL_WORKAROUND=y +# default: CONFIG_SOC_SLEEP_TGWDT_STOP_WORKAROUND=y +# default: CONFIG_SOC_RTCIO_PIN_COUNT=0 +# default: CONFIG_SOC_MPI_MEM_BLOCKS_NUM=4 +# default: CONFIG_SOC_MPI_OPERATIONS_NUM=3 +# default: CONFIG_SOC_RSA_MAX_BIT_LEN=3072 +# default: CONFIG_SOC_SHA_DMA_MAX_BUFFER_SIZE=3968 +# default: CONFIG_SOC_SHA_SUPPORT_DMA=y +# default: CONFIG_SOC_SHA_SUPPORT_RESUME=y +# default: CONFIG_SOC_SHA_GDMA=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA1=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA224=y +# default: CONFIG_SOC_SHA_SUPPORT_SHA256=y -CONFIG_SOC_SDM_GROUPS=1 -CONFIG_SOC_SDM_CHANNELS_PER_GROUP=4 -CONFIG_SOC_SDM_CLK_SUPPORT_APB=y +# default: CONFIG_SOC_SPI_PERIPH_NUM=2 +# default: CONFIG_SOC_SPI_MAX_CS_NUM=6 +# default: CONFIG_SOC_SPI_MAXIMUM_BUFFER_SIZE=64 +# default: CONFIG_SOC_SPI_SUPPORT_DDRCLK=y +# default: CONFIG_SOC_SPI_SLAVE_SUPPORT_SEG_TRANS=y +# default: CONFIG_SOC_SPI_SUPPORT_CD_SIG=y +# default: CONFIG_SOC_SPI_SUPPORT_CONTINUOUS_TRANS=y +# default: CONFIG_SOC_SPI_SUPPORT_SLAVE_HD_VER2=y +# default: CONFIG_SOC_SPI_SUPPORT_CLK_APB=y +# default: CONFIG_SOC_SPI_SUPPORT_CLK_XTAL=y +# default: CONFIG_SOC_SPI_PERIPH_SUPPORT_CONTROL_DUMMY_OUT=y +# default: CONFIG_SOC_SPI_SCT_SUPPORTED=y +# default: CONFIG_SOC_SPI_SCT_REG_NUM=14 +# default: CONFIG_SOC_SPI_SCT_BUFFER_NUM_MAX=y +# default: CONFIG_SOC_SPI_SCT_CONF_BITLEN_MAX=0x3FFFA +# default: CONFIG_SOC_MEMSPI_IS_INDEPENDENT=y +# default: CONFIG_SOC_SPI_MAX_PRE_DIVIDER=16 +# default: CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_SUSPEND=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_RESUME=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_IDLE_INTR=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_SW_SUSPEND=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_CHECK_SUS=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE=y +# default: CONFIG_SOC_SPI_MEM_SUPPORT_WRAP=y -CONFIG_SOC_MEMSPI_SRC_FREQ_80M_SUPPORTED=y -CONFIG_SOC_MEMSPI_SRC_FREQ_40M_SUPPORTED=y -CONFIG_SOC_MEMSPI_SRC_FREQ_26M_SUPPORTED=y -CONFIG_SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED=y +# default: CONFIG_SOC_SYSTIMER_COUNTER_NUM=2 +# default: CONFIG_SOC_SYSTIMER_ALARM_NUM=3 +# default: CONFIG_SOC_SYSTIMER_BIT_WIDTH_LO=32 +# default: CONFIG_SOC_SYSTIMER_BIT_WIDTH_HI=20 +# default: CONFIG_SOC_SYSTIMER_FIXED_DIVIDER=y +# default: CONFIG_SOC_SYSTIMER_INT_LEVEL=y +# default: CONFIG_SOC_SYSTIMER_ALARM_MISS_COMPENSATE=y -CONFIG_SOC_TIMER_GROUPS=2 -CONFIG_SOC_TIMER_GROUP_TIMERS_PER_GROUP=1 -CONFIG_SOC_TIMER_GROUP_COUNTER_BIT_WIDTH=54 -CONFIG_SOC_TIMER_GROUP_SUPPORT_XTAL=y -CONFIG_SOC_TIMER_GROUP_SUPPORT_APB=y -CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=2 +# default: +CONFIG_SOC_MEMSPI_ENCRYPTION_ALIGNMENT=16 +# default: +CONFIG_SOC_LP_TIMER_BIT_WIDTH_LO=32 +# default: +CONFIG_SOC_LP_TIMER_BIT_WIDTH_HI=16 +# default: CONFIG_SOC_MWDT_SUPPORT_XTAL=y +# default: CONFIG_SOC_TWAI_CONTROLLER_NUM=1 -CONFIG_SOC_TWAI_CLK_SUPPORT_APB=y -CONFIG_SOC_TWAI_BRP_MIN=2 -CONFIG_SOC_TWAI_BRP_MAX=16384 -CONFIG_SOC_TWAI_SUPPORTS_RX_STATUS=y +# default: +CONFIG_SOC_TWAI_MASK_FILTER_NUM=1 +# default: CONFIG_SOC_EFUSE_DIS_DOWNLOAD_ICACHE=y +# default: CONFIG_SOC_EFUSE_DIS_PAD_JTAG=y +# default: CONFIG_SOC_EFUSE_DIS_USB_JTAG=y +# default: CONFIG_SOC_EFUSE_DIS_DIRECT_BOOT=y +# default: CONFIG_SOC_EFUSE_SOFT_DIS_JTAG=y +# default: CONFIG_SOC_EFUSE_DIS_ICACHE=y +# default: CONFIG_SOC_EFUSE_BLOCK9_KEY_PURPOSE_QUIRK=y +# default: +CONFIG_SOC_EFUSE_XTS_AES_KEY_128=y +# default: CONFIG_SOC_SECURE_BOOT_V2_RSA=y +# default: CONFIG_SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS=3 +# default: CONFIG_SOC_EFUSE_REVOKE_BOOT_KEY_DIGESTS=y +# default: CONFIG_SOC_SUPPORT_SECURE_BOOT_REVOKE_KEY=y +# default: CONFIG_SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX=32 +# default: CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES=y +# default: CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES_128=y +# default: CONFIG_SOC_MEMPROT_CPU_PREFETCH_PAD_SIZE=16 +# default: CONFIG_SOC_MEMPROT_MEM_ALIGN_SIZE=512 +# default: CONFIG_SOC_UART_NUM=2 +# default: CONFIG_SOC_UART_HP_NUM=2 +# default: CONFIG_SOC_UART_FIFO_LEN=128 +# default: CONFIG_SOC_UART_BITRATE_MAX=5000000 +# default: CONFIG_SOC_UART_SUPPORT_APB_CLK=y +# default: CONFIG_SOC_UART_SUPPORT_RTC_CLK=y +# default: CONFIG_SOC_UART_SUPPORT_XTAL_CLK=y +# default: CONFIG_SOC_UART_SUPPORT_WAKEUP_INT=y -CONFIG_SOC_UART_SUPPORT_FSM_TX_WAIT_SEND=y +# default: +CONFIG_SOC_UART_WAKEUP_SUPPORT_ACTIVE_THRESH_MODE=y +# default: +CONFIG_SOC_UHCI_NUM=1 +# default: CONFIG_SOC_COEX_HW_PTI=y +# default: CONFIG_SOC_PHY_DIG_REGS_MEM_SIZE=21 +# default: CONFIG_SOC_MAC_BB_PD_MEM_SIZE=192 +# default: CONFIG_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH=12 +# default: CONFIG_SOC_PM_SUPPORT_WIFI_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_BT_WAKEUP=y +# default: CONFIG_SOC_PM_SUPPORT_CPU_PD=y +# default: CONFIG_SOC_PM_SUPPORT_WIFI_PD=y +# default: CONFIG_SOC_PM_SUPPORT_BT_PD=y +# default: CONFIG_SOC_PM_SUPPORT_RC_FAST_PD=y +# default: CONFIG_SOC_PM_SUPPORT_VDDSDIO_PD=y +# default: CONFIG_SOC_PM_SUPPORT_MAC_BB_PD=y +# default: CONFIG_SOC_PM_CPU_RETENTION_BY_RTCCNTL=y +# default: CONFIG_SOC_PM_MODEM_RETENTION_BY_BACKUPDMA=y +# default: +CONFIG_SOC_PM_MODEM_PD_BY_SW=y +# default: CONFIG_SOC_CLK_RC_FAST_D256_SUPPORTED=y +# default: CONFIG_SOC_RTC_SLOW_CLK_SUPPORT_RC_FAST_D256=y +# default: CONFIG_SOC_CLK_RC_FAST_SUPPORT_CALIBRATION=y +# default: CONFIG_SOC_CLK_XTAL32K_SUPPORTED=y +# default: +CONFIG_SOC_CLK_LP_FAST_SUPPORT_XTAL_D2=y +# default: CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC=y +# default: CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_XTAL=y +# default: CONFIG_SOC_WIFI_HW_TSF=y +# default: CONFIG_SOC_WIFI_FTM_SUPPORT=y +# default: CONFIG_SOC_WIFI_GCMP_SUPPORT=y +# default: CONFIG_SOC_WIFI_WAPI_SUPPORT=y +# default: +CONFIG_SOC_WIFI_TXOP_SUPPORT=y +# default: CONFIG_SOC_WIFI_CSI_SUPPORT=y +# default: CONFIG_SOC_WIFI_MESH_SUPPORT=y +# default: CONFIG_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y +# default: CONFIG_SOC_WIFI_PHY_NEEDS_USB_WORKAROUND=y +# default: CONFIG_SOC_BLE_SUPPORTED=y +# default: CONFIG_SOC_BLE_MESH_SUPPORTED=y +# default: CONFIG_SOC_BLE_50_SUPPORTED=y +# default: CONFIG_SOC_BLE_DEVICE_PRIVACY_SUPPORTED=y +# default: CONFIG_SOC_BLUFI_SUPPORTED=y +# default: CONFIG_SOC_PHY_COMBO_MODULE=y +# default: CONFIG_IDF_CMAKE=y +# default: CONFIG_IDF_TOOLCHAIN="gcc" +# default: +CONFIG_IDF_TOOLCHAIN_GCC=y +# default: CONFIG_IDF_TARGET_ARCH_RISCV=y +# default: CONFIG_IDF_TARGET_ARCH="riscv" +# default: CONFIG_IDF_TARGET="esp32c3" +# default: CONFIG_IDF_INIT_VERSION="5.3.1" +# default: CONFIG_IDF_TARGET_ESP32C3=y +# default: CONFIG_IDF_FIRMWARE_CHIP_ID=0x0005 # @@ -292,13 +530,21 @@ CONFIG_IDF_FIRMWARE_CHIP_ID=0x0005 # CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y # CONFIG_APP_BUILD_TYPE_RAM is not set +# default: CONFIG_APP_BUILD_GENERATE_BINARIES=y +# default: CONFIG_APP_BUILD_BOOTLOADER=y +# default: CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y # CONFIG_APP_REPRODUCIBLE_BUILD is not set # CONFIG_APP_NO_BLOBS is not set # end of Build type +# +# App Update config +# +# end of App Update config + # # Bootloader config # @@ -310,19 +556,61 @@ CONFIG_BOOTLOADER_COMPILE_TIME_DATE=y CONFIG_BOOTLOADER_PROJECT_VER=1 # end of Bootloader manager +# +# Application Rollback +# +# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set +# end of Application Rollback + +# +# Recovery Bootloader and Rollback +# +# end of Recovery Bootloader and Rollback + +# default: CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set + +# +# Log +# +# default: +CONFIG_BOOTLOADER_LOG_VERSION_1=y +# default: +CONFIG_BOOTLOADER_LOG_VERSION=1 # CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set # CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set +# default: CONFIG_BOOTLOADER_LOG_LEVEL=3 +# +# Format +# +# default: +# CONFIG_BOOTLOADER_LOG_COLORS is not set +# default: +CONFIG_BOOTLOADER_LOG_TIMESTAMP_SOURCE_CPU_TICKS=y +# end of Format + +# +# Settings +# +# default: +CONFIG_BOOTLOADER_LOG_MODE_TEXT_EN=y +# default: +CONFIG_BOOTLOADER_LOG_MODE_TEXT=y +# end of Settings +# end of Log + +# default: +CONFIG_BOOTLOADER_CPU_CLK_FREQ_MHZ=80 + # # Serial Flash Configurations # @@ -336,10 +624,10 @@ CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE=y CONFIG_BOOTLOADER_WDT_ENABLE=y # CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set CONFIG_BOOTLOADER_WDT_TIME_MS=9000 -# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set # CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set # CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set # CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set +# default: CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 # CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set # end of Bootloader config @@ -347,11 +635,18 @@ CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 # # Security features # +# default: CONFIG_SECURE_BOOT_V2_RSA_SUPPORTED=y +# default: CONFIG_SECURE_BOOT_V2_PREFERRED=y # CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set +# default: +CONFIG_SECURE_BOOT_IMAGE_DIGEST_LEN=32 +# default: +CONFIG_SECURE_BOOT_ROM_FAST_WAKE_RESERVE_SIZE=0 # CONFIG_SECURE_BOOT is not set # CONFIG_SECURE_FLASH_ENC_ENABLED is not set +# default: CONFIG_SECURE_ROM_DL_MODE_ENABLED=y # end of Security features @@ -365,29 +660,58 @@ CONFIG_APP_COMPILE_TIME_DATE=y CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 # end of Application manager +# default: CONFIG_ESP_ROM_HAS_CRC_LE=y +# default: CONFIG_ESP_ROM_HAS_CRC_BE=y +# default: CONFIG_ESP_ROM_HAS_MZ_CRC32=y +# default: CONFIG_ESP_ROM_HAS_JPEG_DECODE=y +# default: CONFIG_ESP_ROM_UART_CLK_IS_XTAL=y +# default: CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM=3 +# default: CONFIG_ESP_ROM_HAS_RETARGETABLE_LOCKING=y +# default: CONFIG_ESP_ROM_HAS_ERASE_0_REGION_BUG=y +# default: CONFIG_ESP_ROM_HAS_ENCRYPTED_WRITES_USING_LEGACY_DRV=y +# default: CONFIG_ESP_ROM_GET_CLK_FREQ=y +# default: CONFIG_ESP_ROM_NEEDS_SWSETUP_WORKAROUND=y +# default: CONFIG_ESP_ROM_HAS_LAYOUT_TABLE=y +# default: CONFIG_ESP_ROM_HAS_SPI_FLASH=y +# default: +CONFIG_ESP_ROM_HAS_SPI_FLASH_MMAP=y +# default: CONFIG_ESP_ROM_HAS_ETS_PRINTF_BUG=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB_NANO_FORMAT=y +# default: CONFIG_ESP_ROM_HAS_NEWLIB_32BIT_TIME=y +# default: CONFIG_ESP_ROM_NEEDS_SET_CACHE_MMU_SIZE=y +# default: CONFIG_ESP_ROM_RAM_APP_NEEDS_MMU_INIT=y +# default: CONFIG_ESP_ROM_HAS_SW_FLOAT=y +# default: CONFIG_ESP_ROM_USB_OTG_NUM=-1 +# default: CONFIG_ESP_ROM_HAS_VERSION=y +# default: CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y +# default: +CONFIG_ESP_ROM_CONSOLE_OUTPUT_SECONDARY=y +# default: +CONFIG_ESP_ROM_HAS_SUBOPTIMAL_NEWLIB_ON_MISALIGNED_MEMORY=y # # Boot ROM Behavior @@ -407,12 +731,13 @@ CONFIG_BOOT_ROM_LOG_ALWAYS_ON=y CONFIG_ESPTOOLPY_FLASHMODE_DIO=y # CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y +# default: CONFIG_ESPTOOLPY_FLASHMODE="dio" CONFIG_ESPTOOLPY_FLASHFREQ_80M=y # CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -CONFIG_ESPTOOLPY_FLASHFREQ_80M_DEFAULT=y +# default: CONFIG_ESPTOOLPY_FLASHFREQ="80m" # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y @@ -422,14 +747,18 @@ CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y # CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set +# default: CONFIG_ESPTOOLPY_FLASHSIZE="2MB" # CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE is not set CONFIG_ESPTOOLPY_BEFORE_RESET=y # CONFIG_ESPTOOLPY_BEFORE_NORESET is not set -CONFIG_ESPTOOLPY_BEFORE="default_reset" +# default: +CONFIG_ESPTOOLPY_BEFORE="default-reset" CONFIG_ESPTOOLPY_AFTER_RESET=y # CONFIG_ESPTOOLPY_AFTER_NORESET is not set -CONFIG_ESPTOOLPY_AFTER="hard_reset" +# default: +CONFIG_ESPTOOLPY_AFTER="hard-reset" +# default: CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 # end of Serial flasher config @@ -439,8 +768,10 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 CONFIG_PARTITION_TABLE_SINGLE_APP=y # CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set # CONFIG_PARTITION_TABLE_TWO_OTA is not set +# CONFIG_PARTITION_TABLE_TWO_OTA_LARGE is not set # CONFIG_PARTITION_TABLE_CUSTOM is not set CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +# default: CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y @@ -456,7 +787,10 @@ CONFIG_COMPILER_OPTIMIZATION_DEBUG=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +# default: +# CONFIG_COMPILER_ASSERT_NDEBUG_EVALUATE is not set CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB=y +# default: CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 # CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set CONFIG_COMPILER_HIDE_PATHS_MACROS=y @@ -466,105 +800,112 @@ CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y # CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set # CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set # CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set +# default: +# CONFIG_COMPILER_NO_MERGE_CONSTANTS is not set # CONFIG_COMPILER_WARN_WRITE_STRINGS is not set # CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS is not set +# default: +# CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS is not set # CONFIG_COMPILER_DISABLE_GCC12_WARNINGS is not set # CONFIG_COMPILER_DISABLE_GCC13_WARNINGS is not set +# default: +# CONFIG_COMPILER_DISABLE_GCC14_WARNINGS is not set +# default: +# CONFIG_COMPILER_DISABLE_GCC15_WARNINGS is not set # CONFIG_COMPILER_DUMP_RTL_FILES is not set CONFIG_COMPILER_RT_LIB_GCCLIB=y +# default: CONFIG_COMPILER_RT_LIB_NAME="gcc" +# CONFIG_COMPILER_ORPHAN_SECTIONS_ERROR is not set # CONFIG_COMPILER_ORPHAN_SECTIONS_WARNING is not set CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y +# default: +# CONFIG_COMPILER_STATIC_ANALYZER is not set +# default: +CONFIG_COMPILER_CXX_GLIBCXX_CONSTEXPR_NO_CHANGE=y +# default: +# CONFIG_COMPILER_CXX_GLIBCXX_CONSTEXPR_COLD_CONSTEXPR is not set +# default: +# CONFIG_COMPILER_CXX_GLIBCXX_CONSTEXPR_COLD is not set # end of Compiler options # # Component config # -# -# Application Level Tracing -# -# CONFIG_APPTRACE_DEST_JTAG is not set -CONFIG_APPTRACE_DEST_NONE=y -# CONFIG_APPTRACE_DEST_UART1 is not set -# CONFIG_APPTRACE_DEST_USB_CDC is not set -CONFIG_APPTRACE_DEST_UART_NONE=y -CONFIG_APPTRACE_UART_TASK_PRIO=1 -CONFIG_APPTRACE_LOCK_ENABLE=y -# end of Application Level Tracing - # # Bluetooth # # CONFIG_BT_ENABLED is not set -CONFIG_BT_ALARM_MAX_NUM=50 -# end of Bluetooth # -# Console Library +# Common Options # -# CONFIG_CONSOLE_SORTED_HELP is not set -# end of Console Library # -# Driver Configurations +# BT Logs # # -# TWAI Configuration +# Log Sources # -# CONFIG_TWAI_ISR_IN_IRAM is not set -CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM=y -# end of TWAI Configuration +# end of Log Sources -# -# Legacy ADC Driver Configuration -# -# CONFIG_ADC_SUPPRESS_DEPRECATE_WARN is not set +# default: +# CONFIG_BT_LOG_CRITICAL_ONLY is not set +# default: +# CONFIG_BLE_LOG_ENABLED is not set # -# Legacy ADC Calibration Configuration +# Legacy SPI Log Output (Deprecated - use BT Log Async Output instead) # -# CONFIG_ADC_CALI_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy ADC Calibration Configuration -# end of Legacy ADC Driver Configuration +# default: +# CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED is not set +# end of Legacy SPI Log Output (Deprecated - use BT Log Async Output instead) +# end of BT Logs -# -# Legacy Timer Group Driver Configurations -# -# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy Timer Group Driver Configurations +# default: +# CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED is not set +# end of Common Options +# end of Bluetooth # -# Legacy RMT Driver Configurations +# Console Library # -# CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy RMT Driver Configurations +# CONFIG_CONSOLE_SORTED_HELP is not set +# end of Console Library # -# Legacy I2S Driver Configurations +# Legacy Driver Configurations # -# CONFIG_I2S_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy I2S Driver Configurations # -# Legacy SDM Driver Configurations +# Legacy TWAI Driver Configurations # -# CONFIG_SDM_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy SDM Driver Configurations +# default: +# CONFIG_TWAI_ISR_IN_IRAM_LEGACY is not set +# default: +# CONFIG_TWAI_SUPPRESS_DEPRECATE_WARN is not set +# default: +# CONFIG_TWAI_SKIP_LEGACY_CONFLICT_CHECK is not set +# end of Legacy TWAI Driver Configurations # -# Legacy Temperature Sensor Driver Configurations +# Legacy I2C Driver Configurations # -# CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN is not set -# end of Legacy Temperature Sensor Driver Configurations -# end of Driver Configurations +# default: +# CONFIG_I2C_SUPPRESS_DEPRECATE_WARN is not set +# default: +# CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK is not set +# end of Legacy I2C Driver Configurations +# end of Legacy Driver Configurations # # eFuse Bit Manager # # CONFIG_EFUSE_CUSTOM_TABLE is not set # CONFIG_EFUSE_VIRTUAL is not set +# default: CONFIG_EFUSE_MAX_BLK_LEN=256 # end of eFuse Bit Manager @@ -572,6 +913,7 @@ CONFIG_EFUSE_MAX_BLK_LEN=256 # ESP-TLS # CONFIG_ESP_TLS_USING_MBEDTLS=y +# CONFIG_ESP_TLS_CUSTOM_STACK is not set CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y # CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set # CONFIG_ESP_TLS_SERVER_SESSION_TICKETS is not set @@ -579,6 +921,8 @@ CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y # CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL is not set # CONFIG_ESP_TLS_PSK_VERIFICATION is not set # CONFIG_ESP_TLS_INSECURE is not set +# default: +CONFIG_ESP_TLS_DYN_BUF_STRATEGY_SUPPORTED=y # end of ESP-TLS # @@ -594,8 +938,11 @@ CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y # # Wireless Coexistence # +# default: CONFIG_ESP_COEX_ENABLED=y # CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE is not set +# default: +# CONFIG_ESP_COEX_GPIO_DEBUG is not set # end of Wireless Coexistence # @@ -604,6 +951,17 @@ CONFIG_ESP_COEX_ENABLED=y CONFIG_ESP_ERR_TO_NAME_LOOKUP=y # end of Common ESP-related +# +# GDMA Configurations +# +CONFIG_GDMA_CTRL_FUNC_IN_IRAM=y +# default: +CONFIG_GDMA_ISR_HANDLER_IN_IRAM=y +# default: +CONFIG_GDMA_OBJ_DRAM_SAFE=y +# CONFIG_GDMA_ENABLE_DEBUG_LOG is not set +# end of GDMA Configurations + # # ESP-Driver:GPIO Configurations # @@ -615,7 +973,9 @@ CONFIG_ESP_ERR_TO_NAME_LOOKUP=y # CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set -# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set +# CONFIG_GPTIMER_ISR_CACHE_SAFE is not set +# default: +CONFIG_GPTIMER_OBJ_CACHE_SAFE=y # CONFIG_GPTIMER_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:GPTimer Configurations @@ -624,15 +984,30 @@ CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # # CONFIG_I2C_ISR_IRAM_SAFE is not set # CONFIG_I2C_ENABLE_DEBUG_LOG is not set +# default: +CONFIG_I2C_MASTER_ISR_HANDLER_IN_IRAM=y # end of ESP-Driver:I2C Configurations # # ESP-Driver:I2S Configurations # # CONFIG_I2S_ISR_IRAM_SAFE is not set +# default: +# CONFIG_I2S_CTRL_FUNC_IN_IRAM is not set # CONFIG_I2S_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:I2S Configurations +# +# ESP-Driver:I3C Master Configurations +# +# default: +# CONFIG_I3C_MASTER_ISR_CACHE_SAFE is not set +# default: +# CONFIG_I3C_MASTER_ENABLE_DEBUG_LOG is not set +# default: +# CONFIG_I3C_MASTER_ISR_HANDLER_IN_IRAM is not set +# end of ESP-Driver:I3C Master Configurations + # # ESP-Driver:LEDC Configurations # @@ -642,9 +1017,21 @@ CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # # ESP-Driver:RMT Configurations # -# CONFIG_RMT_ISR_IRAM_SAFE is not set +# default: +CONFIG_RMT_ENCODER_FUNC_IN_IRAM=y +# default: +CONFIG_RMT_TX_ISR_HANDLER_IN_IRAM=y +# default: +CONFIG_RMT_RX_ISR_HANDLER_IN_IRAM=y # CONFIG_RMT_RECV_FUNC_IN_IRAM is not set +# default: +# CONFIG_RMT_TX_ISR_CACHE_SAFE is not set +# default: +# CONFIG_RMT_RX_ISR_CACHE_SAFE is not set +# default: +CONFIG_RMT_OBJ_CACHE_SAFE=y # CONFIG_RMT_ENABLE_DEBUG_LOG is not set +# CONFIG_RMT_ISR_IRAM_SAFE is not set # end of ESP-Driver:RMT Configurations # @@ -657,7 +1044,6 @@ CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y # # ESP-Driver:SPI Configurations # -# CONFIG_SPI_MASTER_IN_IRAM is not set CONFIG_SPI_MASTER_ISR_IN_IRAM=y # CONFIG_SPI_SLAVE_IN_IRAM is not set CONFIG_SPI_SLAVE_ISR_IN_IRAM=y @@ -669,12 +1055,35 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y # CONFIG_TEMP_SENSOR_ENABLE_DEBUG_LOG is not set # end of ESP-Driver:Temperature Sensor Configurations +# +# ESP-Driver:TWAI Configurations +# +# CONFIG_TWAI_ISR_IN_IRAM is not set +# default: +# CONFIG_TWAI_IO_FUNC_IN_IRAM is not set +# default: +# CONFIG_TWAI_ISR_CACHE_SAFE is not set +# default: +# CONFIG_TWAI_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:TWAI Configurations + # # ESP-Driver:UART Configurations # # CONFIG_UART_ISR_IN_IRAM is not set # end of ESP-Driver:UART Configurations +# +# ESP-Driver:UHCI Configurations +# +# default: +# CONFIG_UHCI_ISR_HANDLER_IN_IRAM is not set +# default: +# CONFIG_UHCI_ISR_CACHE_SAFE is not set +# default: +# CONFIG_UHCI_ENABLE_DEBUG_LOG is not set +# end of ESP-Driver:UHCI Configurations + # # ESP-Driver:USB Serial/JTAG Configuration # @@ -684,11 +1093,9 @@ CONFIG_USJ_ENABLE_USB_SERIAL_JTAG=y # # Ethernet # +# default: CONFIG_ETH_ENABLED=y CONFIG_ETH_USE_SPI_ETHERNET=y -# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set -# CONFIG_ETH_SPI_ETHERNET_W5500 is not set -# CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set # CONFIG_ETH_USE_OPENETH is not set # CONFIG_ETH_TRANSMIT_MUTEX is not set # end of Ethernet @@ -704,12 +1111,22 @@ CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y # # GDB Stub # +# default: CONFIG_ESP_GDBSTUB_ENABLED=y # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set CONFIG_ESP_GDBSTUB_SUPPORT_TASKS=y CONFIG_ESP_GDBSTUB_MAX_TASKS=32 # end of GDB Stub +# +# ESP HID +# +# default: +CONFIG_ESPHID_TASK_SIZE_BT=2048 +# default: +CONFIG_ESPHID_TASK_SIZE_BLE=4096 +# end of ESP HID + # # ESP HTTP client # @@ -717,6 +1134,14 @@ CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y # CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set # CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH is not set # CONFIG_ESP_HTTP_CLIENT_ENABLE_CUSTOM_TRANSPORT is not set +# default: +# CONFIG_ESP_HTTP_CLIENT_ENABLE_GET_CONTENT_RANGE is not set +# default: +CONFIG_ESP_HTTP_CLIENT_EVENT_POST_TIMEOUT=2000 +# default: +# CONFIG_ESP_HTTP_CLIENT_SAVE_RESPONSE_HEADERS is not set +# default: +CONFIG_ESP_HTTP_CLIENT_STRICT_HEADER_BUFFER=y # end of ESP HTTP client # @@ -729,6 +1154,10 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32 # CONFIG_HTTPD_LOG_PURGE_DATA is not set # CONFIG_HTTPD_WS_SUPPORT is not set # CONFIG_HTTPD_QUEUE_WORK_BLOCKING is not set +# default: +CONFIG_HTTPD_ENABLE_EVENTS=y +# default: +CONFIG_HTTPD_SERVER_EVENT_POST_TIMEOUT=2000 # end of HTTP Server # @@ -736,17 +1165,25 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32 # # CONFIG_ESP_HTTPS_OTA_DECRYPT_CB is not set # CONFIG_ESP_HTTPS_OTA_ALLOW_HTTP is not set +# default: +CONFIG_ESP_HTTPS_OTA_EVENT_POST_TIMEOUT=2000 +# default: +# CONFIG_ESP_HTTPS_OTA_ENABLE_PARTIAL_DOWNLOAD is not set # end of ESP HTTPS OTA # # ESP HTTPS server # # CONFIG_ESP_HTTPS_SERVER_ENABLE is not set +# default: +# CONFIG_ESP_HTTPS_SERVER_CERT_SELECT_HOOK is not set # end of ESP HTTPS server # # Hardware Settings # +# default: +CONFIG_ESP_HW_SUPPORT_FUNC_IN_IRAM=y # # Chip revision @@ -757,27 +1194,46 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32 CONFIG_ESP32C3_REV_MIN_3=y # CONFIG_ESP32C3_REV_MIN_4 is not set # CONFIG_ESP32C3_REV_MIN_101 is not set +# default: CONFIG_ESP32C3_REV_MIN_FULL=3 +# default: CONFIG_ESP_REV_MIN_FULL=3 # # Maximum Supported ESP32-C3 Revision (Rev v1.99) # +# default: CONFIG_ESP32C3_REV_MAX_FULL=199 +# default: CONFIG_ESP_REV_MAX_FULL=199 +# default: +CONFIG_ESP_EFUSE_BLOCK_REV_MIN_FULL=0 +# default: +CONFIG_ESP_EFUSE_BLOCK_REV_MAX_FULL=199 + +# +# Maximum Supported ESP32-C3 eFuse Block Revision (eFuse Block Rev v1.99) +# # end of Chip revision # # MAC Config # +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y +# default: CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y +# default: CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES_FOUR=y +# default: CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES=4 # CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_TWO is not set CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_FOUR=y +# default: CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES=4 # CONFIG_ESP_MAC_USE_CUSTOM_MAC_AS_BASE_MAC is not set # end of MAC Config @@ -803,57 +1259,115 @@ CONFIG_RTC_CLK_SRC_INT_RC=y # CONFIG_RTC_CLK_SRC_EXT_OSC is not set # CONFIG_RTC_CLK_SRC_INT_8MD256 is not set CONFIG_RTC_CLK_CAL_CYCLES=1024 +# default: +CONFIG_RTC_CLK_FUNC_IN_IRAM=y +# default: +CONFIG_RTC_TIME_FUNC_IN_IRAM=y # end of RTC Clock Config # # Peripheral Control # -CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y +CONFIG_ESP_PERIPH_CTRL_FUNC_IN_IRAM=y +# default: +CONFIG_ESP_REGI2C_CTRL_FUNC_IN_IRAM=y # end of Peripheral Control -# -# GDMA Configurations -# -CONFIG_GDMA_CTRL_FUNC_IN_IRAM=y -# CONFIG_GDMA_ISR_IRAM_SAFE is not set -# CONFIG_GDMA_ENABLE_DEBUG_LOG is not set -# end of GDMA Configurations - # # Main XTAL Config # CONFIG_XTAL_FREQ_40=y +# default: CONFIG_XTAL_FREQ=40 # end of Main XTAL Config -CONFIG_ESP_SPI_BUS_LOCK_ISR_FUNCS_IN_IRAM=y -# end of Hardware Settings - # -# LCD and Touch Panel +# Power Supplier # # -# LCD Touch Drivers are maintained in the IDF Component Registry +# Brownout Detector # +CONFIG_ESP_BROWNOUT_DET=y +CONFIG_ESP_BROWNOUT_DET_LVL_SEL_7=y +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_2 is not set +# default: +CONFIG_ESP_BROWNOUT_DET_LVL=7 +# default: +CONFIG_ESP_BROWNOUT_USE_INTR=y +# end of Brownout Detector +# end of Power Supplier + +# default: +CONFIG_ESP_SPI_BUS_LOCK_ISR_FUNCS_IN_IRAM=y +# default: +CONFIG_ESP_INTR_IN_IRAM=y +# end of Hardware Settings # -# LCD Peripheral Configuration +# ESP-Driver:LCD Controller Configurations # # CONFIG_LCD_ENABLE_DEBUG_LOG is not set -# end of LCD Peripheral Configuration -# end of LCD and Touch Panel +# end of ESP-Driver:LCD Controller Configurations + +# +# LibC +# +# default: +# CONFIG_LIBC_NEWLIB is not set +# default: +CONFIG_LIBC_PICOLIBC=y +# default: +CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY=y +# default: +CONFIG_LIBC_MISC_IN_IRAM=y +# default: +CONFIG_LIBC_LOCKS_PLACE_IN_IRAM=y +CONFIG_LIBC_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_LIBC_STDOUT_LINE_ENDING_LF is not set +# CONFIG_LIBC_STDOUT_LINE_ENDING_CR is not set +# CONFIG_LIBC_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_LIBC_STDIN_LINE_ENDING_LF is not set +CONFIG_LIBC_STDIN_LINE_ENDING_CR=y +CONFIG_LIBC_TIME_SYSCALL_USE_RTC_HRT=y +# CONFIG_LIBC_TIME_SYSCALL_USE_RTC is not set +# CONFIG_LIBC_TIME_SYSCALL_USE_HRT is not set +# CONFIG_LIBC_TIME_SYSCALL_USE_NONE is not set +# default: +CONFIG_LIBC_OPTIMIZED_MISALIGNED_ACCESS=y +# default: +CONFIG_LIBC_ASSERT_BUFFER_SIZE=200 +# end of LibC + +# +# ESP-MM: Memory Management Configurations +# +# end of ESP-MM: Memory Management Configurations # # ESP NETIF Adapter # +# default: +CONFIG_ESP_NETIF_LOST_IP_TIMER_ENABLE=y CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 +# default: +# CONFIG_ESP_NETIF_PROVIDE_CUSTOM_IMPLEMENTATION is not set CONFIG_ESP_NETIF_TCPIP_LWIP=y # CONFIG_ESP_NETIF_LOOPBACK is not set +# default: CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y -# CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS is not set +# default: +CONFIG_ESP_NETIF_REPORT_DATA_TRAFFIC=y +# default: +CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS=y # CONFIG_ESP_NETIF_L2_TAP is not set # CONFIG_ESP_NETIF_BRIDGE_EN is not set +# default: +# CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF is not set # end of ESP NETIF Adapter # @@ -864,10 +1378,12 @@ CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y # # PHY # +# default: CONFIG_ESP_PHY_ENABLED=y CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y # CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 +# default: CONFIG_ESP_PHY_MAX_TX_POWER=20 # CONFIG_ESP_PHY_REDUCE_TX_POWER is not set CONFIG_ESP_PHY_ENABLE_USB=y @@ -875,15 +1391,32 @@ CONFIG_ESP_PHY_ENABLE_USB=y CONFIG_ESP_PHY_RF_CAL_PARTIAL=y # CONFIG_ESP_PHY_RF_CAL_NONE is not set # CONFIG_ESP_PHY_RF_CAL_FULL is not set +# default: CONFIG_ESP_PHY_CALIBRATION_MODE=0 +# default: +CONFIG_ESP_PHY_PLL_TRACK_PERIOD_MS=1000 # CONFIG_ESP_PHY_PLL_TRACK_DEBUG is not set +# default: +# CONFIG_ESP_PHY_RECORD_USED_TIME is not set +# default: +CONFIG_ESP_PHY_IRAM_OPT=y +# default: +# CONFIG_ESP_PHY_DEBUG is not set +# default: +CONFIG_ESP_PHY_ENABLE_VERSION_PRINT=y # end of PHY # # Power Management # +# default: +# CONFIG_PM_SLEEP_FUNC_IN_IRAM is not set # CONFIG_PM_ENABLE is not set +# default: +# CONFIG_PM_SLP_IRAM_OPT is not set CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y +# default: +CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU=y # end of Power Management # @@ -893,50 +1426,80 @@ CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y # # ESP Ringbuf # -# CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH is not set +# default: +# CONFIG_RINGBUF_IN_IRAM is not set +# default: +# CONFIG_RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH is not set # end of ESP Ringbuf +# +# ESP-ROM +# +# default: +CONFIG_ESP_ROM_PRINT_IN_IRAM=y +# end of ESP-ROM + +# +# ESP Security Specific +# +# end of ESP Security Specific + +# +# ESP-STDIO +# +CONFIG_ESP_CONSOLE_UART_DEFAULT=y +# CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set +# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_NONE is not set +# CONFIG_ESP_CONSOLE_SECONDARY_NONE is not set +CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y +# default: +CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y +# default: +CONFIG_ESP_CONSOLE_UART=y +# default: +CONFIG_ESP_CONSOLE_UART_NUM=0 +# default: +CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +# end of ESP-STDIO + # # ESP System Settings # # CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80 is not set CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160=y +# default: CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=160 +# default: +CONFIG_ESP_SYSTEM_IN_IRAM=y # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS=0 +# default: CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE=y +# default: CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y +# default: +CONFIG_ESP_SYSTEM_NO_BACKTRACE=y # CONFIG_ESP_SYSTEM_USE_EH_FRAME is not set - -# -# Memory protection -# -CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=y -CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK=y -# end of Memory protection - +# default: +# CONFIG_ESP_SYSTEM_USE_FRAME_POINTER is not set +CONFIG_ESP_SYSTEM_MEMPROT=y +# default: +CONFIG_ESP_SYSTEM_MEMPROT_PMS=y +CONFIG_ESP_SYSTEM_MEMPROT_PMS_LOCK=y CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y # CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set +# default: CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 -CONFIG_ESP_CONSOLE_UART_DEFAULT=y -# CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set -# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set -# CONFIG_ESP_CONSOLE_NONE is not set -# CONFIG_ESP_CONSOLE_SECONDARY_NONE is not set -CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y -CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y -CONFIG_ESP_CONSOLE_UART=y -CONFIG_ESP_CONSOLE_UART_NUM=0 -CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 -CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 CONFIG_ESP_INT_WDT=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 CONFIG_ESP_TASK_WDT_EN=y @@ -948,21 +1511,6 @@ CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y # CONFIG_ESP_DEBUG_STUBS_ENABLE is not set CONFIG_ESP_DEBUG_OCDAWARE=y CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y - -# -# Brownout Detector -# -CONFIG_ESP_BROWNOUT_DET=y -CONFIG_ESP_BROWNOUT_DET_LVL_SEL_7=y -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_2 is not set -CONFIG_ESP_BROWNOUT_DET_LVL=7 -# end of Brownout Detector - -CONFIG_ESP_SYSTEM_BROWNOUT_INTR=y CONFIG_ESP_SYSTEM_HW_STACK_GUARD=y CONFIG_ESP_SYSTEM_HW_PC_RECORD=y # end of ESP System Settings @@ -976,31 +1524,57 @@ CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 # # ESP Timer (High Resolution Timer) # +# default: +CONFIG_ESP_TIMER_IN_IRAM=y # CONFIG_ESP_TIMER_PROFILING is not set +# default: CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y +# default: CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 # CONFIG_ESP_TIMER_SHOW_EXPERIMENTAL is not set +# default: CONFIG_ESP_TIMER_TASK_AFFINITY=0x0 CONFIG_ESP_TIMER_TASK_AFFINITY_CPU0=y CONFIG_ESP_TIMER_ISR_AFFINITY_CPU0=y # CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set +# default: CONFIG_ESP_TIMER_IMPL_SYSTIMER=y # end of ESP Timer (High Resolution Timer) +# +# ESP Trace Configuration +# +# default: +# CONFIG_ESP_TRACE_LIB_EXTERNAL is not set +# default: +CONFIG_ESP_TRACE_LIB_NONE=y +# default: +CONFIG_ESP_TRACE_LIB_NAME="none" +# default: +# CONFIG_ESP_TRACE_TRANSPORT_APPTRACE is not set +# default: +CONFIG_ESP_TRACE_TRANSPORT_NONE=y +# default: +CONFIG_ESP_TRACE_TRANSPORT_NAME="none" +# end of ESP Trace Configuration + # # Wi-Fi # +# default: CONFIG_ESP_WIFI_ENABLED=y CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32 # CONFIG_ESP_WIFI_STATIC_TX_BUFFER is not set CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER=y +# default: CONFIG_ESP_WIFI_TX_BUFFER_TYPE=1 CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=32 CONFIG_ESP_WIFI_STATIC_RX_MGMT_BUFFER=y # CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER is not set +# default: CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0 CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF=5 # CONFIG_ESP_WIFI_CSI_ENABLED is not set @@ -1015,11 +1589,17 @@ CONFIG_ESP_WIFI_IRAM_OPT=y # CONFIG_ESP_WIFI_EXTRA_IRAM_OPT is not set CONFIG_ESP_WIFI_RX_IRAM_OPT=y CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y +# default: +CONFIG_ESP_WIFI_ENABLE_SAE_H2E=y CONFIG_ESP_WIFI_ENABLE_SAE_PK=y CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT=y CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y +# default: +CONFIG_ESP_WIFI_WPA3_COMPATIBLE_SUPPORT=y # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set CONFIG_ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME=50 +# default: +# CONFIG_ESP_WIFI_BSS_MAX_IDLE_SUPPORT is not set CONFIG_ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME=10 CONFIG_ESP_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME=15 # CONFIG_ESP_WIFI_FTM_ENABLE is not set @@ -1044,12 +1624,15 @@ CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y # # CONFIG_ESP_WIFI_WPS_STRICT is not set # CONFIG_ESP_WIFI_WPS_PASSPHRASE is not set +# default: +# CONFIG_ESP_WIFI_WPS_RECONNECT_ON_FAIL is not set # end of WPS Configuration Options # CONFIG_ESP_WIFI_DEBUG_PRINT is not set -# CONFIG_ESP_WIFI_TESTING_OPTIONS is not set CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=y # CONFIG_ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER is not set +# default: +# CONFIG_ESP_WIFI_PASSIVE_HIDDEN_AP_SUPPORT is not set # end of Wi-Fi # @@ -1091,15 +1674,33 @@ CONFIG_FATFS_CODEPAGE_437=y # CONFIG_FATFS_CODEPAGE_936 is not set # CONFIG_FATFS_CODEPAGE_949 is not set # CONFIG_FATFS_CODEPAGE_950 is not set +# default: CONFIG_FATFS_CODEPAGE=437 CONFIG_FATFS_FS_LOCK=0 CONFIG_FATFS_TIMEOUT_MS=10000 CONFIG_FATFS_PER_FILE_CACHE=y # CONFIG_FATFS_USE_FASTSEEK is not set +# default: +CONFIG_FATFS_USE_STRFUNC_NONE=y +# default: +# CONFIG_FATFS_USE_STRFUNC_WITHOUT_CRLF_CONV is not set +# default: +# CONFIG_FATFS_USE_STRFUNC_WITH_CRLF_CONV is not set CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0 # CONFIG_FATFS_IMMEDIATE_FSYNC is not set # CONFIG_FATFS_USE_LABEL is not set CONFIG_FATFS_LINK_LOCK=y +# default: +CONFIG_FATFS_USE_DYN_BUFFERS=y + +# +# File system free space calculation behavior +# +# default: +CONFIG_FATFS_DONT_TRUST_FREE_CLUSTER_CNT=0 +# default: +CONFIG_FATFS_DONT_TRUST_LAST_ALLOC=0 +# end of File system free space calculation behavior # end of FAT Filesystem support # @@ -1122,9 +1723,12 @@ CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 # CONFIG_FREERTOS_USE_TICK_HOOK is not set CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 # CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY is not set +# default: +CONFIG_FREERTOS_USE_TIMERS=y CONFIG_FREERTOS_TIMER_SERVICE_TASK_NAME="Tmr Svc" # CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU0 is not set CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY=y +# default: CONFIG_FREERTOS_TIMER_SERVICE_TASK_CORE_AFFINITY=0x7FFFFFFF CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 @@ -1144,24 +1748,35 @@ CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y # CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS=y # CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK is not set -# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set +# default: CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y CONFIG_FREERTOS_ISR_STACKSIZE=1536 CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y +# default: CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER=y CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y # CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL3 is not set +# default: CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER=y -# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set +# default: +# CONFIG_FREERTOS_IN_IRAM is not set # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set # end of Port +# +# Extra +# +# end of Extra + +# default: CONFIG_FREERTOS_PORT=y +# default: CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +# default: CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y +# default: CONFIG_FREERTOS_DEBUG_OCDAWARE=y -CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y -CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y +# default: CONFIG_FREERTOS_NUMBER_OF_CORES=1 # end of FreeRTOS @@ -1172,9 +1787,10 @@ CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y # CONFIG_HAL_ASSERTION_DISABLE is not set # CONFIG_HAL_ASSERTION_SILENT is not set # CONFIG_HAL_ASSERTION_ENABLE is not set +# default: CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 -CONFIG_HAL_SPI_MASTER_FUNC_IN_IRAM=y -CONFIG_HAL_SPI_SLAVE_FUNC_IN_IRAM=y +# default: +CONFIG_HAL_GPIO_USE_ROM_IMPL=y # end of Hardware Abstraction Layer (HAL) and Low Level (LL) # @@ -1193,7 +1809,17 @@ CONFIG_HEAP_TRACING_OFF=y # end of Heap memory debugging # -# Log output +# Log +# +# default: +CONFIG_LOG_VERSION_1=y +# default: +# CONFIG_LOG_VERSION_2 is not set +# default: +CONFIG_LOG_VERSION=1 + +# +# Log Level # # CONFIG_LOG_DEFAULT_LEVEL_NONE is not set # CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set @@ -1201,23 +1827,61 @@ CONFIG_HEAP_TRACING_OFF=y CONFIG_LOG_DEFAULT_LEVEL_INFO=y # CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set +# default: CONFIG_LOG_DEFAULT_LEVEL=3 CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y # CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set # CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set +# default: CONFIG_LOG_MAXIMUM_LEVEL=3 + +# +# Level Settings +# # CONFIG_LOG_MASTER_LEVEL is not set +# default: +CONFIG_LOG_DYNAMIC_LEVEL_CONTROL=y +# default: +# CONFIG_LOG_TAG_LEVEL_IMPL_NONE is not set +# default: +# CONFIG_LOG_TAG_LEVEL_IMPL_LINKED_LIST is not set +# default: +CONFIG_LOG_TAG_LEVEL_IMPL_CACHE_AND_LINKED_LIST=y +# default: +# CONFIG_LOG_TAG_LEVEL_CACHE_ARRAY is not set +# default: +CONFIG_LOG_TAG_LEVEL_CACHE_BINARY_MIN_HEAP=y +# default: +CONFIG_LOG_TAG_LEVEL_IMPL_CACHE_SIZE=31 +# end of Level Settings +# end of Log Level + +# +# Format +# CONFIG_LOG_COLORS=y CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y # CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set -# end of Log output +# end of Format + +# +# Settings +# +# default: +CONFIG_LOG_MODE_TEXT_EN=y +# default: +CONFIG_LOG_MODE_TEXT=y +# end of Settings + +# default: +CONFIG_LOG_IN_IRAM=y +# end of Log # # LWIP # CONFIG_LWIP_ENABLE=y CONFIG_LWIP_LOCAL_HOSTNAME="espressif" -# CONFIG_LWIP_NETIF_API is not set CONFIG_LWIP_TCPIP_TASK_PRIO=18 # CONFIG_LWIP_TCPIP_CORE_LOCKING is not set # CONFIG_LWIP_CHECK_THREAD_SAFETY is not set @@ -1241,6 +1905,8 @@ CONFIG_LWIP_IP6_FRAG=y # CONFIG_LWIP_IP4_REASSEMBLY is not set # CONFIG_LWIP_IP6_REASSEMBLY is not set CONFIG_LWIP_IP_REASS_MAX_PBUFS=10 +# default: +CONFIG_LWIP_IPV6_DUP_DETECT_ATTEMPTS=1 # CONFIG_LWIP_IP_FORWARD is not set # CONFIG_LWIP_STATS is not set CONFIG_LWIP_ESP_GRATUITOUS_ARP=y @@ -1249,10 +1915,12 @@ CONFIG_LWIP_ESP_MLDV6_REPORT=y CONFIG_LWIP_MLDV6_TMR_INTERVAL=40 CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +# CONFIG_LWIP_DHCP_DOES_ACD_CHECK is not set +# CONFIG_LWIP_DHCP_DOES_NOT_CHECK_OFFERED_IP is not set # CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y # CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set -CONFIG_LWIP_DHCP_OPTIONS_LEN=68 +CONFIG_LWIP_DHCP_OPTIONS_LEN=69 CONFIG_LWIP_NUM_NETIF_CLIENT_DATA=0 CONFIG_LWIP_DHCP_COARSE_TIMER_SECS=1 @@ -1260,8 +1928,12 @@ CONFIG_LWIP_DHCP_COARSE_TIMER_SECS=1 # DHCP server # CONFIG_LWIP_DHCPS=y +# default: +CONFIG_LWIP_DHCPS_REPORT_CLIENT_HOSTNAME=y CONFIG_LWIP_DHCPS_LEASE_UNIT=60 CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 +# default: +CONFIG_LWIP_DHCPS_MAX_HOSTNAME_LEN=64 CONFIG_LWIP_DHCPS_STATIC_ENTRIES=y # end of DHCP server @@ -1272,6 +1944,8 @@ CONFIG_LWIP_IPV6=y CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 # CONFIG_LWIP_IPV6_FORWARD is not set # CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set +# default: +# CONFIG_LWIP_NETIF_LINK_CALLBACK is not set CONFIG_LWIP_NETIF_LOOPBACK=y CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 @@ -1319,10 +1993,19 @@ CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y # CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set +# default: CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF -# CONFIG_LWIP_PPP_SUPPORT is not set CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 +# default: +CONFIG_LWIP_IPV6_ND6_NUM_PREFIXES=5 +# default: +CONFIG_LWIP_IPV6_ND6_NUM_ROUTERS=3 +# default: +CONFIG_LWIP_IPV6_ND6_NUM_DESTINATIONS=10 +# default: +# CONFIG_LWIP_IPV6_ND6_ROUTE_INFO_OPTION_SUPPORT is not set +# CONFIG_LWIP_PPP_SUPPORT is not set # CONFIG_LWIP_SLIP_SUPPORT is not set # @@ -1352,8 +2035,14 @@ CONFIG_LWIP_SNTP_MAXIMUM_STARTUP_DELAY=5000 # # DNS # +# default: +CONFIG_LWIP_DNS_MAX_HOST_IP=1 CONFIG_LWIP_DNS_MAX_SERVERS=3 # CONFIG_LWIP_FALLBACK_DNS_SERVER_SUPPORT is not set +# default: +# CONFIG_LWIP_DNS_SETSERVER_WITH_NETIF is not set +# default: +# CONFIG_LWIP_USE_ESP_GETADDRINFO is not set # end of DNS CONFIG_LWIP_BRIDGEIF_MAX_PORTS=7 @@ -1374,9 +2063,19 @@ CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_NONE=y # CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_DEFAULT is not set # CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_CUSTOM is not set +# default: +CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_NONE=y +# default: +# CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_DEFAULT is not set +# default: +# CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_CUSTOM is not set CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y # CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set # CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set +# default: +CONFIG_LWIP_HOOK_DNS_EXT_RESOLVE_NONE=y +# default: +# CONFIG_LWIP_HOOK_DNS_EXT_RESOLVE_CUSTOM is not set CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y # CONFIG_LWIP_HOOK_IP6_INPUT_DEFAULT is not set # CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM is not set @@ -1388,6 +2087,33 @@ CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y # # mbedTLS # + +# +# Core Configuration +# +# default: +CONFIG_MBEDTLS_VER_4_X_SUPPORT=y +# default: +# CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_NONE is not set +# default: +CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_SIZE=y +# default: +# CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_PERF is not set +# default: +CONFIG_MBEDTLS_FS_IO=y +# default: +# CONFIG_MBEDTLS_PSA_ITS_CUSTOM_STORAGE_BACKEND is not set +CONFIG_MBEDTLS_THREADING_C=y +# default: +# CONFIG_MBEDTLS_THREADING_ALT is not set +# default: +CONFIG_MBEDTLS_THREADING_PTHREAD=y +CONFIG_MBEDTLS_ERROR_STRINGS=y +# default: +CONFIG_MBEDTLS_VERSION_C=y +CONFIG_MBEDTLS_HAVE_TIME=y +# CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set +# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y # CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set # CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set @@ -1395,159 +2121,257 @@ CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 # CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set +# default: +# CONFIG_MBEDTLS_VERSION_FEATURES is not set # CONFIG_MBEDTLS_DEBUG is not set +# default: +CONFIG_MBEDTLS_SELF_TEST=y +# end of Core Configuration # -# mbedTLS v3.x related +# Certificates # -# CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 is not set -# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set -# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set -# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set -CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y -CONFIG_MBEDTLS_PKCS7_C=y -# end of mbedTLS v3.x related +# default: +CONFIG_MBEDTLS_X509_USE_C=y +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +# default: +CONFIG_MBEDTLS_PK_C=y +# default: +CONFIG_MBEDTLS_PK_PARSE_C=y +# default: +CONFIG_MBEDTLS_PK_WRITE_C=y +# default: +# CONFIG_MBEDTLS_X509_REMOVE_INFO is not set +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +# default: +CONFIG_MBEDTLS_X509_CRT_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +# default: +# CONFIG_MBEDTLS_X509_CREATE_C is not set +# default: +CONFIG_MBEDTLS_X509_RSASSA_PSS_SUPPORT=y +CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK=y +# default: +CONFIG_MBEDTLS_ASN1_PARSE_C=y +# default: +CONFIG_MBEDTLS_ASN1_WRITE_C=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y # -# Certificate Bundle +# Certificate Bundle Configuration # -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set # CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEPRECATED_LIST is not set CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 -# end of Certificate Bundle +# end of Certificate Bundle Configuration -# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set -CONFIG_MBEDTLS_CMAC_C=y -CONFIG_MBEDTLS_HARDWARE_AES=y -CONFIG_MBEDTLS_AES_USE_INTERRUPT=y -CONFIG_MBEDTLS_AES_INTERRUPT_LEVEL=0 -CONFIG_MBEDTLS_GCM_SUPPORT_NON_AES_CIPHER=y -CONFIG_MBEDTLS_HARDWARE_MPI=y -CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI=y -CONFIG_MBEDTLS_MPI_USE_INTERRUPT=y -CONFIG_MBEDTLS_MPI_INTERRUPT_LEVEL=0 -CONFIG_MBEDTLS_HARDWARE_SHA=y -CONFIG_MBEDTLS_ROM_MD5=y -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set -CONFIG_MBEDTLS_HAVE_TIME=y -# CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set -# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set -CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y -CONFIG_MBEDTLS_SHA512_C=y +# default: +# CONFIG_MBEDTLS_ALLOW_WEAK_CERTIFICATE_VERIFICATION is not set +# default: +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y +# end of Certificates + +CONFIG_MBEDTLS_TLS_ENABLED=y + +# +# TLS Protocol Configuration +# +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 is not set +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set +# default: +CONFIG_MBEDTLS_TLS_SERVER=y +# default: +CONFIG_MBEDTLS_TLS_CLIENT=y CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y # CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set # CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set -# CONFIG_MBEDTLS_TLS_DISABLED is not set -CONFIG_MBEDTLS_TLS_SERVER=y -CONFIG_MBEDTLS_TLS_CLIENT=y -CONFIG_MBEDTLS_TLS_ENABLED=y +CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y +# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set +# default: +CONFIG_MBEDTLS_SSL_CACHE_C=y +# default: +CONFIG_MBEDTLS_SSL_ALL_ALERT_MESSAGES=y # -# TLS Key Exchange Methods +# TLS Key Exchange Configuration # # CONFIG_MBEDTLS_PSK_MODES is not set CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y -# end of TLS Key Exchange Methods +# end of TLS Key Exchange Configuration -CONFIG_MBEDTLS_SSL_RENEGOTIATION=y -CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y -# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set -# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +# default: +CONFIG_MBEDTLS_SSL_SERVER_NAME_INDICATION=y CONFIG_MBEDTLS_SSL_ALPN=y +# default: +CONFIG_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH=y +# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y +# default: +# CONFIG_MBEDTLS_SSL_KEYING_MATERIAL_EXPORT is not set +# end of TLS Protocol Configuration + +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set # # Symmetric Ciphers # CONFIG_MBEDTLS_AES_C=y # CONFIG_MBEDTLS_CAMELLIA_C is not set +# default: +# CONFIG_MBEDTLS_ARIA_C is not set # CONFIG_MBEDTLS_DES_C is not set -# CONFIG_MBEDTLS_BLOWFISH_C is not set -# CONFIG_MBEDTLS_XTEA_C is not set CONFIG_MBEDTLS_CCM_C=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_CBC=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_CFB=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_CTR=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_OFB=y +# default: +CONFIG_MBEDTLS_CIPHER_MODE_XTS=y CONFIG_MBEDTLS_GCM_C=y # CONFIG_MBEDTLS_NIST_KW_C is not set +# default: +CONFIG_MBEDTLS_AES_ROM_TABLES=y +# default: +# CONFIG_MBEDTLS_AES_FEWER_TABLES is not set +# default: +# CONFIG_MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH is not set +CONFIG_MBEDTLS_CMAC_C=y # end of Symmetric Ciphers -# CONFIG_MBEDTLS_RIPEMD160_C is not set - # -# Certificates +# Asymmetric Ciphers # -CONFIG_MBEDTLS_PEM_PARSE_C=y -CONFIG_MBEDTLS_PEM_WRITE_C=y -CONFIG_MBEDTLS_X509_CRL_PARSE_C=y -CONFIG_MBEDTLS_X509_CSR_PARSE_C=y -# end of Certificates - +# default: +CONFIG_MBEDTLS_RSA_C=y CONFIG_MBEDTLS_ECP_C=y -# CONFIG_MBEDTLS_DHM_C is not set -CONFIG_MBEDTLS_ECDH_C=y -CONFIG_MBEDTLS_ECDSA_C=y -# CONFIG_MBEDTLS_ECJPAKE_C is not set -CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y + +# +# Supported Curves +# CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +# end of Supported Curves + +# +# Elliptic Curve Ciphers Configuration +# CONFIG_MBEDTLS_ECP_NIST_OPTIM=y CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y -# CONFIG_MBEDTLS_POLY1305_C is not set -# CONFIG_MBEDTLS_CHACHA20_C is not set -# CONFIG_MBEDTLS_HKDF_C is not set -# CONFIG_MBEDTLS_THREADING_C is not set -CONFIG_MBEDTLS_ERROR_STRINGS=y -# end of mbedTLS +# CONFIG_MBEDTLS_DHM_C is not set +CONFIG_MBEDTLS_ECDH_C=y +# CONFIG_MBEDTLS_ECJPAKE_C is not set +CONFIG_MBEDTLS_ECDSA_C=y +# default: +CONFIG_MBEDTLS_PK_PARSE_EC_EXTENDED=y +# default: +CONFIG_MBEDTLS_PK_PARSE_EC_COMPRESSED=y +CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y +# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set +# end of Elliptic Curve Ciphers Configuration +# end of Asymmetric Ciphers # -# ESP-MQTT Configurations +# Hash functions # -CONFIG_MQTT_PROTOCOL_311=y -# CONFIG_MQTT_PROTOCOL_5 is not set -CONFIG_MQTT_TRANSPORT_SSL=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y -# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set -# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set -# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set -# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set -# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set -# CONFIG_MQTT_CUSTOM_OUTBOX is not set -# end of ESP-MQTT Configurations +# CONFIG_MBEDTLS_RIPEMD160_C is not set +# default: +CONFIG_MBEDTLS_MD_C=y +# default: +CONFIG_MBEDTLS_MD5_C=y +# default: +CONFIG_MBEDTLS_SHA1_C=y +# default: +# CONFIG_MBEDTLS_SHA224_C is not set +# default: +CONFIG_MBEDTLS_SHA256_C=y +# default: +CONFIG_MBEDTLS_SHA384_C=y +CONFIG_MBEDTLS_SHA512_C=y +# default: +# CONFIG_MBEDTLS_SHA3_C is not set +CONFIG_MBEDTLS_ROM_MD5=y +# end of Hash functions # -# Newlib +# Hardware Acceleration # -CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set -CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y -# CONFIG_NEWLIB_NANO_FORMAT is not set -CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y -# CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC is not set -# CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT is not set -# CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE is not set -# end of Newlib +CONFIG_MBEDTLS_HARDWARE_SHA=y +CONFIG_MBEDTLS_HARDWARE_MPI=y +CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI=y +CONFIG_MBEDTLS_MPI_USE_INTERRUPT=y +CONFIG_MBEDTLS_MPI_INTERRUPT_LEVEL=0 + +# +# Security hardening +# +# default: +# CONFIG_MBEDTLS_CONSTANT_TIME_PRIME_GEN is not set +# end of Security hardening + +CONFIG_MBEDTLS_HARDWARE_AES=y +# default: +# CONFIG_MBEDTLS_AES_SOFT_FALLBACK is not set +CONFIG_MBEDTLS_GCM_SUPPORT_NON_AES_CIPHER=y +CONFIG_MBEDTLS_AES_USE_INTERRUPT=y +CONFIG_MBEDTLS_AES_INTERRUPT_LEVEL=0 +# default: +CONFIG_MBEDTLS_AES_HW_SMALL_DATA_LEN_OPTIM=y +# CONFIG_MBEDTLS_SECURE_ELEMENT_DRIVER_ENABLED is not set +# default: +CONFIG_MBEDTLS_HARDWARE_RSA_DS_PERIPHERAL=y +# end of Hardware Acceleration + +# +# Entropy and Random Number Generation +# +# default: +# CONFIG_MBEDTLS_ENTROPY_FORCE_SHA256 is not set +# default: +CONFIG_MBEDTLS_CTR_DRBG_C=y +# default: +CONFIG_MBEDTLS_HMAC_DRBG_C=y +# end of Entropy and Random Number Generation + +# +# Encoding/Decoding +# +# default: +CONFIG_MBEDTLS_BASE64_C=y +# default: +CONFIG_MBEDTLS_PKCS5_C=y +CONFIG_MBEDTLS_PKCS7_C=y +# default: +CONFIG_MBEDTLS_PKCS1_V15=y +# default: +CONFIG_MBEDTLS_PKCS1_V21=y +# end of Encoding/Decoding + +# +# Stream Cipher +# +# CONFIG_MBEDTLS_CHACHA20_C is not set +# end of Stream Cipher +# end of mbedTLS # # NVS @@ -1555,6 +2379,10 @@ CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y # CONFIG_NVS_ENCRYPTION is not set # CONFIG_NVS_ASSERT_ERROR_CHECK is not set # CONFIG_NVS_LEGACY_DUP_KEYS_COMPATIBILITY is not set +# default: +# CONFIG_NVS_BDL_STACK is not set +# default: +# CONFIG_NVS_FLASH_VERIFY_ERASE is not set # end of NVS # @@ -1563,25 +2391,13 @@ CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y # CONFIG_OPENTHREAD_ENABLED is not set # -# Thread Operational Dataset +# OpenThread Spinel # -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread-ESP" -CONFIG_OPENTHREAD_MESH_LOCAL_PREFIX="fd00:db8:a0:0::/64" -CONFIG_OPENTHREAD_NETWORK_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_PANID=0x1234 -CONFIG_OPENTHREAD_NETWORK_EXTPANID="dead00beef00cafe" -CONFIG_OPENTHREAD_NETWORK_MASTERKEY="00112233445566778899aabbccddeeff" -CONFIG_OPENTHREAD_NETWORK_PSKC="104810e2315100afd6bc9215a6bfac53" -# end of Thread Operational Dataset - -CONFIG_OPENTHREAD_XTAL_ACCURACY=130 # CONFIG_OPENTHREAD_SPINEL_ONLY is not set -CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE=y +# end of OpenThread Spinel -# -# Thread Address Query Config -# -# end of Thread Address Query Config +# default: +# CONFIG_OPENTHREAD_DEBUG is not set # end of OpenThread # @@ -1590,6 +2406,8 @@ CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=y +# default: +CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_PATCH_VERSION=y # end of Protocomm # @@ -1598,15 +2416,26 @@ CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=y CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 CONFIG_PTHREAD_STACK_MIN=768 +# default: CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # end of PThreads +# +# SD Protocol Layer Configuration +# +# default: +CONFIG_SD_ENABLE_SDIO_SUPPORT=y +# end of SD Protocol Layer Configuration + # # MMU Config # +# default: CONFIG_MMU_PAGE_SIZE_64KB=y +# default: CONFIG_MMU_PAGE_MODE="64KB" +# default: CONFIG_MMU_PAGE_SIZE=0x10000 # end of MMU Config @@ -1618,6 +2447,7 @@ CONFIG_MMU_PAGE_SIZE=0x10000 # SPI Flash behavior when brownout # CONFIG_SPI_FLASH_BROWNOUT_RESET_XMC=y +# default: CONFIG_SPI_FLASH_BROWNOUT_RESET=y # end of SPI Flash behavior when brownout @@ -1628,9 +2458,14 @@ CONFIG_SPI_FLASH_BROWNOUT_RESET=y # # Features here require specific hardware (READ DOCS FIRST!) # -CONFIG_SPI_FLASH_SUSPEND_QVL_SUPPORTED=y # CONFIG_SPI_FLASH_AUTO_SUSPEND is not set CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50 +# default: +# CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND is not set +# default: +# CONFIG_SPI_FLASH_FORCE_ENABLE_C6_H2_SUSPEND is not set +# default: +CONFIG_SPI_FLASH_PLACE_FUNCTIONS_IN_IRAM=y # end of Optional and Experimental Features (READ DOCS FIRST) # end of Main Flash configuration @@ -1639,7 +2474,6 @@ CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50 # # CONFIG_SPI_FLASH_VERIFY_WRITE is not set # CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set -CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y # CONFIG_SPI_FLASH_ROM_IMPL is not set CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y # CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set @@ -1656,13 +2490,20 @@ CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 # # Auto-detect flash chips # -CONFIG_SPI_FLASH_VENDOR_XMC_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_GD_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_ISSI_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_MXIC_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_WINBOND_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_BOYA_SUPPORTED=y -CONFIG_SPI_FLASH_VENDOR_TH_SUPPORTED=y +# default: +CONFIG_SPI_FLASH_VENDOR_XMC_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_GD_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_ISSI_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_MXIC_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_WINBOND_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_BOYA_SUPPORT_ENABLED=y +# default: +CONFIG_SPI_FLASH_VENDOR_TH_SUPPORT_ENABLED=y CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y @@ -1745,12 +2586,17 @@ CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y # CONFIG_VFS_SELECT_IN_RAM is not set CONFIG_VFS_SUPPORT_TERMIOS=y CONFIG_VFS_MAX_COUNT=8 +# default: +# CONFIG_VFS_SUPPRESS_CTX_DEPRECATION is not set # # Host File System I/O (Semihosting) # CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 # end of Host File System I/O (Semihosting) + +# default: +CONFIG_VFS_INITIALIZE_DEV_NULL=y # end of Virtual file system # @@ -1758,18 +2604,9 @@ CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 # # CONFIG_WL_SECTOR_SIZE_512 is not set CONFIG_WL_SECTOR_SIZE_4096=y +# default: CONFIG_WL_SECTOR_SIZE=4096 # end of Wear Levelling - -# -# Wi-Fi Provisioning Manager -# -CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 -CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 -# CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION is not set -CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y -# CONFIG_WIFI_PROV_STA_FAST_SCAN is not set -# end of Wi-Fi Provisioning Manager # end of Component config # CONFIG_IDF_EXPERIMENTAL_FEATURES is not set @@ -1777,6 +2614,8 @@ CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y # Deprecated options for backward compatibility # CONFIG_APP_BUILD_TYPE_ELF_RAM is not set # CONFIG_NO_BLOBS is not set +# CONFIG_APP_ROLLBACK_ENABLE is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set # CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set # CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set # CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set @@ -1784,7 +2623,6 @@ CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y # CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set # CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set CONFIG_LOG_BOOTLOADER_LEVEL=3 -# CONFIG_APP_ROLLBACK_ENABLE is not set # CONFIG_FLASH_ENCRYPTION_ENABLED is not set # CONFIG_FLASHMODE_QIO is not set # CONFIG_FLASHMODE_QOUT is not set @@ -1806,11 +2644,9 @@ CONFIG_STACK_CHECK_NONE=y # CONFIG_STACK_CHECK_STRONG is not set # CONFIG_STACK_CHECK_ALL is not set # CONFIG_WARN_WRITE_STRINGS is not set -# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set -CONFIG_ESP32_APPTRACE_DEST_NONE=y -CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y # CONFIG_EXTERNAL_COEX_ENABLE is not set # CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE is not set +# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set # CONFIG_EVENT_LOOP_PROFILING is not set CONFIG_POST_EVENTS_FROM_ISR=y CONFIG_POST_EVENTS_FROM_IRAM_ISR=y @@ -1824,6 +2660,38 @@ CONFIG_ESP32C3_RTC_CLK_SRC_INT_RC=y # CONFIG_ESP32C3_RTC_CLK_SRC_EXT_OSC is not set # CONFIG_ESP32C3_RTC_CLK_SRC_INT_8MD256 is not set CONFIG_ESP32C3_RTC_CLK_CAL_CYCLES=1024 +CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y +CONFIG_BROWNOUT_DET=y +CONFIG_ESP32C3_BROWNOUT_DET=y +CONFIG_BROWNOUT_DET_LVL_SEL_7=y +CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_7=y +# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_2 is not set +CONFIG_BROWNOUT_DET_LVL=7 +CONFIG_ESP32C3_BROWNOUT_DET_LVL=7 +CONFIG_ESP_SYSTEM_BROWNOUT_INTR=y +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set +CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y +CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y +CONFIG_ESP32C3_TIME_SYSCALL_USE_RTC_SYSTIMER=y +# CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32C3_TIME_SYSCALL_USE_RTC is not set +# CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT is not set +# CONFIG_ESP32C3_TIME_SYSCALL_USE_SYSTIMER is not set +# CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE is not set +# CONFIG_ESP32C3_TIME_SYSCALL_USE_NONE is not set CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y # CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 @@ -1831,21 +2699,25 @@ CONFIG_ESP32_PHY_MAX_TX_POWER=20 # CONFIG_REDUCE_PHY_TX_POWER is not set # CONFIG_ESP32_REDUCE_PHY_TX_POWER is not set CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU=y +CONFIG_CONSOLE_UART_DEFAULT=y +# CONFIG_CONSOLE_UART_CUSTOM is not set +# CONFIG_CONSOLE_UART_NONE is not set +# CONFIG_ESP_CONSOLE_UART_NONE is not set +CONFIG_CONSOLE_UART=y +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_BAUDRATE=115200 # CONFIG_ESP32C3_DEFAULT_CPU_FREQ_80 is not set CONFIG_ESP32C3_DEFAULT_CPU_FREQ_160=y CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ=160 +CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT=y +CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_VIA_TEE=y +CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=y CONFIG_ESP32C3_MEMPROT_FEATURE=y +CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK=y CONFIG_ESP32C3_MEMPROT_FEATURE_LOCK=y CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 CONFIG_MAIN_TASK_STACK_SIZE=3584 -CONFIG_CONSOLE_UART_DEFAULT=y -# CONFIG_CONSOLE_UART_CUSTOM is not set -# CONFIG_CONSOLE_UART_NONE is not set -# CONFIG_ESP_CONSOLE_UART_NONE is not set -CONFIG_CONSOLE_UART=y -CONFIG_CONSOLE_UART_NUM=0 -CONFIG_CONSOLE_UART_BAUDRATE=115200 CONFIG_INT_WDT=y CONFIG_INT_WDT_TIMEOUT_MS=300 CONFIG_TASK_WDT=y @@ -1855,25 +2727,9 @@ CONFIG_TASK_WDT_TIMEOUT_S=5 CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y # CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set CONFIG_ESP32C3_DEBUG_OCDAWARE=y -CONFIG_BROWNOUT_DET=y -CONFIG_ESP32C3_BROWNOUT_DET=y -CONFIG_ESP32C3_BROWNOUT_DET=y -CONFIG_BROWNOUT_DET_LVL_SEL_7=y -CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_7=y -# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_2 is not set -CONFIG_BROWNOUT_DET_LVL=7 -CONFIG_ESP32C3_BROWNOUT_DET_LVL=7 CONFIG_IPC_TASK_STACK_SIZE=1024 CONFIG_TIMER_TASK_STACK_SIZE=3584 +# CONFIG_ESP32_APPTRACE_ENABLE is not set CONFIG_ESP32_WIFI_ENABLED=y CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 @@ -1885,8 +2741,6 @@ CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y CONFIG_ESP32_WIFI_TX_BA_WIN=6 CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y -CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y -CONFIG_ESP32_WIFI_RX_BA_WIN=6 CONFIG_ESP32_WIFI_RX_BA_WIN=6 CONFIG_ESP32_WIFI_NVS_ENABLED=y CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 @@ -1906,7 +2760,6 @@ CONFIG_WPA_MBEDTLS_TLS_CLIENT=y # CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set # CONFIG_WPA_WPS_STRICT is not set # CONFIG_WPA_DEBUG_PRINT is not set -# CONFIG_WPA_TESTING_OPTIONS is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y @@ -1936,10 +2789,8 @@ CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y # CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF # CONFIG_PPP_SUPPORT is not set -CONFIG_ESP32C3_TIME_SYSCALL_USE_RTC_SYSTIMER=y -# CONFIG_ESP32C3_TIME_SYSCALL_USE_RTC is not set -# CONFIG_ESP32C3_TIME_SYSCALL_USE_SYSTIMER is not set -# CONFIG_ESP32C3_TIME_SYSCALL_USE_NONE is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 CONFIG_ESP32_PTHREAD_STACK_MIN=768 From 6ee42b3d8a941e158ae1721157a6a8be1e4d666a Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 08:30:31 -0500 Subject: [PATCH 17/95] Run the U64 WiFi bridge UART ISR and dispatch on core 1, out of flash The WiFi task runs on core 0. esp_intr_alloc() binds an interrupt to the core it is called on, so my_uart_init() now runs from a short task pinned to core 1, which keeps the UART ISR off the core (and cache) the WiFi driver is using. The ISR, the UART buffer code, hacked_recv() and dispatch() move to IRAM with a linker fragment (noflash). The ISR is allocated with flags 0 and is not an IRAM-safe interrupt: it must not run while the flash cache is off, and the buffer code it calls is in IRAM anyway. The dispatch task is pinned to core 1 at priority 19 so it runs where the ISR feeds it. Also checks the init semaphore and the task create. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/main/CMakeLists.txt | 3 ++- software/wifi/raw_u64/main/linker.lf | 7 +++++++ software/wifi/raw_u64/main/rpc_dispatch.c | 3 ++- software/wifi/raw_u64/main/wifi_modem.c | 18 +++++++++++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 software/wifi/raw_u64/main/linker.lf diff --git a/software/wifi/raw_u64/main/CMakeLists.txt b/software/wifi/raw_u64/main/CMakeLists.txt index 2e90c78dd..a3895b1f9 100644 --- a/software/wifi/raw_u64/main/CMakeLists.txt +++ b/software/wifi/raw_u64/main/CMakeLists.txt @@ -1,3 +1,4 @@ set(EXTERNAL "../../../io/uart") idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${EXTERNAL}/cmd_buffer.c - INCLUDE_DIRS "." ${EXTERNAL}) \ No newline at end of file + INCLUDE_DIRS "." ${EXTERNAL} + LDFRAGMENTS "linker.lf") \ No newline at end of file diff --git a/software/wifi/raw_u64/main/linker.lf b/software/wifi/raw_u64/main/linker.lf new file mode 100644 index 000000000..944c75926 --- /dev/null +++ b/software/wifi/raw_u64/main/linker.lf @@ -0,0 +1,7 @@ +[mapping:raw_u64_hot] +archive: libmain.a +entries: + my_uart (noflash) + cmd_buffer (noflash) + wifi_modem:hacked_recv (noflash) + rpc_dispatch:dispatch (noflash) diff --git a/software/wifi/raw_u64/main/rpc_dispatch.c b/software/wifi/raw_u64/main/rpc_dispatch.c index 68a618e2e..4a97e539a 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.c +++ b/software/wifi/raw_u64/main/rpc_dispatch.c @@ -335,7 +335,8 @@ void dispatch(void *ct) void start_dispatch(QueueHandle_t queue) { - xTaskCreate( dispatch, "Dispatch Task", DISPATCHER_STACK, queue, tskIDLE_PRIORITY + 1, NULL ); + // Core 1, above the system tasks: the UART ISR that feeds this queue runs on core 1 too + xTaskCreatePinnedToCore( dispatch, "Dispatch Task", DISPATCHER_STACK, queue, 19, NULL, 1 ); } #if MULTITHREADED diff --git a/software/wifi/raw_u64/main/wifi_modem.c b/software/wifi/raw_u64/main/wifi_modem.c index 0edba58f6..e9fd7fec1 100644 --- a/software/wifi/raw_u64/main/wifi_modem.c +++ b/software/wifi/raw_u64/main/wifi_modem.c @@ -835,6 +835,18 @@ static void start_connector() xTaskCreate(connect_thread, "Connector", 4096, NULL, tskIDLE_PRIORITY + 1, NULL); } +static SemaphoreHandle_t uart_init_done; +static esp_err_t uart_init_result; + +// esp_intr_alloc() binds the interrupt to the core it is called on. The UART ISR must not share +// core 0 (and its cache) with the WiFi task, so the init runs on core 1. +static void uart_init_task(void *a) +{ + uart_init_result = my_uart_init(&work_buffers, UART_NUM_1); + xSemaphoreGive(uart_init_done); + vTaskDelete(NULL); +} + void setup_modem() { // Initialize NVS @@ -859,7 +871,11 @@ void setup_modem() #endif ESP_LOGI(TAG, "my_uart_init..."); // Now install the driver for UART1. We use our own buffer mechanism and interrupt routine - ESP_ERROR_CHECK(my_uart_init(&work_buffers, UART_NUM_1)); + uart_init_done = xSemaphoreCreateBinary(); + ESP_ERROR_CHECK(uart_init_done ? ESP_OK : ESP_ERR_NO_MEM); + ESP_ERROR_CHECK(xTaskCreatePinnedToCore(uart_init_task, "uart_init", 3072, NULL, tskIDLE_PRIORITY + 2, NULL, 1) == pdPASS ? ESP_OK : ESP_ERR_NO_MEM); + xSemaphoreTake(uart_init_done, portMAX_DELAY); + ESP_ERROR_CHECK(uart_init_result); ESP_LOGI(TAG, "wifi_init..."); wifi_init(); From 0676f7b1bf02ff19fee35919d3ddeff70a58bfb2 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 23 Oct 2026 15:52:41 -0500 Subject: [PATCH 18/95] Build all three ESP32 modules in the ESP-IDF 6 image in CI With raw_c3 on ESP-IDF 6, none of the ESP32 modules needs ESP-IDF 5.3.1 any more, so CI builds all of them with one `make esp32` in the pinned espressif/idf:v6.0.3 image instead of one module in my_docker_image and two beside it. The ESP32 cache key no longer names my_docker_image's image id, since that image does not build them now. README.txt and the three module READMEs lose the notes that said the modules need different ESP-IDF versions and that `make` could not complete with one IDF_PATH. They now say all three need ESP-IDF 6 and that docker/Dockerfile still installs 5.3.1. raw_c3 gets a Building section like the other two. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/build.yml | 20 ++++---------------- README.txt | 15 ++++++++------- software/u64ctrl/README.md | 14 ++++++-------- software/wifi/raw_c3/README.md | 22 +++++++++++++++++++++- software/wifi/raw_u64/README.md | 12 +++++------- 5 files changed, 44 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 84f7d05f1..df1a9e27a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository runs-on: self-hosted env: - # u64ctrl and raw_u64 need ESP-IDF 6, so they build here; raw_c3 stays on my_docker_image's 5.3.1 + # The ESP32 modules (raw_u64, raw_c3, u64ctrl) need ESP-IDF 6, so they build here, not in my_docker_image IDF6_IMAGE: espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 steps: - name: Checkout repository @@ -218,13 +218,6 @@ jobs: restore-keys: | ${{ runner.os }}-u2pl-${{ hashFiles('target/fpga/depends/u2pl.txt') }} - # The ESP32 cache key names both build images, so a rebuilt my_docker_image misses too - - name: Identify ESP32 Build Images - run: | - image_id=$(docker image inspect --format '{{.Id}}' my_docker_image) - test -n "$image_id" - echo "ESP32_IMAGE_ID=$image_id" >> $GITHUB_ENV - - name: Cache ESP32 Targets id: cache-esp32 uses: actions/cache@v6 @@ -239,20 +232,15 @@ jobs: software/wifi/raw_u64/build/bridge.bin software/wifi/raw_u64/build/bootloader/bootloader.bin software/wifi/raw_u64/build/partition_table/partition-table.bin - key: ${{ runner.os }}-esp32-${{ env.ESP32_IMAGE_ID }}-${{ env.IDF6_IMAGE }}-${{ hashFiles('software/esp_depends.txt') }} + key: ${{ runner.os }}-esp32-${{ env.IDF6_IMAGE }}-${{ hashFiles('software/esp_depends.txt') }} restore-keys: | - ${{ runner.os }}-esp32-${{ env.ESP32_IMAGE_ID }}-${{ env.IDF6_IMAGE }}-${{ hashFiles('software/esp_depends.txt') }} + ${{ runner.os }}-esp32-${{ env.IDF6_IMAGE }}-${{ hashFiles('software/esp_depends.txt') }} - if: steps.cache-esp32.outputs.cache-hit != 'true' name: Build ESP32 Software (skipped if available in cache) run: | - docker run --rm --net=custom_network --mac-address=4c:cc:6a:06:b3:79 \ - -v /opt/build-tools:/mnt/build-tools:ro \ - -v $GITHUB_WORKSPACE:/mnt/project:rw my_docker_image /bin/bash -c "cd /mnt/project && make esp32_raw_c3" - docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp \ - -v $GITHUB_WORKSPACE:/mnt/project:rw --workdir /mnt/project/software/u64ctrl $IDF6_IMAGE idf.py build docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp \ - -v $GITHUB_WORKSPACE:/mnt/project:rw --workdir /mnt/project/software/wifi/raw_u64 $IDF6_IMAGE idf.py build + -v $GITHUB_WORKSPACE:/mnt/project:rw --workdir /mnt/project $IDF6_IMAGE make esp32 - if: steps.cache-u2.outputs.cache-hit != 'true' name: Build U2 including FPGAs diff --git a/README.txt b/README.txt index 1156133ba..e3a3dc9cb 100644 --- a/README.txt +++ b/README.txt @@ -18,7 +18,7 @@ U2+: U2+L: - Lattice Diamond 3.13 with a (free) generated license - RiscV GNU C/C++ Compiler (for RV32I), same as for U2/RiscV. -- Espressif IDF 5.x +- Espressif IDF 6.x U64: - Altera Quartus (tested with 18.1 Lite Edition) - for the Nios-II compiler only. @@ -40,7 +40,7 @@ In this file, you need to set the location of your Xilinx ISE toolchain. Building targets ================ -ALL targets can be built by just typing 'make' in the root of the repository (see the ESP32 module notes below). +ALL targets can be built by just typing 'make' in the root of the repository (see the ESP32 note below). In order to build for U2 only, use the 'u2_rv' target in the top level makefile. This will build the FPGAs as well as the RiscV based software, including all updaters. @@ -54,11 +54,12 @@ For the U2+L, you can build the 'u2pl' target. The U64 firmware can be built by typing 'make u64'. The U64E-II firmware can be built by typing 'make u64ii' -The ESP32 module firmware of the U64 (software/wifi/raw_u64) and of the U64E-II (software/u64ctrl) needs ESP-IDF 6, -while the one of the U2+L (software/wifi/raw_c3) still needs 5.3.1. So 'make u64' and 'make u64ii' need IDF_PATH to -be an ESP-IDF 6, 'make u2pl' needs 5.3.1, and 'make' (all), 'make esp32' and 'make clean' cannot complete with a -single IDF_PATH. Build the modules as software/wifi/raw_u64/README.md and software/u64ctrl/README.md show, and then -run 'make u64_no_esp' and 'make u64ii_no_esp'. +The ESP32 module firmware (software/wifi/raw_u64 for the U64, software/wifi/raw_c3 for the U2+L and +software/u64ctrl for the U64E-II) needs ESP-IDF 6, so IDF_PATH has to be an ESP-IDF 6 for 'make', 'make esp32', +'make u64', 'make u64ii', 'make u2pl' and 'make clean'. The Dockerfile in docker/ still installs ESP-IDF 5.3.1; CI +builds the modules in the espressif/idf:v6.0.3 image (see .github/workflows/build.yml) and then packs them with +'make u64_no_esp', 'make u64ii_no_esp' and 'make u2pl_no_esp'. The README.md in each module directory shows the +command. ==> When using the top level makefile, the results are copied into the root of the project. diff --git a/software/u64ctrl/README.md b/software/u64ctrl/README.md index f98787863..ee5ade216 100644 --- a/software/u64ctrl/README.md +++ b/software/u64ctrl/README.md @@ -5,20 +5,18 @@ The ESP32-S3 module of the Ultimate 64 Elite II and the C64 Ultimate: WiFi, powe ## Building The module needs ESP-IDF 6 (CI uses v6.0.3); `CMakeLists.txt` stops an older one at configure. -raw_c3 still builds with ESP-IDF 5.3.1, as in `docker/Dockerfile`, so CI builds this -project (and raw_u64) in `espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. Locally, from -the top of the repository, the same way as CI: +`docker/Dockerfile` still installs ESP-IDF 5.3.1, so CI builds this project (and raw_u64 and raw_c3) in +`espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. Locally, from the top of +the repository, the same way as CI: docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp -v "$PWD":/project -w /project/software/u64ctrl \ espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 idf.py build then `make u64ii_no_esp` packs `build/u64ctrl.bin` into the update files. `make esp32_u64ctrl` and -`make u64ii` work only where `IDF_PATH` is an ESP-IDF 6, and `make` (all) cannot complete with one -`IDF_PATH`, because raw_c3 needs 5.3.1. Once `build/` exists here, -`make clean` also needs ESP-IDF 6; otherwise delete `software/u64ctrl/build` by hand. +`make u64ii` work only where `IDF_PATH` is an ESP-IDF 6. Once `build/` exists here, `make clean` also +needs ESP-IDF 6; otherwise delete `software/u64ctrl/build` by hand. -`software/io/uart/cmd_buffer.c` is compiled into all three ESP32 projects, so a change to it has to -build on both ESP-IDF 5.3.1 and 6. +`software/io/uart/cmd_buffer.c` is compiled into all three ESP32 projects (raw_u64, raw_c3 and u64ctrl). `sdkconfig` marks values that follow ESP-IDF's defaults with `# default:`; a reconfigure on a newer ESP-IDF takes its new defaults there. After any ESP-IDF update, diff the values, not just the build. diff --git a/software/wifi/raw_c3/README.md b/software/wifi/raw_c3/README.md index dec4d5ebb..7da946296 100644 --- a/software/wifi/raw_c3/README.md +++ b/software/wifi/raw_c3/README.md @@ -1,4 +1,24 @@ -# Wifi SCAN Example +# ESP32-C3 WiFi bridge (raw_c3) + +The WiFi module of the U2+L. + +## Building + +The bridge needs ESP-IDF 6 (CI uses v6.0.3); `CMakeLists.txt` stops an older one at configure. +`docker/Dockerfile` still installs ESP-IDF 5.3.1, so CI builds this project (and raw_u64 and u64ctrl) in +`espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. Locally, from the top of the +repository, the same way as CI: + + docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp -v "$PWD":/project -w /project/software/wifi/raw_c3 \ + espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 idf.py build + +then `make u2pl_no_esp` packs `build/bridge.bin` into the update file. `make esp32_raw_c3` (and so +`make u2pl`) works only where `IDF_PATH` is an ESP-IDF 6. Once `build/` exists here, `make clean` also +needs ESP-IDF 6; otherwise delete `software/wifi/raw_c3/build` by hand. + +`sdkconfig` marks values that follow ESP-IDF's defaults with `# default:`; a reconfigure on a newer +ESP-IDF takes its new defaults there. After any ESP-IDF update, diff the values, not just the build. + This example shows how to use the scan functionality of the Wi-Fi driver of ESP32. diff --git a/software/wifi/raw_u64/README.md b/software/wifi/raw_u64/README.md index b1160d591..0194d5e34 100644 --- a/software/wifi/raw_u64/README.md +++ b/software/wifi/raw_u64/README.md @@ -3,20 +3,18 @@ ## Building The bridge needs ESP-IDF 6 (CI uses v6.0.3); `CMakeLists.txt` stops an older one at configure. -raw_c3 still builds with ESP-IDF 5.3.1, as in `docker/Dockerfile`, so CI builds this -project (and u64ctrl) in `espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. -Locally, from the top of the repository, the same way as CI: +`docker/Dockerfile` still installs ESP-IDF 5.3.1, so CI builds this project (and raw_c3 and u64ctrl) in +`espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. Locally, from the top of the +repository, the same way as CI: docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp -v "$PWD":/project -w /project/software/wifi/raw_u64 \ espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 idf.py build then `make u64_no_esp` packs `build/bridge.bin` into `update.u64`. `make esp32_raw_u64` (and so -`make u64`) works only where `IDF_PATH` is an ESP-IDF 6; `make all` cannot complete with one `IDF_PATH`, -because raw_c3 needs 5.3.1. Once `build/` exists here, +`make u64`) works only where `IDF_PATH` is an ESP-IDF 6. Once `build/` exists here, `make clean` also needs ESP-IDF 6; otherwise delete `software/wifi/raw_u64/build` by hand. -`software/io/uart/cmd_buffer.c` is compiled into all three ESP32 projects, so a change to it has to -build on both ESP-IDF 5.3.1 and 6. +`software/io/uart/cmd_buffer.c` is compiled into all three ESP32 projects (raw_u64, raw_c3 and u64ctrl). `sdkconfig` marks values that follow ESP-IDF's defaults with `# default:`; a reconfigure on a newer ESP-IDF takes its new defaults there. After any ESP-IDF update, diff the values, not just the build. From 464183ef538e4ea444009a9303cb79e88e96b666 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 08:30:31 -0500 Subject: [PATCH 19/95] Raise the U64 WiFi bridge UART FIFO thresholds Trigger the RX FIFO interrupt at 64 bytes instead of 120 and the TX empty interrupt at 64 instead of 10, so the receive ISR has more FIFO left to absorb a delayed service. The RTS flow threshold (122) is unchanged. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/main/my_uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/software/wifi/raw_u64/main/my_uart.c b/software/wifi/raw_u64/main/my_uart.c index 5abd64960..992649445 100644 --- a/software/wifi/raw_u64/main/my_uart.c +++ b/software/wifi/raw_u64/main/my_uart.c @@ -395,8 +395,8 @@ esp_err_t my_uart_init(command_buf_context_t *buffers, uint8_t uart_num) const uart_intr_config_t interrupt_config = { .intr_enable_mask = UART_INTR_RXFIFO_TOUT | UART_INTR_RXFIFO_FULL, .rx_timeout_thresh = 2, - .txfifo_empty_intr_thresh = 10, - .rxfifo_full_thresh = 120, + .txfifo_empty_intr_thresh = 64, + .rxfifo_full_thresh = 64, }; const uart_config_t uart_config = { From 701c8be523793abb935206633f614efaabb1a7b5 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Sat, 24 Oct 2026 23:22:13 -0500 Subject: [PATCH 20/95] Keep FreeRTOS and the ring buffer in IRAM in the U2+L WiFi bridge ESP-IDF 6 moved the FreeRTOS queue/task and ring buffer functions to flash by default (CONFIG_FREERTOS_IN_IRAM and CONFIG_RINGBUF_IN_IRAM are off); ESP-IDF 5.3.1 had them in IRAM. Every frame passes xQueueGenericSend, xQueueReceive and xRingbufferReceive in both directions, so each call can wait on a flash cache miss. Set both options to put them back in IRAM (10,606 B more DRAM, 165,180 B of 321,296 stay free; flash code drops by 10,748 B). The effect was measured on the U64E's classic ESP32 module only (raw_u64: writemem p50/p90/p99 back in the IDF 5.3.1 range, the REST probe and FTP get not fully). On this module it is not measured yet; raw_c3 is only built, not run on hardware. The change is the same two sdkconfig lines. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_c3/sdkconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/software/wifi/raw_c3/sdkconfig b/software/wifi/raw_c3/sdkconfig index 4ba9edecf..8166da6ef 100644 --- a/software/wifi/raw_c3/sdkconfig +++ b/software/wifi/raw_c3/sdkconfig @@ -1044,6 +1044,8 @@ CONFIG_RMT_OBJ_CACHE_SAFE=y # # ESP-Driver:SPI Configurations # +# default: +# CONFIG_SPI_MASTER_IN_IRAM is not set CONFIG_SPI_MASTER_ISR_IN_IRAM=y # CONFIG_SPI_SLAVE_IN_IRAM is not set CONFIG_SPI_SLAVE_ISR_IN_IRAM=y @@ -1427,9 +1429,7 @@ CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU=y # ESP Ringbuf # # default: -# CONFIG_RINGBUF_IN_IRAM is not set -# default: -# CONFIG_RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH is not set +CONFIG_RINGBUF_IN_IRAM=y # end of ESP Ringbuf # @@ -1759,7 +1759,7 @@ CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y # default: CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER=y # default: -# CONFIG_FREERTOS_IN_IRAM is not set +CONFIG_FREERTOS_IN_IRAM=y # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set # end of Port From 938ae4801a8a59bafa2db51edb92c8d882cb79a1 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 08:30:32 -0500 Subject: [PATCH 21/95] Enable CONFIG_ESP_WIFI_EXTRA_IRAM_OPT in the U64 WiFi bridge Put more of the WiFi driver hot path into IRAM, so frames are not delayed by flash cache misses. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/sdkconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/wifi/raw_u64/sdkconfig b/software/wifi/raw_u64/sdkconfig index 2e6ce67be..f01482598 100644 --- a/software/wifi/raw_u64/sdkconfig +++ b/software/wifi/raw_u64/sdkconfig @@ -1531,7 +1531,7 @@ CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0=y CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN=752 CONFIG_ESP_WIFI_MGMT_SBUF_NUM=32 CONFIG_ESP_WIFI_IRAM_OPT=y -# CONFIG_ESP_WIFI_EXTRA_IRAM_OPT is not set +CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y CONFIG_ESP_WIFI_RX_IRAM_OPT=y CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y # default: From 47324cf9085d239bb7166c8bed0bd29c1b239779 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:06:56 -0500 Subject: [PATCH 22/95] Run the U2+L WiFi bridge UART and dispatch code from IRAM Move the UART ISR, the UART buffer code, hacked_recv(), dispatch() and cmd_send_eth_packet() to IRAM with a linker fragment (noflash). Placement only: the chip has one core, so no task is pinned and no priority changes. The ISR flags stay 0, so the interrupt is masked while the flash cache is off (NVS writes) and nothing in the handler has to be safe to run then; the overflow branch calls the flash function uart_hal_rxfifo_rst(), but RXFIFO_OVF is not in the enable mask, so it does not run. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_c3/main/CMakeLists.txt | 3 ++- software/wifi/raw_c3/main/linker.lf | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 software/wifi/raw_c3/main/linker.lf diff --git a/software/wifi/raw_c3/main/CMakeLists.txt b/software/wifi/raw_c3/main/CMakeLists.txt index 3fd03821d..70bef78a3 100644 --- a/software/wifi/raw_c3/main/CMakeLists.txt +++ b/software/wifi/raw_c3/main/CMakeLists.txt @@ -1,3 +1,4 @@ set(EXTERNAL "../../../io/uart") idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${EXTERNAL}/cmd_buffer.c - INCLUDE_DIRS "." ${EXTERNAL}) + INCLUDE_DIRS "." ${EXTERNAL} + LDFRAGMENTS "linker.lf") diff --git a/software/wifi/raw_c3/main/linker.lf b/software/wifi/raw_c3/main/linker.lf new file mode 100644 index 000000000..3ea761ee3 --- /dev/null +++ b/software/wifi/raw_c3/main/linker.lf @@ -0,0 +1,8 @@ +[mapping:raw_c3_hot] +archive: libmain.a +entries: + my_uart (noflash) + cmd_buffer (noflash) + wifi_modem:hacked_recv (noflash) + rpc_dispatch:dispatch (noflash) + rpc_dispatch:cmd_send_eth_packet (noflash) From 344333f7e20e09a8de16a047ea697ef8008c4154 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:24:58 -0500 Subject: [PATCH 23/95] Keep the U64 WiFi bridge per-frame netif and lwip path in IRAM Add noflash entries to the linker fragment for the per-frame path between the WiFi driver and the UART: esp_netif_transmit/receive/free_rx_buffer, wlanif_input, esp_pbuf_allocate/free, pbuf_free, pbuf_alloced_custom, wifi_netif wifi_transmit/wifi_free, mem_malloc/mem_free and esp_wifi_internal_free_rx_buffer. pbuf_free() and mem_malloc() also take the lwIP lock through sys_arch_protect() and sys_arch_unprotect(), which would still run from flash on every frame, and with -O2 the lock is split into a sys_mutex_lock.part.0 helper that a per-function mapping does not reach. Map the whole sys_arch object to IRAM (about 1.1 KB). cmd_send_eth_packet() and pbuf_init_alloced_pbuf() are inlined at -O2, so they need no entry. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/main/linker.lf | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/software/wifi/raw_u64/main/linker.lf b/software/wifi/raw_u64/main/linker.lf index 944c75926..cb9337427 100644 --- a/software/wifi/raw_u64/main/linker.lf +++ b/software/wifi/raw_u64/main/linker.lf @@ -5,3 +5,33 @@ entries: cmd_buffer (noflash) wifi_modem:hacked_recv (noflash) rpc_dispatch:dispatch (noflash) + +[mapping:raw_u64_netif] +archive: libesp_netif.a +entries: + esp_netif_lwip:esp_netif_transmit (noflash) + esp_netif_lwip:esp_netif_receive (noflash) + esp_netif_lwip:esp_netif_free_rx_buffer (noflash) + wlanif:wlanif_input (noflash) + esp_pbuf_ref:esp_pbuf_allocate (noflash) + esp_pbuf_ref:esp_pbuf_free (noflash) + +[mapping:raw_u64_wifi_netif] +archive: libesp_wifi.a +entries: + wifi_netif:wifi_transmit (noflash) + wifi_netif:wifi_free (noflash) + +[mapping:raw_u64_pp] +archive: libpp.a +entries: + if_hwctrl:esp_wifi_internal_free_rx_buffer (noflash) + +[mapping:raw_u64_lwip] +archive: liblwip.a +entries: + pbuf:pbuf_free (noflash) + pbuf:pbuf_alloced_custom (noflash) + mem:mem_malloc (noflash) + mem:mem_free (noflash) + sys_arch (noflash) From 2bf097f181fb6978e6ddc1517d2fbb0a20ad863e Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:10:13 -0500 Subject: [PATCH 24/95] Keep more of the WiFi driver in IRAM in the U2+L WiFi bridge (ESP_WIFI_EXTRA_IRAM_OPT) The option is off by default for the ESP32-C3 and places more of the WiFi driver send and receive code in IRAM. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_c3/sdkconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/wifi/raw_c3/sdkconfig b/software/wifi/raw_c3/sdkconfig index 8166da6ef..530842e6b 100644 --- a/software/wifi/raw_c3/sdkconfig +++ b/software/wifi/raw_c3/sdkconfig @@ -1586,7 +1586,7 @@ CONFIG_ESP_WIFI_NVS_ENABLED=y CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN=752 CONFIG_ESP_WIFI_MGMT_SBUF_NUM=32 CONFIG_ESP_WIFI_IRAM_OPT=y -# CONFIG_ESP_WIFI_EXTRA_IRAM_OPT is not set +CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y CONFIG_ESP_WIFI_RX_IRAM_OPT=y CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y # default: From 3996eed7ee7e071239bc10b96d99104ae35f4854 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 08:30:32 -0500 Subject: [PATCH 25/95] Build the U64 WiFi bridge with -O2 Set CONFIG_COMPILER_OPTIMIZATION_PERF (sdkconfig as idf.py 6.0.3 writes it, which also drops CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER) and remove the unused _err in cmd_send_eth_packet. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/main/rpc_dispatch.c | 2 +- software/wifi/raw_u64/sdkconfig | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/software/wifi/raw_u64/main/rpc_dispatch.c b/software/wifi/raw_u64/main/rpc_dispatch.c index 4a97e539a..98ada083d 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.c +++ b/software/wifi/raw_u64/main/rpc_dispatch.c @@ -157,7 +157,7 @@ extern esp_netif_t *my_sta_netif; void cmd_send_eth_packet(command_buf_t *buf) { rpc_send_eth_req *param = (rpc_send_eth_req *)buf->data; - err_t _err = esp_netif_transmit(my_sta_netif, ¶m->data, param->length); + esp_netif_transmit(my_sta_netif, ¶m->data, param->length); my_uart_free_buffer(UART_CHAN, buf); } diff --git a/software/wifi/raw_u64/sdkconfig b/software/wifi/raw_u64/sdkconfig index f01482598..2db5170f5 100644 --- a/software/wifi/raw_u64/sdkconfig +++ b/software/wifi/raw_u64/sdkconfig @@ -658,9 +658,9 @@ CONFIG_EXAMPLE_FAST_SCAN_WEAKEST_AUTHMODE_OPEN=y # # Compiler options # -CONFIG_COMPILER_OPTIMIZATION_DEBUG=y +# CONFIG_COMPILER_OPTIMIZATION_DEBUG is not set # CONFIG_COMPILER_OPTIMIZATION_SIZE is not set -# CONFIG_COMPILER_OPTIMIZATION_PERF is not set +CONFIG_COMPILER_OPTIMIZATION_PERF=y # CONFIG_COMPILER_OPTIMIZATION_NONE is not set CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set @@ -1687,7 +1687,6 @@ CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=1 # # Port # -CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y # CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS=y # CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK is not set @@ -2570,9 +2569,9 @@ CONFIG_LOG_BOOTLOADER_LEVEL=3 CONFIG_FLASHMODE_DIO=y # CONFIG_FLASHMODE_DOUT is not set CONFIG_MONITOR_BAUD=115200 -CONFIG_OPTIMIZATION_LEVEL_DEBUG=y -CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y -CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y +# CONFIG_OPTIMIZATION_LEVEL_DEBUG is not set +# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set +# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set # CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set # CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y From 9b1a52e38b4a9bb22a763c4ae1e21f2a2e70a8c7 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:10:13 -0500 Subject: [PATCH 26/95] Run the netif, pbuf and heap path of the U2+L WiFi bridge from IRAM Place esp_netif_transmit/receive/free_rx_buffer, wlanif_input, esp_pbuf_allocate/free, wifi_transmit/free, esp_wifi_internal_free_rx_buffer, pbuf_free, pbuf_alloced_custom, pbuf_init_alloced_pbuf, mem_malloc, mem_free, sys_arch_protect/unprotect and sys_mutex_lock/unlock in IRAM (noflash), so the per-packet path between the WiFi driver and the UART bridge no longer calls flash-resident code. What is left in flash is off that path: the one-time sys_mutex_new, the esp_event_post calls guarded by the runtime tx_rx_events_enabled flag, and the command handlers that dispatch() calls for non-packet commands. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_c3/main/linker.lf | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/software/wifi/raw_c3/main/linker.lf b/software/wifi/raw_c3/main/linker.lf index 3ea761ee3..9cf1c705d 100644 --- a/software/wifi/raw_c3/main/linker.lf +++ b/software/wifi/raw_c3/main/linker.lf @@ -6,3 +6,37 @@ entries: wifi_modem:hacked_recv (noflash) rpc_dispatch:dispatch (noflash) rpc_dispatch:cmd_send_eth_packet (noflash) + +[mapping:raw_c3_netif] +archive: libesp_netif.a +entries: + esp_netif_lwip:esp_netif_transmit (noflash) + esp_netif_lwip:esp_netif_receive (noflash) + esp_netif_lwip:esp_netif_free_rx_buffer (noflash) + wlanif:wlanif_input (noflash) + esp_pbuf_ref:esp_pbuf_allocate (noflash) + esp_pbuf_ref:esp_pbuf_free (noflash) + +[mapping:raw_c3_wifi_netif] +archive: libesp_wifi.a +entries: + wifi_netif:wifi_transmit (noflash) + wifi_netif:wifi_free (noflash) + +[mapping:raw_c3_pp] +archive: libpp.a +entries: + if_hwctrl:esp_wifi_internal_free_rx_buffer (noflash) + +[mapping:raw_c3_lwip] +archive: liblwip.a +entries: + pbuf:pbuf_free (noflash) + pbuf:pbuf_alloced_custom (noflash) + pbuf:pbuf_init_alloced_pbuf (noflash) + mem:mem_malloc (noflash) + mem:mem_free (noflash) + sys_arch:sys_arch_protect (noflash) + sys_arch:sys_arch_unprotect (noflash) + sys_arch:sys_mutex_lock (noflash) + sys_arch:sys_mutex_unlock (noflash) From d22137fa3f3fd3b8b91caf45fbce80ae660e4327 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:27:16 -0500 Subject: [PATCH 27/95] Turn the radio off with Disable on the U64 and U2+L, and make WiFi Enabled work On the Ultimate 64 and Ultimate II+L, Disable only stopped the Ultimate's WiFi task: the module stayed associated and transmitting, and "WiFi Enabled" = Disabled did nothing until the next boot, which then did not start the module. Disable and Enable now send CMD_WIFI_DISABLE / CMD_WIFI_ENABLE, as on the Elite II and C64 Ultimate, and the module serves them with the control module's connector code: radio_stop() / radio_start() (software/wifi/common, esp_wifi_stop/start in one place), EVENT_DISABLED, a Disabled state. The WiFi module and task keep running whatever the setting, so remote wake-up and the default (Enabled) are unchanged; Disabled means radio off. - The module starts with its radio off. The task turns it on (setting Enabled) or keeps it off (Disabled) as soon as it finds the module. Disabled is shown when the module confirms; link events are dropped until then, and after 10 s without confirmation the task follows the module's link state again. - An older Ultimate application never sends Enable: its connection query, with no Disable since CMD_IDENTIFY, starts the radio as before. An older module answers Disable with "not supported"; the task then holds the module off as before. - A restart of the module's own (crash, watchdog, brownout) restores the radio as it was, from a checked record in RTC memory, and sends EVENT_RESTARTED. - On the U64 and U2+L "WiFi Enabled" is the one switch: the menu's Enable and Disable (context menu and config menu) set it and save it when it changes, and its change hook turns the radio on or off; a boot reads it. (The Elite II / C64 Ultimate actions are unchanged.) - A Disable or Autoconnect taken while the connector walks its AP lists is kept. Host tests: software/io/wifi/tests (task), software/wifi/tests (module), each with a -red target that runs the same checks against the code as it was. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Claude Sonnet 5.5 --- Makefile | 2 + software/esp_depends.py | 2 +- software/io/network/network_esp32.cc | 77 +++- software/io/network/network_esp32.h | 7 + software/io/wifi/tests/Makefile | 108 +++++ software/io/wifi/tests/extract.awk | 14 + .../wifi/tests/legacy/fix1_radio_switch.sed | 12 + software/io/wifi/tests/stubs/FreeRTOS.h | 22 + software/io/wifi/tests/stubs/browsable.h | 39 ++ software/io/wifi/tests/stubs/dma_uart.h | 20 + software/io/wifi/tests/stubs/dump_hex.h | 1 + software/io/wifi/tests/stubs/lwip/netdb.h | 1 + software/io/wifi/tests/stubs/lwip/sockets.h | 3 + software/io/wifi/tests/stubs/menu.h | 1 + software/io/wifi/tests/stubs/queue.h | 1 + software/io/wifi/tests/stubs/semphr.h | 1 + software/io/wifi/tests/stubs/size_str.h | 1 + software/io/wifi/tests/stubs/task.h | 1 + software/io/wifi/tests/switch_task_test.cpp | 395 +++++++++++++++++ software/io/wifi/tests/wifi_switch_test.cpp | 246 +++++++++++ software/io/wifi/tests/wifi_task_env.h | 88 ++++ software/io/wifi/tests/wifi_task_stubs.cpp | 208 +++++++++ software/io/wifi/tests/wifi_task_test.h | 64 +++ software/io/wifi/wifi.cc | 154 ++++++- software/io/wifi/wifi.h | 13 + software/io/wifi/wifi_cmd.cc | 2 +- software/io/wifi/wifi_cmd.h | 2 + software/io/wifi/wifi_switch.h | 138 ++++++ software/wifi/common/radio_boot.c | 37 ++ software/wifi/common/radio_boot.h | 45 ++ software/wifi/common/wifi_radio.c | 40 ++ software/wifi/common/wifi_radio.h | 29 ++ software/wifi/common/wifi_radio_esp.c | 20 + software/wifi/common/wifi_radio_port.h | 14 + software/wifi/raw_c3/main/CMakeLists.txt | 5 +- software/wifi/raw_c3/main/rpc_calls.h | 1 + software/wifi/raw_c3/main/rpc_dispatch.c | 34 +- software/wifi/raw_c3/main/wifi_modem.c | 277 ++++++++++-- software/wifi/raw_c3/main/wifi_modem.h | 2 + software/wifi/raw_u64/main/CMakeLists.txt | 7 +- software/wifi/raw_u64/main/rpc_calls.h | 1 + software/wifi/raw_u64/main/rpc_dispatch.c | 34 +- software/wifi/raw_u64/main/wifi_modem.c | 277 ++++++++++-- software/wifi/raw_u64/main/wifi_modem.h | 2 + software/wifi/tests/Makefile | 132 ++++++ software/wifi/tests/module_env.h | 149 +++++++ software/wifi/tests/module_script.h | 87 ++++ software/wifi/tests/module_stubs.c | 416 ++++++++++++++++++ software/wifi/tests/module_switch_test.cpp | 339 ++++++++++++++ software/wifi/tests/radio_test.cpp | 139 ++++++ software/wifi/tests/stub/freertos/FreeRTOS.h | 24 + software/wifi/tests/stub/freertos/queue.h | 1 + software/wifi/tests/stub/lwip/netdb.h | 1 + software/wifi/tests/stub/lwip/sockets.h | 6 + 54 files changed, 3615 insertions(+), 127 deletions(-) create mode 100644 software/io/wifi/tests/Makefile create mode 100644 software/io/wifi/tests/extract.awk create mode 100644 software/io/wifi/tests/legacy/fix1_radio_switch.sed create mode 100644 software/io/wifi/tests/stubs/FreeRTOS.h create mode 100644 software/io/wifi/tests/stubs/browsable.h create mode 100644 software/io/wifi/tests/stubs/dma_uart.h create mode 100644 software/io/wifi/tests/stubs/dump_hex.h create mode 100644 software/io/wifi/tests/stubs/lwip/netdb.h create mode 100644 software/io/wifi/tests/stubs/lwip/sockets.h create mode 100644 software/io/wifi/tests/stubs/menu.h create mode 100644 software/io/wifi/tests/stubs/queue.h create mode 100644 software/io/wifi/tests/stubs/semphr.h create mode 100644 software/io/wifi/tests/stubs/size_str.h create mode 100644 software/io/wifi/tests/stubs/task.h create mode 100644 software/io/wifi/tests/switch_task_test.cpp create mode 100644 software/io/wifi/tests/wifi_switch_test.cpp create mode 100644 software/io/wifi/tests/wifi_task_env.h create mode 100644 software/io/wifi/tests/wifi_task_stubs.cpp create mode 100644 software/io/wifi/tests/wifi_task_test.h create mode 100644 software/io/wifi/wifi_switch.h create mode 100644 software/wifi/common/radio_boot.c create mode 100644 software/wifi/common/radio_boot.h create mode 100644 software/wifi/common/wifi_radio.c create mode 100644 software/wifi/common/wifi_radio.h create mode 100644 software/wifi/common/wifi_radio_esp.c create mode 100644 software/wifi/common/wifi_radio_port.h create mode 100644 software/wifi/tests/Makefile create mode 100644 software/wifi/tests/module_env.h create mode 100644 software/wifi/tests/module_script.h create mode 100644 software/wifi/tests/module_stubs.c create mode 100644 software/wifi/tests/module_switch_test.cpp create mode 100644 software/wifi/tests/radio_test.cpp create mode 100644 software/wifi/tests/stub/freertos/FreeRTOS.h create mode 100644 software/wifi/tests/stub/freertos/queue.h create mode 100644 software/wifi/tests/stub/lwip/netdb.h create mode 100644 software/wifi/tests/stub/lwip/sockets.h diff --git a/Makefile b/Makefile index dbcfb32ff..e33607bc2 100755 --- a/Makefile +++ b/Makefile @@ -82,6 +82,8 @@ host_tests: @$(MAKE) -C target/pc/linux/powerstate test @$(MAKE) -C target/pc/linux/wolmagic test @$(MAKE) -C target/pc/linux/wifireply test + @$(MAKE) -C software/io/wifi/tests + @$(MAKE) -C software/wifi/tests @$(MAKE) -C target/pc/linux/recoveryimage test @$(MAKE) -C target/pc/linux/recoveryurl test diff --git a/software/esp_depends.py b/software/esp_depends.py index 2e8d27305..7d3fcd73c 100644 --- a/software/esp_depends.py +++ b/software/esp_depends.py @@ -11,7 +11,7 @@ def get_hash(path="", hash_type='md5'): return func.hexdigest() # Find dependencies -dirs = [ 'wifi/raw_c3/main', 'wifi/raw_c3', 'wifi/raw_u64/main', 'wifi/raw_u64', 'u64ctrl', 'u64ctrl/main', 'u64ctrl/ca' ] +dirs = [ 'wifi/raw_c3/main', 'wifi/raw_c3', 'wifi/raw_u64/main', 'wifi/raw_u64', 'u64ctrl', 'u64ctrl/main', 'u64ctrl/ca', 'wifi/common' ] ptrns = [ '*.c', '*.h', '*.mk', '*.txt', '*.pem', 'sdkconfig'] fns = [ ] for d in dirs: diff --git a/software/io/network/network_esp32.cc b/software/io/network/network_esp32.cc index e1f3c6fad..ce111ffb7 100644 --- a/software/io/network/network_esp32.cc +++ b/software/io/network/network_esp32.cc @@ -120,8 +120,37 @@ void NetworkLWIP_WiFi :: attach_config() cfg->set_sort_order(SORT_ORDER_CFG_WIFI); cfg->set_change_hook(CFG_NET_DHCP_EN, dhcp_change); dhcp_change(cfg->find_item(CFG_NET_DHCP_EN)); +#if U64 != 2 + cfg->set_change_hook(CFG_WIFI_ENABLE, wifi_enable_change); +#endif +} + +#if U64 != 2 +bool NetworkLWIP_WiFi :: enabled_in_config(void) +{ + return cfg->get_value(CFG_WIFI_ENABLE) != 0; } +// A change of "WiFi Enabled" turns the radio off or on right away. While the WiFi +// application is still looking for the module it does nothing: the application applies +// the setting itself when it finds it. +int NetworkLWIP_WiFi :: wifi_enable_change(ConfigItem *it) +{ + WifiState_t state = wifi.getState(); + if ((state == eWifi_Download) || (state == eWifi_NotDetected) || (state == eWifi_ModuleDetected)) { + return 0; + } + // Also while a radio off waits for its confirmation: an Enable then is not lost + bool off = (state == eWifi_Off) || (state == eWifi_Disabled) || wifi.RadioOffAwaited(); + if (it->getValue() && off) { + wifi.RadioOn(); + } else if (!it->getValue() && !off) { + wifi.RadioOff(); + } + return 0; +} +#endif + // from ConfigurableObject void NetworkLWIP_WiFi :: effectuate_settings(void) { @@ -137,13 +166,9 @@ void NetworkLWIP_WiFi :: effectuate_settings(void) // wifi.RadioOff(); // } #else - if (wifi.getState() == eWifi_Off && cfg->get_value(CFG_WIFI_ENABLE)) { - wifi.Enable(); - } -// For now, we don't disable the Wifi here, because effectuate_settings is also called when the init callback of the network stack occurs, OWWW -// else if (wifi.getState() != eWifi_Off && !cfg->get_value(CFG_WIFI_ENABLE)) { -// wifi.Disable(); -// } + // The WiFi application always runs (WiFi::Init). The setting is applied by the + // application when it finds the module, and by its change hook; not here, because + // this also runs when the init callback of the network stack occurs. #endif } @@ -338,14 +363,40 @@ void NetworkLWIP_WiFi :: cfg_disconn(UserInterface *intf, ConfigItem *it) wifi_wifi_disconnect(); } +#if U64 != 2 +// One switch: "WiFi Enabled" is what the Enable and Disable actions set, what its change hook +// acts on (it turns the radio on or off), and what the next boot reads. It is saved when it +// changes. +void NetworkLWIP_WiFi :: set_enabled(bool on) +{ + ConfigStore *cfg = ConfigManager :: getConfigManager()->find_store((uint32_t)0x57494649); + if (!cfg) { + return; + } + bool changed = (cfg->get_value(CFG_WIFI_ENABLE) != 0) != on; + cfg->set_value(CFG_WIFI_ENABLE, on ? 1 : 0); + if (changed) { + cfg->write(); + } +} +#endif + void NetworkLWIP_WiFi :: cfg_enable(UserInterface *intf, ConfigItem *it) { +#if U64 != 2 + set_enabled(true); +#else wifi.RadioOn(); +#endif } void NetworkLWIP_WiFi :: cfg_disable(UserInterface *intf, ConfigItem *it) { +#if U64 != 2 + set_enabled(false); +#else wifi.RadioOff(); +#endif } void NetworkLWIP_WiFi :: cfg_forget(UserInterface *intf, ConfigItem *it) @@ -371,20 +422,20 @@ SubsysResultCode_e NetworkLWIP_WiFi :: rescan(SubsysCommand *cmd) SubsysResultCode_e NetworkLWIP_WiFi :: disable(SubsysCommand *cmd) { -#if U64 == 2 - wifi.RadioOff(); +#if U64 != 2 + set_enabled(false); #else - wifi.Disable(); + wifi.RadioOff(); #endif return SSRET_OK; } SubsysResultCode_e NetworkLWIP_WiFi :: enable(SubsysCommand *cmd) { -#if U64 == 2 - wifi.RadioOn(); +#if U64 != 2 + set_enabled(true); #else - wifi.Enable(); + wifi.RadioOn(); #endif return SSRET_OK; } diff --git a/software/io/network/network_esp32.h b/software/io/network/network_esp32.h index 8fc84ed18..be85ea9c3 100644 --- a/software/io/network/network_esp32.h +++ b/software/io/network/network_esp32.h @@ -47,6 +47,9 @@ class NetworkLWIP_WiFi : public NetworkInterface static SubsysResultCode_e disconnect(SubsysCommand *cmd); static SubsysResultCode_e rescan(SubsysCommand *cmd); static SubsysResultCode_e enable(SubsysCommand *cmd); +#if U64 != 2 + static void set_enabled(bool on); +#endif static SubsysResultCode_e disable(SubsysCommand *cmd); static SubsysResultCode_e manual_connect(SubsysCommand *cmd); static SubsysResultCode_e auto_connect(SubsysCommand *cmd); @@ -59,6 +62,10 @@ class NetworkLWIP_WiFi : public NetworkInterface static void cfg_enable(UserInterface *intf, ConfigItem *it); static void cfg_disable(UserInterface *intf, ConfigItem *it); static void cfg_forget(UserInterface *intf, ConfigItem *it); +#if U64 != 2 + static int wifi_enable_change(ConfigItem *it); + bool enabled_in_config(void); +#endif // from ConfigurableObject void effectuate_settings(void); diff --git a/software/io/wifi/tests/Makefile b/software/io/wifi/tests/Makefile new file mode 100644 index 000000000..2c89fba52 --- /dev/null +++ b/software/io/wifi/tests/Makefile @@ -0,0 +1,108 @@ +# Host tests of the Ultimate's WiFi application (software/io/wifi). The code under test is +# cut out of wifi.cc, wifi_cmd.cc and network_esp32.cc as it is (extract.awk), and built +# with the real wifi.h, esp32.h, wifi_cmd.h and wifi_switch.h against the stand-ins of +# stubs/ and wifi_task_env.h. Every *_test.cpp here is a set of cases, all linked into one +# program per product. No hardware needed. +# +# make test and red +# make test build and run, for U64=1, the U2+L (U64 not defined) and U64=2 +# make red build the same cases against a model of the code as it was before each fix +# (legacy/*.sed, applied to the extracted code); each has to fail +# +CXX ?= g++ +SW := ../../.. +WIFI_DIR := .. +UART := ../../uart +HOST_TEST := ../../usb/tests + +WIFI_CC := $(WIFI_DIR)/wifi.cc +NET_CC := ../../network/network_esp32.cc +NET_H := ../../network/network_esp32.h +EXTRACT := extract.awk + +# 0 is the Ultimate II+L: it is built as the U2+L is, with U64 not defined at all +U64 ?= 1 +VARIANTS := 1 0 2 +# set by `make red` to the legacy model to apply +LEG ?= +OUT := $(if $(LEG),output/red_$(basename $(notdir $(LEG)))_u64_$(U64),output/u64_$(U64)) + +# Function names are given as written in the source (~ for a blank), so that the C++ method +# of a class is found. Those of wifi_switch.h's users exist for the products other than the U64=2 only. +WIFI_FUNCS := WiFi~::~WiFi WiFi~::~Init WiFi~::~Enable WiFi~::~Disable WiFi~::~RadioOn \ + WiFi~::~RadioOff WiFi~::~RunModeThread +WIFI_FUNCS_SWITCH := WiFi~::~TalksToModule +NET_FUNCS := NetworkLWIP_WiFi~::~disable NetworkLWIP_WiFi~::~enable +NET_FUNCS_SWITCH := NetworkLWIP_WiFi~::~wifi_enable_change NetworkLWIP_WiFi~::~set_enabled \ + NetworkLWIP_WiFi~::~cfg_enable NetworkLWIP_WiFi~::~cfg_disable + +CASES := $(wildcard *_test.cpp) +LEGACY := $(sort $(wildcard legacy/*.sed)) + +CXXFLAGS := -std=c++14 -g -O0 -Wall -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-switch \ + -Wno-format -Wno-unknown-warning-option -Wno-mismatched-tags -Wno-deprecated-declarations \ + -fno-access-control -DRISCV=1 $(if $(filter 0,$(U64)),,-DU64=$(U64)) \ + -I$(OUT) -Istubs -I. -I$(WIFI_DIR) -I$(UART) -I$(SW)/wifi/raw_u64/main + +# Prints the function $(1) of file $(2), and stops when it is not there +extract = out=$$(awk -v f="$(subst ~, ,$(1))" -f $(EXTRACT) $(2)); \ + [ -n "$$out" ] || { echo "wifi_task_test: $(subst ~, ,$(1)) not found in $(2)" >&2; exit 1; }; printf '%s\n' "$$out" + +.PHONY: all test red run redrun clean + +all: test red + +test: + @for v in $(VARIANTS); do $(MAKE) --no-print-directory U64=$$v run || exit 1; done + +red: + @for l in $(LEGACY); do \ + for v in $$(sed -n 's/^# variants: //p' $$l); do \ + $(MAKE) --no-print-directory U64=$$v LEG=$$l redrun || exit 1; \ + done; \ + done + +# The default of "WiFi Enabled", from its row of the configuration (network_esp32.cc) +$(OUT)/wifi_enable_default.h: $(NET_CC) $(NET_H) + @mkdir -p $(OUT) + @tr -d '\r' < $< | sed -n 's/.*CFG_WIFI_ENABLE, *CFG_TYPE_ENUM.*, *\([0-9][0-9]*\) *},.*/#define WIFI_ENABLE_DEFAULT \1/p' > $@ + @tr -d '\r' < $(NET_H) | sed -n 's/^#define \(CFG_WIFI_ENABLE\) *\(0x[0-9A-Fa-f]*\).*/#define \1 \2/p' >> $@ + @grep -q CFG_WIFI_ENABLE $@ || { echo "wifi_task_test: CFG_WIFI_ENABLE not found in $(NET_H)" >&2; exit 1; } + @grep -q WIFI_ENABLE_DEFAULT $@ || { echo "wifi_task_test: the CFG_WIFI_ENABLE row not found in $<" >&2; exit 1; } + +# The code under test, in the order of its files; for a legacy model, with its sed applied +$(OUT)/task.cc: $(WIFI_CC) $(NET_CC) $(EXTRACT) $(LEG) wifi_task_env.h $(OUT)/wifi_enable_default.h + @mkdir -p $(OUT) + @{ echo '#include "wifi_task_env.h"'; \ + $(foreach f,$(WIFI_FUNCS),$(call extract,$(f),$(WIFI_CC));) \ + echo '#if U64 != 2'; \ + $(foreach f,$(WIFI_FUNCS_SWITCH),$(call extract,$(f),$(WIFI_CC));) \ + echo '#endif'; \ + $(foreach f,$(NET_FUNCS),$(call extract,$(f),$(NET_CC));) \ + echo '#if U64 != 2'; \ + $(foreach f,$(NET_FUNCS_SWITCH),$(call extract,$(f),$(NET_CC));) \ + echo '#endif'; } | tr -d '\r' > $(OUT)/task.orig + @if [ -n "$(LEG)" ]; then \ + sed -f $(LEG) $(OUT)/task.orig > $@; \ + if cmp -s $@ $(OUT)/task.orig; then echo "wifi_task_test: $(LEG) changes nothing" >&2; exit 1; fi; \ + else cp $(OUT)/task.orig $@; fi + +$(OUT)/wifi_task_test: $(OUT)/task.cc $(OUT)/wifi_enable_default.h wifi_task_stubs.cpp $(CASES) \ + wifi_task_test.h wifi_task_env.h $(HOST_TEST)/host_test_main.cpp + $(CXX) $(CXXFLAGS) -o $@ $(OUT)/task.cc wifi_task_stubs.cpp $(CASES) $(HOST_TEST)/host_test_main.cpp -lpthread + +run: $(OUT)/wifi_task_test + @echo "wifi_task_test ($(if $(filter 0,$(U64)),U2+L,U64=$(U64))):"; $(OUT)/wifi_task_test + +# The same cases against the code as it was before a fix: the build has to work and the +# run has to fail, which says which checks +redrun: $(OUT)/wifi_task_test + @if $(OUT)/wifi_task_test > $(OUT)/red.log 2>&1; then \ + echo "red $(LEG) ($(if $(filter 0,$(U64)),U2+L,U64=$(U64))): the cases passed against the code before the fix -- they no longer catch it" >&2; exit 1; \ + else \ + echo "red $(LEG) ($(if $(filter 0,$(U64)),U2+L,U64=$(U64))): $$(tail -n 1 $(OUT)/red.log) against the code before the fix, as required"; \ + grep '^FAIL' $(OUT)/red.log | head -n 6 | sed 's/^/ /'; \ + fi + +clean: + @rm -rf output diff --git a/software/io/wifi/tests/extract.awk b/software/io/wifi/tests/extract.awk new file mode 100644 index 000000000..ebdd4b01d --- /dev/null +++ b/software/io/wifi/tests/extract.awk @@ -0,0 +1,14 @@ +# extract.awk -v f=: prints the definition of the function (for C++ also +# "Class :: method"), from its signature line to its closing brace, by brace count, from a +# C or C++ file, as it is. The signature line starts in column 0 with a letter and holds +# "(" but is not a declaration (does not end with ';'). +!p && /^[A-Za-z_]/ && index($0, f "(") && $0 !~ /;[[:space:]]*$/ { p = 1; depth = 0; seen = 0 } +p { + print + line = $0 + opens = gsub(/\{/, "", line) + closes = gsub(/\}/, "", line) + depth += opens - closes + if (opens) seen = 1 + if (seen && depth == 0) p = 0 +} diff --git a/software/io/wifi/tests/legacy/fix1_radio_switch.sed b/software/io/wifi/tests/legacy/fix1_radio_switch.sed new file mode 100644 index 000000000..6f49192b9 --- /dev/null +++ b/software/io/wifi/tests/legacy/fix1_radio_switch.sed @@ -0,0 +1,12 @@ +# The WiFi application before "Turn the radio off with Disable on the U64 and U2+L, and make +# WiFi Enabled work": no radio switch. The module is started by the setting only, never told +# to turn its radio off or on at boot, and the menu's Disable and Enable stop and start the +# application. Applied by the Makefile to the extracted code (make red). +# variants: 1 0 +s/^ wifi\.Enable();$/#if U64 == 2\ + wifi.Enable();\ +#endif/ +s/if (wifi_switch_wants_off(&radio_switch, netstack->enabled_in_config())) {/if (0) {/ +s/^ wifi_enable();$// +s/^ wifi\.RadioOff();$/ wifi.Disable();/ +s/^ wifi\.RadioOn();$/ wifi.Enable();/ diff --git a/software/io/wifi/tests/stubs/FreeRTOS.h b/software/io/wifi/tests/stubs/FreeRTOS.h new file mode 100644 index 000000000..8b961f116 --- /dev/null +++ b/software/io/wifi/tests/stubs/FreeRTOS.h @@ -0,0 +1,22 @@ +// Stand-in for the Ultimate's FreeRTOS on the build host: the types and the few calls the +// WiFi application makes (see wifi_task_env.h) +#ifndef WIFI_TESTS_FREERTOS_H +#define WIFI_TESTS_FREERTOS_H +#include +#include +typedef int BaseType_t; +typedef uint32_t TickType_t; +typedef void *TaskHandle_t; +typedef void *QueueHandle_t; +typedef void *SemaphoreHandle_t; +#define pdTRUE 1 +#define pdFALSE 0 +#define portMAX_DELAY ((TickType_t)0xFFFFFFFFu) +#define configTICK_RATE_HZ 200 +#define pdMS_TO_TICKS(ms) ((TickType_t)(((TickType_t)(ms) * configTICK_RATE_HZ) / 1000)) +#define ENTER_SAFE_SECTION +#define LEAVE_SAFE_SECTION +TickType_t xTaskGetTickCount(void); +void vTaskDelay(TickType_t t); +void vTaskSuspend(TaskHandle_t t); +#endif diff --git a/software/io/wifi/tests/stubs/browsable.h b/software/io/wifi/tests/stubs/browsable.h new file mode 100644 index 000000000..d1ddf4014 --- /dev/null +++ b/software/io/wifi/tests/stubs/browsable.h @@ -0,0 +1,39 @@ +// Stand-in for browsable.h and what it brings: the pieces wifi.h's BrowsableWifiAP and the +// AP list declare against. IndexedList keeps what is appended, so that a test can read it. +#ifndef WIFI_TESTS_BROWSABLE_H +#define WIFI_TESTS_BROWSABLE_H +#include +#include +#include +#include +template class IndexedList { + std::vector items; +public: + IndexedList(int initial, T def) {} + void append(T t) { items.push_back(t); } + int get_elements(void) const { return (int)items.size(); } + T operator[](int i) const { return items[i]; } +}; +class UserInterface { +public: + static void postMessage(const char *msg); + int string_box(const char *msg, char *buffer, int maxlen); +}; +class Action; +class SubsysCommand { public: intptr_t functionID; UserInterface *user_interface; }; +typedef enum { SSRET_OK = 0, SSRET_NO_USER_INTERFACE } SubsysResultCode_e; +class Browsable { +public: + IndexedList children; + Browsable() : children(0, NULL) {} + virtual ~Browsable() {} + virtual void getDisplayString(char *buffer, int width, UserInterface *ui) {} + virtual void fetch_context_items(IndexedList &items) {} + virtual IndexedList *getSubItems(int &error) { return &children; } +}; +class BrowsableStatic : public Browsable { +public: + const char *text; + BrowsableStatic(const char *t) : text(t) {} +}; +#endif diff --git a/software/io/wifi/tests/stubs/dma_uart.h b/software/io/wifi/tests/stubs/dma_uart.h new file mode 100644 index 000000000..15cc2270d --- /dev/null +++ b/software/io/wifi/tests/stubs/dma_uart.h @@ -0,0 +1,20 @@ +// Stand-in for the UART driver: what wifi.h, esp32.h and the WiFi application call. The +// bodies are in wifi_task_stubs.cpp, where they record what happens. +#ifndef WIFI_TESTS_DMA_UART_H +#define WIFI_TESTS_DMA_UART_H +#include "FreeRTOS.h" +extern "C" { + #include "cmd_buffer.h" +} +class DmaUART +{ +public: + bool txDebug; + void ModuleCtrl(int mode); + BaseType_t GetBuffer(command_buf_t **b, TickType_t t); + void FreeBuffer(command_buf_t *buf); + void TransmitPacket(command_buf_t *b) {} + void PrintStatus() {} + void ResetReceiveCallback() {} +}; +#endif diff --git a/software/io/wifi/tests/stubs/dump_hex.h b/software/io/wifi/tests/stubs/dump_hex.h new file mode 100644 index 000000000..f18a8f53a --- /dev/null +++ b/software/io/wifi/tests/stubs/dump_hex.h @@ -0,0 +1 @@ +static inline void dump_hex(const void *p, int n) {} diff --git a/software/io/wifi/tests/stubs/lwip/netdb.h b/software/io/wifi/tests/stubs/lwip/netdb.h new file mode 100644 index 000000000..9a6118bd8 --- /dev/null +++ b/software/io/wifi/tests/stubs/lwip/netdb.h @@ -0,0 +1 @@ +#include diff --git a/software/io/wifi/tests/stubs/lwip/sockets.h b/software/io/wifi/tests/stubs/lwip/sockets.h new file mode 100644 index 000000000..18c4602da --- /dev/null +++ b/software/io/wifi/tests/stubs/lwip/sockets.h @@ -0,0 +1,3 @@ +// rpc_calls.h needs only u16_t from lwIP +#include +typedef uint16_t u16_t; diff --git a/software/io/wifi/tests/stubs/menu.h b/software/io/wifi/tests/stubs/menu.h new file mode 100644 index 000000000..8607a63c2 --- /dev/null +++ b/software/io/wifi/tests/stubs/menu.h @@ -0,0 +1 @@ +// esp32.h includes it and uses nothing from it diff --git a/software/io/wifi/tests/stubs/queue.h b/software/io/wifi/tests/stubs/queue.h new file mode 100644 index 000000000..4a5049cad --- /dev/null +++ b/software/io/wifi/tests/stubs/queue.h @@ -0,0 +1 @@ +#include "FreeRTOS.h" diff --git a/software/io/wifi/tests/stubs/semphr.h b/software/io/wifi/tests/stubs/semphr.h new file mode 100644 index 000000000..4a5049cad --- /dev/null +++ b/software/io/wifi/tests/stubs/semphr.h @@ -0,0 +1 @@ +#include "FreeRTOS.h" diff --git a/software/io/wifi/tests/stubs/size_str.h b/software/io/wifi/tests/stubs/size_str.h new file mode 100644 index 000000000..f31a6cfd2 --- /dev/null +++ b/software/io/wifi/tests/stubs/size_str.h @@ -0,0 +1 @@ +// wifi.h includes it and uses nothing from it diff --git a/software/io/wifi/tests/stubs/task.h b/software/io/wifi/tests/stubs/task.h new file mode 100644 index 000000000..4a5049cad --- /dev/null +++ b/software/io/wifi/tests/stubs/task.h @@ -0,0 +1 @@ +#include "FreeRTOS.h" diff --git a/software/io/wifi/tests/switch_task_test.cpp b/software/io/wifi/tests/switch_task_test.cpp new file mode 100644 index 000000000..fd465a076 --- /dev/null +++ b/software/io/wifi/tests/switch_task_test.cpp @@ -0,0 +1,395 @@ +/* + * switch_task_test.cpp + * + * The radio switch in the WiFi application of the U64 and the U2+L, through the real + * WiFi :: RunModeThread, RadioOn, RadioOff and the menu actions and "WiFi Enabled" hook of + * network_esp32.cc: the stored setting at boot (and its default), the confirmation of a + * radio off and its deadline, a module without the switch, and the menu's Disable and + * Enable and the "WiFi Enabled" hook. + */ + +#include "wifi_task_test.h" +#include "wifi_enable_default.h" + +// What wifi_disable() answers when nothing reached the module (wifi_cmd.h) +static const int kNothingSent = -1; +// What a module without the radio switch answers: ESP_ERR_NOT_SUPPORTED +static const int kNotSupported = 0x106; + +// The module is found at boot on every product, and the WiFi application is the one that +// starts it (WiFi :: Init), whatever "WiFi Enabled" says +TEST(WifiSwitchTask, init_always_starts_the_module) +{ + reset_world(); + rlog[0] = 0; + WiFi :: Init((void *)0, (void *)0); + CHECK(strcmp(rlog, "B") == 0, "the module is started, with no condition on the setting"); +} + +#if U64 != 2 +// "WiFi Enabled" is stored as Enabled until the user changes it: a boot with the default +// turns the radio on, and the link comes up when the module reports one +TEST(WifiSwitchTask, default_setting_is_enabled_and_boots_connected) +{ + reset_world(); + CHECK(WIFI_ENABLE_DEFAULT == 1, "the default of \"WiFi Enabled\" is Enabled"); + world.enabled = WIFI_ENABLE_DEFAULT != 0; + boot({ EVENT_CONNECTED, EVENT_GOTIP }); + CHECK(strchr(rlog, 'O') == NULL, "no radio off"); + CHECK(strchr(rlog, 'N') != NULL, "radio on asked for"); + CHECK(strchr(after('s'), 'U') != NULL, "the link comes up"); + CHECK(wifi.getState() == eWifi_Connected, "Connected"); + CHECK(!wifi.radio_switch.awaiting_off, "nothing awaited"); +} + +// Stored Disabled: the radio off is asked for before the interface starts, the module's +// boot association does not bring the link up, and Disabled follows the confirmation +TEST(WifiSwitchTask, stored_disabled_boot) +{ + reset_world(); + boot({ EVENT_CONNECTED, EVENT_GOTIP, EVENT_DISABLED }); + CHECK(strstr(rlog, "dmOs") != NULL, "detect, MAC, radio off, then the interface starts"); +#ifndef U64 + CHECK(strncmp(rlog, "DE", 2) == 0, "the U2+L finds the module by its boot message first"); +#endif + CHECK(strchr(rlog, 'U') == NULL, "the link never comes up"); + CHECK(strchr(rlog, 'N') == NULL, "the radio on is not asked for"); + CHECK(strchr(rlog, 'F') == NULL, "the module keeps running"); + CHECK(strchr(rlog, 'Q') == NULL || strchr(rlog, 'Q') > strchr(rlog, 'O'), + "no connection query before the radio off"); + CHECK(wifi.getState() == eWifi_Disabled, "Disabled once confirmed"); +} + +TEST(WifiSwitchTask, disabled_only_after_the_confirmation) +{ + reset_world(); + boot({ EVENT_DISABLED }); + CHECK(first_wait_state == eWifi_NotConnected, "not Disabled before EVENT_DISABLED"); + CHECK(wifi.getState() == eWifi_Disabled, "Disabled after it"); +} + +// The module never confirms (its stop failed, or the request was lost): after the deadline +// the application takes the link state from the module again +TEST(WifiSwitchTask, unconfirmed_radio_off) +{ + reset_world(); + world.link = 1; + boot({}); + CHECK(strstr(rlog, "dmOs") != NULL, "radio off asked for"); + CHECK(strchr(after('s'), 'Q') != NULL, "the link state is asked for again"); + CHECK(strchr(after('Q'), 'U') != NULL, "and the link follows the module"); + CHECK(wifi.getState() == eWifi_Connected, "Connected, as the module is"); + CHECK(now - 1000 >= pdMS_TO_TICKS(WIFI_SWITCH_CONFIRM_MS), "not before the deadline"); +} + +// A module without the switch, whose radio is on from its boot: it is held off, as a +// stored Disabled did before, and the link never comes up +TEST(WifiSwitchTask, module_without_the_switch) +{ + reset_world(); + world.disable_answer = kNotSupported; + boot({ EVENT_CONNECTED, EVENT_GOTIP }); + CHECK(strstr(rlog, "OsF") != NULL, "radio off refused, then the module is held off"); + CHECK(strchr(rlog, 'U') == NULL, "the link never comes up"); + CHECK(wifi.getState() == eWifi_Off, "Off"); + CHECK(strcmp(ended, "suspended") == 0, "the application waits for an Enable"); +} + +// Disable while the application is still starting, before it knows whether the module +// can switch: the module is not stopped nor held off, and the start turns its radio off, +// although Enabled is stored; an Enable then undoes it. While flashing, Disable stops the +// application as before. +TEST(WifiSwitchTask, radio_off_while_starting) +{ + reset_world(); + wifi.state = eWifi_NotDetected; + rlog[0] = 0; + wifi.RadioOff(); + CHECK(rlog[0] == 0, "nothing stopped or held off yet"); + world.keep_switch = true; + world.enabled = true; + boot({}); + CHECK(strchr(rlog, 'O') != NULL && strchr(rlog, 'N') == NULL, "the start asks for the radio off"); + CHECK(strpbrk(rlog, "AF") == NULL, "the module keeps running"); + wifi.state = eWifi_ModuleDetected; + wifi.RadioOff(); + wifi.RadioOn(); + world.keep_switch = true; + boot({}); + CHECK(strchr(rlog, 'N') != NULL && strchr(rlog, 'O') == NULL, "an Enable after it wins"); + wifi.state = eWifi_Download; + rlog[0] = 0; + wifi.RadioOff(); + CHECK(strcmp(rlog, "A") == 0, "while flashing, the application stops and the module is left alone"); +} + +// The boot's Disable never left (no transmit buffer): it is not taken for a module +// without the switch, and when the confirmation is overdue it is asked for again before +// the connection query, which the module would otherwise take as an old application's +TEST(WifiSwitchTask, boot_disable_not_sent) +{ + reset_world(); + world.link = 1; + world.disable_answer = kNothingSent; + boot({}); + CHECK(strchr(rlog, 'F') == NULL, "not held off"); + const char *q = strchr(rlog, 'Q'); + const char *again = strchr(after('O'), 'O'); + CHECK((q != NULL) && (again != NULL) && (q > again), "asked again before the query"); +} + +// The radio off asked for again after a restart could not be sent: the wait for its +// confirmation still ends at the deadline, which asks again, so that link events are not +// dropped for good +TEST(WifiSwitchTask, restart_disable_not_sent) +{ + reset_world(); + world.disable_answer = kNothingSent; + boot({ EVENT_DISABLED, EVENT_RESTARTED }); + CHECK(strchr(rlog, 'F') == NULL, "not held off"); + CHECK(strchr(rlog, 'Q') != NULL, "the deadline comes, and the link state is asked for"); +} + +// Only ESP_ERR_NOT_SUPPORTED means a module without the switch. A module with it that +// could not queue the request (ESP_ERR_NO_MEM) is not held off, at boot or from the menu. +TEST(WifiSwitchTask, other_errors_are_not_no_switch) +{ + reset_world(); + world.disable_answer = 0x101; + boot({}); + CHECK(strchr(rlog, 'F') == NULL, "boot: not held off"); + CHECK(strchr(after('O'), 'O') != NULL, "boot: asked again at the deadline"); + world.enabled = true; + boot({ EVENT_CONNECTED }); + rlog[0] = 0; + NetworkLWIP_WiFi :: disable(NULL); + CHECK(strcmp(rlog, "O") == 0, "menu: asked, neither stopped nor held off"); +} + +// A Connect on an AP entry while Disabled starts the module's radio, whose link events +// then arrive while the application is still Disabled: they take it out of Disabled, and +// no radio off is asked for (only EVENT_RESTARTED means the module restarted) +TEST(WifiSwitchTask, link_events_take_it_out_of_disabled) +{ + reset_world(); + boot({ EVENT_DISABLED, EVENT_DISCONNECTED, EVENT_CONNECTED }); + CHECK(strchr(after('O'), 'O') == NULL, "the radio off is not asked for again"); + CHECK(strchr(rlog, 'U') != NULL, "the link comes up"); + CHECK(wifi.getState() == eWifi_Connected, "Connected"); +} + +// The module restarted on its own (radio_boot.h): while Disabled the radio off is asked +// for again and the link events of a radio it turned on are dropped until it confirms; +// while enabled, nothing is asked +TEST(WifiSwitchTask, module_restarted) +{ + reset_world(); + boot({ EVENT_DISABLED, EVENT_RESTARTED, EVENT_DISCONNECTED, EVENT_CONNECTED, EVENT_DISABLED }); + const char *again = strchr(after('O'), 'O'); + CHECK(again != NULL, "the radio off is asked for again"); + CHECK(strchr(rlog, 'U') == NULL, "the link never comes up"); + CHECK(wifi.getState() == eWifi_Disabled, "Disabled"); + world.enabled = true; + boot({ EVENT_CONNECTED, EVENT_RESTARTED }); + CHECK(strchr(rlog, 'O') == NULL, "enabled: no radio off"); +} + +// Disabled means no RF: browsing the AP list does not scan +TEST(WifiSwitchTask, no_scan_while_disabled) +{ + reset_world(); + boot({ EVENT_DISABLED, EVENT_RESCAN }); + CHECK(strchr(rlog, 'C') == NULL, "no scan"); + CHECK(wifi.getState() == eWifi_Disabled, "still Disabled"); +} + +// Also before the module has confirmed the radio off: a rescan then (opening the AP list +// at boot) would reach the module behind the Disable +TEST(WifiSwitchTask, no_scan_while_the_radio_off_waits) +{ + reset_world(); + boot({ EVENT_RESCAN, EVENT_DISABLED }); + CHECK(strchr(rlog, 'C') == NULL, "no scan"); + CHECK(wifi.getState() == eWifi_Disabled, "Disabled once confirmed"); +} + +TEST(WifiSwitchTask, scan_while_enabled) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_RESCAN }); + CHECK(strchr(rlog, 'C') != NULL, "a scan, as before"); +} + +// Stored Enabled: the radio on is asked for before the connection query, which would start +// the radio of a module on its own +TEST(WifiSwitchTask, stored_enabled_asks_before_the_query) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_CONNECTED }); + CHECK(strchr(after('N'), 'Q') != NULL && strchr(rlog, 'Q') > strchr(rlog, 'N'), + "radio on, then the connection query"); +} + +// The menu's Disable and Enable, and the "WiFi Enabled" hook, ask the module; they do not +// stop the application +TEST(WifiSwitchTask, menu_and_setting) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_CONNECTED }); + rlog[0] = 0; + NetworkLWIP_WiFi :: disable(NULL); + CHECK(strcmp(rlog, "O") == 0, "menu Disable asks the module for radio off"); + wifi.state = eWifi_Disabled; + rlog[0] = 0; + NetworkLWIP_WiFi :: enable(NULL); + CHECK(strcmp(rlog, "N") == 0, "menu Enable asks the module for radio on"); + ConfigItem it; + wifi.state = eWifi_Connected; + rlog[0] = 0; + it.value = 0; + NetworkLWIP_WiFi :: wifi_enable_change(&it); + CHECK(strcmp(rlog, "O") == 0, "the setting to Disabled turns the radio off"); + wifi.state = eWifi_Disabled; + rlog[0] = 0; + it.value = 1; + NetworkLWIP_WiFi :: wifi_enable_change(&it); + CHECK(strcmp(rlog, "N") == 0, "the setting to Enabled turns it on"); + // A setting that is the state already asks nothing + wifi.state = eWifi_Connected; + rlog[0] = 0; + it.value = 1; + NetworkLWIP_WiFi :: wifi_enable_change(&it); + CHECK(rlog[0] == 0, "Enabled while on: nothing to do"); + wifi.state = eWifi_Disabled; + it.value = 0; + NetworkLWIP_WiFi :: wifi_enable_change(&it); + CHECK(rlog[0] == 0, "Disabled while off: nothing to do"); + wifi.state = eWifi_Off; // a module without the switch, held off + rlog[0] = 0; + it.value = 0; + NetworkLWIP_WiFi :: wifi_enable_change(&it); + CHECK(rlog[0] == 0, "Disabled with the application stopped: nothing to do"); + it.value = 1; + NetworkLWIP_WiFi :: wifi_enable_change(&it); + CHECK(strcmp(rlog, "B") == 0, "the setting to Enabled starts the application again"); + wifi.state = eWifi_ModuleDetected; + rlog[0] = 0; + it.value = 0; + NetworkLWIP_WiFi :: wifi_enable_change(&it); + CHECK(rlog[0] == 0, "while the module is being found, the setting is left to the boot"); + // The setting to Enabled while the boot's radio off waits for its confirmation (the + // row still reads as not connected): it is not lost + wifi.state = eWifi_NotConnected; + wifi.radio_switch.awaiting_off = true; + rlog[0] = 0; + it.value = 1; + NetworkLWIP_WiFi :: wifi_enable_change(&it); + CHECK(strcmp(rlog, "N") == 0, "the setting to Enabled during the wait turns the radio on"); + CHECK(!wifi.radio_switch.awaiting_off, "and ends the wait"); +} + +// A module without the switch, stored Disabled: it is held off; an Enable restarts the +// application (which then skips the stored Disabled) instead of asking the module, which +// cannot +TEST(WifiSwitchTask, enable_with_a_module_without_the_switch) +{ + reset_world(); + world.disable_answer = kNotSupported; + boot({}); + CHECK(wifi.getState() == eWifi_Off, "Off"); + rlog[0] = 0; + wifi.RadioOn(); + CHECK(strcmp(rlog, "B") == 0, "the application is started again, the module not asked"); + CHECK(wifi.radio_switch.override_off, "and that start skips the stored Disabled"); +} + +// While the application is still setting up its link (AppDetected) it talks to the module +TEST(WifiSwitchTask, radio_off_while_setting_up) +{ + reset_world(); + world.enabled = true; + boot({}); + wifi.state = eWifi_AppDetected; + rlog[0] = 0; + wifi.RadioOff(); + CHECK(strcmp(rlog, "O") == 0, "the module is asked, the application not stopped"); +} + +// One switch: "WiFi Enabled" is what the menu's Enable and Disable (context menu and config +// menu) set and save; its change hook does the radio. A write happens only when the value +// changes, and a reboot reads the saved value. +static void menu_enable(void) { NetworkLWIP_WiFi :: enable(NULL); } +static void menu_disable(void) { NetworkLWIP_WiFi :: disable(NULL); } +static void cfg_menu_enable(void) { NetworkLWIP_WiFi :: cfg_enable(NULL, NULL); } +static void cfg_menu_disable(void) { NetworkLWIP_WiFi :: cfg_disable(NULL, NULL); } + +TEST(WifiSwitchTask, menu_enable_sets_and_saves_the_setting) +{ + void (*enables[])(void) = { menu_enable, cfg_menu_enable }; + for (void (*act)(void) : enables) { + reset_world(); + world.enabled = false; // stored Disabled + boot({ EVENT_DISABLED }); + rlog[0] = 0; + act(); + CHECK(world.enabled, "the setting reads Enabled"); + CHECK(saves == 1 && saved_enabled, "and it is saved"); + CHECK(strcmp(rlog, "N") == 0, "the radio is asked to come on"); + } +} + +TEST(WifiSwitchTask, menu_disable_sets_and_saves_the_setting) +{ + void (*disables[])(void) = { menu_disable, cfg_menu_disable }; + for (void (*act)(void) : disables) { + reset_world(); + world.enabled = true; + boot({ EVENT_CONNECTED }); + rlog[0] = 0; + act(); + CHECK(!world.enabled, "the setting reads Disabled"); + CHECK(saves == 1 && !saved_enabled, "and it is saved"); + CHECK(strcmp(rlog, "O") == 0, "the radio is asked to go off"); + // a reboot reads what was saved: the radio is asked off at boot, not on + bool stored = saved_enabled; + reset_world(); + world.enabled = stored; + boot({ EVENT_DISABLED }); + CHECK(strchr(rlog, 'O') != NULL && strchr(rlog, 'N') == NULL, "after a reboot the radio is off, not asked on"); + } +} + +TEST(WifiSwitchTask, no_write_when_the_setting_does_not_change) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_DISABLED }); // Disabled at run time, the setting still Enabled + rlog[0] = 0; + menu_enable(); + CHECK(saves == 0, "nothing is written"); + CHECK(strcmp(rlog, "N") == 0, "but the radio is asked to come on"); + reset_world(); + world.enabled = false; + boot({ EVENT_DISABLED }); + menu_disable(); + CHECK(saves == 0, "nor for a Disable of a setting that is Disabled"); +} + +// With a module that cannot switch, menu Disable stops the application as before +TEST(WifiSwitchTask, menu_disable_old_module) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_CONNECTED }); + rlog[0] = 0; + world.disable_answer = kNotSupported; + NetworkLWIP_WiFi :: disable(NULL); + CHECK(strcmp(rlog, "OAF") == 0, "asked, refused, application stopped, module held off"); + rlog[0] = 0; + NetworkLWIP_WiFi :: enable(NULL); + CHECK(strcmp(rlog, "B") == 0, "Enable starts the application again"); +} +#endif diff --git a/software/io/wifi/tests/wifi_switch_test.cpp b/software/io/wifi/tests/wifi_switch_test.cpp new file mode 100644 index 000000000..57b1d2853 --- /dev/null +++ b/software/io/wifi/tests/wifi_switch_test.cpp @@ -0,0 +1,246 @@ +/* + * wifi_switch_test.cpp + * + * Unit test of the radio switch logic (io/wifi/wifi_switch.h): which module events the WiFi + * application drops while it waits for the radio to go off, when the wait ends, and when + * the start of the application applies a Disable or an Enable. The task around it is in + * switch_task_test.cpp. + */ + +#include "../../usb/tests/host_test/host_test.h" +#include +#include "wifi_switch.h" + +#if U64 != 2 + +// The WiFi application as far as these events go: what the link does on each event the +// application does not drop (wifi.cc, RunModeThread) +struct app { + wifi_switch_t sw; + bool link_up; + bool disabled; + int dropped; +}; + +static void app_start(struct app *a, bool enabled) +{ + a->link_up = false; + a->disabled = false; + a->dropped = 0; + if (wifi_switch_wants_off(&a->sw, enabled)) { + wifi_switch_asked_off(&a->sw, 1000, 100); + a->disabled = true; + } +} + +static void event(struct app *a, uint8_t code) +{ + if (wifi_switch_drop_event(&a->sw, code)) { + a->dropped++; + return; + } + switch (code) { + case EVENT_CONNECTED: + a->link_up = true; + a->disabled = false; + break; + case EVENT_DISCONNECTED: + a->link_up = false; + a->disabled = false; + break; + case EVENT_DISABLED: + a->link_up = false; + a->disabled = true; + break; + default: + break; + } +} + +static void fresh(struct app *a) +{ + memset(a, 0, sizeof(*a)); +} + +// The module made an association at boot and reports it before it has turned off +TEST(WifiSwitch, stored_off_drops_the_boot_association) +{ + struct app a; + fresh(&a); + app_start(&a, false); + EXPECT_TRUE(a.disabled); + event(&a, EVENT_CONNECTED); + event(&a, EVENT_GOTIP); + EXPECT_FALSE(a.link_up); + EXPECT_EQ(a.dropped, 2); + event(&a, EVENT_DISABLED); + EXPECT_TRUE(a.disabled && !a.link_up); + // Once confirmed, the events are the module's again: an Enable brings the link up + event(&a, EVENT_DISCONNECTED); + event(&a, EVENT_CONNECTED); + EXPECT_TRUE(a.link_up); + EXPECT_EQ(a.dropped, 2); +} + +TEST(WifiSwitch, stored_off_confirmed_first) +{ + struct app a; + fresh(&a); + app_start(&a, false); + event(&a, EVENT_DISABLED); + EXPECT_TRUE(a.disabled); + event(&a, EVENT_DISCONNECTED); + EXPECT_EQ(a.dropped, 0); +} + +TEST(WifiSwitch, stored_on_drops_nothing) +{ + struct app a; + fresh(&a); + app_start(&a, true); + EXPECT_FALSE(a.disabled); + event(&a, EVENT_CONNECTED); + event(&a, EVENT_GOTIP); + EXPECT_TRUE(a.link_up); + EXPECT_EQ(a.dropped, 0); +} + +TEST(WifiSwitch, packets_and_internal_events_pass) +{ + struct app a; + fresh(&a); + app_start(&a, false); + event(&a, EVENT_RECV_PACKET); + event(&a, EVENT_RESCAN); + event(&a, EVENT_KEEPALIVE); + EXPECT_EQ(a.dropped, 0); +} + +// An Enable before the module has confirmed the radio off ends the wait: the module turns +// off, then on, and the link comes up +TEST(WifiSwitch, enable_ends_the_wait_for_the_confirmation) +{ + struct app a; + fresh(&a); + app_start(&a, false); + wifi_switch_on(&a.sw, true); + EXPECT_FALSE(a.sw.awaiting_off); + EXPECT_FALSE(a.sw.override_off); + event(&a, EVENT_DISABLED); + event(&a, EVENT_DISCONNECTED); + event(&a, EVENT_CONNECTED); + EXPECT_TRUE(a.link_up); + EXPECT_EQ(a.dropped, 0); +} + +// The module never confirmed the radio off (its stop failed). An Enable ends the wait, so +// the link can come up again. +TEST(WifiSwitch, enable_ends_an_unconfirmed_wait) +{ + struct app a; + fresh(&a); + app_start(&a, false); + wifi_switch_on(&a.sw, true); + event(&a, EVENT_CONNECTED); + EXPECT_TRUE(a.link_up); + EXPECT_EQ(a.dropped, 0); +} + +// After the application was stopped (a module without the switch is held off as a whole), +// Enable starts it again, and that start skips the stored Disabled, once +TEST(WifiSwitch, enable_with_the_application_stopped) +{ + struct app a; + fresh(&a); + wifi_switch_on(&a.sw, false); + EXPECT_TRUE(a.sw.override_off); + app_start(&a, false); + EXPECT_FALSE(a.disabled); + event(&a, EVENT_CONNECTED); + EXPECT_TRUE(a.link_up); + app_start(&a, false); + EXPECT_TRUE(a.disabled); +} + +// An Enable on a running application asks the module; a later start still applies the +// stored Disabled +TEST(WifiSwitch, enable_on_a_running_application_asks_the_module) +{ + struct app a; + fresh(&a); + app_start(&a, false); + event(&a, EVENT_DISABLED); + wifi_switch_on(&a.sw, true); + EXPECT_FALSE(a.sw.override_off); + app_start(&a, false); + EXPECT_TRUE(a.disabled); +} + +// The wait for the confirmation has a deadline, and ends once, when it is passed +TEST(WifiSwitch, confirmation_deadline) +{ + wifi_switch_t sw; + memset(&sw, 0, sizeof(sw)); + EXPECT_EQ(wifi_switch_wait(&sw, 0), -1); // no wait before the radio off is asked for + wifi_switch_wants_off(&sw, false); + wifi_switch_asked_off(&sw, 0xFFFFFFF0u, 100); // across the wrap of the clock + EXPECT_EQ(wifi_switch_wait(&sw, 0xFFFFFFF0u), 100); + EXPECT_EQ(wifi_switch_wait(&sw, 0x00000010u), 68); + EXPECT_FALSE(wifi_switch_expired(&sw, 0x00000010u)); + EXPECT_EQ(wifi_switch_wait(&sw, 0x00000054u), 0); + EXPECT_TRUE(wifi_switch_expired(&sw, 0x00000054u)); + EXPECT_FALSE(sw.awaiting_off); + EXPECT_FALSE(wifi_switch_expired(&sw, 0x00000100u)); // only once + EXPECT_EQ(wifi_switch_wait(&sw, 0x00000100u), -1); +} + +// Overdue is a wait of 0, not "as long as it takes": the application must not sleep on +TEST(WifiSwitch, overdue_wait_is_zero) +{ + wifi_switch_t sw; + memset(&sw, 0, sizeof(sw)); + wifi_switch_asked_off(&sw, 100, 50); + EXPECT_EQ(wifi_switch_wait(&sw, 400), 0); + EXPECT_TRUE(wifi_switch_expired(&sw, 400)); +} + +// The application starts again (after a flash, or an Enable of a held-off module): a wait +// of the earlier run is over +TEST(WifiSwitch, a_start_ends_a_stale_wait) +{ + wifi_switch_t sw; + memset(&sw, 0, sizeof(sw)); + wifi_switch_asked_off(&sw, 100, 50); + EXPECT_FALSE(wifi_switch_wants_off(&sw, true)); + EXPECT_FALSE(sw.awaiting_off); + EXPECT_EQ(wifi_switch_wait(&sw, 120), -1); +} + +TEST(WifiSwitch, confirmed_in_time) +{ + wifi_switch_t sw; + memset(&sw, 0, sizeof(sw)); + wifi_switch_wants_off(&sw, false); + wifi_switch_asked_off(&sw, 0, 100); + wifi_switch_drop_event(&sw, EVENT_DISABLED); + EXPECT_EQ(wifi_switch_wait(&sw, 50), -1); + EXPECT_FALSE(wifi_switch_expired(&sw, 200)); +} + +// A Disable or Enable while the application starts, before it knows the module: the start +// applies it, whatever is stored +TEST(WifiSwitch, switched_while_starting) +{ + wifi_switch_t sw; + memset(&sw, 0, sizeof(sw)); + wifi_switch_later(&sw, false); + EXPECT_TRUE(wifi_switch_wants_off(&sw, true)); // a Disable then: off, though Enabled is stored + EXPECT_FALSE(wifi_switch_wants_off(&sw, true)); // once only + wifi_switch_later(&sw, true); + EXPECT_FALSE(wifi_switch_wants_off(&sw, false)); // an Enable then: on, though Disabled is stored + wifi_switch_later(&sw, false); + wifi_switch_later(&sw, true); + EXPECT_FALSE(wifi_switch_wants_off(&sw, true)); // the last one counts +} + +#endif diff --git a/software/io/wifi/tests/wifi_task_env.h b/software/io/wifi/tests/wifi_task_env.h new file mode 100644 index 000000000..3d7512fae --- /dev/null +++ b/software/io/wifi/tests/wifi_task_env.h @@ -0,0 +1,88 @@ +/* + * wifi_task_env.h + * + * The world the Ultimate's WiFi application sees on the build host. The code under test is + * cut out of wifi.cc, wifi_cmd.cc and network_esp32.cc as it is (by the Makefile, with + * extract.awk) and put behind this header. The real wifi.h, esp32.h, wifi_cmd.h and + * wifi_switch.h (and wifi_connect.h, where the tree has it) are used; the RTOS, the UART, + * the browsable tree and the network interface are the stand-ins of stubs/ and below, + * which record what is called (wifi_task_stubs.cpp). + * + * The test reads and sets WiFi's private members (the task's state, the radio switch): + * the Makefile builds with -fno-access-control, which is the one place that does it. + */ + +#ifndef WIFI_TASK_ENV_H_ +#define WIFI_TASK_ENV_H_ + +#include +#include +#include +#include +#include +#include + +typedef int err_t; + +#include "dma_uart.h" +#include "esp32.h" +#include "browsable.h" +#include "dump_hex.h" +#include "wifi.h" +#if __has_include("wifi_connect.h") +#include "wifi_connect.h" +#endif +#include "wifi_enable_default.h" // CFG_WIFI_ENABLE and the default of that setting, from network_esp32.cc / .h + +class ConfigItem; + +// The configuration store of the WiFi settings, as far as the menu uses it +class ConfigStore { +public: + void set_value(uint8_t id, int value); + int get_value(uint8_t id); + void write(void); +}; +class ConfigManager { +public: + static ConfigManager *getConfigManager(void); + ConfigStore *find_store(uint32_t page_id); +}; + +// The network interface, as far as the application uses it +class NetworkLWIP_WiFi { +public: + NetworkLWIP_WiFi(void *driver, err_t (*out)(void *, void *, int), void (*free)(void *, void *)) {} + void attach_config(void) {} + void effectuate_registered_settings(void) {} + void set_mac_address(uint8_t *mac) {} + void start(void); + void stop(void) {} + void link_up(void); + void link_down(void); + void input_copy(uint8_t *data, int len) {} + bool enabled_in_config(void); + static SubsysResultCode_e enable(SubsysCommand *cmd); + static void set_enabled(bool on); + static void cfg_enable(UserInterface *intf, ConfigItem *it); + static void cfg_disable(UserInterface *intf, ConfigItem *it); + static SubsysResultCode_e disable(SubsysCommand *cmd); + static int wifi_enable_change(class ConfigItem *it); +}; + +class ConfigItem { +public: + int value; + int getValue(void) { return value; } +}; + +class U64Config { +public: + static void pushPowerOnMode(void); + static void pushWakeOnWifi(void); + static void pushRecoveryUrl(void); +}; + +extern ultimate_ap_records_t wifi_aps; + +#endif /* WIFI_TASK_ENV_H_ */ diff --git a/software/io/wifi/tests/wifi_task_stubs.cpp b/software/io/wifi/tests/wifi_task_stubs.cpp new file mode 100644 index 000000000..8b6d2beae --- /dev/null +++ b/software/io/wifi/tests/wifi_task_stubs.cpp @@ -0,0 +1,208 @@ +/* + * wifi_task_stubs.cpp + * + * Recording stubs for everything the extracted WiFi application code calls, and the + * scripted event source. See wifi_task_test.h for what a case file uses. The tests are + * registered by the case files (software/io/usb/tests/host_test_main.cpp runs them). + */ + +#include +#include "wifi_task_test.h" + +World world; +WiFi wifi; +NetworkLWIP_WiFi net(NULL, NULL, NULL); +ultimate_ap_records_t wifi_aps; + +char rlog[256]; +char messages[256]; +const char *ended = ""; +TickType_t now; +int first_wait_state; +static jmp_buf done; +static int calls; +static int waits; + +static void note(char c) +{ + size_t n = strlen(rlog); + if (n + 1 < sizeof(rlog)) { + rlog[n] = c; + rlog[n + 1] = 0; + } +} + +// The task ends here: it waits for an event that does not come, or sleeps for good +static void stop(const char *why) +{ + ended = why; + longjmp(done, 1); +} + +// Every stub the task can loop through counts, so that a defect that loops ends the case +static void count(void) +{ + if (++calls > 200) { + stop("runaway"); + } +} + +int saves; +bool saved_enabled; + +// The WiFi settings store: a change of "WiFi Enabled" runs its hook, as ConfigItem :: setChanged does +static ConfigStore store; +static ConfigManager manager; +ConfigManager *ConfigManager :: getConfigManager(void) { return &manager; } +ConfigStore *ConfigManager :: find_store(uint32_t page_id) { return (page_id == 0x57494649) ? &store : NULL; } +void ConfigStore :: set_value(uint8_t id, int value) +{ + if (id == CFG_WIFI_ENABLE) { + world.enabled = (value != 0); +#if U64 != 2 + ConfigItem it; + it.value = value; + NetworkLWIP_WiFi :: wifi_enable_change(&it); +#endif + } +} +int ConfigStore :: get_value(uint8_t id) { return (id == CFG_WIFI_ENABLE) ? (world.enabled ? 1 : 0) : 0; } +void ConfigStore :: write(void) { saves++; saved_enabled = world.enabled; } + +void reset_world(void) +{ + saves = 0; + saved_enabled = false; + memset(&world, 0, sizeof(world)); +} + +void check_failed(const char *what, const char *file, int line) +{ + char msg[512]; + snprintf(msg, sizeof(msg), "%s:%d: %s (log \"%s\", messages \"%s\", ended: %s)", file, line, what, rlog, messages, ended); + host_test::record_failure(msg, false); +} + +// The queue of the task: the script, and what the task queues itself +static command_buf_t queue[16]; +static int queue_n, queue_i; + +TickType_t xTaskGetTickCount(void) { return now; } +void vTaskDelay(TickType_t t) { stop("delayed"); } +void vTaskSuspend(TaskHandle_t t) { stop("suspended"); } + +void DmaUART :: ModuleCtrl(int mode) { if (mode == ESP_MODE_OFF) note('F'); } +// The UART refills a buffer that is given back, so a read after it finds anything +void DmaUART :: FreeBuffer(command_buf_t *buf) { memset(buf->data, 0xA5, sizeof(buf->data)); buf->size = -1; } +BaseType_t DmaUART :: GetBuffer(command_buf_t **b, TickType_t t) { return pdFALSE; } + +void UserInterface :: postMessage(const char *msg) +{ + note('!'); + strncat(messages, msg, sizeof(messages) - strlen(messages) - 2); + strcat(messages, "\n"); +} + +BaseType_t cmd_buffer_received(command_buf_context_t *context, command_buf_t **b, TickType_t t) +{ + count(); + if (++waits == 1) { + first_wait_state = wifi.getState(); + } + if (queue_i < queue_n) { + *b = &queue[queue_i++]; + return pdTRUE; + } + if (t == portMAX_DELAY) { + stop("waiting for an event"); + } + now += t; // the time it waited, with nothing coming + return pdFALSE; +} + +void wifi_command_init(void) {} +Esp32 :: Esp32() : uart(NULL) {} +Esp32 esp32; +void Esp32 :: AttachApplication(Esp32Application *app) {} +void Esp32 :: StartApp() { note('B'); } +void Esp32 :: StopApp() { note('A'); wifi.state = eWifi_Off; } +#ifndef U64 +// The U2+L finds its module by its boot message +int Esp32 :: DetectModule(void *buffer, int len) { note('D'); strcpy((char *)buffer, "ESP-ROM:esp32c3-api1-20210207"); return 29; } +void Esp32 :: EnableRunMode(void) { note('E'); } +#endif + +BaseType_t wifi_detect(uint16_t *major, uint16_t *minor, char *str, int maxlen) { count(); note('d'); strcpy(str, "test"); return pdTRUE; } +int wifi_getmac(uint8_t *mac) { note('m'); return 0; } +int wifi_scan(void *) { count(); note('C'); return 0; } +int wifi_enable() { note('N'); return world.enable_answer; } +int wifi_disable() { note('O'); return world.disable_answer; } +int wifi_modem_enable(bool) { note('M'); return 0; } +int wifi_get_voltages(voltages_t *v) +{ + if (world.voltages_result == 0) { + v->vbus = world.voltages_vbus; + } + return world.voltages_result; +} +int wifi_is_connected(uint8_t &status) { count(); note('Q'); status = world.link; return 0; } + +err_t wifi_tx_packet(void *driver, void *buffer, int length) { return 0; } +void wifi_free(void *driver, void *buffer) {} + +void NetworkLWIP_WiFi :: start(void) { note('s'); } +void NetworkLWIP_WiFi :: link_up(void) { note('U'); } +void NetworkLWIP_WiFi :: link_down(void) { note('u'); } +bool NetworkLWIP_WiFi :: enabled_in_config(void) { return world.enabled; } + +void U64Config :: pushPowerOnMode(void) {} +void U64Config :: pushWakeOnWifi(void) {} +void U64Config :: pushRecoveryUrl(void) {} + +void WiFi :: RefreshRoot() {} +void WiFi :: RefreshAPs() {} +void WiFi :: Start() {} +void WiFi :: Terminate() {} + +static DmaUART uart; +static command_buf_context_t packets; + +void boot(std::initializer_list steps) +{ +#if U64 != 2 + if (!world.keep_switch) { + memset(&wifi.radio_switch, 0, sizeof(wifi.radio_switch)); + } +#endif + world.keep_switch = false; + rlog[0] = 0; + messages[0] = 0; + ended = ""; + calls = 0; + waits = 0; + now = 1000; + queue_n = queue_i = 0; + for (std::initializer_list::const_iterator s = steps.begin(); s != steps.end(); ++s) { + command_buf_t *b = &queue[queue_n++]; + memset(b, 0, sizeof(*b)); + ((rpc_header_t *)b->data)->command = s->code; + b->size = sizeof(rpc_header_t); + if (s->code == EVENT_CONNECTED && s->ssid) { + strncpy((char *)((event_pkt_connected *)b->data)->ssid, s->ssid, 32); + b->size = sizeof(event_pkt_connected); + } + } + wifi.netstack = &net; + wifi.uart = &uart; + wifi.packets = &packets; + esp32.uart = &uart; + if (setjmp(done) == 0) { + wifi.RunModeThread(); + } +} + +const char *after(char c) +{ + const char *p = strchr(rlog, c); + return p ? p + 1 : ""; +} diff --git a/software/io/wifi/tests/wifi_task_test.h b/software/io/wifi/tests/wifi_task_test.h new file mode 100644 index 000000000..3267c94c3 --- /dev/null +++ b/software/io/wifi/tests/wifi_task_test.h @@ -0,0 +1,64 @@ +/* + * wifi_task_test.h + * + * The scripted world of the WiFi application host test (wifi_task_stubs.cpp) as a case file + * sees it. A case boots the WiFi task (WiFi :: RunModeThread, cut out of wifi.cc as it is) + * with the module found, feeds it the events of a script in order, and looks at the log of + * what the task did and at its state. The task runs until it waits for an event that does + * not come. Built for U64=1, the U2+L (U64 not defined) and U64=2; a case that is for + * some of them says so with #if. + * + * Log letters: d detect, m get MAC, O radio off asked (CMD_WIFI_DISABLE), N radio on asked + * (CMD_WIFI_ENABLE), Q connection state asked, s netstack start, U link up, u link down, + * C scan, A application stopped, B application started, M modem taken over, F module held + * off, D/E U2+L module detection and run mode, ! a message to the user. + */ + +#ifndef WIFI_TASK_TEST_H_ +#define WIFI_TASK_TEST_H_ + +#include +#include "../../usb/tests/host_test/host_test.h" +#include "wifi_task_env.h" + +// What the case sets before it boots the task +struct World { + bool enabled; // "WiFi Enabled" as stored + int disable_answer; // the module's answer to a radio off (0: queued; 0x106: no switch) + int enable_answer; // and to a radio on + uint8_t link; // what the module says to the connection query + int voltages_result; // wifi_get_voltages()'s answer (U64=2) + uint16_t voltages_vbus; + bool keep_switch; // the next boot keeps the radio switch state (once) +}; +extern World world; +void reset_world(void); // every case starts with it + +extern int saves; // how often the WiFi settings were written +extern bool saved_enabled; // "WiFi Enabled" as written +extern char rlog[256]; // what the task did, one letter each +extern char messages[256]; // what the user was told, one message per line +extern const char *ended; // why the task stopped running +extern TickType_t now; // the task's clock, in ticks +extern int first_wait_state; // the task's state when it first waits for an event +extern WiFi wifi; +extern NetworkLWIP_WiFi net; + +// A step of the script: an event of the module +struct Step { + int code; + const char *ssid; + int reason; + Step(int c) : code(c), ssid(NULL), reason(-1) {} + Step(int c, const char *s) : code(c), ssid(s), reason(-1) {} +}; + +// Starts the WiFi task with the module found, and these steps in order +void boot(std::initializer_list steps); +const char *after(char c); // the log after the first occurrence of c + +// The case's check: a failure says what was expected and what the task did +void check_failed(const char *what, const char *file, int line); +#define CHECK(cond, what) do { if (!(cond)) check_failed(what, __FILE__, __LINE__); } while (0) + +#endif /* WIFI_TASK_TEST_H_ */ diff --git a/software/io/wifi/wifi.cc b/software/io/wifi/wifi.cc index 948b29574..4cc7334e1 100644 --- a/software/io/wifi/wifi.cc +++ b/software/io/wifi/wifi.cc @@ -36,6 +36,9 @@ WiFi :: WiFi() my_ip = 0; my_gateway = 0; my_netmask = 0; +#if U64 != 2 + memset(&radio_switch, 0, sizeof(radio_switch)); +#endif } void WiFi :: Init(void *obj, void *param) @@ -44,10 +47,11 @@ void WiFi :: Init(void *obj, void *param) wifi.netstack = new NetworkLWIP_WiFi(&wifi, wifi_tx_packet, wifi_free); wifi.netstack->attach_config(); -#if U64 == 2 - wifi.Enable(); // Unconditionally enable the WiFi module -#endif - wifi.netstack->effectuate_registered_settings(); // may start the WiFi application + // Unconditionally enable the WiFi module: it always runs, also with "WiFi Enabled" + // stored as Disabled, which means its radio is off. On the U64 and U2+L the + // application tells the module, which starts with its radio off, to turn it on or not. + wifi.Enable(); + wifi.netstack->effectuate_registered_settings(); } void WiFi :: RefreshRoot() @@ -71,14 +75,69 @@ void WiFi :: Disable() esp32.StopApp(); } +#if U64 != 2 +// The states in which the WiFi application is running and the module answers it +bool WiFi :: TalksToModule() +{ + switch (state) { + case eWifi_AppDetected: + case eWifi_Scanning: + case eWifi_NotConnected: + case eWifi_Connected: + case eWifi_Disabled: + return true; + default: + return false; + } +} +#endif + void WiFi :: RadioOn() { +#if U64 != 2 + if (state == eWifi_Off) { + wifi_switch_on(&radio_switch, false); + Enable(); + return; + } + if (!TalksToModule()) { + // still starting: the start applies it + wifi_switch_later(&radio_switch, true); + return; + } + // Ends a wait for a radio-off confirmation. A module without the switch is never + // talked to here: it is held off (state Off) at boot and by RadioOff. + wifi_switch_on(&radio_switch, true); +#endif wifi_enable(); } void WiFi :: RadioOff() { +#if U64 != 2 + if (TalksToModule()) { + if (!wifi_switch_unsupported(wifi_disable())) { + return; + } + // A module known to lack the radio switch: stop the WiFi application, as Disable + // always did here, and hold the module off, as at boot, so that its radio is off too + Disable(); + if (uart) { + uart->ModuleCtrl(ESP_MODE_OFF); + } + return; + } + if ((state == eWifi_NotDetected) || (state == eWifi_ModuleDetected)) { + // Still starting, and whether the module can switch is not known yet: the start + // applies the Disable (a module with the switch keeps running, its radio off) + wifi_switch_later(&radio_switch, false); + return; + } + // Off already, or being flashed: stop the WiFi application, as Disable always did + Disable(); +#else wifi_disable(); +#endif } BaseType_t wifi_rx_isr(command_buf_context_t *context, command_buf_t *buf, BaseType_t *w); @@ -194,6 +253,9 @@ void WiFi :: RunModeThread() static char boot_message[256]; int len; voltages_t voltages; +#if U64 != 2 + int32_t wait; +#endif while(1) { switch(state) { @@ -272,6 +334,37 @@ void WiFi :: RunModeThread() wifi_getmac(my_mac); netstack->set_mac_address(my_mac); +#if U64 != 2 + // Stored as Disabled: the radio goes off before the interface is up, and the + // link stays down. Disabled is shown once the module confirms (wifi_switch.h). + if (wifi_switch_wants_off(&radio_switch, netstack->enabled_in_config())) { + result = wifi_disable(); + netstack->start(); // link down + // Only a module without the switch is held off; any other error, or a + // request that never left, is asked again at the deadline + if (wifi_switch_unsupported(result)) { + // A module without the switch cannot keep its radio off: hold the + // module off. It had to run to tell (its radio is on from its own + // boot, so it may have associated for a moment), where a stored + // Disabled used to keep it from starting at all. An Enable starts the + // application again (wifi_switch_on), and that start skips the + // stored Disabled. + printf("WiFi module cannot turn its radio off: %d\n", result); + uart->ModuleCtrl(ESP_MODE_OFF); + state = eWifi_Off; + RefreshRoot(); + vTaskSuspend(NULL); // until that start ends this task + break; + } + wifi_switch_asked_off(&radio_switch, xTaskGetTickCount(), pdMS_TO_TICKS(WIFI_SWITCH_CONFIRM_MS)); + state = eWifi_NotConnected; + RefreshRoot(); + break; + } + // Stored as Enabled: the module starts with its radio off and turns it on now. + // A module without the switch, whose radio is on already, ignores this. + wifi_enable(); +#endif netstack->start(); // always starts in link down state state = eWifi_NotConnected; if (wifi_is_connected(conn) == 0) { @@ -296,19 +389,69 @@ void WiFi :: RunModeThread() case eWifi_NotConnected: case eWifi_Connected: case eWifi_Disabled: +#if U64 != 2 + wait = wifi_switch_wait(&radio_switch, xTaskGetTickCount()); + if (cmd_buffer_received(packets, &buf, (wait < 0) ? portMAX_DELAY : (TickType_t)wait) != pdTRUE) { + // The radio off was not confirmed in time: take the link state from the + // module again + if (wifi_switch_expired(&radio_switch, xTaskGetTickCount())) { + printf("WiFi module did not confirm the radio off\n"); + // Ask once more first: a Disable that never left (no transmit buffer) + // or that a module restart lost would otherwise let the connection + // query start the radio of a module that takes it as an application + // without the switch (wifi_modem.c, off_asked) + wifi_disable(); + state = eWifi_NotConnected; + if ((wifi_is_connected(conn) == 0) && conn) { + wifi_modem_enable(true); // take control! + netstack->link_up(); + state = eWifi_Connected; + } + RefreshRoot(); + } + break; + } +#else cmd_buffer_received(packets, &buf, portMAX_DELAY); +#endif hdr = (rpc_header_t *)(buf->data); #if DEBUG_INPUT printf("Pkt %d. Ev %b. Sz %d. Seq: %d\n", buf->bufnr, hdr->command, buf->size, hdr->sequence); +#endif +#if U64 != 2 + if (wifi_switch_drop_event(&radio_switch, hdr->command)) { + uart->FreeBuffer(buf); + break; + } #endif switch(hdr->command) { case EVENT_RESCAN: // requested from user interface uart->FreeBuffer(buf); +#if U64 != 2 + // Disabled means no RF, also while the radio off waits to be confirmed: + // the module does not scan with its radio off + if ((state == eWifi_Disabled) || radio_switch.awaiting_off) { + break; + } +#endif netstack->link_down(); state = eWifi_Scanning; RefreshRoot(); break; +#if U64 != 2 + // The module restarted on its own (radio_boot.h). It put its radio back as it + // was, or, with no record of that, turned it on: while Disabled, the radio off + // is asked for again, and confirmed as at boot. + case EVENT_RESTARTED: + uart->FreeBuffer(buf); + if (state == eWifi_Disabled) { + wifi_disable(); + wifi_switch_asked_off(&radio_switch, xTaskGetTickCount(), pdMS_TO_TICKS(WIFI_SWITCH_CONFIRM_MS)); + } + break; + +#endif case EVENT_DISABLED: uart->FreeBuffer(buf); state = eWifi_Disabled; @@ -414,7 +557,8 @@ int WiFi ::getAccessPointItems(Browsable *parent, IndexedList &list { ultimate_ap_records_t *aps = &wifi_aps; if (aps->num_records == 0) { - list.append(new BrowsableStatic("Scanning...")); + // While Disabled nothing scans, so the list is empty until WiFi is enabled + list.append(new BrowsableStatic((state == eWifi_Disabled) ? "WiFi is disabled" : "Scanning...")); return 0; } ENTER_SAFE_SECTION; diff --git a/software/io/wifi/wifi.h b/software/io/wifi/wifi.h index 517cf0fe7..508217606 100644 --- a/software/io/wifi/wifi.h +++ b/software/io/wifi/wifi.h @@ -17,6 +17,9 @@ #include "size_str.h" //#include "network_esp32.h" #include "wifi_cmd.h" +#if U64 != 2 +#include "wifi_switch.h" +#endif // This class provides an interface to the WiFi module, to manage and program it typedef enum { @@ -48,6 +51,10 @@ class WiFi : public Esp32Application uint32_t my_ip; uint32_t my_gateway; uint32_t my_netmask; +#if U64 != 2 + wifi_switch_t radio_switch; + bool TalksToModule(void); +#endif bool RequestEcho(void); void RxPacket(command_buf_t *); @@ -63,6 +70,12 @@ class WiFi : public Esp32Application BaseType_t doRequestEcho(void); WifiState_t getState(void) { return state; } + // A radio off is asked for and not confirmed yet (wifi_switch.h) +#if U64 != 2 + bool RadioOffAwaited(void) { return radio_switch.awaiting_off; } +#else + bool RadioOffAwaited(void) { return false; } +#endif const char *getLastAP(void) { return (state == eWifi_Connected) ? last_ap : "-"; } const char *getModuleName(void) { return moduleName; } const char *getModuleType(void) { return moduleType; } diff --git a/software/io/wifi/wifi_cmd.cc b/software/io/wifi/wifi_cmd.cc index 8753bfd31..594a3fcbd 100644 --- a/software/io/wifi/wifi_cmd.cc +++ b/software/io/wifi/wifi_cmd.cc @@ -351,7 +351,6 @@ int wifi_forget_aps() } -#if U64 == 2 int wifi_enable() { BUFARGS(identify, CMD_WIFI_ENABLE); @@ -366,6 +365,7 @@ int wifi_disable() RETURN_ESP; } +#if U64 == 2 int wifi_get_voltages(voltages_t *voltages) { BUFARGS(identify, CMD_GET_VOLTAGES); diff --git a/software/io/wifi/wifi_cmd.h b/software/io/wifi/wifi_cmd.h index c128457f4..660fa7e59 100644 --- a/software/io/wifi/wifi_cmd.h +++ b/software/io/wifi/wifi_cmd.h @@ -43,6 +43,8 @@ int wifi_machine_off(); int wifi_machine_reboot(); void wifi_rx_packet(); +// The radio switch: 0 when the module queued the request, its error otherwise, or -1 +// when nothing reached the module (no buffer or slot, or no reply) int wifi_enable(); int wifi_disable(); int wifi_modem_enable(bool); diff --git a/software/io/wifi/wifi_switch.h b/software/io/wifi/wifi_switch.h new file mode 100644 index 000000000..ba41d8d3f --- /dev/null +++ b/software/io/wifi/wifi_switch.h @@ -0,0 +1,138 @@ +/* + * wifi_switch.h + * + * The Ultimate 64's and Ultimate II+L's side of turning the WiFi module's radio off and on + * (U64 != 2). The Elite II and C64 Ultimate send the same requests from their own code + * paths. + * + * The WiFi application always runs, because it is what asks the module. The module starts + * with its radio off. With "WiFi Enabled" stored as Enabled the application asks for it to + * go on; stored as Disabled, it asks for it to go off as soon as it finds the module, + * before the interface is up. Until the module confirms that with EVENT_DISABLED, a link + * event from it (a module that associated at boot after all) would put the WiFi + * interface on the network while WiFi is off, so those events are dropped. + * + * The answer to the request only says that the module queued it. The application shows + * Disabled when EVENT_DISABLED arrives, not before. If it does not arrive within + * WIFI_SWITCH_CONFIRM_MS (the module could not stop its radio, or the request was lost), + * the wait ends and the application takes the link state from the module again. + * + * A module without the radio switch answers the request with an error; its radio is on + * from its boot. The application then stops and holds the module off, at its start and on + * a Disable from the menu, the REST API or the setting. At a boot with Disabled stored the + * module has had to run to tell, so unlike before it may have associated for a moment. An + * Enable then starts the WiFi application again, which is what an Enable did before, and + * that start does not apply the stored Disabled. + * + * Pure logic, so that the host test (target/pc/linux/wifiswitch) runs it. + */ + +#ifndef WIFI_SWITCH_H_ +#define WIFI_SWITCH_H_ + +#include +#include +#include "rpc_calls.h" + +#define WIFI_SWITCH_CONFIRM_MS 10000 + +// The answer of a module without the radio switch to a radio off or on: +// ESP_ERR_NOT_SUPPORTED, as every module before the switch gives for a command it does not +// have. Any other error (the module could not queue it, or it never left) is not taken +// for that: the confirmation deadline asks again. +#define WIFI_SWITCH_NOT_SUPPORTED 0x106 + +static inline bool wifi_switch_unsupported(int result) +{ + return result == WIFI_SWITCH_NOT_SUPPORTED; +} + +typedef struct { + bool awaiting_off; // the radio off was asked for, and EVENT_DISABLED is not seen yet + bool override_off; // the next start of the application ignores a stored Disabled + bool off_pending; // a Disable came while the application was starting: its start applies it + uint32_t deadline; // when the wait for EVENT_DISABLED ends, in the caller's time unit +} wifi_switch_t; + +// At the start of the WiFi application, when it has found the module: whether the radio +// is to be turned off now. enabled is the stored "WiFi Enabled". +static inline bool wifi_switch_wants_off(wifi_switch_t *sw, bool enabled) +{ + bool off = (!enabled || sw->off_pending) && !sw->override_off; + sw->override_off = false; + sw->off_pending = false; + sw->awaiting_off = false; + return off; +} + +// The radio off was asked for and the module queued it (or the answer was an error other +// than WIFI_SWITCH_NOT_SUPPORTED, taken as asked: the deadline asks again). +// now and limit are in one time unit (RTOS ticks in the application): the wait for the +// module's confirmation ends at now + limit. +static inline void wifi_switch_asked_off(wifi_switch_t *sw, uint32_t now, uint32_t limit) +{ + sw->awaiting_off = true; + sw->deadline = now + limit; +} + +// How long the application may wait for the next event: -1 for as long as it takes, else +// the time left until the confirmation is overdue (0 when it is) +static inline int32_t wifi_switch_wait(const wifi_switch_t *sw, uint32_t now) +{ + if (!sw->awaiting_off) { + return -1; + } + int32_t left = (int32_t)(sw->deadline - now); + return (left > 0) ? left : 0; +} + +// True once, when the confirmation is overdue: the wait ends, and the application asks the +// module for its link state again +static inline bool wifi_switch_expired(wifi_switch_t *sw, uint32_t now) +{ + if (!sw->awaiting_off || (wifi_switch_wait(sw, now) > 0)) { + return false; + } + sw->awaiting_off = false; + return true; +} + +// Whether the WiFi application must drop this event from the module +static inline bool wifi_switch_drop_event(wifi_switch_t *sw, uint8_t command) +{ + if (!sw->awaiting_off) { + return false; + } + switch (command) { + case EVENT_DISABLED: + // Only the module that turned its radio off ends the wait + sw->awaiting_off = false; + return false; + case EVENT_CONNECTED: + case EVENT_DISCONNECTED: + case EVENT_GOTIP: + return true; + default: + return false; + } +} + +// On an Enable. app_running is false when the WiFi application is not running (it is held +// off with the module): it is started again, and that start ignores a stored Disabled. +static inline void wifi_switch_on(wifi_switch_t *sw, bool app_running) +{ + sw->awaiting_off = false; + if (!app_running) { + sw->override_off = true; + } +} + +// A Disable (on false) or Enable (on true) while the application is still starting, before +// it knows whether the module can switch its radio: the start applies it +static inline void wifi_switch_later(wifi_switch_t *sw, bool on) +{ + sw->off_pending = !on; + sw->override_off = on; +} + +#endif /* WIFI_SWITCH_H_ */ diff --git a/software/wifi/common/radio_boot.c b/software/wifi/common/radio_boot.c new file mode 100644 index 000000000..7204a0120 --- /dev/null +++ b/software/wifi/common/radio_boot.c @@ -0,0 +1,37 @@ +/* + * radio_boot.c + * + * See radio_boot.h. Free of ESP-IDF, so that the host test tests what ships. + */ + +#include "radio_boot.h" + +void radio_record_set(radio_record_t *rec, bool on) +{ + uint32_t state = on ? RADIO_RECORD_ON : RADIO_RECORD_OFF; + // The magic goes last, so that a record cut short by a reset does not check out; + // volatile keeps the stores in that order + volatile radio_record_t *v = rec; + v->magic = 0; + v->state = state; + v->check = ~(RADIO_RECORD_MAGIC ^ state); + v->magic = RADIO_RECORD_MAGIC; +} + +static bool record_valid(const radio_record_t *rec) +{ + return (rec->magic == RADIO_RECORD_MAGIC) && + ((rec->state == RADIO_RECORD_ON) || (rec->state == RADIO_RECORD_OFF)) && + (rec->check == ~(rec->magic ^ rec->state)); +} + +radio_boot_t radio_boot_decision(bool self_restart, const radio_record_t *rec) +{ + if (!self_restart) { + return RADIO_BOOT_WAIT; + } + if (!record_valid(rec)) { + return RADIO_BOOT_ON; // no record: the radio goes on, as it always did + } + return (rec->state == RADIO_RECORD_ON) ? RADIO_BOOT_ON : RADIO_BOOT_OFF; +} diff --git a/software/wifi/common/radio_boot.h b/software/wifi/common/radio_boot.h new file mode 100644 index 000000000..ffd3519d5 --- /dev/null +++ b/software/wifi/common/radio_boot.h @@ -0,0 +1,45 @@ +/* + * radio_boot.h + * + * Whether the radio of the U64 and U2+L WiFi modules (software/wifi/raw_u64, raw_c3) goes + * on at boot. After a power-up, or a reset by the Ultimate, the module starts with its + * radio off and waits for the Ultimate (wifi_modem.c, switch_seen). After a restart the + * Ultimate did not cause (a crash, a watchdog, a brownout), nobody would tell it again, so + * it goes back to the radio's last state, kept in RTC memory that such a reset leaves + * alone. A record that does not check out (lost, half written, never written) counts as + * none: the radio goes on, as these modules always did at boot, and the module tells the + * Ultimate it restarted (EVENT_RESTARTED), so that one with "WiFi Enabled" Disabled asks + * for the radio off again. Until it does, the radio is on. + * + * Pure logic, so that the host test (target/pc/linux/wifiradio) runs it. + */ + +#ifndef SOFTWARE_WIFI_COMMON_RADIO_BOOT_H_ +#define SOFTWARE_WIFI_COMMON_RADIO_BOOT_H_ + +#include +#include + +#define RADIO_RECORD_MAGIC 0x52414449u // "RADI" +#define RADIO_RECORD_ON 0x4F4E4F4Eu +#define RADIO_RECORD_OFF 0x4F464646u + +typedef struct { + uint32_t magic; + uint32_t state; // RADIO_RECORD_ON or RADIO_RECORD_OFF + uint32_t check; // ~(magic ^ state) +} radio_record_t; + +typedef enum { + RADIO_BOOT_WAIT, // radio off, until the Ultimate asks + RADIO_BOOT_ON, // a restart of its own: radio on, as before it + RADIO_BOOT_OFF, // a restart of its own: radio off, as before it +} radio_boot_t; + +// Called wherever the radio goes on or off for good +void radio_record_set(radio_record_t *rec, bool on); + +// self_restart: the reset was not a power-up nor one the Ultimate caused +radio_boot_t radio_boot_decision(bool self_restart, const radio_record_t *rec); + +#endif /* SOFTWARE_WIFI_COMMON_RADIO_BOOT_H_ */ diff --git a/software/wifi/common/wifi_radio.c b/software/wifi/common/wifi_radio.c new file mode 100644 index 000000000..29954c952 --- /dev/null +++ b/software/wifi/common/wifi_radio.c @@ -0,0 +1,40 @@ +/* + * wifi_radio.c + * + * See wifi_radio.h. Free of ESP-IDF, so that the host test tests what ships. + */ + +#include "wifi_radio.h" +#include "wifi_radio_port.h" + +// Written by the task that starts and stops the radio, read by any +static volatile bool radio_on = false; + +bool radio_is_on(void) +{ + return radio_on; +} + +int radio_start(void) +{ + if (radio_on) { + return 0; + } + int rc = wr_port_wifi_start(); + if (rc == 0) { + radio_on = true; + } + return rc; +} + +int radio_stop(void) +{ + if (!radio_on) { + return 0; + } + int rc = wr_port_wifi_stop(); + if (rc == 0) { + radio_on = false; + } + return rc; +} diff --git a/software/wifi/common/wifi_radio.h b/software/wifi/common/wifi_radio.h new file mode 100644 index 000000000..9f3c07747 --- /dev/null +++ b/software/wifi/common/wifi_radio.h @@ -0,0 +1,29 @@ +/* + * wifi_radio.h + * + * The one place that starts and stops the Wi-Fi radio of the WiFi modules of the + * Ultimate 64 (software/wifi/raw_u64) and the Ultimate II+L (software/wifi/raw_c3), so + * that "off" means the same on both: esp_wifi_stop(), the RF is off and the module leaves + * the AP. + * + * The logic is in wifi_radio.c, the chip side in wifi_radio_esp.c, and the host test + * (target/pc/linux/wifiradio) replaces the latter. It also checks that nothing else in + * the modules calls esp_wifi_start() or esp_wifi_stop(). + */ + +#ifndef SOFTWARE_WIFI_COMMON_WIFI_RADIO_H_ +#define SOFTWARE_WIFI_COMMON_WIFI_RADIO_H_ + +#include + +// Both are idempotent: asking for the state the radio is in already does nothing and +// returns 0. Otherwise they return 0 or the esp_err_t of the start or stop, and a failed +// call leaves the state as it was. Called by one task at a time (the boot, then the +// connector). +int radio_start(void); +int radio_stop(void); + +// True from a successful start until a successful stop +bool radio_is_on(void); + +#endif /* SOFTWARE_WIFI_COMMON_WIFI_RADIO_H_ */ diff --git a/software/wifi/common/wifi_radio_esp.c b/software/wifi/common/wifi_radio_esp.c new file mode 100644 index 000000000..2e46b7a8d --- /dev/null +++ b/software/wifi/common/wifi_radio_esp.c @@ -0,0 +1,20 @@ +/* + * wifi_radio_esp.c + * + * The chip side of wifi_radio.c, for the ESP32 (software/wifi/raw_u64) and the ESP32-C3 + * (software/wifi/raw_c3). This file holds the only calls of esp_wifi_start() and + * esp_wifi_stop() of those modules. + */ + +#include "esp_wifi.h" +#include "wifi_radio_port.h" + +int wr_port_wifi_start(void) +{ + return esp_wifi_start(); +} + +int wr_port_wifi_stop(void) +{ + return esp_wifi_stop(); +} diff --git a/software/wifi/common/wifi_radio_port.h b/software/wifi/common/wifi_radio_port.h new file mode 100644 index 000000000..8c8322116 --- /dev/null +++ b/software/wifi/common/wifi_radio_port.h @@ -0,0 +1,14 @@ +/* + * wifi_radio_port.h + * + * What wifi_radio.c needs from the chip. wifi_radio_esp.c implements it for the modules; + * the host test implements it with recording stubs. + */ + +#ifndef SOFTWARE_WIFI_COMMON_WIFI_RADIO_PORT_H_ +#define SOFTWARE_WIFI_COMMON_WIFI_RADIO_PORT_H_ + +int wr_port_wifi_start(void); // the Wi-Fi start (esp_wifi_start): 0 or an esp_err_t +int wr_port_wifi_stop(void); // the Wi-Fi stop (esp_wifi_stop) + +#endif /* SOFTWARE_WIFI_COMMON_WIFI_RADIO_PORT_H_ */ diff --git a/software/wifi/raw_c3/main/CMakeLists.txt b/software/wifi/raw_c3/main/CMakeLists.txt index 70bef78a3..fdfd7fe88 100644 --- a/software/wifi/raw_c3/main/CMakeLists.txt +++ b/software/wifi/raw_c3/main/CMakeLists.txt @@ -1,4 +1,5 @@ set(EXTERNAL "../../../io/uart") -idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${EXTERNAL}/cmd_buffer.c - INCLUDE_DIRS "." ${EXTERNAL} +set(COMMON "../../common") +idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_boot.c + INCLUDE_DIRS "." ${EXTERNAL} ${COMMON} LDFRAGMENTS "linker.lf") diff --git a/software/wifi/raw_c3/main/rpc_calls.h b/software/wifi/raw_c3/main/rpc_calls.h index 09e7aeec9..162db98ff 100644 --- a/software/wifi/raw_c3/main/rpc_calls.h +++ b/software/wifi/raw_c3/main/rpc_calls.h @@ -196,6 +196,7 @@ typedef struct { #define EVENT_RESCAN 0x44 #define EVENT_KEEPALIVE 0x45 #define EVENT_DISABLED 0x46 +#define EVENT_RESTARTED 0x47 // the module restarted on its own (radio_boot.h) #define EVENT_BUTTON 0x80 #define EVENT_FREEZE 0x81 diff --git a/software/wifi/raw_c3/main/rpc_dispatch.c b/software/wifi/raw_c3/main/rpc_dispatch.c index ab24b9811..4b9f1d69f 100644 --- a/software/wifi/raw_c3/main/rpc_dispatch.c +++ b/software/wifi/raw_c3/main/rpc_dispatch.c @@ -35,6 +35,7 @@ void cmd_echo(command_buf_t *buf) void cmd_identify(command_buf_t *buf) { rpc_identify_resp *resp = (rpc_identify_resp *)buf->data; + wifi_note_identify(); // an Ultimate application starts (wifi_modem.c, off_asked) resp->major = IDENT_MAJOR; resp->minor = IDENT_MINOR; strcpy(&resp->string, IDENT_STRING); @@ -188,20 +189,26 @@ void cmd_modem_off(command_buf_t *buf) disable_hook(); } -void cmd_wifi_disable(command_buf_t *buf) +void cmd_wifi_endisable(command_buf_t *buf) { + rpc_header_t *hdr = (rpc_header_t *)buf->data; rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; - resp->esp_err = ESP_ERR_NOT_SUPPORTED; - buf->size = sizeof(rpc_espcmd_resp); - my_uart_transmit_packet(UART_CHAN, buf); -} -void cmd_wifi_enable(command_buf_t *buf) -{ - rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; - resp->esp_err = ESP_ERR_NOT_SUPPORTED; buf->size = sizeof(rpc_espcmd_resp); - my_uart_transmit_packet(UART_CHAN, buf); + ConnectCommand_t ev; + ev.buf = buf; + ev.command = hdr->command; + + if (xQueueSend(connect_commands, &ev, 1000) == pdFALSE) { + resp->esp_err = ESP_ERR_NO_MEM; + my_uart_transmit_packet(UART_CHAN, buf); + return; + } else { + resp->esp_err = ESP_OK; + my_uart_transmit_packet(UART_CHAN, buf); + } + xSemaphoreGive(connect_semaphore); + // command is now in the queue, so the connect handler will process it further } void cmd_get_connection(command_buf_t *buf) @@ -211,6 +218,9 @@ void cmd_get_connection(command_buf_t *buf) resp->status = wifi_get_connection(); buf->size = sizeof(rpc_get_connection_resp); my_uart_transmit_packet(UART_CHAN, buf); + + // if the radio is off, say so, so that a WiFi application that starts now shows it + wifi_report_disabled(); } void cmd_get_time(command_buf_t *buf) @@ -310,10 +320,8 @@ void dispatch(void *ct) cmd_modem_off(pbuffer); break; case CMD_WIFI_DISABLE: - cmd_wifi_disable(pbuffer); - break; case CMD_WIFI_ENABLE: - cmd_wifi_enable(pbuffer); + cmd_wifi_endisable(pbuffer); break; case CMD_WIFI_IS_CONNECTED: cmd_get_connection(pbuffer); diff --git a/software/wifi/raw_c3/main/wifi_modem.c b/software/wifi/raw_c3/main/wifi_modem.c index 0edba58f6..95f2e28ad 100644 --- a/software/wifi/raw_c3/main/wifi_modem.c +++ b/software/wifi/raw_c3/main/wifi_modem.c @@ -29,6 +29,9 @@ #include "rpc_dispatch.h" #include "wifi_modem.h" #include "pinout.h" +#include "wifi_radio.h" +#include "radio_boot.h" +#include "esp_attr.h" #define NET_CMD_BUFSIZE 512 @@ -76,6 +79,32 @@ command_buf_context_t work_buffers; wifi_ap_record_t ap_info[DEFAULT_SCAN_LIST_SIZE]; uint16_t ap_count = 0; uint16_t connected_g = 0; +// The module starts with its radio off, in Disabled, until the Ultimate asks for it +uint16_t disabled_g = 1; + +/* Set when the Ultimate asks for the radio off (Disable), and cleared when an Ultimate + * application starts and identifies the module (CMD_IDENTIFY). A compatibility rule for an + * application that does not know the radio switch, not a timing assumption: such an + * application never sends Enable or Disable, and asks for the connection state + * (CMD_WIFI_IS_CONNECTED) right after it finds the module. One that knows the switch sends + * Enable or Disable before it ever asks. So a connection query that finds the radio off + * with no Disable since the application identified the module starts the radio, as the + * module always did at boot; after a Disable it never does. Enable, Autoconnect and + * Connect leave it alone: they ask for the radio on, so a query after a start that failed + * tries again. */ +volatile bool off_asked = false; + +// An Ultimate application identified the module (rpc_dispatch.c): it starts afresh +void wifi_note_identify(void) +{ + off_asked = false; +} + +/* The radio's last state, for a restart of the module that the Ultimate did not cause: + * RTC memory, which such a reset leaves alone (radio_boot.h). boot_mode is what + * setup_modem() made of it and of the reset reason, before the connector starts. */ +RTC_NOINIT_ATTR radio_record_t radio_record; +radio_boot_t boot_mode = RADIO_BOOT_WAIT; esp_netif_t *my_sta_netif = NULL; netif_input_fn default_input; @@ -87,8 +116,9 @@ QueueHandle_t connect_events; ConnectCommand_t last_connect; typedef enum { - LastAP, Scanning, ScannedAPs, StoredAPs, Connected, Disconnected, + LastAP, Scanning, ScannedAPs, StoredAPs, Connected, Disconnected, Disabled, } ConnectState_t; +static const char *states[] = { "LastAP", "Scanning", "ScannedAPs", "StoredAPs", "Connected", "Disconnected", "Disabled" }; // typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp); @@ -159,11 +189,30 @@ static void got_ip_event_handler(void *esp_netif, esp_event_base_t base, int32_t } } +static void send_event(uint8_t evcode) +{ + command_buf_t *reply; + if (my_uart_get_buffer(UART_NUM_1, &reply, 100)) { + rpc_header_t *ev = (rpc_header_t *)reply->data; + ev->command = evcode; + ev->thread = 0xFF; + ev->sequence = 0; + reply->size = sizeof(rpc_header_t); + if (evcode == EVENT_CONNECTED) { + event_pkt_connected *ev2 = (event_pkt_connected *)reply->data; + memcpy(ev2->ssid, last_connect.ssid, 32); + reply->size = sizeof(event_pkt_connected); + } + my_uart_transmit_packet(UART_NUM_1, reply); + } else { + ESP_LOGW(TAG, "No buffer to send event."); + } +} + static void wifi_event_handler(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) { ESP_LOGW(TAG, "WiFi Event %ld, data %p", event_id, data); ConnectEvent_t cev; - command_buf_t *reply; uint8_t evcode = 0; switch(event_id) { @@ -186,21 +235,7 @@ static void wifi_event_handler(void *esp_netif, esp_event_base_t base, int32_t e } if (evcode) { - if (my_uart_get_buffer(UART_NUM_1, &reply, 100)) { - rpc_header_t *ev = (rpc_header_t *)reply->data; - ev->command = evcode; - ev->thread = 0xFF; - ev->sequence = 0; - reply->size = sizeof(rpc_header_t); - if (evcode == EVENT_CONNECTED) { - event_pkt_connected *ev2 = (event_pkt_connected *)reply->data; - memcpy(ev2->ssid, last_connect.ssid, 32); - reply->size = sizeof(event_pkt_connected); - } - my_uart_transmit_packet(UART_NUM_1, reply); - } else { - ESP_LOGW(TAG, "No buffer to send event."); - } + send_event(evcode); } } @@ -208,6 +243,12 @@ void enable_hook() { struct netif *lw = ((struct esp_netif_obj *)my_sta_netif)->lwip_netif; if (lw) { + // The interface's own handlers exist only once the radio has started, and a + // restart of the radio installs them again, so they are taken here + if (lw->input && (lw->input != hacked_recv)) { + default_input = lw->input; + default_output = lw->output; + } lw->input = hacked_recv; lw->output = hacked_tx; } @@ -216,7 +257,7 @@ void enable_hook() void disable_hook() { struct netif *lw = ((struct esp_netif_obj *)my_sta_netif)->lwip_netif; - if(lw) { + if (lw && default_input) { lw->input = default_input; lw->output = default_output; } @@ -253,7 +294,8 @@ static void wifi_init() ESP_ERROR_CHECK(esp_wifi_init(&cfg)); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); - ESP_ERROR_CHECK(esp_wifi_start()); + // The radio stays off here: the connector starts it on the Ultimate's Enable or + // Autoconnect, so that a stored "WiFi Enabled" = Disabled never puts it on the air ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, @@ -266,12 +308,6 @@ static void wifi_init() &got_ip_event_handler, NULL, NULL)); - - struct netif *lw = ((struct esp_netif_obj *)my_sta_netif)->lwip_netif; - if (lw) { - default_input = lw->input; - default_output = lw->output; - } } uint8_t wifi_get_connection() @@ -626,6 +662,39 @@ esp_err_t wifi_connect_to_last() return err; } +// Has the connector replay EVENT_DISABLED if its radio is off when it gets to this. A +// command for it, not a send from here, so that it goes out in order with the Disable or +// Enable queued before it. +void wifi_report_disabled(void) +{ + ConnectCommand_t cmd; + if (!disabled_g) { + return; + } + memset(&cmd, 0, sizeof(cmd)); + cmd.command = CMD_WIFI_IS_CONNECTED; + if (xQueueSend(connect_commands, &cmd, 0) == pdTRUE) { + xSemaphoreGive(connect_semaphore); + } +} + +esp_err_t enable_wifi_if_needed(ConnectState_t state) +{ + if (state == Disabled) { + ESP_LOGI(TAG, "Starting WiFi."); + esp_err_t err = radio_start(); + if (err == ESP_OK) { + disabled_g = 0; + radio_record_set(&radio_record, true); + send_event(EVENT_DISCONNECTED); + } else { + ESP_LOGW(TAG, "Failed to start WiFi: %d", err); + } + return err; + } + return ESP_OK; +} + int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) { ConnectEvent_t connect_event; @@ -633,10 +702,83 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) esp_err_t err; switch(cmd->command) { + case CMD_WIFI_DISABLE: + off_asked = true; + if (*state == Connected) { + ESP_LOGI(TAG, "Disconnecting from WiFi."); + err = esp_wifi_disconnect(); + if (err == ESP_OK) { + xQueueReceive(connect_events, &connect_event, portMAX_DELAY); + if (connect_event.event_code == EVENT_DISCONNECTED) { + *state = Disconnected; + } + } + } + ESP_LOGI(TAG, "Stopping WiFi."); + err = radio_stop(); + if (err == ESP_OK) { + send_event(EVENT_DISABLED); + *state = Disabled; + disabled_g = 1; + radio_record_set(&radio_record, false); + return 1; + } else { + ESP_LOGW(TAG, "Failed to stop WiFi: %d", err); + } + break; + case CMD_WIFI_ENABLE: + if (*state == Disabled) { + // Like a connect request, an Enable means the user wants to be on the + // network again, so a Disconnect from before the Disable is spent + user_disconnected = false; + ESP_LOGI(TAG, "Starting WiFi."); + err = radio_start(); + if (err == ESP_OK) { + disabled_g = 0; + radio_record_set(&radio_record, true); + send_event(EVENT_DISCONNECTED); + *state = LastAP; + return 1; + } else { + ESP_LOGW(TAG, "Failed to start WiFi: %d", err); + } + } else { + ESP_LOGE(TAG, "Enabling WiFi is not possible in state %s.", states[*state]); + } // else, do nothing, not supported + break; + // The Ultimate asked for the connection state (cmd_get_connection). A WiFi + // application that starts while the radio is off is told so. Sent from here, in + // order with the Disable and Enable before it, so that it cannot overtake them. + // Asked with the radio off and no Disable since the application identified the + // module, it is an application without the radio switch (see off_asked): the radio + // starts, as it did at boot. + case CMD_WIFI_IS_CONNECTED: + if ((*state == Disabled) && !off_asked) { + ESP_LOGI(TAG, "Starting WiFi for an Ultimate without the radio switch."); + err = radio_start(); + if (err == ESP_OK) { + disabled_g = 0; + radio_record_set(&radio_record, true); + send_event(EVENT_DISCONNECTED); + *state = LastAP; + return 1; + } + ESP_LOGW(TAG, "Failed to start WiFi: %d", err); + } + if (*state == Disabled) { + send_event(EVENT_DISABLED); + } + break; case CMD_WIFI_SCAN: { rpc_scan_resp *resp = (rpc_scan_resp *)buf->data; - resp->esp_err = wifi_scan(&resp->rec); + if (*state == Disabled) { + // Disabled means the radio is off; a scan does not turn it on, Enable does + resp->esp_err = ESP_ERR_INVALID_STATE; + resp->rec.num_records = 0; + } else { + resp->esp_err = wifi_scan(&resp->rec); + } buf->size = sizeof(resp->hdr) + sizeof(resp->esp_err) + 2 + (resp->rec.num_records * sizeof(ultimate_ap_record_t)); my_uart_transmit_packet(UART_NUM_1, buf); } @@ -646,15 +788,26 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) // disconnect is spent. Scanning is not such a request and leaves it be. case CMD_WIFI_AUTOCONNECT: user_disconnected = false; - *state = LastAP; + err = enable_wifi_if_needed(*state); + if (err == ESP_OK) { + *state = LastAP; + } return 1; case CMD_WIFI_CONNECT: + user_disconnected = false; + err = enable_wifi_if_needed(*state); + if ((err == ESP_OK) && (*state == Disabled)) { + // The radio is on again: whatever the attempt gives, the connector goes + // on from here and retries, as after a dropped link + *state = Disconnected; + } { - user_disconnected = false; last_connect = *cmd; last_connect.list_index = -1; rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; - err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + if (err == ESP_OK) { + err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + } resp->esp_err = err; my_uart_transmit_packet(UART_NUM_1, cmd->buf); @@ -678,15 +831,43 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) return 0; // not connected } +// The connector's first state (radio_boot.h): Disabled with the radio off after a power-up +// or a reset by the Ultimate; after a restart of its own, the radio as it was, and the +// Ultimate is told +ConnectState_t connector_boot_state(void) +{ + if (boot_mode == RADIO_BOOT_WAIT) { + return Disabled; + } + send_event(EVENT_RESTARTED); + if (boot_mode == RADIO_BOOT_ON) { + ESP_LOGI(TAG, "Restarted: starting WiFi again."); + if (radio_start() == ESP_OK) { + disabled_g = 0; + radio_record_set(&radio_record, true); + send_event(EVENT_DISCONNECTED); + return LastAP; + } + ESP_LOGW(TAG, "Failed to start WiFi."); + return Disabled; + } + // Off before the restart: the Ultimate had asked for that, and a later connection + // query must not start it + off_asked = true; + return Disabled; +} + void connect_thread(void *a) { ConnectEvent_t connect_event; ConnectCommand_t connect_command; - ConnectState_t state = LastAP; - ConnectState_t prev = LastAP; + // Radio off until the Ultimate sends Enable or Autoconnect, or asks for the connection + // state without knowing the radio switch (disabled_g starts set; see off_asked), + // except after a restart of the module's own (connector_boot_state) + ConnectState_t state = connector_boot_state(); + ConnectState_t prev = state; int retry_delay_ms = WIFI_RETRY_MIN_MS; esp_err_t err; - static const char *states[] = { "LastAP", "Scanning", "ScannedAPs", "StoredAPs", "Connected", "Disconnected" }; while(1) { // A disconnect the user asked for can arrive while the ladder is @@ -699,8 +880,9 @@ void connect_thread(void *a) // So check here, between states, which is the one point the ladder // passes through with nothing in flight. An attempt that landed in the // meantime has to be undone rather than prevented; it had already been - // accepted by the time the request arrived. - if (user_disconnected && (state != Disconnected)) { + // accepted by the time the request arrived. Disabled is left alone: + // the radio is off, so there is nothing to undo or to retry. + if (user_disconnected && (state != Disconnected) && (state != Disabled)) { if (connected_g) { ESP_LOGI(TAG, "Disconnect requested while reconnecting; undoing."); esp_wifi_disconnect(); @@ -746,7 +928,9 @@ void connect_thread(void *a) } } } - if (state != Connected) { + // A command handled in the walk has set the state already: a Disable + // or an Autoconnect must not be overwritten here + if (state == ScannedAPs) { state = StoredAPs; } break; @@ -768,7 +952,7 @@ void connect_thread(void *a) } } } - if (state != Connected) { + if (state == StoredAPs) { state = Disconnected; } break; @@ -785,7 +969,8 @@ void connect_thread(void *a) // Connected waits indefinitely, because something else has to // happen first. Disconnected does not: nothing is coming unless // we go and ask, so the wait is bounded and a timeout means it - // is time to try again. + // is time to try again. Disabled has its own case below and is + // left alone -- the radio is off, so there is nothing to retry. if (state == Connected) { retry_delay_ms = WIFI_RETRY_MIN_MS; } @@ -816,6 +1001,13 @@ void connect_thread(void *a) } } break; + + case Disabled: + // The only way to wake up the WiFi again is to send a connect command + xQueueReceive(connect_commands, &connect_command, portMAX_DELAY); + handle_connect_command(&connect_command, &state); + break; + default: state = LastAP; } @@ -864,10 +1056,19 @@ void setup_modem() ESP_LOGI(TAG, "wifi_init..."); wifi_init(); ESP_LOGI(TAG, "start wifi connector..."); - start_connector(); + // A restart that neither a power-up nor the Ultimate caused (the Ultimate drives the + // module's enable pin, which reads as a power-up or an external reset) + esp_reset_reason_t why = esp_reset_reason(); + bool self_restart = (why == ESP_RST_PANIC) || (why == ESP_RST_INT_WDT) || (why == ESP_RST_TASK_WDT) || + (why == ESP_RST_WDT) || (why == ESP_RST_SW) || (why == ESP_RST_BROWNOUT); + boot_mode = radio_boot_decision(self_restart, &radio_record); + ESP_LOGI(TAG, "Reset reason %d, radio at boot %d", (int)why, (int)boot_mode); ESP_LOGI(TAG, "dispatch... switching UART pins!"); vTaskDelay(100 / portTICK_PERIOD_MS); ESP_ERROR_CHECK( uart_set_pin(UART_NUM_1, IO_UART_TXD, IO_UART_RXD, IO_UART_RTS, IO_UART_CTS)); + // The connector may send events from its first state on (EVENT_RESTARTED), so it starts + // once the UART is on its pins; the dispatcher, which queues commands for it, after it + start_connector(); start_dispatch(work_buffers.receivedQueue); } diff --git a/software/wifi/raw_c3/main/wifi_modem.h b/software/wifi/raw_c3/main/wifi_modem.h index 20a571352..7e5dae2c5 100644 --- a/software/wifi/raw_c3/main/wifi_modem.h +++ b/software/wifi/raw_c3/main/wifi_modem.h @@ -26,5 +26,7 @@ esp_err_t wifi_clear_aps(void); void enable_hook(); void disable_hook(); uint8_t wifi_get_connection(); +void wifi_report_disabled(void); +void wifi_note_identify(void); #endif diff --git a/software/wifi/raw_u64/main/CMakeLists.txt b/software/wifi/raw_u64/main/CMakeLists.txt index a3895b1f9..fdfd7fe88 100644 --- a/software/wifi/raw_u64/main/CMakeLists.txt +++ b/software/wifi/raw_u64/main/CMakeLists.txt @@ -1,4 +1,5 @@ set(EXTERNAL "../../../io/uart") -idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${EXTERNAL}/cmd_buffer.c - INCLUDE_DIRS "." ${EXTERNAL} - LDFRAGMENTS "linker.lf") \ No newline at end of file +set(COMMON "../../common") +idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_boot.c + INCLUDE_DIRS "." ${EXTERNAL} ${COMMON} + LDFRAGMENTS "linker.lf") diff --git a/software/wifi/raw_u64/main/rpc_calls.h b/software/wifi/raw_u64/main/rpc_calls.h index 09e7aeec9..162db98ff 100644 --- a/software/wifi/raw_u64/main/rpc_calls.h +++ b/software/wifi/raw_u64/main/rpc_calls.h @@ -196,6 +196,7 @@ typedef struct { #define EVENT_RESCAN 0x44 #define EVENT_KEEPALIVE 0x45 #define EVENT_DISABLED 0x46 +#define EVENT_RESTARTED 0x47 // the module restarted on its own (radio_boot.h) #define EVENT_BUTTON 0x80 #define EVENT_FREEZE 0x81 diff --git a/software/wifi/raw_u64/main/rpc_dispatch.c b/software/wifi/raw_u64/main/rpc_dispatch.c index 98ada083d..5ec52f7c7 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.c +++ b/software/wifi/raw_u64/main/rpc_dispatch.c @@ -35,6 +35,7 @@ void cmd_echo(command_buf_t *buf) void cmd_identify(command_buf_t *buf) { rpc_identify_resp *resp = (rpc_identify_resp *)buf->data; + wifi_note_identify(); // an Ultimate application starts (wifi_modem.c, off_asked) resp->major = IDENT_MAJOR; resp->minor = IDENT_MINOR; strcpy(&resp->string, IDENT_STRING); @@ -188,20 +189,26 @@ void cmd_modem_off(command_buf_t *buf) disable_hook(); } -void cmd_wifi_disable(command_buf_t *buf) +void cmd_wifi_endisable(command_buf_t *buf) { + rpc_header_t *hdr = (rpc_header_t *)buf->data; rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; - resp->esp_err = ESP_ERR_NOT_SUPPORTED; - buf->size = sizeof(rpc_espcmd_resp); - my_uart_transmit_packet(UART_CHAN, buf); -} -void cmd_wifi_enable(command_buf_t *buf) -{ - rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; - resp->esp_err = ESP_ERR_NOT_SUPPORTED; buf->size = sizeof(rpc_espcmd_resp); - my_uart_transmit_packet(UART_CHAN, buf); + ConnectCommand_t ev; + ev.buf = buf; + ev.command = hdr->command; + + if (xQueueSend(connect_commands, &ev, 1000) == pdFALSE) { + resp->esp_err = ESP_ERR_NO_MEM; + my_uart_transmit_packet(UART_CHAN, buf); + return; + } else { + resp->esp_err = ESP_OK; + my_uart_transmit_packet(UART_CHAN, buf); + } + xSemaphoreGive(connect_semaphore); + // command is now in the queue, so the connect handler will process it further } void cmd_get_connection(command_buf_t *buf) @@ -211,6 +218,9 @@ void cmd_get_connection(command_buf_t *buf) resp->status = wifi_get_connection(); buf->size = sizeof(rpc_get_connection_resp); my_uart_transmit_packet(UART_CHAN, buf); + + // if the radio is off, say so, so that a WiFi application that starts now shows it + wifi_report_disabled(); } void cmd_get_time(command_buf_t *buf) @@ -312,10 +322,8 @@ void dispatch(void *ct) cmd_modem_off(pbuffer); break; case CMD_WIFI_DISABLE: - cmd_wifi_disable(pbuffer); - break; case CMD_WIFI_ENABLE: - cmd_wifi_enable(pbuffer); + cmd_wifi_endisable(pbuffer); break; case CMD_WIFI_IS_CONNECTED: cmd_get_connection(pbuffer); diff --git a/software/wifi/raw_u64/main/wifi_modem.c b/software/wifi/raw_u64/main/wifi_modem.c index e9fd7fec1..52b16b2b5 100644 --- a/software/wifi/raw_u64/main/wifi_modem.c +++ b/software/wifi/raw_u64/main/wifi_modem.c @@ -29,6 +29,9 @@ #include "rpc_dispatch.h" #include "wifi_modem.h" #include "pinout.h" +#include "wifi_radio.h" +#include "radio_boot.h" +#include "esp_attr.h" #define NET_CMD_BUFSIZE 512 @@ -76,6 +79,32 @@ command_buf_context_t work_buffers; wifi_ap_record_t ap_info[DEFAULT_SCAN_LIST_SIZE]; uint16_t ap_count = 0; uint16_t connected_g = 0; +// The module starts with its radio off, in Disabled, until the Ultimate asks for it +uint16_t disabled_g = 1; + +/* Set when the Ultimate asks for the radio off (Disable), and cleared when an Ultimate + * application starts and identifies the module (CMD_IDENTIFY). A compatibility rule for an + * application that does not know the radio switch, not a timing assumption: such an + * application never sends Enable or Disable, and asks for the connection state + * (CMD_WIFI_IS_CONNECTED) right after it finds the module. One that knows the switch sends + * Enable or Disable before it ever asks. So a connection query that finds the radio off + * with no Disable since the application identified the module starts the radio, as the + * module always did at boot; after a Disable it never does. Enable, Autoconnect and + * Connect leave it alone: they ask for the radio on, so a query after a start that failed + * tries again. */ +volatile bool off_asked = false; + +// An Ultimate application identified the module (rpc_dispatch.c): it starts afresh +void wifi_note_identify(void) +{ + off_asked = false; +} + +/* The radio's last state, for a restart of the module that the Ultimate did not cause: + * RTC memory, which such a reset leaves alone (radio_boot.h). boot_mode is what + * setup_modem() made of it and of the reset reason, before the connector starts. */ +RTC_NOINIT_ATTR radio_record_t radio_record; +radio_boot_t boot_mode = RADIO_BOOT_WAIT; esp_netif_t *my_sta_netif = NULL; netif_input_fn default_input; @@ -87,8 +116,9 @@ QueueHandle_t connect_events; ConnectCommand_t last_connect; typedef enum { - LastAP, Scanning, ScannedAPs, StoredAPs, Connected, Disconnected, + LastAP, Scanning, ScannedAPs, StoredAPs, Connected, Disconnected, Disabled, } ConnectState_t; +static const char *states[] = { "LastAP", "Scanning", "ScannedAPs", "StoredAPs", "Connected", "Disconnected", "Disabled" }; // typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp); @@ -159,11 +189,30 @@ static void got_ip_event_handler(void *esp_netif, esp_event_base_t base, int32_t } } +static void send_event(uint8_t evcode) +{ + command_buf_t *reply; + if (my_uart_get_buffer(UART_NUM_1, &reply, 100)) { + rpc_header_t *ev = (rpc_header_t *)reply->data; + ev->command = evcode; + ev->thread = 0xFF; + ev->sequence = 0; + reply->size = sizeof(rpc_header_t); + if (evcode == EVENT_CONNECTED) { + event_pkt_connected *ev2 = (event_pkt_connected *)reply->data; + memcpy(ev2->ssid, last_connect.ssid, 32); + reply->size = sizeof(event_pkt_connected); + } + my_uart_transmit_packet(UART_NUM_1, reply); + } else { + ESP_LOGW(TAG, "No buffer to send event."); + } +} + static void wifi_event_handler(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) { ESP_LOGW(TAG, "WiFi Event %ld, data %p", event_id, data); ConnectEvent_t cev; - command_buf_t *reply; uint8_t evcode = 0; switch(event_id) { @@ -186,21 +235,7 @@ static void wifi_event_handler(void *esp_netif, esp_event_base_t base, int32_t e } if (evcode) { - if (my_uart_get_buffer(UART_NUM_1, &reply, 100)) { - rpc_header_t *ev = (rpc_header_t *)reply->data; - ev->command = evcode; - ev->thread = 0xFF; - ev->sequence = 0; - reply->size = sizeof(rpc_header_t); - if (evcode == EVENT_CONNECTED) { - event_pkt_connected *ev2 = (event_pkt_connected *)reply->data; - memcpy(ev2->ssid, last_connect.ssid, 32); - reply->size = sizeof(event_pkt_connected); - } - my_uart_transmit_packet(UART_NUM_1, reply); - } else { - ESP_LOGW(TAG, "No buffer to send event."); - } + send_event(evcode); } } @@ -208,6 +243,12 @@ void enable_hook() { struct netif *lw = ((struct esp_netif_obj *)my_sta_netif)->lwip_netif; if (lw) { + // The interface's own handlers exist only once the radio has started, and a + // restart of the radio installs them again, so they are taken here + if (lw->input && (lw->input != hacked_recv)) { + default_input = lw->input; + default_output = lw->output; + } lw->input = hacked_recv; lw->output = hacked_tx; } @@ -216,7 +257,7 @@ void enable_hook() void disable_hook() { struct netif *lw = ((struct esp_netif_obj *)my_sta_netif)->lwip_netif; - if(lw) { + if (lw && default_input) { lw->input = default_input; lw->output = default_output; } @@ -253,7 +294,8 @@ static void wifi_init() ESP_ERROR_CHECK(esp_wifi_init(&cfg)); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); - ESP_ERROR_CHECK(esp_wifi_start()); + // The radio stays off here: the connector starts it on the Ultimate's Enable or + // Autoconnect, so that a stored "WiFi Enabled" = Disabled never puts it on the air ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, @@ -266,12 +308,6 @@ static void wifi_init() &got_ip_event_handler, NULL, NULL)); - - struct netif *lw = ((struct esp_netif_obj *)my_sta_netif)->lwip_netif; - if (lw) { - default_input = lw->input; - default_output = lw->output; - } } uint8_t wifi_get_connection() @@ -626,6 +662,39 @@ esp_err_t wifi_connect_to_last() return err; } +// Has the connector replay EVENT_DISABLED if its radio is off when it gets to this. A +// command for it, not a send from here, so that it goes out in order with the Disable or +// Enable queued before it. +void wifi_report_disabled(void) +{ + ConnectCommand_t cmd; + if (!disabled_g) { + return; + } + memset(&cmd, 0, sizeof(cmd)); + cmd.command = CMD_WIFI_IS_CONNECTED; + if (xQueueSend(connect_commands, &cmd, 0) == pdTRUE) { + xSemaphoreGive(connect_semaphore); + } +} + +esp_err_t enable_wifi_if_needed(ConnectState_t state) +{ + if (state == Disabled) { + ESP_LOGI(TAG, "Starting WiFi."); + esp_err_t err = radio_start(); + if (err == ESP_OK) { + disabled_g = 0; + radio_record_set(&radio_record, true); + send_event(EVENT_DISCONNECTED); + } else { + ESP_LOGW(TAG, "Failed to start WiFi: %d", err); + } + return err; + } + return ESP_OK; +} + int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) { ConnectEvent_t connect_event; @@ -633,10 +702,83 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) esp_err_t err; switch(cmd->command) { + case CMD_WIFI_DISABLE: + off_asked = true; + if (*state == Connected) { + ESP_LOGI(TAG, "Disconnecting from WiFi."); + err = esp_wifi_disconnect(); + if (err == ESP_OK) { + xQueueReceive(connect_events, &connect_event, portMAX_DELAY); + if (connect_event.event_code == EVENT_DISCONNECTED) { + *state = Disconnected; + } + } + } + ESP_LOGI(TAG, "Stopping WiFi."); + err = radio_stop(); + if (err == ESP_OK) { + send_event(EVENT_DISABLED); + *state = Disabled; + disabled_g = 1; + radio_record_set(&radio_record, false); + return 1; + } else { + ESP_LOGW(TAG, "Failed to stop WiFi: %d", err); + } + break; + case CMD_WIFI_ENABLE: + if (*state == Disabled) { + // Like a connect request, an Enable means the user wants to be on the + // network again, so a Disconnect from before the Disable is spent + user_disconnected = false; + ESP_LOGI(TAG, "Starting WiFi."); + err = radio_start(); + if (err == ESP_OK) { + disabled_g = 0; + radio_record_set(&radio_record, true); + send_event(EVENT_DISCONNECTED); + *state = LastAP; + return 1; + } else { + ESP_LOGW(TAG, "Failed to start WiFi: %d", err); + } + } else { + ESP_LOGE(TAG, "Enabling WiFi is not possible in state %s.", states[*state]); + } // else, do nothing, not supported + break; + // The Ultimate asked for the connection state (cmd_get_connection). A WiFi + // application that starts while the radio is off is told so. Sent from here, in + // order with the Disable and Enable before it, so that it cannot overtake them. + // Asked with the radio off and no Disable since the application identified the + // module, it is an application without the radio switch (see off_asked): the radio + // starts, as it did at boot. + case CMD_WIFI_IS_CONNECTED: + if ((*state == Disabled) && !off_asked) { + ESP_LOGI(TAG, "Starting WiFi for an Ultimate without the radio switch."); + err = radio_start(); + if (err == ESP_OK) { + disabled_g = 0; + radio_record_set(&radio_record, true); + send_event(EVENT_DISCONNECTED); + *state = LastAP; + return 1; + } + ESP_LOGW(TAG, "Failed to start WiFi: %d", err); + } + if (*state == Disabled) { + send_event(EVENT_DISABLED); + } + break; case CMD_WIFI_SCAN: { rpc_scan_resp *resp = (rpc_scan_resp *)buf->data; - resp->esp_err = wifi_scan(&resp->rec); + if (*state == Disabled) { + // Disabled means the radio is off; a scan does not turn it on, Enable does + resp->esp_err = ESP_ERR_INVALID_STATE; + resp->rec.num_records = 0; + } else { + resp->esp_err = wifi_scan(&resp->rec); + } buf->size = sizeof(resp->hdr) + sizeof(resp->esp_err) + 2 + (resp->rec.num_records * sizeof(ultimate_ap_record_t)); my_uart_transmit_packet(UART_NUM_1, buf); } @@ -646,15 +788,26 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) // disconnect is spent. Scanning is not such a request and leaves it be. case CMD_WIFI_AUTOCONNECT: user_disconnected = false; - *state = LastAP; + err = enable_wifi_if_needed(*state); + if (err == ESP_OK) { + *state = LastAP; + } return 1; case CMD_WIFI_CONNECT: + user_disconnected = false; + err = enable_wifi_if_needed(*state); + if ((err == ESP_OK) && (*state == Disabled)) { + // The radio is on again: whatever the attempt gives, the connector goes + // on from here and retries, as after a dropped link + *state = Disconnected; + } { - user_disconnected = false; last_connect = *cmd; last_connect.list_index = -1; rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; - err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + if (err == ESP_OK) { + err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + } resp->esp_err = err; my_uart_transmit_packet(UART_NUM_1, cmd->buf); @@ -678,15 +831,43 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) return 0; // not connected } +// The connector's first state (radio_boot.h): Disabled with the radio off after a power-up +// or a reset by the Ultimate; after a restart of its own, the radio as it was, and the +// Ultimate is told +ConnectState_t connector_boot_state(void) +{ + if (boot_mode == RADIO_BOOT_WAIT) { + return Disabled; + } + send_event(EVENT_RESTARTED); + if (boot_mode == RADIO_BOOT_ON) { + ESP_LOGI(TAG, "Restarted: starting WiFi again."); + if (radio_start() == ESP_OK) { + disabled_g = 0; + radio_record_set(&radio_record, true); + send_event(EVENT_DISCONNECTED); + return LastAP; + } + ESP_LOGW(TAG, "Failed to start WiFi."); + return Disabled; + } + // Off before the restart: the Ultimate had asked for that, and a later connection + // query must not start it + off_asked = true; + return Disabled; +} + void connect_thread(void *a) { ConnectEvent_t connect_event; ConnectCommand_t connect_command; - ConnectState_t state = LastAP; - ConnectState_t prev = LastAP; + // Radio off until the Ultimate sends Enable or Autoconnect, or asks for the connection + // state without knowing the radio switch (disabled_g starts set; see off_asked), + // except after a restart of the module's own (connector_boot_state) + ConnectState_t state = connector_boot_state(); + ConnectState_t prev = state; int retry_delay_ms = WIFI_RETRY_MIN_MS; esp_err_t err; - static const char *states[] = { "LastAP", "Scanning", "ScannedAPs", "StoredAPs", "Connected", "Disconnected" }; while(1) { // A disconnect the user asked for can arrive while the ladder is @@ -699,8 +880,9 @@ void connect_thread(void *a) // So check here, between states, which is the one point the ladder // passes through with nothing in flight. An attempt that landed in the // meantime has to be undone rather than prevented; it had already been - // accepted by the time the request arrived. - if (user_disconnected && (state != Disconnected)) { + // accepted by the time the request arrived. Disabled is left alone: + // the radio is off, so there is nothing to undo or to retry. + if (user_disconnected && (state != Disconnected) && (state != Disabled)) { if (connected_g) { ESP_LOGI(TAG, "Disconnect requested while reconnecting; undoing."); esp_wifi_disconnect(); @@ -746,7 +928,9 @@ void connect_thread(void *a) } } } - if (state != Connected) { + // A command handled in the walk has set the state already: a Disable + // or an Autoconnect must not be overwritten here + if (state == ScannedAPs) { state = StoredAPs; } break; @@ -768,7 +952,7 @@ void connect_thread(void *a) } } } - if (state != Connected) { + if (state == StoredAPs) { state = Disconnected; } break; @@ -785,7 +969,8 @@ void connect_thread(void *a) // Connected waits indefinitely, because something else has to // happen first. Disconnected does not: nothing is coming unless // we go and ask, so the wait is bounded and a timeout means it - // is time to try again. + // is time to try again. Disabled has its own case below and is + // left alone -- the radio is off, so there is nothing to retry. if (state == Connected) { retry_delay_ms = WIFI_RETRY_MIN_MS; } @@ -816,6 +1001,13 @@ void connect_thread(void *a) } } break; + + case Disabled: + // The only way to wake up the WiFi again is to send a connect command + xQueueReceive(connect_commands, &connect_command, portMAX_DELAY); + handle_connect_command(&connect_command, &state); + break; + default: state = LastAP; } @@ -880,10 +1072,19 @@ void setup_modem() ESP_LOGI(TAG, "wifi_init..."); wifi_init(); ESP_LOGI(TAG, "start wifi connector..."); - start_connector(); + // A restart that neither a power-up nor the Ultimate caused (the Ultimate drives the + // module's enable pin, which reads as a power-up or an external reset) + esp_reset_reason_t why = esp_reset_reason(); + bool self_restart = (why == ESP_RST_PANIC) || (why == ESP_RST_INT_WDT) || (why == ESP_RST_TASK_WDT) || + (why == ESP_RST_WDT) || (why == ESP_RST_SW) || (why == ESP_RST_BROWNOUT); + boot_mode = radio_boot_decision(self_restart, &radio_record); + ESP_LOGI(TAG, "Reset reason %d, radio at boot %d", (int)why, (int)boot_mode); ESP_LOGI(TAG, "dispatch... switching UART pins!"); vTaskDelay(100 / portTICK_PERIOD_MS); ESP_ERROR_CHECK( uart_set_pin(UART_NUM_1, IO_UART_TXD, IO_UART_RXD, IO_UART_RTS, IO_UART_CTS)); + // The connector may send events from its first state on (EVENT_RESTARTED), so it starts + // once the UART is on its pins; the dispatcher, which queues commands for it, after it + start_connector(); start_dispatch(work_buffers.receivedQueue); } diff --git a/software/wifi/raw_u64/main/wifi_modem.h b/software/wifi/raw_u64/main/wifi_modem.h index 20a571352..7e5dae2c5 100644 --- a/software/wifi/raw_u64/main/wifi_modem.h +++ b/software/wifi/raw_u64/main/wifi_modem.h @@ -26,5 +26,7 @@ esp_err_t wifi_clear_aps(void); void enable_hook(); void disable_hook(); uint8_t wifi_get_connection(); +void wifi_report_disabled(void); +void wifi_note_identify(void); #endif diff --git a/software/wifi/tests/Makefile b/software/wifi/tests/Makefile new file mode 100644 index 000000000..a67a0a7d3 --- /dev/null +++ b/software/wifi/tests/Makefile @@ -0,0 +1,132 @@ +# +# Host tests of the code of the ESP32 WiFi modules (raw_u64 = Ultimate 64, raw_c3 = Ultimate II+L, +# u64ctrl = Elite II / C64 Ultimate): their connector, dispatcher commands, event handler and AP +# selection, and the radio switch (wifi/common). The functions are cut out of each module's +# wifi_modem.c and rpc_dispatch.c as they are (software/io/wifi/tests/extract.awk) and run +# against the stand-ins of ESP-IDF, FreeRTOS and the UART in module_stubs.c. No hardware and no +# ESP-IDF needed. +# +# make all modules, the radio switch, and then the -red runs +# make test all modules and the radio switch +# make MODULE=u64ctrl test one module (raw_u64, raw_c3, u64ctrl) +# make red the same cases against a model of the modules as they were before +# each fix (the LEGACY_* sed expressions below); every one must +# fail (project pattern: software/io/network/tests, eth-tx-frame-red) +# +# The cases are the C++ files picked up by name, so that a case file is added without touching +# this file: module_*_test.cpp run against each module, radio_*test.cpp against wifi/common. +# +PATH_SW := ../.. +EXTRACT := awk -f $(PATH_SW)/io/wifi/tests/extract.awk +OUT := output +ALL := raw_u64 raw_c3 u64ctrl +MODULE ?= $(ALL) +CXX ?= g++ +CC ?= gcc + +DIR_raw_u64 := $(PATH_SW)/wifi/raw_u64/main +DIR_raw_c3 := $(PATH_SW)/wifi/raw_c3/main +DIR_u64ctrl := $(PATH_SW)/u64ctrl/main +# The U64 and U2+L modules have the radio switch (radio_boot.h): only they see wifi/common +INC_raw_u64 := -I$(PATH_SW)/wifi/common +INC_raw_c3 := -I$(PATH_SW)/wifi/common + +HOSTTEST := $(PATH_SW)/io/usb/tests +CASES := $(wildcard module_*_test.cpp) +RADIO := $(wildcard radio_*test.cpp) +COMMON := -g -O0 -Wall -Wno-unused-parameter -D_FORTIFY_SOURCE=0 +CFLAGS := -std=gnu11 $(COMMON) -Wno-unused-variable -Wno-unused-function +CXXFLAGS := -std=c++14 $(COMMON) -I$(HOSTTEST) -I. -Istub +INCLUDES = -I. -Istub -I$(DIR_$(M)) -I$(PATH_SW)/io/uart $(INC_$(M)) + +# What the extracted code of a module is made of ... +FUNCS_MODEM := send_event wifi_event_handler wifi_note_identify wifi_send_connected_event attempt_connect \ + wifi_connect_to_scanned enable_wifi_if_needed wifi_report_disabled handle_connect_command \ + connector_boot_state connect_thread +FUNCS_RPC := cmd_identify cmd_wifi_connect cmd_wifi_endisable cmd_get_connection +# ... and what every module must have +NEEDED := send_event wifi_event_handler attempt_connect wifi_connect_to_scanned enable_wifi_if_needed \ + handle_connect_command connect_thread cmd_identify cmd_wifi_connect cmd_wifi_endisable cmd_get_connection + +# --- the -red runs: the same cases against a model of the modules as they were before a fix -- +# +# One sed expression list per fix and module over the extracted code, which keeps what the fix +# changed and puts back what was there before. Every one has to make the suite FAIL (a failing +# check, not a build error); `make red` prints which checks failed. A fix that a module +# does not have, or whose cases are not in this commit, has no entry. +RED_FIXES := 1 + +# 1 The radio switch (U64, U2+L): no Disable is served, and the radio goes on at boot, as +# on a module without the switch +LEGACY_1_raw_u64 := -e 's/case CMD_WIFI_DISABLE:/case 0x7F:/' -e 's/return Disabled;/return LastAP;/' +LEGACY_1_raw_c3 := $(LEGACY_1_raw_u64) + +LEGACY = $(LEGACY_$(FIX)_$(M)) + +.PHONY: all test red clean radio + +all: test red + +test: + @set -e; for m in $(MODULE); do $(MAKE) --no-print-directory M=$$m run; done + @$(MAKE) --no-print-directory radio + +# --- one module: M= ------------------------------------------------------------- + +# The module's functions, verbatim, behind module_env.h, and the stubs at the end. The +# typedef of ConnectState_t is taken along with the awk of the three lines it needs. +# RED= turns the code into a model of it as it was before a fix. +define EXTRACTED + @mkdir -p $(1) + @{ echo '#include "module_env.h"'; \ + awk '/^typedef enum \{/ { t = 1; buf = "" } t { buf = buf $$0 "\n" } t && /\} ConnectState_t;/ { if (buf ~ /LastAP/) printf "%s", buf; t = 0 }' $(DIR_$(M))/wifi_modem.c; \ + grep -E '^static const char \*states\[\]' $(DIR_$(M))/wifi_modem.c; \ + for f in $(FUNCS_MODEM); do $(EXTRACT) -v f=$$f $(DIR_$(M))/wifi_modem.c; done; \ + for f in $(FUNCS_RPC); do $(EXTRACT) -v f=$$f $(DIR_$(M))/rpc_dispatch.c; done; } > $(1)/module_code.in + @for f in ConnectState_t $(NEEDED); do grep -q "$$f" $(1)/module_code.in || { echo "wifi tests: $$f not found in $(M)"; exit 1; }; done + $(if $(LEGACY),@sed $(LEGACY) $(1)/module_code.in > $(1)/module_code.red && ! cmp -s $(1)/module_code.red $(1)/module_code.in || { echo "wifi tests: legacy model $(FIX) does not apply to $(M)"; exit 1; }) + $(if $(LEGACY),@mv $(1)/module_code.red $(1)/module_code.in) + @{ cat $(1)/module_code.in; echo '#include "module_stubs.c"'; for f in $(wildcard module_*_stubs.c); do echo "#include \"$$f\""; done; } > $(1)/module_code.c +endef + +define BUILD + $(CC) $(CFLAGS) $(INCLUDES) -D$(DEF) -c -o $(1)/module_code.o $(1)/module_code.c + $(CXX) $(CXXFLAGS) -I$(DIR_$(M)) -I$(PATH_SW)/io/uart $(INC_$(M)) -D$(DEF) -DMODULE_NAME='"$(M)"' \ + -o $(1)/wifi_module_test $(CASES) $(HOSTTEST)/host_test_main.cpp $(1)/module_code.o -lpthread +endef + +red: + @set -e; for fix in $(RED_FIXES); do for m in $(MODULE); do $(MAKE) --no-print-directory M=$$m FIX=$$fix redrun; done; done + +redrun: DEF = MODULE_$(shell echo $(M) | tr a-z A-Z) +redrun: + @: +ifneq ($(LEGACY),) + $(call EXTRACTED,$(OUT)/red$(FIX)/$(M)) + $(call BUILD,$(OUT)/red$(FIX)/$(M)) + @if $(OUT)/red$(FIX)/$(M)/wifi_module_test > $(OUT)/red$(FIX)/$(M)/log 2>&1; then \ + echo "red $(FIX) $(M): the suite PASSED against the model before fix $(FIX): it no longer catches it"; exit 1; \ + else \ + echo "red $(FIX) $(M): $$(grep -c '^FAIL' $(OUT)/red$(FIX)/$(M)/log) check(s) fail against the model before fix $(FIX), as required:"; \ + grep -E '^(FAIL| check)' $(OUT)/red$(FIX)/$(M)/log | grep -v 'check_ok_' | cut -c1-150 | head -6 | sed 's/^/ /'; \ + fi +endif + +run: DEF = MODULE_$(shell echo $(M) | tr a-z A-Z) +run: + $(call EXTRACTED,$(OUT)/$(M)) + $(call BUILD,$(OUT)/$(M)) + @echo "== $(M)"; $(OUT)/$(M)/wifi_module_test + +# --- the radio switch: wifi_radio.c and radio_boot.c against a chip stub --------------------- + +radio: + @mkdir -p $(OUT)/radio + $(CC) -std=c99 $(COMMON) -I$(PATH_SW)/wifi/common -c -o $(OUT)/radio/wifi_radio.o $(PATH_SW)/wifi/common/wifi_radio.c + $(CC) -std=c99 $(COMMON) -I$(PATH_SW)/wifi/common -c -o $(OUT)/radio/radio_boot.o $(PATH_SW)/wifi/common/radio_boot.c + $(CXX) $(CXXFLAGS) -I$(PATH_SW)/wifi/common -o $(OUT)/radio/wifi_radio_test $(RADIO) $(HOSTTEST)/host_test_main.cpp \ + $(OUT)/radio/wifi_radio.o $(OUT)/radio/radio_boot.o -lpthread + @echo "== radio"; $(OUT)/radio/wifi_radio_test + +clean: + @rm -rf $(OUT) diff --git a/software/wifi/tests/module_env.h b/software/wifi/tests/module_env.h new file mode 100644 index 000000000..01770fbed --- /dev/null +++ b/software/wifi/tests/module_env.h @@ -0,0 +1,149 @@ +/* + * module_env.h + * + * The world the WiFi modules' code under test (the functions Makefile cuts out of + * wifi_modem.c and rpc_dispatch.c of raw_u64, raw_c3 and u64ctrl) sees on the build host: + * the module's own rpc_calls.h and wifi_modem.h, and declarations of the ESP-IDF, FreeRTOS + * and UART calls that module_stubs.c provides. Included by that code (C) and by the cases + * (C++). + * + * The station config below copies the field names and enum values of ESP-IDF 5.3.1 + * (components/esp_wifi/include/esp_wifi_types_generic.h): the values matter, because the + * module clears the config with memset first, and 0 is WIFI_FAST_SCAN and + * WIFI_CONNECT_AP_BY_SIGNAL there. + */ + +#ifndef MODULE_ENV_H_ +#define MODULE_ENV_H_ + +#include +#include +#include +#include +#include +#include "freertos/FreeRTOS.h" + +typedef int esp_err_t; +#define ESP_OK 0 +#define ESP_FAIL (-1) +#define ESP_ERR_NO_MEM 0x101 +#define ESP_ERR_INVALID_ARG 0x102 +#define ESP_ERR_INVALID_STATE 0x103 +#define ESP_ERR_NOT_FOUND 0x105 +#define ESP_ERR_NOT_SUPPORTED 0x106 +typedef const char *esp_event_base_t; + +#ifdef __cplusplus +extern "C" { +#endif +#include "cmd_buffer.h" +#include "rpc_calls.h" +#include "wifi_modem.h" +#ifdef __cplusplus +} +#endif +#define UART_NUM_1 1 +#define UART_CHAN UART_NUM_1 +#define IDENT_MAJOR 1 +#define IDENT_MINOR 2 +#define IDENT_STRING "module test" + +#define ESP_LOGI(tag, ...) ((void)0) +#define ESP_LOGW(tag, ...) ((void)0) +#define ESP_LOGE(tag, ...) ((void)0) + +#define WIFI_RETRY_MIN_MS 5000 +#define WIFI_RETRY_MAX_MS 60000 + +typedef enum { WIFI_FAST_SCAN = 0, WIFI_ALL_CHANNEL_SCAN } wifi_scan_method_t; +typedef enum { WIFI_CONNECT_AP_BY_SIGNAL = 0, WIFI_CONNECT_AP_BY_SECURITY } wifi_sort_method_t; +typedef enum { + WIFI_AUTH_OPEN = 0, WIFI_AUTH_WEP, WIFI_AUTH_WPA_PSK, WIFI_AUTH_WPA2_PSK, + WIFI_AUTH_WPA_WPA2_PSK, WIFI_AUTH_ENTERPRISE, WIFI_AUTH_WPA3_PSK, WIFI_AUTH_WPA2_WPA3_PSK, +} wifi_auth_mode_t; +typedef struct { int8_t rssi; wifi_auth_mode_t authmode; } wifi_scan_threshold_t; +typedef struct { bool capable; bool required; } wifi_pmf_config_t; +typedef struct { + uint8_t ssid[32]; + uint8_t password[64]; + wifi_scan_method_t scan_method; + bool bssid_set; + uint8_t bssid[6]; + uint8_t channel; + uint16_t listen_interval; + wifi_sort_method_t sort_method; + wifi_scan_threshold_t threshold; + wifi_pmf_config_t pmf_cfg; + uint8_t failure_retry_cnt; +} wifi_sta_config_t; +typedef union { wifi_sta_config_t sta; } wifi_config_t; +typedef enum { WIFI_IF_STA = 0 } wifi_interface_t; +typedef struct { + uint8_t bssid[6]; + uint8_t ssid[33]; + uint8_t primary; + int8_t rssi; + wifi_auth_mode_t authmode; +} wifi_ap_record_t; +typedef struct { + uint8_t ssid[33]; + uint8_t ssid_len; + uint8_t bssid[6]; + uint8_t reason; + int8_t rssi; +} wifi_event_sta_disconnected_t; +enum { WIFI_EVENT_STA_START, WIFI_EVENT_STA_CONNECTED, WIFI_EVENT_STA_DISCONNECTED }; + +#if __has_include("radio_boot.h") +#include "radio_boot.h" // the U64 and U2+L modules' restart record +#define MODULE_HAS_SWITCH 1 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// What the modules define themselves (the extracted code uses them; module_stubs.c has them) +extern const char *TAG; +extern volatile bool user_disconnected; +extern volatile bool off_asked; +extern uint16_t connected_g, disabled_g, ap_count; +extern ConnectCommand_t last_connect; +extern wifi_ap_record_t ap_info[DEFAULT_SCAN_LIST_SIZE]; +extern QueueHandle_t connect_events, connect_commands; +extern SemaphoreHandle_t connect_semaphore; +extern int wake_machine_on; // u64ctrl +void wake_on_wifi_update(int machine_on); +void wifi_note_identify(void); +#ifdef MODULE_HAS_SWITCH +extern radio_record_t radio_record; +extern radio_boot_t boot_mode; +#endif + +// ESP-IDF, the radio and the UART +esp_err_t esp_wifi_start(void); +esp_err_t esp_wifi_stop(void); +esp_err_t esp_wifi_disconnect(void); +esp_err_t esp_wifi_connect(void); +esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf); +int radio_start(void); +int radio_stop(void); +int my_uart_get_buffer(int uart, command_buf_t **buf, int ticks); +BaseType_t my_uart_transmit_packet(uint8_t uart_num, command_buf_t *buf); + +// The rest of wifi_modem.c that the connector calls but this test does not cut out +esp_err_t wifi_connect_to_last(void); +esp_err_t wifi_connect_to_scanned(int index); +esp_err_t wifi_connect_to_stored(int index); +esp_err_t wifi_connect_to_hotspot(void); +esp_err_t wifi_store_ap(ConnectCommand_t *cmd); +esp_err_t wifi_set_last_ap(int index); +esp_err_t wifi_find_password(const uint8_t *ssid, char *pw, size_t maxlen, int16_t *list_idx); +void wifi_list_aps(void); +bool recovery_running(void); +uint8_t wifi_get_connection(void); +#ifdef __cplusplus +} +#endif + +#endif /* MODULE_ENV_H_ */ diff --git a/software/wifi/tests/module_script.h b/software/wifi/tests/module_script.h new file mode 100644 index 000000000..d1d2ed343 --- /dev/null +++ b/software/wifi/tests/module_script.h @@ -0,0 +1,87 @@ +/* + * module_script.h + * + * The scripted world of module_stubs.c as the cases (C++) see it: run the connector with a + * list of commands, then look at the trace of what it did and why it stopped. Trace + * letters: L connect to the last AP, S scan, c connect to a scanned AP, s connect to a + * stored AP, P radio stopped, T radio started, t a radio start that failed (start_fails), + * D disconnect, X EVENT_DISABLED sent, Z EVENT_DISCONNECTED sent, Y EVENT_RESTARTED sent, + * R reply sent, K the AP associated (a connect event). + */ + +#ifndef MODULE_SCRIPT_H_ +#define MODULE_SCRIPT_H_ + +#include "module_env.h" +#ifdef __cplusplus +#include "host_test/host_test.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern char trace[256]; +extern const char *ended; +extern int stale_disabled; // EVENT_DISCONNECTED sent while disabled_g still said off +extern bool last_ap_reachable; // the next run's connect to the last AP succeeds (false again + // after each run); every other connect attempt fails +extern int start_fails; // the next radio_start() calls fail; 0 again after each run +extern int retry_timeouts; // the next idle waits with a timeout run out, one each (the retry timer); 0 again after each run +extern int recorded; // the last radio_record_set() of a run (1 on, 0 off, -1 none) + +// In a command list: not a command for the connector, but ... +#define CONNECTOR_ASK 0xFE // the Ultimate asking for the connection state (cmd_get_connection) +#define CONNECTOR_SEND_DISABLE 0xFD // CMD_WIFI_DISABLE through the dispatcher (cmd_wifi_endisable) +#define CONNECTOR_SEND_ENABLE 0xFC // CMD_WIFI_ENABLE through the dispatcher +#define CONNECTOR_IDENTIFY 0xFB // CMD_IDENTIFY through the dispatcher (cmd_identify) + +// Runs connect_thread() from its first state until it waits for something the script does +// not give it. aps_found is what a scan finds; disconnected_before stands for an explicit +// Disconnect from the user before the commands; the commands are taken one by one wherever +// the connector looks for one. +void run_with(int aps_found, bool disconnected_before, const uint8_t *commands, int n); +void run(bool disconnected_before, const uint8_t *commands, int n); + +// The trace after the first occurrence of c +const char *after(char c); + +// The scripted air and the dispatcher, for the AP selection cases +#define AIR_MAX 16 +typedef struct { + uint8_t ssid[33]; + uint8_t bssid[6]; + uint8_t channel; + int8_t rssi; + wifi_auth_mode_t auth; +} air_ap_t; +extern air_ap_t air[AIR_MAX]; +extern wifi_config_t last_config; // the last station config set +extern int joined; // index into air[] of the AP that config made the station join, -1 none +extern ConnectCommand_t queued; // the last command the dispatcher queued for the connector +extern int queued_count; +extern int transmitted; // packets sent to the Ultimate +void air_reset(void); +int air_add(const char *ssid, uint8_t last_bssid_byte, uint8_t channel, int8_t rssi, wifi_auth_mode_t auth); +void air_to_scan_list(const int *order, int n); + +// The Ultimate's packets the module sent on its own (events) +extern command_buf_t sent; +extern int sent_n; + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +// A check that evaluates its condition once, and prints the trace of the run when it fails +#define CHECK(cond, what) do { \ + bool check_ok_ = (cond); \ + if (!check_ok_) { \ + fprintf(stderr, " check \"%s\" (%s), trace \"%s\", ended: %s\n", what, #cond, trace, ended); \ + } \ + EXPECT_TRUE(check_ok_); \ +} while (0) +#endif + +#endif /* MODULE_SCRIPT_H_ */ diff --git a/software/wifi/tests/module_stubs.c b/software/wifi/tests/module_stubs.c new file mode 100644 index 000000000..da0f9ad2c --- /dev/null +++ b/software/wifi/tests/module_stubs.c @@ -0,0 +1,416 @@ +/* + * module_stubs.c + * + * Scripted stand-ins for everything the WiFi modules' connector, dispatcher and event + * handler call, and a model of how the IDF station chooses an access point in + * esp_wifi_connect(). Makefile includes this file at the end of the module's extracted + * code (output//module_code.c), so that it can reach the static functions there. + * See module_script.h for what the cases get. + * + * The station model follows the station config table of ESP-IDF 5.3.1 + * (docs/en/api-guides/wifi.rst, "Station Basic Configuration"): + * - The scan visits the config's channel first when it is 1..13, then channels 1..13 + * without it; without a channel, 1..13 in order. + * - WIFI_FAST_SCAN: the scan ends at the first AP whose SSID (and BSSID, if bssid_set) + * matches and that passes the threshold; that is the one joined. + * - WIFI_ALL_CHANNEL_SCAN: every channel is scanned and the matching APs are sorted, by + * RSSI (WIFI_CONNECT_AP_BY_SIGNAL) or by security (WIFI_CONNECT_AP_BY_SECURITY); the + * first after sorting is joined. + * - threshold.rssi 0 means -127; an AP whose auth mode is below threshold.authmode is + * skipped. + */ + +#include +#include "module_script.h" + +// What the extracted code refers to +const char *TAG = "test"; +volatile bool user_disconnected; +volatile bool off_asked; // the U64 and U2+L modules: a Disable since the last CMD_IDENTIFY +uint16_t connected_g, disabled_g, ap_count; +wifi_ap_record_t ap_info[DEFAULT_SCAN_LIST_SIZE]; +ConnectCommand_t last_connect; +int wake_machine_on; +void wake_on_wifi_update(int machine_on) { } +static int commands_tag, events_tag, semaphore_tag; +QueueHandle_t connect_commands = &commands_tag; +QueueHandle_t connect_events = &events_tag; +SemaphoreHandle_t connect_semaphore = &semaphore_tag; +#ifdef MODULE_HAS_SWITCH +radio_record_t radio_record; +radio_boot_t boot_mode; // RADIO_BOOT_WAIT unless a case sets it; again after each run +int recorded = -1; // the last radio_record_set(): 1 on, 0 off, -1 none in this run +void radio_record_set(radio_record_t *rec, bool on) { recorded = on; } +#else +int recorded = -1; +// The control module has no such call +void wifi_note_identify(void) { } +#endif + +// The script +static ConnectCommand_t script[8]; +static int script_n, script_i; +static command_buf_t reply_buf, request_buf, event_buf; +command_buf_t sent; +int sent_n; +int transmitted; +char trace[256]; +const char *ended; +static jmp_buf done; +static int calls; +static int scanned = 3; // APs the scan finds +static uint8_t pending_event; +bool last_ap_reachable; +int start_fails; +int retry_timeouts; // the next idle waits with a timeout that run out, once each; 0 again after each run +int stale_disabled; +ConnectCommand_t queued; +int queued_count; + +static void note(char c) +{ + size_t n = strlen(trace); + if (n + 1 < sizeof(trace)) { + trace[n] = c; + trace[n + 1] = 0; + } +} + +static void stop(const char *why) +{ + ended = why; + longjmp(done, 1); +} + +BaseType_t xQueueReceive(QueueHandle_t q, void *item, TickType_t wait) +{ + if (++calls > 2000) { + stop("runaway"); + } + if (q == connect_commands) { + // A step of the script that is the Ultimate talking to the dispatcher: it answers + // now, while the connector goes on with its commands + while ((script_i < script_n) && (script[script_i].command >= CONNECTOR_IDENTIFY)) { + uint8_t step = script[script_i++].command; + memset(&request_buf, 0, sizeof(request_buf)); + if (step == CONNECTOR_ASK) { + cmd_get_connection(&reply_buf); + } else if (step == CONNECTOR_IDENTIFY) { + cmd_identify(&request_buf); + } else { + ((rpc_header_t *)request_buf.data)->command = (step == CONNECTOR_SEND_DISABLE) ? CMD_WIFI_DISABLE : CMD_WIFI_ENABLE; + cmd_wifi_endisable(&request_buf); + } + } + if (script_i < script_n) { + *(ConnectCommand_t *)item = script[script_i++]; + return pdTRUE; + } + if (wait == portMAX_DELAY) { + stop("waiting for a command"); + } + return pdFALSE; + } + // An event the stubs made happen: the association to a reachable AP, and the + // disconnect that follows esp_wifi_disconnect() or a connect that found no AP + if (pending_event) { + ((ConnectEvent_t *)item)->event_code = pending_event; + connected_g = (pending_event == EVENT_CONNECTED); + if (connected_g) { + note('K'); + } + pending_event = 0; + return pdTRUE; + } + if (wait == portMAX_DELAY) { + stop("waiting for an event"); // no other connect attempt succeeds + } + return pdFALSE; +} + +BaseType_t xQueueSend(QueueHandle_t q, const void *item, TickType_t wait) +{ + if (q != connect_commands) { + return pdTRUE; // connect_events: the event handler's copy, nobody reads it + } + queued = *(const ConnectCommand_t *)item; + queued_count++; + if (script_n >= (int)(sizeof(script) / sizeof(script[0]))) { + return pdFALSE; + } + script[script_n++] = queued; + return pdTRUE; +} + +BaseType_t xSemaphoreGive(SemaphoreHandle_t s) +{ + return pdTRUE; +} + +BaseType_t xSemaphoreTake(SemaphoreHandle_t s, TickType_t wait) +{ + if (script_i < script_n) { + return pdTRUE; + } + if ((wait != portMAX_DELAY) && (retry_timeouts > 0)) { + retry_timeouts--; + return pdFALSE; // the retry timer ran out + } + stop((wait == portMAX_DELAY) ? "idle without a timeout" : "idle until the retry timer"); + return pdFALSE; +} + +// The radio and the UART +#ifdef MODULE_HAS_SWITCH +// The U64 and U2+L modules start and stop the radio through radio_start() and radio_stop() +// (wifi/common) and nowhere else: a direct call fails and leaves a trace letter +esp_err_t esp_wifi_start(void) { note('!'); return ESP_FAIL; } +esp_err_t esp_wifi_stop(void) { note('!'); return ESP_FAIL; } +#else +esp_err_t esp_wifi_start(void) { note('T'); return ESP_OK; } +esp_err_t esp_wifi_stop(void) { note('P'); return ESP_OK; } +#endif +esp_err_t esp_wifi_disconnect(void) { note('D'); pending_event = EVENT_DISCONNECTED; return ESP_OK; } +int radio_start(void) +{ + if (start_fails > 0) { + start_fails--; + note('t'); + return ESP_FAIL; + } + note('T'); + return ESP_OK; +} +int radio_stop(void) { note('P'); return ESP_OK; } + +int my_uart_get_buffer(int uart, command_buf_t **buf, int ticks) +{ + memset(&event_buf, 0xEE, sizeof(event_buf)); // what a reused buffer holds + *buf = &event_buf; + return 1; +} + +BaseType_t my_uart_transmit_packet(uint8_t uart_num, command_buf_t *buf) +{ + if (buf != &event_buf) { + transmitted++; + if ((buf == &reply_buf) || (buf == &request_buf)) { + note('R'); + } + return pdTRUE; + } + sent = *buf; + sent_n++; + if (buf->data[0] == EVENT_DISABLED) { + note('X'); +#ifdef EVENT_RESTARTED + } else if (buf->data[0] == EVENT_RESTARTED) { + note('Y'); +#endif + } else if (buf->data[0] == EVENT_DISCONNECTED) { + note('Z'); + if (disabled_g) { + stale_disabled++; + } + } + return pdTRUE; +} + +// The connector's walks: the last AP and the stored ones are scripted, the scanned ones +// are tried through the real wifi_connect_to_scanned() and attempt_connect() +esp_err_t wifi_connect_to_last(void) +{ + note('L'); + if (!last_ap_reachable) { + return ESP_FAIL; + } + last_ap_reachable = false; + pending_event = EVENT_CONNECTED; + return ESP_OK; +} +esp_err_t wifi_connect_to_stored(int index) { note('s'); return ESP_FAIL; } +esp_err_t wifi_connect_to_hotspot(void) { return ESP_FAIL; } +esp_err_t wifi_store_ap(ConnectCommand_t *cmd) { cmd->list_index = 0; return ESP_OK; } +esp_err_t wifi_set_last_ap(int index) { return ESP_OK; } +esp_err_t wifi_scan(ultimate_ap_records_t *rec) { note('S'); return ESP_OK; } +void wifi_list_aps(void) +{ + memset(ap_info, 0, sizeof(ap_info)); + ap_count = scanned; + for (int i = 0; i < scanned; i++) { + snprintf((char *)ap_info[i].ssid, sizeof(ap_info[i].ssid), "net%d", i); + ap_info[i].authmode = WIFI_AUTH_WPA2_PSK; + } +} +bool recovery_running(void) { return false; } +uint8_t wifi_get_connection(void) { return (uint8_t)connected_g; } + +// Every SSID is known, with this password +esp_err_t wifi_find_password(const uint8_t *ssid, char *pw, size_t maxlen, int16_t *list_idx) +{ + strncpy(pw, "secret-pw", maxlen); + *list_idx = 0; + return ESP_OK; +} + +// The air +air_ap_t air[AIR_MAX]; +static int air_count; +wifi_config_t last_config; +int joined; + +void air_reset(void) +{ + memset(air, 0, sizeof(air)); + air_count = 0; + memset(&last_config, 0, sizeof(last_config)); + joined = -1; + connected_g = 0; + memset(&queued, 0, sizeof(queued)); + queued_count = 0; + transmitted = 0; + script_n = script_i = 0; + calls = 0; + memset(&last_connect, 0, sizeof(last_connect)); + memset(ap_info, 0, sizeof(ap_info)); + ap_count = 0; + pending_event = 0; +} + +int air_add(const char *ssid, uint8_t last_bssid_byte, uint8_t channel, int8_t rssi, wifi_auth_mode_t auth) +{ + air_ap_t *ap = &air[air_count]; + memset(ap, 0, sizeof(*ap)); + strncpy((char *)ap->ssid, ssid, 32); + const uint8_t bssid[6] = { 0x02, 0x00, 0x00, 0x00, 0x00, last_bssid_byte }; + memcpy(ap->bssid, bssid, 6); + ap->channel = channel; + ap->rssi = rssi; + ap->auth = auth; + return air_count++; +} + +// What the driver's own scan list would hold, in the order given +void air_to_scan_list(const int *order, int n) +{ + memset(ap_info, 0, sizeof(ap_info)); + for (int i = 0; i < n; i++) { + const air_ap_t *ap = &air[order[i]]; + memcpy(ap_info[i].bssid, ap->bssid, 6); + memcpy(ap_info[i].ssid, ap->ssid, 32); + ap_info[i].primary = ap->channel; + ap_info[i].rssi = ap->rssi; + ap_info[i].authmode = ap->auth; + } + ap_count = n; +} + +static int matches(const wifi_sta_config_t *sta, const air_ap_t *ap) +{ + int8_t min_rssi = sta->threshold.rssi ? sta->threshold.rssi : -127; + if (strncmp((const char *)sta->ssid, (const char *)ap->ssid, 32) != 0) { + return 0; + } + if (sta->bssid_set && memcmp(sta->bssid, ap->bssid, 6) != 0) { + return 0; + } + return (ap->rssi >= min_rssi) && (ap->auth >= sta->threshold.authmode); +} + +// Is a better than b for this sort method; on a tie, scan order decides +static int better(const wifi_sta_config_t *sta, const air_ap_t *a, const air_ap_t *b) +{ + if (sta->sort_method == WIFI_CONNECT_AP_BY_SECURITY && a->auth != b->auth) { + return a->auth > b->auth; + } + return a->rssi > b->rssi; +} + +static int pick(const wifi_sta_config_t *sta) +{ + int order[14]; + int n = 0; + if ((sta->channel >= 1) && (sta->channel <= 13)) { + order[n++] = sta->channel; + } + for (int ch = 1; ch <= 13; ch++) { + if (ch != sta->channel) { + order[n++] = ch; + } + } + int best = -1; + for (int c = 0; c < n; c++) { + for (int i = 0; i < air_count; i++) { + if ((air[i].channel != order[c]) || !matches(sta, &air[i])) { + continue; + } + if (sta->scan_method == WIFI_FAST_SCAN) { + return i; + } + if ((best < 0) || better(sta, &air[i], &air[best])) { + best = i; + } + } + } + return best; +} + +esp_err_t esp_wifi_set_config(wifi_interface_t interface, wifi_config_t *conf) +{ + last_config = *conf; + return ESP_OK; +} + +// The connect is accepted; the outcome comes as an event +esp_err_t esp_wifi_connect(void) +{ + note('c'); + joined = pick(&last_config.sta); + pending_event = (joined >= 0) ? EVENT_CONNECTED : EVENT_DISCONNECTED; + return ESP_OK; +} + +void run_with(int aps_found, bool disconnected_before, const uint8_t *commands, int n) +{ + scanned = aps_found; + air_reset(); + memset(script, 0, sizeof(script)); + for (int i = 0; i < n; i++) { + script[i].command = commands[i]; + script[i].buf = &reply_buf; + } + script_n = n; + trace[0] = 0; + ended = ""; + calls = 0; + connected_g = ap_count = 0; + disabled_g = 0; +#ifdef MODULE_HAS_SWITCH + disabled_g = 1; // as the module starts: radio off, until the Ultimate asks for it + recorded = -1; +#endif + stale_disabled = 0; + sent_n = 0; + user_disconnected = disconnected_before; + off_asked = false; + if (setjmp(done) == 0) { + connect_thread(NULL); + } + last_ap_reachable = false; + start_fails = 0; + retry_timeouts = 0; +#ifdef MODULE_HAS_SWITCH + boot_mode = RADIO_BOOT_WAIT; +#endif +} + +void run(bool disconnected_before, const uint8_t *commands, int n) +{ + run_with(3, disconnected_before, commands, n); +} + +const char *after(char c) +{ + const char *p = strchr(trace, c); + return p ? p + 1 : ""; +} diff --git a/software/wifi/tests/module_switch_test.cpp b/software/wifi/tests/module_switch_test.cpp new file mode 100644 index 000000000..c4bc4d978 --- /dev/null +++ b/software/wifi/tests/module_switch_test.cpp @@ -0,0 +1,339 @@ +/* + * module_switch_test.cpp + * + * The radio switch in the connector of the U64 and U2+L modules (raw_u64, raw_c3), fix 1: + * the module starts with its radio off and waits for the Ultimate (or starts it for an + * Ultimate without the switch, which asks for the connection state first); a Disable stops + * the radio and leaves the connector waiting in Disabled, also when it is taken during the + * AP walks; an Enable starts it again and reconnects, also after an explicit Disconnect + * before the Disable; an Autoconnect taken during the walks starts over; and the replay of + * EVENT_DISABLED for a starting WiFi application stays in order with Disable and Enable. + * The Elite II / C64 Ultimate module had its switch before: no case here is for it. Except + * in the boot cases, the first command is the Enable the Ultimate sends at boot with "WiFi + * Enabled" stored as Enabled. The cases run against the module's real dispatcher commands + * (cmd_wifi_endisable, cmd_get_connection, cmd_identify) and connector. + */ + +#include +#include "module_script.h" + +// The command numbers the radio switch added to or relies on are the same in the three +// rpc_calls.h (the application has its own copy of them), and the Wake-on-WiFi commands +// of the control module keep theirs: nothing the switch adds moves them. +static_assert(CMD_WIFI_IS_CONNECTED == 0x0B && CMD_WIFI_ENABLE == 0x0D && CMD_WIFI_DISABLE == 0x0E && + CMD_CLEAR_APS == 0x11 && CMD_WIFI_AUTOCONNECT == 0x12, "WiFi command numbers"); +static_assert(EVENT_DISABLED == 0x46, "EVENT_DISABLED"); +#ifdef MODULE_U64CTRL +static_assert(CMD_SET_WAKE_ON_WIFI == 0x18 && CMD_GET_WAKE_ON_WIFI == 0x19, "Wake-on-WiFi command numbers"); +#endif + +#ifdef MODULE_HAS_SWITCH + +// At boot the radio stays off, and nothing is tried, until the Ultimate asks +TEST(Switch, boot_radio_off) +{ + const uint8_t cmds[] = { 0 }; + run(false, cmds, 0); + CHECK(strpbrk(trace, "TLScs") == NULL, "no radio start, no scan, no connect attempt"); + CHECK(strcmp(ended, "waiting for a command") == 0, "waits in Disabled"); +} + +// "WiFi Enabled" stored as Disabled: the Ultimate's Disable keeps it off +TEST(Switch, boot_stored_disabled) +{ + const uint8_t cmds[] = { CONNECTOR_SEND_DISABLE }; + run(false, cmds, 1); + CHECK(strchr(trace, 'T') == NULL, "the radio never starts"); + CHECK(strchr(trace, 'X') != NULL, "EVENT_DISABLED confirms it"); + CHECK(strpbrk(trace, "LScs") == NULL, "no scan, no connect attempt"); + CHECK(strcmp(ended, "waiting for a command") == 0, "waits in Disabled"); +} + +// An Ultimate application without the radio switch asks for the connection state first +// and never sends Enable or Disable: the radio starts, as the module always did at boot +TEST(Switch, boot_old_application) +{ + const uint8_t cmds[] = { CONNECTOR_ASK }; + last_ap_reachable = true; + run(false, cmds, 1); + CHECK(strncmp(trace, "RTZLK", 5) == 0, "the answer, radio on, EVENT_DISCONNECTED, the last AP"); + CHECK(strchr(trace, 'X') == NULL, "no EVENT_DISABLED"); + CHECK(stale_disabled == 0, "disabled_g is cleared before EVENT_DISCONNECTED goes out"); +} + +// An application with the switch and "WiFi Enabled" stored as Disabled: its Disable comes +// first, so a later connection query (the confirmation deadline) does not start the radio +TEST(Switch, boot_new_application_disabled) +{ + const uint8_t cmds[] = { CONNECTOR_SEND_DISABLE, CONNECTOR_ASK }; + run(false, cmds, 2); + CHECK(strchr(trace, 'T') == NULL, "the radio never starts"); + CHECK(strstr(trace, "PXX") != NULL, "off and confirmed, then told again for the query"); + CHECK(strcmp(ended, "waiting for a command") == 0, "waits in Disabled"); +} + +// The same with "WiFi Enabled" stored as Enabled: Enable first, then the query +TEST(Switch, boot_new_application_enabled) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CONNECTOR_ASK }; + run(false, cmds, 2); + CHECK(strncmp(trace, "TZ", 2) == 0, "radio on at the Enable"); + CHECK(strchr(after('T'), 'T') == NULL, "started once"); + CHECK(strchr(trace, 'X') == NULL, "no EVENT_DISABLED"); +} + +// Stored as Enabled: the Ultimate's Enable, or an Autoconnect, starts the radio and walks +TEST(Switch, boot_enable_connects) +{ + const uint8_t enable[] = { CMD_WIFI_ENABLE }; + const uint8_t autoconnect[] = { CMD_WIFI_AUTOCONNECT }; + for (int i = 0; i < 2; i++) { + last_ap_reachable = true; + run(false, i ? autoconnect : enable, 1); + CHECK(strncmp(trace, "TZLK", 4) == 0, "radio on, EVENT_DISCONNECTED, then the last AP"); + CHECK(stale_disabled == 0, "disabled_g is cleared before EVENT_DISCONNECTED goes out"); + } +} + +// A Scan at boot is refused like any Scan while Disabled, and it does not count as an +// Ultimate that knows the switch: an old application's connection query after it still +// starts the radio +TEST(Switch, boot_scan_refused) +{ + const uint8_t cmds[] = { CMD_WIFI_SCAN, CONNECTOR_ASK }; + run(false, cmds, 1); + CHECK(strpbrk(trace, "TS") == NULL, "no radio start and no scan"); + run(false, cmds, 2); + CHECK(strpbrk(trace, "S") == NULL || strchr(trace, 'S') > strchr(trace, 'T'), "the refused scan does not scan"); + CHECK(strchr(trace, 'T') != NULL, "the old application's query then starts the radio"); +} + +// The scan of an old application (opening the AP list) comes after its connection query, +// so it finds the radio on; with the switch and "WiFi Enabled" stored as Disabled a scan +// after the Disable neither scans nor starts the radio +TEST(Switch, boot_scans) +{ + // the connection query as the dispatcher queues it (before the application sends its + // scan, which it does only once it has the answer) + const uint8_t old_app[] = { CMD_WIFI_IS_CONNECTED, CMD_WIFI_SCAN }; + const uint8_t stored_off[] = { CONNECTOR_SEND_DISABLE, CMD_WIFI_SCAN }; + run_with(3, true, old_app, 2); // settles at once, so the scan is taken while idle + CHECK(strncmp(trace, "TZS", 3) == 0, "radio on, then the scan"); + run(false, stored_off, 2); + CHECK(strpbrk(trace, "TS") == NULL, "no radio start and no scan"); +} + +// A restart of the module's own (radio_boot.h) with the radio on before it: the radio +// goes on again and the connector walks, as before; the Ultimate is told it restarted, +// and its connection query afterwards does not start the radio a second time +TEST(Switch, restart_with_the_radio_on) +{ + const uint8_t cmds[] = { CONNECTOR_ASK }; + boot_mode = RADIO_BOOT_ON; + last_ap_reachable = true; + run(false, cmds, 1); + CHECK(strncmp(trace, "YTZLK", 5) == 0, "EVENT_RESTARTED, radio on, EVENT_DISCONNECTED, the last AP"); + CHECK(strchr(after('T'), 'T') == NULL, "started once"); + CHECK(recorded == 1, "the record says on"); + CHECK(stale_disabled == 0, "disabled_g is cleared before EVENT_DISCONNECTED goes out"); +} + +// The same with the radio off before it: it stays off, and the connection query that +// follows does not count as an Ultimate without the switch +TEST(Switch, restart_with_the_radio_off) +{ + const uint8_t cmds[] = { CONNECTOR_ASK }; + boot_mode = RADIO_BOOT_OFF; + run(false, cmds, 1); + CHECK(trace[0] == 'Y', "EVENT_RESTARTED"); + CHECK(strchr(trace, 'T') == NULL, "the radio stays off"); + CHECK(strchr(after('R'), 'X') != NULL, "and the query is told Disabled"); + CHECK(strcmp(ended, "waiting for a command") == 0, "waits in Disabled"); +} + +// The record follows every radio start and stop +TEST(Switch, record_follows_the_radio) +{ + const uint8_t enable[] = { CMD_WIFI_ENABLE }; + const uint8_t disable[] = { CMD_WIFI_ENABLE, CMD_WIFI_DISABLE }; + const uint8_t old_app[] = { CONNECTOR_ASK }; + const uint8_t autoconnect[] = { CMD_WIFI_AUTOCONNECT }; + run(false, enable, 1); + CHECK(recorded == 1, "on after an Enable"); + run(false, disable, 2); + CHECK(recorded == 0, "off after a Disable"); + run(false, old_app, 1); + CHECK(recorded == 1, "on after an old application's query"); + run(false, autoconnect, 1); + CHECK(recorded == 1, "on after an Autoconnect"); + run(false, disable + 1, 1); + CHECK(recorded == 0, "off after a Disable at boot"); +} + +// A request for the radio on whose start fails (Enable, Autoconnect, Connect, or an old +// application's query) does not count as a Disable: the next connection query tries the +// start again, because the radio was asked for on +TEST(Switch, failed_start_then_query) +{ + const uint8_t requests[] = { CMD_WIFI_ENABLE, CMD_WIFI_AUTOCONNECT, CMD_WIFI_CONNECT, CMD_WIFI_IS_CONNECTED }; + for (int i = 0; i < 4; i++) { + const uint8_t cmds[] = { requests[i], CMD_WIFI_IS_CONNECTED }; + start_fails = 1; + run(false, cmds, 2); + CHECK(trace[0] == 't', "the first start fails"); + CHECK(strchr(trace, 'T') != NULL, "the query starts the radio after all"); + } +} + +// An Ultimate application that starts afresh (it identifies the module) after another one +// asked for the radio off: an application without the switch gets its radio +TEST(Switch, identify_after_a_disable) +{ + // the Disable as the connector takes it, long before the next application starts + const uint8_t old_app_after[] = { CMD_WIFI_DISABLE, CONNECTOR_IDENTIFY, CONNECTOR_ASK }; + run(false, old_app_after, 3); + CHECK(strchr(after('P'), 'T') != NULL, "the old application's query starts the radio"); +} + +// Settled and disconnected, as after a failed boot ladder, then Disable +TEST(Switch, disable_stops_the_radio) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CONNECTOR_SEND_DISABLE }; // as the Ultimate sends it + run_with(0, false, cmds, 2); + CHECK(strstr(trace, "RPX") != NULL, "answered, then the radio is stopped and EVENT_DISABLED sent"); + CHECK(strpbrk(after('P'), "LcsT") == NULL, "nothing else with the radio off"); + CHECK(strcmp(ended, "waiting for a command") == 0, "waits in Disabled"); +} + +// Taken during the walk over the scanned APs, and over the stored ones (a scan that finds +// nothing goes straight there) +TEST(Switch, disable_in_the_walks) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CMD_WIFI_DISABLE }; + for (int found = 3; found >= 0; found -= 3) { + run_with(found, false, cmds, 2); + CHECK(strstr(trace, "PX") != NULL, "the radio is stopped and EVENT_DISABLED sent"); + CHECK(strpbrk(after('P'), "Lcs") == NULL, "no connect attempt with the radio off"); + CHECK(strcmp(ended, "waiting for a command") == 0, "waits in Disabled"); + } +} + +TEST(Switch, disable_in_the_walk_then_enable) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CMD_WIFI_DISABLE, CMD_WIFI_ENABLE }; + run_with(3, false, cmds, 3); + CHECK(strstr(trace, "PX") != NULL, "the radio is stopped"); + CHECK(strchr(after('P'), 'T') != NULL, "the Enable is taken and starts it"); + CHECK(strchr(after('T'), 'L') != NULL, "then the connector tries the last AP"); +} + +TEST(Switch, autoconnect_in_the_walks) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CMD_WIFI_AUTOCONNECT }; + for (int found = 3; found >= 0; found -= 3) { + run_with(found, false, cmds, 2); + CHECK(after('S')[0] == 'L', "the next attempt after the Autoconnect is the last AP"); + } +} + +// A WiFi application that starts while the radio is off is told so +TEST(Switch, replay_while_disabled) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CMD_WIFI_DISABLE, CONNECTOR_ASK }; + run(false, cmds, 3); + CHECK(strstr(trace, "PXRX") != NULL, "the answer, then EVENT_DISABLED again"); + CHECK(strcmp(ended, "waiting for a command") == 0, "still Disabled"); +} + +TEST(Switch, no_replay_while_on) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CONNECTOR_ASK }; + run(false, cmds, 2); + CHECK((strchr(trace, 'R') != NULL) && (strchr(trace, 'X') == NULL), "an answer, no EVENT_DISABLED"); +} + +// Asked while off, with an Enable queued already: the replay goes out after the Enable and +// so is not sent at all; it never follows the EVENT_DISCONNECTED of the radio start +TEST(Switch, replay_in_order_with_an_enable) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CMD_WIFI_DISABLE, CONNECTOR_ASK, CMD_WIFI_ENABLE }; + run(false, cmds, 4); + const char *on = strstr(trace, "PXRTZ"); + CHECK(on != NULL, "off, the answer, on"); + CHECK((on != NULL) && (strchr(on + 5, 'X') == NULL), "no EVENT_DISABLED after the radio came on"); + CHECK(stale_disabled == 0, "disabled_g is cleared before EVENT_DISCONNECTED goes out"); +} + +// Disabled means the radio is off: a Scan is refused and does not turn it on +TEST(Switch, scan_refused_while_disabled) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CMD_WIFI_DISABLE, CMD_WIFI_SCAN }; + run(false, cmds, 3); + CHECK(strstr(trace, "PX") != NULL, "the radio is stopped"); + CHECK(strpbrk(after('P'), "TS") == NULL, "no radio start and no scan"); + CHECK(strcmp(ended, "waiting for a command") == 0, "still Disabled"); +} + +// A Connect from Disabled starts the radio; when the attempt fails, the connector goes on +// as after a dropped link (retry timer), not parked in Disabled with the radio on +TEST(Switch, failed_connect_from_disabled) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CMD_WIFI_DISABLE, CMD_WIFI_CONNECT }; + run(false, cmds, 3); + CHECK(strstr(trace, "PXTZ") != NULL, "off, then on with EVENT_DISCONNECTED"); + CHECK(stale_disabled == 0, "disabled_g is cleared before EVENT_DISCONNECTED goes out"); + CHECK(strcmp(ended, "idle until the retry timer") == 0, "it retries, it is not parked in Disabled"); +} + +// An Autoconnect from Disabled starts the radio and walks the ladder +TEST(Switch, autoconnect_from_disabled) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CMD_WIFI_DISABLE, CMD_WIFI_AUTOCONNECT }; + run(false, cmds, 3); + CHECK(strstr(trace, "PXTZ") != NULL, "off, then on with EVENT_DISCONNECTED"); + CHECK(strchr(after('T'), 'L') != NULL, "then the last AP"); + CHECK(stale_disabled == 0, "disabled_g is cleared before EVENT_DISCONNECTED goes out"); +} + +// A Disable while Connected disconnects first, then stops the radio +TEST(Switch, disable_while_connected) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CMD_WIFI_DISABLE }; + last_ap_reachable = true; + run(false, cmds, 2); + CHECK(strncmp(trace, "TZLK", 4) == 0, "connected at once"); + CHECK(strstr(trace, "DPX") != NULL, "disconnect, then radio off, then EVENT_DISABLED"); + CHECK(strcmp(ended, "waiting for a command") == 0, "waits in Disabled"); +} + +// Disabled with an explicit Disconnect still on record (as after Disconnect, Disable) +TEST(Switch, enable_after_disconnect_and_disable) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE }; + run(true, cmds, 1); + CHECK(trace[0] == 'T', "the radio is started"); + CHECK(strchr(after('T'), 'L') != NULL, "then the connector tries the last AP"); + CHECK(strcmp(ended, "idle without a timeout") != 0, "it does not idle for good"); +} + +// An Enable with the radio on does nothing: it does not start it a second time +TEST(Switch, enable_while_on_does_nothing) +{ + const uint8_t cmds[] = { CMD_WIFI_ENABLE, CMD_WIFI_ENABLE }; + run(false, cmds, 2); + CHECK(strchr(after('T'), 'T') == NULL, "the radio is started once"); +} + +// The first CMD_IDENTIFY of an Ultimate application clears what a Disable of an earlier one +// left, through the module's own cmd_identify (not a call of wifi_note_identify here) +TEST(Switch, identify_clears_off_asked) +{ + const uint8_t cmds[] = { CMD_WIFI_DISABLE }; + run(false, cmds, 1); + EXPECT_TRUE(off_asked); + const uint8_t after_identify[] = { CMD_WIFI_DISABLE, CONNECTOR_IDENTIFY }; + run(false, after_identify, 2); + EXPECT_FALSE(off_asked); +} + +#endif /* MODULE_HAS_SWITCH */ diff --git a/software/wifi/tests/radio_test.cpp b/software/wifi/tests/radio_test.cpp new file mode 100644 index 000000000..87367c71a --- /dev/null +++ b/software/wifi/tests/radio_test.cpp @@ -0,0 +1,139 @@ +/* + * radio_test.cpp + * + * wifi_radio.c (the one place that starts and stops the radio of the U64 and U2+L modules) + * against a chip stub that counts the Wi-Fi starts and stops and can be told to fail them, + * and radio_boot.c (the radio's state across a restart of the module). + */ + +#include +#include "host_test/host_test.h" +extern "C" { +#include "wifi_radio.h" +#include "wifi_radio_port.h" +#include "radio_boot.h" +} + +#define CHECK(cond, what) EXPECT_TRUE((cond) && (what)) + +#define ESP_FAIL_CODE 0x101 // any esp_err_t other than 0 + +static int starts, stops; +static int start_result, stop_result; +static int chip_on; // what the chip does, as opposed to what wifi_radio.c believes + +extern "C" int wr_port_wifi_start(void) +{ + starts++; + if (start_result == 0) { + chip_on = 1; + } + return start_result; +} + +extern "C" int wr_port_wifi_stop(void) +{ + stops++; + if (stop_result == 0) { + chip_on = 0; + } + return stop_result; +} + +// Each case starts with the radio off and the stub counting from zero +static void reset(void) +{ + start_result = stop_result = 0; + radio_stop(); + starts = stops = 0; + chip_on = 0; +} + +TEST(Radio, starts_once) +{ + reset(); + CHECK(!radio_is_on(), "off to begin with"); + CHECK(radio_start() == 0, "start"); + CHECK(radio_is_on() && chip_on, "on"); + CHECK(radio_start() == 0, "a second start is not an error"); + CHECK(starts == 1, "the chip is started once"); +} + +TEST(Radio, stops_once) +{ + reset(); + radio_start(); + CHECK(radio_stop() == 0, "stop"); + CHECK(!radio_is_on() && !chip_on, "off"); + CHECK(radio_stop() == 0, "a second stop is not an error"); + CHECK(stops == 1, "the chip is stopped once"); +} + +TEST(Radio, stop_when_off_does_nothing) +{ + reset(); + CHECK(radio_stop() == 0, "stop while off"); + CHECK(stops == 0 && starts == 0, "the chip is not touched"); +} + +TEST(Radio, failed_start_stays_off) +{ + reset(); + start_result = ESP_FAIL_CODE; + CHECK(radio_start() == ESP_FAIL_CODE, "the error is passed on"); + CHECK(!radio_is_on(), "still off"); + start_result = 0; + CHECK(radio_start() == 0, "a later start is tried again"); + CHECK(starts == 2 && radio_is_on(), "and works"); +} + +TEST(Radio, failed_stop_stays_on) +{ + reset(); + radio_start(); + stop_result = ESP_FAIL_CODE; + CHECK(radio_stop() == ESP_FAIL_CODE, "the error is passed on"); + CHECK(radio_is_on() && chip_on, "still on"); + stop_result = 0; + CHECK(radio_stop() == 0, "a later stop is tried again"); + CHECK(stops == 2 && !radio_is_on(), "and works"); +} + +TEST(Radio, off_and_on_again) +{ + reset(); + for (int i = 0; i < 100; i++) { + CHECK(radio_start() == 0, "start"); + CHECK(radio_stop() == 0, "stop"); + } + CHECK(starts == 100 && stops == 100, "one chip call per change"); + CHECK(!radio_is_on() && !chip_on, "ends off"); +} + +// radio_boot.c: after a power-up or a reset by the Ultimate the radio waits, whatever the +// record says; after a restart of its own the record decides, and one that does not check +// out counts as none (radio on) +TEST(Radio, boot_decisions) +{ + radio_record_t on, off, rec; + radio_record_set(&on, true); + radio_record_set(&off, false); + CHECK(radio_boot_decision(false, &on) == RADIO_BOOT_WAIT, "power-up, record on: wait"); + CHECK(radio_boot_decision(false, &off) == RADIO_BOOT_WAIT, "power-up, record off: wait"); + CHECK(radio_boot_decision(true, &on) == RADIO_BOOT_ON, "own restart, record on: on"); + CHECK(radio_boot_decision(true, &off) == RADIO_BOOT_OFF, "own restart, record off: off"); + rec = off; rec.magic ^= 1; + CHECK(radio_boot_decision(true, &rec) == RADIO_BOOT_ON, "a wrong magic is no record"); + rec = off; rec.magic = 0x12345678u; rec.check = ~(rec.magic ^ rec.state); + CHECK(radio_boot_decision(true, &rec) == RADIO_BOOT_ON, "another magic with a matching check is no record"); + rec = off; rec.check ^= 0x100; + CHECK(radio_boot_decision(true, &rec) == RADIO_BOOT_ON, "a wrong check is no record"); + rec = on; rec.state = RADIO_RECORD_OFF; + CHECK(radio_boot_decision(true, &rec) == RADIO_BOOT_ON, "a state that does not match its check"); + rec.magic = RADIO_RECORD_MAGIC; rec.state = 0x12345678u; rec.check = ~(RADIO_RECORD_MAGIC ^ rec.state); + CHECK(radio_boot_decision(true, &rec) == RADIO_BOOT_ON, "a state that is neither on nor off"); + rec.magic = 0xFFFFFFFFu; rec.state = 0xFFFFFFFFu; rec.check = 0xFFFFFFFFu; + CHECK(radio_boot_decision(true, &rec) == RADIO_BOOT_ON, "erased memory is no record"); + rec = on; radio_record_set(&rec, false); + CHECK(radio_boot_decision(true, &rec) == RADIO_BOOT_OFF, "rewritten from on to off"); +} diff --git a/software/wifi/tests/stub/freertos/FreeRTOS.h b/software/wifi/tests/stub/freertos/FreeRTOS.h new file mode 100644 index 000000000..f86eb657a --- /dev/null +++ b/software/wifi/tests/stub/freertos/FreeRTOS.h @@ -0,0 +1,24 @@ +// Stand-in for FreeRTOS on the build host: only what the WiFi modules' connector, cmd_buffer.h and +// the cases use. The queues and semaphores are the scripted ones of module_stubs.c. +#ifndef WIFI_TESTS_FREERTOS_H +#define WIFI_TESTS_FREERTOS_H +#include +typedef int BaseType_t; +typedef uint32_t TickType_t; +typedef void *QueueHandle_t; +typedef void *SemaphoreHandle_t; +#define pdTRUE 1 +#define pdFALSE 0 +#define portMAX_DELAY ((TickType_t)0xFFFFFFFFu) +#define pdMS_TO_TICKS(ms) ((TickType_t)(ms)) +#ifdef __cplusplus +extern "C" { +#endif +BaseType_t xQueueReceive(QueueHandle_t q, void *item, TickType_t wait); +BaseType_t xQueueSend(QueueHandle_t q, const void *item, TickType_t wait); +BaseType_t xSemaphoreTake(SemaphoreHandle_t s, TickType_t wait); +BaseType_t xSemaphoreGive(SemaphoreHandle_t s); +#ifdef __cplusplus +} +#endif +#endif diff --git a/software/wifi/tests/stub/freertos/queue.h b/software/wifi/tests/stub/freertos/queue.h new file mode 100644 index 000000000..4a5049cad --- /dev/null +++ b/software/wifi/tests/stub/freertos/queue.h @@ -0,0 +1 @@ +#include "FreeRTOS.h" diff --git a/software/wifi/tests/stub/lwip/netdb.h b/software/wifi/tests/stub/lwip/netdb.h new file mode 100644 index 000000000..864f089e4 --- /dev/null +++ b/software/wifi/tests/stub/lwip/netdb.h @@ -0,0 +1 @@ +#include "sockets.h" diff --git a/software/wifi/tests/stub/lwip/sockets.h b/software/wifi/tests/stub/lwip/sockets.h new file mode 100644 index 000000000..2b3461ec7 --- /dev/null +++ b/software/wifi/tests/stub/lwip/sockets.h @@ -0,0 +1,6 @@ +// Stand-in for lwIP's sockets.h on the build host: rpc_calls.h needs only u16_t. +#ifndef WIFI_TESTS_LWIP_SOCKETS_H +#define WIFI_TESTS_LWIP_SOCKETS_H +#include +typedef uint16_t u16_t; +#endif From 4852d963ffacb3e5bdc57627f7e2b6557e09feff Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:27:16 -0500 Subject: [PATCH 28/95] Keep a Disable during the AP walks and do not scan from Disabled on the control module On the Elite II / C64 Ultimate module, a Disable or Autoconnect taken between two connect attempts of the scanned or stored AP walks was overwritten by the line after the loop, so the radio stayed off while the connector thought it was not disabled, and the next Enable was refused. The walk now moves on only when nothing set another state. Enable clears an earlier explicit Disconnect, like Connect and Autoconnect, so Disconnect, Disable, Enable reconnects. Opening the AP list sends a rescan; with WiFi disabled the module took it as a reason to start its radio. A Scan while Disabled is now refused by the module and dropped by the WiFi task, and the AP list is emptied when WiFi is disabled, so no stale entry stays pickable. The menu actions that scan or connect ("Select AP from list", "Enter AP manually", "Connect to last AP", a pick from the list) now ask "WiFi is disabled. Enable it?" while Disabled: Yes enables WiFi and the action goes on (the scan once the radio is on), No does nothing. On the U64 and U2+L, Yes is the menu's Enable (it sets and saves "WiFi Enabled"); on the Elite II / C64 Ultimate it is the Enable action. A Connect that the module accepted but that fails now continues in Disconnected (retry with backoff) in every state, instead of idling in Connected. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Claude Sonnet 5.5 --- software/io/network/network_esp32.cc | 31 ++- software/io/network/network_esp32.h | 1 + software/io/wifi/tests/Makefile | 13 +- software/io/wifi/tests/disabled_task_test.cpp | 188 ++++++++++++++++++ .../legacy/fix2_ap_list_after_disable.sed | 3 + .../io/wifi/tests/legacy/fix2_ask_enable.sed | 6 + .../tests/legacy/fix2_scan_from_disabled.sed | 4 + software/io/wifi/tests/stubs/browsable.h | 14 +- software/io/wifi/tests/wifi_task_env.h | 15 ++ software/io/wifi/tests/wifi_task_stubs.cpp | 98 ++++++++- software/io/wifi/tests/wifi_task_test.h | 27 ++- software/io/wifi/wifi.cc | 14 +- software/io/wifi/wifi.h | 2 + software/u64ctrl/main/wifi_modem.c | 25 ++- software/wifi/raw_c3/main/wifi_modem.c | 7 +- software/wifi/raw_u64/main/wifi_modem.c | 7 +- software/wifi/tests/Makefile | 13 +- software/wifi/tests/module_connector_test.cpp | 151 ++++++++++++++ 18 files changed, 588 insertions(+), 31 deletions(-) create mode 100644 software/io/wifi/tests/disabled_task_test.cpp create mode 100644 software/io/wifi/tests/legacy/fix2_ap_list_after_disable.sed create mode 100644 software/io/wifi/tests/legacy/fix2_ask_enable.sed create mode 100644 software/io/wifi/tests/legacy/fix2_scan_from_disabled.sed create mode 100644 software/wifi/tests/module_connector_test.cpp diff --git a/software/io/network/network_esp32.cc b/software/io/network/network_esp32.cc index ce111ffb7..65ed61ef5 100644 --- a/software/io/network/network_esp32.cc +++ b/software/io/network/network_esp32.cc @@ -315,11 +315,17 @@ SubsysResultCode_e NetworkLWIP_WiFi :: manual_connect(SubsysCommand *cmd) void NetworkLWIP_WiFi :: cfg_show_aps(UserInterface *intf, ConfigItem *it) { WifiState_t state = wifi.getState(); - if ((state != eWifi_NotConnected) && (state != eWifi_Connected)) { + if (state == eWifi_Disabled) { + if (!ask_enable(intf)) { + return; + } + wifi.sendEventWhenEnabled(EVENT_RESCAN); // the radio is not on yet + } else if ((state != eWifi_NotConnected) && (state != eWifi_Connected)) { intf->popup("Can only show APs when active", BUTTON_OK); return; + } else { + wifi.sendEvent(EVENT_RESCAN); } - wifi.sendEvent(EVENT_RESCAN); BrowsableWifiAPList *broot = new BrowsableWifiAPList(); // new root! TreeBrowser *tb = new TreeBrowser(intf, broot); tb->has_border = true; @@ -335,7 +341,10 @@ void NetworkLWIP_WiFi :: cfg_show_aps(UserInterface *intf, ConfigItem *it) void NetworkLWIP_WiFi :: cfg_enter_ap(UserInterface *intf, ConfigItem *it) { WifiState_t state = wifi.getState(); - if ((state != eWifi_NotConnected) && (state != eWifi_Connected)) { + if ((state == eWifi_Disabled) && !ask_enable(intf)) { + return; + } + if ((state != eWifi_NotConnected) && (state != eWifi_Connected) && (state != eWifi_Disabled)) { intf->popup("Can only connect when active", BUTTON_OK); return; } @@ -346,7 +355,10 @@ void NetworkLWIP_WiFi :: cfg_enter_ap(UserInterface *intf, ConfigItem *it) void NetworkLWIP_WiFi :: cfg_conn_last(UserInterface *intf, ConfigItem *it) { WifiState_t state = wifi.getState(); - if ((state != eWifi_NotConnected) && (state != eWifi_Connected)) { + if ((state == eWifi_Disabled) && !ask_enable(intf)) { + return; + } + if ((state != eWifi_NotConnected) && (state != eWifi_Connected) && (state != eWifi_Disabled)) { intf->popup("Can only connect when active", BUTTON_OK); return; } @@ -440,6 +452,17 @@ SubsysResultCode_e NetworkLWIP_WiFi :: enable(SubsysCommand *cmd) return SSRET_OK; } +// A scan or connect while WiFi is disabled: ask, and on Yes enable it. False: nothing is +// enabled, and the action is dropped. +bool NetworkLWIP_WiFi :: ask_enable(UserInterface *intf) +{ + if (!intf || (intf->popup("WiFi is disabled. Enable it?", BUTTON_YES|BUTTON_NO) != BUTTON_YES)) { + return false; + } + enable(NULL); // the Enable action + return true; +} + // Browsable APs IndexedList *BrowsableWifiAPList :: getSubItems(int &error) { diff --git a/software/io/network/network_esp32.h b/software/io/network/network_esp32.h index be85ea9c3..535c2058c 100644 --- a/software/io/network/network_esp32.h +++ b/software/io/network/network_esp32.h @@ -47,6 +47,7 @@ class NetworkLWIP_WiFi : public NetworkInterface static SubsysResultCode_e disconnect(SubsysCommand *cmd); static SubsysResultCode_e rescan(SubsysCommand *cmd); static SubsysResultCode_e enable(SubsysCommand *cmd); + static bool ask_enable(UserInterface *intf); #if U64 != 2 static void set_enabled(bool on); #endif diff --git a/software/io/wifi/tests/Makefile b/software/io/wifi/tests/Makefile index 2c89fba52..d3ef69741 100644 --- a/software/io/wifi/tests/Makefile +++ b/software/io/wifi/tests/Makefile @@ -18,6 +18,7 @@ HOST_TEST := ../../usb/tests WIFI_CC := $(WIFI_DIR)/wifi.cc NET_CC := ../../network/network_esp32.cc NET_H := ../../network/network_esp32.h +CMD_CC := $(WIFI_DIR)/wifi_cmd.cc EXTRACT := extract.awk # 0 is the Ultimate II+L: it is built as the U2+L is, with U64 not defined at all @@ -30,11 +31,14 @@ OUT := $(if $(LEG),output/red_$(basename $(notdir $(LEG)))_u64_$(U64),output/u64 # Function names are given as written in the source (~ for a blank), so that the C++ method # of a class is found. Those of wifi_switch.h's users exist for the products other than the U64=2 only. WIFI_FUNCS := WiFi~::~WiFi WiFi~::~Init WiFi~::~Enable WiFi~::~Disable WiFi~::~RadioOn \ - WiFi~::~RadioOff WiFi~::~RunModeThread + WiFi~::~RadioOff WiFi~::~RunModeThread WiFi~::~sendEvent WiFi~::~sendConnectEvent WiFi~::getAccessPointItems \ + BrowsableWifiAP~::~connect_ap WIFI_FUNCS_SWITCH := WiFi~::~TalksToModule -NET_FUNCS := NetworkLWIP_WiFi~::~disable NetworkLWIP_WiFi~::~enable +NET_FUNCS := NetworkLWIP_WiFi~::~disable NetworkLWIP_WiFi~::~enable NetworkLWIP_WiFi~::~ask_enable \ + NetworkLWIP_WiFi~::~cfg_show_aps NetworkLWIP_WiFi~::~cfg_enter_ap NetworkLWIP_WiFi~::~cfg_conn_last NET_FUNCS_SWITCH := NetworkLWIP_WiFi~::~wifi_enable_change NetworkLWIP_WiFi~::~set_enabled \ NetworkLWIP_WiFi~::~cfg_enable NetworkLWIP_WiFi~::~cfg_disable +CMD_FUNCS := wifi_wifi_connect CASES := $(wildcard *_test.cpp) LEGACY := $(sort $(wildcard legacy/*.sed)) @@ -71,7 +75,7 @@ $(OUT)/wifi_enable_default.h: $(NET_CC) $(NET_H) @grep -q WIFI_ENABLE_DEFAULT $@ || { echo "wifi_task_test: the CFG_WIFI_ENABLE row not found in $<" >&2; exit 1; } # The code under test, in the order of its files; for a legacy model, with its sed applied -$(OUT)/task.cc: $(WIFI_CC) $(NET_CC) $(EXTRACT) $(LEG) wifi_task_env.h $(OUT)/wifi_enable_default.h +$(OUT)/task.cc: Makefile $(WIFI_CC) $(NET_CC) $(CMD_CC) $(EXTRACT) $(LEG) wifi_task_env.h $(OUT)/wifi_enable_default.h @mkdir -p $(OUT) @{ echo '#include "wifi_task_env.h"'; \ $(foreach f,$(WIFI_FUNCS),$(call extract,$(f),$(WIFI_CC));) \ @@ -81,7 +85,8 @@ $(OUT)/task.cc: $(WIFI_CC) $(NET_CC) $(EXTRACT) $(LEG) wifi_task_env.h $(OUT)/wi $(foreach f,$(NET_FUNCS),$(call extract,$(f),$(NET_CC));) \ echo '#if U64 != 2'; \ $(foreach f,$(NET_FUNCS_SWITCH),$(call extract,$(f),$(NET_CC));) \ - echo '#endif'; } | tr -d '\r' > $(OUT)/task.orig + echo '#endif'; \ + $(foreach f,$(CMD_FUNCS),$(call extract,$(f),$(CMD_CC));) } | tr -d '\r' > $(OUT)/task.orig @if [ -n "$(LEG)" ]; then \ sed -f $(LEG) $(OUT)/task.orig > $@; \ if cmp -s $@ $(OUT)/task.orig; then echo "wifi_task_test: $(LEG) changes nothing" >&2; exit 1; fi; \ diff --git a/software/io/wifi/tests/disabled_task_test.cpp b/software/io/wifi/tests/disabled_task_test.cpp new file mode 100644 index 000000000..4ca2a7e42 --- /dev/null +++ b/software/io/wifi/tests/disabled_task_test.cpp @@ -0,0 +1,188 @@ +/* + * disabled_task_test.cpp + * + * The WiFi application while WiFi is disabled: opening the AP list sends a rescan, which + * must not start the radio (on every product, the Elite II / C64 Ultimate included); the + * list is empty once the radio is off; and a pick from a list that was shown earlier + * sends no connect request, which would turn the radio back on. + */ + +#include "wifi_task_test.h" + +#if U64 == 2 +TEST(WifiDisabledTask, no_scan_while_disabled) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_DISABLED, EVENT_RESCAN }); + CHECK(wifi.getState() == eWifi_Disabled, "Disabled"); + CHECK(strchr(rlog, 'C') == NULL, "no scan while Disabled"); +} + +TEST(WifiDisabledTask, scan_while_enabled) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_RESCAN }); + CHECK(strchr(rlog, 'C') != NULL, "a scan, as before"); +} +#endif + +TEST(WifiDisabledTask, scan_after_enable) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_DISABLED, EVENT_DISCONNECTED, EVENT_RESCAN }); + CHECK(strchr(rlog, 'C') != NULL, "once the radio is on again, a scan"); +} + +// A list scanned before the radio went off is not shown after it: its entries cannot be +// picked +TEST(WifiDisabledTask, ap_list_is_empty_once_disabled) +{ + reset_world(); + world.enabled = true; + wifi_aps.num_records = 3; + boot({ EVENT_DISABLED }); + CHECK(wifi.getState() == eWifi_Disabled, "Disabled"); + CHECK(wifi_aps.num_records == 0, "no AP is kept"); + IndexedList list(0, NULL); + CHECK(wifi.getAccessPointItems(NULL, list) == 0, "no AP to pick"); + BrowsableStatic *row = (list.get_elements() == 1) ? dynamic_cast(list[0]) : NULL; + CHECK(row && strcmp(row->text, "WiFi is disabled") == 0, "the list says so"); +} + +TEST(WifiDisabledTask, ap_list_is_shown_while_enabled) +{ + reset_world(); + world.enabled = true; + wifi_aps.num_records = 3; + boot({ EVENT_CONNECTED }); + IndexedList list(0, NULL); + CHECK(wifi.getAccessPointItems(NULL, list) == 3, "the scanned APs"); + CHECK(list.get_elements() == 3, "are listed"); +} + +// Every scan or connect action of the menu while WiFi is disabled asks "Enable it?". Yes does +// what the Enable action does (the module is asked to turn its radio on), and then the action +// goes on; No sends nothing and leaves the state as it was. +static void act_show_aps(void) { UserInterface ui; NetworkLWIP_WiFi :: cfg_show_aps(&ui, NULL); } +static void act_enter_ap(void) { UserInterface ui; NetworkLWIP_WiFi :: cfg_enter_ap(&ui, NULL); } +static void act_conn_last(void) { UserInterface ui; NetworkLWIP_WiFi :: cfg_conn_last(&ui, NULL); } + +// the action's own mark in the task's log, and what it sends to the module +struct Action_t { const char *name; void (*run)(void); char mark; }; +static const Action_t actions[] = { + { "Select AP from list", act_show_aps, 'C' }, // the scan, once the radio is on + { "Enter AP manually", act_enter_ap, 'k' }, + { "Connect to last AP", act_conn_last, 'a' }, + { "pick from the list", pick, '!' }, // marks are checked below by requests +}; + +static void ask_case(const Action_t &a, bool yes) +{ + reset_world(); + world.enabled = true; + world.popup_answer = yes ? BUTTON_YES : BUTTON_NO; + if (yes) { + boot({ EVENT_DISABLED, a.run, EVENT_DISCONNECTED }); + } else { + boot({ EVENT_DISABLED, a.run }); + } + char what[80]; + snprintf(what, sizeof(what), "%s: asked once", a.name); + CHECK(popups == 1, what); + const char *asked = after('?'); // what the task did after the question + bool done = (a.run == pick) ? (requests == 1) : (strchr(asked, a.mark) != NULL); + const char *enable = strchr(asked, 'N'); + if (yes) { + snprintf(what, sizeof(what), "%s: Yes enables the radio", a.name); + CHECK(enable != NULL, what); + snprintf(what, sizeof(what), "%s: and then the action goes on", a.name); + CHECK(done, what); + if (a.run != pick && enable && a.mark != 'C') { + snprintf(what, sizeof(what), "%s: after the Enable, not before", a.name); + CHECK(strchr(asked, a.mark) > enable, what); + } + if (a.run == act_show_aps) { + CHECK(strchr(asked, 'T') != NULL, "the list is opened"); + } + } else { + snprintf(what, sizeof(what), "%s: No sends nothing", a.name); + CHECK(enable == NULL && !done && requests == 0 && strchr(asked, 'T') == NULL, what); + CHECK(wifi.getState() == eWifi_Disabled, "and the state is unchanged"); + } +} + +TEST(WifiDisabledTask, yes_enables_and_the_action_goes_on) +{ + for (const Action_t &a : actions) { + ask_case(a, true); + } +} + +// After a Yes the state is consistent with "radio on => not Disabled": on the U64 and U2+L +// "WiFi Enabled" reads Enabled, saved, as if it had been set in the menu; on the Elite II / +// C64 Ultimate the Enable action leaves the setting alone +TEST(WifiDisabledTask, yes_leaves_wifi_enabled_set_and_saved) +{ + for (const Action_t &a : actions) { + reset_world(); + world.enabled = false; // "WiFi Enabled" stored as Disabled + boot({ EVENT_DISABLED, a.run, EVENT_DISCONNECTED }); + CHECK(strchr(after('?'), 'N') != NULL, "the radio is asked to come on"); +#if U64 != 2 + CHECK(world.enabled, "the setting reads Enabled"); + CHECK(saves == 1 && saved_enabled, "and it is saved, so it stays so after a reboot"); +#else + CHECK(!world.enabled && saves == 0, "the Enable action leaves the setting alone"); +#endif + } +} + +TEST(WifiDisabledTask, no_leaves_the_setting_alone) +{ + for (const Action_t &a : actions) { + reset_world(); + world.enabled = false; + world.popup_answer = BUTTON_NO; + boot({ EVENT_DISABLED, a.run }); + CHECK(!world.enabled && saves == 0, "No changes and saves nothing"); + } +} + +TEST(WifiDisabledTask, no_does_nothing) +{ + for (const Action_t &a : actions) { + ask_case(a, false); + } +} + +// The scan waits for the radio to be on; if WiFi is disabled again first, it is not sent +TEST(WifiDisabledTask, a_scan_waiting_for_the_radio_is_dropped_by_a_disable) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_DISABLED, act_show_aps, EVENT_DISABLED, EVENT_DISCONNECTED }); + CHECK(strchr(after('?'), 'C') == NULL, "no scan after the Disable"); +} + +TEST(WifiDisabledTask, no_prompt_while_active) +{ + for (const Action_t &a : actions) { + reset_world(); + world.enabled = true; + boot({ EVENT_CONNECTED, a.run }); + CHECK(popups == 0, "not asked while WiFi is on"); + } +} + +TEST(WifiDisabledTask, pick_while_active_connects) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_CONNECTED, pick }); + CHECK(requests == 1, "a connect request"); + CHECK(((rpc_header_t *)request.data)->command == CMD_WIFI_CONNECT, "CMD_WIFI_CONNECT"); + CHECK(strstr(messages, "Can only connect") == NULL, "no refusal"); +} diff --git a/software/io/wifi/tests/legacy/fix2_ap_list_after_disable.sed b/software/io/wifi/tests/legacy/fix2_ap_list_after_disable.sed new file mode 100644 index 000000000..066682059 --- /dev/null +++ b/software/io/wifi/tests/legacy/fix2_ap_list_after_disable.sed @@ -0,0 +1,3 @@ +# The AP list before EVENT_DISABLED emptied it: the list of the last scan stays pickable. +# variants: 1 0 2 +s/^ *wifi_aps\.num_records = 0; \/\/ nothing to pick while the radio is off$// diff --git a/software/io/wifi/tests/legacy/fix2_ask_enable.sed b/software/io/wifi/tests/legacy/fix2_ask_enable.sed new file mode 100644 index 000000000..f5a479ece --- /dev/null +++ b/software/io/wifi/tests/legacy/fix2_ask_enable.sed @@ -0,0 +1,6 @@ +# The menu before it asked "Enable it?" while Disabled (or, on master, refused): a scan or +# connect action while Disabled goes on without asking and without turning the radio on. +# variants: 1 0 2 +s/if ((state == eWifi_Disabled) && !ask_enable(intf)) {/if (0) {/ +s/if ((wifi\.getState() == eWifi_Disabled) && !NetworkLWIP_WiFi :: ask_enable(cmd->user_interface)) {/if (0) {/ +s/ if (!ask_enable(intf)) {/ if (0) {/ diff --git a/software/io/wifi/tests/legacy/fix2_scan_from_disabled.sed b/software/io/wifi/tests/legacy/fix2_scan_from_disabled.sed new file mode 100644 index 000000000..a938fd003 --- /dev/null +++ b/software/io/wifi/tests/legacy/fix2_scan_from_disabled.sed @@ -0,0 +1,4 @@ +# The Elite II / C64 Ultimate task before "do not scan from Disabled on the control module": +# a rescan asked for while Disabled is sent on (and starts the radio). +# variants: 2 +s/if ((state == eWifi_Disabled) || RadioOffAwaited()) {/if (0) {/ diff --git a/software/io/wifi/tests/stubs/browsable.h b/software/io/wifi/tests/stubs/browsable.h index d1ddf4014..89cac011e 100644 --- a/software/io/wifi/tests/stubs/browsable.h +++ b/software/io/wifi/tests/stubs/browsable.h @@ -14,13 +14,25 @@ template class IndexedList { int get_elements(void) const { return (int)items.size(); } T operator[](int i) const { return items[i]; } }; +#define BUTTON_OK 0x01 +#define BUTTON_YES 0x02 +#define BUTTON_NO 0x04 +class TreeBrowser; class UserInterface { public: static void postMessage(const char *msg); int string_box(const char *msg, char *buffer, int maxlen); + int popup(const char *msg, uint8_t flags); + void activate_uiobject(TreeBrowser *tb); }; class Action; -class SubsysCommand { public: intptr_t functionID; UserInterface *user_interface; }; +class SubsysCommand { +public: + intptr_t functionID; + UserInterface *user_interface; + SubsysCommand() : functionID(0), user_interface(NULL) {} + SubsysCommand(UserInterface *u, int, int, int, const char *, const char *) : functionID(0), user_interface(u) {} +}; typedef enum { SSRET_OK = 0, SSRET_NO_USER_INTERFACE } SubsysResultCode_e; class Browsable { public: diff --git a/software/io/wifi/tests/wifi_task_env.h b/software/io/wifi/tests/wifi_task_env.h index 3d7512fae..1a6211eb0 100644 --- a/software/io/wifi/tests/wifi_task_env.h +++ b/software/io/wifi/tests/wifi_task_env.h @@ -34,6 +34,16 @@ typedef int err_t; #endif #include "wifi_enable_default.h" // CFG_WIFI_ENABLE and the default of that setting, from network_esp32.cc / .h +// The AP list's browser, as far as the menu uses it +class BrowsableWifiAPList : public Browsable {}; +class TreeBrowser { +public: + bool has_border, allow_exit, has_path; + TreeBrowser(UserInterface *intf, Browsable *root) {} + void init(void) {} + void setCleanup(void) {} +}; + class ConfigItem; // The configuration store of the WiFi settings, as far as the menu uses it @@ -67,6 +77,11 @@ class NetworkLWIP_WiFi { static void cfg_enable(UserInterface *intf, ConfigItem *it); static void cfg_disable(UserInterface *intf, ConfigItem *it); static SubsysResultCode_e disable(SubsysCommand *cmd); + static SubsysResultCode_e manual_connect(SubsysCommand *cmd); + static bool ask_enable(UserInterface *intf); + static void cfg_show_aps(UserInterface *intf, ConfigItem *it); + static void cfg_enter_ap(UserInterface *intf, ConfigItem *it); + static void cfg_conn_last(UserInterface *intf, ConfigItem *it); static int wifi_enable_change(class ConfigItem *it); }; diff --git a/software/io/wifi/tests/wifi_task_stubs.cpp b/software/io/wifi/tests/wifi_task_stubs.cpp index 8b6d2beae..148570e9a 100644 --- a/software/io/wifi/tests/wifi_task_stubs.cpp +++ b/software/io/wifi/tests/wifi_task_stubs.cpp @@ -74,6 +74,11 @@ void reset_world(void) saves = 0; saved_enabled = false; memset(&world, 0, sizeof(world)); + world.voltages_vbus = 12000; // above the low input voltage warning (U64=2) + world.pick_ssid = "HomeNet"; + string_box_result = 1; + world.popup_answer = BUTTON_YES; + popups = 0; } void check_failed(const char *what, const char *file, int line) @@ -84,8 +89,17 @@ void check_failed(const char *what, const char *file, int line) } // The queue of the task: the script, and what the task queues itself +#define ACT 0x7777 // marks an action of the user in the queue (its bufnr) static command_buf_t queue[16]; static int queue_n, queue_i; +static command_buf_t pool[8]; +static int pool_i; +TickType_t waited; +int requests; +command_buf_t request; +int string_box_result = 1; +int popups; +static command_buf_t txbuf, replybuf; TickType_t xTaskGetTickCount(void) { return now; } void vTaskDelay(TickType_t t) { stop("delayed"); } @@ -94,7 +108,15 @@ void vTaskSuspend(TaskHandle_t t) { stop("suspended"); } void DmaUART :: ModuleCtrl(int mode) { if (mode == ESP_MODE_OFF) note('F'); } // The UART refills a buffer that is given back, so a read after it finds anything void DmaUART :: FreeBuffer(command_buf_t *buf) { memset(buf->data, 0xA5, sizeof(buf->data)); buf->size = -1; } -BaseType_t DmaUART :: GetBuffer(command_buf_t **b, TickType_t t) { return pdFALSE; } +BaseType_t DmaUART :: GetBuffer(command_buf_t **b, TickType_t t) +{ + if (world.no_tx_buffer) { + return pdFALSE; + } + memset(&txbuf, 0, sizeof(txbuf)); + *b = &txbuf; + return pdTRUE; +} void UserInterface :: postMessage(const char *msg) { @@ -103,12 +125,67 @@ void UserInterface :: postMessage(const char *msg) strcat(messages, "\n"); } +int UserInterface :: popup(const char *msg, uint8_t flags) +{ + note('?'); + popups++; + return world.popup_answer; +} + +void UserInterface :: activate_uiobject(TreeBrowser *tb) { note('T'); } + +SubsysResultCode_e NetworkLWIP_WiFi :: manual_connect(SubsysCommand *cmd) { note('k'); return SSRET_OK; } +int wifi_wifi_autoconnect() { note('a'); return 0; } + +int UserInterface :: string_box(const char *msg, char *buffer, int maxlen) { buffer[0] = 0; return string_box_result; } +void BrowsableWifiAP :: fetch_context_items(IndexedList &items) {} + +// The request channel: wifi_wifi_connect (cut out of wifi_cmd.cc) sends through these. The +// request is kept as it went out, and answered as the case says. +const char *no_wifi_buf = "No buffer\n"; +const char *no_wifi_slot = "No slot\n"; +int wifi_reply_register(rpc_header_t *hdr) { return 1; } +command_buf_t *wifi_transmit(command_buf_t *buf, int timeout_ms) +{ + requests++; + request = *buf; + if (world.connect_noreply) { + return NULL; + } + memset(&replybuf, 0, sizeof(replybuf)); + ((rpc_espcmd_resp *)replybuf.data)->esp_err = world.connect_result; + return &replybuf; +} + +// The next to be delivered; the others were queued before it +BaseType_t cmd_buffer_get(command_buf_context_t *context, command_buf_t **b, TickType_t t) +{ + *b = &pool[pool_i++ % 8]; + memset(*b, 0, sizeof(**b)); + return pdTRUE; +} + +BaseType_t cmd_buffer_loopback(command_buf_context_t *context, command_buf_t *b) +{ + if (world.loopback_fails) { + return pdFALSE; + } + memmove(&queue[queue_i + 1], &queue[queue_i], (queue_n - queue_i) * sizeof(queue[0])); + queue[queue_i] = *b; + queue_n++; + return pdTRUE; +} + BaseType_t cmd_buffer_received(command_buf_context_t *context, command_buf_t **b, TickType_t t) { count(); if (++waits == 1) { first_wait_state = wifi.getState(); } + if (queue_i < queue_n && queue[queue_i].bufnr == ACT) { + void (*act)(void) = (void (*)(void))queue[queue_i++].object; + act(); + } if (queue_i < queue_n) { *b = &queue[queue_i++]; return pdTRUE; @@ -117,6 +194,7 @@ BaseType_t cmd_buffer_received(command_buf_context_t *context, command_buf_t **b stop("waiting for an event"); } now += t; // the time it waited, with nothing coming + waited += t; return pdFALSE; } @@ -181,10 +259,18 @@ void boot(std::initializer_list steps) calls = 0; waits = 0; now = 1000; + waited = 0; + requests = 0; + pool_i = 0; queue_n = queue_i = 0; for (std::initializer_list::const_iterator s = steps.begin(); s != steps.end(); ++s) { command_buf_t *b = &queue[queue_n++]; memset(b, 0, sizeof(*b)); + if (s->act) { + b->bufnr = ACT; + b->object = (void *)s->act; + continue; + } ((rpc_header_t *)b->data)->command = s->code; b->size = sizeof(rpc_header_t); if (s->code == EVENT_CONNECTED && s->ssid) { @@ -206,3 +292,13 @@ const char *after(char c) const char *p = strchr(rlog, c); return p ? p + 1 : ""; } + +void pick(void) +{ + BrowsableWifiAP ap(NULL, (char *)world.pick_ssid, -50, world.pick_auth); + UserInterface ui; + SubsysCommand cmd; + cmd.functionID = (intptr_t)≈ + cmd.user_interface = &ui; + BrowsableWifiAP :: connect_ap(&cmd); +} diff --git a/software/io/wifi/tests/wifi_task_test.h b/software/io/wifi/tests/wifi_task_test.h index 3267c94c3..a7e572e0a 100644 --- a/software/io/wifi/tests/wifi_task_test.h +++ b/software/io/wifi/tests/wifi_task_test.h @@ -30,6 +30,13 @@ struct World { int voltages_result; // wifi_get_voltages()'s answer (U64=2) uint16_t voltages_vbus; bool keep_switch; // the next boot keeps the radio switch state (once) + int connect_result; // what the module answers to a connect request (esp_err) + bool connect_noreply; // the module does not answer it + bool no_tx_buffer; // the UART has no buffer for a request + bool loopback_fails; // the task's queue refuses an event of its own + const char *pick_ssid; // the AP the user picks from the list (see pick()) + int pick_auth; // and whether it wants a password + int popup_answer; // BUTTON_YES or BUTTON_NO, to "WiFi is disabled. Enable it?" }; extern World world; void reset_world(void); // every case starts with it @@ -37,25 +44,37 @@ void reset_world(void); // every case starts with it extern int saves; // how often the WiFi settings were written extern bool saved_enabled; // "WiFi Enabled" as written extern char rlog[256]; // what the task did, one letter each +extern int popups; // how often the user was asked extern char messages[256]; // what the user was told, one message per line extern const char *ended; // why the task stopped running extern TickType_t now; // the task's clock, in ticks extern int first_wait_state; // the task's state when it first waits for an event +extern TickType_t waited; // the ticks the task waited for events that did not come extern WiFi wifi; extern NetworkLWIP_WiFi net; +extern int requests; // requests that went to the module (connect) +extern command_buf_t request; // the last one, as it went out +extern int string_box_result; // what the password box returns: <= 0 is a cancel -// A step of the script: an event of the module +// A step of the script: an event of the module, or an action of the user (ACT), run when +// the task reaches it in its queue, as the user interface task would run it at that time struct Step { int code; const char *ssid; int reason; - Step(int c) : code(c), ssid(NULL), reason(-1) {} - Step(int c, const char *s) : code(c), ssid(s), reason(-1) {} + void (*act)(void); + Step(int c) : code(c), ssid(NULL), reason(-1), act(NULL) {} + Step(int c, const char *s) : code(c), ssid(s), reason(-1), act(NULL) {} + Step(void (*a)(void)) : code(0), ssid(NULL), reason(-1), act(a) {} }; // Starts the WiFi task with the module found, and these steps in order void boot(std::initializer_list steps); -const char *after(char c); // the log after the first occurrence of c +const char *after(char c); + +// The user picks world.pick_ssid in the AP list (BrowsableWifiAP :: connect_ap, which runs +// in the user interface task); as a step of a script, when the task reaches it +void pick(void); // the log after the first occurrence of c // The case's check: a failure says what was expected and what the task did void check_failed(const char *what, const char *file, int line); diff --git a/software/io/wifi/wifi.cc b/software/io/wifi/wifi.cc index 4cc7334e1..8de81da12 100644 --- a/software/io/wifi/wifi.cc +++ b/software/io/wifi/wifi.cc @@ -31,6 +31,7 @@ WiFi :: WiFi() { runModeTask = NULL; state = eWifi_Off; + event_when_enabled = 0; bzero(my_mac, 6); wifi_aps.num_records = 0; my_ip = 0; @@ -427,13 +428,11 @@ void WiFi :: RunModeThread() switch(hdr->command) { case EVENT_RESCAN: // requested from user interface uart->FreeBuffer(buf); -#if U64 != 2 // Disabled means no RF, also while the radio off waits to be confirmed: // the module does not scan with its radio off - if ((state == eWifi_Disabled) || radio_switch.awaiting_off) { + if ((state == eWifi_Disabled) || RadioOffAwaited()) { break; } -#endif netstack->link_down(); state = eWifi_Scanning; RefreshRoot(); @@ -455,6 +454,8 @@ void WiFi :: RunModeThread() case EVENT_DISABLED: uart->FreeBuffer(buf); state = eWifi_Disabled; + event_when_enabled = 0; + wifi_aps.num_records = 0; // nothing to pick while the radio is off netstack->link_down(); RefreshRoot(); break; @@ -480,6 +481,10 @@ void WiFi :: RunModeThread() if(netstack) { netstack->link_down(); } + if (event_when_enabled) { // the radio is on again: what the user asked for + sendEvent(event_when_enabled); + event_when_enabled = 0; + } RefreshRoot(); break; @@ -579,6 +584,9 @@ SubsysResultCode_e BrowsableWifiAP :: connect_ap(SubsysCommand *cmd) { char password[65] = { 0 }; // string_box takes 64 characters plus the terminator BrowsableWifiAP *bap = (BrowsableWifiAP *)cmd->functionID; + if ((wifi.getState() == eWifi_Disabled) && !NetworkLWIP_WiFi :: ask_enable(cmd->user_interface)) { + return SSRET_OK; + } if (bap->auth) { if(cmd->user_interface) { cmd->user_interface->string_box("Enter password", password, 64); diff --git a/software/io/wifi/wifi.h b/software/io/wifi/wifi.h index 508217606..7febbd1ae 100644 --- a/software/io/wifi/wifi.h +++ b/software/io/wifi/wifi.h @@ -44,6 +44,7 @@ class WiFi : public Esp32Application NetworkLWIP_WiFi *netstack; WifiState_t state; + uint8_t event_when_enabled; // an event of the user to send once the radio is on again (0: none) char last_ap[32]; char moduleName[34]; char moduleType[24]; @@ -84,6 +85,7 @@ class WiFi : public Esp32Application void sendEvent(uint8_t code); void sendConnectEvent(const char *ssid, const char *pass, uint8_t auth); + void sendEventWhenEnabled(uint8_t code) { event_when_enabled = code; } // after the radio is on again void freeBuffer(command_buf_t *buf); int getAccessPointItems(Browsable *parent, IndexedList &list); diff --git a/software/u64ctrl/main/wifi_modem.c b/software/u64ctrl/main/wifi_modem.c index 16b33cf0a..e19b92541 100644 --- a/software/u64ctrl/main/wifi_modem.c +++ b/software/u64ctrl/main/wifi_modem.c @@ -800,6 +800,9 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) break; case CMD_WIFI_ENABLE: if (*state == Disabled) { + // Like a connect request, an Enable means the user wants to be on the + // network again, so a Disconnect from before the Disable is spent + user_disconnected = false; ESP_LOGI(TAG, "Starting WiFi."); err = esp_wifi_start(); if (err == ESP_OK) { @@ -816,13 +819,13 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) break; case CMD_WIFI_SCAN: { - err = enable_wifi_if_needed(*state); rpc_scan_resp *resp = (rpc_scan_resp *)buf->data; - if (err == ESP_OK) { - resp->esp_err = wifi_scan(&resp->rec); - } else { - resp->esp_err = err; + if (*state == Disabled) { + // Disabled means the radio is off; a scan does not turn it on, Enable does + resp->esp_err = ESP_ERR_INVALID_STATE; resp->rec.num_records = 0; + } else { + resp->esp_err = wifi_scan(&resp->rec); } buf->size = sizeof(resp->hdr) + sizeof(resp->esp_err) + 2 + (resp->rec.num_records * sizeof(ultimate_ap_record_t)); my_uart_transmit_packet(UART_NUM_1, buf); @@ -841,6 +844,12 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) case CMD_WIFI_CONNECT: user_disconnected = false; err = enable_wifi_if_needed(*state); + if (err == ESP_OK) { + // The radio is on: whatever the attempt gives, the connector goes on from + // here and retries, as after a dropped link, not idle in Connected or + // Disabled + *state = Disconnected; + } { last_connect = *cmd; last_connect.list_index = -1; @@ -939,7 +948,9 @@ void connect_thread(void *a) } } } - if (state != Connected) { + // A command handled in the walk has set the state already: a Disable + // or an Autoconnect must not be overwritten here + if (state == ScannedAPs) { state = StoredAPs; } break; @@ -970,7 +981,7 @@ void connect_thread(void *a) } } } - if (state != Connected) { + if (state == StoredAPs) { state = Disconnected; } break; diff --git a/software/wifi/raw_c3/main/wifi_modem.c b/software/wifi/raw_c3/main/wifi_modem.c index 95f2e28ad..8497c4648 100644 --- a/software/wifi/raw_c3/main/wifi_modem.c +++ b/software/wifi/raw_c3/main/wifi_modem.c @@ -796,9 +796,10 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) case CMD_WIFI_CONNECT: user_disconnected = false; err = enable_wifi_if_needed(*state); - if ((err == ESP_OK) && (*state == Disabled)) { - // The radio is on again: whatever the attempt gives, the connector goes - // on from here and retries, as after a dropped link + if (err == ESP_OK) { + // The radio is on: whatever the attempt gives, the connector goes on from + // here and retries, as after a dropped link, not idle in Connected or + // Disabled *state = Disconnected; } { diff --git a/software/wifi/raw_u64/main/wifi_modem.c b/software/wifi/raw_u64/main/wifi_modem.c index 52b16b2b5..605d17c98 100644 --- a/software/wifi/raw_u64/main/wifi_modem.c +++ b/software/wifi/raw_u64/main/wifi_modem.c @@ -796,9 +796,10 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) case CMD_WIFI_CONNECT: user_disconnected = false; err = enable_wifi_if_needed(*state); - if ((err == ESP_OK) && (*state == Disabled)) { - // The radio is on again: whatever the attempt gives, the connector goes - // on from here and retries, as after a dropped link + if (err == ESP_OK) { + // The radio is on: whatever the attempt gives, the connector goes on from + // here and retries, as after a dropped link, not idle in Connected or + // Disabled *state = Disconnected; } { diff --git a/software/wifi/tests/Makefile b/software/wifi/tests/Makefile index a67a0a7d3..5faa76497 100644 --- a/software/wifi/tests/Makefile +++ b/software/wifi/tests/Makefile @@ -54,13 +54,24 @@ NEEDED := send_event wifi_event_handler attempt_connect wifi_connect_to_sca # changed and puts back what was there before. Every one has to make the suite FAIL (a failing # check, not a build error); `make red` prints which checks failed. A fix that a module # does not have, or whose cases are not in this commit, has no entry. -RED_FIXES := 1 +RED_FIXES := 1 2 # 1 The radio switch (U64, U2+L): no Disable is served, and the radio goes on at boot, as # on a module without the switch LEGACY_1_raw_u64 := -e 's/case CMD_WIFI_DISABLE:/case 0x7F:/' -e 's/return Disabled;/return LastAP;/' LEGACY_1_raw_c3 := $(LEGACY_1_raw_u64) +# 2 The control module: a Disable or Autoconnect taken in the AP walks is overwritten by the +# line after the loop, an Enable does not spend an earlier Disconnect, and a Scan in Disabled +# starts the radio. All three: a Connect only leaves Disabled for the retry, not Connected +LEGACY_CONNECT := -e '/case CMD_WIFI_CONNECT:/,/last_connect = \*cmd;/s/if (err == ESP_OK) {/if ((err == ESP_OK) \&\& (*state == Disabled)) {/' +LEGACY_2_raw_u64 := $(LEGACY_CONNECT) +LEGACY_2_raw_c3 := $(LEGACY_CONNECT) +LEGACY_2_u64ctrl := $(LEGACY_CONNECT) \ + -e 's/if (state == ScannedAPs) {/if (state != Connected) {/' -e 's/if (state == StoredAPs) {/if (state != Connected) {/' \ + -e '/^ *user_disconnected = false;$$/{' -e 'N' -e '/ESP_LOGI(TAG, "Starting WiFi.")/s/^.*\n//' -e '}' \ + -e '/if (\*state == Disabled) {$$/{' -e 'N' -e '/a scan does not turn it on/s/(\*state == Disabled)/(0)/' -e '}' + LEGACY = $(LEGACY_$(FIX)_$(M)) .PHONY: all test red clean radio diff --git a/software/wifi/tests/module_connector_test.cpp b/software/wifi/tests/module_connector_test.cpp new file mode 100644 index 000000000..105da5c54 --- /dev/null +++ b/software/wifi/tests/module_connector_test.cpp @@ -0,0 +1,151 @@ +/* + * module_connector_test.cpp + * + * The connector of the modules, fix 2: a Disable or an Autoconnect taken while it walks its + * AP lists, an Enable after a Disconnect, no scan from Disabled (see module_script.h). The + * first group is for the Elite II / C64 Ultimate module (u64ctrl); the U64 and U2+L modules + * have these cases in module_switch_test.cpp, with their radio switch. The last group is + * for all three: a Connect whose attempt fails. + */ + +#include +#include "module_script.h" + +#ifdef MODULE_U64CTRL +// An Autoconnect handled while the connector walks its scanned APs: the walk ends and the +// connector starts over from the last AP, instead of going on to the stored ones. +TEST(Connector, autoconnect_in_the_walk) +{ + const uint8_t cmds[] = { CMD_WIFI_AUTOCONNECT }; + run(false, cmds, 1); + CHECK(strncmp(trace, "LS", 2) == 0, "the walk began"); + CHECK(after('S')[0] == 'L', "the next attempt after the Autoconnect is the last AP"); +} + +// The same in the walk over the stored APs: a scan that finds nothing goes straight there +TEST(Connector, autoconnect_in_the_stored_walk) +{ + const uint8_t cmds[] = { CMD_WIFI_AUTOCONNECT }; + run_with(0, false, cmds, 1); + CHECK(after('S')[0] == 'L', "the next attempt after the Autoconnect is the last AP"); +} + +// C13 in the stored walk +TEST(Connector, disable_in_the_stored_walk) +{ + const uint8_t cmds[] = { CMD_WIFI_DISABLE }; + run_with(0, false, cmds, 1); + CHECK(strpbrk(after('P'), "Lcs") == NULL, "no connect attempt with the radio off"); + CHECK(strcmp(ended, "waiting for a command") == 0, "waits in Disabled"); +} + +// C13: a Disable handled during the walk turns the radio off, and the connector then waits +// in Disabled for a command, without trying any AP. +TEST(Connector, disable_in_the_walk) +{ + const uint8_t cmds[] = { CMD_WIFI_DISABLE }; + run(false, cmds, 1); + CHECK(strstr(trace, "PX") != NULL, "the radio is stopped and EVENT_DISABLED sent"); + CHECK(strpbrk(after('P'), "Lcs") == NULL, "no connect attempt with the radio off"); + CHECK(strcmp(ended, "waiting for a command") == 0, "waits in Disabled"); +} + +// C16: Disconnect, then Disable, then Enable: the connector reconnects. +TEST(Connector, enable_after_disconnect_and_disable) +{ + const uint8_t cmds[] = { CMD_WIFI_DISABLE, CMD_WIFI_ENABLE }; + run(true, cmds, 2); + CHECK(strstr(trace, "PX") != NULL, "the radio is stopped"); + CHECK(strchr(after('P'), 'T') != NULL, "and started again"); + CHECK(strchr(after('T'), 'L') != NULL, "then the connector tries the last AP"); + CHECK(strcmp(ended, "idle without a timeout") != 0, "it does not idle for good"); +} + +// Disabled means the radio is off: a Scan is refused and does not turn it on (the menu's +// rescan, a rescan sent before the Ultimate saw EVENT_DISABLED, or any other sender) +TEST(Connector, scan_refused_while_disabled) +{ + const uint8_t cmds[] = { CMD_WIFI_DISABLE, CMD_WIFI_SCAN }; + run(true, cmds, 2); + CHECK(strstr(trace, "PX") != NULL, "the radio is stopped"); + CHECK(strpbrk(after('P'), "TS") == NULL, "no radio start and no scan"); + CHECK(strcmp(ended, "waiting for a command") == 0, "still Disabled"); +} + +// A Connect from Disabled (a stale AP entry's Connect) starts the radio and leaves +// Disabled: when the attempt fails, the connector retries as after a dropped link +// instead of idling in Disabled with the radio on +TEST(Connector, failed_connect_from_disabled) +{ + const uint8_t cmds[] = { CMD_WIFI_DISABLE, CMD_WIFI_CONNECT }; + run(true, cmds, 2); + CHECK(strstr(trace, "PX") != NULL, "the radio is stopped"); + CHECK(strchr(after('P'), 'T') != NULL, "the Connect starts it"); + CHECK(strcmp(ended, "idle until the retry timer") == 0, "it retries, it is not parked in Disabled"); +} + +// An Autoconnect from Disabled starts the radio and walks the ladder +TEST(Connector, autoconnect_from_disabled) +{ + const uint8_t cmds[] = { CMD_WIFI_DISABLE, CMD_WIFI_AUTOCONNECT }; + run(false, cmds, 2); + CHECK(strstr(trace, "PX") != NULL, "the radio is stopped"); + CHECK(strchr(after('P'), 'T') != NULL, "the Autoconnect starts it"); + CHECK(strchr(after('T'), 'L') != NULL, "then the last AP"); +} + +#endif /* MODULE_U64CTRL */ + +// The U64 and U2+L modules start with the radio off: their first command is the Enable +#ifdef MODULE_HAS_SWITCH +#define ENABLE_FIRST CMD_WIFI_ENABLE, +#else +#define ENABLE_FIRST +#endif + +// A Connect that the ESP accepts and that then fails (EVENT_DISCONNECTED) while the +// connector is Connected: it ends in Disconnected, and the retry timer runs the last AP +// again, instead of the connector idling in Connected without a timeout (review M1) +TEST(Connector, failed_connect_while_connected_retries) +{ + const uint8_t cmds[] = { ENABLE_FIRST CMD_WIFI_CONNECT }; + last_ap_reachable = true; + retry_timeouts = 1; + run(false, cmds, sizeof(cmds)); + CHECK(strstr(trace, "LK") != NULL, "connected to the last AP first"); + CHECK(strchr(trace, 'c') != NULL, "the Connect was tried"); + CHECK(strcmp(ended, "idle without a timeout") != 0, "it does not idle in Connected"); + CHECK(strchr(strchr(trace, 'c'), 'L') != NULL, "after the failed Connect the retry runs the last AP"); + CHECK(strcmp(ended, "idle until the retry timer") == 0, "and it keeps retrying"); +} + +// The same for a Connect taken in the walk over the scanned APs: the walk ends, the +// stored APs are not walked, the connector retries +TEST(Connector, failed_connect_in_the_walk_retries) +{ + const uint8_t cmds[] = { ENABLE_FIRST CMD_WIFI_CONNECT }; + retry_timeouts = 1; + run(false, cmds, sizeof(cmds)); + CHECK(strchr(trace, 'S') != NULL, "the walk began"); + CHECK(strchr(after('S'), 'L') != NULL, "after the failed Connect the retry runs the last AP"); +} + +// ... and from Disabled, after a Disable (a stale AP entry's Connect) +TEST(Connector, failed_connect_from_disabled_retries) +{ + const uint8_t cmds[] = { ENABLE_FIRST CMD_WIFI_DISABLE, CMD_WIFI_CONNECT }; + retry_timeouts = 1; + run(false, cmds, sizeof(cmds)); + CHECK(strchr(after('P'), 'T') != NULL, "the Connect starts the radio"); + CHECK(strchr(after('T'), 'L') != NULL, "and the retry runs the last AP"); +} + +// A Connect is a request to be on the network: an explicit Disconnect from before is spent, so +// a failed Connect retries instead of waiting for the user +TEST(Connector, connect_spends_an_earlier_disconnect) +{ + const uint8_t cmds[] = { CMD_WIFI_CONNECT }; + run(true, cmds, 1); + CHECK(strchr(trace, 'c') != NULL, "the Connect was tried"); + CHECK(strcmp(ended, "idle until the retry timer") == 0, "and the connector retries"); +} From 5a038c2de7890193c88a14b6888eb9e8d2d78832 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:27:16 -0500 Subject: [PATCH 29/95] Keep the WiFi interface up while the AP list is scanned Opening the AP list sends a rescan. The WiFi task took its interface down and set "not connected" when the scan was done, although the module stays associated through a scan and sends no new connect event: the interface stayed down until the link dropped and came back. A scan now leaves the interface up and the task returns to the state it was in. No packet goes out while the scan runs (wifi_tx_packet sends only when Connected); events the module sent meanwhile are taken afterwards. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Claude Sonnet 5.5 --- .../legacy/fix3_scan_takes_the_link_down.sed | 5 ++ .../io/wifi/tests/scan_link_task_test.cpp | 57 +++++++++++++++++++ software/io/wifi/wifi.cc | 11 +++- software/io/wifi/wifi.h | 1 + 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 software/io/wifi/tests/legacy/fix3_scan_takes_the_link_down.sed create mode 100644 software/io/wifi/tests/scan_link_task_test.cpp diff --git a/software/io/wifi/tests/legacy/fix3_scan_takes_the_link_down.sed b/software/io/wifi/tests/legacy/fix3_scan_takes_the_link_down.sed new file mode 100644 index 000000000..601b2504d --- /dev/null +++ b/software/io/wifi/tests/legacy/fix3_scan_takes_the_link_down.sed @@ -0,0 +1,5 @@ +# The task before "Keep the WiFi interface up while the AP list is scanned": a rescan takes +# the interface down, and the task is not connected after the scan. +# variants: 1 0 2 +s/^ *state_before_scan = state;$/ netstack->link_down();/ +s/state = state_before_scan;/state = eWifi_NotConnected;/ diff --git a/software/io/wifi/tests/scan_link_task_test.cpp b/software/io/wifi/tests/scan_link_task_test.cpp new file mode 100644 index 000000000..86abfad34 --- /dev/null +++ b/software/io/wifi/tests/scan_link_task_test.cpp @@ -0,0 +1,57 @@ +/* + * scan_link_task_test.cpp + * + * A scan (EVENT_RESCAN, as opening the AP list sends) does not take the WiFi interface + * down: while Connected the interface stays up and the task is Connected again after the + * scan (no packet goes out while it scans: wifi_tx_packet sends only when Connected). A + * connect or disconnect from the module that is queued behind the scan is taken after it, + * and the state before the scan (not connected, Disabled) is the state after it. The stub + * scan returns at once, so "during" means "queued behind the scan". + */ + +#include "wifi_task_test.h" + +// Connected (the module was associated at boot), then a rescan +TEST(WifiScanLinkTask, connected_scan_keeps_the_link) +{ + reset_world(); + world.enabled = true; + world.link = 1; + boot({ EVENT_RESCAN }); + CHECK(strchr(after('U'), 'C') != NULL, "linked up, then the scan"); + CHECK(strchr(after('U'), 'u') == NULL, "the interface is not taken down"); + CHECK(wifi.getState() == eWifi_Connected, "still Connected"); +} + +// The module reports a lost link behind the scan, then gets it back: the task follows +TEST(WifiScanLinkTask, disconnect_behind_the_scan) +{ + reset_world(); + world.enabled = true; + world.link = 1; + boot({ EVENT_RESCAN, EVENT_DISCONNECTED }); + CHECK(strchr(after('C'), 'u') != NULL, "the disconnect takes the interface down"); + CHECK(wifi.getState() == eWifi_NotConnected, "not connected"); + boot({ EVENT_RESCAN, EVENT_DISCONNECTED, EVENT_CONNECTED }); + CHECK(strchr(after('u'), 'U') != NULL, "the reconnect brings it up again"); + CHECK(wifi.getState() == eWifi_Connected, "Connected"); +} + +// Not connected before the scan: not connected after it +TEST(WifiScanLinkTask, not_connected_scan) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_RESCAN }); + CHECK(strchr(rlog, 'C') != NULL, "a scan"); + CHECK(wifi.getState() == eWifi_NotConnected, "not connected"); +} + +// Disabled before the scan: the task's state is Disabled after it +TEST(WifiScanLinkTask, disabled_scan) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_DISABLED, EVENT_RESCAN }); + CHECK(wifi.getState() == eWifi_Disabled, "still Disabled"); +} diff --git a/software/io/wifi/wifi.cc b/software/io/wifi/wifi.cc index 8de81da12..f61eeeab7 100644 --- a/software/io/wifi/wifi.cc +++ b/software/io/wifi/wifi.cc @@ -31,6 +31,7 @@ WiFi :: WiFi() { runModeTask = NULL; state = eWifi_Off; + state_before_scan = eWifi_NotConnected; event_when_enabled = 0; bzero(my_mac, 6); wifi_aps.num_records = 0; @@ -382,7 +383,10 @@ void WiFi :: RunModeThread() case eWifi_Scanning: wifi_aps.num_records = 0; wifi_scan(&wifi_aps); - state = eWifi_NotConnected; + // Back to where it was: a scan does not take the link down. Events the module + // sent while it scanned are taken next, from the queue (as many as the receive + // buffers hold while this task waits for the scan's answer). + state = state_before_scan; RefreshRoot(); RefreshAPs(); break; @@ -433,7 +437,10 @@ void WiFi :: RunModeThread() if ((state == eWifi_Disabled) || RadioOffAwaited()) { break; } - netstack->link_down(); + // The module scans while it stays associated, so the interface stays up; + // no packet goes out until the scan is done (wifi_tx_packet sends only + // when Connected) + state_before_scan = state; state = eWifi_Scanning; RefreshRoot(); break; diff --git a/software/io/wifi/wifi.h b/software/io/wifi/wifi.h index 7febbd1ae..1ef9f1d29 100644 --- a/software/io/wifi/wifi.h +++ b/software/io/wifi/wifi.h @@ -44,6 +44,7 @@ class WiFi : public Esp32Application NetworkLWIP_WiFi *netstack; WifiState_t state; + WifiState_t state_before_scan; // the state a scan of the AP list returns to uint8_t event_when_enabled; // an event of the user to send once the radio is on again (0: none) char last_ap[32]; char moduleName[34]; From e37b3492021d2c21bc16dfff0783a41823c906f2 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:27:16 -0500 Subject: [PATCH 30/95] Join the strongest access point when several share the SSID The modules connected by SSID with ESP-IDF's default fast scan, which joins the first AP it hears with that SSID, going up from channel 1: a far AP while a near one was in the room, and no connection where the network only lets a client join the closest AP. attempt_connect() now asks for an all-channel scan sorted by signal, so the station joins the strongest AP of the SSID (the others stay as fallbacks). All connect paths go through it. The connect takes about one scan of the band longer. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/main/wifi_modem.c | 6 ++ software/wifi/raw_c3/main/wifi_modem.c | 6 ++ software/wifi/raw_u64/main/wifi_modem.c | 6 ++ software/wifi/tests/Makefile | 8 +- software/wifi/tests/module_aps.h | 30 ++++++++ software/wifi/tests/module_aps_stubs.c | 11 +++ software/wifi/tests/module_strongest_test.cpp | 75 +++++++++++++++++++ 7 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 software/wifi/tests/module_aps.h create mode 100644 software/wifi/tests/module_aps_stubs.c create mode 100644 software/wifi/tests/module_strongest_test.cpp diff --git a/software/u64ctrl/main/wifi_modem.c b/software/u64ctrl/main/wifi_modem.c index e19b92541..1a9692ded 100644 --- a/software/u64ctrl/main/wifi_modem.c +++ b/software/u64ctrl/main/wifi_modem.c @@ -561,6 +561,12 @@ esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode memcpy(&wifi_config_auto.sta.password, passwd, 64); wifi_config_auto.sta.pmf_cfg.capable = true; wifi_config_auto.sta.pmf_cfg.required = false; + // One network often has several access points under the same SSID. The + // default fast scan joins the first of them it hears, going up from + // channel 1, however far away that one is. Scan all channels and take the + // one with the strongest signal; the others stay as fallbacks. + wifi_config_auto.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; + wifi_config_auto.sta.sort_method = WIFI_CONNECT_AP_BY_SIGNAL; esp_err_t err = esp_wifi_set_config(WIFI_IF_STA, &wifi_config_auto); if (err == ESP_OK) { diff --git a/software/wifi/raw_c3/main/wifi_modem.c b/software/wifi/raw_c3/main/wifi_modem.c index 8497c4648..00878618c 100644 --- a/software/wifi/raw_c3/main/wifi_modem.c +++ b/software/wifi/raw_c3/main/wifi_modem.c @@ -492,6 +492,12 @@ esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode memcpy(&wifi_config_auto.sta.password, passwd, 64); wifi_config_auto.sta.pmf_cfg.capable = true; wifi_config_auto.sta.pmf_cfg.required = false; + // One network often has several access points under the same SSID. The + // default fast scan joins the first of them it hears, going up from + // channel 1, however far away that one is. Scan all channels and take the + // one with the strongest signal; the others stay as fallbacks. + wifi_config_auto.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; + wifi_config_auto.sta.sort_method = WIFI_CONNECT_AP_BY_SIGNAL; esp_err_t err = esp_wifi_set_config(WIFI_IF_STA, &wifi_config_auto); if (err == ESP_OK) { diff --git a/software/wifi/raw_u64/main/wifi_modem.c b/software/wifi/raw_u64/main/wifi_modem.c index 605d17c98..7cd88f482 100644 --- a/software/wifi/raw_u64/main/wifi_modem.c +++ b/software/wifi/raw_u64/main/wifi_modem.c @@ -492,6 +492,12 @@ esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode memcpy(&wifi_config_auto.sta.password, passwd, 64); wifi_config_auto.sta.pmf_cfg.capable = true; wifi_config_auto.sta.pmf_cfg.required = false; + // One network often has several access points under the same SSID. The + // default fast scan joins the first of them it hears, going up from + // channel 1, however far away that one is. Scan all channels and take the + // one with the strongest signal; the others stay as fallbacks. + wifi_config_auto.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; + wifi_config_auto.sta.sort_method = WIFI_CONNECT_AP_BY_SIGNAL; esp_err_t err = esp_wifi_set_config(WIFI_IF_STA, &wifi_config_auto); if (err == ESP_OK) { diff --git a/software/wifi/tests/Makefile b/software/wifi/tests/Makefile index 5faa76497..6518b03d5 100644 --- a/software/wifi/tests/Makefile +++ b/software/wifi/tests/Makefile @@ -54,7 +54,7 @@ NEEDED := send_event wifi_event_handler attempt_connect wifi_connect_to_sca # changed and puts back what was there before. Every one has to make the suite FAIL (a failing # check, not a build error); `make red` prints which checks failed. A fix that a module # does not have, or whose cases are not in this commit, has no entry. -RED_FIXES := 1 2 +RED_FIXES := 1 2 4 # 1 The radio switch (U64, U2+L): no Disable is served, and the radio goes on at boot, as # on a module without the switch @@ -72,6 +72,12 @@ LEGACY_2_u64ctrl := $(LEGACY_CONNECT) \ -e '/^ *user_disconnected = false;$$/{' -e 'N' -e '/ESP_LOGI(TAG, "Starting WiFi.")/s/^.*\n//' -e '}' \ -e '/if (\*state == Disabled) {$$/{' -e 'N' -e '/a scan does not turn it on/s/(\*state == Disabled)/(0)/' -e '}' +# 4 The first AP of the SSID that answers is joined, not the strongest +LEGACY_NOTSTRONGEST := -e '/sta.scan_method = WIFI_ALL_CHANNEL_SCAN;/d' -e '/sta.sort_method = WIFI_CONNECT_AP_BY_SIGNAL;/d' +LEGACY_4_raw_u64 := $(LEGACY_NOTSTRONGEST) +LEGACY_4_raw_c3 := $(LEGACY_NOTSTRONGEST) +LEGACY_4_u64ctrl := $(LEGACY_NOTSTRONGEST) + LEGACY = $(LEGACY_$(FIX)_$(M)) .PHONY: all test red clean radio diff --git a/software/wifi/tests/module_aps.h b/software/wifi/tests/module_aps.h new file mode 100644 index 000000000..711435436 --- /dev/null +++ b/software/wifi/tests/module_aps.h @@ -0,0 +1,30 @@ +/* + * module_aps.h + * + * The air of the AP selection cases: one network, three APs, and a stronger AP of another + * network (module_strongest_test.cpp, module_pick_test.cpp). + */ + +#ifndef MODULE_APS_H_ +#define MODULE_APS_H_ + +#include "module_script.h" + +extern "C" { +esp_err_t air_attempt_connect(const char *ssid, const char *pw, uint8_t auth, const uint8_t *bssid, uint8_t channel); +} + +/* One network, three APs: the far one on channel 1, the near one on 6, one between on 11, + * and a stronger AP of another network. */ +static int far_ap, near_ap, mid_ap, other_ap; + +static void three_aps(void) +{ + air_reset(); + far_ap = air_add("Home", 0x01, 1, -82, WIFI_AUTH_WPA2_PSK); + near_ap = air_add("Home", 0x06, 6, -41, WIFI_AUTH_WPA2_PSK); + mid_ap = air_add("Home", 0x0B, 11, -63, WIFI_AUTH_WPA2_PSK); + other_ap = air_add("Other", 0x03, 3, -30, WIFI_AUTH_WPA2_PSK); +} + +#endif /* MODULE_APS_H_ */ diff --git a/software/wifi/tests/module_aps_stubs.c b/software/wifi/tests/module_aps_stubs.c new file mode 100644 index 000000000..544d261c9 --- /dev/null +++ b/software/wifi/tests/module_aps_stubs.c @@ -0,0 +1,11 @@ +/* + * module_aps_stubs.c + * + * The calls the AP selection cases make into the module's code (module_aps.h). Included at the + * end of module_stubs.c. + */ + +esp_err_t air_attempt_connect(const char *ssid, const char *pw, uint8_t auth, const uint8_t *bssid, uint8_t channel) +{ + return attempt_connect(ssid, pw, auth); // the module takes the picked AP (BSSID, channel) only from fix 5 +} diff --git a/software/wifi/tests/module_strongest_test.cpp b/software/wifi/tests/module_strongest_test.cpp new file mode 100644 index 000000000..73bd0e38c --- /dev/null +++ b/software/wifi/tests/module_strongest_test.cpp @@ -0,0 +1,75 @@ +/* + * module_strongest_test.cpp + * + * Fix 4: which access point a WiFi module joins when several share one SSID. attempt_connect() + * and wifi_connect_to_scanned() are the module's own, run against the station model of + * module_stubs.c, whose esp_wifi_connect() picks an AP from a scripted air the way the IDF + * station does. + */ + +#include +#include "module_aps.h" + + +TEST(Strongest, ssid_joins_the_strongest) +{ + three_aps(); + char ssid[32] = "Home"; + char pw[68] = "secret-pw"; + CHECK(air_attempt_connect(ssid, pw, WIFI_AUTH_WPA2_PSK, NULL, 0) == ESP_OK, "the connect is accepted"); + CHECK(joined == near_ap, "the strongest AP of the SSID is joined, not the first on channel 1"); + CHECK(last_config.sta.scan_method == WIFI_ALL_CHANNEL_SCAN, "all channels are scanned"); + CHECK(last_config.sta.sort_method == WIFI_CONNECT_AP_BY_SIGNAL, "the APs are sorted by signal"); +} + +TEST(Strongest, config_otherwise_unchanged) +{ + three_aps(); + char ssid[32] = "Home"; + char pw[68] = "secret-pw"; + air_attempt_connect(ssid, pw, WIFI_AUTH_WPA2_PSK, NULL, 0); + CHECK(strncmp((char *)last_config.sta.ssid, "Home", 32) == 0, "the SSID is passed"); + CHECK(strncmp((char *)last_config.sta.password, "secret-pw", 64) == 0, "the password is passed"); + CHECK(last_config.sta.threshold.authmode == WIFI_AUTH_WPA2_PSK, "the auth mode is the threshold"); + CHECK(last_config.sta.pmf_cfg.capable && !last_config.sta.pmf_cfg.required, "PMF capable, not required"); + CHECK(!last_config.sta.bssid_set && (last_config.sta.channel == 0), "no BSSID, no channel"); +} + +/* A stronger WPA2 AP and a weaker WPA3 one under one SSID: by signal, not by security */ +TEST(Strongest, signal_before_security) +{ + air_reset(); + int wpa3 = air_add("Mesh", 0x21, 1, -75, WIFI_AUTH_WPA3_PSK); + int wpa2 = air_add("Mesh", 0x22, 6, -40, WIFI_AUTH_WPA2_PSK); + char ssid[32] = "Mesh"; + char pw[68] = "secret-pw"; + air_attempt_connect(ssid, pw, WIFI_AUTH_WPA2_PSK, NULL, 0); + CHECK(joined == wpa2, "the stronger WPA2 AP is joined, not the weaker WPA3 one"); + (void)wpa3; +} + +/* The module's own walk (ScannedAPs) goes through its scan list in the driver's order; + * whichever entry of the SSID it is at, the strongest AP of that SSID is the one joined. */ +TEST(Strongest, scanned_walk_joins_the_strongest) +{ + three_aps(); + const int order[] = { far_ap, other_ap, mid_ap, near_ap }; + air_to_scan_list(order, 4); + CHECK(wifi_connect_to_scanned(0) == ESP_OK, "the walk's first entry (the far AP) is tried"); + CHECK(joined == near_ap, "the strongest AP of its SSID is joined"); + wifi_connect_to_scanned(2); + CHECK(joined == near_ap, "and from the middle entry as well"); +} + +/* The only AP of the SSID is the weak one: it is still joined */ +TEST(Strongest, a_lone_weak_ap) +{ + air_reset(); + int weak = air_add("Far", 0x31, 13, -90, WIFI_AUTH_WPA2_PSK); + air_add("Home", 0x32, 1, -40, WIFI_AUTH_WPA2_PSK); + char ssid[32] = "Far"; + char pw[68] = "secret-pw"; + air_attempt_connect(ssid, pw, WIFI_AUTH_WPA2_PSK, NULL, 0); + CHECK(joined == weak, "the only AP of the SSID is joined"); +} + From c5902c85b7b025f0c0ee5703a641ae196047de08 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:27:16 -0500 Subject: [PATCH 31/95] Join the access point picked from the WiFi AP list Picking an entry of the AP list connected by its SSID alone, so with several APs under that SSID the module joined whichever its own scan chose. The list already holds each AP's BSSID and channel; the Ultimate now keeps them per entry and appends them to rpc_wifi_connect_req (bssid[6], channel). - An older module reads only the fields it knows and connects by SSID as before; a module takes the BSSID only from a request of the new length, so an older application's request is connected by SSID (now to the strongest AP). - An all-zero BSSID (the manual entry) sets none. The module sets bssid_set and the channel for that request only; if the picked AP is not found the connect fails like any other. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Claude Sonnet 5.5 --- .../tests/legacy/fix5_pick_names_any_ap.sed | 5 + software/io/wifi/tests/pick_task_test.cpp | 99 +++++++++++ software/io/wifi/tests/wifi_task_stubs.cpp | 21 ++- software/io/wifi/tests/wifi_task_test.h | 3 + software/io/wifi/wifi.cc | 6 +- software/io/wifi/wifi.h | 6 +- software/io/wifi/wifi_cmd.cc | 9 +- software/io/wifi/wifi_cmd.h | 2 +- software/u64ctrl/main/rpc_calls.h | 5 + software/u64ctrl/main/rpc_dispatch.c | 8 + software/u64ctrl/main/wifi_modem.c | 19 +- software/u64ctrl/main/wifi_modem.h | 2 + software/wifi/raw_c3/main/rpc_calls.h | 5 + software/wifi/raw_c3/main/rpc_dispatch.c | 8 + software/wifi/raw_c3/main/wifi_modem.c | 17 +- software/wifi/raw_c3/main/wifi_modem.h | 2 + software/wifi/raw_u64/main/rpc_calls.h | 5 + software/wifi/raw_u64/main/rpc_dispatch.c | 8 + software/wifi/raw_u64/main/wifi_modem.c | 17 +- software/wifi/raw_u64/main/wifi_modem.h | 2 + software/wifi/tests/Makefile | 8 +- software/wifi/tests/module_aps.h | 2 + software/wifi/tests/module_aps_stubs.c | 15 +- software/wifi/tests/module_pick_test.cpp | 167 ++++++++++++++++++ 24 files changed, 415 insertions(+), 26 deletions(-) create mode 100644 software/io/wifi/tests/legacy/fix5_pick_names_any_ap.sed create mode 100644 software/io/wifi/tests/pick_task_test.cpp create mode 100644 software/wifi/tests/module_pick_test.cpp diff --git a/software/io/wifi/tests/legacy/fix5_pick_names_any_ap.sed b/software/io/wifi/tests/legacy/fix5_pick_names_any_ap.sed new file mode 100644 index 000000000..bd0297641 --- /dev/null +++ b/software/io/wifi/tests/legacy/fix5_pick_names_any_ap.sed @@ -0,0 +1,5 @@ +# The AP list's Connect before it sent the AP picked: the request names the SSID only, and +# carries no BSSID or channel. +# variants: 1 0 2 +s/wifi_wifi_connect(bap->ssid, password, bap->auth, bap->bssid, bap->channel)/wifi_wifi_connect(bap->ssid, password, bap->auth)/ +s/memcpy(args->bssid, bssid, 6);// diff --git a/software/io/wifi/tests/pick_task_test.cpp b/software/io/wifi/tests/pick_task_test.cpp new file mode 100644 index 000000000..281808202 --- /dev/null +++ b/software/io/wifi/tests/pick_task_test.cpp @@ -0,0 +1,99 @@ +/* + * pick_task_test.cpp + * + * The AP the user picks from the list is the AP the connect request names: the BSSID and + * the channel of its scan record go to the module (through the real getAccessPointItems, + * connect_ap and wifi_wifi_connect), and a connect by SSID alone (the manual entry) sends + * them as zero. The fields a module that predates them reads stay where they were. + */ + +#include "wifi_task_test.h" + +/* The request as it was before the BSSID was added */ +typedef struct { + rpc_header_t hdr; + uint8_t auth_mode; + char ssid[32]; + char password[64]; +} old_wifi_connect_req; + +static const uint8_t zero[6] = { 0 }; + +TEST(WifiPickTask, request_layout_is_the_old_one_then_the_bssid) +{ + EXPECT_EQ(offsetof(rpc_wifi_connect_req, auth_mode), offsetof(old_wifi_connect_req, auth_mode)); + EXPECT_EQ(offsetof(rpc_wifi_connect_req, ssid), offsetof(old_wifi_connect_req, ssid)); + EXPECT_EQ(offsetof(rpc_wifi_connect_req, password), offsetof(old_wifi_connect_req, password)); + EXPECT_TRUE(offsetof(rpc_wifi_connect_req, bssid) >= offsetof(old_wifi_connect_req, password) + 64); + // a module tells the new request from the old one by its size + EXPECT_TRUE(sizeof(rpc_wifi_connect_req) > sizeof(old_wifi_connect_req)); +} + +TEST(WifiPickTask, pick_sends_the_bssid_and_the_channel) +{ + reset_world(); + world.enabled = true; + world.pick_auth = 3; + world.password = "secret-pw"; + boot({ EVENT_CONNECTED, pick }); + const rpc_wifi_connect_req *req = (const rpc_wifi_connect_req *)request.data; + CHECK(requests == 1, "one request"); + CHECK(request.size == (int)sizeof(rpc_wifi_connect_req), "the full request is sent"); + CHECK(req->hdr.command == CMD_WIFI_CONNECT, "as CMD_WIFI_CONNECT"); + char ssid[32] = "HomeNet", password[64] = "secret-pw"; // zero padded, to the end of the fields + CHECK(memcmp(req->ssid, ssid, 32) == 0, "the SSID, zero padded"); + CHECK(memcmp(req->password, password, 64) == 0, "the password, zero padded"); + CHECK(req->auth_mode == 3, "the auth mode"); + CHECK(memcmp(req->bssid, world.pick_bssid, 6) == 0, "the picked BSSID"); + CHECK(req->channel == 6, "its channel"); +} + +// Several APs share an SSID: the one picked from the list, with its own BSSID and channel +TEST(WifiPickTask, pick_from_the_list_names_that_ap) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_CONNECTED }); + wifi_aps.num_records = 2; + for (int i = 0; i < 2; i++) { + memset(&wifi_aps.aps[i], 0, sizeof(wifi_aps.aps[i])); + strcpy((char *)wifi_aps.aps[i].ssid, "Shared"); + wifi_aps.aps[i].bssid[5] = 0x10 + i; + wifi_aps.aps[i].channel = 1 + 5 * i; + } + IndexedList list(0, NULL); + CHECK(wifi.getAccessPointItems(NULL, list) == 2, "both are listed"); + SubsysCommand cmd; + cmd.functionID = (intptr_t)list[1]; + cmd.user_interface = NULL; + BrowsableWifiAP :: connect_ap(&cmd); + const rpc_wifi_connect_req *req = (const rpc_wifi_connect_req *)request.data; + CHECK(requests == 1, "one request"); + CHECK(req->bssid[5] == 0x11 && req->channel == 6, "the second one, not the first with that SSID"); +} + +TEST(WifiPickTask, ssid_only_sends_zeros) +{ + reset_world(); + wifi_wifi_connect("Home", "secret-pw", 3); + const rpc_wifi_connect_req *req = (const rpc_wifi_connect_req *)request.data; + CHECK(requests == 1, "one request"); + CHECK(memcmp(req->bssid, zero, 6) == 0, "no BSSID: all zero"); + CHECK(req->channel == 0, "no channel"); + CHECK(strncmp(req->ssid, "Home", 32) == 0, "the SSID"); +} + +// The longest password the box takes, 64 characters, goes out whole +TEST(WifiPickTask, longest_password_is_sent_whole) +{ + reset_world(); + world.enabled = true; + world.pick_auth = 3; + char pw[65]; + memset(pw, 'p', 64); + pw[64] = 0; + world.password = pw; + boot({ EVENT_CONNECTED, pick }); + const rpc_wifi_connect_req *req = (const rpc_wifi_connect_req *)request.data; + CHECK(memcmp(req->password, pw, 64) == 0, "all 64 characters"); +} diff --git a/software/io/wifi/tests/wifi_task_stubs.cpp b/software/io/wifi/tests/wifi_task_stubs.cpp index 148570e9a..a6629529a 100644 --- a/software/io/wifi/tests/wifi_task_stubs.cpp +++ b/software/io/wifi/tests/wifi_task_stubs.cpp @@ -20,6 +20,8 @@ const char *ended = ""; TickType_t now; int first_wait_state; static jmp_buf done; +static DmaUART uart; +static command_buf_context_t packets; static int calls; static int waits; @@ -74,8 +76,14 @@ void reset_world(void) saves = 0; saved_enabled = false; memset(&world, 0, sizeof(world)); + esp32.uart = &uart; // for a request made outside a script + requests = 0; world.voltages_vbus = 12000; // above the low input voltage warning (U64=2) world.pick_ssid = "HomeNet"; + static const uint8_t bssid[6] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x01 }; + memcpy(world.pick_bssid, bssid, 6); + world.pick_channel = 6; + world.password = ""; string_box_result = 1; world.popup_answer = BUTTON_YES; popups = 0; @@ -113,7 +121,7 @@ BaseType_t DmaUART :: GetBuffer(command_buf_t **b, TickType_t t) if (world.no_tx_buffer) { return pdFALSE; } - memset(&txbuf, 0, sizeof(txbuf)); + memset(&txbuf, 0xAA, sizeof(txbuf)); // a request has to set every field it sends *b = &txbuf; return pdTRUE; } @@ -137,7 +145,11 @@ void UserInterface :: activate_uiobject(TreeBrowser *tb) { note('T'); } SubsysResultCode_e NetworkLWIP_WiFi :: manual_connect(SubsysCommand *cmd) { note('k'); return SSRET_OK; } int wifi_wifi_autoconnect() { note('a'); return 0; } -int UserInterface :: string_box(const char *msg, char *buffer, int maxlen) { buffer[0] = 0; return string_box_result; } +int UserInterface :: string_box(const char *msg, char *buffer, int maxlen) +{ + strncpy(buffer, world.password, maxlen); + return string_box_result; +} void BrowsableWifiAP :: fetch_context_items(IndexedList &items) {} // The request channel: wifi_wifi_connect (cut out of wifi_cmd.cc) sends through these. The @@ -242,9 +254,6 @@ void WiFi :: RefreshAPs() {} void WiFi :: Start() {} void WiFi :: Terminate() {} -static DmaUART uart; -static command_buf_context_t packets; - void boot(std::initializer_list steps) { #if U64 != 2 @@ -295,7 +304,7 @@ const char *after(char c) void pick(void) { - BrowsableWifiAP ap(NULL, (char *)world.pick_ssid, -50, world.pick_auth); + BrowsableWifiAP ap(NULL, (char *)world.pick_ssid, -50, world.pick_auth, world.pick_bssid, world.pick_channel); UserInterface ui; SubsysCommand cmd; cmd.functionID = (intptr_t)≈ diff --git a/software/io/wifi/tests/wifi_task_test.h b/software/io/wifi/tests/wifi_task_test.h index a7e572e0a..d1f21bc23 100644 --- a/software/io/wifi/tests/wifi_task_test.h +++ b/software/io/wifi/tests/wifi_task_test.h @@ -36,6 +36,9 @@ struct World { bool loopback_fails; // the task's queue refuses an event of its own const char *pick_ssid; // the AP the user picks from the list (see pick()) int pick_auth; // and whether it wants a password + uint8_t pick_bssid[6]; // its BSSID and channel in the list + uint8_t pick_channel; + const char *password; // what the user types in the password box int popup_answer; // BUTTON_YES or BUTTON_NO, to "WiFi is disabled. Enable it?" }; extern World world; diff --git a/software/io/wifi/wifi.cc b/software/io/wifi/wifi.cc index f61eeeab7..5e66afb88 100644 --- a/software/io/wifi/wifi.cc +++ b/software/io/wifi/wifi.cc @@ -575,7 +575,8 @@ int WiFi ::getAccessPointItems(Browsable *parent, IndexedList &list } ENTER_SAFE_SECTION; for (int i = 0; i < aps->num_records; i++) { - list.append(new BrowsableWifiAP(parent, (char *)aps->aps[i].ssid, aps->aps[i].rssi, aps->aps[i].authmode)); + list.append(new BrowsableWifiAP(parent, (char *)aps->aps[i].ssid, aps->aps[i].rssi, aps->aps[i].authmode, + aps->aps[i].bssid, aps->aps[i].channel)); } LEAVE_SAFE_SECTION; return aps->num_records; @@ -599,7 +600,8 @@ SubsysResultCode_e BrowsableWifiAP :: connect_ap(SubsysCommand *cmd) cmd->user_interface->string_box("Enter password", password, 64); } } - int result = wifi_wifi_connect(bap->ssid, password, bap->auth); + // The AP picked, not just any AP with its SSID + int result = wifi_wifi_connect(bap->ssid, password, bap->auth, bap->bssid, bap->channel); printf("Connect result: %d\n", result); if (result == 0) { //wifi.sendEvent(EVENT_CONNECTED); diff --git a/software/io/wifi/wifi.h b/software/io/wifi/wifi.h index 1ef9f1d29..c91a0a645 100644 --- a/software/io/wifi/wifi.h +++ b/software/io/wifi/wifi.h @@ -115,12 +115,16 @@ class BrowsableWifiAP : public Browsable char ssid[32]; int8_t dbm; uint8_t auth; + uint8_t bssid[6]; + uint8_t channel; public: - BrowsableWifiAP(Browsable *parent, char *ssid, int8_t dbm, uint8_t auth) { + BrowsableWifiAP(Browsable *parent, char *ssid, int8_t dbm, uint8_t auth, const uint8_t *bssid, uint8_t channel) { this->parent = parent; strncpy(this->ssid, ssid, 32); this->dbm = dbm; this->auth = auth; + memcpy(this->bssid, bssid, 6); + this->channel = channel; } void getDisplayString(char *buffer, int width, UserInterface *ui) { diff --git a/software/io/wifi/wifi_cmd.cc b/software/io/wifi/wifi_cmd.cc index 594a3fcbd..d71dd47ae 100644 --- a/software/io/wifi/wifi_cmd.cc +++ b/software/io/wifi/wifi_cmd.cc @@ -299,7 +299,7 @@ int wifi_scan(void *a) RETURN_ESP; } -int wifi_wifi_connect(const char *ssid, const char *password, uint8_t auth) +int wifi_wifi_connect(const char *ssid, const char *password, uint8_t auth, const uint8_t *bssid, uint8_t channel) { BUFARGS(wifi_connect, CMD_WIFI_CONNECT); @@ -308,6 +308,13 @@ int wifi_wifi_connect(const char *ssid, const char *password, uint8_t auth) strncpy(args->ssid, ssid, 32); strncpy(args->password, password, 64); args->auth_mode = auth; + // A module that predates these ignores them + bzero(args->bssid, 6); + args->channel = 0; + if (bssid) { + memcpy(args->bssid, bssid, 6); + args->channel = channel; + } TRANSMIT_T(scan, WIFI_SLOW_TIMEOUT_MS); RETURN_ESP; diff --git a/software/io/wifi/wifi_cmd.h b/software/io/wifi/wifi_cmd.h index 660fa7e59..7c215f294 100644 --- a/software/io/wifi/wifi_cmd.h +++ b/software/io/wifi/wifi_cmd.h @@ -36,7 +36,7 @@ int wifi_setbaud(int baudrate, uint8_t flowctrl); BaseType_t wifi_detect(uint16_t *major, uint16_t *minor, char *str, int maxlen); int wifi_getmac(uint8_t *mac); int wifi_scan(void *); -int wifi_wifi_connect(const char *ssid, const char *password, uint8_t auth); +int wifi_wifi_connect(const char *ssid, const char *password, uint8_t auth, const uint8_t *bssid = NULL, uint8_t channel = 0); int wifi_wifi_autoconnect(); int wifi_wifi_disconnect(); int wifi_machine_off(); diff --git a/software/u64ctrl/main/rpc_calls.h b/software/u64ctrl/main/rpc_calls.h index 0ffb3f49e..a1b14cb06 100644 --- a/software/u64ctrl/main/rpc_calls.h +++ b/software/u64ctrl/main/rpc_calls.h @@ -72,6 +72,11 @@ typedef struct { uint8_t auth_mode; // to be casted to wifi_auth_mode_t char ssid[32]; char password[64]; + // The AP picked from the scan list. Added later: a module takes these only + // from a request this long, and an older module ignores them. All zero (or + // a shorter request): any AP with the SSID. + uint8_t bssid[6]; + uint8_t channel; } rpc_wifi_connect_req; typedef struct { diff --git a/software/u64ctrl/main/rpc_dispatch.c b/software/u64ctrl/main/rpc_dispatch.c index 6a717f227..e2f276e7c 100644 --- a/software/u64ctrl/main/rpc_dispatch.c +++ b/software/u64ctrl/main/rpc_dispatch.c @@ -106,6 +106,8 @@ void cmd_wifi_connect(command_buf_t *buf) return; } + // An application that predates the BSSID sends the shorter request + int with_bssid = (buf->size >= (int)sizeof(rpc_wifi_connect_req)); buf->size = sizeof(rpc_espcmd_resp); ConnectCommand_t ev; ev.buf = buf; @@ -115,6 +117,12 @@ void cmd_wifi_connect(command_buf_t *buf) ev.ssid[32] = 0; memcpy(&ev.pw, param->password, 64); ev.pw[64] = 0; + memset(ev.bssid, 0, 6); + ev.channel = 0; + if (with_bssid) { + memcpy(ev.bssid, param->bssid, 6); + ev.channel = param->channel; + } if (xQueueSend(connect_commands, &ev, 1000) == pdFALSE) { resp->esp_err = ESP_ERR_NO_MEM; diff --git a/software/u64ctrl/main/wifi_modem.c b/software/u64ctrl/main/wifi_modem.c index 1a9692ded..7e00fccad 100644 --- a/software/u64ctrl/main/wifi_modem.c +++ b/software/u64ctrl/main/wifi_modem.c @@ -529,7 +529,7 @@ esp_err_t wifi_set_last_ap(int index) return err; } -esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode) +esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode, const uint8_t *bssid, uint8_t channel) { if (connected_g) { esp_err_t err = esp_wifi_disconnect(); @@ -567,6 +567,15 @@ esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode // one with the strongest signal; the others stay as fallbacks. wifi_config_auto.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; wifi_config_auto.sta.sort_method = WIFI_CONNECT_AP_BY_SIGNAL; + // Unless the user picked one of them from the list: then only that one, + // with its channel scanned first. + if (bssid && memcmp(bssid, "\0\0\0\0\0\0", 6)) { + wifi_config_auto.sta.bssid_set = true; + memcpy(wifi_config_auto.sta.bssid, bssid, 6); + if ((channel >= 1) && (channel <= 13)) { + wifi_config_auto.sta.channel = channel; + } + } esp_err_t err = esp_wifi_set_config(WIFI_IF_STA, &wifi_config_auto); if (err == ESP_OK) { @@ -670,7 +679,7 @@ esp_err_t wifi_connect_to_scanned(int index) strncpy(last_connect.ssid, (const char *)(ap_info[index].ssid), 32); last_connect.ssid[32] = 0; last_connect.auth_mode = ap_info[index].authmode; - return attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + return attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode, NULL, 0); } return err; } @@ -707,7 +716,7 @@ esp_err_t wifi_connect_to_stored(int index) if (err == ESP_OK) { last_connect.list_index = index; last_connect.buf = NULL; - err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode, NULL, 0); } } } @@ -723,7 +732,7 @@ esp_err_t wifi_connect_to_hotspot(void) strncpy(last_connect.pw, recovery_hotspot_password, sizeof(last_connect.pw)); last_connect.auth_mode = WIFI_AUTH_WPA2_PSK; last_connect.list_index = -1; - return attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + return attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode, NULL, 0); } esp_err_t wifi_connect_to_last() @@ -861,7 +870,7 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) last_connect.list_index = -1; rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; if (err == ESP_OK) { - err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode, last_connect.bssid, last_connect.channel); } resp->esp_err = err; my_uart_transmit_packet(UART_NUM_1, cmd->buf); diff --git a/software/u64ctrl/main/wifi_modem.h b/software/u64ctrl/main/wifi_modem.h index 643334acd..d978e80d6 100644 --- a/software/u64ctrl/main/wifi_modem.h +++ b/software/u64ctrl/main/wifi_modem.h @@ -10,6 +10,8 @@ typedef struct { char ssid[33]; // 32 SSID bytes plus the terminator char pw[68]; uint8_t auth_mode; + uint8_t bssid[6]; // CMD_WIFI_CONNECT: the AP picked, all zero for any + uint8_t channel; // and its channel, 0 when not known uint8_t command; int16_t list_index; command_buf_t *buf; diff --git a/software/wifi/raw_c3/main/rpc_calls.h b/software/wifi/raw_c3/main/rpc_calls.h index 162db98ff..20c39a454 100644 --- a/software/wifi/raw_c3/main/rpc_calls.h +++ b/software/wifi/raw_c3/main/rpc_calls.h @@ -72,6 +72,11 @@ typedef struct { uint8_t auth_mode; // to be casted to wifi_auth_mode_t char ssid[32]; char password[64]; + // The AP picked from the scan list. Added later: a module takes these only + // from a request this long, and an older module ignores them. All zero (or + // a shorter request): any AP with the SSID. + uint8_t bssid[6]; + uint8_t channel; } rpc_wifi_connect_req; /* 42 byte AP record */ diff --git a/software/wifi/raw_c3/main/rpc_dispatch.c b/software/wifi/raw_c3/main/rpc_dispatch.c index 4b9f1d69f..d4b459a69 100644 --- a/software/wifi/raw_c3/main/rpc_dispatch.c +++ b/software/wifi/raw_c3/main/rpc_dispatch.c @@ -101,6 +101,8 @@ void cmd_wifi_connect(command_buf_t *buf) return; } + // An application that predates the BSSID sends the shorter request + int with_bssid = (buf->size >= (int)sizeof(rpc_wifi_connect_req)); buf->size = sizeof(rpc_espcmd_resp); ConnectCommand_t ev; ev.buf = buf; @@ -110,6 +112,12 @@ void cmd_wifi_connect(command_buf_t *buf) ev.ssid[32] = 0; memcpy(&ev.pw, param->password, 64); ev.pw[64] = 0; + memset(ev.bssid, 0, 6); + ev.channel = 0; + if (with_bssid) { + memcpy(ev.bssid, param->bssid, 6); + ev.channel = param->channel; + } if (xQueueSend(connect_commands, &ev, 1000) == pdFALSE) { resp->esp_err = ESP_ERR_NO_MEM; diff --git a/software/wifi/raw_c3/main/wifi_modem.c b/software/wifi/raw_c3/main/wifi_modem.c index 00878618c..277b65f48 100644 --- a/software/wifi/raw_c3/main/wifi_modem.c +++ b/software/wifi/raw_c3/main/wifi_modem.c @@ -460,7 +460,7 @@ esp_err_t wifi_set_last_ap(int index) return err; } -esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode) +esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode, const uint8_t *bssid, uint8_t channel) { if (connected_g) { esp_err_t err = esp_wifi_disconnect(); @@ -498,6 +498,15 @@ esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode // one with the strongest signal; the others stay as fallbacks. wifi_config_auto.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; wifi_config_auto.sta.sort_method = WIFI_CONNECT_AP_BY_SIGNAL; + // Unless the user picked one of them from the list: then only that one, + // with its channel scanned first. + if (bssid && memcmp(bssid, "\0\0\0\0\0\0", 6)) { + wifi_config_auto.sta.bssid_set = true; + memcpy(wifi_config_auto.sta.bssid, bssid, 6); + if ((channel >= 1) && (channel <= 13)) { + wifi_config_auto.sta.channel = channel; + } + } esp_err_t err = esp_wifi_set_config(WIFI_IF_STA, &wifi_config_auto); if (err == ESP_OK) { @@ -601,7 +610,7 @@ esp_err_t wifi_connect_to_scanned(int index) strncpy(last_connect.ssid, (const char *)(ap_info[index].ssid), 32); last_connect.ssid[32] = 0; last_connect.auth_mode = ap_info[index].authmode; - return attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + return attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode, NULL, 0); } return err; } @@ -638,7 +647,7 @@ esp_err_t wifi_connect_to_stored(int index) if (err == ESP_OK) { last_connect.list_index = index; last_connect.buf = NULL; - err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode, NULL, 0); } } } @@ -813,7 +822,7 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) last_connect.list_index = -1; rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; if (err == ESP_OK) { - err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode, last_connect.bssid, last_connect.channel); } resp->esp_err = err; my_uart_transmit_packet(UART_NUM_1, cmd->buf); diff --git a/software/wifi/raw_c3/main/wifi_modem.h b/software/wifi/raw_c3/main/wifi_modem.h index 7e5dae2c5..8c232c63e 100644 --- a/software/wifi/raw_c3/main/wifi_modem.h +++ b/software/wifi/raw_c3/main/wifi_modem.h @@ -10,6 +10,8 @@ typedef struct { char ssid[33]; // 32 SSID bytes plus the terminator char pw[68]; uint8_t auth_mode; + uint8_t bssid[6]; // CMD_WIFI_CONNECT: the AP picked, all zero for any + uint8_t channel; // and its channel, 0 when not known uint8_t command; int16_t list_index; command_buf_t *buf; diff --git a/software/wifi/raw_u64/main/rpc_calls.h b/software/wifi/raw_u64/main/rpc_calls.h index 162db98ff..20c39a454 100644 --- a/software/wifi/raw_u64/main/rpc_calls.h +++ b/software/wifi/raw_u64/main/rpc_calls.h @@ -72,6 +72,11 @@ typedef struct { uint8_t auth_mode; // to be casted to wifi_auth_mode_t char ssid[32]; char password[64]; + // The AP picked from the scan list. Added later: a module takes these only + // from a request this long, and an older module ignores them. All zero (or + // a shorter request): any AP with the SSID. + uint8_t bssid[6]; + uint8_t channel; } rpc_wifi_connect_req; /* 42 byte AP record */ diff --git a/software/wifi/raw_u64/main/rpc_dispatch.c b/software/wifi/raw_u64/main/rpc_dispatch.c index 5ec52f7c7..5ea581272 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.c +++ b/software/wifi/raw_u64/main/rpc_dispatch.c @@ -101,6 +101,8 @@ void cmd_wifi_connect(command_buf_t *buf) return; } + // An application that predates the BSSID sends the shorter request + int with_bssid = (buf->size >= (int)sizeof(rpc_wifi_connect_req)); buf->size = sizeof(rpc_espcmd_resp); ConnectCommand_t ev; ev.buf = buf; @@ -110,6 +112,12 @@ void cmd_wifi_connect(command_buf_t *buf) ev.ssid[32] = 0; memcpy(&ev.pw, param->password, 64); ev.pw[64] = 0; + memset(ev.bssid, 0, 6); + ev.channel = 0; + if (with_bssid) { + memcpy(ev.bssid, param->bssid, 6); + ev.channel = param->channel; + } if (xQueueSend(connect_commands, &ev, 1000) == pdFALSE) { resp->esp_err = ESP_ERR_NO_MEM; diff --git a/software/wifi/raw_u64/main/wifi_modem.c b/software/wifi/raw_u64/main/wifi_modem.c index 7cd88f482..1001c1031 100644 --- a/software/wifi/raw_u64/main/wifi_modem.c +++ b/software/wifi/raw_u64/main/wifi_modem.c @@ -460,7 +460,7 @@ esp_err_t wifi_set_last_ap(int index) return err; } -esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode) +esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode, const uint8_t *bssid, uint8_t channel) { if (connected_g) { esp_err_t err = esp_wifi_disconnect(); @@ -498,6 +498,15 @@ esp_err_t attempt_connect(const char *ssid, const char *passwd, uint8_t authmode // one with the strongest signal; the others stay as fallbacks. wifi_config_auto.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; wifi_config_auto.sta.sort_method = WIFI_CONNECT_AP_BY_SIGNAL; + // Unless the user picked one of them from the list: then only that one, + // with its channel scanned first. + if (bssid && memcmp(bssid, "\0\0\0\0\0\0", 6)) { + wifi_config_auto.sta.bssid_set = true; + memcpy(wifi_config_auto.sta.bssid, bssid, 6); + if ((channel >= 1) && (channel <= 13)) { + wifi_config_auto.sta.channel = channel; + } + } esp_err_t err = esp_wifi_set_config(WIFI_IF_STA, &wifi_config_auto); if (err == ESP_OK) { @@ -601,7 +610,7 @@ esp_err_t wifi_connect_to_scanned(int index) strncpy(last_connect.ssid, (const char *)(ap_info[index].ssid), 32); last_connect.ssid[32] = 0; last_connect.auth_mode = ap_info[index].authmode; - return attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + return attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode, NULL, 0); } return err; } @@ -638,7 +647,7 @@ esp_err_t wifi_connect_to_stored(int index) if (err == ESP_OK) { last_connect.list_index = index; last_connect.buf = NULL; - err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode, NULL, 0); } } } @@ -813,7 +822,7 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) last_connect.list_index = -1; rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; if (err == ESP_OK) { - err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode); + err = attempt_connect(last_connect.ssid, last_connect.pw, last_connect.auth_mode, last_connect.bssid, last_connect.channel); } resp->esp_err = err; my_uart_transmit_packet(UART_NUM_1, cmd->buf); diff --git a/software/wifi/raw_u64/main/wifi_modem.h b/software/wifi/raw_u64/main/wifi_modem.h index 7e5dae2c5..8c232c63e 100644 --- a/software/wifi/raw_u64/main/wifi_modem.h +++ b/software/wifi/raw_u64/main/wifi_modem.h @@ -10,6 +10,8 @@ typedef struct { char ssid[33]; // 32 SSID bytes plus the terminator char pw[68]; uint8_t auth_mode; + uint8_t bssid[6]; // CMD_WIFI_CONNECT: the AP picked, all zero for any + uint8_t channel; // and its channel, 0 when not known uint8_t command; int16_t list_index; command_buf_t *buf; diff --git a/software/wifi/tests/Makefile b/software/wifi/tests/Makefile index 6518b03d5..ba6b01ce6 100644 --- a/software/wifi/tests/Makefile +++ b/software/wifi/tests/Makefile @@ -54,7 +54,7 @@ NEEDED := send_event wifi_event_handler attempt_connect wifi_connect_to_sca # changed and puts back what was there before. Every one has to make the suite FAIL (a failing # check, not a build error); `make red` prints which checks failed. A fix that a module # does not have, or whose cases are not in this commit, has no entry. -RED_FIXES := 1 2 4 +RED_FIXES := 1 2 4 5 # 1 The radio switch (U64, U2+L): no Disable is served, and the radio goes on at boot, as # on a module without the switch @@ -78,6 +78,12 @@ LEGACY_4_raw_u64 := $(LEGACY_NOTSTRONGEST) LEGACY_4_raw_c3 := $(LEGACY_NOTSTRONGEST) LEGACY_4_u64ctrl := $(LEGACY_NOTSTRONGEST) +# 5 The AP picked from the list (BSSID, channel) is not honoured +LEGACY_NOPICK := -e 's/if (bssid \&\& memcmp(bssid, "\\0\\0\\0\\0\\0\\0", 6)) {/if (0) {/' +LEGACY_5_raw_u64 := $(LEGACY_NOPICK) +LEGACY_5_raw_c3 := $(LEGACY_NOPICK) +LEGACY_5_u64ctrl := $(LEGACY_NOPICK) + LEGACY = $(LEGACY_$(FIX)_$(M)) .PHONY: all test red clean radio diff --git a/software/wifi/tests/module_aps.h b/software/wifi/tests/module_aps.h index 711435436..95bece682 100644 --- a/software/wifi/tests/module_aps.h +++ b/software/wifi/tests/module_aps.h @@ -12,6 +12,8 @@ extern "C" { esp_err_t air_attempt_connect(const char *ssid, const char *pw, uint8_t auth, const uint8_t *bssid, uint8_t channel); +// The dispatcher takes a CMD_WIFI_CONNECT, then the connector handles it; true if it connected +int air_connect_request(command_buf_t *request); } /* One network, three APs: the far one on channel 1, the near one on 6, one between on 11, diff --git a/software/wifi/tests/module_aps_stubs.c b/software/wifi/tests/module_aps_stubs.c index 544d261c9..771482e85 100644 --- a/software/wifi/tests/module_aps_stubs.c +++ b/software/wifi/tests/module_aps_stubs.c @@ -7,5 +7,18 @@ esp_err_t air_attempt_connect(const char *ssid, const char *pw, uint8_t auth, const uint8_t *bssid, uint8_t channel) { - return attempt_connect(ssid, pw, auth); // the module takes the picked AP (BSSID, channel) only from fix 5 + return attempt_connect(ssid, pw, auth, bssid, channel); +} + +// The dispatcher, then the connector, as for a request from the Ultimate +int air_connect_request(command_buf_t *request) +{ + ConnectState_t state = Disconnected; + queued_count = 0; + cmd_wifi_connect(request); + if (queued_count != 1) { + return 0; + } + handle_connect_command(&queued, &state); + return state == Connected; } diff --git a/software/wifi/tests/module_pick_test.cpp b/software/wifi/tests/module_pick_test.cpp new file mode 100644 index 000000000..cb0ae5ecf --- /dev/null +++ b/software/wifi/tests/module_pick_test.cpp @@ -0,0 +1,167 @@ +/* + * module_pick_test.cpp + * + * Fix 5: the AP the user picked from the list. The dispatcher's cmd_wifi_connect() and the + * connector's handle_connect_command() are the module's own; the request is built as the + * application builds it (wifi_wifi_connect, checked byte by byte in software/io/wifi/tests). + */ + +#include +#include "module_aps.h" + +/* The request as an application that predates the BSSID sends it */ +typedef struct { + rpc_header_t hdr; + uint8_t auth_mode; + char ssid[32]; + char password[64]; +} old_wifi_connect_req; + +static command_buf_t request; + +/* A CMD_WIFI_CONNECT of `size` bytes. Whatever lies beyond it is the far AP's BSSID and + * channel, as left in the buffer by an earlier packet: a module must not read it. */ +static void make_request(int size, const char *ssid, const uint8_t *bssid, uint8_t channel) +{ + memset(&request, 0, sizeof(request)); + rpc_wifi_connect_req *req = (rpc_wifi_connect_req *)request.data; + req->hdr.command = CMD_WIFI_CONNECT; + req->auth_mode = WIFI_AUTH_WPA2_PSK; + strncpy(req->ssid, ssid, 32); + strncpy(req->password, "secret-pw", 64); + memcpy(req->bssid, air[far_ap].bssid, 6); + req->channel = air[far_ap].channel; + if (size >= (int)sizeof(rpc_wifi_connect_req)) { + memcpy(req->bssid, bssid, 6); + req->channel = channel; + } + request.size = size; +} + +/* The dispatcher, then the connector, as for a request from the Ultimate */ +static int connect_request(void) +{ + return air_connect_request(&request); +} + +TEST(Pick, picked_ap_is_joined) +{ + three_aps(); + make_request(sizeof(rpc_wifi_connect_req), "Home", air[far_ap].bssid, air[far_ap].channel); + CHECK(connect_request(), "the connect succeeds"); + CHECK(joined == far_ap, "the AP picked is joined, not the strongest"); + CHECK(last_config.sta.bssid_set && (memcmp(last_config.sta.bssid, air[far_ap].bssid, 6) == 0), "its BSSID is set"); + CHECK(last_config.sta.channel == 1, "its channel is scanned first"); + CHECK(transmitted == 1, "the Ultimate gets its answer"); +} + +TEST(Pick, picked_mid_ap_is_joined) +{ + three_aps(); + make_request(sizeof(rpc_wifi_connect_req), "Home", air[mid_ap].bssid, air[mid_ap].channel); + connect_request(); + CHECK(joined == mid_ap, "the AP picked on channel 11 is joined"); +} + +TEST(Pick, old_application_joins_the_strongest) +{ + three_aps(); + make_request(sizeof(old_wifi_connect_req), "Home", NULL, 0); + CHECK(connect_request(), "the shorter request is taken"); + CHECK(strncmp(queued.ssid, "Home", 32) == 0 && strncmp(queued.pw, "secret-pw", 64) == 0, "with its SSID and password"); + CHECK(!last_config.sta.bssid_set, "the bytes beyond it are not read as a BSSID"); + CHECK(joined == near_ap, "the strongest AP of the SSID is joined"); +} + +TEST(Pick, no_bssid_joins_the_strongest) +{ + three_aps(); + const uint8_t zero[6] = { 0 }; + make_request(sizeof(rpc_wifi_connect_req), "Home", zero, 0); + connect_request(); + CHECK(!last_config.sta.bssid_set && (last_config.sta.channel == 0), "an all zero BSSID sets none"); + CHECK(joined == near_ap, "the strongest AP of the SSID is joined"); +} + +TEST(Pick, picked_ap_gone) +{ + three_aps(); + const uint8_t gone[6] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x77 }; + make_request(sizeof(rpc_wifi_connect_req), "Home", gone, 6); + CHECK(!connect_request(), "the connect fails"); + CHECK(joined < 0, "no other AP is joined in its place"); +} + +/* The pick is for that request: the module's own walk afterwards takes the strongest */ +TEST(Pick, walk_after_a_pick) +{ + three_aps(); + make_request(sizeof(rpc_wifi_connect_req), "Home", air[far_ap].bssid, air[far_ap].channel); + connect_request(); + const int order[] = { far_ap, mid_ap, near_ap }; + air_to_scan_list(order, 3); + wifi_connect_to_scanned(0); + CHECK(!last_config.sta.bssid_set, "the walk sets no BSSID"); + CHECK(joined == near_ap, "and joins the strongest"); +} + +// The channels the module sets: 13 is the last one, 14 is none +TEST(Pick, picked_ap_on_channel_13) +{ + three_aps(); + int ch13 = air_add("Home", 0x0D, 13, -90, WIFI_AUTH_WPA2_PSK); + make_request(sizeof(rpc_wifi_connect_req), "Home", air[ch13].bssid, 13); + CHECK(connect_request(), "the connect succeeds"); + CHECK(joined == ch13, "the AP on channel 13 is joined"); + CHECK(last_config.sta.channel == 13, "its channel is scanned first"); +} + +TEST(Pick, channel_14_is_not_set) +{ + three_aps(); + make_request(sizeof(rpc_wifi_connect_req), "Home", air[mid_ap].bssid, 14); + connect_request(); + CHECK(joined == mid_ap, "the picked AP is joined by its BSSID"); + CHECK(last_config.sta.channel == 0, "a channel the module does not set is left out"); +} + +/* cmd_wifi_connect() of a module that predates the BSSID, as on master 60f16dc15 + * (raw_u64 rpc_dispatch.c), against which the new application's request must still work */ +static void old_module_cmd_wifi_connect(command_buf_t *buf) +{ + rpc_wifi_connect_req *param = (rpc_wifi_connect_req *)buf->data; + rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; + + if (buf->size < 98) { + resp->esp_err = ESP_ERR_INVALID_ARG; + my_uart_transmit_packet(UART_CHAN, buf); + return; + } + + buf->size = sizeof(rpc_espcmd_resp); + ConnectCommand_t ev; + ev.buf = buf; + ev.command = CMD_WIFI_CONNECT; + ev.auth_mode = param->auth_mode; + memcpy(&ev.ssid, param->ssid, 32); + memcpy(&ev.pw, param->password, 64); + + if (xQueueSend(connect_commands, &ev, 1000) == pdFALSE) { + resp->esp_err = ESP_ERR_NO_MEM; + my_uart_transmit_packet(UART_CHAN, buf); + return; + } + xSemaphoreGive(connect_semaphore); +} + +TEST(Pick, old_module_takes_the_new_request) +{ + three_aps(); + make_request(sizeof(rpc_wifi_connect_req), "Home", air[far_ap].bssid, air[far_ap].channel); + old_module_cmd_wifi_connect(&request); + CHECK(queued_count == 1 && transmitted == 0, "the longer request is taken, not refused"); + CHECK(strncmp(queued.ssid, "Home", 32) == 0, "the SSID where it reads it"); + CHECK(strncmp(queued.pw, "secret-pw", 64) == 0, "the password where it reads it"); + CHECK(queued.auth_mode == WIFI_AUTH_WPA2_PSK, "the auth mode where it reads it"); +} + From 233bcd6ab328f284077d3201032a436ac0b0208e Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:27:16 -0500 Subject: [PATCH 32/95] Tell the user how a connect from the Wi-Fi AP list ended The module answers a connect request as soon as ESP-IDF has accepted the attempt, and the Ultimate then queued an EVENT_CONNECTED of its own. An AP that refused the client (a wrong password) still showed as connected, brought the link up, and the later EVENT_DISCONNECTED took it down without a word. The injected packet also put last_ap one byte off. The Ultimate now queues an internal EVENT_CONNECT_PENDING and leaves the outcome to the module's own events. A refusal posts "Incorrect password" when the disconnect reason is an authentication / 4-way handshake failure (15, 202, 204), else "Could not connect to "; the same when the request is not accepted, or no outcome arrives within 20 seconds. The modules send the reason with EVENT_DISCONNECTED (the byte after the header; an older Ultimate reads the header only). Cancelling the password box sends nothing. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Claude Sonnet 5.5 --- software/io/wifi/tests/Makefile | 2 +- .../wifi/tests/connect_feedback_task_test.cpp | 181 ++++++++++++++++++ .../legacy/fix6_connect_not_reported.sed | 6 + software/io/wifi/tests/wifi_task_env.h | 4 +- software/io/wifi/tests/wifi_task_stubs.cpp | 28 ++- software/io/wifi/tests/wifi_task_test.h | 16 +- software/io/wifi/wifi.cc | 69 ++++--- software/io/wifi/wifi.h | 2 +- software/io/wifi/wifi_connect.h | 114 +++++++++++ software/test/wifi_reply/wifi_connect_test.cc | 164 ++++++++++++++++ software/u64ctrl/main/rpc_calls.h | 7 + software/u64ctrl/main/wifi_modem.c | 20 +- software/wifi/raw_c3/main/rpc_calls.h | 7 + software/wifi/raw_c3/main/wifi_modem.c | 26 ++- software/wifi/raw_u64/main/rpc_calls.h | 7 + software/wifi/raw_u64/main/wifi_modem.c | 26 ++- software/wifi/tests/Makefile | 8 +- software/wifi/tests/module_event_stubs.c | 19 ++ software/wifi/tests/module_event_test.cpp | 67 +++++++ target/pc/linux/wifireply/Makefile | 11 +- 20 files changed, 724 insertions(+), 60 deletions(-) create mode 100644 software/io/wifi/tests/connect_feedback_task_test.cpp create mode 100644 software/io/wifi/tests/legacy/fix6_connect_not_reported.sed create mode 100644 software/io/wifi/wifi_connect.h create mode 100644 software/test/wifi_reply/wifi_connect_test.cc create mode 100644 software/wifi/tests/module_event_stubs.c create mode 100644 software/wifi/tests/module_event_test.cpp diff --git a/software/io/wifi/tests/Makefile b/software/io/wifi/tests/Makefile index d3ef69741..0205792be 100644 --- a/software/io/wifi/tests/Makefile +++ b/software/io/wifi/tests/Makefile @@ -31,7 +31,7 @@ OUT := $(if $(LEG),output/red_$(basename $(notdir $(LEG)))_u64_$(U64),output/u64 # Function names are given as written in the source (~ for a blank), so that the C++ method # of a class is found. Those of wifi_switch.h's users exist for the products other than the U64=2 only. WIFI_FUNCS := WiFi~::~WiFi WiFi~::~Init WiFi~::~Enable WiFi~::~Disable WiFi~::~RadioOn \ - WiFi~::~RadioOff WiFi~::~RunModeThread WiFi~::~sendEvent WiFi~::~sendConnectEvent WiFi~::getAccessPointItems \ + WiFi~::~RadioOff WiFi~::~RunModeThread WiFi~::~sendEvent WiFi~::~sendConnectPending WiFi~::getAccessPointItems \ BrowsableWifiAP~::~connect_ap WIFI_FUNCS_SWITCH := WiFi~::~TalksToModule NET_FUNCS := NetworkLWIP_WiFi~::~disable NetworkLWIP_WiFi~::~enable NetworkLWIP_WiFi~::~ask_enable \ diff --git a/software/io/wifi/tests/connect_feedback_task_test.cpp b/software/io/wifi/tests/connect_feedback_task_test.cpp new file mode 100644 index 000000000..e6e58b650 --- /dev/null +++ b/software/io/wifi/tests/connect_feedback_task_test.cpp @@ -0,0 +1,181 @@ +/* + * connect_feedback_task_test.cpp + * + * What a connect from the AP list does to the WiFi interface and tells the user, through + * the real connect_ap and WiFi :: RunModeThread: the interface stays down and the state + * stays as it was until the module reports an outcome, a refused client ends in a message + * and no link, a joined one in the link, last_ap and a message, and no outcome ends in a + * message after the timeout. And the wait of the task when both a radio-off confirmation + * and a connect outcome are due: it wakes at the earlier one. + */ + +#include "wifi_task_test.h" + +static bool linked_up(void) { return strchr(rlog, 'U') != NULL; } + +// The module accepted the request; nothing has come from it yet +TEST(WifiConnectFeedbackTask, accepted_is_not_connected) +{ + reset_world(); + world.enabled = true; + boot({ pick }); + CHECK(!linked_up(), "no link before the outcome"); + CHECK(wifi.getState() == eWifi_NotConnected, "not Connected before the outcome"); +} + +TEST(WifiConnectFeedbackTask, wrong_password) +{ + reset_world(); + world.enabled = true; + boot({ pick, disconnected(15) }); + CHECK(!linked_up(), "the link never comes up"); + CHECK(wifi.getState() == eWifi_NotConnected, "not Connected"); + CHECK(strcmp(messages, "Incorrect password\n") == 0, "told so"); +} + +TEST(WifiConnectFeedbackTask, refused_for_other_reasons) +{ + reset_world(); + world.enabled = true; + boot({ pick, disconnected(201) }); + CHECK(strcmp(messages, "Could not connect to HomeNet\n") == 0, "no AP: generic message"); + boot({ pick, Step(EVENT_DISCONNECTED) }); + CHECK(strcmp(messages, "Could not connect to HomeNet\n") == 0, "old module: generic message"); + CHECK(!linked_up(), "no link"); +} + +TEST(WifiConnectFeedbackTask, joined) +{ + reset_world(); + world.enabled = true; + boot({ pick, Step(EVENT_CONNECTED, "HomeNet") }); + CHECK(linked_up(), "the link comes up on the outcome"); + CHECK(wifi.getState() == eWifi_Connected, "Connected"); + CHECK(strcmp(wifi.getLastAP(), "HomeNet") == 0, "last_ap is the ssid, not shifted"); + CHECK(messages[0] == 0, "no message: the row going up says it"); +} + +// Connected to another AP: its drop is not the outcome of the pick +TEST(WifiConnectFeedbackTask, switching) +{ + reset_world(); + world.enabled = true; + world.link = 1; + boot({ disconnected(8), pick, Step(EVENT_CONNECTED, "HomeNet") }); + CHECK(messages[0] == 0, "nothing to report"); + CHECK(wifi.getState() == eWifi_Connected, "Connected"); + boot({ disconnected(8), pick, disconnected(202) }); + CHECK(strcmp(messages, "Incorrect password\n") == 0, "the refusal of the pick is reported"); + CHECK(wifi.getState() == eWifi_NotConnected, "not Connected"); +} + +// The module's leave of the AP it was on is part of the connect, whenever it is reported +TEST(WifiConnectFeedbackTask, ordering) +{ + reset_world(); + world.enabled = true; + world.link = 1; + boot({ disconnected(8), pick, Step(EVENT_CONNECTED, "HomeNet") }); + CHECK(messages[0] == 0 && wifi.getState() == eWifi_Connected, "leave, pick, joined"); + boot({ pick, disconnected(8), Step(EVENT_CONNECTED, "HomeNet") }); + CHECK(messages[0] == 0 && wifi.getState() == eWifi_Connected, "pick, leave, joined"); + boot({ pick, disconnected(8), disconnected(202) }); + CHECK(strcmp(messages, "Incorrect password\n") == 0, "pick, leave, refused"); + boot({ pick, disconnected(202) }); + CHECK(strcmp(messages, "Incorrect password\n") == 0, "picked while Connected, refused"); + boot({ pick, disconnected(8) }); + CHECK(strcmp(messages, "Could not connect to HomeNet\n") == 0 && waited > 0, "the leave alone is no outcome"); +} + +TEST(WifiConnectFeedbackTask, long_ssid) +{ + reset_world(); + world.enabled = true; + const char *name = "0123456789abcdef0123456789abcdef"; + world.pick_ssid = name; + boot({ pick, Step(EVENT_DISCONNECTED) }); + CHECK(strcmp(messages, "Could not connect to 0123456789abcdef0123456789abcdef\n") == 0, "32 characters"); + boot({ pick, Step(EVENT_CONNECTED, name) }); + CHECK(memcmp(wifi.last_ap, name, 32) == 0, "last_ap, 32 characters"); +} + +// No outcome: the wait is bounded +TEST(WifiConnectFeedbackTask, no_outcome) +{ + reset_world(); + world.enabled = true; + boot({ pick }); + CHECK(strcmp(messages, "Could not connect to HomeNet\n") == 0, "told after the timeout"); + CHECK(message_at - 1000 == (20 * configTICK_RATE_HZ), "not before it"); + CHECK(!linked_up(), "no link"); + CHECK(strcmp(ended, "waiting for an event") == 0, "and the task waits without a bound again"); +} + +// The module did not accept the request, or the task cannot be told: nothing is pending +TEST(WifiConnectFeedbackTask, not_accepted) +{ + reset_world(); + world.enabled = true; + world.connect_result = 0x103; // ESP_ERR_INVALID_STATE + boot({ pick }); + CHECK(strcmp(messages, "Could not connect to HomeNet\n") == 0, "told"); + CHECK(waited == 0, "without waiting for an outcome"); + CHECK(!linked_up(), "no link"); + world.connect_result = 0; + world.connect_noreply = true; + boot({ pick }); + CHECK(strcmp(messages, "Could not connect to HomeNet\n") == 0, "told when the module does not answer"); + CHECK(waited == 0, "at once"); + world.connect_noreply = false; + world.loopback_fails = true; + boot({ pick }); + CHECK(strcmp(messages, "Could not connect to HomeNet\n") == 0, "told when the event is refused"); + CHECK(waited == 0, "at once"); +} + +// Cancelling the password box connects to nothing +TEST(WifiConnectFeedbackTask, cancelled) +{ + reset_world(); + world.enabled = true; + world.pick_auth = 1; + string_box_result = -1; + boot({ pick }); + CHECK(requests == 0, "no request"); + CHECK(messages[0] == 0, "no message"); + string_box_result = 1; + boot({ pick }); + CHECK(requests == 1, "a password is sent"); +} + +#if U64 != 2 +// A radio-off confirmation due in 10 s, and a connect outcome due in 20 s: the task wakes +// when the radio-off one is due, then when the other is. The pick comes while the boot's +// radio off waits for its confirmation (the task is not Disabled yet). +TEST(WifiConnectFeedbackTask, wakes_for_the_radio_off_deadline_first) +{ + reset_world(); + world.enabled = false; + boot({ pick }); + CHECK(timed_waits_n >= 2, "two bounded waits"); + CHECK(timed_waits[0] == pdMS_TO_TICKS(WIFI_SWITCH_CONFIRM_MS), "the first ends at the radio off deadline, 10 s"); + CHECK(strcmp(messages, "Could not connect to HomeNet\n") == 0, "then the outcome is reported"); + CHECK(message_at == 1000 + (20 * configTICK_RATE_HZ), "exactly at its deadline, 20 s"); +} + +// The reverse: the radio off is asked again (the module restarted) when the connect outcome +// is almost due. The task wakes for the outcome, which is due first, not 10 s later. +TEST(WifiConnectFeedbackTask, wakes_for_the_connect_deadline_first) +{ + reset_world(); + world.enabled = true; + const TickType_t picked_at = 1000; + boot({ pick, + late(Step(EVENT_DISABLED), 1000), + late(Step(EVENT_RESTARTED), (20 * configTICK_RATE_HZ) - 1500) }); + // the pick at 1000 gives a deadline at 1000 + 4000; the restart comes at 4500 + CHECK(strchr(rlog, 'O') != NULL, "the radio off is asked again"); + CHECK(strcmp(messages, "Could not connect to HomeNet\n") == 0, "the outcome is reported"); + CHECK(message_at == picked_at + (20 * configTICK_RATE_HZ), "at its deadline, not at the radio off one"); +} +#endif diff --git a/software/io/wifi/tests/legacy/fix6_connect_not_reported.sed b/software/io/wifi/tests/legacy/fix6_connect_not_reported.sed new file mode 100644 index 000000000..e5329b9fb --- /dev/null +++ b/software/io/wifi/tests/legacy/fix6_connect_not_reported.sed @@ -0,0 +1,6 @@ +# The AP list's Connect before the user was told how it ended: nothing is queued for the +# task to follow, so there is no message and no timeout, and a cancelled password box +# connects with an empty password. +# variants: 1 0 2 +s/if (result != 0 || !wifi\.sendConnectPending(bap->ssid)) {/if (0) {/ +s/password, 64) <= 0) {/password, 64) < -99) {/ diff --git a/software/io/wifi/tests/wifi_task_env.h b/software/io/wifi/tests/wifi_task_env.h index 1a6211eb0..c521aee68 100644 --- a/software/io/wifi/tests/wifi_task_env.h +++ b/software/io/wifi/tests/wifi_task_env.h @@ -4,7 +4,7 @@ * The world the Ultimate's WiFi application sees on the build host. The code under test is * cut out of wifi.cc, wifi_cmd.cc and network_esp32.cc as it is (by the Makefile, with * extract.awk) and put behind this header. The real wifi.h, esp32.h, wifi_cmd.h and - * wifi_switch.h (and wifi_connect.h, where the tree has it) are used; the RTOS, the UART, + * wifi_switch.h and wifi_connect.h are used; the RTOS, the UART, * the browsable tree and the network interface are the stand-ins of stubs/ and below, * which record what is called (wifi_task_stubs.cpp). * @@ -29,9 +29,7 @@ typedef int err_t; #include "browsable.h" #include "dump_hex.h" #include "wifi.h" -#if __has_include("wifi_connect.h") #include "wifi_connect.h" -#endif #include "wifi_enable_default.h" // CFG_WIFI_ENABLE and the default of that setting, from network_esp32.cc / .h // The AP list's browser, as far as the menu uses it diff --git a/software/io/wifi/tests/wifi_task_stubs.cpp b/software/io/wifi/tests/wifi_task_stubs.cpp index a6629529a..79c772fc6 100644 --- a/software/io/wifi/tests/wifi_task_stubs.cpp +++ b/software/io/wifi/tests/wifi_task_stubs.cpp @@ -103,6 +103,10 @@ static int queue_n, queue_i; static command_buf_t pool[8]; static int pool_i; TickType_t waited; +TickType_t timed_waits[8]; +int timed_waits_n; +TickType_t message_at; +static TickType_t queue_delay[16]; int requests; command_buf_t request; int string_box_result = 1; @@ -129,6 +133,7 @@ BaseType_t DmaUART :: GetBuffer(command_buf_t **b, TickType_t t) void UserInterface :: postMessage(const char *msg) { note('!'); + message_at = now; strncat(messages, msg, sizeof(messages) - strlen(messages) - 2); strcat(messages, "\n"); } @@ -183,7 +188,9 @@ BaseType_t cmd_buffer_loopback(command_buf_context_t *context, command_buf_t *b) return pdFALSE; } memmove(&queue[queue_i + 1], &queue[queue_i], (queue_n - queue_i) * sizeof(queue[0])); + memmove(&queue_delay[queue_i + 1], &queue_delay[queue_i], (queue_n - queue_i) * sizeof(queue_delay[0])); queue[queue_i] = *b; + queue_delay[queue_i] = 0; queue_n++; return pdTRUE; } @@ -198,9 +205,18 @@ BaseType_t cmd_buffer_received(command_buf_context_t *context, command_buf_t **b void (*act)(void) = (void (*)(void))queue[queue_i++].object; act(); } + if (t != portMAX_DELAY && timed_waits_n < 8) { + timed_waits[timed_waits_n++] = t; + } if (queue_i < queue_n) { - *b = &queue[queue_i++]; - return pdTRUE; + TickType_t d = queue_delay[queue_i]; + if (d == 0 || t == portMAX_DELAY || d < t) { + now += d; // the time it waited for this one + waited += d; + *b = &queue[queue_i++]; + return pdTRUE; + } + queue_delay[queue_i] -= t; // the wait ran out first } if (t == portMAX_DELAY) { stop("waiting for an event"); @@ -269,12 +285,15 @@ void boot(std::initializer_list steps) waits = 0; now = 1000; waited = 0; + timed_waits_n = 0; + message_at = 0; requests = 0; pool_i = 0; queue_n = queue_i = 0; for (std::initializer_list::const_iterator s = steps.begin(); s != steps.end(); ++s) { command_buf_t *b = &queue[queue_n++]; memset(b, 0, sizeof(*b)); + queue_delay[queue_n - 1] = s->delay; if (s->act) { b->bufnr = ACT; b->object = (void *)s->act; @@ -285,6 +304,11 @@ void boot(std::initializer_list steps) if (s->code == EVENT_CONNECTED && s->ssid) { strncpy((char *)((event_pkt_connected *)b->data)->ssid, s->ssid, 32); b->size = sizeof(event_pkt_connected); + } else if (s->code == EVENT_DISCONNECTED && s->reason >= 0) { + ((event_pkt_disconnected *)b->data)->reason = s->reason; + b->size = sizeof(event_pkt_disconnected); + } else if (s->code == EVENT_DISCONNECTED) { + b->data[sizeof(rpc_header_t)] = 15; // a bare header: what follows it is no reason } } wifi.netstack = &net; diff --git a/software/io/wifi/tests/wifi_task_test.h b/software/io/wifi/tests/wifi_task_test.h index d1f21bc23..1212f128a 100644 --- a/software/io/wifi/tests/wifi_task_test.h +++ b/software/io/wifi/tests/wifi_task_test.h @@ -55,6 +55,9 @@ extern int first_wait_state; // the task's state when it first waits for an even extern TickType_t waited; // the ticks the task waited for events that did not come extern WiFi wifi; extern NetworkLWIP_WiFi net; +extern TickType_t timed_waits[8]; // the bounded waits the task asked for, in order +extern int timed_waits_n; +extern TickType_t message_at; // the clock when the last message was posted extern int requests; // requests that went to the module (connect) extern command_buf_t request; // the last one, as it went out extern int string_box_result; // what the password box returns: <= 0 is a cancel @@ -66,10 +69,17 @@ struct Step { const char *ssid; int reason; void (*act)(void); - Step(int c) : code(c), ssid(NULL), reason(-1), act(NULL) {} - Step(int c, const char *s) : code(c), ssid(s), reason(-1), act(NULL) {} - Step(void (*a)(void)) : code(0), ssid(NULL), reason(-1), act(a) {} + TickType_t delay; // the ticks the task has waited when this one comes + Step(int c) : code(c), ssid(NULL), reason(-1), act(NULL), delay(0) {} + Step(int c, const char *s) : code(c), ssid(s), reason(-1), act(NULL), delay(0) {} + Step(void (*a)(void)) : code(0), ssid(NULL), reason(-1), act(a), delay(0) {} }; +// EVENT_DISCONNECTED with the reason (the module's wifi_event_sta_disconnected_t.reason); +// Step(EVENT_DISCONNECTED) is the bare header of a module that does not tell +static inline Step disconnected(int reason) { Step s(EVENT_DISCONNECTED); s.reason = reason; return s; } +// The step comes only after the task has waited this long for an event; one that waits less +// than that, gets nothing +static inline Step late(Step s, TickType_t ticks) { s.delay = ticks; return s; } // Starts the WiFi task with the module found, and these steps in order void boot(std::initializer_list steps); diff --git a/software/io/wifi/wifi.cc b/software/io/wifi/wifi.cc index 5e66afb88..1d154c92d 100644 --- a/software/io/wifi/wifi.cc +++ b/software/io/wifi/wifi.cc @@ -6,6 +6,7 @@ */ #include "wifi.h" +#include "wifi_connect.h" #include "socket.h" #include "u64.h" #include "dump_hex.h" @@ -250,6 +251,9 @@ void WiFi :: RunModeThread() state = eWifi_NotDetected; uint8_t conn; uint32_t ip; + WifiConnectFeedback feedback; + char feedback_msg[80]; + TickType_t wait_ticks; RefreshRoot(); static char boot_message[256]; @@ -394,9 +398,18 @@ void WiFi :: RunModeThread() case eWifi_NotConnected: case eWifi_Connected: case eWifi_Disabled: + if (feedback.onTick(xTaskGetTickCount(), feedback_msg, sizeof(feedback_msg))) { + UserInterface :: postMessage(feedback_msg); + } + wait_ticks = feedback.waitTicks(xTaskGetTickCount()); #if U64 != 2 wait = wifi_switch_wait(&radio_switch, xTaskGetTickCount()); - if (cmd_buffer_received(packets, &buf, (wait < 0) ? portMAX_DELAY : (TickType_t)wait) != pdTRUE) { + if ((wait >= 0) && ((TickType_t)wait < wait_ticks)) { + wait_ticks = wait; + } +#endif + if (cmd_buffer_received(packets, &buf, wait_ticks) != pdTRUE) { +#if U64 != 2 // The radio off was not confirmed in time: take the link state from the // module again if (wifi_switch_expired(&radio_switch, xTaskGetTickCount())) { @@ -414,11 +427,9 @@ void WiFi :: RunModeThread() } RefreshRoot(); } - break; - } -#else - cmd_buffer_received(packets, &buf, portMAX_DELAY); #endif + break; // the wait for the outcome of a connect ran out; the next pass reports it + } hdr = (rpc_header_t *)(buf->data); #if DEBUG_INPUT printf("Pkt %d. Ev %b. Sz %d. Seq: %d\n", buf->bufnr, hdr->command, buf->size, hdr->sequence); @@ -470,6 +481,7 @@ void WiFi :: RunModeThread() case EVENT_CONNECTED: ev2 = (event_pkt_connected *)buf->data; memcpy(last_ap, ev2->ssid, 32); + feedback.onConnected(); uart->FreeBuffer(buf); if (state == eWifi_Connected) { // already connected! netstack->link_down(); @@ -482,7 +494,17 @@ void WiFi :: RunModeThread() RefreshRoot(); break; + case EVENT_CONNECT_PENDING: // the module accepted a connect from the AP list + ev2 = (event_pkt_connected *)buf->data; + feedback.begin(ev2->ssid, xTaskGetTickCount()); + uart->FreeBuffer(buf); + break; + case EVENT_DISCONNECTED: + // the reason is read before the buffer goes back to the UART, which may refill it + if (feedback.onDisconnected(wifi_disconnect_reason(buf->data, buf->size), feedback_msg, sizeof(feedback_msg))) { + UserInterface :: postMessage(feedback_msg); + } uart->FreeBuffer(buf); state = eWifi_NotConnected; if(netstack) { @@ -542,22 +564,22 @@ void WiFi :: sendEvent(uint8_t code) cmd_buffer_loopback(packets, buf); // internal event } -// This event also updates the configuration. -void WiFi :: sendConnectEvent(const char *ssid, const char *pass, uint8_t auth) +// The module accepted a connect request; its own event will tell the outcome. +bool WiFi :: sendConnectPending(const char *ssid) { command_buf_t *buf; cmd_buffer_get(packets, &buf, portMAX_DELAY); - // reuse of the rpc structure; but of course it is not sent to the module - rpc_wifi_connect_req *args = (rpc_wifi_connect_req *)(buf->data); - args->hdr.command = EVENT_CONNECTED; - args->hdr.sequence = 0; - args->hdr.thread = 0xFF; - bzero(args->ssid, 32); - bzero(args->password, 64); - strncpy(args->ssid, ssid, 32); - strncpy(args->password, pass, 64); - args->auth_mode = auth; - cmd_buffer_loopback(packets, buf); // internal event + event_pkt_connected *ev = (event_pkt_connected *)(buf->data); + ev->hdr.command = EVENT_CONNECT_PENDING; + ev->hdr.sequence = 0; + ev->hdr.thread = 0xFF; + bzero(ev->ssid, 32); + strncpy((char *)ev->ssid, ssid, 32); + if (cmd_buffer_loopback(packets, buf) != pdTRUE) { // internal event + uart->FreeBuffer(buf); + return false; + } + return true; } void WiFi :: freeBuffer(command_buf_t *buf) @@ -597,15 +619,18 @@ SubsysResultCode_e BrowsableWifiAP :: connect_ap(SubsysCommand *cmd) } if (bap->auth) { if(cmd->user_interface) { - cmd->user_interface->string_box("Enter password", password, 64); + if (cmd->user_interface->string_box("Enter password", password, 64) <= 0) { + return SSRET_OK; // cancelled: nothing to connect with + } } } // The AP picked, not just any AP with its SSID int result = wifi_wifi_connect(bap->ssid, password, bap->auth, bap->bssid, bap->channel); printf("Connect result: %d\n", result); - if (result == 0) { - //wifi.sendEvent(EVENT_CONNECTED); - wifi.sendConnectEvent(bap->ssid, password, bap->auth); + if (result != 0 || !wifi.sendConnectPending(bap->ssid)) { + char msg[64]; + snprintf(msg, sizeof(msg), "Could not connect to %.32s", bap->ssid); + UserInterface :: postMessage(msg); } return SSRET_OK; } diff --git a/software/io/wifi/wifi.h b/software/io/wifi/wifi.h index c91a0a645..1e064724f 100644 --- a/software/io/wifi/wifi.h +++ b/software/io/wifi/wifi.h @@ -85,8 +85,8 @@ class WiFi : public Esp32Application char *getIpAddrString(char *buf, int max) { sprintf(buf, "%d.%d.%d.%d", (my_ip >> 0) & 0xff, (my_ip >> 8) & 0xff, (my_ip >> 16) & 0xff, (my_ip >> 24) & 0xff); return buf; } void sendEvent(uint8_t code); - void sendConnectEvent(const char *ssid, const char *pass, uint8_t auth); void sendEventWhenEnabled(uint8_t code) { event_when_enabled = code; } // after the radio is on again + bool sendConnectPending(const char *ssid); void freeBuffer(command_buf_t *buf); int getAccessPointItems(Browsable *parent, IndexedList &list); diff --git a/software/io/wifi/wifi_connect.h b/software/io/wifi/wifi_connect.h new file mode 100644 index 000000000..3f1b83d4f --- /dev/null +++ b/software/io/wifi/wifi_connect.h @@ -0,0 +1,114 @@ +/* + * wifi_connect.h + * + * What a manual connect from the access point list tells the user. The module + * answers the connect request as soon as ESP-IDF has accepted the attempt, which + * says nothing about the outcome: that is the module's own EVENT_CONNECTED, or an + * EVENT_DISCONNECTED when the access point refuses the client. The task notes the + * accepted attempt here, and the outcome (or the lack of one) becomes a message. + */ +#ifndef WIFI_CONNECT_H_ +#define WIFI_CONNECT_H_ + +#include +#include +#include +#include "rpc_calls.h" + +// Internal event, queued by the user interface once the module has accepted a +// connect request. It carries the same payload as the module's EVENT_CONNECTED. +#define EVENT_CONNECT_PENDING 0x7F + +// Longer than a join normally takes (a few seconds), shorter than a user waits. +// The tick is 5 ms (configTICK_RATE_HZ 200). +#define WIFI_CONNECT_TIMEOUT_TICKS (20 * 200) + +// The reason of the module's EVENT_DISCONNECTED, 0 when it does not tell (a bare +// header from a module without it). The numbers are the station's: ESP-IDF's +// wifi_err_reason_t, which are the 802.11 reason codes, and 200 and up of its own. +static inline uint8_t wifi_disconnect_reason(const void *pkt, int size) +{ + if (size < (int)sizeof(event_pkt_disconnected)) { + return 0; + } + return ((const event_pkt_disconnected *)pkt)->reason; +} + +// The module's own leave of the access point it was on, which it does as part of a connect +#define WIFI_REASON_ASSOC_LEAVE 8 + +// Authentication or the 4-way handshake failed: the access point took the client +// for one with the wrong key (WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT, _AUTH_FAIL, +// _HANDSHAKE_TIMEOUT; the same values in ESP-IDF 5.3.1 and 6.0.3) +static inline bool wifi_disconnect_is_password(uint8_t reason) +{ + return reason == 15 || reason == 202 || reason == 204; +} + +class WifiConnectFeedback +{ + bool pending; + uint32_t deadline; + char ssid[33]; + + static void fail(char *msg, int max, const char *ssid) + { + snprintf(msg, max, "Could not connect to %s", ssid); + } +public: + WifiConnectFeedback() : pending(false), deadline(0) { ssid[0] = 0; } + + // The module accepted a connect request; the outcome is still to come + void begin(const uint8_t *ssid32, uint32_t now) + { + memcpy(ssid, ssid32, 32); + ssid[32] = 0; + deadline = now + WIFI_CONNECT_TIMEOUT_TICKS; + pending = true; + } + + bool isPending(void) const { return pending; } + + // How long the task can wait for its next event + uint32_t waitTicks(uint32_t now) const + { + if (!pending) { + return 0xFFFFFFFFUL; + } + int32_t left = (int32_t)(deadline - now); + return (left > 0) ? (uint32_t)left : 0; + } + + // The module reports the link up; the row going up is the user's signal + void onConnected(void) { pending = false; } + + // The module reports the link down; reason is wifi_disconnect_reason of its packet + bool onDisconnected(uint8_t reason, char *msg, int max) + { + // WIFI_REASON_ASSOC_LEAVE is the module's own leave of the access point it was on, + // which it does as part of the connect. Its event can follow the acceptance. + if (!pending || reason == WIFI_REASON_ASSOC_LEAVE) { + return false; + } + pending = false; + if (wifi_disconnect_is_password(reason)) { + snprintf(msg, max, "Incorrect password"); + } else { + fail(msg, max, ssid); + } + return true; + } + + // Called before every wait, so a busy queue cannot hold the timeout off + bool onTick(uint32_t now, char *msg, int max) + { + if (!pending || (int32_t)(deadline - now) > 0) { + return false; + } + pending = false; + fail(msg, max, ssid); + return true; + } +}; + +#endif /* WIFI_CONNECT_H_ */ diff --git a/software/test/wifi_reply/wifi_connect_test.cc b/software/test/wifi_reply/wifi_connect_test.cc new file mode 100644 index 000000000..06382c736 --- /dev/null +++ b/software/test/wifi_reply/wifi_connect_test.cc @@ -0,0 +1,164 @@ +/* + * Host test of wifi_connect.h: what the user is told after the module accepted a + * connect from the access point list. The acceptance says nothing about the + * outcome, so there is no message until the module's own event, or the timeout. + */ +#include +#include +typedef uint16_t u16_t; // for rpc_calls.h; the stub FreeRTOS.h would widen uint32_t +#include "wifi_connect.h" + +static int failures; +#define CHECK(c) do { if (!(c)) { printf("FAIL line %d: %s\n", __LINE__, #c); failures++; } } while (0) + +static uint8_t ssid32[32]; +static char msg[80]; + +static void set_ssid(const char *s) +{ + memset(ssid32, 0, sizeof(ssid32)); + strncpy((char *)ssid32, s, 32); +} + +static void test_refused(void) +{ + WifiConnectFeedback fb; + set_ssid("HomeNet"); + fb.begin(ssid32, 1000); + CHECK(fb.isPending()); + CHECK(!fb.onTick(1001, msg, sizeof(msg))); // the acceptance is not an outcome + CHECK(fb.onDisconnected(0, msg, sizeof(msg))); + CHECK(strcmp(msg, "Could not connect to HomeNet") == 0); + CHECK(!fb.isPending()); + CHECK(!fb.onDisconnected(0, msg, sizeof(msg))); // one message per attempt + CHECK(fb.waitTicks(1002) == 0xFFFFFFFFUL); +} + +// The module's EVENT_DISCONNECTED: a bare header, or with the reason +static int module_disconnected(event_pkt_disconnected *ev, int reason) +{ + memset(ev, 0, sizeof(*ev)); + ev->hdr.command = EVENT_DISCONNECTED; + ev->hdr.thread = 0xFF; + ev->reason = reason; + return reason < 0 ? sizeof(rpc_header_t) : sizeof(*ev); +} + +static const char *refused_with(int reason) +{ + WifiConnectFeedback fb; + set_ssid("HomeNet"); + fb.begin(ssid32, 1000); + event_pkt_disconnected ev; + int size = module_disconnected(&ev, reason); + if (reason < 0) { + ev.reason = 15; // what follows a bare header is not a reason + } + CHECK(fb.onDisconnected(wifi_disconnect_reason(&ev, size), msg, sizeof(msg))); + return msg; +} + +static void test_reasons(void) +{ + CHECK(strcmp(refused_with(-1), "Could not connect to HomeNet") == 0); // an old module + CHECK(strcmp(refused_with(15), "Incorrect password") == 0); + CHECK(strcmp(refused_with(202), "Incorrect password") == 0); + CHECK(strcmp(refused_with(204), "Incorrect password") == 0); + CHECK(strcmp(refused_with(201), "Could not connect to HomeNet") == 0); // no AP + CHECK(strcmp(refused_with(2), "Could not connect to HomeNet") == 0); + CHECK(strcmp(refused_with(9), "Could not connect to HomeNet") == 0); +} + +static void test_connected(void) +{ + WifiConnectFeedback fb; + set_ssid("HomeNet"); + fb.begin(ssid32, 1000); + fb.onConnected(); + CHECK(!fb.isPending()); + CHECK(!fb.onDisconnected(0, msg, sizeof(msg))); // a later drop is not a failed connect +} + +static void test_32_character_ssid(void) +{ + WifiConnectFeedback fb; + const char *name = "0123456789abcdef0123456789abcdef"; + set_ssid(name); + fb.begin(ssid32, 5); + CHECK(fb.onDisconnected(0, msg, sizeof(msg))); + CHECK(strcmp(msg, "Could not connect to 0123456789abcdef0123456789abcdef") == 0); +} + +static void test_timeout(void) +{ + WifiConnectFeedback fb; + set_ssid("HomeNet"); + fb.begin(ssid32, 1000); + uint32_t t = fb.waitTicks(1000); + CHECK(t == WIFI_CONNECT_TIMEOUT_TICKS); + CHECK(t == 20 * 200); // 20 s of 5 ms ticks + CHECK(fb.waitTicks(1000 + t / 2) == t - t / 2); + CHECK(!fb.onTick(1000 + t - 1, msg, sizeof(msg))); + CHECK(fb.waitTicks(1000 + t + 7) == 0); + CHECK(fb.onTick(1000 + t, msg, sizeof(msg))); + CHECK(strcmp(msg, "Could not connect to HomeNet") == 0); + CHECK(!fb.isPending()); + CHECK(!fb.onTick(1000 + t + 1, msg, sizeof(msg))); +} + +static void test_tick_wrap(void) +{ + WifiConnectFeedback fb; + set_ssid("HomeNet"); + fb.begin(ssid32, 0xFFFFFF00UL); + CHECK(fb.waitTicks(0xFFFFFF00UL) == WIFI_CONNECT_TIMEOUT_TICKS); + CHECK(!fb.onTick(5, msg, sizeof(msg))); + CHECK(fb.onTick(0xFFFFFF00UL + WIFI_CONNECT_TIMEOUT_TICKS, msg, sizeof(msg))); +} + +static void test_not_a_manual_connect(void) +{ + // The module's own reconnects say nothing to the user + WifiConnectFeedback fb; + fb.onConnected(); + CHECK(!fb.onDisconnected(0, msg, sizeof(msg))); + CHECK(!fb.onTick(1u << 31, msg, sizeof(msg))); +} + +// The module's own leave of the AP it was on is no outcome, before or after the acceptance +static void test_leave_is_no_outcome(void) +{ + WifiConnectFeedback fb; + set_ssid("HomeNet"); + fb.begin(ssid32, 1000); + CHECK(!fb.onDisconnected(8, msg, sizeof(msg))); + CHECK(fb.isPending()); + CHECK(fb.onDisconnected(202, msg, sizeof(msg))); + CHECK(strcmp(msg, "Incorrect password") == 0); +} + +static void test_second_attempt(void) +{ + WifiConnectFeedback fb; + set_ssid("First"); + fb.begin(ssid32, 100); + set_ssid("Second"); + fb.begin(ssid32, 200); + CHECK(fb.onDisconnected(0, msg, sizeof(msg))); + CHECK(strcmp(msg, "Could not connect to Second") == 0); +} + +int main(void) +{ + test_refused(); + test_reasons(); + test_connected(); + test_32_character_ssid(); + test_timeout(); + test_tick_wrap(); + test_not_a_manual_connect(); + test_leave_is_no_outcome(); + test_second_attempt(); + printf(failures ? "wifi_connect: %d FAILED\n" : "wifi_connect: all passed\n", failures); + return failures != 0; +} diff --git a/software/u64ctrl/main/rpc_calls.h b/software/u64ctrl/main/rpc_calls.h index a1b14cb06..f545f84e3 100644 --- a/software/u64ctrl/main/rpc_calls.h +++ b/software/u64ctrl/main/rpc_calls.h @@ -201,6 +201,13 @@ typedef struct { uint8_t ssid[32]; } event_pkt_connected; +// EVENT_DISCONNECTED may carry the reason (wifi_event_sta_disconnected_t.reason) +// after the header. 0 and a bare header both mean that it is not known. +typedef struct { + rpc_header_t hdr; + uint8_t reason; +} event_pkt_disconnected; + #define CMD_ECHO 0x01 #define CMD_IDENTIFY 0x02 #define CMD_SET_BAUD 0x03 diff --git a/software/u64ctrl/main/wifi_modem.c b/software/u64ctrl/main/wifi_modem.c index 7e00fccad..360b196be 100644 --- a/software/u64ctrl/main/wifi_modem.c +++ b/software/u64ctrl/main/wifi_modem.c @@ -240,7 +240,8 @@ static void got_ip_event_handler(void *esp_netif, esp_event_base_t base, int32_t } } -static void send_event(uint8_t evcode) +// reason: what EVENT_DISCONNECTED says (0: unknown, as for a disconnect this module makes up) +static void send_event(uint8_t evcode, uint8_t reason) { command_buf_t *reply; if (my_uart_get_buffer(UART_NUM_1, &reply, 100)) { @@ -253,6 +254,9 @@ static void send_event(uint8_t evcode) event_pkt_connected *ev2 = (event_pkt_connected *)reply->data; memcpy(ev2->ssid, last_connect.ssid, 32); reply->size = sizeof(event_pkt_connected); + } else if (evcode == EVENT_DISCONNECTED) { + ((event_pkt_disconnected *)reply->data)->reason = reason; + reply->size = sizeof(event_pkt_disconnected); } ESP_LOGI(TAG, "Sending event %d to ultimate", evcode); if(my_uart_transmit_packet(UART_NUM_1, reply) == pdFALSE) { @@ -266,9 +270,9 @@ static void send_event(uint8_t evcode) void wifi_send_connected_event(void) { if(connected_g) { - send_event(EVENT_CONNECTED); + send_event(EVENT_CONNECTED, 0); } else if(disabled_g) { - send_event(EVENT_DISABLED); + send_event(EVENT_DISABLED, 0); } } @@ -278,6 +282,7 @@ static void wifi_event_handler(void *esp_netif, esp_event_base_t base, int32_t e ConnectEvent_t cev; uint8_t evcode = 0; + uint8_t disc_reason = 0; switch(event_id) { case WIFI_EVENT_STA_START: // Attaching the lwIP netif resets netif->input, so a machine that @@ -289,6 +294,7 @@ static void wifi_event_handler(void *esp_netif, esp_event_base_t base, int32_t e break; case WIFI_EVENT_STA_DISCONNECTED: evcode = EVENT_DISCONNECTED; + disc_reason = data ? ((const wifi_event_sta_disconnected_t *)data)->reason : 0; cev.event_code = evcode; xQueueSend(connect_events, &cev, 10); xSemaphoreGive(connect_semaphore); @@ -305,7 +311,7 @@ static void wifi_event_handler(void *esp_netif, esp_event_base_t base, int32_t e break; } if (evcode) { - send_event(evcode); + send_event(evcode, disc_reason); } } @@ -774,7 +780,7 @@ esp_err_t enable_wifi_if_needed(ConnectState_t state) ESP_LOGI(TAG, "Starting WiFi."); esp_err_t err = esp_wifi_start(); if (err == ESP_OK) { - send_event(EVENT_DISCONNECTED); + send_event(EVENT_DISCONNECTED, 0); disabled_g = 0; } else { ESP_LOGW(TAG, "Failed to start WiFi: %d", err); @@ -805,7 +811,7 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) ESP_LOGI(TAG, "Stopping WiFi."); err = esp_wifi_stop(); if (err == ESP_OK) { - send_event(EVENT_DISABLED); + send_event(EVENT_DISABLED, 0); *state = Disabled; disabled_g = 1; return 1; @@ -821,7 +827,7 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) ESP_LOGI(TAG, "Starting WiFi."); err = esp_wifi_start(); if (err == ESP_OK) { - send_event(EVENT_DISCONNECTED); + send_event(EVENT_DISCONNECTED, 0); *state = LastAP; disabled_g = 0; return 1; diff --git a/software/wifi/raw_c3/main/rpc_calls.h b/software/wifi/raw_c3/main/rpc_calls.h index 20c39a454..986972c06 100644 --- a/software/wifi/raw_c3/main/rpc_calls.h +++ b/software/wifi/raw_c3/main/rpc_calls.h @@ -153,6 +153,13 @@ typedef struct { uint8_t ssid[32]; } event_pkt_connected; +// EVENT_DISCONNECTED may carry the reason (wifi_event_sta_disconnected_t.reason) +// after the header. 0 and a bare header both mean that it is not known. +typedef struct { + rpc_header_t hdr; + uint8_t reason; +} event_pkt_disconnected; + #define CMD_ECHO 0x01 #define CMD_IDENTIFY 0x02 #define CMD_SET_BAUD 0x03 diff --git a/software/wifi/raw_c3/main/wifi_modem.c b/software/wifi/raw_c3/main/wifi_modem.c index 277b65f48..5386b98b5 100644 --- a/software/wifi/raw_c3/main/wifi_modem.c +++ b/software/wifi/raw_c3/main/wifi_modem.c @@ -189,7 +189,8 @@ static void got_ip_event_handler(void *esp_netif, esp_event_base_t base, int32_t } } -static void send_event(uint8_t evcode) +// reason: what EVENT_DISCONNECTED says (0: unknown, as for a disconnect this module makes up) +static void send_event(uint8_t evcode, uint8_t reason) { command_buf_t *reply; if (my_uart_get_buffer(UART_NUM_1, &reply, 100)) { @@ -202,6 +203,9 @@ static void send_event(uint8_t evcode) event_pkt_connected *ev2 = (event_pkt_connected *)reply->data; memcpy(ev2->ssid, last_connect.ssid, 32); reply->size = sizeof(event_pkt_connected); + } else if (evcode == EVENT_DISCONNECTED) { + ((event_pkt_disconnected *)reply->data)->reason = reason; + reply->size = sizeof(event_pkt_disconnected); } my_uart_transmit_packet(UART_NUM_1, reply); } else { @@ -215,9 +219,13 @@ static void wifi_event_handler(void *esp_netif, esp_event_base_t base, int32_t e ConnectEvent_t cev; uint8_t evcode = 0; + uint8_t disc_reason = 0; switch(event_id) { case WIFI_EVENT_STA_DISCONNECTED: evcode = EVENT_DISCONNECTED; + if (data) { + disc_reason = ((const wifi_event_sta_disconnected_t *)data)->reason; + } cev.event_code = evcode; xQueueSend(connect_events, &cev, 10); xSemaphoreGive(connect_semaphore); @@ -235,7 +243,7 @@ static void wifi_event_handler(void *esp_netif, esp_event_base_t base, int32_t e } if (evcode) { - send_event(evcode); + send_event(evcode, disc_reason); } } @@ -701,7 +709,7 @@ esp_err_t enable_wifi_if_needed(ConnectState_t state) if (err == ESP_OK) { disabled_g = 0; radio_record_set(&radio_record, true); - send_event(EVENT_DISCONNECTED); + send_event(EVENT_DISCONNECTED, 0); } else { ESP_LOGW(TAG, "Failed to start WiFi: %d", err); } @@ -732,7 +740,7 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) ESP_LOGI(TAG, "Stopping WiFi."); err = radio_stop(); if (err == ESP_OK) { - send_event(EVENT_DISABLED); + send_event(EVENT_DISABLED, 0); *state = Disabled; disabled_g = 1; radio_record_set(&radio_record, false); @@ -751,7 +759,7 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) if (err == ESP_OK) { disabled_g = 0; radio_record_set(&radio_record, true); - send_event(EVENT_DISCONNECTED); + send_event(EVENT_DISCONNECTED, 0); *state = LastAP; return 1; } else { @@ -774,14 +782,14 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) if (err == ESP_OK) { disabled_g = 0; radio_record_set(&radio_record, true); - send_event(EVENT_DISCONNECTED); + send_event(EVENT_DISCONNECTED, 0); *state = LastAP; return 1; } ESP_LOGW(TAG, "Failed to start WiFi: %d", err); } if (*state == Disabled) { - send_event(EVENT_DISABLED); + send_event(EVENT_DISABLED, 0); } break; case CMD_WIFI_SCAN: @@ -855,13 +863,13 @@ ConnectState_t connector_boot_state(void) if (boot_mode == RADIO_BOOT_WAIT) { return Disabled; } - send_event(EVENT_RESTARTED); + send_event(EVENT_RESTARTED, 0); if (boot_mode == RADIO_BOOT_ON) { ESP_LOGI(TAG, "Restarted: starting WiFi again."); if (radio_start() == ESP_OK) { disabled_g = 0; radio_record_set(&radio_record, true); - send_event(EVENT_DISCONNECTED); + send_event(EVENT_DISCONNECTED, 0); return LastAP; } ESP_LOGW(TAG, "Failed to start WiFi."); diff --git a/software/wifi/raw_u64/main/rpc_calls.h b/software/wifi/raw_u64/main/rpc_calls.h index 20c39a454..986972c06 100644 --- a/software/wifi/raw_u64/main/rpc_calls.h +++ b/software/wifi/raw_u64/main/rpc_calls.h @@ -153,6 +153,13 @@ typedef struct { uint8_t ssid[32]; } event_pkt_connected; +// EVENT_DISCONNECTED may carry the reason (wifi_event_sta_disconnected_t.reason) +// after the header. 0 and a bare header both mean that it is not known. +typedef struct { + rpc_header_t hdr; + uint8_t reason; +} event_pkt_disconnected; + #define CMD_ECHO 0x01 #define CMD_IDENTIFY 0x02 #define CMD_SET_BAUD 0x03 diff --git a/software/wifi/raw_u64/main/wifi_modem.c b/software/wifi/raw_u64/main/wifi_modem.c index 1001c1031..b8a6ef949 100644 --- a/software/wifi/raw_u64/main/wifi_modem.c +++ b/software/wifi/raw_u64/main/wifi_modem.c @@ -189,7 +189,8 @@ static void got_ip_event_handler(void *esp_netif, esp_event_base_t base, int32_t } } -static void send_event(uint8_t evcode) +// reason: what EVENT_DISCONNECTED says (0: unknown, as for a disconnect this module makes up) +static void send_event(uint8_t evcode, uint8_t reason) { command_buf_t *reply; if (my_uart_get_buffer(UART_NUM_1, &reply, 100)) { @@ -202,6 +203,9 @@ static void send_event(uint8_t evcode) event_pkt_connected *ev2 = (event_pkt_connected *)reply->data; memcpy(ev2->ssid, last_connect.ssid, 32); reply->size = sizeof(event_pkt_connected); + } else if (evcode == EVENT_DISCONNECTED) { + ((event_pkt_disconnected *)reply->data)->reason = reason; + reply->size = sizeof(event_pkt_disconnected); } my_uart_transmit_packet(UART_NUM_1, reply); } else { @@ -215,9 +219,13 @@ static void wifi_event_handler(void *esp_netif, esp_event_base_t base, int32_t e ConnectEvent_t cev; uint8_t evcode = 0; + uint8_t disc_reason = 0; switch(event_id) { case WIFI_EVENT_STA_DISCONNECTED: evcode = EVENT_DISCONNECTED; + if (data) { + disc_reason = ((const wifi_event_sta_disconnected_t *)data)->reason; + } cev.event_code = evcode; xQueueSend(connect_events, &cev, 10); xSemaphoreGive(connect_semaphore); @@ -235,7 +243,7 @@ static void wifi_event_handler(void *esp_netif, esp_event_base_t base, int32_t e } if (evcode) { - send_event(evcode); + send_event(evcode, disc_reason); } } @@ -701,7 +709,7 @@ esp_err_t enable_wifi_if_needed(ConnectState_t state) if (err == ESP_OK) { disabled_g = 0; radio_record_set(&radio_record, true); - send_event(EVENT_DISCONNECTED); + send_event(EVENT_DISCONNECTED, 0); } else { ESP_LOGW(TAG, "Failed to start WiFi: %d", err); } @@ -732,7 +740,7 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) ESP_LOGI(TAG, "Stopping WiFi."); err = radio_stop(); if (err == ESP_OK) { - send_event(EVENT_DISABLED); + send_event(EVENT_DISABLED, 0); *state = Disabled; disabled_g = 1; radio_record_set(&radio_record, false); @@ -751,7 +759,7 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) if (err == ESP_OK) { disabled_g = 0; radio_record_set(&radio_record, true); - send_event(EVENT_DISCONNECTED); + send_event(EVENT_DISCONNECTED, 0); *state = LastAP; return 1; } else { @@ -774,14 +782,14 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) if (err == ESP_OK) { disabled_g = 0; radio_record_set(&radio_record, true); - send_event(EVENT_DISCONNECTED); + send_event(EVENT_DISCONNECTED, 0); *state = LastAP; return 1; } ESP_LOGW(TAG, "Failed to start WiFi: %d", err); } if (*state == Disabled) { - send_event(EVENT_DISABLED); + send_event(EVENT_DISABLED, 0); } break; case CMD_WIFI_SCAN: @@ -855,13 +863,13 @@ ConnectState_t connector_boot_state(void) if (boot_mode == RADIO_BOOT_WAIT) { return Disabled; } - send_event(EVENT_RESTARTED); + send_event(EVENT_RESTARTED, 0); if (boot_mode == RADIO_BOOT_ON) { ESP_LOGI(TAG, "Restarted: starting WiFi again."); if (radio_start() == ESP_OK) { disabled_g = 0; radio_record_set(&radio_record, true); - send_event(EVENT_DISCONNECTED); + send_event(EVENT_DISCONNECTED, 0); return LastAP; } ESP_LOGW(TAG, "Failed to start WiFi."); diff --git a/software/wifi/tests/Makefile b/software/wifi/tests/Makefile index ba6b01ce6..530dda747 100644 --- a/software/wifi/tests/Makefile +++ b/software/wifi/tests/Makefile @@ -54,7 +54,7 @@ NEEDED := send_event wifi_event_handler attempt_connect wifi_connect_to_sca # changed and puts back what was there before. Every one has to make the suite FAIL (a failing # check, not a build error); `make red` prints which checks failed. A fix that a module # does not have, or whose cases are not in this commit, has no entry. -RED_FIXES := 1 2 4 5 +RED_FIXES := 1 2 4 5 6 # 1 The radio switch (U64, U2+L): no Disable is served, and the radio goes on at boot, as # on a module without the switch @@ -84,6 +84,12 @@ LEGACY_5_raw_u64 := $(LEGACY_NOPICK) LEGACY_5_raw_c3 := $(LEGACY_NOPICK) LEGACY_5_u64ctrl := $(LEGACY_NOPICK) +# 6 EVENT_DISCONNECTED does not carry the reason +LEGACY_NOREASON := -e 's/->reason = reason;/->reason = 0;/' +LEGACY_6_raw_u64 := $(LEGACY_NOREASON) +LEGACY_6_raw_c3 := $(LEGACY_NOREASON) +LEGACY_6_u64ctrl := $(LEGACY_NOREASON) + LEGACY = $(LEGACY_$(FIX)_$(M)) .PHONY: all test red clean radio diff --git a/software/wifi/tests/module_event_stubs.c b/software/wifi/tests/module_event_stubs.c new file mode 100644 index 000000000..d31d00828 --- /dev/null +++ b/software/wifi/tests/module_event_stubs.c @@ -0,0 +1,19 @@ +/* + * module_event_stubs.c + * + * The calls the event cases make into the module's code (module_event_test.cpp). Included at the + * end of module_stubs.c. + */ + +// The event handler and send_event(), as the cases call them +void module_event(int event, const wifi_event_sta_disconnected_t *data) +{ + sent_n = 0; + wifi_event_handler(NULL, NULL, event, (void *)data); +} + +void module_send_event(uint8_t evcode, uint8_t reason) +{ + sent_n = 0; + send_event(evcode, reason); +} diff --git a/software/wifi/tests/module_event_test.cpp b/software/wifi/tests/module_event_test.cpp new file mode 100644 index 000000000..1b976ca71 --- /dev/null +++ b/software/wifi/tests/module_event_test.cpp @@ -0,0 +1,67 @@ +/* + * module_event_test.cpp + * + * Fix 6: what the ESP32 modules put on the UART for a disconnect and a connect of the + * station. EVENT_DISCONNECTED is the header plus one byte (padded to + * sizeof(event_pkt_disconnected)), the reason ESP-IDF gives (0 when it gives none), so that + * an Ultimate that does not know the byte reads the header only; EVENT_CONNECTED is + * unchanged. The control module also makes up disconnects, which say 0. wifi_event_handler + * and send_event are the module's own. + */ + +#include +#include +#include "module_script.h" + +extern "C" { +void module_event(int event, const wifi_event_sta_disconnected_t *data); +void module_send_event(uint8_t evcode, uint8_t reason); +} + +TEST(Event, disconnect_carries_the_reason) +{ + EXPECT_EQ(offsetof(event_pkt_disconnected, reason), sizeof(rpc_header_t)); + wifi_event_sta_disconnected_t d; + memset(&d, 0, sizeof(d)); + static const uint8_t reasons[] = { 15, 202, 204, 8, 1 }; + for (unsigned i = 0; i < sizeof(reasons); i++) { + d.reason = reasons[i]; + module_event(WIFI_EVENT_STA_DISCONNECTED, &d); + EXPECT_EQ(sent_n, 1); + EXPECT_EQ((int)sent.data[0], EVENT_DISCONNECTED); + EXPECT_EQ((int)sent.data[1], 0xFF); // thread: for the task's queue + EXPECT_EQ(sent.size, (int)sizeof(event_pkt_disconnected)); + EXPECT_EQ((int)sent.data[sizeof(rpc_header_t)], (int)reasons[i]); + } +} + +TEST(Event, disconnect_without_data_says_unknown) +{ + module_event(WIFI_EVENT_STA_DISCONNECTED, NULL); + EXPECT_EQ(sent_n, 1); + EXPECT_EQ(sent.size, (int)sizeof(event_pkt_disconnected)); + EXPECT_EQ((int)sent.data[sizeof(rpc_header_t)], (int)0); +} + +TEST(Event, connect_event_is_unchanged) +{ + strcpy(last_connect.ssid, "HomeNet"); + module_event(WIFI_EVENT_STA_CONNECTED, NULL); + EXPECT_EQ(sent_n, 1); + EXPECT_EQ((int)sent.data[0], EVENT_CONNECTED); + EXPECT_EQ(sent.size, (int)sizeof(event_pkt_connected)); + EXPECT_EQ(memcmp(((event_pkt_connected *)sent.data)->ssid, "HomeNet", 8), 0); +} + +// A disconnect the module makes up does not carry the reason of an earlier one +TEST(Event, made_up_disconnect_says_unknown) +{ + wifi_event_sta_disconnected_t d; + memset(&d, 0, sizeof(d)); + d.reason = 15; + module_event(WIFI_EVENT_STA_DISCONNECTED, &d); + module_send_event(EVENT_DISCONNECTED, 0); + EXPECT_EQ(sent_n, 1); + EXPECT_EQ(sent.size, (int)sizeof(event_pkt_disconnected)); + EXPECT_EQ((int)sent.data[sizeof(rpc_header_t)], (int)0); +} diff --git a/target/pc/linux/wifireply/Makefile b/target/pc/linux/wifireply/Makefile index 02d232bfc..d025ea974 100644 --- a/target/pc/linux/wifireply/Makefile +++ b/target/pc/linux/wifireply/Makefile @@ -1,6 +1,7 @@ # # Host build of the reply table of the WiFi command channel, and of -# wifi_cmd.cc against stubs of the UART and the RTOS. +# wifi_cmd.cc against stubs of the UART and the RTOS, and of what wifi_connect.h +# tells the user after a connect from the access point list. # # make build # make test build and run @@ -27,10 +28,11 @@ SRCS_C = wifi_reply_test.c OBJS = $(addprefix $(OUTPUT)/, $(SRCS_C:%.c=%.o)) CMD_SRC = $(PATH_SW)/io/wifi/wifi_cmd.cc $(PATH_SW)/test/wifi_reply/wifi_cmd_test.cc CMD_DEP = $(wildcard $(PATH_SW)/io/wifi/*.h $(STUBS)/*.h) +CONN_SRC = $(PATH_SW)/test/wifi_reply/wifi_connect_test.cc .PHONY: all test legacy clean -all: $(RESULT)/$(PRJ) $(RESULT)/wifi_cmd +all: $(RESULT)/$(PRJ) $(RESULT)/wifi_cmd $(RESULT)/wifi_connect $(OUTPUT)/%.o: %.c wifi_reply.h @mkdir -p $(OUTPUT) @@ -44,11 +46,16 @@ $(RESULT)/wifi_cmd: $(CMD_SRC) $(CMD_DEP) @mkdir -p $(RESULT) $(CXX) $(CXXOPTIONS) -o $@ $(CMD_SRC) +$(RESULT)/wifi_connect: $(CONN_SRC) $(CMD_DEP) + @mkdir -p $(RESULT) + $(CXX) $(CXXOPTIONS) -o $@ $(CONN_SRC) + test: all @$(RESULT)/$(PRJ) @mkdir -p $(OUTPUT) @$(RESULT)/wifi_cmd > $(OUTPUT)/wifi_cmd.log || { grep '^FAIL' $(OUTPUT)/wifi_cmd.log; tail -n 1 $(OUTPUT)/wifi_cmd.log; exit 1; } @tail -n 1 $(OUTPUT)/wifi_cmd.log + @$(RESULT)/wifi_connect legacy: @mkdir -p $(OUTPUT) From 7bfa836a93084754535c1673c5d513de97f9436b Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:27:17 -0500 Subject: [PATCH 33/95] Bump the WiFi modules' identities for the changes above The Ultimate's updater only reflashes a module when its identity differs from what the module reports: raw_u64 and raw_c3 1.8, u64ctrl 1.22. Placeholders for the maintainer to assign at merge. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/main/rpc_dispatch.h | 8 ++++++-- software/wifi/raw_c3/main/rpc_dispatch.h | 10 ++++++++-- software/wifi/raw_u64/main/rpc_dispatch.h | 10 ++++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/software/u64ctrl/main/rpc_dispatch.h b/software/u64ctrl/main/rpc_dispatch.h index 285b96df4..506fb1001 100644 --- a/software/u64ctrl/main/rpc_dispatch.h +++ b/software/u64ctrl/main/rpc_dispatch.h @@ -26,8 +26,12 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.22" +#define IDENT_STRING "ESP32 WiFi Bridge V1.23" #define IDENT_MAJOR 1 +// 1.23: a Disable or Autoconnect during the AP list walks is no longer lost, Enable +// reconnects after a Disconnect, a Scan while Disabled is refused and a Connect leaves +// Disabled. Joins the strongest access point of an SSID, or the one the Ultimate picked +// when it sends its BSSID. EVENT_DISCONNECTED carries the reason the station gave. // 1.22: built with ESP-IDF 6.0.3; the recovery code uses PSA Crypto (mbedTLS 4). // 1.21: a recovery trusts Mozilla's root list of 2026-10-20 (software/u64ctrl/ca), which // no longer holds the emSign roots G3, C1 and C3, instead of the one in ESP-IDF 5.3.1. @@ -43,7 +47,7 @@ void send_keepalive(); // when this is higher than what the module reports, so a module change that // does not bump it is silently never installed, and an older release never // replaces a newer module. -#define IDENT_MINOR 22 +#define IDENT_MINOR 23 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 diff --git a/software/wifi/raw_c3/main/rpc_dispatch.h b/software/wifi/raw_c3/main/rpc_dispatch.h index ca36e1e81..c29bbe597 100644 --- a/software/wifi/raw_c3/main/rpc_dispatch.h +++ b/software/wifi/raw_c3/main/rpc_dispatch.h @@ -24,8 +24,14 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.8" +#define IDENT_STRING "ESP32 WiFi Bridge V1.9" #define IDENT_MAJOR 1 +// 1.9: turns its radio off and on when asked (CMD_WIFI_DISABLE / CMD_WIFI_ENABLE) and +// starts with it off until the Ultimate sends Enable or Autoconnect (or, without the +// switch, asks for the connection state); after a restart of its own it puts the radio +// back as it was and sends EVENT_RESTARTED. Joins the strongest access point of an +// SSID, or the one the Ultimate picked when it sends its BSSID. EVENT_DISCONNECTED +// carries the reason the station gave. // 1.8: built with ESP-IDF 6.0.3. Labels the image; the U2+L updater does not compare it. // 1.7: terminates 32-character SSIDs and 64-character passwords, and reads // them back from NVS whole. @@ -33,7 +39,7 @@ void send_keepalive(); // Disconnected forever. The Ultimate's updater only reflashes the module // when this differs from what the module reports, so a module change that // does not bump it is silently never installed. -#define IDENT_MINOR 8 +#define IDENT_MINOR 9 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 diff --git a/software/wifi/raw_u64/main/rpc_dispatch.h b/software/wifi/raw_u64/main/rpc_dispatch.h index d9479fbbf..7723374f7 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.h +++ b/software/wifi/raw_u64/main/rpc_dispatch.h @@ -26,8 +26,14 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.8" +#define IDENT_STRING "ESP32 WiFi Bridge V1.9" #define IDENT_MAJOR 1 +// 1.9: turns its radio off and on when asked (CMD_WIFI_DISABLE / CMD_WIFI_ENABLE) and +// starts with it off until the Ultimate sends Enable or Autoconnect (or, without the +// switch, asks for the connection state); after a restart of its own it puts the radio +// back as it was and sends EVENT_RESTARTED. Joins the strongest access point of an +// SSID, or the one the Ultimate picked when it sends its BSSID. EVENT_DISCONNECTED +// carries the reason the station gave. // 1.8: built with ESP-IDF 6.0.3. // 1.7: terminates 32-character SSIDs and 64-character passwords, and reads // them back from NVS whole. @@ -35,7 +41,7 @@ void send_keepalive(); // Disconnected forever. The Ultimate's updater only reflashes the module // when this differs from what the module reports, so a module change that // does not bump it is silently never installed. -#define IDENT_MINOR 8 +#define IDENT_MINOR 9 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 From 817b9f8fa8ae57afbc39d4f1ef42cbc262689a64 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 30 Oct 2026 15:06:41 -0500 Subject: [PATCH 34/95] Review fixes for the WiFi series: pass every WiFi Enabled change on, confirm a runtime Disable, end a pick with the radio - "WiFi Enabled": the change hook acted on the state the task shows, which follows the module's events and lags behind them. An Enable and a Disable (or the reverse) made faster than the module answers left the radio in the state of the first and the setting in that of the second. Every change is now passed to the module (both requests are harmless when the module is in that state already). - A Disable at runtime is confirmed as the boot's is: Disabled is shown when the module says so, its link events are dropped until then, and an unconfirmed one is asked again at the deadline. wifi_switch_later / off_pending and the start-state branches of RadioOn / RadioOff could not be reached any more (the hook returns before them while the module is being found); they and WiFi :: TalksToModule are removed. - A Disable ends a connect from the AP list that is still pending, so no "Could not connect" follows 20 s later while WiFi is off. - "Select AP from list" while Disabled arms the scan for when the radio is on before it sends the Enable, and drops it when the user says No. - Comments that named test directories that do not exist now name the real ones. - Tests: the two quick-toggle orders, the runtime Disable (confirmed, link events dropped, unconfirmed), a Disable during a pending pick, a Disable while an AP list scan runs, the armed scan dropped on No, the buffer given back when the pending event is refused. Co-Authored-By: Claude Sonnet 5.5 --- software/io/network/network_esp32.cc | 15 ++- software/io/wifi/tests/Makefile | 6 +- .../wifi/tests/connect_feedback_task_test.cpp | 27 ++++- software/io/wifi/tests/disabled_task_test.cpp | 1 + software/io/wifi/tests/switch_task_test.cpp | 104 ++++++++++++------ software/io/wifi/tests/wifi_switch_test.cpp | 16 --- software/io/wifi/tests/wifi_task_stubs.cpp | 3 +- software/io/wifi/tests/wifi_task_test.h | 1 + software/io/wifi/wifi.cc | 49 ++------- software/io/wifi/wifi.h | 1 - software/io/wifi/wifi_connect.h | 3 + software/io/wifi/wifi_switch.h | 17 +-- software/wifi/common/radio_boot.h | 2 +- software/wifi/common/wifi_radio.h | 3 +- 14 files changed, 129 insertions(+), 119 deletions(-) diff --git a/software/io/network/network_esp32.cc b/software/io/network/network_esp32.cc index 65ed61ef5..c346af75a 100644 --- a/software/io/network/network_esp32.cc +++ b/software/io/network/network_esp32.cc @@ -133,18 +133,18 @@ bool NetworkLWIP_WiFi :: enabled_in_config(void) // A change of "WiFi Enabled" turns the radio off or on right away. While the WiFi // application is still looking for the module it does nothing: the application applies -// the setting itself when it finds it. +// the setting itself when it finds it. Every change is passed on, whatever the row shows: +// the row follows the module's events, which can lag behind a quick Enable and Disable, +// and both requests are harmless when the module is in that state already. int NetworkLWIP_WiFi :: wifi_enable_change(ConfigItem *it) { WifiState_t state = wifi.getState(); if ((state == eWifi_Download) || (state == eWifi_NotDetected) || (state == eWifi_ModuleDetected)) { return 0; } - // Also while a radio off waits for its confirmation: an Enable then is not lost - bool off = (state == eWifi_Off) || (state == eWifi_Disabled) || wifi.RadioOffAwaited(); - if (it->getValue() && off) { + if (it->getValue()) { wifi.RadioOn(); - } else if (!it->getValue() && !off) { + } else if (state != eWifi_Off) { // the application is stopped (a module without the switch): off already wifi.RadioOff(); } return 0; @@ -316,10 +316,13 @@ void NetworkLWIP_WiFi :: cfg_show_aps(UserInterface *intf, ConfigItem *it) { WifiState_t state = wifi.getState(); if (state == eWifi_Disabled) { + // Set before the Enable goes out: the module's event for it can reach the WiFi + // application before this function returns + wifi.sendEventWhenEnabled(EVENT_RESCAN); // the radio is not on yet if (!ask_enable(intf)) { + wifi.sendEventWhenEnabled(0); return; } - wifi.sendEventWhenEnabled(EVENT_RESCAN); // the radio is not on yet } else if ((state != eWifi_NotConnected) && (state != eWifi_Connected)) { intf->popup("Can only show APs when active", BUTTON_OK); return; diff --git a/software/io/wifi/tests/Makefile b/software/io/wifi/tests/Makefile index 0205792be..d9af725a0 100644 --- a/software/io/wifi/tests/Makefile +++ b/software/io/wifi/tests/Makefile @@ -29,11 +29,10 @@ LEG ?= OUT := $(if $(LEG),output/red_$(basename $(notdir $(LEG)))_u64_$(U64),output/u64_$(U64)) # Function names are given as written in the source (~ for a blank), so that the C++ method -# of a class is found. Those of wifi_switch.h's users exist for the products other than the U64=2 only. +# of a class is found. WIFI_FUNCS := WiFi~::~WiFi WiFi~::~Init WiFi~::~Enable WiFi~::~Disable WiFi~::~RadioOn \ WiFi~::~RadioOff WiFi~::~RunModeThread WiFi~::~sendEvent WiFi~::~sendConnectPending WiFi~::getAccessPointItems \ BrowsableWifiAP~::~connect_ap -WIFI_FUNCS_SWITCH := WiFi~::~TalksToModule NET_FUNCS := NetworkLWIP_WiFi~::~disable NetworkLWIP_WiFi~::~enable NetworkLWIP_WiFi~::~ask_enable \ NetworkLWIP_WiFi~::~cfg_show_aps NetworkLWIP_WiFi~::~cfg_enter_ap NetworkLWIP_WiFi~::~cfg_conn_last NET_FUNCS_SWITCH := NetworkLWIP_WiFi~::~wifi_enable_change NetworkLWIP_WiFi~::~set_enabled \ @@ -79,9 +78,6 @@ $(OUT)/task.cc: Makefile $(WIFI_CC) $(NET_CC) $(CMD_CC) $(EXTRACT) $(LEG) wifi_t @mkdir -p $(OUT) @{ echo '#include "wifi_task_env.h"'; \ $(foreach f,$(WIFI_FUNCS),$(call extract,$(f),$(WIFI_CC));) \ - echo '#if U64 != 2'; \ - $(foreach f,$(WIFI_FUNCS_SWITCH),$(call extract,$(f),$(WIFI_CC));) \ - echo '#endif'; \ $(foreach f,$(NET_FUNCS),$(call extract,$(f),$(NET_CC));) \ echo '#if U64 != 2'; \ $(foreach f,$(NET_FUNCS_SWITCH),$(call extract,$(f),$(NET_CC));) \ diff --git a/software/io/wifi/tests/connect_feedback_task_test.cpp b/software/io/wifi/tests/connect_feedback_task_test.cpp index e6e58b650..3445ec8ba 100644 --- a/software/io/wifi/tests/connect_feedback_task_test.cpp +++ b/software/io/wifi/tests/connect_feedback_task_test.cpp @@ -128,7 +128,9 @@ TEST(WifiConnectFeedbackTask, not_accepted) CHECK(waited == 0, "at once"); world.connect_noreply = false; world.loopback_fails = true; + frees = 0; boot({ pick }); + CHECK(frees == 2, "the connect reply's buffer and the one the event was built in go back to the UART"); CHECK(strcmp(messages, "Could not connect to HomeNet\n") == 0, "told when the event is refused"); CHECK(waited == 0, "at once"); } @@ -148,6 +150,20 @@ TEST(WifiConnectFeedbackTask, cancelled) CHECK(requests == 1, "a password is sent"); } +static void user_turns_off(void) { NetworkLWIP_WiFi :: disable(NULL); } + +// The user turns the radio off while a pick is under way: the module's own leave (reason +// 8) and EVENT_DISABLED follow, and nothing is said about the pick 20 s later, while Disabled +TEST(WifiConnectFeedbackTask, disable_ends_a_pending_pick) +{ + reset_world(); + world.enabled = true; + boot({ pick, Step(user_turns_off), disconnected(8), EVENT_DISABLED, + late(Step(EVENT_DISCONNECTED), 25 * configTICK_RATE_HZ) }); + CHECK(wifi.getState() == eWifi_Disabled || wifi.getState() == eWifi_NotConnected, "radio off"); + CHECK(messages[0] == 0, "no message about the pick"); +} + #if U64 != 2 // A radio-off confirmation due in 10 s, and a connect outcome due in 20 s: the task wakes // when the radio-off one is due, then when the other is. The pick comes while the boot's @@ -163,7 +179,9 @@ TEST(WifiConnectFeedbackTask, wakes_for_the_radio_off_deadline_first) CHECK(message_at == 1000 + (20 * configTICK_RATE_HZ), "exactly at its deadline, 20 s"); } -// The reverse: the radio off is asked again (the module restarted) when the connect outcome +static void user_disable(void) { NetworkLWIP_WiFi :: disable(NULL); } + +// The reverse: the user turns the radio off (no confirmation comes) when the connect outcome // is almost due. The task wakes for the outcome, which is due first, not 10 s later. TEST(WifiConnectFeedbackTask, wakes_for_the_connect_deadline_first) { @@ -171,10 +189,9 @@ TEST(WifiConnectFeedbackTask, wakes_for_the_connect_deadline_first) world.enabled = true; const TickType_t picked_at = 1000; boot({ pick, - late(Step(EVENT_DISABLED), 1000), - late(Step(EVENT_RESTARTED), (20 * configTICK_RATE_HZ) - 1500) }); - // the pick at 1000 gives a deadline at 1000 + 4000; the restart comes at 4500 - CHECK(strchr(rlog, 'O') != NULL, "the radio off is asked again"); + late(Step(user_disable), (20 * configTICK_RATE_HZ) - 500) }); + // the pick at 1000 gives a deadline at 1000 + 4000; the Disable comes at 4500 + CHECK(strchr(rlog, 'O') != NULL, "the radio off is asked for"); CHECK(strcmp(messages, "Could not connect to HomeNet\n") == 0, "the outcome is reported"); CHECK(message_at == picked_at + (20 * configTICK_RATE_HZ), "at its deadline, not at the radio off one"); } diff --git a/software/io/wifi/tests/disabled_task_test.cpp b/software/io/wifi/tests/disabled_task_test.cpp index 4ca2a7e42..86aca92e6 100644 --- a/software/io/wifi/tests/disabled_task_test.cpp +++ b/software/io/wifi/tests/disabled_task_test.cpp @@ -111,6 +111,7 @@ static void ask_case(const Action_t &a, bool yes) snprintf(what, sizeof(what), "%s: No sends nothing", a.name); CHECK(enable == NULL && !done && requests == 0 && strchr(asked, 'T') == NULL, what); CHECK(wifi.getState() == eWifi_Disabled, "and the state is unchanged"); + CHECK(wifi.event_when_enabled == 0, "and no scan is left waiting for the radio"); } } diff --git a/software/io/wifi/tests/switch_task_test.cpp b/software/io/wifi/tests/switch_task_test.cpp index fd465a076..8f20222eb 100644 --- a/software/io/wifi/tests/switch_task_test.cpp +++ b/software/io/wifi/tests/switch_task_test.cpp @@ -95,34 +95,6 @@ TEST(WifiSwitchTask, module_without_the_switch) CHECK(strcmp(ended, "suspended") == 0, "the application waits for an Enable"); } -// Disable while the application is still starting, before it knows whether the module -// can switch: the module is not stopped nor held off, and the start turns its radio off, -// although Enabled is stored; an Enable then undoes it. While flashing, Disable stops the -// application as before. -TEST(WifiSwitchTask, radio_off_while_starting) -{ - reset_world(); - wifi.state = eWifi_NotDetected; - rlog[0] = 0; - wifi.RadioOff(); - CHECK(rlog[0] == 0, "nothing stopped or held off yet"); - world.keep_switch = true; - world.enabled = true; - boot({}); - CHECK(strchr(rlog, 'O') != NULL && strchr(rlog, 'N') == NULL, "the start asks for the radio off"); - CHECK(strpbrk(rlog, "AF") == NULL, "the module keeps running"); - wifi.state = eWifi_ModuleDetected; - wifi.RadioOff(); - wifi.RadioOn(); - world.keep_switch = true; - boot({}); - CHECK(strchr(rlog, 'N') != NULL && strchr(rlog, 'O') == NULL, "an Enable after it wins"); - wifi.state = eWifi_Download; - rlog[0] = 0; - wifi.RadioOff(); - CHECK(strcmp(rlog, "A") == 0, "while flashing, the application stops and the module is left alone"); -} - // The boot's Disable never left (no transmit buffer): it is not taken for a module // without the switch, and when the confirmation is overdue it is asked for again before // the connection query, which the module would otherwise take as an old application's @@ -257,16 +229,18 @@ TEST(WifiSwitchTask, menu_and_setting) it.value = 1; NetworkLWIP_WiFi :: wifi_enable_change(&it); CHECK(strcmp(rlog, "N") == 0, "the setting to Enabled turns it on"); - // A setting that is the state already asks nothing + // A setting that is the state already is passed on all the same (the row can lag behind + // the module): the module takes it as a request it is in already wifi.state = eWifi_Connected; rlog[0] = 0; it.value = 1; NetworkLWIP_WiFi :: wifi_enable_change(&it); - CHECK(rlog[0] == 0, "Enabled while on: nothing to do"); + CHECK(strcmp(rlog, "N") == 0, "Enabled while on: passed on"); wifi.state = eWifi_Disabled; + rlog[0] = 0; it.value = 0; NetworkLWIP_WiFi :: wifi_enable_change(&it); - CHECK(rlog[0] == 0, "Disabled while off: nothing to do"); + CHECK(strcmp(rlog, "O") == 0, "Disabled while off: passed on"); wifi.state = eWifi_Off; // a module without the switch, held off rlog[0] = 0; it.value = 0; @@ -393,3 +367,71 @@ TEST(WifiSwitchTask, menu_disable_old_module) CHECK(strcmp(rlog, "B") == 0, "Enable starts the application again"); } #endif + +#if U64 != 2 +// Quick changes of "WiFi Enabled", faster than the module's events: each one reaches the +// module, whatever the row shows, so the last setting wins. (The row followed the module's +// events only: Enable then Disable from Disabled left the radio on and the link up with +// the setting Disabled, and Disable then Enable from Connected left it off with Enabled.) +static void enable_then_disable(void) { cfg_menu_enable(); cfg_menu_disable(); } +static void disable_then_enable(void) { cfg_menu_disable(); cfg_menu_enable(); } + +TEST(WifiSwitchTask, quick_enable_then_disable_ends_off) +{ + reset_world(); + world.enabled = false; + boot({ EVENT_DISABLED, Step(enable_then_disable), + EVENT_DISCONNECTED, EVENT_CONNECTED, EVENT_GOTIP, EVENT_DISABLED }); + CHECK(strstr(after('s'), "NO") != NULL, "the Enable and the Disable both reach the module"); + CHECK(wifi.getState() == eWifi_Disabled, "Disabled: the module's link events of the Enable are dropped"); + CHECK(!world.enabled, "the setting reads Disabled"); +} + +TEST(WifiSwitchTask, quick_disable_then_enable_ends_on) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_CONNECTED, Step(disable_then_enable), + EVENT_DISABLED, EVENT_DISCONNECTED, EVENT_CONNECTED }); + CHECK(strstr(after('U'), "ON") != NULL, "the Disable and the Enable both reach the module"); + CHECK(wifi.getState() == eWifi_Connected, "Connected again"); + CHECK(world.enabled, "the setting reads Enabled"); +} + +// A Disable at runtime is confirmed as the boot's is: Disabled is shown when the module +// says so, its link events are dropped until then, and when it never says so, the radio +// off is asked again and the link state is taken from the module again +TEST(WifiSwitchTask, runtime_disable_is_confirmed) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_CONNECTED, Step(menu_disable), EVENT_DISCONNECTED, EVENT_GOTIP, EVENT_DISABLED }); + CHECK(wifi.getState() == eWifi_Disabled, "Disabled once confirmed"); + CHECK(strchr(after('O'), 'U') == NULL, "no link comes up after the Disable"); +} + +TEST(WifiSwitchTask, runtime_disable_unconfirmed) +{ + reset_world(); + world.enabled = true; + world.link = 1; + // (the deadline is timed from the task's next pass, which the next event starts) + boot({ EVENT_CONNECTED, Step(menu_disable), EVENT_GOTIP }); + CHECK(strstr(after('O'), "OQ") != NULL, "asked again at the deadline, then the link state is asked for"); +} +#endif + +#if U64 != 2 +// While an AP list scan is under way the module is still talked to: a Disable reaches it +// and the WiFi application keeps running +TEST(WifiSwitchTask, disable_while_scanning_reaches_the_module) +{ + reset_world(); + world.enabled = true; + boot({ EVENT_CONNECTED }); + wifi.state = eWifi_Scanning; + rlog[0] = 0; + NetworkLWIP_WiFi :: disable(NULL); + CHECK(strcmp(rlog, "O") == 0, "the module is asked, the application not stopped"); +} +#endif diff --git a/software/io/wifi/tests/wifi_switch_test.cpp b/software/io/wifi/tests/wifi_switch_test.cpp index 57b1d2853..15d230f12 100644 --- a/software/io/wifi/tests/wifi_switch_test.cpp +++ b/software/io/wifi/tests/wifi_switch_test.cpp @@ -227,20 +227,4 @@ TEST(WifiSwitch, confirmed_in_time) EXPECT_FALSE(wifi_switch_expired(&sw, 200)); } -// A Disable or Enable while the application starts, before it knows the module: the start -// applies it, whatever is stored -TEST(WifiSwitch, switched_while_starting) -{ - wifi_switch_t sw; - memset(&sw, 0, sizeof(sw)); - wifi_switch_later(&sw, false); - EXPECT_TRUE(wifi_switch_wants_off(&sw, true)); // a Disable then: off, though Enabled is stored - EXPECT_FALSE(wifi_switch_wants_off(&sw, true)); // once only - wifi_switch_later(&sw, true); - EXPECT_FALSE(wifi_switch_wants_off(&sw, false)); // an Enable then: on, though Disabled is stored - wifi_switch_later(&sw, false); - wifi_switch_later(&sw, true); - EXPECT_FALSE(wifi_switch_wants_off(&sw, true)); // the last one counts -} - #endif diff --git a/software/io/wifi/tests/wifi_task_stubs.cpp b/software/io/wifi/tests/wifi_task_stubs.cpp index 79c772fc6..3c0f93bc9 100644 --- a/software/io/wifi/tests/wifi_task_stubs.cpp +++ b/software/io/wifi/tests/wifi_task_stubs.cpp @@ -119,7 +119,8 @@ void vTaskSuspend(TaskHandle_t t) { stop("suspended"); } void DmaUART :: ModuleCtrl(int mode) { if (mode == ESP_MODE_OFF) note('F'); } // The UART refills a buffer that is given back, so a read after it finds anything -void DmaUART :: FreeBuffer(command_buf_t *buf) { memset(buf->data, 0xA5, sizeof(buf->data)); buf->size = -1; } +int frees; // buffers given back to the UART +void DmaUART :: FreeBuffer(command_buf_t *buf) { frees++; memset(buf->data, 0xA5, sizeof(buf->data)); buf->size = -1; } BaseType_t DmaUART :: GetBuffer(command_buf_t **b, TickType_t t) { if (world.no_tx_buffer) { diff --git a/software/io/wifi/tests/wifi_task_test.h b/software/io/wifi/tests/wifi_task_test.h index 1212f128a..4ac5d5ac8 100644 --- a/software/io/wifi/tests/wifi_task_test.h +++ b/software/io/wifi/tests/wifi_task_test.h @@ -47,6 +47,7 @@ void reset_world(void); // every case starts with it extern int saves; // how often the WiFi settings were written extern bool saved_enabled; // "WiFi Enabled" as written extern char rlog[256]; // what the task did, one letter each +extern int frees; // buffers given back to the UART extern int popups; // how often the user was asked extern char messages[256]; // what the user was told, one message per line extern const char *ended; // why the task stopped running diff --git a/software/io/wifi/wifi.cc b/software/io/wifi/wifi.cc index 1d154c92d..b44aa095a 100644 --- a/software/io/wifi/wifi.cc +++ b/software/io/wifi/wifi.cc @@ -78,23 +78,6 @@ void WiFi :: Disable() esp32.StopApp(); } -#if U64 != 2 -// The states in which the WiFi application is running and the module answers it -bool WiFi :: TalksToModule() -{ - switch (state) { - case eWifi_AppDetected: - case eWifi_Scanning: - case eWifi_NotConnected: - case eWifi_Connected: - case eWifi_Disabled: - return true; - default: - return false; - } -} -#endif - void WiFi :: RadioOn() { #if U64 != 2 @@ -103,11 +86,6 @@ void WiFi :: RadioOn() Enable(); return; } - if (!TalksToModule()) { - // still starting: the start applies it - wifi_switch_later(&radio_switch, true); - return; - } // Ends a wait for a radio-off confirmation. A module without the switch is never // talked to here: it is held off (state Off) at boot and by RadioOff. wifi_switch_on(&radio_switch, true); @@ -118,26 +96,18 @@ void WiFi :: RadioOn() void WiFi :: RadioOff() { #if U64 != 2 - if (TalksToModule()) { - if (!wifi_switch_unsupported(wifi_disable())) { - return; - } - // A module known to lack the radio switch: stop the WiFi application, as Disable - // always did here, and hold the module off, as at boot, so that its radio is off too - Disable(); - if (uart) { - uart->ModuleCtrl(ESP_MODE_OFF); - } + int result = wifi_disable(); + if (!wifi_switch_unsupported(result)) { + // Disabled is shown when the module confirms, as at boot (wifi_switch.h) + wifi_switch_asked_off(&radio_switch, xTaskGetTickCount(), pdMS_TO_TICKS(WIFI_SWITCH_CONFIRM_MS)); return; } - if ((state == eWifi_NotDetected) || (state == eWifi_ModuleDetected)) { - // Still starting, and whether the module can switch is not known yet: the start - // applies the Disable (a module with the switch keeps running, its radio off) - wifi_switch_later(&radio_switch, false); - return; - } - // Off already, or being flashed: stop the WiFi application, as Disable always did + // A module known to lack the radio switch: stop the WiFi application, as Disable + // always did here, and hold the module off, as at boot, so that its radio is off too Disable(); + if (uart) { + uart->ModuleCtrl(ESP_MODE_OFF); + } #else wifi_disable(); #endif @@ -472,6 +442,7 @@ void WiFi :: RunModeThread() case EVENT_DISABLED: uart->FreeBuffer(buf); state = eWifi_Disabled; + feedback.cancel(); // a pick that was under way ends with the radio event_when_enabled = 0; wifi_aps.num_records = 0; // nothing to pick while the radio is off netstack->link_down(); diff --git a/software/io/wifi/wifi.h b/software/io/wifi/wifi.h index 1e064724f..2ae568af2 100644 --- a/software/io/wifi/wifi.h +++ b/software/io/wifi/wifi.h @@ -55,7 +55,6 @@ class WiFi : public Esp32Application uint32_t my_netmask; #if U64 != 2 wifi_switch_t radio_switch; - bool TalksToModule(void); #endif bool RequestEcho(void); diff --git a/software/io/wifi/wifi_connect.h b/software/io/wifi/wifi_connect.h index 3f1b83d4f..5a8bd49f7 100644 --- a/software/io/wifi/wifi_connect.h +++ b/software/io/wifi/wifi_connect.h @@ -82,6 +82,9 @@ class WifiConnectFeedback // The module reports the link up; the row going up is the user's signal void onConnected(void) { pending = false; } + // The user turned the radio off: nothing is to be reported for the pick any more + void cancel(void) { pending = false; } + // The module reports the link down; reason is wifi_disconnect_reason of its packet bool onDisconnected(uint8_t reason, char *msg, int max) { diff --git a/software/io/wifi/wifi_switch.h b/software/io/wifi/wifi_switch.h index ba41d8d3f..133bd77f8 100644 --- a/software/io/wifi/wifi_switch.h +++ b/software/io/wifi/wifi_switch.h @@ -12,6 +12,9 @@ * event from it (a module that associated at boot after all) would put the WiFi * interface on the network while WiFi is off, so those events are dropped. * + * A Disable at runtime (the menu, the REST API, the setting) is confirmed the same way. The + * wait is timed by the application's next pass, which any event from the module starts. + * * The answer to the request only says that the module queued it. The application shows * Disabled when EVENT_DISABLED arrives, not before. If it does not arrive within * WIFI_SWITCH_CONFIRM_MS (the module could not stop its radio, or the request was lost), @@ -24,7 +27,7 @@ * Enable then starts the WiFi application again, which is what an Enable did before, and * that start does not apply the stored Disabled. * - * Pure logic, so that the host test (target/pc/linux/wifiswitch) runs it. + * Pure logic, so that the host test (software/io/wifi/tests/wifi_switch_test.cpp) runs it. */ #ifndef WIFI_SWITCH_H_ @@ -50,7 +53,6 @@ static inline bool wifi_switch_unsupported(int result) typedef struct { bool awaiting_off; // the radio off was asked for, and EVENT_DISABLED is not seen yet bool override_off; // the next start of the application ignores a stored Disabled - bool off_pending; // a Disable came while the application was starting: its start applies it uint32_t deadline; // when the wait for EVENT_DISABLED ends, in the caller's time unit } wifi_switch_t; @@ -58,9 +60,8 @@ typedef struct { // is to be turned off now. enabled is the stored "WiFi Enabled". static inline bool wifi_switch_wants_off(wifi_switch_t *sw, bool enabled) { - bool off = (!enabled || sw->off_pending) && !sw->override_off; + bool off = !enabled && !sw->override_off; sw->override_off = false; - sw->off_pending = false; sw->awaiting_off = false; return off; } @@ -127,12 +128,4 @@ static inline void wifi_switch_on(wifi_switch_t *sw, bool app_running) } } -// A Disable (on false) or Enable (on true) while the application is still starting, before -// it knows whether the module can switch its radio: the start applies it -static inline void wifi_switch_later(wifi_switch_t *sw, bool on) -{ - sw->off_pending = !on; - sw->override_off = on; -} - #endif /* WIFI_SWITCH_H_ */ diff --git a/software/wifi/common/radio_boot.h b/software/wifi/common/radio_boot.h index ffd3519d5..7419d573d 100644 --- a/software/wifi/common/radio_boot.h +++ b/software/wifi/common/radio_boot.h @@ -11,7 +11,7 @@ * Ultimate it restarted (EVENT_RESTARTED), so that one with "WiFi Enabled" Disabled asks * for the radio off again. Until it does, the radio is on. * - * Pure logic, so that the host test (target/pc/linux/wifiradio) runs it. + * Pure logic, so that the host test (software/wifi/tests/radio_test.cpp) runs it. */ #ifndef SOFTWARE_WIFI_COMMON_RADIO_BOOT_H_ diff --git a/software/wifi/common/wifi_radio.h b/software/wifi/common/wifi_radio.h index 9f3c07747..8a5274206 100644 --- a/software/wifi/common/wifi_radio.h +++ b/software/wifi/common/wifi_radio.h @@ -7,8 +7,7 @@ * the AP. * * The logic is in wifi_radio.c, the chip side in wifi_radio_esp.c, and the host test - * (target/pc/linux/wifiradio) replaces the latter. It also checks that nothing else in - * the modules calls esp_wifi_start() or esp_wifi_stop(). + * (software/wifi/tests/radio_test.cpp) replaces the latter. */ #ifndef SOFTWARE_WIFI_COMMON_WIFI_RADIO_H_ From 11e625763da721be9b7b675e174146735656b60e Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 30 Oct 2026 14:15:50 -0500 Subject: [PATCH 35/95] Start and stop the radio of the control module through the shared code The control module called esp_wifi_start() and esp_wifi_stop() itself, while the U64 and U2+L modules go through wifi_radio.c. Use the same code, so that the radio's state (radio_is_on(), radio_epoch()) is known in one place, which the answer to GET_RANDOM needs. The calls reach the chip in the same order as before; the only difference is that a start of a radio that is on, or a stop of one that is off, no longer reaches the chip, which answers ESP_OK to both. Co-Authored-By: Claude Opus 5.5 --- software/u64ctrl/main/CMakeLists.txt | 5 +++-- software/u64ctrl/main/rpc_dispatch.h | 5 +++-- software/u64ctrl/main/wifi_modem.c | 9 +++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/software/u64ctrl/main/CMakeLists.txt b/software/u64ctrl/main/CMakeLists.txt index 26e7c9a13..b7da73541 100755 --- a/software/u64ctrl/main/CMakeLists.txt +++ b/software/u64ctrl/main/CMakeLists.txt @@ -1,4 +1,5 @@ set(EXTERNAL "../../io/uart") -idf_component_register(SRCS "button_handler.c" "control_main.c" "my_uart.c" "dump_hex.c" "rpc_dispatch.c" "wifi_modem.c" "button_handler.c" "jtag.c" "sntp.c" "power_state.c" "wol_magic.c" "recovery_manifest.c" "recovery_verify.c" "recovery_image.c" "recovery_url.c" "recovery.c" "recovery_trust.c" ${EXTERNAL}/cmd_buffer.c - INCLUDE_DIRS "." ${EXTERNAL} +set(COMMON "../../wifi/common") +idf_component_register(SRCS "button_handler.c" "control_main.c" "my_uart.c" "dump_hex.c" "rpc_dispatch.c" "wifi_modem.c" "button_handler.c" "jtag.c" "sntp.c" "power_state.c" "wol_magic.c" "recovery_manifest.c" "recovery_verify.c" "recovery_image.c" "recovery_url.c" "recovery.c" "recovery_trust.c" ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c + INCLUDE_DIRS "." ${EXTERNAL} ${COMMON} LDFRAGMENTS "linker.lf") diff --git a/software/u64ctrl/main/rpc_dispatch.h b/software/u64ctrl/main/rpc_dispatch.h index 506fb1001..798341251 100644 --- a/software/u64ctrl/main/rpc_dispatch.h +++ b/software/u64ctrl/main/rpc_dispatch.h @@ -26,8 +26,9 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.23" +#define IDENT_STRING "ESP32 WiFi Bridge V1.24" #define IDENT_MAJOR 1 +// 1.24: starts and stops the radio through the code it shares with the U64 module. // 1.23: a Disable or Autoconnect during the AP list walks is no longer lost, Enable // reconnects after a Disconnect, a Scan while Disabled is refused and a Connect leaves // Disabled. Joins the strongest access point of an SSID, or the one the Ultimate picked @@ -47,7 +48,7 @@ void send_keepalive(); // when this is higher than what the module reports, so a module change that // does not bump it is silently never installed, and an older release never // replaces a newer module. -#define IDENT_MINOR 23 +#define IDENT_MINOR 24 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 diff --git a/software/u64ctrl/main/wifi_modem.c b/software/u64ctrl/main/wifi_modem.c index 360b196be..9732f13a4 100644 --- a/software/u64ctrl/main/wifi_modem.c +++ b/software/u64ctrl/main/wifi_modem.c @@ -33,6 +33,7 @@ #include "button_handler.h" #include "wol_magic.h" #include "recovery.h" +#include "wifi_radio.h" #define NET_CMD_BUFSIZE 512 @@ -364,7 +365,7 @@ static void wifi_init() ESP_ERROR_CHECK(esp_wifi_init(&cfg)); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); - ESP_ERROR_CHECK(esp_wifi_start()); + ESP_ERROR_CHECK(radio_start()); ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, @@ -778,7 +779,7 @@ esp_err_t enable_wifi_if_needed(ConnectState_t state) { if (state == Disabled) { ESP_LOGI(TAG, "Starting WiFi."); - esp_err_t err = esp_wifi_start(); + esp_err_t err = radio_start(); if (err == ESP_OK) { send_event(EVENT_DISCONNECTED, 0); disabled_g = 0; @@ -809,7 +810,7 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) } } ESP_LOGI(TAG, "Stopping WiFi."); - err = esp_wifi_stop(); + err = radio_stop(); if (err == ESP_OK) { send_event(EVENT_DISABLED, 0); *state = Disabled; @@ -825,7 +826,7 @@ int handle_connect_command(ConnectCommand_t *cmd, ConnectState_t *state) // network again, so a Disconnect from before the Disable is spent user_disconnected = false; ESP_LOGI(TAG, "Starting WiFi."); - err = esp_wifi_start(); + err = radio_start(); if (err == ESP_OK) { send_event(EVENT_DISCONNECTED, 0); *state = LastAP; From 884fbbc67b054aa014bc56b3fdb1a38042b04265 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:28:57 -0500 Subject: [PATCH 36/95] Add E2E scenarios for the UCI network target's GET_RANDOM NET_CMD_GET_RANDOM ($20) hands a C64 program random bytes drawn by the WiFi module's hardware generator. The scenarios check lengths 1 to 512, the refusals 81 and 82, that replies are not stuck, zeroed, patterned or handed out twice, and that the command leaves the socket table and the read buffer alone. The long replies (300 and 512 bytes, lengths that are not a multiple of 4 or 16, a series of short replies whose tails a handler might never draw, and the stale-buffer check) run on the native route only: the REST route reads one byte per DMA cycle, and the firmware path is the same. Every GET_RANDOM reply the suite provokes is held to one rule: a status other than 00,OK carries no data. Whether bytes are owed is taken from the device's own report, not from the command's answer: an Ultimate 64 or Elite owes them once its WiFi module reports a wifi_mac, so firmware that always refuses fails rather than skips; every other product has to answer 87. On those two products the suite sets "WiFi Enabled" for the run and restores the stored setting first on exit; the module it started keeps running until the next reboot. On firmware without the command every GET_RANDOM scenario that needs bytes fails with 21,UNKNOWN COMMAND. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../io/command_interface/net_target_test.py | 571 +++++++++++++++++- 1 file changed, 561 insertions(+), 10 deletions(-) diff --git a/tests/e2e/io/command_interface/net_target_test.py b/tests/e2e/io/command_interface/net_target_test.py index 17ed5a99f..19061b2e7 100644 --- a/tests/e2e/io/command_interface/net_target_test.py +++ b/tests/e2e/io/command_interface/net_target_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # E2E: Verifies UCI network target socket reads: length handling and datagram delivery. -"""End-to-end check of the UCI network target's READ_SOCKET command. +"""End-to-end check of the UCI network target's READ_SOCKET and GET_RANDOM commands. Regression guard for GideonZ/1541ultimate#802, reported as "a maxlen above 512 silently returns no data". Everything here was measured on real hardware @@ -40,15 +40,30 @@ suite, and every property under test is visible at 64 bytes as clearly as at 894. +GET_RANDOM hands a C64 program random bytes drawn on the ESP32. Its scenarios +need no network peer except the one that interleaves it with a socket. What +they can check about the bytes is that each reply has the length asked for and +that replies are not stuck, zeroed or patterned; they cannot check that a real +entropy source is behind them, since the output of a post-processed RNG looks +the same either way. Whether bytes are owed at all is taken from the device's +own report, not from GET_RANDOM's answer: an Ultimate 64 or Ultimate 64 +Elite owes them, once "WiFi Enabled" is set and it reports a wifi_mac in +/v1/info. Any other product has to refuse. + Supported on any Ultimate whose FPGA provides the command interface. The suite -enables the "Command Interface" setting and restores it on exit. +enables the "Command Interface" setting and restores it on exit. On an Ultimate +64 or Ultimate 64 Elite it also sets "WiFi Enabled" and restores the stored +setting on exit; the module it started keeps running until the next reboot. """ import argparse +import functools +import math import socket import sys import time from pathlib import Path +from typing import NamedTuple # The one stanza that puts the shared library on sys.path; see tests/lib/bootstrap.py. sys.path.insert(0, str(next(p for p in Path(__file__).resolve().parents @@ -58,7 +73,7 @@ import targets # noqa: E402 from api import UltimateApi # noqa: E402 from report import ( # noqa: E402 - FAIL, Failure, OK, SKIP, check, check_ok, check_skip, check_start, detail, + FAIL, Failure, OK, SKIP, check, check_fail, check_ok, check_skip, check_start, detail, format_exception, section, suite_fail, suite_ok, warn) from uci import ( # noqa: E402 MAX_BLOCK_BYTES, REPLY_QUEUE_BYTES, TARGET_NETWORK, Uci, Wedged, @@ -76,9 +91,23 @@ NET_CMD_CLOSE_SOCKET = 0x09 NET_CMD_READ_SOCKET = 0x10 NET_CMD_WRITE_SOCKET = 0x11 +NET_CMD_GET_RANDOM = 0x20 STATUS_OK = b"00,OK" +STATUS_INVALID_PARAMS = b"81,INVALID PARAMS" STATUS_OUT_OF_RANGE = b"82,PARAMETER(S) OUT OF RANGE" +# GET_RANDOM's answer when the ESP32 has nothing to draw bytes from: absent, +# not running, timed out, or not yet started its radio. It is only ever +# answered with no data, whatever the reason. +STATUS_NO_ENTROPY = b"87,NO ENTROPY SOURCE" +STATUS_NO_ENTROPY_PREFIX = b"87," +# GET_RANDOM's answer when the ESP32 runs but was busy and did not answer in +# time. The client should try again; like 87 it never carries data. +STATUS_ENTROPY_BUSY = b"88,ENTROPY SOURCE BUSY" +STATUS_ENTROPY_BUSY_PREFIX = b"88," +# What the network target answers for an opcode it does not implement, which +# is what GET_RANDOM is on firmware that predates it. +STATUS_UNKNOWN_COMMAND = b"21,UNKNOWN COMMAND" # Not in the network target document, but what the firmware answers when # lwip_recv returns -1. The number is the errno: 9 is EBADF for a handle that # was never opened, 11 is EAGAIN for an open socket with nothing pending. @@ -148,6 +177,58 @@ SOCKETS_LEFT_OPEN_AT_RESET = 4 RESET_CYCLES = 3 +# The /v1/info products that draw GET_RANDOM bytes on the ESP32 (U64 == 1 in +# product.cc), matched exactly since "Ultimate 64-II" starts with "Ultimate 64". +# Every other product answers 87, even with a wifi_mac: its ESP32 runs other code. +U64_MK1_PRODUCTS = ("Ultimate 64", "Ultimate 64 Elite") +# The setting that starts the module there, by the store's exact name (the answer +# is keyed by it). Set for the run; writing Disabled back restores the setting but +# does not stop the module (network_esp32.cc, effectuate_settings). +CFG_WIFI_CATEGORY = "WiFi settings" +CFG_WIFI_ENABLED = "WiFi Enabled" +# How long a device with Wi-Fi enabled gets to report its wifi_mac, which it +# does once the module has started; this covers a device that has just booted. +WIFI_MAC_SECONDS = 30.0 + +# The most GET_RANDOM hands out in one command. 512 bytes fits one reply block, +# so every GET_RANDOM reply arrives in one. +RANDOM_MAX_BYTES = 512 +# The size a program asking for a key or a nonce would use. +RANDOM_TYPICAL = 32 +# A length whose high byte is neither 0 nor that of RANDOM_MAX_BYTES, so a +# handler that reads only the low byte answers with 44 bytes instead of 300. +RANDOM_SPLIT_LENGTH = 300 +# How long a run of pattern() bytes inside a random reply has to be before it +# counts as the socket read buffer handed back. A chance match of eight bytes +# is 1 in 2^56 per position. +STALE_RUN_BYTES = 8 +# Every window of this many bytes, at every offset of every reply in a route, +# has to be new. A route holds at most about 2,500, so honest bytes repeat one by +# chance with a probability of about 2,500^2 / 2 / 2^64, 1 in 10^12. +RANDOM_WINDOW_BYTES = 8 +# Lengths that are not a multiple of 4 or of 16, so a handler that fills whole +# words or blocks leaves a tail it did not draw in every one of them. +RANDOM_ODD_LENGTHS = (3, 17, 31, 257, 511) +# Same-offset matches over a pair of length m are Binomial(m, 1/256). A pair fails +# at the smallest count less likely than this, capped at RANDOM_PAIR_MATCHES_MAX +# (4 in 10^10 for 512 bytes); pairs too short to get there (m = 1, 3) are not judged. +RANDOM_PAIR_FALSE_ALARM = 1e-12 +RANDOM_PAIR_MATCHES_MAX = 16 +# A run of replies of one length, so a byte a handler never draws stays the +# same through all of them. Honest bytes hold one offset through 16 replies +# with a probability of 256^-15 per offset. +RANDOM_SERIES_LENGTH = 17 +RANDOM_SERIES_COUNT = 16 +# How often, and how far apart, a GET_RANDOM that answered 88 is asked again: +# 15 s covers the up to 10 s the ESP32 can block queueing a scan or connect. +# A source still busy after that fails where bytes are owed. +RANDOM_BUSY_RETRIES = 15 +RANDOM_BUSY_DELAY_SECONDS = 1.0 +# How many GET_RANDOM calls in one route may need a retry where bytes are +# owed. On an idle device an 88 is rare, so more than this says the source +# is busy as a matter of course rather than now and then. +RANDOM_BUSY_CALLS_MAX = 2 + # The two ways of reaching the registers, described at the top of this file. ROUTES = ["rest", "native"] @@ -162,8 +243,15 @@ "oversize-request-keeps-the-datagram", "empty-datagram-keeps-udp-open", "multi-block-state-does-not-leak", + "get-random-lengths", + "get-random-bytes-vary", + "get-random-refusals", + "get-random-leaves-sockets-alone", "reset-closes-uci-sockets", ] +# The scenarios that need no network peer, because they open no socket. +PEERLESS_TESTS = ("read-length-limit", "get-random-lengths", "get-random-bytes-vary", + "get-random-refusals") def pattern(size: int, seed: int = 0) -> bytes: @@ -249,8 +337,19 @@ def describe_mismatch(actual: bytes, expected: bytes) -> str: class Net: """The network target's commands, over the command interface.""" - def __init__(self, uci: Uci) -> None: + def __init__(self, uci: Uci, duty: "RandomDuty | None" = None) -> None: self.uci = uci + # What GET_RANDOM owes on this device, which decides what an 88 is. + # None for a driver that never sends it. + self.duty = duty + # Every GET_RANDOM reply on this driver, and how many calls needed a + # retry after an 88. + self.random_replies = 0 + self.busy_calls = 0 + # Every RANDOM_WINDOW_BYTES window of every GET_RANDOM reply so far, + # with the reply and offset it came from, and every reply itself. + self.random_windows: dict[bytes, tuple[int, int]] = {} + self.random_data: list[tuple[int, bytes]] = [] def identify(self): return self.uci.transact(bytes([TARGET_NETWORK, NET_CMD_IDENTIFY])) @@ -306,6 +405,106 @@ def abort_read(self, handle: int, maxlen: int) -> tuple[int, bool]: def close(self, handle: int): return self.uci.transact(bytes([TARGET_NETWORK, NET_CMD_CLOSE_SOCKET, handle])) + def random_command(self, length: int) -> bytes: + return bytes([TARGET_NETWORK, NET_CMD_GET_RANDOM, length & 0xFF, (length >> 8) & 0xFF]) + + def get_random(self, length: int | None = None, command: bytes | None = None): + """One GET_RANDOM, of `length` bytes or as the raw `command` given. + + Every reply passes the fail-closed rule here, so it holds for each one + the suite provokes rather than only where a scenario thinks to look: a + reply that is not 00,OK carries no data, and an 87 above all. Bytes + handed out when the ESP32 had no entropy source would look exactly as + random as real ones, so the status is the only place a client can learn + not to use them, and a reply that sends both has already lost. + + An 88 fails at once on a product that owes no bytes, which never asks + the ESP32, so its only refusal is an immediate 87. Elsewhere it is asked + again, up to RANDOM_BUSY_RETRIES times, each retried reply held to the + same rule, and more than RANDOM_BUSY_CALLS_MAX calls needing a retry + fails. + """ + if command is None: + command = self.random_command(length) + result = self._random_reply(command) + busy = result.status_text.startswith(STATUS_ENTROPY_BUSY_PREFIX) + if busy and self.duty is not None and not self.duty.owed: + raise Failure(f"GET_RANDOM answered {result.status_text!r} on this " + f"{self.duty.product}, which never asks the ESP32 for bytes; " + f"the only correct refusal there is an immediate " + f"{STATUS_NO_ENTROPY!r}") + if busy: + self.busy_calls += 1 + if self.duty is not None and self.duty.owed and \ + self.busy_calls > RANDOM_BUSY_CALLS_MAX: + raise Failure(f"{self.busy_calls} GET_RANDOM calls on this route answered " + f"{result.status_text!r} and needed a retry; where bytes are " + f"owed an idle device does that at most " + f"{RANDOM_BUSY_CALLS_MAX} times") + for attempt in range(1, RANDOM_BUSY_RETRIES + 1): + if not result.status_text.startswith(STATUS_ENTROPY_BUSY_PREFIX): + break + detail(f"GET_RANDOM answered {result.status_text!r}; retry {attempt} of " + f"{RANDOM_BUSY_RETRIES} in {RANDOM_BUSY_DELAY_SECONDS:.1f}s") + time.sleep(RANDOM_BUSY_DELAY_SECONDS) + result = self._random_reply(command) + return result + + def _random_reply(self, command: bytes): + """One GET_RANDOM exchange, counted and held to the fail-closed rule.""" + result = self.uci.transact(command) + self.random_replies += 1 + for prefix, what in ((STATUS_NO_ENTROPY_PREFIX, "with no entropy source"), + (STATUS_ENTROPY_BUSY_PREFIX, "with the entropy source busy")): + if result.status_text.startswith(prefix) and result.data: + raise Failure(f"GET_RANDOM answered {result.status_text!r} and still handed " + f"out {len(result.data)} bytes; {what} it must hand out none") + if result.status_text != STATUS_OK and result.data: + raise Failure(f"GET_RANDOM answered {result.status_text!r} with {len(result.data)} " + f"data bytes; a refusal carries no data") + if result.status_text == STATUS_OK: + self._remember_random(result.data) + return result + + def _remember_random(self, data: bytes) -> None: + """Fail if any window of `data` was handed out before on this route. + + A sanity check against bytes handed out twice, not an entropy proof. + A handler that fills only part of its buffer still answers with the + full length, and the rest is whatever an earlier reply left there: + random, so no check on one reply sees it, but the same bytes as + before. Every offset is checked rather than aligned blocks, so bytes + served again at a different position are caught as well, and so is + a reply that repeats itself. + """ + reply = self.random_replies + for offset in range(len(data) - RANDOM_WINDOW_BYTES + 1): + window = data[offset:offset + RANDOM_WINDOW_BYTES] + seen = self.random_windows.get(window) + if seen is not None: + raise Failure( + f"bytes {offset}-{offset + RANDOM_WINDOW_BYTES - 1} of GET_RANDOM reply " + f"{reply} ({len(data)} bytes) were handed out before, at offset " + f"{seen[1]} of reply {seen[0]}: {window.hex(' ')}. Random bytes do " + f"not repeat {RANDOM_WINDOW_BYTES} at a time, so part of this reply " + f"was left over rather than drawn") + self.random_windows[window] = (reply, offset) + # Bytes left over at the same offset rather than in a run: a handler + # that draws every other byte, or whole words and not the tail. + for earlier, before in self.random_data: + common = min(len(data), len(before)) + limit = same_offset_limit(common) + if limit is None: + continue + matches = sum(1 for a, b in zip(data, before, strict=False) if a == b) + if matches >= limit: + raise Failure( + f"GET_RANDOM reply {reply} ({len(data)} bytes) has the same byte as reply " + f"{earlier} at {matches} of their {common} common offsets; honest bytes " + f"match at about {common / 256:.1f}, and {limit} or more has a chance " + f"below {RANDOM_PAIR_FALSE_ALARM:g}") + self.random_data.append((reply, data)) + def largest_accepted_length(self) -> int: """The largest length READ_SOCKET accepts, found by bisection. @@ -1136,6 +1335,318 @@ def run_empty_datagram_keeps_udp_open(net: Net, peer: Peer) -> bool: return ok +@functools.cache +def same_offset_limit(common: int) -> int | None: + """How many same-offset matches fail a pair with `common` offsets in common. + + The smallest k with P(Binomial(common, 1/256) >= k) below + RANDOM_PAIR_FALSE_ALARM, capped at RANDOM_PAIR_MATCHES_MAX, or None where + no k up to `common` gets there. + """ + for k in range(1, min(common, RANDOM_PAIR_MATCHES_MAX) + 1): + # P(X >= k), summed directly rather than as 1 - P(X < k) for precision. + tail = sum(math.comb(common, j) * (1 / 256) ** j * (255 / 256) ** (common - j) + for j in range(k, common + 1)) + if tail < RANDOM_PAIR_FALSE_ALARM: + return k + return RANDOM_PAIR_MATCHES_MAX if common >= RANDOM_PAIR_MATCHES_MAX else None + + +def require_random(result, length: int) -> bytes: + """The bytes of a GET_RANDOM reply that has to have succeeded, or Failure.""" + if result.status_text == STATUS_UNKNOWN_COMMAND: + raise Failure(f"GET_RANDOM answered {result.status_text!r}: this firmware does not " + f"implement NET_CMD_GET_RANDOM (${NET_CMD_GET_RANDOM:02X})") + if result.status_text.startswith(STATUS_ENTROPY_BUSY_PREFIX): + raise Failure(f"GET_RANDOM of {length} bytes answered {result.status_text!r}: the " + f"entropy source was still busy when the suite stopped asking, which " + f"is after {RANDOM_BUSY_RETRIES} retries " + f"{RANDOM_BUSY_DELAY_SECONDS:.1f}s apart") + if result.status_text.startswith(STATUS_NO_ENTROPY_PREFIX): + raise Failure(f"GET_RANDOM of {length} bytes answered {result.status_text!r}, expected " + f"{STATUS_OK!r}; if WiFi was disabled from the menu, enable it there or " + f"reboot, then run the suite again") + if result.status_text != STATUS_OK: + raise Failure(f"GET_RANDOM of {length} bytes answered {result.status_text!r}, " + f"expected {STATUS_OK!r}") + if len(result.data) != length: + raise Failure(f"GET_RANDOM of {length} bytes handed out {len(result.data)}") + if len(result.blocks) != 1: + raise Failure(f"the reply arrived in {len(result.blocks)} blocks; " + f"{RANDOM_MAX_BYTES} bytes fit one, so every reply must") + return result.data + + +def read_wifi_setting(device, info) -> object: + """CFG_WIFI_ENABLED as the device reports it, or None where it has none. + + Asked only of the products that can owe bytes: the others either have no + such store or, on an Elite II, one whose Wi-Fi items are actions. + """ + if info.product not in U64_MK1_PRODUCTS: + return None + if CFG_WIFI_CATEGORY not in device.configs.category_names(): + return None + return device.configs.get(CFG_WIFI_CATEGORY, CFG_WIFI_ENABLED) + + +def reports_wifi_mac(info) -> bool: + wifi_mac = info.extra.get("wifi_mac") + return isinstance(wifi_mac, str) and bool(wifi_mac.strip()) + + +def wait_for_wifi_mac(device, info): + """The device's report once it names a wifi_mac, or after WIFI_MAC_SECONDS.""" + deadline = time.monotonic() + WIFI_MAC_SECONDS + while not reports_wifi_mac(info) and time.monotonic() < deadline: + time.sleep(1.0) + info = device.info() + return info + + +def read_duty(device, wifi_original: dict[str, str]) -> "RandomDuty": + """What GET_RANDOM owes on this device, from its report. + + On an Ultimate 64 or Ultimate 64 Elite "WiFi Enabled" is set first, and its + stored value kept in `wifi_original` for the restore. A device that then cannot + owe bytes fails this check, and the Failure is passed on for the + GET_RANDOM scenarios to fail with. + """ + with check("read whether this device owes GET_RANDOM bytes"): + info = device.info() + wifi_setting = read_wifi_setting(device, info) + if info.product in U64_MK1_PRODUCTS and wifi_setting is None: + raise Failure(f"this {info.product} has no {CFG_WIFI_ENABLED!r} in " + f"{CFG_WIFI_CATEGORY!r}, so the suite cannot start its WiFi module") + if wifi_setting is not None and wifi_setting != "Enabled": + wifi_original[CFG_WIFI_ENABLED] = str(wifi_setting) + device.configs.set(CFG_WIFI_CATEGORY, CFG_WIFI_ENABLED, "Enabled") + wifi_setting = "Enabled" + if wifi_setting == "Enabled": + info = wait_for_wifi_mac(device, info) + duty = random_duty(info) + expected = ("has to hand out bytes" if duty.owed else "has to refuse with 87") + mac = "reported" if reports_wifi_mac(info) else "not reported" + detail(f"product {info.product!r}, wifi_mac {mac}, " + f"{CFG_WIFI_ENABLED!r} {wifi_setting!r}" + f"{' (set for the run)' if wifi_original else ''}: GET_RANDOM {expected}") + return duty + + +class RandomDuty(NamedTuple): + """What GET_RANDOM has to answer on one device, decided from its report.""" + + owed: bool # bytes are owed: 87, or 88 past the retries, fails; else only 87 passes + product: str + + +def random_duty(info) -> RandomDuty: + """What a device with "WiFi Enabled" set has to answer to GET_RANDOM. + + Only an Ultimate 64 or Ultimate 64 Elite draws bytes at all, so on any + other product a reply with bytes in it came from somewhere else, which + is the fallback the command must never have. On those two the bytes are + owed, and one whose module never reported a wifi_mac fails rather than + skips; otherwise a firmware that always refuses would pass. + """ + owed = info.product in U64_MK1_PRODUCTS + if owed and not reports_wifi_mac(info): + raise Failure(f"this {info.product} has {CFG_WIFI_ENABLED!r} set but reported no " + f"wifi_mac in /v1/info within {WIFI_MAC_SECONDS:g}s, so its WiFi module " + f"did not start. Check that the WiFi module is fitted and starts, " + f"then run the suite again") + return RandomDuty(owed=owed, product=info.product) + + +def random_expected(net: Net, duty: RandomDuty) -> bool: + """Whether this device should hand out random bytes at all. + + `duty` is decided in main from the device's own report, never from this + answer. Where bytes are owed, 87 is a failure, and so is an 88 that + outlasts its retries. Elsewhere 87 with no data is the one correct answer: + that is checked here, and the checks that need bytes skip; 00,OK fails + here. Anything else, the unknown-command answer of firmware without + GET_RANDOM included, goes on to fail the checks that need bytes. + """ + if duty.owed: + return True + probe = net.get_random(RANDOM_TYPICAL) + if probe.status_text == STATUS_OK: + with check(f"GET_RANDOM on this {duty.product} refuses rather than hand out bytes"): + raise Failure(f"GET_RANDOM answered {STATUS_OK!r} with {len(probe.data)} bytes on " + f"this {duty.product}, which has no source to draw them from: only an " + f"{' or '.join(U64_MK1_PRODUCTS)} does. The only correct answer " + f"here is {STATUS_NO_ENTROPY!r}, with no data") + if not probe.status_text.startswith(STATUS_NO_ENTROPY_PREFIX): + return True + with check("where no bytes are owed, GET_RANDOM refuses with 87 and no data"): + if probe.status_text != STATUS_NO_ENTROPY: + raise Failure(f"expected {STATUS_NO_ENTROPY!r}, got {probe.status_text!r}") + check_start("GET_RANDOM hands out random bytes") + check_skip(f"GET_RANDOM answered {probe.status_text[:2].decode()} on a device that owes " + f"no bytes: only an {' or '.join(U64_MK1_PRODUCTS)} serves them") + return False + + +def run_get_random_lengths(net: Net, duty: RandomDuty, native: bool) -> bool | None: + """GET_RANDOM hands out exactly the number of bytes asked for. + + At the typical size and the lower bound on both routes. On the native route + also at the upper bound, at a length whose high byte is neither 0 nor 2, so + a handler that drops the high byte is caught on the success path as well as + on the refusals, and at lengths that are not a multiple of 4 or 16, whose + tails Net checks against earlier replies. The REST route reads one byte per + DMA cycle, and the firmware path is the same. + """ + section("get-random-lengths") + if not random_expected(net, duty): + return None + for length in (RANDOM_TYPICAL, 1, + *((RANDOM_MAX_BYTES, RANDOM_SPLIT_LENGTH, *RANDOM_ODD_LENGTHS) if native else ())): + with check(f"GET_RANDOM of {length} bytes answers {STATUS_OK.decode()} with exactly " + f"{length} bytes"): + require_random(net.get_random(length), length) + return True + + +def run_get_random_bytes_vary(net: Net, duty: RandomDuty) -> bool | None: + """No byte of a reply stays the same from one reply to the next. + + A sanity check, NOT a proof of entropy: the bytes are the output of a + post-processed RNG, which looks random whether or not a physical source is + feeding it. Replies handed out again, repeated or patterned are caught on + every reply by Net's window and same-offset checks; what those cannot see + is a tail of one to three bytes that a handler never draws. Native route + only, where it is cheap. + """ + section("get-random-bytes-vary") + if not random_expected(net, duty): + return None + with check(f"no byte stays the same through {RANDOM_SERIES_COUNT} GET_RANDOM of " + f"{RANDOM_SERIES_LENGTH} bytes"): + series = [require_random(net.get_random(RANDOM_SERIES_LENGTH), RANDOM_SERIES_LENGTH) + for _ in range(RANDOM_SERIES_COUNT)] + stuck = [offset for offset in range(RANDOM_SERIES_LENGTH) + if len({reply[offset] for reply in series}) == 1] + if stuck: + raise Failure(f"offsets {stuck} held the same byte in all {RANDOM_SERIES_COUNT} " + f"replies: ${series[0][stuck[0]]:02X} at {stuck[0]}") + return True + + +def run_get_random_refusals(net: Net, duty: RandomDuty) -> bool: + """Malformed and out-of-range requests are refused, with no data. + + Refusals do not need an entropy source, so these run on every device. + The lengths above the limit include ones with the top bit set, which a + handler that holds the length in a signed 16-bit value reads as negative. + """ + section("get-random-refusals") + malformed = [ + ("no length bytes", bytes([TARGET_NETWORK, NET_CMD_GET_RANDOM])), + ("only the low length byte", + bytes([TARGET_NETWORK, NET_CMD_GET_RANDOM, RANDOM_TYPICAL])), + # A valid length with a byte after it: the command is exactly four + # bytes, and a check for "at least four" would take this one. + ("a byte after a valid length", + bytes([TARGET_NETWORK, NET_CMD_GET_RANDOM, RANDOM_TYPICAL, 0, 0])), + ] + for what, command in malformed: + with check(f"GET_RANDOM with {what} answers {STATUS_INVALID_PARAMS.decode()} " + f"and no data"): + result = net.get_random(command=command) + if result.status_text != STATUS_INVALID_PARAMS: + raise Failure(f"expected {STATUS_INVALID_PARAMS!r}, got {result.status_text!r}") + + for length in (0, RANDOM_MAX_BYTES + 1, 0x8000, 0xFFFF): + with check(f"GET_RANDOM of {length} bytes answers {STATUS_OUT_OF_RANGE.decode()} " + f"and no data"): + result = net.get_random(length) + if result.status_text != STATUS_OUT_OF_RANGE: + raise Failure(f"expected {STATUS_OUT_OF_RANGE!r}, got {result.status_text!r}") + + # Refusals must not leave the command unusable. Where there is no entropy + # source the answer is 87 either way, and random_expected says so. + if random_expected(net, duty): + with check("GET_RANDOM still hands out bytes after the refusals"): + require_random(net.get_random(RANDOM_TYPICAL), RANDOM_TYPICAL) + return True + + +def run_get_random_leaves_sockets_alone(net: Net, peer: Peer, duty: RandomDuty, + native: bool) -> bool | None: + """GET_RANDOM does not disturb the network target's socket state. + + It is answered by the same target that holds the socket table and the + buffer READ_SOCKET replies from, so it runs here between an open, a + pending datagram, the read of it, and the close, all of which have to + behave as they do without it. + """ + section("get-random-leaves-sockets-alone") + if not random_expected(net, duty): + return None + baseline = net.identify() + handle = net.open_udp(peer.ip, peer.udp_port) + try: + peer.learn_udp_peer(net, handle) + net.drain_socket(handle) + peer.send_udp(pattern(SAFE_READ)) + time.sleep(DELIVERY_SETTLE_SECONDS) + + with check("GET_RANDOM answers while a socket holds a pending datagram"): + require_random(net.get_random(RANDOM_TYPICAL), RANDOM_TYPICAL) + refused = net.get_random(0) + if refused.status_text != STATUS_OUT_OF_RANGE: + raise Failure(f"a length of 0 answered {refused.status_text!r}, expected " + f"{STATUS_OUT_OF_RANGE!r}") + + with check("the pending datagram is read back whole after GET_RANDOM"): + result = net.read(handle, SAFE_READ) + detail(result.describe()) + if result.status_text != STATUS_OK or result.header != SAFE_READ: + raise Failure(f"expected {STATUS_OK!r} and a header of {SAFE_READ}, got " + f"{result.status_text!r} and {result.header}") + if result.payload != pattern(SAFE_READ): + raise Failure(f"the datagram changed: " + f"{describe_mismatch(result.payload, pattern(SAFE_READ))}") + + if native: # 512 bytes; the REST route reads them one DMA cycle at a time + with check("GET_RANDOM right after a socket read does not hand back the read's bytes"): + # The read just filled the target's buffer with pattern() bytes. A + # handler that answers from that buffer without filling all of it + # hands some of them out again, and they read as a run of pattern(). + data = require_random(net.get_random(RANDOM_MAX_BYTES), RANDOM_MAX_BYTES) + stale = [offset for offset in range(len(data) - STALE_RUN_BYTES + 1) + if run_offset(data[offset:offset + STALE_RUN_BYTES]) is not None] + if stale: + raise Failure(f"bytes from offset {stale[0]} are a run of the datagram just " + f"read: {data[stale[0]:stale[0] + 16].hex(' ')}") + + with check("the socket still sends after GET_RANDOM"): + # learn_udp_peer sends from the device and waits for it here, with + # the retry a lost datagram needs. + peer.learn_udp_peer(net, handle) + + with check("the socket closes with 00,OK"): + closing, handle = handle, None + result = net.close(closing) + if result.status_text != STATUS_OK: + raise Failure(f"CLOSE_SOCKET answered {result.status_text!r}") + + with check("IDENTIFY after GET_RANDOM answers exactly as before it"): + identity = net.identify() + if (identity.data, identity.status_text, len(identity.blocks)) != \ + (baseline.data, baseline.status_text, len(baseline.blocks)): + raise Failure(f"IDENTIFY answered {identity.data!r}, {identity.status_text!r} " + f"in {len(identity.blocks)} block(s); before GET_RANDOM it was " + f"{baseline.data!r}, {baseline.status_text!r} in " + f"{len(baseline.blocks)}") + finally: + if handle is not None: + net.close(handle) + return True + + def close_quietly(net: Net, handles: list[int]) -> None: """Close every handle a scenario opened; an error means it was already gone.""" for handle in handles: @@ -1232,7 +1743,8 @@ def build_driver(route: str, computer, busy_timeout: float): def main() -> int: parser = argparse.ArgumentParser( description="Verify how the UCI network target's READ_SOCKET handles the requested " - "length and datagrams larger than it (GideonZ/1541ultimate#802)." + "length and datagrams larger than it (GideonZ/1541ultimate#802), and " + "what GET_RANDOM hands out." ) cli.add_device_arguments(parser, password=None, timeout=30.0, colour=False) parser.add_argument("-b", "--busy-timeout", type=float, default=15.0, @@ -1244,7 +1756,8 @@ def main() -> int: "Ultimate issues, 'native' for 6502 code running on the " "C64. Both by default.") parser.add_argument("--keep-config", action="store_true", - help="Don't restore the original Command Interface setting on exit.") + help="Don't restore the original Command Interface and WiFi Enabled " + "settings on exit.") args = parser.parse_args() selected = TESTS if not args.test or "all" in args.test else [t for t in TESTS if t in args.test] @@ -1265,6 +1778,7 @@ def main() -> int: rest_uci = Uci(computer.machine, args.busy_timeout) original: dict[str, str] = {} + wifi_original: dict[str, str] = {} results: dict[str, bool | None] = {} peer: Peer | None = None interface_enabled = False @@ -1272,6 +1786,10 @@ def main() -> int: cleanup_ok = True setup_failed = False + # Why no GET_RANDOM scenario can be run on this device, when the device + # cannot owe bytes; each of them then fails with it, and the rest run. + duty_failure: str | None = None + def run(route: str, name: str, fn, *fn_args) -> None: """Run one scenario on one route; a failed check ends that scenario only. @@ -1284,6 +1802,11 @@ def run(route: str, name: str, fn, *fn_args) -> None: return label = f"{name} [{route}]" results[label] = False # so an aborted scenario reports FAIL, not "not reached" + if duty_failure is not None and name.startswith("get-random-"): + section(name) + check_start(f"{name} can run on this device") + check_fail(duty_failure) + return try: results[label] = fn(*fn_args) except Wedged: @@ -1293,6 +1816,16 @@ def run(route: str, name: str, fn, *fn_args) -> None: detail(f"{label} stopped: {format_exception(exc)}") try: + # Whether bytes are owed comes from the device's report, not the answer, + # so a firmware that always answers 87 fails. If it cannot be read, only + # the GET_RANDOM scenarios fail. + duty = RandomDuty(owed=False, product="") + if any(name.startswith("get-random-") for name in selected): + try: + duty = read_duty(device, wifi_original) + except Failure as exc: + duty_failure = format_exception(exc) + with check(f"read {CONFIG_CATEGORY!r}"): config = device.configs.category(CONFIG_CATEGORY) if CFG_CMD_IF not in config: @@ -1313,7 +1846,7 @@ def run(route: str, name: str, fn, *fn_args) -> None: return 0 needs_peer = [name for name in TESTS - if name != "read-length-limit" and name in selected] + if name not in PEERLESS_TESTS and name in selected] if needs_peer: check_start("this host can act as the device's network peer") try: @@ -1363,7 +1896,7 @@ def run(route: str, name: str, fn, *fn_args) -> None: computer.machine.reset(force=True) native_started = True driver = build_driver(route, computer, args.busy_timeout) - net = Net(driver) + net = Net(driver, duty) identity = net.identify() if identity.status_text != STATUS_OK or not identity.data: raise Failure(f"NET_CMD_IDENTIFY answered {identity.status_text!r} " @@ -1371,9 +1904,16 @@ def run(route: str, name: str, fn, *fn_args) -> None: detail(identity.data.decode("latin-1")) run(route, "read-length-limit", run_read_length_limit, net) + run(route, "get-random-lengths", run_get_random_lengths, net, duty, route == "native") + if route == "native": + run(route, "get-random-bytes-vary", run_get_random_bytes_vary, net, duty) + run(route, "get-random-refusals", run_get_random_refusals, net, duty) if peer is None: for name in needs_peer: - results.setdefault(f"{name} [{route}]", None) + if duty_failure is not None and name.startswith("get-random-"): + run(route, name, None) # records the FAIL without calling anything + else: + results.setdefault(f"{name} [{route}]", None) continue run(route, "reply-blocks-are-drainable", run_reply_blocks_are_drainable, net, peer) run(route, "datagram-spans-reply-blocks", run_datagram_spans_reply_blocks, net, peer) @@ -1388,6 +1928,8 @@ def run(route: str, name: str, fn, *fn_args) -> None: run_empty_datagram_keeps_udp_open, net, peer) run(route, "multi-block-state-does-not-leak", run_multi_block_state_does_not_leak, net, peer) + run(route, "get-random-leaves-sockets-alone", + run_get_random_leaves_sockets_alone, net, peer, duty, route == "native") def reset_and_reopen(route=route): """Reset the C64 and hand back a driver that reaches the target.""" @@ -1411,6 +1953,15 @@ def reset_and_reopen(route=route): finally: if peer is not None: peer.close() + wifi_restored = True + if wifi_original and not args.keep_config: + # First, and caught, so that it runs whatever the restores below raise. + try: + with check(f"restore {CFG_WIFI_ENABLED!r} to {wifi_original[CFG_WIFI_ENABLED]!r}"): + device.configs.set(CFG_WIFI_CATEGORY, CFG_WIFI_ENABLED, + wifi_original[CFG_WIFI_ENABLED]) + except Exception: # check() has reported it + wifi_restored = False # A failed scenario can leave the interface holding a reply, so hand the # data back before the setting goes home. released = rest_uci.release() if interface_enabled else True @@ -1422,7 +1973,7 @@ def reset_and_reopen(route=route): with check("reset the C64 so the 6502 agent releases the machine"): computer.machine.reset(force=True) restored = restore_settings(device, original, args.keep_config) - cleanup_ok = released and restored + cleanup_ok = released and restored and wifi_restored section("summary") all_ok = cleanup_ok and not setup_failed From 3fb4a4e54daff2e7617d6a1c5bdb654efcb8c43a Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:28:57 -0500 Subject: [PATCH 37/95] Give the WiFi module a call that returns hardware random bytes CMD_GET_RANDOM returns 1 to 512 bytes from esp_fill_random(), together with the entropy source behind them. The ESP32's generator gives true random numbers only while the radio runs, so the source is ENTROPY_NONE while the radio is off, and the call then refuses with ESP_ERR_INVALID_STATE and no bytes. A length of 0 or above 512 is refused with ESP_ERR_INVALID_ARG. The module can now turn its radio off on request, so the source follows radio_is_on(). The radio stops counting as on as soon as a stop begins, and radio_epoch() counts the stops: bytes drawn while the radio stopped, even if it has started again, are not sent. It is 0x20: the u64ctrl module's own commands run from 0x13 and may grow to 0x1F, and 0x20 is free in every module map, active or commented out. It is also the number of the UCI command that serves it. The reply overlays the request, so it echoes the header the Ultimate matches it by, and its fixed part is cleared first so no stale buffer bytes go out. The layout is asserted at compile time on both sides. Co-Authored-By: Claude Opus 5.5 (1M context) Co-Authored-By: Claude Opus 5.5 --- software/wifi/common/wifi_radio.c | 13 +++++- software/wifi/common/wifi_radio.h | 7 +++- software/wifi/raw_u64/main/rpc_calls.h | 23 +++++++++++ software/wifi/raw_u64/main/rpc_dispatch.c | 48 +++++++++++++++++++++++ software/wifi/raw_u64/main/rpc_dispatch.h | 5 ++- software/wifi/raw_u64/main/wifi_modem.c | 13 ++++++ software/wifi/raw_u64/main/wifi_modem.h | 2 + software/wifi/tests/radio_test.cpp | 26 ++++++++++++ 8 files changed, 132 insertions(+), 5 deletions(-) diff --git a/software/wifi/common/wifi_radio.c b/software/wifi/common/wifi_radio.c index 29954c952..8fa936853 100644 --- a/software/wifi/common/wifi_radio.c +++ b/software/wifi/common/wifi_radio.c @@ -9,12 +9,18 @@ // Written by the task that starts and stops the radio, read by any static volatile bool radio_on = false; +static volatile uint32_t epoch = 0; bool radio_is_on(void) { return radio_on; } +uint32_t radio_epoch(void) +{ + return epoch; +} + int radio_start(void) { if (radio_on) { @@ -32,9 +38,12 @@ int radio_stop(void) if (!radio_on) { return 0; } + // A GET_RANDOM draw that overlaps the stop must not count as drawn with the radio on + epoch++; + radio_on = false; int rc = wr_port_wifi_stop(); - if (rc == 0) { - radio_on = false; + if (rc != 0) { + radio_on = true; } return rc; } diff --git a/software/wifi/common/wifi_radio.h b/software/wifi/common/wifi_radio.h index 8a5274206..d57d33fc4 100644 --- a/software/wifi/common/wifi_radio.h +++ b/software/wifi/common/wifi_radio.h @@ -14,6 +14,7 @@ #define SOFTWARE_WIFI_COMMON_WIFI_RADIO_H_ #include +#include // Both are idempotent: asking for the state the radio is in already does nothing and // returns 0. Otherwise they return 0 or the esp_err_t of the start or stop, and a failed @@ -22,7 +23,11 @@ int radio_start(void); int radio_stop(void); -// True from a successful start until a successful stop +// True from a successful start until a stop begins: while a stop runs the radio no +// longer counts as on, and a stop that fails makes it count again bool radio_is_on(void); +// The number of stops begun so far, so that a caller can tell the radio went off under it +uint32_t radio_epoch(void); + #endif /* SOFTWARE_WIFI_COMMON_WIFI_RADIO_H_ */ diff --git a/software/wifi/raw_u64/main/rpc_calls.h b/software/wifi/raw_u64/main/rpc_calls.h index 986972c06..2758db44e 100644 --- a/software/wifi/raw_u64/main/rpc_calls.h +++ b/software/wifi/raw_u64/main/rpc_calls.h @@ -127,6 +127,28 @@ typedef struct { esp_datetime_t datetime; } rpc_get_time_resp; +//---------------------------------- +// hardware random bytes +#define RANDOM_MAX_BYTES 512 + +typedef enum { + ENTROPY_NONE = 0, // RNG not fed by a live entropy source; no bytes are returned + ENTROPY_RADIO = 1, // Wi-Fi is running, so the RNG gives true random numbers +} entropy_source_t; + +typedef struct { + rpc_header_t hdr; + uint16_t length; +} rpc_get_random_req; + +typedef struct { + rpc_header_t hdr; + int esp_err; // to be casted to esp_err_t + uint8_t source; // to be casted to entropy_source_t + uint16_t length; + uint8_t data[]; // sizeof() excludes it, so it is exactly the header size +} rpc_get_random_resp; + //---------------------------------- // send raw packet typedef struct { @@ -178,6 +200,7 @@ typedef struct { #define CMD_GET_TIME 0x10 #define CMD_CLEAR_APS 0x11 #define CMD_WIFI_AUTOCONNECT 0x12 +#define CMD_GET_RANDOM 0x20 // u64ctrl's own commands run from 0x13 and may reach 0x1F; kept apart so the maps agree /* #define CMD_SOCKET 0x11 diff --git a/software/wifi/raw_u64/main/rpc_dispatch.c b/software/wifi/raw_u64/main/rpc_dispatch.c index 5ea581272..78f528eb6 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.c +++ b/software/wifi/raw_u64/main/rpc_dispatch.c @@ -6,11 +6,13 @@ */ +#include #include "freertos/FreeRTOS.h" #include "freertos/queue.h" #include "esp_wifi.h" #include "esp_log.h" #include "driver/uart.h" +#include "esp_random.h" #include "rpc_calls.h" #include "rpc_dispatch.h" #include "my_uart.h" @@ -249,6 +251,49 @@ void cmd_clear_aps(command_buf_t *buf) my_uart_transmit_packet(UART_CHAN, buf); } +// The Ultimate decodes these by offset: a layout change must break the build, not the wire +_Static_assert(sizeof(rpc_get_random_req) == 6, "rpc_get_random_req size"); +_Static_assert(offsetof(rpc_get_random_req, length) == 4, "rpc_get_random_req.length"); +_Static_assert(sizeof(rpc_get_random_resp) == 12, "rpc_get_random_resp size"); +_Static_assert(offsetof(rpc_get_random_resp, esp_err) == 4, "rpc_get_random_resp.esp_err"); +_Static_assert(offsetof(rpc_get_random_resp, source) == 8, "rpc_get_random_resp.source"); +_Static_assert(offsetof(rpc_get_random_resp, length) == 10, "rpc_get_random_resp.length"); +_Static_assert(offsetof(rpc_get_random_resp, data) == 12, "rpc_get_random_resp.data"); +_Static_assert(ENTROPY_NONE == 0, "ENTROPY_NONE"); + +void cmd_get_random(command_buf_t *buf) +{ + rpc_get_random_req *req = (rpc_get_random_req *)buf->data; + rpc_get_random_resp *resp = (rpc_get_random_resp *)buf->data; + + // The response overlays the request, so take what we need from it first + uint16_t length = (buf->size >= (int)sizeof(rpc_get_random_req)) ? req->length : 0; + uint32_t epoch = entropy_epoch(); + entropy_source_t source = entropy_source(); + + // Clear the fixed part, padding included, so no stale buffer bytes go out + memset(&resp->esp_err, 0, sizeof(rpc_get_random_resp) - sizeof(rpc_header_t)); + resp->source = source; + if ((length == 0) || (length > RANDOM_MAX_BYTES)) { + resp->esp_err = ESP_ERR_INVALID_ARG; + } else if (source == ENTROPY_NONE) { + resp->esp_err = ESP_ERR_INVALID_STATE; + } else { + esp_fill_random(resp->data, length); + // This module stops the radio on request: bytes drawn while it stopped, even if + // it has started again, are not sent + if ((entropy_source() == ENTROPY_NONE) || (entropy_epoch() != epoch)) { + resp->source = ENTROPY_NONE; + resp->esp_err = ESP_ERR_INVALID_STATE; + } else { + resp->esp_err = ESP_OK; + resp->length = length; + } + } + buf->size = sizeof(rpc_get_random_resp) + resp->length; + my_uart_transmit_packet(UART_CHAN, buf); +} + void cmd_not_implemented(command_buf_t *buf) { rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; @@ -342,6 +387,9 @@ void dispatch(void *ct) case CMD_CLEAR_APS: cmd_clear_aps(pbuffer); break; + case CMD_GET_RANDOM: + cmd_get_random(pbuffer); + break; default: cmd_not_implemented(pbuffer); break; diff --git a/software/wifi/raw_u64/main/rpc_dispatch.h b/software/wifi/raw_u64/main/rpc_dispatch.h index 7723374f7..56ce26361 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.h +++ b/software/wifi/raw_u64/main/rpc_dispatch.h @@ -26,8 +26,9 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.9" +#define IDENT_STRING "ESP32 WiFi Bridge V1.10" #define IDENT_MAJOR 1 +// 1.10: CMD_GET_RANDOM. // 1.9: turns its radio off and on when asked (CMD_WIFI_DISABLE / CMD_WIFI_ENABLE) and // starts with it off until the Ultimate sends Enable or Autoconnect (or, without the // switch, asks for the connection state); after a restart of its own it puts the radio @@ -41,7 +42,7 @@ void send_keepalive(); // Disconnected forever. The Ultimate's updater only reflashes the module // when this differs from what the module reports, so a module change that // does not bump it is silently never installed. -#define IDENT_MINOR 9 +#define IDENT_MINOR 10 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 diff --git a/software/wifi/raw_u64/main/wifi_modem.c b/software/wifi/raw_u64/main/wifi_modem.c index b8a6ef949..bb141d750 100644 --- a/software/wifi/raw_u64/main/wifi_modem.c +++ b/software/wifi/raw_u64/main/wifi_modem.c @@ -72,6 +72,19 @@ void wifi_note_user_disconnect(void) user_disconnected = true; } +/* What feeds the RNG: esp_fill_random() is only truly random while the radio runs + * (esp_random.h). The radio counts as off from the moment a stop begins, and the epoch + * counts the stops, so that a stop and a start within one draw are noticed. */ +entropy_source_t entropy_source(void) +{ + return radio_is_on() ? ENTROPY_RADIO : ENTROPY_NONE; +} + +uint32_t entropy_epoch(void) +{ + return radio_epoch(); +} + // Allocate some buffers to work with command_buf_context_t work_buffers; diff --git a/software/wifi/raw_u64/main/wifi_modem.h b/software/wifi/raw_u64/main/wifi_modem.h index 8c232c63e..382543f4f 100644 --- a/software/wifi/raw_u64/main/wifi_modem.h +++ b/software/wifi/raw_u64/main/wifi_modem.h @@ -30,5 +30,7 @@ void disable_hook(); uint8_t wifi_get_connection(); void wifi_report_disabled(void); void wifi_note_identify(void); +entropy_source_t entropy_source(void); +uint32_t entropy_epoch(void); #endif diff --git a/software/wifi/tests/radio_test.cpp b/software/wifi/tests/radio_test.cpp index 87367c71a..c3c1b4d90 100644 --- a/software/wifi/tests/radio_test.cpp +++ b/software/wifi/tests/radio_test.cpp @@ -21,6 +21,7 @@ extern "C" { static int starts, stops; static int start_result, stop_result; static int chip_on; // what the chip does, as opposed to what wifi_radio.c believes +static int on_during_stop; // radio_is_on() while the chip was stopping extern "C" int wr_port_wifi_start(void) { @@ -34,6 +35,7 @@ extern "C" int wr_port_wifi_start(void) extern "C" int wr_port_wifi_stop(void) { stops++; + on_during_stop = radio_is_on(); if (stop_result == 0) { chip_on = 0; } @@ -137,3 +139,27 @@ TEST(Radio, boot_decisions) rec = on; radio_record_set(&rec, false); CHECK(radio_boot_decision(true, &rec) == RADIO_BOOT_OFF, "rewritten from on to off"); } + +// A GET_RANDOM draw that overlaps a stop is refused: the radio no longer counts as on once the +// stop begins, and the epoch has moved, also when the stop fails +TEST(Radio, a_stop_moves_the_epoch_first) +{ + reset(); + radio_start(); + uint32_t e = radio_epoch(); + on_during_stop = 1; + radio_stop(); + CHECK(!on_during_stop, "off while stopping"); + CHECK(radio_epoch() == e + 1, "one stop, one step"); + radio_start(); + CHECK(radio_epoch() == e + 1, "a start does not move it"); + stop_result = ESP_FAIL_CODE; + radio_stop(); + CHECK(radio_epoch() == e + 2, "a failed stop moves it too"); + radio_stop(); + CHECK(radio_epoch() == e + 3, "and so does its retry"); + stop_result = 0; + radio_stop(); + radio_stop(); + CHECK(radio_epoch() == e + 4, "a stop while off does not"); +} From e41d23eb41475394fa82916d30d4a9bbfe4b8731 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:28:57 -0500 Subject: [PATCH 38/95] Give GET_RANDOM a reply channel of its own to the WiFi module GET_RANDOM must neither wait for the module forever nor trust what comes back, so it does not use the transmit-buffer slots that route the other RPC replies. wifi_dedicated_call() sends one request at a time on a thread number no transmit buffer has, and waits for the answer on a queue of its own, until a deadline counted from when the request was queued. A reply counts only if it matches the command and the sequence number; a late or foreign one is skipped, and after the deadline the call answers busy. wifi_get_random() is its first user: 1 to 512 bytes, with a 200 ms deadline, and wifi_random.cc checks that the answer carries exactly the bytes asked for from a real source. ClearRxBuffer() now runs with the scheduler suspended and counts pool resets, so a reply queued before a reset, whose buffer the reset put back in the pool, is dropped unread rather than freed a second time. Two host tests come with it (make host_tests): target/pc/linux/wifirandom checks every malformed answer at five lengths, and target/pc/linux/wifidedicated runs the real wifi_dedicated.cc in a scripted world: each kind of reply alone and queued behind another, the deadline never overrun, the request and its sequence number, the calls that send nothing, and 100,000 random worlds in which bytes may only come from the answer to this request. Co-Authored-By: Claude Opus 5.5 (1M context) --- Makefile | 2 + software/io/uart/dma_uart.cc | 5 + software/io/uart/dma_uart.h | 4 + software/io/wifi/wifi.cc | 8 + software/io/wifi/wifi_cmd.cc | 21 +- software/io/wifi/wifi_cmd.h | 16 + software/io/wifi/wifi_dedicated.cc | 140 ++++++ software/io/wifi/wifi_dedicated.h | 34 ++ software/io/wifi/wifi_random.cc | 63 +++ software/io/wifi/wifi_random.h | 29 ++ software/test/wifi_dedicated/check.cc | 22 + software/test/wifi_dedicated/check.h | 8 + software/test/wifi_dedicated/stub/FreeRTOS.h | 17 + software/test/wifi_dedicated/stub/queue.h | 5 + software/test/wifi_dedicated/stub/task.h | 8 + software/test/wifi_dedicated/stub/wifi_cmd.h | 51 +++ .../wifi_dedicated/wifi_dedicated_test.cc | 411 ++++++++++++++++++ software/test/wifi_dedicated/world.cc | 326 ++++++++++++++ software/test/wifi_dedicated/world.h | 43 ++ software/test/wifi_random/lwip/netdb.h | 1 + software/test/wifi_random/lwip/sockets.h | 6 + software/test/wifi_random/wifi_random_test.cc | 198 +++++++++ target/pc/linux/wifidedicated/Makefile | 43 ++ target/pc/linux/wifirandom/Makefile | 34 ++ target/u64/nios2/ultimate/Makefile | 2 + 25 files changed, 1496 insertions(+), 1 deletion(-) create mode 100644 software/io/wifi/wifi_dedicated.cc create mode 100644 software/io/wifi/wifi_dedicated.h create mode 100644 software/io/wifi/wifi_random.cc create mode 100644 software/io/wifi/wifi_random.h create mode 100644 software/test/wifi_dedicated/check.cc create mode 100644 software/test/wifi_dedicated/check.h create mode 100644 software/test/wifi_dedicated/stub/FreeRTOS.h create mode 100644 software/test/wifi_dedicated/stub/queue.h create mode 100644 software/test/wifi_dedicated/stub/task.h create mode 100644 software/test/wifi_dedicated/stub/wifi_cmd.h create mode 100644 software/test/wifi_dedicated/wifi_dedicated_test.cc create mode 100644 software/test/wifi_dedicated/world.cc create mode 100644 software/test/wifi_dedicated/world.h create mode 100644 software/test/wifi_random/lwip/netdb.h create mode 100644 software/test/wifi_random/lwip/sockets.h create mode 100644 software/test/wifi_random/wifi_random_test.cc create mode 100644 target/pc/linux/wifidedicated/Makefile create mode 100644 target/pc/linux/wifirandom/Makefile diff --git a/Makefile b/Makefile index e33607bc2..b25df58fd 100755 --- a/Makefile +++ b/Makefile @@ -86,6 +86,8 @@ host_tests: @$(MAKE) -C software/wifi/tests @$(MAKE) -C target/pc/linux/recoveryimage test @$(MAKE) -C target/pc/linux/recoveryurl test + @$(MAKE) -C target/pc/linux/wifirandom test + @$(MAKE) -C target/pc/linux/wifidedicated test esp32: esp32_raw_u64 esp32_raw_c3 esp32_u64ctrl diff --git a/software/io/uart/dma_uart.cc b/software/io/uart/dma_uart.cc index 396ef4583..bb56f3ba8 100644 --- a/software/io/uart/dma_uart.cc +++ b/software/io/uart/dma_uart.cc @@ -113,11 +113,16 @@ void DmaUART::ModuleCtrl(uint8_t mode) void DmaUART::ClearRxBuffer(void) { + // No task may free a held buffer into the half refilled pool, which the + // reset would then fill with it a second time. Nothing below blocks. + vTaskSuspendAll(); // uart->ictrl = DMAUART_RxIRQ_DIS | DMAUART_TxIRQ_DIS |DMAUART_BufReq_DIS; // disable interrupts uart->flowctrl = uart->flowctrl | DMAUART_RESET; // reset pulse; will also disable interrupts xQueueGenericReset(rx_bufs, pdFALSE); uart->flowctrl = uart->flowctrl | DMAUART_RESET; // reset pulse; will also disable interrupts cmd_buffer_reset(packets); + generation++; // after the reset, so that any doubt ends in a leak, not a double free + xTaskResumeAll(); } int DmaUART::Read(uint8_t *buffer, int bufsize) diff --git a/software/io/uart/dma_uart.h b/software/io/uart/dma_uart.h index 0e6d180ec..3eb6fd27f 100644 --- a/software/io/uart/dma_uart.h +++ b/software/io/uart/dma_uart.h @@ -61,6 +61,9 @@ class DmaUART public: static uint8_t DmaUartInterrupt(void *context); bool txDebug; + // Counts the resets of the buffer pool. A buffer handed out before the + // last one has been put back in the pool by it, and is not to be freed. + volatile uint32_t generation; DmaUART(void *registers, int irq, void *sem, command_buf_context_t *pkts) { @@ -70,6 +73,7 @@ class DmaUART rxSemaphore = sem; slipMode = false; txDebug = false; + generation = 0; current_tx_buf = NULL; uint16_t rate = (((uint16_t)uart->rate_h) << 8) | uart->rate_l; uart->flowctrl = DMAUART_RESET; diff --git a/software/io/wifi/wifi.cc b/software/io/wifi/wifi.cc index b44aa095a..845035d97 100644 --- a/software/io/wifi/wifi.cc +++ b/software/io/wifi/wifi.cc @@ -19,6 +19,7 @@ #include "u64_config.h" #endif #include "init_function.h" +#include "wifi_dedicated.h" #define DEBUG_INPUT 0 #define EVENT_START 0xF1 @@ -636,6 +637,13 @@ void wifi_free(void *driver, void *buffer) w->freeBuffer((command_buf_t *)buffer); } +#if U64 == 1 +bool wifi_module_ready(void) +{ + return wifi.getState() >= eWifi_AppDetected; +} +#endif + extern "C" { void print_uart_status() { diff --git a/software/io/wifi/wifi_cmd.cc b/software/io/wifi/wifi_cmd.cc index d71dd47ae..5af68f592 100644 --- a/software/io/wifi/wifi_cmd.cc +++ b/software/io/wifi/wifi_cmd.cc @@ -2,8 +2,12 @@ #include "dump_hex.h" /// C like functions to 'talk' with the WiFi Module -static uint16_t sequence_nr = 0; +uint16_t sequence_nr = 0; static wifi_reply_slot_t replySlots[WIFI_REPLY_SLOTS]; +#if U64 == 1 +QueueHandle_t dedicated_replies = NULL; +volatile bool dedicated_waiting = false; +#endif void hex(uint8_t h) { @@ -17,6 +21,16 @@ BaseType_t wifi_rx_isr(command_buf_context_t *context, command_buf_t *buf, BaseT rpc_header_t *hdr = (rpc_header_t *)buf->data; BaseType_t res; +#if U64 == 1 + if (hdr->thread == WIFI_DEDICATED_THREAD) { + // pdFALSE makes the interrupt handler free the buffer. + if (!dedicated_waiting) { + return pdFALSE; + } + dedicated_reply_t reply = { buf, esp32.uart->generation }; + return xQueueSendFromISR(dedicated_replies, &reply, w); + } +#endif TaskHandle_t thread = (TaskHandle_t)wifi_reply_take(replySlots, hdr->thread, hdr->sequence); if (thread) { ioWrite8(UART_DATA, 'N'); @@ -82,6 +96,11 @@ void wifi_command_init(void) esp32.uart->FlowControl(true); esp32.uart->ClearRxBuffer(); esp32.uart->EnableSlip(true); +#if U64 == 1 + if (!dedicated_replies) { + dedicated_replies = xQueueCreate(4, sizeof(dedicated_reply_t)); + } +#endif esp32.uart->SetReceiveCallback(wifi_rx_isr); esp32.uart->EnableIRQ(true); } diff --git a/software/io/wifi/wifi_cmd.h b/software/io/wifi/wifi_cmd.h index 7c215f294..16914423d 100644 --- a/software/io/wifi/wifi_cmd.h +++ b/software/io/wifi/wifi_cmd.h @@ -73,6 +73,22 @@ command_buf_t *wifi_wait_reply(rpc_header_t hdr, int timeout_ms); int wifi_set_recovery_url(const char *url); int wifi_get_recovery_url(char *url, int maxlen); +extern uint16_t sequence_nr; + +// wifi_dedicated_call's thread number, which no transmit buffer has. While +// dedicated_waiting is set, the receive interrupt queues its replies in +// dedicated_replies, tagged with the buffer generation; otherwise it drops them. +// Not a reply slot (0 to WIFI_REPLY_SLOTS - 1), not 0xFF (no reply wanted), and not 0xFD to 0xFF, which +// the HTTPS provider channels of CMD_IDENTIFY use (#936) +#define WIFI_DEDICATED_THREAD 0xFC +#if U64 == 1 +typedef struct { + command_buf_t *buf; + uint32_t generation; +} dedicated_reply_t; +extern QueueHandle_t dedicated_replies; +extern volatile bool dedicated_waiting; +#endif extern "C" { void print_uart_status(); } extern const char *no_wifi_buf; extern const char *no_wifi_slot; diff --git a/software/io/wifi/wifi_dedicated.cc b/software/io/wifi/wifi_dedicated.cc new file mode 100644 index 000000000..4feb73749 --- /dev/null +++ b/software/io/wifi/wifi_dedicated.cc @@ -0,0 +1,140 @@ +// wifi_dedicated.cc: the one waiter for replies on WIFI_DEDICATED_THREAD, and +// GET_RANDOM, its first user. Not in wifi_cmd.cc, which the updater compiles. + +#include +#include "wifi_cmd.h" +#include "wifi_dedicated.h" +#include "wifi_random.h" + +static_assert(WIFI_RANDOM_BUSY == DEDICATED_BUSY, "codes differ"); +static_assert(WIFI_RANDOM_NO_MODULE == DEDICATED_NO_MODULE, "codes differ"); +static_assert(WIFI_RANDOM_FOREIGN == DEDICATED_FOREIGN, "codes differ"); +// The log reads esp_err where every reply that has one keeps it. +static_assert(sizeof(rpc_espcmd_resp) == offsetof(rpc_get_random_resp, source), "rpc_espcmd_resp changed"); + +// Hands a queued reply to take, then frees it. One queued before the last pool +// reset is dropped unread, as its buffer may be someone else's by now; the +// scheduler stays suspended so that no reset comes in between. check false: free only. +static int take_dedicated_reply(const dedicated_call_t *call, dedicated_reply_t *reply, bool check, uint16_t sequence) +{ + int retval = DEDICATED_FOREIGN; + int size = 0; + int esp_err = 0; + vTaskSuspendAll(); + if (reply->generation == esp32.uart->generation) { + command_buf_t *packet = reply->buf; + if (check) { + size = packet->size; + if (size >= (int)sizeof(rpc_espcmd_resp)) { + esp_err = ((rpc_espcmd_resp *)packet->data)->esp_err; + } + retval = call->take(packet->data, size, sequence, call->context); + } + esp32.uart->FreeBuffer(packet); // does not block + } + xTaskResumeAll(); + if ((retval != 0) && (retval != DEDICATED_FOREIGN)) { + if (size >= (int)sizeof(rpc_espcmd_resp)) { + printf("%s failed (%d). Size: %d. Error: %d.\n", call->name, retval, size, esp_err); + } else { + printf("%s failed (%d). Size: %d.\n", call->name, retval, size); + } + } + return retval; +} + +// Unlike wifi_cmd.cc, neither waits forever nor trusts the reply: take decides. +// Between calls dedicated_waiting is clear and dedicated_replies is empty. +int wifi_dedicated_call(const dedicated_call_t *call) +{ + // Without the module application nothing can answer; fail now, not on a timeout. + if (!wifi_module_ready() || !dedicated_replies) { + return DEDICATED_NO_MODULE; + } + // One request at a time: a second caller fails rather than waits. + bool busy; + ENTER_SAFE_SECTION; + busy = dedicated_waiting; + dedicated_waiting = true; + LEAVE_SAFE_SECTION; + if (busy) { + return DEDICATED_BUSY; + } + + int retval = DEDICATED_BUSY; + uint16_t sequence = sequence_nr++; + dedicated_reply_t reply; + command_buf_t *packet; + if (esp32.uart->GetBuffer(&packet, 4) == pdFALSE) { // 20 ms + printf(no_wifi_buf); + } else { + rpc_header_t *hdr = (rpc_header_t *)packet->data; + hdr->command = call->command; + hdr->sequence = sequence; + hdr->thread = WIFI_DEDICATED_THREAD; + packet->size = call->fill(packet->data, call->context); + + if (esp32.uart->TransmitPacket(packet) == pdTRUE) { + // A late reply to an earlier request is skipped, within the same timeout. + const TickType_t timeout = pdMS_TO_TICKS(call->timeout_ms); + TickType_t start = xTaskGetTickCount(); + retval = DEDICATED_FOREIGN; + while (retval == DEDICATED_FOREIGN) { + TickType_t spent = xTaskGetTickCount() - start; + if ((spent >= timeout) || + (xQueueReceive(dedicated_replies, &reply, timeout - spent) == pdFALSE)) { + retval = DEDICATED_BUSY; + break; + } + retval = take_dedicated_reply(call, &reply, true, sequence); + } + } + } + + // Stop the interrupt from queueing replies, then release what it queued. + // After a timeout that can still be our reply. + dedicated_waiting = false; + while (xQueueReceive(dedicated_replies, &reply, 0) == pdTRUE) { + if (retval == DEDICATED_BUSY) { + retval = take_dedicated_reply(call, &reply, true, sequence); + if (retval == DEDICATED_FOREIGN) { + retval = DEDICATED_BUSY; + } + } else { + take_dedicated_reply(call, &reply, false, 0); + } + } + if (retval == DEDICATED_BUSY) { + printf("%s: no reply.\n", call->name); + } + return retval; +} + +typedef struct { + uint8_t *buf; + uint16_t len; +} random_call_t; + +static int fill_random(uint8_t *request, void *context) +{ + rpc_get_random_req *args = (rpc_get_random_req *)request; + args->length = ((random_call_t *)context)->len; + return sizeof(rpc_get_random_req); +} + +static int take_random(const uint8_t *reply, int size, uint16_t sequence, void *context) +{ + random_call_t *c = (random_call_t *)context; + return wifi_random_take_reply(reply, size, sequence, c->buf, c->len); +} + +// A C64 program is waiting on the UCI for this one. Bytes are only handed out +// when the reply is the answer to this request and carries all of them. +int wifi_get_random(uint8_t *buf, uint16_t len) +{ + random_call_t args = { buf, len }; + // About 1 ms on the wire; far longer only while the module's dispatcher is + // blocked handing a scan or connect to its connector, which is worth a retry. + const dedicated_call_t call = { "Get Random", CMD_GET_RANDOM, 200, fill_random, take_random, &args }; + return wifi_dedicated_call(&call); +} diff --git a/software/io/wifi/wifi_dedicated.h b/software/io/wifi/wifi_dedicated.h new file mode 100644 index 000000000..8b2b9c055 --- /dev/null +++ b/software/io/wifi/wifi_dedicated.h @@ -0,0 +1,34 @@ +// wifi_dedicated.h: requests whose replies bypass the reply slots and are +// awaited with a deadline, one at a time. Free of rpc_calls.h and FreeRTOS. + +#ifndef WIFI_DEDICATED_H_ +#define WIFI_DEDICATED_H_ + +#include + +// What wifi_dedicated_call returns itself. Anything else comes from take. +// Callers keep their own numbers for these, and assert that they match. +#define DEDICATED_BUSY 1 // no answer in time, or not sent (channel taken, no buffer); retry +#define DEDICATED_NO_MODULE 4 // the module application is not running; nothing was sent +#define DEDICATED_FOREIGN 5 // from take only: not the answer to this request + +typedef struct { + const char *name; // for the log + uint8_t command; // CMD_* + uint32_t timeout_ms; // for the answer, from the moment the request is queued + // Writes the arguments after the header and returns the request's size. + // It may not fail, so the caller checks the arguments first. + int (*fill)(uint8_t *request, void *context); + // Takes what it needs from the answer to request sequence, or returns + // DEDICATED_FOREIGN. Runs with the scheduler suspended: no blocking, no printing. + int (*take)(const uint8_t *reply, int size, uint16_t sequence, void *context); + void *context; +} dedicated_call_t; + +// Sends one request and waits for its answer. U64 only. +int wifi_dedicated_call(const dedicated_call_t *call); + +// Whether the module application has been detected. In wifi.cc. +bool wifi_module_ready(void); + +#endif /* WIFI_DEDICATED_H_ */ diff --git a/software/io/wifi/wifi_random.cc b/software/io/wifi/wifi_random.cc new file mode 100644 index 000000000..98b2bb632 --- /dev/null +++ b/software/io/wifi/wifi_random.cc @@ -0,0 +1,63 @@ +// wifi_random.cc: checks the WiFi module's answer to GET_RANDOM. Free of +// FreeRTOS and of the UART driver, so that the host test tests what ships. + +#include +#include +#include "rpc_calls.h" +#include "wifi_random.h" + +// The layout the module sends and this code reads. Checked here so that the +// firmware build itself, not only the host test, fails if it ever changes. +static_assert(sizeof(rpc_get_random_req) == 6, "rpc_get_random_req changed"); +static_assert(offsetof(rpc_get_random_req, length) == 4, "rpc_get_random_req changed"); +static_assert(sizeof(rpc_get_random_resp) == 12, "rpc_get_random_resp changed"); +static_assert(offsetof(rpc_get_random_resp, esp_err) == 4, "rpc_get_random_resp changed"); +static_assert(offsetof(rpc_get_random_resp, source) == 8, "rpc_get_random_resp changed"); +static_assert(offsetof(rpc_get_random_resp, length) == 10, "rpc_get_random_resp changed"); +static_assert(offsetof(rpc_get_random_resp, data) == 12, "rpc_get_random_resp changed"); + +int wifi_random_take_reply(const uint8_t *reply, int size, uint16_t sequence, + uint8_t *buf, uint16_t len) +{ + const rpc_get_random_resp *result = (const rpc_get_random_resp *)reply; + const int with_error = offsetof(rpc_get_random_resp, source); + const int header = offsetof(rpc_get_random_resp, data); + + if ((size < (int)sizeof(rpc_header_t)) || (result->hdr.command != CMD_GET_RANDOM) || + (result->hdr.sequence != sequence)) { + return WIFI_RANDOM_FOREIGN; + } + if (size < with_error) { + return WIFI_RANDOM_INVALID; + } + if (result->esp_err != 0) { + return WIFI_RANDOM_REFUSED; + } + if (size < header) { + return WIFI_RANDOM_INVALID; + } + // Bytes drawn without an entropy source are refused even when esp_err + // says OK. + if (result->source == ENTROPY_NONE) { + return WIFI_RANDOM_REFUSED; + } + if ((result->length != len) || (size < header + len)) { + return WIFI_RANDOM_INVALID; + } + memcpy(buf, result->data, len); + return 0; +} + +int wifi_random_status(int result) +{ + switch (result) { + case 0: + return 0; + case WIFI_RANDOM_BUSY: + return 88; + case WIFI_RANDOM_INVALID: + return 86; + default: + return 87; + } +} diff --git a/software/io/wifi/wifi_random.h b/software/io/wifi/wifi_random.h new file mode 100644 index 000000000..fa8b803bb --- /dev/null +++ b/software/io/wifi/wifi_random.h @@ -0,0 +1,29 @@ +// wifi_random.h: hardware random bytes from the WiFi module. Apart from +// wifi_cmd.h, whose rpc_calls.h clashes with the command interface (CMD_IDENTIFY). + +#ifndef WIFI_RANDOM_H_ +#define WIFI_RANDOM_H_ + +#include + +// Fills buf with len bytes from the module's hardware random number generator +// and returns 0, or returns one of the codes below and leaves buf untouched. +// U64 only. +int wifi_get_random(uint8_t *buf, uint16_t len); +#define WIFI_RANDOM_BUSY 1 // no answer in time; the module may be busy +#define WIFI_RANDOM_REFUSED 2 // the module refused, or had no entropy source +#define WIFI_RANDOM_INVALID 3 // the answer is not a well formed reply +#define WIFI_RANDOM_NO_MODULE 4 // the module application is not running + +// Checks size bytes at reply as the answer to request sequence for len bytes. +// Only a well formed answer of exactly len bytes from a real source returns 0 +// and copies the bytes to buf; nothing else touches buf. +int wifi_random_take_reply(const uint8_t *reply, int size, uint16_t sequence, + uint8_t *buf, uint16_t len); +#define WIFI_RANDOM_FOREIGN 5 // not the answer to this request + +// The UCI status for a result of wifi_get_random: 0 (the bytes go out) for 0 only, +// 88 (busy) for WIFI_RANDOM_BUSY, 86 (internal error) for WIFI_RANDOM_INVALID, 87 otherwise. +int wifi_random_status(int result); + +#endif /* WIFI_RANDOM_H_ */ diff --git a/software/test/wifi_dedicated/check.cc b/software/test/wifi_dedicated/check.cc new file mode 100644 index 000000000..7a0c51e18 --- /dev/null +++ b/software/test/wifi_dedicated/check.cc @@ -0,0 +1,22 @@ +// check.cc: see check.h. +#include +#include "check.h" + +int failures; +int checks; + +void check(bool condition, const char *what, ...) +{ + char line[300]; + va_list ap; + va_start(ap, what); + vsnprintf(line, sizeof(line), what, ap); + va_end(ap); + checks++; + if (!condition) { + failures++; + printf(" FAIL %s\n", line); + } else { + printf(" ok %s\n", line); + } +} diff --git a/software/test/wifi_dedicated/check.h b/software/test/wifi_dedicated/check.h new file mode 100644 index 000000000..bca1b8d11 --- /dev/null +++ b/software/test/wifi_dedicated/check.h @@ -0,0 +1,8 @@ +#ifndef CHECK_H_ +#define CHECK_H_ +#include +extern int failures; +extern int checks; +// Counts one check and prints it: "ok" or "FAIL". +void check(bool condition, const char *what, ...); +#endif diff --git a/software/test/wifi_dedicated/stub/FreeRTOS.h b/software/test/wifi_dedicated/stub/FreeRTOS.h new file mode 100644 index 000000000..44ddca460 --- /dev/null +++ b/software/test/wifi_dedicated/stub/FreeRTOS.h @@ -0,0 +1,17 @@ +// Host stand-in for FreeRTOS.h: the types and macros the code under test uses. +#ifndef FREERTOS_H_STUB +#define FREERTOS_H_STUB +#include +#include +typedef uint32_t TickType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; +typedef void *QueueHandle_t; +typedef void *TaskHandle_t; +#define pdTRUE 1 +#define pdFALSE 0 +#define configTICK_RATE_HZ 200 +#define portTICK_PERIOD_MS (1000 / configTICK_RATE_HZ) +// As in software/FreeRTOS/Source/include/projdefs.h. +#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) +#endif diff --git a/software/test/wifi_dedicated/stub/queue.h b/software/test/wifi_dedicated/stub/queue.h new file mode 100644 index 000000000..cb7604eb5 --- /dev/null +++ b/software/test/wifi_dedicated/stub/queue.h @@ -0,0 +1,5 @@ +#ifndef QUEUE_H_STUB +#define QUEUE_H_STUB +#include "FreeRTOS.h" +BaseType_t xQueueReceive(QueueHandle_t queue, void *item, TickType_t ticks); +#endif diff --git a/software/test/wifi_dedicated/stub/task.h b/software/test/wifi_dedicated/stub/task.h new file mode 100644 index 000000000..a6408e654 --- /dev/null +++ b/software/test/wifi_dedicated/stub/task.h @@ -0,0 +1,8 @@ +#ifndef TASK_H_STUB +#define TASK_H_STUB +#include "FreeRTOS.h" +TickType_t xTaskGetTickCount(void); +void vTaskSuspendAll(void); +BaseType_t xTaskResumeAll(void); +void vTaskDelay(TickType_t ticks); +#endif diff --git a/software/test/wifi_dedicated/stub/wifi_cmd.h b/software/test/wifi_dedicated/stub/wifi_cmd.h new file mode 100644 index 000000000..9548c8170 --- /dev/null +++ b/software/test/wifi_dedicated/stub/wifi_cmd.h @@ -0,0 +1,51 @@ +// Host stand-in for software/io/wifi/wifi_cmd.h: only what wifi_dedicated.cc +// uses, backed by world.cc. Keep the declarations in step with the real header. +#ifndef WIFI_CMD_H_ +#define WIFI_CMD_H_ + +#include +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "rpc_calls.h" +extern "C" { + #include "cmd_buffer.h" +} + +class DmaUART +{ +public: + volatile uint32_t generation; + BaseType_t GetBuffer(command_buf_t **buf, TickType_t ticks); + BaseType_t TransmitPacket(command_buf_t *buf, uint16_t *ms = NULL); + BaseType_t FreeBuffer(command_buf_t *buf); +}; + +class Esp32 +{ +public: + DmaUART *uart; +}; +extern Esp32 esp32; + +extern uint16_t sequence_nr; +extern const char *no_wifi_buf; + +#define WIFI_DEDICATED_THREAD 0xFC +typedef struct { + command_buf_t *buf; + uint32_t generation; +} dedicated_reply_t; +extern QueueHandle_t dedicated_replies; +extern volatile bool dedicated_waiting; + +void world_enter_safe(void); +void world_leave_safe(void); +#define ENTER_SAFE_SECTION world_enter_safe() +#define LEAVE_SAFE_SECTION world_leave_safe() + +// Everything the code under test prints goes into the trace. +int world_printf(const char *fmt, ...); +#define printf world_printf + +#endif /* WIFI_CMD_H_ */ diff --git a/software/test/wifi_dedicated/wifi_dedicated_test.cc b/software/test/wifi_dedicated/wifi_dedicated_test.cc new file mode 100644 index 000000000..543177026 --- /dev/null +++ b/software/test/wifi_dedicated/wifi_dedicated_test.cc @@ -0,0 +1,411 @@ +// Host test of wifi_dedicated.cc: GET_RANDOM through the dedicated channel, and +// the channel's own waits, in the scripted world of world.cc. +// make -C target/pc/linux/wifidedicated test +#include +#include +#include +#include "world.h" +#include "wifi_dedicated.h" +#include "wifi_random.h" +#include "check.h" +#undef printf + +// The replies random_maker builds. 0 to 3 are the right answer. +enum { + RIGHT = 0, + LATE = 4, // the answer to the previous request + OTHER_COMMAND = 5, // the answer to another command + REFUSED = 6, // esp_err set, no bytes + NO_SOURCE = 7, // bytes, but no entropy source + TRUNCATED = 8, // cut short at a random size + LONGER = 9, // one byte more than asked for + SHORT = 10, // one byte missing; scripts only +}; + +// The bytes of every right answer made in this world, by sequence number. +struct made_t { + uint16_t sequence; + std::vector data; +}; +static std::vector made; + +static void random_maker(command_buf_t *rx, const uint8_t *req, int req_size, int kind) +{ + const rpc_get_random_req *request = (const rpc_get_random_req *)req; + uint16_t sequence = (req_size >= 0) ? request->hdr.sequence : (uint16_t)world_rand(65536); + uint16_t len = (req_size >= 0) ? request->length : 32; + if (len > RANDOM_MAX_BYTES) { + len = RANDOM_MAX_BYTES; + } + rpc_get_random_resp *r = (rpc_get_random_resp *)rx->data; + memset(rx->data, 0, sizeof(rx->data)); + r->hdr.command = CMD_GET_RANDOM; + r->hdr.thread = WIFI_DEDICATED_THREAD; + r->hdr.sequence = sequence; + r->esp_err = 0; + r->source = ENTROPY_RADIO; + r->length = len; + for (int i = 0; i < len; i++) { + r->data[i] = (uint8_t)world_rand(256); + } + rx->size = sizeof(rpc_get_random_resp) + len; + switch (kind) { + case LATE: r->hdr.sequence = sequence - 1; break; + case OTHER_COMMAND: r->hdr.command = (uint8_t)(CMD_GET_RANDOM + 1 + world_rand(255)); break; + case REFUSED: r->esp_err = 0x103; r->length = 0; rx->size = sizeof(rpc_get_random_resp); break; + case NO_SOURCE: r->source = ENTROPY_NONE; break; + case TRUNCATED: rx->size = world_rand(sizeof(rpc_get_random_resp) + len); break; + case LONGER: r->length = len + 1; break; + case SHORT: rx->size--; break; + default: made.push_back({ sequence, std::vector(r->data, r->data + len) }); break; + } +} + +static int count(const std::string &text, const std::string &what) +{ + int n = 0; + for (size_t at = text.find(what); at != std::string::npos; at = text.find(what, at + 1)) { + n++; + } + return n; +} + +static bool printed(const char *line) +{ + return world_trace.find(std::string("print: ") + line) != std::string::npos; +} + +// The right answer made for sequence, if its bytes are those at buf. +static bool from_right_answer(uint16_t sequence, const uint8_t *buf, uint16_t len) +{ + for (const made_t &m : made) { + if ((m.sequence == sequence) && (m.data.size() == len) && (memcmp(m.data.data(), buf, len) == 0)) { + return true; + } + } + return false; +} + +// A script step: kinds arriving delay ticks into the wait. +static world_step_t at(TickType_t delay, std::initializer_list kinds, bool stale = false, + TickType_t preempt = 0) +{ + world_step_t s; + memset(&s, 0, sizeof(s)); + s.delay = delay; + s.preempt = preempt; + for (int kind : kinds) { + s.stale[s.count] = stale; + s.kind[s.count++] = kind; + } + return s; +} + +#define UNTOUCHED 0xEE +#define WAIT_TICKS 40 // GET_RANDOM's 200 ms + +typedef struct { + int result; + uint16_t sequence; // the request's, if one was sent + uint16_t advanced; // how far sequence_nr moved + uint8_t buf[RANDOM_MAX_BYTES + 8]; +} outcome_t; + +static void get_random(uint16_t len, outcome_t *o) +{ + memset(o->buf, UNTOUCHED, sizeof(o->buf)); + o->sequence = sequence_nr; + o->result = wifi_get_random(o->buf, len); + o->advanced = (uint16_t)(sequence_nr - o->sequence); +} + +static bool untouched(const outcome_t *o) +{ + for (size_t i = 0; i < sizeof(o->buf); i++) { + if (o->buf[i] != UNTOUCHED) { + return false; + } + } + return true; +} + +static bool channel_free(void) +{ + return !dedicated_waiting && (world_queued() == 0) && (world_suspended == 0) && + (world_trace.find("not suspended") == std::string::npos); +} + +// One GET_RANDOM of 32 bytes in a calm world that answers with steps. +static void scripted(uint32_t seed, const world_step_t *steps, int n, outcome_t *o) +{ + made.clear(); + world_reset(seed, random_maker, true); + world_script(steps, n); + get_random(32, o); +} + +static void test_answers(void) +{ + printf("GET_RANDOM: what each reply leads to\n"); + outcome_t o; + const world_step_t right[] = { at(1, { RIGHT }) }; + scripted(1, right, 1, &o); + check((o.result == 0) && from_right_answer(o.sequence, o.buf, 32) && + (o.buf[32] == UNTOUCHED) && (o.advanced == 1) && channel_free(), + "the answer: 0, its 32 bytes and nothing past them, the sequence number moved on by one"); + + struct { + int kind; + int result; + const char *line; + const char *what; + } const single[] = { + { LATE, WIFI_RANDOM_BUSY, "Get Random: no reply.", "an answer to the previous request is skipped: BUSY" }, + { OTHER_COMMAND, WIFI_RANDOM_BUSY, "Get Random: no reply.", "an answer to another command is skipped: BUSY" }, + { REFUSED, WIFI_RANDOM_REFUSED, "Get Random failed (2). Size: 12. Error: 259.", "a refusal: REFUSED" }, + { NO_SOURCE, WIFI_RANDOM_REFUSED, "Get Random failed (2). Size: 44. Error: 0.", "bytes without a source: REFUSED" }, + { LONGER, WIFI_RANDOM_INVALID, "Get Random failed (3). Size: 44. Error: 0.", "one byte too many: INVALID" }, + { SHORT, WIFI_RANDOM_INVALID, "Get Random failed (3). Size: 43. Error: 0.", "one byte missing: INVALID" }, + }; + for (const auto &c : single) { + const world_step_t step[] = { at(1, { c.kind }) }; + scripted(2, step, 1, &o); + check((o.result == c.result) && untouched(&o) && printed(c.line) && (o.advanced == 1) && channel_free(), + "%s, no bytes, logged", c.what); + } + + const world_step_t stale[] = { at(1, { RIGHT }, true) }; + scripted(3, stale, 1, &o); + check((o.result == WIFI_RANDOM_BUSY) && untouched(&o) && (count(world_trace, "free b") == 0) && channel_free(), + "the answer queued before a pool reset is dropped unread and not freed: BUSY"); + const world_step_t foreign_first[] = { at(1, { LATE, RIGHT }) }; + scripted(4, foreign_first, 1, &o); + check((o.result == 0) && from_right_answer(o.sequence, o.buf, 32) && channel_free(), + "a late answer, then the answer, in one wait: the answer is taken"); + const world_step_t two_waits[] = { at(5, { OTHER_COMMAND }), at(10, { RIGHT }) }; + scripted(5, two_waits, 2, &o); + check((o.result == 0) && from_right_answer(o.sequence, o.buf, 32) && (count(world_trace, "receive ") == 3), + "another command's answer, then the answer 10 ticks later: taken in the second wait"); + const world_step_t too_late[] = { at(WAIT_TICKS + 1, { RIGHT }) }; + scripted(6, too_late, 1, &o); + check((o.result == WIFI_RANDOM_BUSY) && untouched(&o) && printed("Get Random: no reply.") && channel_free(), + "an answer after 200 ms: BUSY"); + + const world_step_t overshoot[] = { at(WAIT_TICKS - 1, { OTHER_COMMAND }, false, 5) }; + scripted(11, overshoot, 1, &o); + check((o.result == WIFI_RANDOM_BUSY) && untouched(&o) && (world_wait_span <= WAIT_TICKS) && + (count(world_trace, "receive 0") == 1) && channel_free(), + "a skipped reply just before the deadline, then preempted past it: BUSY, no wait beyond 200 ms " + "(%llu ticks)", (unsigned long long)world_wait_span); + const world_step_t skipped_early[] = { at(10, { OTHER_COMMAND }) }; + scripted(12, skipped_early, 1, &o); + check((o.result == WIFI_RANDOM_BUSY) && (world_wait_span == WAIT_TICKS) && channel_free(), + "a reply skipped 10 ticks in: the wait goes on to the deadline, not 200 ms past the skip (%llu ticks)", + (unsigned long long)world_wait_span); + + // The wait ends on a skipped reply with the timeout spent; what is still + // queued behind it decides the result. + const world_step_t tail_right[] = { at(WAIT_TICKS, { OTHER_COMMAND, RIGHT }) }; + scripted(7, tail_right, 1, &o); + check((o.result == 0) && from_right_answer(o.sequence, o.buf, 32) && channel_free(), + "the answer queued behind a skipped reply as the time runs out is still taken"); + const world_step_t tail_foreign[] = { at(WAIT_TICKS, { OTHER_COMMAND, LATE }) }; + scripted(8, tail_foreign, 1, &o); + check((o.result == WIFI_RANDOM_BUSY) && untouched(&o) && printed("Get Random: no reply.") && channel_free(), + "only foreign replies queued as the time runs out: BUSY, not FOREIGN (%d)", o.result); + const world_step_t tail_refused[] = { at(WAIT_TICKS, { OTHER_COMMAND, REFUSED }) }; + scripted(9, tail_refused, 1, &o); + check((o.result == WIFI_RANDOM_REFUSED) && untouched(&o) && channel_free(), + "a refusal queued behind a skipped reply as the time runs out: REFUSED"); + const world_step_t burst[] = { at(1, { RIGHT, RIGHT, RIGHT, RIGHT }) }; + scripted(10, burst, 1, &o); + check((o.result == 0) && (count(world_trace, "free b") == 4) && channel_free(), + "a burst of four: the first is taken, the other three released, all freed"); +} + +static void test_orderings(void) +{ + printf("GET_RANDOM: the deadline and the claim, around the queue\n"); + outcome_t o; + const world_step_t nothing[] = { at(100000, {}) }; + made.clear(); + world_reset(13, random_maker, true); + world_script(nothing, 1); + world_transmit_ticks = 30; + get_random(32, &o); + check((o.result == WIFI_RANDOM_BUSY) && (world_wait_span == WAIT_TICKS) && channel_free(), + "a request that takes 150 ms to queue still waits 200 ms from then (%llu ticks)", + (unsigned long long)world_wait_span); + made.clear(); + world_reset(14, random_maker, true); + world_script(nothing, 1); + world_late_after_poll = 1; + get_random(32, &o); + check((o.result == WIFI_RANDOM_BUSY) && channel_free(), + "a reply arriving as the queue is drained finds the claim released: nothing is left queued"); +} + +static void test_sequence(void) +{ + printf("GET_RANDOM: the request and its sequence number\n"); + made.clear(); + world_reset(20, random_maker, true); + uint16_t first = sequence_nr; + outcome_t a, b; + get_random(300, &a); + std::string request = world_trace.substr(world_trace.find("transmit")); + char want[64]; + snprintf(want, sizeof(want), "transmit 6: %02x %02x %02x %02x 2c 01\n", CMD_GET_RANDOM, + WIFI_DEDICATED_THREAD, first & 0xFF, first >> 8); + check(request.compare(0, strlen(want), want) == 0, + "the request: CMD_GET_RANDOM, the dedicated thread, the sequence number, the length (%s)", want); + world_trace.clear(); + const world_step_t late[] = { at(1, { LATE, RIGHT }) }; + world_script(late, 1); + get_random(300, &b); + check((a.result == 0) && (b.result == 0) && (b.sequence == (uint16_t)(first + 1)) && + (sequence_nr == (uint16_t)(first + 2)) && from_right_answer(b.sequence, b.buf, 300) && + !from_right_answer(a.sequence, b.buf, 300), + "two calls: two sequence numbers, and the first's late answer is not taken for the second's"); +} + +static void test_unsent(void) +{ + printf("GET_RANDOM: when nothing is sent\n"); + outcome_t o; + world_reset(30, random_maker, true); + world_ready = false; + get_random(32, &o); + check((o.result == WIFI_RANDOM_NO_MODULE) && untouched(&o) && world_trace.empty() && (o.advanced == 0), + "no module application: NO_MODULE, nothing tried"); + world_reset(31, random_maker, true); + dedicated_replies = NULL; + get_random(32, &o); + check((o.result == WIFI_RANDOM_NO_MODULE) && world_trace.empty(), "no reply queue: NO_MODULE, nothing tried"); + world_reset(32, random_maker, true); + dedicated_waiting = true; + get_random(32, &o); + check((o.result == WIFI_RANDOM_BUSY) && untouched(&o) && dedicated_waiting && (world_transmits == 0) && + (o.advanced == 0), + "another request outstanding: BUSY at once, its claim left alone, nothing sent"); + world_reset(33, random_maker, true); + world_no_buffer = true; + get_random(32, &o); + check((o.result == WIFI_RANDOM_BUSY) && untouched(&o) && printed("No buffer for WiFi command.") && + (world_transmits == 0) && channel_free(), + "no buffer: BUSY, logged, the channel free again"); + world_reset(34, random_maker, true); + world_no_transmit = true; + get_random(32, &o); + check((o.result == WIFI_RANDOM_BUSY) && untouched(&o) && printed("Get Random: no reply.") && channel_free(), + "a failed transmit: BUSY, the channel free again"); +} + +// Seeds of a world where anything can go wrong: replies right, late, foreign, +// refused, short, stale, in bursts, after preemption, near the tick wrap. +static void test_random_world(void) +{ + printf("GET_RANDOM in a world where anything goes wrong, seed by seed\n"); + static const uint16_t lengths[] = { 1, 2, 3, 31, 32, 255, 256, 257, 300, 511, 512 }; + const uint32_t seeds = 100000; + int wrong = 0; + int results[5] = { 0 }; + int with[6] = { 0 }; + const char *features[6] = { "a stale reply dropped", "the queue overflowing", "a reply refused or invalid", + "no buffer", "a failed transmit", "a reply released after the wait" }; + static outcome_t o; + for (uint32_t seed = 1; seed <= seeds; seed++) { + made.clear(); + world_reset(seed, random_maker, false); + bool held = dedicated_waiting; + bool gated = held || !world_ready || !dedicated_replies; + uint16_t len = (world_rand(4) == 0) ? (uint16_t)(1 + world_rand(RANDOM_MAX_BYTES)) + : lengths[world_rand(sizeof(lengths) / sizeof(lengths[0]))]; + get_random(len, &o); + bool ok = (o.result >= 0) && (o.result <= WIFI_RANDOM_NO_MODULE) && (o.advanced == (gated ? 0 : 1)) && + (dedicated_waiting == held) && (world_suspended == 0) && + (world_trace.find("not suspended") == std::string::npos) && (gated || (world_queued() == 0)) && + (world_wait_span <= WAIT_TICKS); + if (o.result == 0) { + ok = ok && from_right_answer(o.sequence, o.buf, len) && + (o.buf[len] == UNTOUCHED); + } else { + ok = ok && untouched(&o); + } + if (!ok) { + if (wrong++ < 3) { + printf(" seed %u: result %d, sequence moved %u, waited up to %llu ticks\n", seed, o.result, + o.advanced, (unsigned long long)world_wait_span); + } + continue; + } + results[o.result]++; + const std::string &t = world_trace; + with[0] += t.find("suspend\nresume\n") != std::string::npos; // looked at, not freed + with[1] += t.find("(full)") != std::string::npos; + with[2] += t.find("Get Random failed") != std::string::npos; + with[3] += t.find("getbuffer 4 -> none") != std::string::npos; + with[4] += t.find("-> failed") != std::string::npos; + with[5] += t.find("receive 0 -> b") != std::string::npos; + } + check(wrong == 0, "%u seeds: bytes only from this request's answer, no wait past the 200 ms deadline, the " + "sequence number and the channel as they should be (%d not)", seeds, wrong); + printf(" results: 0 OK %d, 1 BUSY %d, 2 REFUSED %d, 3 INVALID %d, 4 NO_MODULE %d\n", + results[0], results[1], results[2], results[3], results[4]); + for (int i = 0; i < 6; i++) { + check(with[i] > 100, "the seeds include %s (%d)", features[i], with[i]); + } +} + +// A call of the channel's own, with its own timeout. +static int takes; +static uint8_t taken[32]; + +static int fill_test(uint8_t *request, void *context) +{ + ((rpc_get_random_req *)request)->length = sizeof(taken); + return sizeof(rpc_get_random_req); +} + +static int take_test(const uint8_t *reply, int size, uint16_t sequence, void *context) +{ + int retval = wifi_random_take_reply(reply, size, sequence, taken, sizeof(taken)); + takes += (retval != DEDICATED_FOREIGN); + return retval; +} + +static int call(uint32_t timeout_ms) +{ + takes = 0; + const dedicated_call_t c = { "Test", CMD_GET_RANDOM, timeout_ms, fill_test, take_test, NULL }; + return wifi_dedicated_call(&c); +} + +static void test_waits(void) +{ + printf("The channel's wait: the caller's timeout, in one go\n"); + const world_step_t nothing[] = { at(100000, {}) }; + world_reset(40, random_maker, true); + world_script(nothing, 1); + int r = call(5000); + check((r == DEDICATED_BUSY) && (count(world_trace, "receive 1000") == 1) && (takes == 0) && + printed("Test: no reply.") && (world_wait_span == 1000) && channel_free(), + "nothing arrives: one wait of the whole timeout (5 s = 1000 ticks), then BUSY"); + const world_step_t late[] = { at(999, { RIGHT }) }; + world_reset(41, random_maker, true); + world_script(late, 1); + r = call(5000); + check((r == 0) && (takes == 1) && channel_free(), "the answer a tick before the timeout is taken"); +} + +int main(void) +{ + test_answers(); + test_sequence(); + test_orderings(); + test_unsent(); + test_random_world(); + test_waits(); + printf("\n%d checks, %d failures\n", checks, failures); + return failures ? 1 : 0; +} diff --git a/software/test/wifi_dedicated/world.cc b/software/test/wifi_dedicated/world.cc new file mode 100644 index 000000000..4b774cb6d --- /dev/null +++ b/software/test/wifi_dedicated/world.cc @@ -0,0 +1,326 @@ +// world.cc: see world.h. +#include +#include +#include +#include "world.h" + +Esp32 esp32; +uint16_t sequence_nr; +const char *no_wifi_buf = "No buffer for WiFi command.\n"; +QueueHandle_t dedicated_replies; +volatile bool dedicated_waiting; + +bool world_ready; +bool world_no_buffer; +bool world_no_transmit; +std::string world_trace; +int world_suspended; +int world_transmits; +uint64_t world_wait_span; +TickType_t world_transmit_ticks; +int world_late_after_poll; + +#define QUEUE_DEPTH 4 // as wifi_cmd.cc creates it +#define RX_BUFFERS 16 + +static DmaUART uart; +static std::deque queue; +static uint32_t rng; +static TickType_t now; +static command_buf_t tx_buf; +static command_buf_t rx_bufs[RX_BUFFERS]; +static int rx_next; +static uint8_t last_tx[CMD_BUF_SIZE]; +static int last_tx_size; +static world_maker_t make_reply; +static bool calm; +static bool calm_delivered; +static const world_step_t *script; +static int script_left; +static TickType_t script_waited; // of the current step's delay, in earlier waits +static TickType_t preempt_next; // added at the next tick read +static bool start_pending; // a request went out; the next tick read starts its deadline +static TickType_t start_tick; + +static void trace(const char *fmt, ...) +{ + char line[256]; + va_list ap; + va_start(ap, fmt); + vsnprintf(line, sizeof(line), fmt, ap); + va_end(ap); + world_trace += line; +} + +uint32_t world_rand(uint32_t n) +{ + rng ^= rng << 13; + rng ^= rng >> 17; + rng ^= rng << 5; + return n ? (rng % n) : 0; +} + +size_t world_queued(void) +{ + return queue.size(); +} + +void world_reset(uint32_t seed, world_maker_t maker, bool quiet) +{ + rng = (seed * 2654435761u) ^ 0x9E3779B9u; + if (!rng) { + rng = 1; + } + make_reply = maker; + calm = quiet; + calm_delivered = false; + script = NULL; + script_left = 0; + script_waited = 0; + preempt_next = 0; + start_pending = false; + start_tick = 0; + world_wait_span = 0; + world_transmit_ticks = 0; + world_late_after_poll = 0; + world_trace.clear(); + queue.clear(); + world_suspended = 0; + world_transmits = 0; + rx_next = 0; + last_tx_size = -1; + // Now and then start just short of the tick counter wrapping. + now = (world_rand(4) == 0) ? (0xFFFFFFFFu - world_rand(400)) : world_rand(100000); + sequence_nr = (uint16_t)world_rand(65536); + uart.generation = world_rand(1000); + esp32.uart = &uart; + world_ready = calm || (world_rand(100) >= 3); + world_no_buffer = false; + world_no_transmit = false; + dedicated_replies = (!calm && (world_rand(100) < 2)) ? NULL : (QueueHandle_t)&queue; + dedicated_waiting = !calm && (world_rand(100) < 5); // another caller holds the channel + memset(tx_buf.data, 0xAB, sizeof(tx_buf.data)); + tx_buf.bufnr = 3; + for (int i = 0; i < RX_BUFFERS; i++) { + rx_bufs[i].bufnr = 0x40 | i; + } +} + +void world_script(const world_step_t *steps, int count) +{ + script = steps; + script_left = count; + script_waited = 0; +} + +// The receive interrupt, as wifi_rx_isr handles a frame on the dedicated thread. +static void isr_deliver(int kind, bool stale) +{ + command_buf_t *rx = &rx_bufs[rx_next++ % RX_BUFFERS]; + make_reply(rx, last_tx, last_tx_size, kind); + uint32_t generation = uart.generation; + if (stale) { + generation--; // tagged before a reset that has since happened + } + if (!dedicated_waiting) { + trace("isr drop b%x (not waiting)\n", rx->bufnr); + } else if (queue.size() >= QUEUE_DEPTH) { + trace("isr drop b%x (full)\n", rx->bufnr); + } else { + dedicated_reply_t reply = { rx, generation }; + queue.push_back(reply); + trace("isr queue b%x g%u k%d\n", rx->bufnr, generation, kind); + } +} + +static void isr_deliver_random(void) +{ + int kind = calm ? 0 : (int)world_rand(10); + isr_deliver(kind, !calm && (world_rand(10) == 0)); +} + +// One wait of a scripted world: the next step, if it falls within the wait. +static void scripted_wait(TickType_t ticks) +{ + if (!script_left || (script->delay - script_waited > ticks)) { + if (script_left) { + script_waited += ticks; + } + now += ticks; + return; + } + TickType_t delay = script->delay - script_waited; + now += delay; + for (int i = 0; i < script->count; i++) { + isr_deliver(script->kind[i], script->stale[i]); + } + preempt_next += script->preempt; + script++; + script_left--; + script_waited = 0; + if (queue.empty()) { + now += ticks - delay; // nothing came through; wait it out + } +} + +TickType_t xTaskGetTickCount(void) +{ + if (!calm && (world_rand(5) == 0)) { + now += world_rand(11); // preempted for a while + } + now += preempt_next; + preempt_next = 0; + if (start_pending) { + start_pending = false; + start_tick = now; + } + trace("tick %u\n", now); + return now; +} + +void vTaskSuspendAll(void) +{ + world_suspended++; + trace("suspend\n"); +} + +BaseType_t xTaskResumeAll(void) +{ + world_suspended--; + trace("resume\n"); + return pdFALSE; +} + +void vTaskDelay(TickType_t ticks) +{ + now += ticks; + trace("delay %u\n", ticks); +} + +BaseType_t xQueueReceive(QueueHandle_t q, void *item, TickType_t ticks) +{ + trace("receive %u", ticks); + uint64_t reach = (uint64_t)(TickType_t)(now - start_tick) + ticks; // no wrap: a huge wait must show + if ((ticks > 0) && (reach > world_wait_span)) { + world_wait_span = reach; + } + if (q != (QueueHandle_t)&queue) { + trace(" wrong queue\n"); + return pdFALSE; + } + if (queue.empty() && (ticks > 0)) { + if (script) { + scripted_wait(ticks); + } else if (calm) { + if (!calm_delivered) { + calm_delivered = true; + now += 1; + isr_deliver_random(); + } else { + now += ticks; + } + } else if (world_rand(10) < 6) { + TickType_t delay = world_rand(ticks); + now += delay; + if (world_rand(10) == 0) { + uart.generation++; + trace(" reset"); + } + int burst = 1 + world_rand((world_rand(4) == 0) ? 6 : 3); // more than the queue holds, now and then + for (int i = 0; i < burst; i++) { + isr_deliver_random(); + } + if (queue.empty()) { + now += ticks - delay; // nothing came through; wait it out + } + } else { + now += ticks; + } + } + if (queue.empty()) { + trace(" -> none\n"); + if ((ticks == 0) && (world_late_after_poll > 0)) { + world_late_after_poll--; + isr_deliver(0, false); + } + return pdFALSE; + } + *(dedicated_reply_t *)item = queue.front(); + queue.pop_front(); + trace(" -> b%x\n", ((dedicated_reply_t *)item)->buf->bufnr); + return pdTRUE; +} + +BaseType_t DmaUART::GetBuffer(command_buf_t **buf, TickType_t ticks) +{ + trace("getbuffer %u", ticks); + if (world_no_buffer || (!calm && (world_rand(100) < 5))) { + now += ticks; + trace(" -> none\n"); + return pdFALSE; + } + tx_buf.size = 0; + tx_buf.dropped = 0; + *buf = &tx_buf; + trace(" -> b%x\n", tx_buf.bufnr); + return pdTRUE; +} + +BaseType_t DmaUART::TransmitPacket(command_buf_t *buf, uint16_t *ms) +{ + trace("transmit %d:", buf->size); + for (int i = 0; (i < buf->size) && (i < CMD_BUF_SIZE); i++) { + trace(" %02x", buf->data[i]); + } + if (world_no_transmit || (!calm && (world_rand(100) < 5))) { + trace(" -> failed\n"); + return pdFALSE; // the real one frees the buffer itself + } + trace("\n"); + world_transmits++; + now += world_transmit_ticks; + start_pending = true; + memcpy(last_tx, buf->data, CMD_BUF_SIZE); + last_tx_size = buf->size; + // Late replies to earlier requests, or even this one, before the wait. + if (!calm && (world_rand(100) < 15)) { + int burst = 1 + world_rand(2); + for (int i = 0; i < burst; i++) { + isr_deliver_random(); + } + } + return pdTRUE; +} + +BaseType_t DmaUART::FreeBuffer(command_buf_t *buf) +{ + trace("free b%x%s\n", buf->bufnr, world_suspended ? "" : " (not suspended)"); + return pdTRUE; +} + +void world_enter_safe(void) +{ + trace("enter\n"); +} + +void world_leave_safe(void) +{ + trace("leave\n"); +} + +int world_printf(const char *fmt, ...) +{ + char line[256]; + va_list ap; + va_start(ap, fmt); + int n = vsnprintf(line, sizeof(line), fmt, ap); + va_end(ap); + world_trace += "print: "; + world_trace += line; + return n; +} + +bool wifi_module_ready(void) +{ + return world_ready; +} diff --git a/software/test/wifi_dedicated/world.h b/software/test/wifi_dedicated/world.h new file mode 100644 index 000000000..7f042833e --- /dev/null +++ b/software/test/wifi_dedicated/world.h @@ -0,0 +1,43 @@ +// The scripted world that the host test runs wifi_dedicated.cc in: the module's +// replies, the receive interrupt, the tick, the buffer pool and its resets. +// Every random decision comes from one generator, and every call is traced. +#ifndef WORLD_H_ +#define WORLD_H_ + +#include +#include "wifi_cmd.h" + +// Builds a reply of the given kind into rx, as an answer to the last request +// sent (req, req_size; req_size is -1 when nothing has been sent). +typedef void (*world_maker_t)(command_buf_t *rx, const uint8_t *req, int req_size, int kind); + +// Starts a new world from seed. With calm set nothing fails at random, and the +// first wait delivers exactly one reply of kind 0, unless a script is given. +void world_reset(uint32_t seed, world_maker_t maker, bool calm); +uint32_t world_rand(uint32_t n); + +// A calm world's waits follow a script instead: each step arrives delay ticks +// into the wait, at most MAX_STEP_REPLIES replies, a stale one tagged before a +// pool reset. A step whose delay outlasts the wait is still due in the next one. +#define MAX_STEP_REPLIES 4 +typedef struct { + TickType_t delay; + int count; + int kind[MAX_STEP_REPLIES]; + bool stale[MAX_STEP_REPLIES]; + TickType_t preempt; // added to the clock at the next tick read, as if preempted +} world_step_t; +void world_script(const world_step_t *steps, int count); + +extern bool world_ready; // what wifi_module_ready answers +extern bool world_no_buffer; // GetBuffer fails, even when calm +extern bool world_no_transmit; // TransmitPacket fails, even when calm +extern std::string world_trace; // every call, in order +extern int world_suspended; // vTaskSuspendAll minus xTaskResumeAll +extern int world_transmits; // requests that went out +extern TickType_t world_transmit_ticks; // how long a calm TransmitPacket takes to queue the request +extern int world_late_after_poll; // replies the interrupt hands over just after an empty receive 0 +extern uint64_t world_wait_span; // how far past the first tick read after sending any wait reached +size_t world_queued(void); // replies still in dedicated_replies + +#endif /* WORLD_H_ */ diff --git a/software/test/wifi_random/lwip/netdb.h b/software/test/wifi_random/lwip/netdb.h new file mode 100644 index 000000000..72207e47d --- /dev/null +++ b/software/test/wifi_random/lwip/netdb.h @@ -0,0 +1 @@ +// Stand-in for lwIP's netdb.h on the build host. rpc_calls.h needs nothing from it. diff --git a/software/test/wifi_random/lwip/sockets.h b/software/test/wifi_random/lwip/sockets.h new file mode 100644 index 000000000..b78473080 --- /dev/null +++ b/software/test/wifi_random/lwip/sockets.h @@ -0,0 +1,6 @@ +// Stand-in for lwIP's sockets.h on the build host. rpc_calls.h needs only u16_t. +#ifndef LWIP_SOCKETS_H_STUB +#define LWIP_SOCKETS_H_STUB +#include +typedef uint16_t u16_t; +#endif diff --git a/software/test/wifi_random/wifi_random_test.cc b/software/test/wifi_random/wifi_random_test.cc new file mode 100644 index 000000000..9be94a945 --- /dev/null +++ b/software/test/wifi_random/wifi_random_test.cc @@ -0,0 +1,198 @@ +// Host test of wifi_random.cc, the check on the module's answer to GET_RANDOM: +// answers a broken or confused module could send, none of which may hand out a byte. +// make -C target/pc/linux/wifirandom test +#include +#include +#include +#include +#include "rpc_calls.h" +#include "wifi_random.h" + +// The layout both sides agree on is asserted in wifi_random.cc itself. + +#define SEQUENCE 0x1234 +#define HEADER 12 + +// The length every case below asks for; main runs them for several. +static uint16_t LEN; + +static int failures; +static int checks; + +static void check(int condition, const char *what) +{ + checks++; + if (!condition) { + failures++; + printf(" FAIL %s\n", what); + } else { + printf(" ok %s\n", what); + } +} + +// Word aligned, as the data of a command_buf_t is. +static union { + uint32_t align; + uint8_t bytes[HEADER + 512 + 256]; +} reply; + +// A correct answer to request SEQUENCE for LEN bytes; returns its size. +static int build(void) +{ + memset(reply.bytes, 0, sizeof(reply.bytes)); + rpc_get_random_resp *r = (rpc_get_random_resp *)reply.bytes; + r->hdr.command = CMD_GET_RANDOM; + r->hdr.thread = 12; + r->hdr.sequence = SEQUENCE; + r->esp_err = 0; + r->source = ENTROPY_RADIO; + r->length = LEN; + for (int i = 0; i < LEN; i++) { + r->data[i] = (uint8_t)(0xA0 + (i * 7) + (i >> 8)); // no period of 256 + } + return HEADER + LEN; +} + +static rpc_get_random_resp *answer(void) +{ + return (rpc_get_random_resp *)reply.bytes; +} + +// Runs the check on the first size bytes of the reply; true when it returned +// expected and, unless that is success, left buf alone. +static bool outcome(int size, uint16_t len, int expected) +{ + uint8_t buf[600]; + memset(buf, 0xEE, sizeof(buf)); + int result = wifi_random_take_reply(reply.bytes, size, SEQUENCE, buf, len); + if (result != expected) { + printf(" returned %d, expected %d\n", result, expected); + return false; + } + if (expected == 0) { + return (memcmp(buf, answer()->data, len) == 0) && (buf[len] == 0xEE); + } + for (size_t i = 0; i < sizeof(buf); i++) { + if (buf[i] != 0xEE) { + printf(" byte %d was written\n", (int)i); + return false; + } + } + return true; +} + +static void reply_cases(void) +{ + int size; + + printf("The answer to this request\n"); + size = build(); + check(outcome(size, LEN, 0), "hands out exactly len bytes"); + size = build(); + check(outcome(size + 100, LEN, 0), "ignores bytes the module sent beyond len"); + + printf("An answer to something else\n"); + size = build(); + answer()->hdr.sequence = SEQUENCE - 1; + check(outcome(size, LEN, WIFI_RANDOM_FOREIGN), "wrong sequence is not ours"); + size = build(); + answer()->hdr.sequence = SEQUENCE ^ 0x0100; + check(outcome(size, LEN, WIFI_RANDOM_FOREIGN), "a sequence that differs only in its high byte is not ours"); + size = build(); + answer()->hdr.command = CMD_WIFI_GETMAC; + check(outcome(size, LEN, WIFI_RANDOM_FOREIGN), "wrong command is not ours"); + size = build(); + check(outcome(3, LEN, WIFI_RANDOM_FOREIGN), "fewer bytes than a header is not ours"); + bool only_ours = true; + for (int command = 0; command < 256; command++) { + size = build(); + answer()->hdr.command = (uint8_t)command; + uint8_t buf[512]; + int expected = (command == CMD_GET_RANDOM) ? 0 : WIFI_RANDOM_FOREIGN; + if (wifi_random_take_reply(reply.bytes, size, SEQUENCE, buf, LEN) != expected) { + printf(" command 0x%02x\n", command); + only_ours = false; + } + } + check(only_ours, "of all 256 commands only CMD_GET_RANDOM is ours"); + + printf("A refusal\n"); + size = build(); + answer()->esp_err = 0x103; // ESP_ERR_INVALID_STATE + answer()->length = 0; + check(outcome(HEADER, LEN, WIFI_RANDOM_REFUSED), "esp_err INVALID_STATE with no bytes"); + size = build(); + answer()->esp_err = 0x103; + check(outcome(size, LEN, WIFI_RANDOM_REFUSED), "esp_err set, even with len bytes behind it"); + const int errors[] = { 0x3000, 0x10000, -1, INT_MIN }; // ESP_ERR_WIFI_BASE, beyond 16 bits, ESP_FAIL + for (int i = 0; i < 4; i++) { + char what[64]; + size = build(); + answer()->esp_err = errors[i]; + snprintf(what, sizeof(what), "esp_err %d, with len bytes behind it", errors[i]); + check(outcome(size, LEN, WIFI_RANDOM_REFUSED), what); + } + size = build(); + answer()->esp_err = 0x106; // ESP_ERR_NOT_SUPPORTED, from firmware without the call + check(outcome(8, LEN, WIFI_RANDOM_REFUSED), "the 8 byte answer of old module firmware"); + size = build(); + answer()->source = ENTROPY_NONE; + check(outcome(size, LEN, WIFI_RANDOM_REFUSED), "OK without an entropy source"); + + printf("A malformed answer\n"); + size = build(); + answer()->esp_err = 0x103; // only partly received, so it must not be read + check(outcome(7, LEN, WIFI_RANDOM_INVALID), "too short to hold esp_err, whatever lies beyond it"); + size = build(); + check(outcome(HEADER - 1, LEN, WIFI_RANDOM_INVALID), "OK but too short to hold the header"); + size = build(); + answer()->source = ENTROPY_NONE; // a byte past the frame must not be read + check(outcome(HEADER - 2, LEN, WIFI_RANDOM_INVALID), "too short to hold the header, whatever lies beyond it"); + size = build(); + answer()->length = LEN - 1; + check(outcome(size, LEN, WIFI_RANDOM_INVALID), "fewer bytes announced than asked"); + size = build(); + answer()->length = LEN + 1; + check(outcome(size + 1, LEN, WIFI_RANDOM_INVALID), "more bytes announced than asked"); + size = build(); + answer()->length = LEN ^ 0x0100; + check(outcome(size + 256, LEN, WIFI_RANDOM_INVALID), "a length that differs only in its high byte"); + size = build(); + check(outcome(size - 1, LEN, WIFI_RANDOM_INVALID), "fewer bytes received than announced"); + size = build(); + answer()->length = 0; + check(outcome(HEADER, LEN, WIFI_RANDOM_INVALID), "OK with no bytes at all"); + +} + +int main(void) +{ + // One byte, a byte count that fills a uint8_t, one past it, a length past + // 256, and the most the UCI asks for. + const uint16_t lengths[] = { 1, 255, 256, 300, 512 }; + for (int i = 0; i < 5; i++) { + LEN = lengths[i]; + printf("\n== len %d\n", LEN); + reply_cases(); + } + + printf("The UCI status of a result\n"); + check(wifi_random_status(0) == 0, "0 is OK"); + check(wifi_random_status(WIFI_RANDOM_BUSY) == 88, "busy is 88"); + check(wifi_random_status(WIFI_RANDOM_INVALID) == 86, "an invalid reply is 86"); + check(wifi_random_status(WIFI_RANDOM_REFUSED) == 87, "a refusal is 87"); + check(wifi_random_status(WIFI_RANDOM_NO_MODULE) == 87, "no module is 87"); + check(wifi_random_status(WIFI_RANDOM_FOREIGN) == 87, "a foreign reply is 87"); + bool only_zero = true; + for (int result = -1000; result <= 1000; result++) { + if ((wifi_random_status(result) == 0) != (result == 0)) { + only_zero = false; + } + } + check(only_zero, "no result but 0 maps to OK, from -1000 to 1000"); + check((wifi_random_status(INT_MIN) == 87) && (wifi_random_status(INT_MAX) == 87), + "INT_MIN and INT_MAX are 87, so carry no data"); + + printf("\n%d checks, %d failures\n", checks, failures); + return failures ? 1 : 0; +} diff --git a/target/pc/linux/wifidedicated/Makefile b/target/pc/linux/wifidedicated/Makefile new file mode 100644 index 000000000..39c25a90c --- /dev/null +++ b/target/pc/linux/wifidedicated/Makefile @@ -0,0 +1,43 @@ +# Host build of the check on the WiFi module's dedicated channel and GET_RANDOM, +# its first user, against stand-ins. `make test` builds and runs it. +PRJ = wifidedicated +RESULT = result +OUTPUT = output + +PATH_SW = ../../../../software +TEST = $(PATH_SW)/test/wifi_dedicated + +VPATH = $(TEST)/stub $(TEST) $(PATH_SW)/test/wifi_random $(PATH_SW)/io/wifi $(PATH_SW)/io/uart \ + $(PATH_SW)/wifi/raw_u64/main + +CXX = g++ +CPPOPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter -DNIOS=1 -DU64=1 \ + $(addprefix -I, $(VPATH)) + +SRCS_CC = wifi_dedicated_test.cc check.cc world.cc wifi_dedicated.cc wifi_random.cc +OBJS = $(addprefix $(OUTPUT)/, $(SRCS_CC:%.cc=%.o)) + +.PHONY: all test clean + +all: $(RESULT)/$(PRJ) + +$(OUTPUT)/%.o: %.cc + @mkdir -p $(OUTPUT) + $(CXX) $(CPPOPTIONS) -c -o $@ $< + +# Compiled from a copy, so that its "wifi_cmd.h" is the stand-in rather than +# the real header next to it. +$(OUTPUT)/wifi_dedicated.o: $(PATH_SW)/io/wifi/wifi_dedicated.cc + @mkdir -p $(OUTPUT) + cp $< $(OUTPUT)/wifi_dedicated.cc + $(CXX) $(CPPOPTIONS) -c -o $@ $(OUTPUT)/wifi_dedicated.cc + +$(RESULT)/$(PRJ): $(OBJS) + @mkdir -p $(RESULT) + $(CXX) -o $@ $(OBJS) + +test: all + @$(RESULT)/$(PRJ) + +clean: + @rm -rf $(OUTPUT) $(RESULT) diff --git a/target/pc/linux/wifirandom/Makefile b/target/pc/linux/wifirandom/Makefile new file mode 100644 index 000000000..b35b7d408 --- /dev/null +++ b/target/pc/linux/wifirandom/Makefile @@ -0,0 +1,34 @@ +# Host build of the check the Nios applies to the WiFi module's answer to +# GET_RANDOM, with lwIP's headers stubbed out. `make test` builds and runs it. +PRJ = wifirandom +RESULT = result +OUTPUT = output + +PATH_SW = ../../../../software + +VPATH = $(PATH_SW)/io/wifi $(PATH_SW)/wifi/raw_u64/main $(PATH_SW)/test/wifi_random + +CXX = g++ +CPPOPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter \ + $(addprefix -I, $(VPATH)) + +SRCS_CC = wifi_random.cc wifi_random_test.cc +OBJS = $(addprefix $(OUTPUT)/, $(SRCS_CC:%.cc=%.o)) + +.PHONY: all test clean + +all: $(RESULT)/$(PRJ) + +$(OUTPUT)/%.o: %.cc + @mkdir -p $(OUTPUT) + $(CXX) $(CPPOPTIONS) -c -o $@ $< + +$(RESULT)/$(PRJ): $(OBJS) + @mkdir -p $(RESULT) + $(CXX) -o $@ $(OBJS) + +test: all + @$(RESULT)/$(PRJ) + +clean: + @rm -rf $(OUTPUT) $(RESULT) diff --git a/target/u64/nios2/ultimate/Makefile b/target/u64/nios2/ultimate/Makefile index d276babf8..2c42ccf7e 100755 --- a/target/u64/nios2/ultimate/Makefile +++ b/target/u64/nios2/ultimate/Makefile @@ -164,6 +164,8 @@ SRCS_CC = u2p_init.cc \ esp32.cc \ wifi.cc \ wifi_cmd.cc \ + wifi_random.cc \ + wifi_dedicated.cc \ acia.cc \ modem.cc \ listener_socket.cc \ From 99f2beb991366ecec0f69abb0e09ff47d55cf45a Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:28:58 -0500 Subject: [PATCH 39/95] Answer NET_CMD_GET_RANDOM on the UCI network target NET_CMD_GET_RANDOM ($20) takes a 16-bit length, 1 to 512, and answers with exactly that many bytes from the WiFi module's hardware generator and 00,OK, in one reply block. It never answers with bytes from anywhere else: 81,INVALID PARAMS the command is not exactly 4 bytes 82,PARAMETER(S) OUT OF RANGE a length of 0 or above 512 86,INTERNAL ERROR the module's answer was malformed 87,NO ENTROPY SOURCE no module application, a product without one (everything but the U64), or the module has no entropy source yet 88,ENTROPY SOURCE BUSY no answer within 200 ms of the request being queued, for instance while the module hands a scan to its connector task; try again A refusal carries no data. Co-Authored-By: Claude Opus 5.5 (1M context) --- software/io/network/network_target.cc | 42 +++++++++++++++++++++++++++ software/io/network/network_target.h | 10 +++++++ 2 files changed, 52 insertions(+) diff --git a/software/io/network/network_target.cc b/software/io/network/network_target.cc index fff843e6e..4caa3ef89 100644 --- a/software/io/network/network_target.cc +++ b/software/io/network/network_target.cc @@ -12,6 +12,9 @@ #include "netdb.h" #include #include +#if U64 == 1 +#include "wifi_random.h" +#endif NetworkTarget net(3); @@ -24,6 +27,8 @@ Message c_status_no_socket = { 23, true, (uint8_t *)"85,ERROR OPENING Message c_status_socket_closed = { 28, true, (uint8_t *)"01,CONNECTION CLOSED BY HOST" }; Message c_status_net_no_data = { 26, true, (uint8_t *)"03,MORE DATA NOT SUPPORTED" }; Message c_status_internal_error = { 17, true, (uint8_t *)"86,INTERNAL ERROR" }; +Message c_status_no_entropy = { 20, true, (uint8_t *)"87,NO ENTROPY SOURCE" }; +Message c_status_entropy_busy = { 22, true, (uint8_t *)"88,ENTROPY SOURCE BUSY" }; NetworkTarget::NetworkTarget(int id) { @@ -175,6 +180,14 @@ void NetworkTarget :: parse_command(Message *command, Message **reply, Message * case NET_CMD_WRITE_SOCKET: write_socket(command, reply, status); break; + case NET_CMD_GET_RANDOM: + if (command->length != 4) { // 2 + 2 + *reply = &c_message_empty; + *status = &c_status_invalid_params; + break; + } + get_random(command, reply, status); + break; default: *reply = &c_message_empty; *status = &c_status_unknown_command; @@ -410,6 +423,35 @@ void NetworkTarget :: close_socket(Message *command, Message **reply, Message ** } } +void NetworkTarget :: get_random(Message *command, Message **reply, Message **status) +{ + uint16_t length = uint16_t(command->message[2]) | (uint16_t(command->message[3]) << 8); + + *reply = &c_message_empty; + if ((length == 0) || (length > NET_MAX_RANDOM)) { + *status = &c_status_param_out_of_range; + return; + } + // The bytes come from the WiFi module's hardware generator and from + // nowhere else, so without that module there are none. + *status = &c_status_no_entropy; +#if U64 == 1 + // The reply stays empty unless the result may carry data, and 87 stays + // for any status not handled here. + int result = wifi_get_random(data_message.message, length); + if (wifi_random_status(result) == 0) { + data_message.length = length; + data_message.last_part = true; + *reply = &data_message; + *status = &c_status_ok; + } else if (wifi_random_status(result) == 88) { + *status = &c_status_entropy_busy; + } else if (wifi_random_status(result) == 86) { + *status = &c_status_internal_error; + } +#endif +} + // A socket handed to the client without a table entry would survive a C64 // reset, which is the defect in #808, so the table must cover every descriptor // lwip can return. lwip's NUM_SOCKETS is MEMP_NUM_NETCONN, tested here rather diff --git a/software/io/network/network_target.h b/software/io/network/network_target.h index 85da8e844..a7e0f1302 100644 --- a/software/io/network/network_target.h +++ b/software/io/network/network_target.h @@ -21,6 +21,7 @@ #define NET_CMD_CLOSE_SOCKET 0x09 #define NET_CMD_READ_SOCKET 0x10 #define NET_CMD_WRITE_SOCKET 0x11 +#define NET_CMD_GET_RANDOM 0x20 #define NET_CMD_BUFSIZE 2048 @@ -43,10 +44,18 @@ // Payload bytes in the first block, which also carries the two byte header. #define NET_FIRST_BLOCK_PAYLOAD (NET_MAX_REPLY_BLOCK - 2) +// The most random bytes GET_RANDOM returns at once, which is what the WiFi +// module hands out per request (RANDOM_MAX_BYTES in its rpc_calls.h). +#define NET_MAX_RANDOM 512 + #if NET_MAX_SOCKET_READ > NET_CMD_BUFSIZE #error "the socket read buffer cannot hold the largest accepted read" #endif +#if NET_MAX_RANDOM > NET_MAX_REPLY_BLOCK +#error "random bytes must fit a single reply block" +#endif + class NetworkTarget : public CommandTarget { Message data_message; Message status_message; @@ -81,6 +90,7 @@ class NetworkTarget : public CommandTarget { void read_socket(Message *command, Message **reply, Message **status); void write_socket(Message *command, Message **reply, Message **status); void close_socket(Message *command, Message **reply, Message **status); + void get_random(Message *command, Message **reply, Message **status); void start_read_reply(int payload_length, Message *result, Message **reply, Message **status); void discard_read_reply(void); public: From 6bf0391807068254a6049711c42b65d62994a4cf Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:28:58 -0500 Subject: [PATCH 40/95] Share the GET_RANDOM wire definitions between the WiFi modules CMD_GET_RANDOM, entropy_source_t, RANDOM_MAX_BYTES and the request and reply structs move from raw_u64's rpc_calls.h to software/wifi/common/ rpc_shared.h, which raw_u64's and u64ctrl's rpc_calls.h both include. The layout static_asserts move with them, so that every compiler that reads the structs (the module, the Nios and RISC-V Ultimate builds, the host tests) checks the layout, not only the ESP32 build. The include path goes to every Ultimate target that compiles against a module's rpc_calls.h; the modules and the ESP build cache key have had wifi/common since the radio switch. The host tests of wifi_random.cc and wifi_dedicated.cc now run once against each module's headers (make test; make U64=2 run for u64ctrl's alone). No behaviour changes. Co-Authored-By: Claude Opus 5.5 (1M context) Co-Authored-By: Claude Opus 5.5 --- software/io/wifi/tests/Makefile | 2 +- software/io/wifi/wifi_random.cc | 10 --- software/test/wifi_random/wifi_random_test.cc | 2 +- software/u64ctrl/main/rpc_calls.h | 2 + software/wifi/common/rpc_shared.h | 61 +++++++++++++++++++ software/wifi/raw_u64/main/rpc_calls.h | 26 +------- software/wifi/raw_u64/main/rpc_dispatch.c | 10 --- software/wifi/tests/Makefile | 3 + software/wifi/tests/module_env.h | 2 +- target/pc/linux/wifidedicated/Makefile | 28 ++++++--- target/pc/linux/wifirandom/Makefile | 28 ++++++--- target/pc/linux/wifireply/Makefile | 3 +- target/u64/nios2/ultimate/Makefile | 1 + target/u64/nios2/updater/Makefile | 1 + target/u64ii/riscv/factorytest/Makefile | 1 + target/u64ii/riscv/ultimate/Makefile | 1 + target/u64ii/riscv/update/Makefile | 1 + 17 files changed, 121 insertions(+), 61 deletions(-) create mode 100644 software/wifi/common/rpc_shared.h diff --git a/software/io/wifi/tests/Makefile b/software/io/wifi/tests/Makefile index d9af725a0..140086f60 100644 --- a/software/io/wifi/tests/Makefile +++ b/software/io/wifi/tests/Makefile @@ -45,7 +45,7 @@ LEGACY := $(sort $(wildcard legacy/*.sed)) CXXFLAGS := -std=c++14 -g -O0 -Wall -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-switch \ -Wno-format -Wno-unknown-warning-option -Wno-mismatched-tags -Wno-deprecated-declarations \ -fno-access-control -DRISCV=1 $(if $(filter 0,$(U64)),,-DU64=$(U64)) \ - -I$(OUT) -Istubs -I. -I$(WIFI_DIR) -I$(UART) -I$(SW)/wifi/raw_u64/main + -I$(OUT) -Istubs -I. -I$(WIFI_DIR) -I$(UART) -I$(SW)/wifi/raw_u64/main -I$(SW)/wifi/common # Prints the function $(1) of file $(2), and stops when it is not there extract = out=$$(awk -v f="$(subst ~, ,$(1))" -f $(EXTRACT) $(2)); \ diff --git a/software/io/wifi/wifi_random.cc b/software/io/wifi/wifi_random.cc index 98b2bb632..52f3f8385 100644 --- a/software/io/wifi/wifi_random.cc +++ b/software/io/wifi/wifi_random.cc @@ -6,16 +6,6 @@ #include "rpc_calls.h" #include "wifi_random.h" -// The layout the module sends and this code reads. Checked here so that the -// firmware build itself, not only the host test, fails if it ever changes. -static_assert(sizeof(rpc_get_random_req) == 6, "rpc_get_random_req changed"); -static_assert(offsetof(rpc_get_random_req, length) == 4, "rpc_get_random_req changed"); -static_assert(sizeof(rpc_get_random_resp) == 12, "rpc_get_random_resp changed"); -static_assert(offsetof(rpc_get_random_resp, esp_err) == 4, "rpc_get_random_resp changed"); -static_assert(offsetof(rpc_get_random_resp, source) == 8, "rpc_get_random_resp changed"); -static_assert(offsetof(rpc_get_random_resp, length) == 10, "rpc_get_random_resp changed"); -static_assert(offsetof(rpc_get_random_resp, data) == 12, "rpc_get_random_resp changed"); - int wifi_random_take_reply(const uint8_t *reply, int size, uint16_t sequence, uint8_t *buf, uint16_t len) { diff --git a/software/test/wifi_random/wifi_random_test.cc b/software/test/wifi_random/wifi_random_test.cc index 9be94a945..e5c7bac35 100644 --- a/software/test/wifi_random/wifi_random_test.cc +++ b/software/test/wifi_random/wifi_random_test.cc @@ -8,7 +8,7 @@ #include "rpc_calls.h" #include "wifi_random.h" -// The layout both sides agree on is asserted in wifi_random.cc itself. +// The layout both sides agree on is asserted in rpc_shared.h itself. #define SEQUENCE 0x1234 #define HEADER 12 diff --git a/software/u64ctrl/main/rpc_calls.h b/software/u64ctrl/main/rpc_calls.h index f545f84e3..07fa28a85 100644 --- a/software/u64ctrl/main/rpc_calls.h +++ b/software/u64ctrl/main/rpc_calls.h @@ -20,6 +20,8 @@ typedef struct { uint16_t sequence; } rpc_header_t; +#include "rpc_shared.h" + typedef struct { rpc_header_t hdr; int esp_err; // to be casted to esp_err_t diff --git a/software/wifi/common/rpc_shared.h b/software/wifi/common/rpc_shared.h new file mode 100644 index 000000000..68224b6ae --- /dev/null +++ b/software/wifi/common/rpc_shared.h @@ -0,0 +1,61 @@ +/* + * rpc_shared.h + * + * What the Ultimate and the WiFi modules of the Ultimate 64 (software/wifi/raw_u64) + * and of the Ultimate 64 Elite II and C64 Ultimate (software/u64ctrl) must agree + * on, in one place. Included by each module's + * rpc_calls.h, after rpc_header_t, and by the Ultimate through it. + */ + +#ifndef SOFTWARE_WIFI_COMMON_RPC_SHARED_H_ +#define SOFTWARE_WIFI_COMMON_RPC_SHARED_H_ + +#include +#include + +// The Nios updater is still built as C++98 +#if defined(__cplusplus) && (__cplusplus < 201103L) +#define RPC_CONCAT_(a, b) a ## b +#define RPC_CONCAT(a, b) RPC_CONCAT_(a, b) +#define RPC_STATIC_ASSERT(cond, msg) typedef char RPC_CONCAT(rpc_assert_, __LINE__)[(cond) ? 1 : -1] +#elif defined(__cplusplus) +#define RPC_STATIC_ASSERT static_assert +#else +#define RPC_STATIC_ASSERT _Static_assert +#endif + +//---------------------------------- +// hardware random bytes +#define CMD_GET_RANDOM 0x20 // u64ctrl's own commands run from 0x13 and may reach 0x1F; kept apart so the maps agree +#define RANDOM_MAX_BYTES 512 + +typedef enum { + ENTROPY_NONE = 0, // RNG not fed by a live entropy source; no bytes are returned + ENTROPY_RADIO = 1, // Wi-Fi is running, so the RNG gives true random numbers +} entropy_source_t; + +typedef struct { + rpc_header_t hdr; + uint16_t length; +} rpc_get_random_req; + +typedef struct { + rpc_header_t hdr; + int esp_err; // to be casted to esp_err_t + uint8_t source; // to be casted to entropy_source_t + uint16_t length; + uint8_t data[]; // sizeof() excludes it, so it is exactly the header size +} rpc_get_random_resp; + +// The Ultimate decodes these by offset: a layout change must break the build, +// on every compiler that includes this, not the wire +RPC_STATIC_ASSERT(sizeof(rpc_get_random_req) == 6, "rpc_get_random_req changed"); +RPC_STATIC_ASSERT(offsetof(rpc_get_random_req, length) == 4, "rpc_get_random_req changed"); +RPC_STATIC_ASSERT(sizeof(rpc_get_random_resp) == 12, "rpc_get_random_resp changed"); +RPC_STATIC_ASSERT(offsetof(rpc_get_random_resp, esp_err) == 4, "rpc_get_random_resp changed"); +RPC_STATIC_ASSERT(offsetof(rpc_get_random_resp, source) == 8, "rpc_get_random_resp changed"); +RPC_STATIC_ASSERT(offsetof(rpc_get_random_resp, length) == 10, "rpc_get_random_resp changed"); +RPC_STATIC_ASSERT(offsetof(rpc_get_random_resp, data) == 12, "rpc_get_random_resp changed"); +RPC_STATIC_ASSERT(ENTROPY_NONE == 0, "ENTROPY_NONE changed"); + +#endif /* SOFTWARE_WIFI_COMMON_RPC_SHARED_H_ */ diff --git a/software/wifi/raw_u64/main/rpc_calls.h b/software/wifi/raw_u64/main/rpc_calls.h index 2758db44e..9e58d8b7c 100644 --- a/software/wifi/raw_u64/main/rpc_calls.h +++ b/software/wifi/raw_u64/main/rpc_calls.h @@ -20,6 +20,8 @@ typedef struct { uint16_t sequence; } rpc_header_t; +#include "rpc_shared.h" + typedef struct { rpc_header_t hdr; int esp_err; // to be casted to esp_err_t @@ -127,28 +129,6 @@ typedef struct { esp_datetime_t datetime; } rpc_get_time_resp; -//---------------------------------- -// hardware random bytes -#define RANDOM_MAX_BYTES 512 - -typedef enum { - ENTROPY_NONE = 0, // RNG not fed by a live entropy source; no bytes are returned - ENTROPY_RADIO = 1, // Wi-Fi is running, so the RNG gives true random numbers -} entropy_source_t; - -typedef struct { - rpc_header_t hdr; - uint16_t length; -} rpc_get_random_req; - -typedef struct { - rpc_header_t hdr; - int esp_err; // to be casted to esp_err_t - uint8_t source; // to be casted to entropy_source_t - uint16_t length; - uint8_t data[]; // sizeof() excludes it, so it is exactly the header size -} rpc_get_random_resp; - //---------------------------------- // send raw packet typedef struct { @@ -200,7 +180,7 @@ typedef struct { #define CMD_GET_TIME 0x10 #define CMD_CLEAR_APS 0x11 #define CMD_WIFI_AUTOCONNECT 0x12 -#define CMD_GET_RANDOM 0x20 // u64ctrl's own commands run from 0x13 and may reach 0x1F; kept apart so the maps agree +// 0x13-0x1F are u64ctrl's; 0x20 is CMD_GET_RANDOM, in rpc_shared.h /* #define CMD_SOCKET 0x11 diff --git a/software/wifi/raw_u64/main/rpc_dispatch.c b/software/wifi/raw_u64/main/rpc_dispatch.c index 78f528eb6..4bbf57863 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.c +++ b/software/wifi/raw_u64/main/rpc_dispatch.c @@ -251,16 +251,6 @@ void cmd_clear_aps(command_buf_t *buf) my_uart_transmit_packet(UART_CHAN, buf); } -// The Ultimate decodes these by offset: a layout change must break the build, not the wire -_Static_assert(sizeof(rpc_get_random_req) == 6, "rpc_get_random_req size"); -_Static_assert(offsetof(rpc_get_random_req, length) == 4, "rpc_get_random_req.length"); -_Static_assert(sizeof(rpc_get_random_resp) == 12, "rpc_get_random_resp size"); -_Static_assert(offsetof(rpc_get_random_resp, esp_err) == 4, "rpc_get_random_resp.esp_err"); -_Static_assert(offsetof(rpc_get_random_resp, source) == 8, "rpc_get_random_resp.source"); -_Static_assert(offsetof(rpc_get_random_resp, length) == 10, "rpc_get_random_resp.length"); -_Static_assert(offsetof(rpc_get_random_resp, data) == 12, "rpc_get_random_resp.data"); -_Static_assert(ENTROPY_NONE == 0, "ENTROPY_NONE"); - void cmd_get_random(command_buf_t *buf) { rpc_get_random_req *req = (rpc_get_random_req *)buf->data; diff --git a/software/wifi/tests/Makefile b/software/wifi/tests/Makefile index 530dda747..15e66a065 100644 --- a/software/wifi/tests/Makefile +++ b/software/wifi/tests/Makefile @@ -30,6 +30,9 @@ DIR_u64ctrl := $(PATH_SW)/u64ctrl/main # The U64 and U2+L modules have the radio switch (radio_boot.h): only they see wifi/common INC_raw_u64 := -I$(PATH_SW)/wifi/common INC_raw_c3 := -I$(PATH_SW)/wifi/common +# u64ctrl's rpc_calls.h and wifi_modem.h include rpc_shared.h and radio_entropy.h from there. It has no radio +# switch: module_env.h does not count it as one, although radio_boot.h is on its path now +INC_u64ctrl := -I$(PATH_SW)/wifi/common HOSTTEST := $(PATH_SW)/io/usb/tests CASES := $(wildcard module_*_test.cpp) diff --git a/software/wifi/tests/module_env.h b/software/wifi/tests/module_env.h index 01770fbed..d41e427cb 100644 --- a/software/wifi/tests/module_env.h +++ b/software/wifi/tests/module_env.h @@ -94,7 +94,7 @@ typedef struct { } wifi_event_sta_disconnected_t; enum { WIFI_EVENT_STA_START, WIFI_EVENT_STA_CONNECTED, WIFI_EVENT_STA_DISCONNECTED }; -#if __has_include("radio_boot.h") +#if !defined(MODULE_U64CTRL) && __has_include("radio_boot.h") #include "radio_boot.h" // the U64 and U2+L modules' restart record #define MODULE_HAS_SWITCH 1 #endif diff --git a/target/pc/linux/wifidedicated/Makefile b/target/pc/linux/wifidedicated/Makefile index 39c25a90c..388c1a4f2 100644 --- a/target/pc/linux/wifidedicated/Makefile +++ b/target/pc/linux/wifidedicated/Makefile @@ -1,23 +1,33 @@ # Host build of the check on the WiFi module's dedicated channel and GET_RANDOM, # its first user, against stand-ins. `make test` builds and runs it. PRJ = wifidedicated -RESULT = result -OUTPUT = output - PATH_SW = ../../../../software TEST = $(PATH_SW)/test/wifi_dedicated +# `make test` runs it against each module's headers: raw_u64 (the U64) and +# u64ctrl (the C64 Ultimate, U64=2). `make U64=2 run` is the second alone. +U64 ?= 1 +ifeq ($(U64),2) +MODULE = $(PATH_SW)/u64ctrl/main +RESULT = result/u64ctrl +OUTPUT = output/u64ctrl +else +MODULE = $(PATH_SW)/wifi/raw_u64/main +RESULT = result +OUTPUT = output +endif + VPATH = $(TEST)/stub $(TEST) $(PATH_SW)/test/wifi_random $(PATH_SW)/io/wifi $(PATH_SW)/io/uart \ - $(PATH_SW)/wifi/raw_u64/main + $(MODULE) $(PATH_SW)/wifi/common CXX = g++ -CPPOPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter -DNIOS=1 -DU64=1 \ +CPPOPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter -DNIOS=1 -DU64=$(U64) \ $(addprefix -I, $(VPATH)) SRCS_CC = wifi_dedicated_test.cc check.cc world.cc wifi_dedicated.cc wifi_random.cc OBJS = $(addprefix $(OUTPUT)/, $(SRCS_CC:%.cc=%.o)) -.PHONY: all test clean +.PHONY: all run test clean all: $(RESULT)/$(PRJ) @@ -36,8 +46,12 @@ $(RESULT)/$(PRJ): $(OBJS) @mkdir -p $(RESULT) $(CXX) -o $@ $(OBJS) -test: all +run: all @$(RESULT)/$(PRJ) +test: + @$(MAKE) --no-print-directory run + @$(MAKE) --no-print-directory U64=2 run + clean: @rm -rf $(OUTPUT) $(RESULT) diff --git a/target/pc/linux/wifirandom/Makefile b/target/pc/linux/wifirandom/Makefile index b35b7d408..4de32805b 100644 --- a/target/pc/linux/wifirandom/Makefile +++ b/target/pc/linux/wifirandom/Makefile @@ -1,21 +1,31 @@ # Host build of the check the Nios applies to the WiFi module's answer to -# GET_RANDOM, with lwIP's headers stubbed out. `make test` builds and runs it. +# GET_RANDOM, with lwIP's headers stubbed out. `make test` builds and runs it +# against each module's headers: raw_u64 (the U64) and u64ctrl (the C64 Ultimate, +# U64=2). `make U64=2 run` is the second alone. PRJ = wifirandom +PATH_SW = ../../../../software + +U64 ?= 1 +ifeq ($(U64),2) +MODULE = $(PATH_SW)/u64ctrl/main +RESULT = result/u64ctrl +OUTPUT = output/u64ctrl +else +MODULE = $(PATH_SW)/wifi/raw_u64/main RESULT = result OUTPUT = output +endif -PATH_SW = ../../../../software - -VPATH = $(PATH_SW)/io/wifi $(PATH_SW)/wifi/raw_u64/main $(PATH_SW)/test/wifi_random +VPATH = $(PATH_SW)/io/wifi $(MODULE) $(PATH_SW)/wifi/common $(PATH_SW)/test/wifi_random CXX = g++ -CPPOPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter \ +CPPOPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter -DU64=$(U64) \ $(addprefix -I, $(VPATH)) SRCS_CC = wifi_random.cc wifi_random_test.cc OBJS = $(addprefix $(OUTPUT)/, $(SRCS_CC:%.cc=%.o)) -.PHONY: all test clean +.PHONY: all run test clean all: $(RESULT)/$(PRJ) @@ -27,8 +37,12 @@ $(RESULT)/$(PRJ): $(OBJS) @mkdir -p $(RESULT) $(CXX) -o $@ $(OBJS) -test: all +run: all @$(RESULT)/$(PRJ) +test: + @$(MAKE) --no-print-directory run + @$(MAKE) --no-print-directory U64=2 run + clean: @rm -rf $(OUTPUT) $(RESULT) diff --git a/target/pc/linux/wifireply/Makefile b/target/pc/linux/wifireply/Makefile index d025ea974..d24f6a0d1 100644 --- a/target/pc/linux/wifireply/Makefile +++ b/target/pc/linux/wifireply/Makefile @@ -22,7 +22,8 @@ COPTIONS = -std=c99 -g -O0 -Wall -Wextra -Wno-unused-parameter \ CXX = g++ CXXOPTIONS = -std=c++11 -g -O0 -w -DRISCV=1 -DU64=2 -I$(STUBS) $(addprefix -I, $(VPATH)) \ - -I$(PATH_SW)/io/uart -I$(PATH_SW)/u64ctrl/main -I$(PATH_SW)/system + -I$(PATH_SW)/io/uart -I$(PATH_SW)/u64ctrl/main -I$(PATH_SW)/system \ + -I$(PATH_SW)/wifi/common SRCS_C = wifi_reply_test.c OBJS = $(addprefix $(OUTPUT)/, $(SRCS_C:%.c=%.o)) diff --git a/target/u64/nios2/ultimate/Makefile b/target/u64/nios2/ultimate/Makefile index 2c42ccf7e..41e1626d6 100755 --- a/target/u64/nios2/ultimate/Makefile +++ b/target/u64/nios2/ultimate/Makefile @@ -231,6 +231,7 @@ VPATH += $(BSP)/HAL/inc VPATH += $(BSP)/drivers/inc VPATH += $(PATH_SW)/6502/sidcrt/target VPATH += $(PATH_SW)/wifi/raw_u64/main +VPATH += $(PATH_SW)/wifi/common # sock_echo.c \ # sys_calls.cc \ diff --git a/target/u64/nios2/updater/Makefile b/target/u64/nios2/updater/Makefile index d8e7ce707..914a90b6e 100755 --- a/target/u64/nios2/updater/Makefile +++ b/target/u64/nios2/updater/Makefile @@ -101,6 +101,7 @@ VPATH += $(PATH_SW)/u64 VPATH += $(PATH_SW)/../html VPATH += $(PATH_SW)/../doc/api VPATH += $(PATH_SW)/wifi/raw_u64/main +VPATH += $(PATH_SW)/wifi/common VPATH += $(PATH_SW)/wifi/raw_u64/build/bootloader VPATH += $(PATH_SW)/wifi/raw_u64/build/partition_table VPATH += $(PATH_SW)/wifi/raw_u64/build diff --git a/target/u64ii/riscv/factorytest/Makefile b/target/u64ii/riscv/factorytest/Makefile index 253fc33b6..809d95a60 100755 --- a/target/u64ii/riscv/factorytest/Makefile +++ b/target/u64ii/riscv/factorytest/Makefile @@ -103,6 +103,7 @@ VPATH += $(PATH_SW)/portable/riscv VPATH += $(PATH_SW)/6502/sidcrt/target VPATH += $(PATH_SW)/u64 VPATH += $(PATH_SW)/u64ctrl/main +VPATH += $(PATH_SW)/wifi/common VPATH += $(PATH_SW)/application/u64ii_tester diff --git a/target/u64ii/riscv/ultimate/Makefile b/target/u64ii/riscv/ultimate/Makefile index c8228bffe..59ff5e06a 100755 --- a/target/u64ii/riscv/ultimate/Makefile +++ b/target/u64ii/riscv/ultimate/Makefile @@ -229,6 +229,7 @@ VPATH += $(PATH_SW)/6502/sidcrt/target VPATH += $(PATH_SW)/u64ii VPATH += $(PATH_SW)/u64 VPATH += $(PATH_SW)/u64ctrl/main +VPATH += $(PATH_SW)/wifi/common SRCS_ASM = diff --git a/target/u64ii/riscv/update/Makefile b/target/u64ii/riscv/update/Makefile index c0baeb070..8ca300702 100755 --- a/target/u64ii/riscv/update/Makefile +++ b/target/u64ii/riscv/update/Makefile @@ -128,6 +128,7 @@ VPATH += $(PATH_SW)/application/update_u2p VPATH += $(PATH_SW)/../html VPATH += $(PATH_SW)/../doc/api VPATH += $(PATH_SW)/u64ctrl/main +VPATH += $(PATH_SW)/wifi/common VPATH += $(PATH_SW)/u64ctrl/build/bootloader VPATH += $(PATH_SW)/u64ctrl/build/partition_table VPATH += $(PATH_SW)/u64ctrl/build From 61b2f5577d719954b01b951af6259632935703f3 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:28:58 -0500 Subject: [PATCH 41/95] Answer GET_RANDOM from the control module of the Ultimate 64 Elite II and C64 Ultimate The same request and reply as the U64's module, with the same source: RADIO while radio_is_on(), NONE from the moment a stop begins until the next successful start. With the radio off the module answers ESP_ERR_INVALID_STATE and no bytes, and the Ultimate turns that into UCI status 87. Bytes drawn while a stop began are dropped the same way, even if the radio has started again by the end of the draw: the count of stops is compared before and after. Co-Authored-By: Claude Opus 5.5 (1M context) Co-Authored-By: Claude Opus 5.5 --- software/u64ctrl/main/rpc_calls.h | 1 + software/u64ctrl/main/rpc_dispatch.c | 37 ++++++++++++++++++++++++++++ software/u64ctrl/main/rpc_dispatch.h | 5 ++-- software/u64ctrl/main/wifi_modem.c | 13 ++++++++++ software/u64ctrl/main/wifi_modem.h | 2 ++ 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/software/u64ctrl/main/rpc_calls.h b/software/u64ctrl/main/rpc_calls.h index 07fa28a85..0b507839c 100644 --- a/software/u64ctrl/main/rpc_calls.h +++ b/software/u64ctrl/main/rpc_calls.h @@ -237,6 +237,7 @@ typedef struct { #define CMD_GET_WAKE_ON_WIFI 0x19 #define CMD_SET_RECOVERY_URL 0x1A #define CMD_GET_RECOVERY_URL 0x1B +// 0x20 is CMD_GET_RANDOM, in rpc_shared.h #define EVENT_CONNECTED 0x40 #define EVENT_GOTIP 0x41 diff --git a/software/u64ctrl/main/rpc_dispatch.c b/software/u64ctrl/main/rpc_dispatch.c index e2f276e7c..6df5e8d60 100644 --- a/software/u64ctrl/main/rpc_dispatch.c +++ b/software/u64ctrl/main/rpc_dispatch.c @@ -14,6 +14,7 @@ #include "nvs_flash.h" #include "power_state.h" #include "driver/uart.h" +#include "esp_random.h" #include "rpc_calls.h" #include "rpc_dispatch.h" #include "my_uart.h" @@ -408,6 +409,39 @@ void cmd_get_recovery_url(command_buf_t *buf) my_uart_transmit_packet(UART_CHAN, buf); } +void cmd_get_random(command_buf_t *buf) +{ + rpc_get_random_req *req = (rpc_get_random_req *)buf->data; + rpc_get_random_resp *resp = (rpc_get_random_resp *)buf->data; + + // The response overlays the request, so take what we need from it first + uint16_t length = (buf->size >= (int)sizeof(rpc_get_random_req)) ? req->length : 0; + uint32_t epoch = entropy_epoch(); + entropy_source_t source = entropy_source(); + + // Clear the fixed part, padding included, so no stale buffer bytes go out + memset(&resp->esp_err, 0, sizeof(rpc_get_random_resp) - sizeof(rpc_header_t)); + resp->source = source; + if ((length == 0) || (length > RANDOM_MAX_BYTES)) { + resp->esp_err = ESP_ERR_INVALID_ARG; + } else if (source == ENTROPY_NONE) { + resp->esp_err = ESP_ERR_INVALID_STATE; + } else { + esp_fill_random(resp->data, length); + // This module stops the radio on request: bytes drawn while it stopped, even if + // it has started again, are not sent + if ((entropy_source() == ENTROPY_NONE) || (entropy_epoch() != epoch)) { + resp->source = ENTROPY_NONE; + resp->esp_err = ESP_ERR_INVALID_STATE; + } else { + resp->esp_err = ESP_OK; + resp->length = length; + } + } + buf->size = sizeof(rpc_get_random_resp) + resp->length; + my_uart_transmit_packet(UART_CHAN, buf); +} + void cmd_not_implemented(command_buf_t *buf) { rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; @@ -547,6 +581,9 @@ void dispatch(void *ct) case CMD_GET_RECOVERY_URL: cmd_get_recovery_url(pbuffer); break; + case CMD_GET_RANDOM: + cmd_get_random(pbuffer); + break; default: cmd_not_implemented(pbuffer); break; diff --git a/software/u64ctrl/main/rpc_dispatch.h b/software/u64ctrl/main/rpc_dispatch.h index 798341251..0f017ce57 100644 --- a/software/u64ctrl/main/rpc_dispatch.h +++ b/software/u64ctrl/main/rpc_dispatch.h @@ -26,8 +26,9 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.24" +#define IDENT_STRING "ESP32 WiFi Bridge V1.25" #define IDENT_MAJOR 1 +// 1.25: CMD_GET_RANDOM. // 1.24: starts and stops the radio through the code it shares with the U64 module. // 1.23: a Disable or Autoconnect during the AP list walks is no longer lost, Enable // reconnects after a Disconnect, a Scan while Disabled is refused and a Connect leaves @@ -48,7 +49,7 @@ void send_keepalive(); // when this is higher than what the module reports, so a module change that // does not bump it is silently never installed, and an older release never // replaces a newer module. -#define IDENT_MINOR 24 +#define IDENT_MINOR 25 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 diff --git a/software/u64ctrl/main/wifi_modem.c b/software/u64ctrl/main/wifi_modem.c index 9732f13a4..e7ef2803c 100644 --- a/software/u64ctrl/main/wifi_modem.c +++ b/software/u64ctrl/main/wifi_modem.c @@ -83,6 +83,19 @@ uint16_t ap_count = 0; uint16_t connected_g = 0; uint16_t disabled_g = 0; +/* What feeds the RNG: esp_fill_random() is only truly random while the radio runs + * (esp_random.h). The radio counts as off from the moment a stop begins, and the epoch + * counts the stops, so that a stop and a start within one draw are noticed. */ +entropy_source_t entropy_source(void) +{ + return radio_is_on() ? ENTROPY_RADIO : ENTROPY_NONE; +} + +uint32_t entropy_epoch(void) +{ + return radio_epoch(); +} + esp_netif_t *my_sta_netif = NULL; netif_input_fn default_input; netif_output_fn default_output; diff --git a/software/u64ctrl/main/wifi_modem.h b/software/u64ctrl/main/wifi_modem.h index d978e80d6..280f973fe 100644 --- a/software/u64ctrl/main/wifi_modem.h +++ b/software/u64ctrl/main/wifi_modem.h @@ -29,6 +29,8 @@ void enable_hook(); void disable_hook(); void wake_on_wifi_update(int machine_on); uint8_t wifi_get_connection(); +entropy_source_t entropy_source(void); +uint32_t entropy_epoch(void); void wifi_send_connected_event(); void show_buffer_status(); From 276771fc9953e96b8757e379ecf498f9c71c4c22 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:28:59 -0500 Subject: [PATCH 42/95] Describe the C64 Ultimate's release firmware by its product name in a test comment Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/e2e/io/command_interface/net_target_test.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/e2e/io/command_interface/net_target_test.py b/tests/e2e/io/command_interface/net_target_test.py index 19061b2e7..9c2fa3734 100644 --- a/tests/e2e/io/command_interface/net_target_test.py +++ b/tests/e2e/io/command_interface/net_target_test.py @@ -179,8 +179,20 @@ # The /v1/info products that draw GET_RANDOM bytes on the ESP32 (U64 == 1 in # product.cc), matched exactly since "Ultimate 64-II" starts with "Ultimate 64". -# Every other product answers 87, even with a wifi_mac: its ESP32 runs other code. U64_MK1_PRODUCTS = ("Ultimate 64", "Ultimate 64 Elite") +# U64 == 2, the Ultimate 64 Elite II and the C64 Ultimate. It draws them too, but +# has no "WiFi Enabled" setting: its radio is on from boot and the menu's Enable +# and Disable are actions. Two names, because the name is not the build's: +# - "Ultimate 64-II" is the only one this source tree has (product_name[6], +# product.cc:18, chosen by getProductId() for U64 == 2 at product.cc:96-97). The +# Elite II reports it, and so does a C64 Ultimate running a build of this tree. +# - "C64 Ultimate" is what the C64 Ultimate's release firmware reports in +# /v1/info (read from a C64 Ultimate on 1.1.0, 2026-10-15). Nothing in this tree +# produces it; it is listed so that such a unit is not taken to be a product +# that must refuse. +U64_MK2_PRODUCTS = ("Ultimate 64-II", "C64 Ultimate") +# Every other product answers 87, even with a wifi_mac: its ESP32 runs other code. +GET_RANDOM_PRODUCTS = U64_MK1_PRODUCTS + U64_MK2_PRODUCTS # The setting that starts the module there, by the store's exact name (the answer # is keyed by it). Set for the run; writing Disabled back restores the setting but # does not stop the module (network_esp32.cc, effectuate_settings). From 93d945cd9d88d9540f91e628cce98f36de6fcdb0 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:28:59 -0500 Subject: [PATCH 43/95] Serve GET_RANDOM with the radio off, from the SAR ADC entropy source With the radio off, esp_fill_random() is no longer fed by a true entropy source, so GET_RANDOM refused with 87. The modules now enable the bootloader_random SAR ADC source whenever the radio is off, read its registers back, and report ENTROPY_ADC only when they match; a failed readback leaves ENTROPY_NONE and is retried at most three times per radio change. radio_entropy.c in software/wifi/common holds the logic for both modules, radio_entropy_esp.c the chip side. wifi_radio.c makes every radio start and stop under the exclusive hold of a writer-preferring gate there, which switches the source between the radio and the ADC. A draw takes it shared, for the draw only, and answers RPC_ERR_ENTROPY_BUSY when it cannot get it within 20 ms: nothing is drawn, and asking again is safe. A radio change waits for the draws in progress, and no new draw starts while it waits. On the Elite II and C64 Ultimate the voltage readout uses the same SAR ADC, and a oneshot read takes it over from the entropy source. A read now takes the gate exclusively, turns the source off for the read, and turns it back on and reads it back afterwards. When the gate is not free within 50 ms the read gives the last values, never zeros; a first read at boot fills them. The gate replaces the ADC mutex. A voltage answer that has no values now says so in its error field, with the fields cleared. On the ESP32-S3, bootloader_random_enable() pulses the SAR ADC's reset and leaves its bus clock off, behind the reference count of the oneshot driver, which set the clock on when it created its unit and never sets it again. Every voltage read therefore sets the clock on first, also with the radio on, since an earlier enable may have left it off. The ESP32-S3 source needs ESP-IDF 6: with 5.3.1 the disable leaves the SAR ADC's digital block in reset and every later enable fails its readback (1999 of 2000 on a devkit); with 6.0.3, 0 of 2000. The module is built with 6, and an S3 build with 5 now stops with an error. The host test runs the helper and wifi_radio.c against a model of the chip that fails on any call the hardware would not allow, or made without the gate, and on a source reported while the radio changes. Co-Authored-By: Claude Opus 5.5 --- Makefile | 1 + .../test/radio_entropy/radio_entropy_test.c | 1016 +++++++++++++++++ software/u64ctrl/main/CMakeLists.txt | 2 +- software/u64ctrl/main/control_main.c | 26 +- software/u64ctrl/main/rpc_dispatch.c | 39 +- software/u64ctrl/main/rpc_dispatch.h | 2 +- software/u64ctrl/main/wifi_modem.c | 20 +- software/u64ctrl/main/wifi_modem.h | 4 +- software/wifi/common/radio_entropy.c | 392 +++++++ software/wifi/common/radio_entropy.h | 115 ++ software/wifi/common/radio_entropy_esp.c | 151 +++ software/wifi/common/radio_entropy_port.h | 34 + software/wifi/common/rpc_shared.h | 6 + software/wifi/common/wifi_radio.c | 41 +- software/wifi/common/wifi_radio.h | 3 +- software/wifi/raw_u64/main/CMakeLists.txt | 2 +- software/wifi/raw_u64/main/rpc_dispatch.c | 32 +- software/wifi/raw_u64/main/rpc_dispatch.h | 2 +- software/wifi/raw_u64/main/wifi_modem.c | 15 +- software/wifi/raw_u64/main/wifi_modem.h | 3 +- software/wifi/tests/Makefile | 6 +- software/wifi/tests/radio_test.cpp | 57 +- target/pc/linux/radioentropy/Makefile | 40 + 23 files changed, 1889 insertions(+), 120 deletions(-) create mode 100644 software/test/radio_entropy/radio_entropy_test.c create mode 100644 software/wifi/common/radio_entropy.c create mode 100644 software/wifi/common/radio_entropy.h create mode 100644 software/wifi/common/radio_entropy_esp.c create mode 100644 software/wifi/common/radio_entropy_port.h create mode 100644 target/pc/linux/radioentropy/Makefile diff --git a/Makefile b/Makefile index b25df58fd..5072485fa 100755 --- a/Makefile +++ b/Makefile @@ -86,6 +86,7 @@ host_tests: @$(MAKE) -C software/wifi/tests @$(MAKE) -C target/pc/linux/recoveryimage test @$(MAKE) -C target/pc/linux/recoveryurl test + @$(MAKE) -C target/pc/linux/radioentropy test @$(MAKE) -C target/pc/linux/wifirandom test @$(MAKE) -C target/pc/linux/wifidedicated test diff --git a/software/test/radio_entropy/radio_entropy_test.c b/software/test/radio_entropy/radio_entropy_test.c new file mode 100644 index 000000000..3184511be --- /dev/null +++ b/software/test/radio_entropy/radio_entropy_test.c @@ -0,0 +1,1016 @@ +// Host test of radio_entropy.c, against a model of the chip that counts every call the +// hardware would not allow as a violation: +// - bootloader_random_enable while the radio runs or while the source is on already; +// - bootloader_random_disable while it is off; +// - the Wi-Fi start while the source is on or the radio runs, the Wi-Fi stop while it is off; +// - any chip call made without the gate held exclusively, or a log line written with it held; +// - a source other than NONE reported while the radio starts or stops. +// The radio is started and stopped through wifi_radio.c, which is built in too. +// make -C target/pc/linux/radioentropy test +// Each case runs in a process of its own, because the helper keeps its state in statics. +#include +#include +#include +#include +#include +#include +#include +#include "radio_entropy.h" +#include "radio_entropy_port.h" +#include "wifi_radio.h" +#include "wifi_radio_port.h" + +static int failures; + +#define CHECK(cond, what) do { \ + if (!(cond)) { failures++; printf(" FAIL %s (line %d)\n", what, __LINE__); } \ + } while (0) + +//---------------------------------- +// The model + +static pthread_mutex_t lock_mutex = PTHREAD_MUTEX_INITIALIZER; + +static volatile bool wifi_running; +static volatile bool hw_on; // the source is enabled +static volatile bool hw_good = true; // the registers read back correctly while it is on +static volatile int violations; +static volatile int readback_failing; // this many readbacks fail +static volatile int wifi_start_fails; +static volatile int wifi_stop_fails; +static volatile int readbacks; +static char trace[256]; +static pthread_mutex_t trace_mutex = PTHREAD_MUTEX_INITIALIZER; + +static void note(char c) +{ + pthread_mutex_lock(&trace_mutex); + size_t n = strlen(trace); + if (n + 1 < sizeof(trace)) { + trace[n] = c; + trace[n + 1] = 0; + } + pthread_mutex_unlock(&trace_mutex); +} + +static void violate(const char *what) +{ + violations++; + printf(" violation: %s\n", what); +} + +// Every chip call comes with the exclusive hold. +static void need_gate(const char *what) +{ + if (!radio_entropy_held_exclusive()) { + violate(what); + } +} + +void re_port_lock(void) { pthread_mutex_lock(&lock_mutex); } +void re_port_unlock(void) { pthread_mutex_unlock(&lock_mutex); } + +uint32_t re_port_now_ms(void) +{ + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return (uint32_t)(ts.tv_sec * 1000 + ts.tv_nsec / 1000000); +} + +void re_port_delay_ms(uint32_t ms) +{ + usleep(ms * 1000); +} + +uintptr_t re_port_task(void) +{ + return (uintptr_t)pthread_self(); +} + +int wr_port_wifi_start(void) +{ + need_gate("wifi start without the gate"); + if (entropy_source() != ENTROPY_NONE) violate("a source reported while the radio starts"); + if (wifi_running) violate("wifi start while running"); + if (hw_on) violate("wifi start with the ADC source on"); + note('S'); + if (wifi_start_fails > 0) { + wifi_start_fails--; + return 0x101; + } + wifi_running = true; + return 0; +} + +int wr_port_wifi_stop(void) +{ + need_gate("wifi stop without the gate"); + if (entropy_source() != ENTROPY_NONE) violate("a source reported while the radio stops"); + if (!wifi_running) violate("wifi stop while not running"); + note('P'); + if (wifi_stop_fails > 0) { + wifi_stop_fails--; + return 0x101; + } + wifi_running = false; + return 0; +} + +static volatile bool bus_clk_off; // as bootloader_random_enable() leaves it on the S3 + +void re_port_random_enable(void) +{ + need_gate("enable without the gate"); + if (wifi_running) violate("enable while the radio runs"); + if (hw_on) violate("enable twice"); + note('E'); + hw_on = true; + bus_clk_off = true; +} + +void re_port_adc_ready(void) +{ + need_gate("ADC readied without the gate"); + bus_clk_off = false; +} + +void re_port_random_disable(void) +{ + need_gate("disable without the gate"); + if (!hw_on) violate("disable while off"); + note('D'); + hw_on = false; +} + +bool re_port_random_readback(void) +{ + need_gate("readback without the gate"); + readbacks++; + if (readback_failing > 0) { + readback_failing--; + return false; + } + return hw_on && hw_good; +} + +static volatile int log_lines; + +void re_port_log(const char *fmt, ...) +{ + if (radio_entropy_held_exclusive()) violate("log line written with the gate held"); + log_lines++; +} + +static void reset_trace(void) +{ + pthread_mutex_lock(&trace_mutex); + trace[0] = 0; + pthread_mutex_unlock(&trace_mutex); +} + +static bool trace_is(const char *expected) +{ + if (strcmp(trace, expected) != 0) { + printf(" trace \"%s\", expected \"%s\"\n", trace, expected); + return false; + } + return true; +} + +//---------------------------------- +// The cases + +static void boot_without_radio(void) +{ + // The bootloader left the source off. A boot that does not start the radio turns it on. + radio_entropy_init(); + CHECK(trace_is("E"), "enable once"); + CHECK(entropy_source() == ENTROPY_ADC, "ADC after a passing readback"); + CHECK(violations == 0, "no violations"); + radio_entropy_init(); + CHECK(trace_is("E"), "a second init does nothing"); +} + +static void boot_with_radio(void) +{ + CHECK(entropy_source() == ENTROPY_NONE, "NONE before anything"); + CHECK(radio_start() == 0, "start"); + CHECK(trace_is("S"), "no disable or enable on a boot that never had the source on"); + CHECK(entropy_source() == ENTROPY_RADIO, "RADIO"); + radio_entropy_init(); + CHECK(trace_is("S"), "init does nothing with the radio running"); + CHECK(violations == 0, "no violations"); +} + +static void boot_readback_fails_then_retries(void) +{ + // NONE until a readback passes; never ADC without one + readback_failing = 2; + radio_entropy_init(); + CHECK(entropy_source() == ENTROPY_NONE, "NONE after a failed readback"); + radio_entropy_poll(); + CHECK(entropy_source() == ENTROPY_NONE, "still NONE after the first retry fails"); + radio_entropy_poll(); + CHECK(entropy_source() == ENTROPY_ADC, "ADC once a retry reads back"); + CHECK(trace_is("EDEDE"), "each retry disables, then enables"); + radio_entropy_poll(); + CHECK(trace_is("EDEDE"), "no more retries once it passed"); + radio_entropy_stats_t st; + radio_entropy_get_stats(&st); + CHECK(st.readback_failures == 2, "two failures counted"); + CHECK(st.retries == 2, "two retries counted"); + CHECK(violations == 0, "no violations"); +} + +static void retries_are_bounded(void) +{ + readback_failing = 100; + radio_entropy_init(); + for (int i = 0; i < 10; i++) { + radio_entropy_poll(); + } + radio_entropy_stats_t st; + radio_entropy_get_stats(&st); + CHECK(st.retries == RE_RETRIES, "RE_RETRIES retries, then no more"); + CHECK(entropy_source() == ENTROPY_NONE, "NONE"); + // A transition gives a new budget + readback_failing = 0; + CHECK(radio_start() == 0, "start"); + CHECK(radio_stop() == 0, "stop"); + CHECK(entropy_source() == ENTROPY_ADC, "ADC after a transition with a good readback"); + CHECK(violations == 0, "no violations"); +} + +static void start_from_adc(void) +{ + radio_entropy_init(); + reset_trace(); + uint32_t epoch = entropy_epoch(); + CHECK(radio_start() == 0, "start"); + CHECK(trace_is("DS"), "disable, then start"); + CHECK(entropy_source() == ENTROPY_RADIO, "RADIO"); + CHECK(entropy_epoch() == epoch, "the epoch counts stops, not starts"); + CHECK(radio_start() == 0, "start again"); + CHECK(trace_is("DS"), "a second start does nothing"); + CHECK(violations == 0, "no violations"); +} + +static void stop_enables(void) +{ + CHECK(radio_start() == 0, "start"); + reset_trace(); + uint32_t epoch = entropy_epoch(); + CHECK(radio_stop() == 0, "stop"); + CHECK(trace_is("PE"), "stop, then enable"); + CHECK(entropy_source() == ENTROPY_ADC, "ADC"); + CHECK(entropy_epoch() == epoch + 1, "epoch moved"); + CHECK(radio_stop() == 0, "stop again"); + CHECK(trace_is("PE"), "a second stop does nothing"); + CHECK(entropy_epoch() == epoch + 1, "and does not move the epoch"); + CHECK(violations == 0, "no violations"); +} + +static void stop_readback_fails(void) +{ + CHECK(radio_start() == 0, "start"); + readback_failing = 1; + CHECK(radio_stop() == 0, "stop"); + CHECK(entropy_source() == ENTROPY_NONE, "NONE: the readback caught it"); + radio_entropy_poll(); + CHECK(entropy_source() == ENTROPY_ADC, "ADC after the retry"); + // and the source then goes away with the next start + CHECK(radio_start() == 0, "start"); + CHECK(entropy_source() == ENTROPY_RADIO, "RADIO"); + CHECK(violations == 0, "no violations"); +} + +static void stop_fails(void) +{ + CHECK(radio_start() == 0, "start"); + reset_trace(); + wifi_stop_fails = 1; + CHECK(radio_stop() == 0x101, "stop passes the error on"); + CHECK(trace_is("P"), "no enable after a failed stop"); + CHECK(entropy_source() == ENTROPY_RADIO, "RADIO: the radio is still on"); + CHECK(wifi_running, "and it is"); + CHECK(radio_stop() == 0, "stop works the next time"); + CHECK(entropy_source() == ENTROPY_ADC, "ADC"); + CHECK(violations == 0, "no violations"); +} + +static void start_fails(void) +{ + radio_entropy_init(); + reset_trace(); + wifi_start_fails = 1; + CHECK(radio_start() == 0x101, "start passes the error on"); + CHECK(trace_is("DSE"), "the source is put back after a failed start"); + CHECK(entropy_source() == ENTROPY_ADC, "ADC"); + CHECK(!wifi_running, "radio off"); + CHECK(radio_start() == 0, "start works the next time"); + CHECK(entropy_source() == ENTROPY_RADIO, "RADIO"); + CHECK(violations == 0, "no violations"); +} + +static void adc_read_with_source_on(void) +{ + radio_entropy_init(); + reset_trace(); + CHECK(radio_entropy_adc_begin(RE_WAIT_ADC_MS) == 0, "begin"); + CHECK(trace_is("D"), "the source off"); + CHECK(entropy_source() == ENTROPY_NONE, "NONE while the ADC is lent out"); + CHECK(radio_entropy_acquire_shared(0) == RE_ERR_RECURSION, "the lender holds the gate"); + radio_entropy_adc_end(); + CHECK(trace_is("DE"), "the source on again"); + CHECK(entropy_source() == ENTROPY_ADC, "ADC, read back"); + radio_entropy_stats_t st; + radio_entropy_get_stats(&st); + CHECK(st.adc_hold_max_ms < 10, "held for less than 10 ms"); + CHECK(radio_entropy_acquire_shared(0) == 0, "and the gate is free"); + radio_entropy_release_shared(); + CHECK(violations == 0, "no violations"); +} + +static void adc_read_readback_fails(void) +{ + radio_entropy_init(); + CHECK(radio_entropy_adc_begin(RE_WAIT_ADC_MS) == 0, "begin"); + readback_failing = 1; + radio_entropy_adc_end(); + CHECK(entropy_source() == ENTROPY_NONE, "NONE: the readback caught it"); + radio_entropy_poll(); + CHECK(entropy_source() == ENTROPY_ADC, "ADC after the retry"); + CHECK(violations == 0, "no violations"); +} + +static void adc_read_with_radio_on(void) +{ + CHECK(radio_start() == 0, "start"); + reset_trace(); + CHECK(radio_entropy_adc_begin(RE_WAIT_ADC_MS) == 0, "begin"); + CHECK(entropy_source() == ENTROPY_RADIO, "RADIO throughout"); + radio_entropy_adc_end(); + CHECK(trace_is(""), "the radio running, nothing is touched"); + CHECK(entropy_source() == ENTROPY_RADIO, "RADIO"); + CHECK(violations == 0, "no violations"); +} + +static void adc_read_with_source_off(void) +{ + // A failed readback left no source; reading the voltages does not make one + readback_failing = 100; + radio_entropy_init(); + reset_trace(); + CHECK(radio_entropy_adc_begin(RE_WAIT_ADC_MS) == 0, "begin"); + radio_entropy_adc_end(); + CHECK(entropy_source() == ENTROPY_NONE, "NONE"); + CHECK(violations == 0, "no violations"); +} + +//---------------------------------- +// The gate + +struct holder { + volatile int state; // 0 not started, 1 holding, 2 done + volatile int release; + int rc; + uint32_t wait_ms; + int kind; // 0 shared hold, 1 radio_stop, 2 adc_begin/end, 3 start +}; + +static void *holder_thread(void *arg) +{ + struct holder *h = arg; + if (h->kind == 0) { + h->rc = radio_entropy_acquire_shared(h->wait_ms); + if (h->rc == 0) { + h->state = 1; + while (!h->release) usleep(500); + radio_entropy_release_shared(); + } + } else if (h->kind == 1) { + h->state = 1; + h->rc = radio_stop(); + } else if (h->kind == 2) { + h->state = 1; + h->rc = radio_entropy_adc_begin(h->wait_ms); + if (h->rc == 0) { + radio_entropy_adc_end(); + } + } else if (h->kind == 5) { + h->rc = radio_entropy_adc_begin(h->wait_ms); + if (h->rc == 0) { + h->state = 1; + while (!h->release) usleep(500); + radio_entropy_adc_end(); + } + } else { + h->state = 1; + h->rc = radio_start(); + } + h->state = 2; + return NULL; +} + +static pthread_t spawn(struct holder *h) +{ + pthread_t t; + h->state = 0; + h->release = 0; + pthread_create(&t, NULL, holder_thread, h); + return t; +} + +static void wait_state(struct holder *h, int state) +{ + for (int i = 0; (i < 4000) && (h->state < state); i++) usleep(500); +} + +static void shared_holders_do_not_block_each_other(void) +{ + CHECK(radio_start() == 0, "start"); + struct holder a = { .wait_ms = 20 }, b = { .wait_ms = 20 }; + pthread_t ta = spawn(&a); + wait_state(&a, 1); + pthread_t tb = spawn(&b); + wait_state(&b, 1); + CHECK((a.state == 1) && (b.state == 1), "two holders at once"); + a.release = b.release = 1; + pthread_join(ta, NULL); + pthread_join(tb, NULL); + CHECK((a.rc == 0) && (b.rc == 0), "both got it"); +} + +static void pending_writer_blocks_new_readers(void) +{ + CHECK(radio_start() == 0, "start"); + struct holder reader = { .wait_ms = 20 }; + pthread_t tr = spawn(&reader); + wait_state(&reader, 1); + + struct holder writer = { .kind = 1 }; + pthread_t tw = spawn(&writer); + usleep(20000); // the stop is waiting for the reader + CHECK(writer.state == 1, "the stop waits for the reader"); + CHECK(wifi_running, "and has not stopped the radio"); + + uint32_t t0 = re_port_now_ms(); + CHECK(radio_entropy_acquire_shared(20) == RE_ERR_BUSY, "a new reader is turned away: busy"); + uint32_t waited = re_port_now_ms() - t0; + CHECK((waited >= 15) && (waited < 200), "after about 20 ms"); + CHECK(radio_entropy_acquire_shared(0) == RE_ERR_BUSY, "at once with a wait of 0"); + + reader.release = 1; + pthread_join(tr, NULL); + pthread_join(tw, NULL); + CHECK(writer.rc == 0, "the stop completes"); + CHECK(!wifi_running, "radio off"); + CHECK(radio_entropy_acquire_shared(20) == 0, "readers are served again"); + CHECK(entropy_source() == ENTROPY_ADC, "ADC"); + radio_entropy_release_shared(); + CHECK(violations == 0, "no violations"); +} + +static void writer_that_gives_up_leaves_nothing_behind(void) +{ + radio_entropy_init(); + struct holder reader = { .wait_ms = 20 }; + pthread_t tr = spawn(&reader); + wait_state(&reader, 1); + uint32_t t0 = re_port_now_ms(); + CHECK(radio_entropy_adc_begin(30) == RE_ERR_BUSY, "the voltage read gives up"); + uint32_t waited = re_port_now_ms() - t0; + CHECK((waited >= 25) && (waited < 200), "after about 30 ms"); + reader.release = 1; + pthread_join(tr, NULL); + CHECK(radio_entropy_acquire_shared(0) == 0, "no pending writer left behind"); + radio_entropy_release_shared(); + CHECK(entropy_source() == ENTROPY_ADC, "the source was not touched"); + CHECK(violations == 0, "no violations"); +} + +static void recursion_is_refused(void) +{ + CHECK(radio_start() == 0, "start"); + CHECK(radio_entropy_acquire_shared(20) == 0, "shared"); + // With a writer pending, a waiting second acquire would never return + struct holder writer = { .kind = 1 }; + pthread_t tw = spawn(&writer); + usleep(20000); + uint32_t t0 = re_port_now_ms(); + CHECK(radio_entropy_acquire_shared(5000) == RE_ERR_RECURSION, "shared again, writer pending: refused"); + CHECK(re_port_now_ms() - t0 < 100, "at once, not after the wait"); + CHECK(radio_stop() == RE_ERR_RECURSION, "a reader cannot become a writer"); + CHECK(radio_start() == RE_ERR_RECURSION, "nor start the radio"); + CHECK(radio_entropy_adc_begin(5000) == RE_ERR_RECURSION, "nor lend out the ADC"); + radio_entropy_release_shared(); + pthread_join(tw, NULL); + CHECK(writer.rc == 0, "the stop completes"); + radio_entropy_stats_t st; + radio_entropy_get_stats(&st); + CHECK(st.recursion >= 4, "counted"); + CHECK(violations == 0, "no violations"); +} + +// A stub of a busy reader: shared holds of 2 ms, one after another, as fast as it can +static volatile int stop_engine; +static volatile int engine_steps, engine_busy; + +static void *engine(void *arg) +{ + while (!stop_engine) { + if (radio_entropy_acquire_shared(RE_WAIT_RANDOM_MS) == 0) { + usleep(2000); + radio_entropy_release_shared(); + engine_steps++; + } else { + engine_busy++; + } + } + return NULL; +} + +static void back_to_back_readers_do_not_starve_a_transition(void) +{ + CHECK(radio_start() == 0, "start"); + pthread_t te; + pthread_create(&te, NULL, engine, NULL); + while (engine_steps < 5) usleep(1000); + uint32_t t0 = re_port_now_ms(); + CHECK(radio_stop() == 0, "stop"); + uint32_t took = re_port_now_ms() - t0; + CHECK(took < 300, "completes within a few steps, not starved"); + CHECK(!wifi_running, "radio off"); + stop_engine = 1; + pthread_join(te, NULL); + CHECK(violations == 0, "no violations"); +} + +static void gate_is_free_after_a_failed_transition(void) +{ + CHECK(radio_start() == 0, "start"); + wifi_stop_fails = 1; + CHECK(radio_stop() != 0, "stop fails"); + CHECK(radio_entropy_acquire_shared(0) == 0, "the gate is free"); + radio_entropy_release_shared(); + CHECK(radio_entropy_adc_begin(20) == 0, "and for the writer"); + radio_entropy_adc_end(); +} + +//---------------------------------- +// The answer to GET_RANDOM + +static volatile int fills; +static volatile int fill_gate_ok; + +// esp_fill_random(): called with the shared hold, and with nothing else held +static void fake_fill(void *buf, size_t len) +{ + fills++; + if ((radio_entropy_acquire_shared(0) == RE_ERR_RECURSION) && !radio_entropy_held_exclusive()) { + fill_gate_ok++; + } + memset(buf, 0xA5, len); +} + +static union { + uint32_t align; + uint8_t bytes[12 + 512 + 16]; +} msg; + +// Asks for len bytes; returns the size of the answer +static int ask(uint16_t len, int size_in) +{ + memset(msg.bytes, 0xEE, sizeof(msg.bytes)); + rpc_get_random_req *req = (rpc_get_random_req *)msg.bytes; + req->hdr.command = CMD_GET_RANDOM; + req->length = len; + return radio_entropy_serve_get_random(msg.bytes, size_in, fake_fill); +} + +static rpc_get_random_resp *reply(void) +{ + return (rpc_get_random_resp *)msg.bytes; +} + +static bool gate_is_free(void) +{ + if (radio_entropy_acquire_shared(0) != 0) return false; + radio_entropy_release_shared(); + if (radio_entropy_adc_begin(0) != 0) return false; + radio_entropy_adc_end(); + return true; +} + +static void get_random_answers(void) +{ + int n; + // No source yet + n = ask(16, 6); + CHECK((n == 12) && (reply()->esp_err == RE_ESP_ERR_INVALID_STATE) && (reply()->length == 0), "NONE: refused, no bytes"); + CHECK(reply()->source == ENTROPY_NONE, "NONE: source says none"); + CHECK(fills == 0, "nothing drawn"); + CHECK(gate_is_free(), "the gate is free after a refusal (no hold leaks)"); + + radio_entropy_init(); + n = ask(16, 6); + CHECK((n == 12 + 16) && (reply()->esp_err == 0) && (reply()->length == 16), "ADC: 16 bytes"); + CHECK((reply()->source == ENTROPY_ADC) && (reply()->data[0] == 0xA5) && (reply()->data[15] == 0xA5), "ADC: from the draw"); + CHECK(msg.bytes[12 + 16] == 0xEE, "no byte past the length is written"); + CHECK((fills == 1) && (fill_gate_ok == 1), "drawn once, with the shared hold only"); + CHECK(gate_is_free(), "the gate is free when the answer goes out"); + + n = ask(512, 6); + CHECK((n == 12 + 512) && (reply()->esp_err == 0), "512 bytes"); + n = ask(0, 6); + CHECK((n == 12) && (reply()->esp_err == RE_ESP_ERR_INVALID_ARG), "0 bytes: invalid"); + n = ask(513, 6); + CHECK((n == 12) && (reply()->esp_err == RE_ESP_ERR_INVALID_ARG) && (reply()->length == 0), "513 bytes: invalid"); + n = ask(16, 5); + CHECK((n == 12) && (reply()->esp_err == RE_ESP_ERR_INVALID_ARG), "a request too short to hold the length"); + CHECK(fills == 2, "refusals draw nothing"); + CHECK(gate_is_free(), "the gate is free after each"); + CHECK(msg.bytes[12] == 0xEE, "a refusal sends no data"); + + CHECK(radio_start() == 0, "start"); + n = ask(8, 6); + CHECK((n == 12 + 8) && (reply()->source == ENTROPY_RADIO), "RADIO: served"); + CHECK(radio_stop() == 0, "stop"); + n = ask(8, 6); + CHECK((n == 12 + 8) && (reply()->source == ENTROPY_ADC), "ADC again after the stop"); + CHECK(violations == 0, "no violations"); +} + +void serve_from_thread(int *size, uint32_t *ms); + +static void get_random_busy(void) +{ + radio_entropy_init(); + // A voltage read holds the source + CHECK(radio_entropy_adc_begin(20) == 0, "the ADC is lent out"); + // This task holds the gate exclusively, so serve from another + int size = 0; + uint32_t ms = 0; + serve_from_thread(&size, &ms); + CHECK(size == 12, "busy: no data"); + CHECK(reply()->esp_err == RPC_ERR_ENTROPY_BUSY, "busy: the busy error"); + CHECK((reply()->source == ENTROPY_NONE) && (reply()->length == 0), "busy: no source, no bytes"); + CHECK((ms >= 15) && (ms < 200), "after about 20 ms"); + CHECK(fills == 0, "nothing drawn"); + radio_entropy_adc_end(); + CHECK(gate_is_free(), "free again"); + CHECK(ask(4, 6) == 12 + 4, "served once the ADC is back"); + CHECK(violations == 0, "no violations"); +} + +static void *serve_thread(void *arg) +{ + int *r = arg; + uint32_t t0 = re_port_now_ms(); + r[0] = ask(16, 6); + r[1] = (int)(re_port_now_ms() - t0); + return NULL; +} + +void serve_from_thread(int *size, uint32_t *ms) +{ + int r[2]; + pthread_t t; + pthread_create(&t, NULL, serve_thread, r); + pthread_join(t, NULL); + *size = r[0]; + *ms = (uint32_t)r[1]; +} + +//---------------------------------- +// The voltage read + +static volatile int unit_reads; +static volatile int unit_fails; +static volatile uint16_t unit_base; + +static int fake_unit(uint16_t *out) +{ + unit_reads++; + if (!radio_entropy_held_exclusive()) violate("voltages read without the exclusive hold"); + if (bus_clk_off) violate("voltages read with the SAR ADC bus clock off"); + if (hw_on) violate("voltages read with the ADC source on"); + if (unit_fails > 0) { + unit_fails--; + return 0x101; + } + for (int i = 0; i < 7; i++) out[i] = unit_base + i; + return 0; +} + +// Radio off (the source on), then on: the source's enable left the ADC's bus clock off, +// and a voltage read with the radio on must not read with it off +static void adc_read_after_the_radio_came_on(void) +{ + uint16_t out[7], cache[7]; + bool valid = false; + radio_entropy_init(); + CHECK(entropy_source() == ENTROPY_ADC, "radio off: the ADC source"); + CHECK(radio_start() == 0, "start"); + CHECK(radio_entropy_read_adc(out, cache, &valid, 7, fake_unit) == 0, "read with the radio on"); + CHECK(violations == 0, "the clock was on for the read"); +} + +static void adc_read_cache(void) +{ + uint16_t cache[7] = { 0 }; + bool valid = false; + uint16_t out[7]; + radio_entropy_init(); + + unit_base = 1000; + memset(out, 0xEE, sizeof(out)); + CHECK(radio_entropy_read_adc(out, cache, &valid, 7, fake_unit) == 0, "first read"); + CHECK(valid && (out[0] == 1000) && (out[6] == 1006) && (cache[3] == 1003), "values and cache"); + CHECK(entropy_source() == ENTROPY_ADC, "the source is back"); + CHECK(gate_is_free(), "gate free"); + + // The ADC is busy: a reader holds the gate + struct holder reader = { .wait_ms = 20 }; + pthread_t tr = spawn(&reader); + wait_state(&reader, 1); + unit_base = 2000; + int before = unit_reads; + memset(out, 0xEE, sizeof(out)); + uint32_t t0 = re_port_now_ms(); + CHECK(radio_entropy_read_adc(out, cache, &valid, 7, fake_unit) == 0, "busy with a cache: succeeds"); + uint32_t took = re_port_now_ms() - t0; + CHECK((out[0] == 1000) && (out[6] == 1006), "with the last values, not zeros"); + CHECK((took >= 40) && (took < 300), "after about 50 ms"); + CHECK(unit_reads == before, "the unit was not read"); + reader.release = 1; + pthread_join(tr, NULL); + + // A failing read gives the cache and the error + unit_fails = 1; + memset(out, 0xEE, sizeof(out)); + CHECK(radio_entropy_read_adc(out, cache, &valid, 7, fake_unit) == 0x101, "a failed read is reported"); + CHECK((out[0] == 1000) && (cache[0] == 1000), "and does not touch the cache"); + CHECK(entropy_source() == ENTROPY_ADC, "the source is back after a failed read"); + CHECK(gate_is_free(), "gate free"); + CHECK(violations == 0, "no violations"); +} + +static struct holder *release_target; + +static void *release_later(void *arg) +{ + usleep(100000); + release_target->release = 1; + return NULL; +} + +static void adc_read_without_a_cache(void) +{ + uint16_t cache[7] = { 0 }; + bool valid = false; + uint16_t out[7]; + radio_entropy_init(); + + // The boot read fails: no values, so an error, never zeros + unit_fails = 1; + memset(out, 0xEE, sizeof(out)); + CHECK(radio_entropy_read_adc(out, cache, &valid, 7, fake_unit) == 0x101, "the failed first read is an error"); + CHECK(!valid, "and there is no cache"); + CHECK(out[0] == 0xEEEE, "out is left alone"); + + // And the next read, when it cannot get the ADC, is an error too + struct holder reader = { .wait_ms = 20 }; + pthread_t tr = spawn(&reader); + wait_state(&reader, 1); + memset(out, 0xEE, sizeof(out)); + int rc = radio_entropy_read_adc(out, cache, &valid, 7, fake_unit); + CHECK(rc == RE_ERR_BUSY, "no cache and no ADC: an error, after the long wait"); + CHECK(out[0] == 0xEEEE, "out is left alone, not zeros"); + reader.release = 1; + pthread_join(tr, NULL); + + // The long wait lets a short hold through + struct holder blip = { .wait_ms = 20 }; + pthread_t tb = spawn(&blip); + wait_state(&blip, 1); + unit_base = 3000; + pthread_t rel; + release_target = &blip; + pthread_create(&rel, NULL, release_later, NULL); + rc = radio_entropy_read_adc(out, cache, &valid, 7, fake_unit); + CHECK((rc == 0) && valid && (out[0] == 3000), "no cache: waits for the ADC rather than give up at once"); + pthread_join(rel, NULL); + pthread_join(tb, NULL); + CHECK(violations == 0, "no violations"); +} + +static void retry_budget_survives_voltage_reads(void) +{ + uint16_t cache[7] = { 0 }; + bool valid = false; + uint16_t out[7]; + readback_failing = 100; + radio_entropy_init(); + for (int i = 0; i < 6; i++) radio_entropy_poll(); + radio_entropy_stats_t st; + radio_entropy_get_stats(&st); + CHECK(st.retries == RE_RETRIES, "the budget is spent"); + int lines = log_lines; + for (int i = 0; i < 5; i++) { + radio_entropy_read_adc(out, cache, &valid, 7, fake_unit); + radio_entropy_poll(); + } + radio_entropy_get_stats(&st); + CHECK(st.retries == RE_RETRIES, "voltage reads do not give new retries"); + CHECK(log_lines == lines, "and the failing readbacks are not logged again"); + CHECK(entropy_source() == ENTROPY_NONE, "NONE"); +} + +static void retries_per_transition(void) +{ + // The budget belongs to the transition: poll and voltage reads draw on it, nothing renews it + uint16_t cache[7] = { 0 }; + bool valid = false; + uint16_t out[7]; + unit_base = 500; + radio_entropy_init(); + CHECK(entropy_source() == ENTROPY_ADC, "healthy"); + // A healthy source fails once on a voltage read: that is the first failure, retries follow + readback_failing = 100; + radio_entropy_read_adc(out, cache, &valid, 7, fake_unit); + CHECK(entropy_source() == ENTROPY_NONE, "NONE after the failed re-enable"); + for (int i = 0; i < 10; i++) { + radio_entropy_poll(); + radio_entropy_read_adc(out, cache, &valid, 7, fake_unit); + } + radio_entropy_stats_t st; + radio_entropy_get_stats(&st); + CHECK(st.retries == RE_RETRIES, "no more than RE_RETRIES retries, polls and reads together"); + reset_trace(); + for (int i = 0; i < 5; i++) { + radio_entropy_read_adc(out, cache, &valid, 7, fake_unit); + } + CHECK(trace_is(""), "once spent, a voltage read does not touch the source at all"); + CHECK(entropy_source() == ENTROPY_NONE, "NONE until the next transition"); + CHECK(valid && (out[0] == 500), "and the voltages still read"); + // The next transition gives a new budget + readback_failing = 0; + CHECK(radio_start() == 0, "start"); + CHECK(radio_stop() == 0, "stop"); + CHECK(entropy_source() == ENTROPY_ADC, "ADC after the next transition"); + CHECK(violations == 0, "no violations"); +} + +static void spent_poll_does_not_wait_for_the_gate(void) +{ + readback_failing = 100; + radio_entropy_init(); + for (int i = 0; i < 4; i++) radio_entropy_poll(); + struct holder reader = { .wait_ms = 20 }; + pthread_t tr = spawn(&reader); + wait_state(&reader, 1); + uint32_t t0 = re_port_now_ms(); + radio_entropy_poll(); + CHECK(re_port_now_ms() - t0 < 5, "a poll with nothing to do returns at once, with the gate busy"); + reader.release = 1; + pthread_join(tr, NULL); + radio_entropy_stats_t st; + radio_entropy_get_stats(&st); + CHECK(st.busy == 0, "and did not queue for the gate"); +} + +static void adc_end_by_a_bystander_changes_nothing(void) +{ + radio_entropy_init(); + struct holder lender = { .kind = 5, .wait_ms = 50 }; + pthread_t tl = spawn(&lender); + wait_state(&lender, 1); + CHECK(entropy_source() == ENTROPY_NONE, "lent out"); + int lines = log_lines; + radio_entropy_adc_end(); + CHECK(log_lines == lines + 1, "an end without a begin is logged"); + CHECK(radio_entropy_acquire_shared(0) == RE_ERR_BUSY, "and the lender still holds the gate"); + CHECK(entropy_source() == ENTROPY_NONE, "and the source is untouched"); + lender.release = 1; + pthread_join(tl, NULL); + CHECK(entropy_source() == ENTROPY_ADC, "the lender's end puts the source back"); + CHECK(violations == 0, "no violations"); +} + +static void logs_are_written_outside_the_gate(void) +{ + readback_failing = 1; + radio_entropy_init(); + CHECK(log_lines == 1, "the mismatch was logged"); + CHECK(violations == 0, "and not with the gate held"); +} + +//---------------------------------- +// A long random walk over everything, with failures, against the model's rules + +static unsigned rng_state = 12345; +static unsigned rnd(unsigned n) +{ + rng_state = rng_state * 1664525u + 1013904223u; + return (rng_state >> 8) % n; +} + +static void random_walk(void) +{ + int adc_without_source = 0; + for (int i = 0; i < 20000; i++) { + switch (rnd(8)) { + case 0: radio_start(); break; + case 1: radio_stop(); break; + case 2: radio_entropy_init(); break; + case 3: radio_entropy_poll(); break; + case 4: + if (radio_entropy_adc_begin(5) == 0) { + radio_entropy_adc_end(); + } + break; + case 5: wifi_start_fails = rnd(3) == 0; break; + case 6: wifi_stop_fails = rnd(3) == 0; break; + case 7: readback_failing = rnd(3) == 0 ? 1 + rnd(3) : 0; break; + } + // The source is only ADC when the hardware really is on and was read back; RADIO only + // while the radio runs + entropy_source_t s = entropy_source(); + if ((s == ENTROPY_ADC) && !(hw_on && !wifi_running)) adc_without_source++; + if ((s == ENTROPY_RADIO) && !wifi_running) adc_without_source++; + if (s == ENTROPY_NONE && wifi_running) { /* a start that failed to report cannot happen */ adc_without_source++; } + } + CHECK(adc_without_source == 0, "the source always matches the chip"); + CHECK(violations == 0, "no violations in 20000 steps"); +} + +//---------------------------------- + +struct testcase { + const char *name; + void (*fn)(void); +}; + +#define CASE(f) { #f, f } + +static const struct testcase cases[] = { + CASE(boot_without_radio), + CASE(boot_with_radio), + CASE(boot_readback_fails_then_retries), + CASE(retries_are_bounded), + CASE(start_from_adc), + CASE(stop_enables), + CASE(stop_readback_fails), + CASE(stop_fails), + CASE(start_fails), + CASE(adc_read_with_source_on), + CASE(adc_read_readback_fails), + CASE(adc_read_with_radio_on), + CASE(adc_read_with_source_off), + CASE(shared_holders_do_not_block_each_other), + CASE(pending_writer_blocks_new_readers), + CASE(writer_that_gives_up_leaves_nothing_behind), + CASE(recursion_is_refused), + CASE(back_to_back_readers_do_not_starve_a_transition), + CASE(gate_is_free_after_a_failed_transition), + CASE(get_random_answers), + CASE(get_random_busy), + CASE(adc_read_after_the_radio_came_on), + CASE(adc_read_cache), + CASE(adc_read_without_a_cache), + CASE(retry_budget_survives_voltage_reads), + CASE(logs_are_written_outside_the_gate), + CASE(retries_per_transition), + CASE(spent_poll_does_not_wait_for_the_gate), + CASE(adc_end_by_a_bystander_changes_nothing), + CASE(random_walk), +}; + +int main(void) +{ + int bad = 0; + int n = sizeof(cases) / sizeof(cases[0]); + setvbuf(stdout, NULL, _IOLBF, 0); + for (int i = 0; i < n; i++) { + printf("%s\n", cases[i].name); + fflush(stdout); + pid_t pid = fork(); + if (pid == 0) { + alarm(30); // a hang is a failure + cases[i].fn(); + fflush(stdout); + _exit(failures ? 1 : 0); + } + int status = 0; + waitpid(pid, &status, 0); + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { + printf(" FAILED (status 0x%x)\n", status); + bad++; + } else { + printf(" ok\n"); + } + } + printf("\n%d cases, %d failed\n", n, bad); + return bad ? 1 : 0; +} diff --git a/software/u64ctrl/main/CMakeLists.txt b/software/u64ctrl/main/CMakeLists.txt index b7da73541..b62a94ecd 100755 --- a/software/u64ctrl/main/CMakeLists.txt +++ b/software/u64ctrl/main/CMakeLists.txt @@ -1,5 +1,5 @@ set(EXTERNAL "../../io/uart") set(COMMON "../../wifi/common") -idf_component_register(SRCS "button_handler.c" "control_main.c" "my_uart.c" "dump_hex.c" "rpc_dispatch.c" "wifi_modem.c" "button_handler.c" "jtag.c" "sntp.c" "power_state.c" "wol_magic.c" "recovery_manifest.c" "recovery_verify.c" "recovery_image.c" "recovery_url.c" "recovery.c" "recovery_trust.c" ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c +idf_component_register(SRCS "button_handler.c" "control_main.c" "my_uart.c" "dump_hex.c" "rpc_dispatch.c" "wifi_modem.c" "button_handler.c" "jtag.c" "sntp.c" "power_state.c" "wol_magic.c" "recovery_manifest.c" "recovery_verify.c" "recovery_image.c" "recovery_url.c" "recovery.c" "recovery_trust.c" ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_entropy.c ${COMMON}/radio_entropy_esp.c INCLUDE_DIRS "." ${EXTERNAL} ${COMMON} LDFRAGMENTS "linker.lf") diff --git a/software/u64ctrl/main/control_main.c b/software/u64ctrl/main/control_main.c index 6bd49fc40..eb4168053 100755 --- a/software/u64ctrl/main/control_main.c +++ b/software/u64ctrl/main/control_main.c @@ -23,6 +23,7 @@ #include "jtag.h" #include "sntp.h" #include "power_state.h" +#include "radio_entropy.h" #include "recovery.h" static const char *TAG = "u64ctrl"; @@ -97,7 +98,6 @@ static bool adc_calibration_init(adc_unit_t unit, adc_channel_t channel, adc_att } static adc_oneshot_unit_handle_t adc1_handle; -static SemaphoreHandle_t adc_lock = NULL; static adc_cali_handle_t adc1_cali_handle[7] = { 0 }; static void configure_adc(void) @@ -121,8 +121,6 @@ static void configure_adc(void) for(int i=0;i<7;i++) { adc_calibration_init(ADC_UNIT_1, ADC_CHANNEL_0+i, ADC_ATTEN_DB_12, &adc1_cali_handle[i]); } - - adc_lock = xSemaphoreCreateMutex(); } const int adc_scale[7] = { SCALE_VBUS, SCALE_VAUX, SCALE_V50, SCALE_V33, SCALE_V18, SCALE_V10, SCALE_VUSB }; @@ -139,28 +137,39 @@ static uint16_t adc_data_local[7]; // } // } -esp_err_t read_adc_channels(uint16_t *adc_data) +// The last voltages that were read, for a read that cannot get the ADC in time +static uint16_t adc_cache[7]; +static bool adc_cache_valid; + +// With the gate held exclusively, which is what keeps others off the unit +static int read_adc_unit(uint16_t *adc_data) { int adc_raw, voltage; esp_err_t ret = ESP_OK; - xSemaphoreTake(adc_lock, portMAX_DELAY); for(int i=0;i<7;i++) { ret = adc_oneshot_read(adc1_handle, ADC_CHANNEL_0+i, &adc_raw); if (ret != ESP_OK) { - xSemaphoreGive(adc_lock); return ret; } ret = adc_cali_raw_to_voltage(adc1_cali_handle[i], adc_raw, &voltage); if (ret != ESP_OK) { - xSemaphoreGive(adc_lock); return ret; } adc_data[i] = (voltage * adc_scale[i]) >> 16; } - xSemaphoreGive(adc_lock); return ESP_OK; } +// While the radio is off, the SAR ADC feeds the RNG, and a oneshot read takes ADC1 over +// from that source. So a read of the voltages takes the ADC for the length of the read, +// under the entropy gate. When it cannot get it in time it gives the values of the last +// read, never zeros; before there is a last read it waits for the ADC, and if that fails +// too it returns an error and leaves adc_data alone. +esp_err_t read_adc_channels(uint16_t *adc_data) +{ + return radio_entropy_read_adc(adc_data, adc_cache, &adc_cache_valid, 7, read_adc_unit); +} + void setup_modem(); void show_buffer_status(); @@ -200,6 +209,7 @@ void app_main(void) while (1) { read_adc_channels(adc_data_local); + radio_entropy_poll(); ESP_LOGI(TAG, "App Main Alive; 5V_GOOD: %d (Initial: %d). VBus = %d mV", gpio_get_level(IO_5V_GOOD), initial_state, adc_data_local[0]); // show_buffer_status(); if (recovery_owns_leds()) { diff --git a/software/u64ctrl/main/rpc_dispatch.c b/software/u64ctrl/main/rpc_dispatch.c index 6df5e8d60..31ff37973 100644 --- a/software/u64ctrl/main/rpc_dispatch.c +++ b/software/u64ctrl/main/rpc_dispatch.c @@ -245,11 +245,10 @@ void cmd_wifi_endisable(command_buf_t *buf) void cmd_get_voltages(command_buf_t *buf) { - extern esp_err_t read_adc_channels(uint16_t *adc_data); - rpc_get_voltages_resp *resp = (rpc_get_voltages_resp *)buf->data; - resp->esp_err = ESP_OK; - read_adc_channels(&(resp->vbus)); + // The answer overlays the request: an error must not carry what was in the buffer + memset(&resp->vbus, 0, sizeof(rpc_get_voltages_resp) - offsetof(rpc_get_voltages_resp, vbus)); + resp->esp_err = read_adc_channels(&(resp->vbus)); ESP_LOGI(TAG, "Vbus = %d, Vaux = %d, V50 = %d, V33 = %d, V18 = %d, V10 = %d, Vusb = %d", resp->vbus, resp->vaux, resp->v50, resp->v33, resp->v18, resp->v10, resp->vusb); buf->size = sizeof(rpc_get_voltages_resp); my_uart_transmit_packet(UART_CHAN, buf); @@ -409,36 +408,12 @@ void cmd_get_recovery_url(command_buf_t *buf) my_uart_transmit_packet(UART_CHAN, buf); } +_Static_assert(RPC_ERR_ENTROPY_BUSY == ESP_ERR_TIMEOUT, "RPC_ERR_ENTROPY_BUSY is an esp_err_t"); + void cmd_get_random(command_buf_t *buf) { - rpc_get_random_req *req = (rpc_get_random_req *)buf->data; - rpc_get_random_resp *resp = (rpc_get_random_resp *)buf->data; - - // The response overlays the request, so take what we need from it first - uint16_t length = (buf->size >= (int)sizeof(rpc_get_random_req)) ? req->length : 0; - uint32_t epoch = entropy_epoch(); - entropy_source_t source = entropy_source(); - - // Clear the fixed part, padding included, so no stale buffer bytes go out - memset(&resp->esp_err, 0, sizeof(rpc_get_random_resp) - sizeof(rpc_header_t)); - resp->source = source; - if ((length == 0) || (length > RANDOM_MAX_BYTES)) { - resp->esp_err = ESP_ERR_INVALID_ARG; - } else if (source == ENTROPY_NONE) { - resp->esp_err = ESP_ERR_INVALID_STATE; - } else { - esp_fill_random(resp->data, length); - // This module stops the radio on request: bytes drawn while it stopped, even if - // it has started again, are not sent - if ((entropy_source() == ENTROPY_NONE) || (entropy_epoch() != epoch)) { - resp->source = ENTROPY_NONE; - resp->esp_err = ESP_ERR_INVALID_STATE; - } else { - resp->esp_err = ESP_OK; - resp->length = length; - } - } - buf->size = sizeof(rpc_get_random_resp) + resp->length; + buf->size = radio_entropy_serve_get_random(buf->data, buf->size, (void (*)(void *, size_t))esp_fill_random); + // The gate is released: the answer is sent without it my_uart_transmit_packet(UART_CHAN, buf); } diff --git a/software/u64ctrl/main/rpc_dispatch.h b/software/u64ctrl/main/rpc_dispatch.h index 0f017ce57..7ef7201b3 100644 --- a/software/u64ctrl/main/rpc_dispatch.h +++ b/software/u64ctrl/main/rpc_dispatch.h @@ -28,7 +28,7 @@ void send_keepalive(); #define IDENT_STRING "ESP32 WiFi Bridge V1.25" #define IDENT_MAJOR 1 -// 1.25: CMD_GET_RANDOM. +// 1.25: CMD_GET_RANDOM, served with the radio off too, from the SAR ADC source. // 1.24: starts and stops the radio through the code it shares with the U64 module. // 1.23: a Disable or Autoconnect during the AP list walks is no longer lost, Enable // reconnects after a Disconnect, a Scan while Disabled is refused and a Connect leaves diff --git a/software/u64ctrl/main/wifi_modem.c b/software/u64ctrl/main/wifi_modem.c index e7ef2803c..a9da0a1e6 100644 --- a/software/u64ctrl/main/wifi_modem.c +++ b/software/u64ctrl/main/wifi_modem.c @@ -83,19 +83,6 @@ uint16_t ap_count = 0; uint16_t connected_g = 0; uint16_t disabled_g = 0; -/* What feeds the RNG: esp_fill_random() is only truly random while the radio runs - * (esp_random.h). The radio counts as off from the moment a stop begins, and the epoch - * counts the stops, so that a stop and a start within one draw are noticed. */ -entropy_source_t entropy_source(void) -{ - return radio_is_on() ? ENTROPY_RADIO : ENTROPY_NONE; -} - -uint32_t entropy_epoch(void) -{ - return radio_epoch(); -} - esp_netif_t *my_sta_netif = NULL; netif_input_fn default_input; netif_output_fn default_output; @@ -1135,6 +1122,13 @@ void setup_modem() ESP_LOGI(TAG, "wifi_init..."); wifi_init(); + radio_entropy_init(); + // The first read of the voltages, so that a later one that cannot get the ADC has + // values to give + uint16_t seed_voltages[7]; + if (read_adc_channels(seed_voltages) != ESP_OK) { + ESP_LOGW(TAG, "No first read of the voltages"); + } ESP_LOGI(TAG, "start wifi connector..."); start_connector(); diff --git a/software/u64ctrl/main/wifi_modem.h b/software/u64ctrl/main/wifi_modem.h index 280f973fe..5615aabcf 100644 --- a/software/u64ctrl/main/wifi_modem.h +++ b/software/u64ctrl/main/wifi_modem.h @@ -2,6 +2,7 @@ #define WIFI_MODEM_H #include "rpc_calls.h" +#include "radio_entropy.h" extern QueueHandle_t connect_commands; extern SemaphoreHandle_t connect_semaphore; @@ -29,10 +30,9 @@ void enable_hook(); void disable_hook(); void wake_on_wifi_update(int machine_on); uint8_t wifi_get_connection(); -entropy_source_t entropy_source(void); -uint32_t entropy_epoch(void); void wifi_send_connected_event(); +esp_err_t read_adc_channels(uint16_t *adc_data); void show_buffer_status(); #endif diff --git a/software/wifi/common/radio_entropy.c b/software/wifi/common/radio_entropy.c new file mode 100644 index 000000000..834e202c1 --- /dev/null +++ b/software/wifi/common/radio_entropy.c @@ -0,0 +1,392 @@ +/* + * radio_entropy.c + * + * See radio_entropy.h. Free of ESP-IDF and FreeRTOS, so that the host test tests what + * ships: everything the chip and the RTOS do goes through radio_entropy_port.h. + */ + +#include +#include "radio_entropy.h" +#include "radio_entropy_port.h" +#include "wifi_radio.h" + +#define MAX_READERS 8 + +// The gate. All of it is changed under re_port_lock() only, and a waiter polls, so that no +// state needs a wake up, and a waiter that gives up leaves nothing behind. +static struct { + int readers; + bool writer_active; + int writers_pending; + uintptr_t writer_task; + uintptr_t reader_task[MAX_READERS]; // 0 for a free slot +} gate; + +// Changed under the exclusive hold, read by anyone +static volatile entropy_source_t source = ENTROPY_NONE; + +// Changed under the exclusive hold only +static bool hw_enabled; // bootloader_random_enable() was called, and no disable since +static bool adc_off; // radio_entropy_adc_begin() switched the source off +static uint32_t adc_begin_ms; +static bool retry_pending; +static int retries_left; + +static radio_entropy_stats_t stats; + +// A line for the log, set under the exclusive hold and written after it is released: a +// holder does not touch the UART +static const char *pending_log; + +entropy_source_t entropy_source(void) +{ + return source; +} + +uint32_t entropy_epoch(void) +{ + return radio_epoch(); +} + +static bool expired(uint32_t deadline) +{ + return (int32_t)(re_port_now_ms() - deadline) >= 0; +} + +// Under re_port_lock() +static bool holds(uintptr_t me) +{ + if (gate.writer_active && (gate.writer_task == me)) { + return true; + } + for (int i = 0; i < MAX_READERS; i++) { + if (gate.reader_task[i] == me) { + return true; + } + } + return false; +} + +int radio_entropy_acquire_shared(uint32_t timeout_ms) +{ + uintptr_t me = re_port_task(); + uint32_t deadline = re_port_now_ms() + timeout_ms; + for (;;) { + re_port_lock(); + if (holds(me)) { + stats.recursion++; + re_port_unlock(); + return RE_ERR_RECURSION; + } + // A pending writer keeps new readers out, so that back to back readers + // cannot starve a radio change + if (!gate.writer_active && (gate.writers_pending == 0)) { + for (int i = 0; i < MAX_READERS; i++) { + if (gate.reader_task[i] == 0) { + gate.reader_task[i] = me; + gate.readers++; + re_port_unlock(); + return RE_OK; + } + } + } + re_port_unlock(); + if (expired(deadline)) { + re_port_lock(); + stats.busy++; + re_port_unlock(); + return RE_ERR_BUSY; + } + re_port_delay_ms(1); + } +} + +void radio_entropy_release_shared(void) +{ + uintptr_t me = re_port_task(); + re_port_lock(); + for (int i = 0; i < MAX_READERS; i++) { + if (gate.reader_task[i] == me) { + gate.reader_task[i] = 0; + gate.readers--; + break; + } + } + re_port_unlock(); +} + +static int acquire_exclusive(uint32_t timeout_ms) +{ + uintptr_t me = re_port_task(); + uint32_t deadline = re_port_now_ms() + timeout_ms; + + re_port_lock(); + if (holds(me)) { + stats.recursion++; + re_port_unlock(); + return RE_ERR_RECURSION; + } + gate.writers_pending++; + re_port_unlock(); + + for (;;) { + re_port_lock(); + if (!gate.writer_active && (gate.readers == 0)) { + gate.writer_active = true; + gate.writer_task = me; + gate.writers_pending--; + re_port_unlock(); + return RE_OK; + } + re_port_unlock(); + if (expired(deadline)) { + re_port_lock(); + gate.writers_pending--; + stats.busy++; + re_port_unlock(); + return RE_ERR_BUSY; + } + re_port_delay_ms(1); + } +} + +static void release_exclusive(void) +{ + re_port_lock(); + gate.writer_active = false; + gate.writer_task = 0; + const char *line = pending_log; + pending_log = NULL; + re_port_unlock(); + if (line) { + re_port_log("%s", line); + } +} + +bool radio_entropy_held_exclusive(void) +{ + re_port_lock(); + bool mine = gate.writer_active && (gate.writer_task == re_port_task()); + re_port_unlock(); + return mine; +} + +//---------------------------------- +// The source. Everything below runs under the exclusive hold. + +// Switches the ADC source off if it is on +static void disable_source(void) +{ + if (hw_enabled) { + re_port_random_disable(); + hw_enabled = false; + } +} + +// Only a source that reads back correctly is ENTROPY_ADC. The first attempt of a transition +// starts the retry budget; nothing else gives it back. +static void enable_source(bool first) +{ + if (first) { + retries_left = RE_RETRIES; + } + re_port_random_enable(); + hw_enabled = true; + if (re_port_random_readback()) { + source = ENTROPY_ADC; + retry_pending = false; + } else { + source = ENTROPY_NONE; + stats.readback_failures++; + retry_pending = true; + // Once the retries are spent there is nothing more to say + if (first || (retries_left > 0)) { + pending_log = "radio_entropy: ADC source readback mismatch"; + } + } +} + +void radio_entropy_init(void) +{ + if (acquire_exclusive(RE_WAIT_TRANSITION_MS) != RE_OK) { + return; + } + if (!radio_is_on() && !hw_enabled) { + enable_source(true); + } + release_exclusive(); +} + +int radio_entropy_change_begin(void) +{ + return acquire_exclusive(RE_WAIT_TRANSITION_MS); +} + +void radio_entropy_changing(bool starting) +{ + source = ENTROPY_NONE; + if (starting) { + // The radio and the ADC source do not run together + disable_source(); + } +} + +void radio_entropy_changed(bool radio_on) +{ + if (radio_on) { + source = ENTROPY_RADIO; + } else { + enable_source(true); + } +} + +void radio_entropy_change_end(void) +{ + release_exclusive(); +} + +int radio_entropy_adc_begin(uint32_t timeout_ms) +{ + int rc = acquire_exclusive(timeout_ms); + if (rc != RE_OK) { + return rc; + } + adc_begin_ms = re_port_now_ms(); + // With the radio running the RNG does not depend on the ADC, and the ADC is free as it is + adc_off = hw_enabled; + if (adc_off) { + source = ENTROPY_NONE; + disable_source(); + } + // Also with the radio on: an enable since the unit was created leaves the clock off + re_port_adc_ready(); + return RE_OK; +} + +void radio_entropy_adc_end(void) +{ + if (!radio_entropy_held_exclusive()) { + re_port_log("radio_entropy: adc_end without adc_begin"); + return; + } + if (adc_off) { + adc_off = false; + // The retries of a transition are spent once, by whoever needs them: a source that + // went bad does not get a new budget from a voltage read + bool failing = retry_pending; + if (!failing || (retries_left > 0)) { + if (failing) { + retries_left--; + stats.retries++; + } + enable_source(false); + } + } + uint32_t held = re_port_now_ms() - adc_begin_ms; + if (held > stats.adc_hold_max_ms) { + stats.adc_hold_max_ms = held; + } + release_exclusive(); +} + +void radio_entropy_poll(void) +{ + // A look without the gate; the decision is made again under it + if (!retry_pending || (retries_left <= 0) || radio_is_on()) { + return; + } + if (acquire_exclusive(RE_WAIT_RETRY_MS) != RE_OK) { + return; + } + if (retry_pending && (retries_left > 0) && !radio_is_on()) { + retries_left--; + stats.retries++; + source = ENTROPY_NONE; + disable_source(); + enable_source(false); + } + release_exclusive(); +} + +void radio_entropy_get_stats(radio_entropy_stats_t *out) +{ + re_port_lock(); + *out = stats; + re_port_unlock(); +} + +//---------------------------------- +// The answer to GET_RANDOM, and the voltage read. Here so that the host test runs them. + +int radio_entropy_serve_get_random(void *data, int size, void (*fill)(void *, size_t)) +{ + rpc_get_random_req *req = (rpc_get_random_req *)data; + rpc_get_random_resp *resp = (rpc_get_random_resp *)data; + + // The response overlays the request, so take what we need from it first + uint16_t length = (size >= (int)sizeof(rpc_get_random_req)) ? req->length : 0; + + // Clear the fixed part, padding included, so no stale buffer bytes go out + memset(&resp->esp_err, 0, sizeof(rpc_get_random_resp) - sizeof(rpc_header_t)); + if ((length == 0) || (length > RANDOM_MAX_BYTES)) { + resp->esp_err = RE_ESP_ERR_INVALID_ARG; + } else if (radio_entropy_acquire_shared(RE_WAIT_RANDOM_MS) != RE_OK) { + // A radio change or a read of the voltages holds the source. Nothing is drawn. + resp->esp_err = RPC_ERR_ENTROPY_BUSY; + } else { + uint32_t epoch = entropy_epoch(); + entropy_source_t src = entropy_source(); + resp->source = src; + if (src == ENTROPY_NONE) { + resp->esp_err = RE_ESP_ERR_INVALID_STATE; + } else { + fill(resp->data, length); + // The gate keeps the radio from changing while it is held; this is a second guard + if ((entropy_source() == ENTROPY_NONE) || (entropy_epoch() != epoch)) { + resp->source = ENTROPY_NONE; + resp->esp_err = RE_ESP_ERR_INVALID_STATE; + } else { + resp->esp_err = 0; + resp->length = length; + } + } + radio_entropy_release_shared(); + } + return sizeof(rpc_get_random_resp) + resp->length; +} + +int radio_entropy_read_adc(uint16_t *out, uint16_t *cache, bool *valid, int n, + int (*read_unit)(uint16_t *)) +{ + uint16_t fresh[16]; + if (n > 16) { + return RE_ESP_ERR_INVALID_ARG; + } + re_port_lock(); + bool have = *valid; + re_port_unlock(); + + if (radio_entropy_adc_begin(have ? RE_WAIT_ADC_MS : RE_WAIT_TRANSITION_MS) != RE_OK) { + if (!have) { + return RE_ERR_BUSY; + } + re_port_lock(); + memcpy(out, cache, n * sizeof(uint16_t)); + re_port_unlock(); + return 0; + } + int rc = read_unit(fresh); + radio_entropy_adc_end(); + + re_port_lock(); + if (rc == 0) { + memcpy(cache, fresh, n * sizeof(uint16_t)); + *valid = true; + } + have = *valid; + if (have) { + memcpy(out, cache, n * sizeof(uint16_t)); + } + re_port_unlock(); + return rc; +} diff --git a/software/wifi/common/radio_entropy.h b/software/wifi/common/radio_entropy.h new file mode 100644 index 000000000..3bbcf07c9 --- /dev/null +++ b/software/wifi/common/radio_entropy.h @@ -0,0 +1,115 @@ +/* + * radio_entropy.h + * + * What feeds the hardware RNG of the WiFi modules, with the radio on or off. + * + * esp_fill_random() gives true random numbers only while Wi-Fi runs or while the + * bootloader_random SAR ADC source is on (esp_random.h). The bootloader switches that + * source off before the application starts. So with the radio off, this enables it again + * and reads the hardware back, and only a source that read back correctly is reported as + * ENTROPY_ADC. + * + * A writer-preferring reader/writer gate keeps those transitions away from the draws: + * - shared holders: a GET_RANDOM draw; + * - exclusive holders: a radio start or stop (wifi_radio.c), a read of the voltages that + * needs the SAR ADC, and a retry of a failed readback. + * Rules for every holder: no re-acquire (it is refused, never waited for), no UART, queue + * or event-loop wait while holding, and event handlers never take the gate. + * + * Built into both ESP modules (software/wifi/raw_u64 and software/u64ctrl). The logic is + * in radio_entropy.c, the chip side in radio_entropy_esp.c, and the host test + * (target/pc/linux/radioentropy) replaces the latter. + */ + +#ifndef SOFTWARE_WIFI_COMMON_RADIO_ENTROPY_H_ +#define SOFTWARE_WIFI_COMMON_RADIO_ENTROPY_H_ + +#include +#include +#include +#include "rpc_calls.h" + +// Results; the values are those of the esp_err_t they are passed on as (asserted in +// radio_entropy_esp.c) +#define RE_OK 0 +#define RE_ERR_BUSY 0x107 // ESP_ERR_TIMEOUT: the gate was not free in time +#define RE_ERR_RECURSION 0x103 // ESP_ERR_INVALID_STATE: the caller holds the gate already + +// esp_err_t values the GET_RANDOM answer uses (asserted in radio_entropy_esp.c) +#define RE_ESP_ERR_INVALID_ARG 0x102 +#define RE_ESP_ERR_INVALID_STATE 0x103 + +// How long a caller waits for the gate +#define RE_WAIT_RANDOM_MS 20 // a GET_RANDOM draw +#define RE_WAIT_TRANSITION_MS 5000 // a radio start or stop +#define RE_WAIT_ADC_MS 50 // the voltage read, which gives up and uses its cache +#define RE_WAIT_RETRY_MS 50 + +// Readback attempts after the first one failed, per transition +#define RE_RETRIES 3 + +// The source now feeding the RNG, and a count of the radio's stops so far +entropy_source_t entropy_source(void); +uint32_t entropy_epoch(void); + +// Once, after the boot's radio start and before the first RPC is served. A boot that did +// not start the radio enables the ADC source here. +void radio_entropy_init(void); + +// Around every radio start and stop, by wifi_radio.c only. begin takes the gate +// exclusively: RE_OK, RE_ERR_BUSY or RE_ERR_RECURSION. changing() is called when the +// radio is about to change: the source goes off for the change. changed() gives the state +// the radio is in afterwards: ENTROPY_RADIO when on, else the ADC source, read back. end +// releases the gate. +int radio_entropy_change_begin(void); +void radio_entropy_changing(bool starting); +void radio_entropy_changed(bool radio_on); +void radio_entropy_change_end(void); + +// Shared hold of the gate. Returns RE_OK, RE_ERR_BUSY after timeout_ms, or +// RE_ERR_RECURSION. Every RE_OK is matched by one release by the same task. +int radio_entropy_acquire_shared(uint32_t timeout_ms); +void radio_entropy_release_shared(void); + +// Exclusive hold around a use of the SAR ADC1 by someone else (the voltage read). Takes +// the gate, and switches the ADC source off if it is on. The end enables the source again +// and reads it back. RE_OK or RE_ERR_BUSY. +int radio_entropy_adc_begin(uint32_t timeout_ms); +void radio_entropy_adc_end(void); + +// True while the calling task holds the gate exclusively +bool radio_entropy_held_exclusive(void); + +// The whole of a GET_RANDOM answer, up to its transmission: data is the request on the way +// in (size bytes) and the answer on the way out, whose size is returned. fill is +// esp_fill_random(). The gate is held shared for the draw only and is free when this +// returns, so the caller transmits with it released. +int radio_entropy_serve_get_random(void *data, int size, void (*fill)(void *, size_t)); + +// Reads n voltages with the SAR ADC lent out for the read (radio_entropy_adc_begin), through +// read_unit, which returns 0 or an error. cache holds the last good values, and *valid says +// it does. When the ADC is not free in time the cache is given, never zeros; while there is +// no cache yet, the wait is as long as a radio change's. Returns 0, or an error when there +// is nothing to give: out is then left alone. +int radio_entropy_read_adc(uint16_t *out, uint16_t *cache, bool *valid, int n, + int (*read_unit)(uint16_t *)); + +// Retries a failed readback, at most RE_RETRIES times per transition. Call it about every +// 10 s from a task that may wait. +void radio_entropy_poll(void); + +// The chip side, radio_entropy_esp.c only: a task for radio_entropy_poll(), for a module +// that has no loop of its own +void radio_entropy_start_poll_task(void); + +typedef struct { + uint32_t readback_failures; // enables whose readback did not match + uint32_t retries; // attempts made by radio_entropy_poll() + uint32_t recursion; // acquires refused + uint32_t busy; // acquires that timed out + uint32_t adc_hold_max_ms; // longest radio_entropy_adc_begin() to _end() +} radio_entropy_stats_t; + +void radio_entropy_get_stats(radio_entropy_stats_t *stats); + +#endif /* SOFTWARE_WIFI_COMMON_RADIO_ENTROPY_H_ */ diff --git a/software/wifi/common/radio_entropy_esp.c b/software/wifi/common/radio_entropy_esp.c new file mode 100644 index 000000000..e25f86b4c --- /dev/null +++ b/software/wifi/common/radio_entropy_esp.c @@ -0,0 +1,151 @@ +/* + * radio_entropy_esp.c + * + * The chip side of radio_entropy.c, for the ESP32 (software/wifi/raw_u64) and the + * ESP32-S3 (software/u64ctrl). + */ + +#include +#include +#include "sdkconfig.h" +#include "esp_err.h" +#include "esp_idf_version.h" +#include "esp_log.h" +#include "esp_timer.h" +#include "bootloader_random.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/timers.h" +#include "soc/soc.h" +#include "esp_private/periph_ctrl.h" +#if CONFIG_IDF_TARGET_ESP32S3 +#include "soc/apb_saradc_reg.h" +#include "soc/system_reg.h" +#include "soc/sens_reg.h" +#elif CONFIG_IDF_TARGET_ESP32 +#include "soc/dport_access.h" +#include "soc/dport_reg.h" +#include "soc/i2s_reg.h" +#include "soc/sens_reg.h" +#else +#error "radio_entropy: no readback for this chip" +#endif +#include "radio_entropy.h" +#include "radio_entropy_port.h" + +_Static_assert(RE_ERR_BUSY == ESP_ERR_TIMEOUT, "RE_ERR_BUSY is an esp_err_t"); +_Static_assert(RE_ERR_RECURSION == ESP_ERR_INVALID_STATE, "RE_ERR_RECURSION is an esp_err_t"); +_Static_assert(RE_ESP_ERR_INVALID_ARG == ESP_ERR_INVALID_ARG, "an esp_err_t"); +_Static_assert(RE_ESP_ERR_INVALID_STATE == ESP_ERR_INVALID_STATE, "an esp_err_t"); + +// On ESP-IDF 5 the S3's bootloader_random_disable() leaves the SAR ADC's digital block in +// reset, so that every later enable fails its readback (measured on the S3 with 5.3.1), +// and it writes the SAR power force behind the reference count that the PHY and the ADC +// driver share. ESP-IDF 6 does neither, and the module is built with it. +#if CONFIG_IDF_TARGET_ESP32S3 && (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)) +#error "radio_entropy: the ESP32-S3 needs ESP-IDF 6 for the SAR ADC source" +#endif + +static const char *TAG = "radio_entropy"; + +static portMUX_TYPE lock_mux = portMUX_INITIALIZER_UNLOCKED; + +void re_port_lock(void) +{ + portENTER_CRITICAL(&lock_mux); +} + +void re_port_unlock(void) +{ + portEXIT_CRITICAL(&lock_mux); +} + +uint32_t re_port_now_ms(void) +{ + return (uint32_t)(esp_timer_get_time() / 1000); +} + +void re_port_delay_ms(uint32_t ms) +{ + TickType_t ticks = pdMS_TO_TICKS(ms); + vTaskDelay(ticks ? ticks : 1); +} + +uintptr_t re_port_task(void) +{ + return (uintptr_t)xTaskGetCurrentTaskHandle(); +} + +void re_port_random_enable(void) +{ + bootloader_random_enable(); +} + +void re_port_random_disable(void) +{ + bootloader_random_disable(); +} + +void re_port_adc_ready(void) +{ +#if CONFIG_IDF_TARGET_ESP32S3 + // The same register and lock as the ADC driver's own claim (adc_apb_periph_claim()) + PERIPH_RCC_ATOMIC() { + SET_PERI_REG_MASK(SYSTEM_PERIP_CLK_EN0_REG, SYSTEM_APB_SARADC_CLK_EN); + } +#endif +} + +// The registers that bootloader_random_enable() sets, on both ESP-IDF versions +bool re_port_random_readback(void) +{ +#if CONFIG_IDF_TARGET_ESP32S3 + return ((REG_READ(APB_SARADC_CTRL2_REG) & APB_SARADC_TIMER_EN) != 0) && + ((REG_READ(SENS_SAR_MEAS1_MUX_REG) & SENS_SAR1_DIG_FORCE) != 0); +#else + return ((REG_READ(SENS_SAR_START_FORCE_REG) & SENS_SAR2_EN_TEST) != 0) && + ((REG_READ(I2S_CONF_REG(0)) & I2S_RX_START) != 0) && + ((DPORT_REG_READ(DPORT_PERIP_CLK_EN_REG) & DPORT_I2S0_CLK_EN) != 0); +#endif +} + +void re_port_log(const char *fmt, ...) +{ + char line[96]; + va_list args; + va_start(args, fmt); + vsnprintf(line, sizeof(line), fmt, args); + va_end(args); + ESP_LOGW(TAG, "%s", line); +} + +//---------------------------------- +// radio_entropy_poll() every 10 s, for the module that has no loop of its own. The timer +// only notifies; the task takes the gate. + +static TaskHandle_t poll_task; + +static void poll_timer(TimerHandle_t timer) +{ + xTaskNotifyGive(poll_task); +} + +static void poll_loop(void *arg) +{ + for (;;) { + ulTaskNotifyTake(pdTRUE, portMAX_DELAY); + radio_entropy_poll(); + } +} + +void radio_entropy_start_poll_task(void) +{ + if (xTaskCreate(poll_loop, "re_poll", 3072, NULL, 1, &poll_task) != pdPASS) { + ESP_LOGE(TAG, "no poll task"); + return; + } + TimerHandle_t timer = xTimerCreate("re_poll", pdMS_TO_TICKS(10000), pdTRUE, NULL, poll_timer); + if (!timer || (xTimerStart(timer, 0) != pdPASS)) { + ESP_LOGE(TAG, "no poll timer"); + } +} diff --git a/software/wifi/common/radio_entropy_port.h b/software/wifi/common/radio_entropy_port.h new file mode 100644 index 000000000..48cd63fe9 --- /dev/null +++ b/software/wifi/common/radio_entropy_port.h @@ -0,0 +1,34 @@ +/* + * radio_entropy_port.h + * + * What radio_entropy.c needs from the chip and the RTOS. radio_entropy_esp.c implements + * it for the modules; the host test implements it with recording stubs. + */ + +#ifndef SOFTWARE_WIFI_COMMON_RADIO_ENTROPY_PORT_H_ +#define SOFTWARE_WIFI_COMMON_RADIO_ENTROPY_PORT_H_ + +#include +#include + +// A short critical section, never blocking, never held across any other call +void re_port_lock(void); +void re_port_unlock(void); + +uint32_t re_port_now_ms(void); +void re_port_delay_ms(uint32_t ms); // at least one RTOS tick +uintptr_t re_port_task(void); // never 0 + +void re_port_random_enable(void); // bootloader_random_enable() +void re_port_random_disable(void); // bootloader_random_disable() +bool re_port_random_readback(void); // the registers it sets are set + +// Before every use of the SAR ADC1 by the voltage read. ESP32-S3: bootloader_random_enable() +// pulses the SAR ADC's reset and leaves its bus clock off, behind the reference count of the +// oneshot ADC driver, which set the clock on when it created its unit and does not set it +// again; this sets it on again. Nothing on the classic ESP32. +void re_port_adc_ready(void); + +void re_port_log(const char *fmt, ...) __attribute__((format(printf, 1, 2))); + +#endif /* SOFTWARE_WIFI_COMMON_RADIO_ENTROPY_PORT_H_ */ diff --git a/software/wifi/common/rpc_shared.h b/software/wifi/common/rpc_shared.h index 68224b6ae..045ca6d67 100644 --- a/software/wifi/common/rpc_shared.h +++ b/software/wifi/common/rpc_shared.h @@ -32,8 +32,14 @@ typedef enum { ENTROPY_NONE = 0, // RNG not fed by a live entropy source; no bytes are returned ENTROPY_RADIO = 1, // Wi-Fi is running, so the RNG gives true random numbers + ENTROPY_ADC = 2, // Wi-Fi is off, and the bootloader_random SAR ADC source feeds the RNG } entropy_source_t; +// esp_err of a GET_RANDOM answer that was not given because a radio change, or a read of +// the voltages, holds the entropy source. Nothing was drawn; asking again is safe. Equal +// to ESP_ERR_TIMEOUT, which each module asserts. +#define RPC_ERR_ENTROPY_BUSY 0x107 + typedef struct { rpc_header_t hdr; uint16_t length; diff --git a/software/wifi/common/wifi_radio.c b/software/wifi/common/wifi_radio.c index 8fa936853..004d4f4ce 100644 --- a/software/wifi/common/wifi_radio.c +++ b/software/wifi/common/wifi_radio.c @@ -6,6 +6,7 @@ #include "wifi_radio.h" #include "wifi_radio_port.h" +#include "radio_entropy.h" // Written by the task that starts and stops the radio, read by any static volatile bool radio_on = false; @@ -21,29 +22,43 @@ uint32_t radio_epoch(void) return epoch; } +// Every change runs under the exclusive hold of the entropy gate, which also switches the +// RNG's source between the radio and the SAR ADC (radio_entropy.h) int radio_start(void) { - if (radio_on) { - return 0; + int rc = radio_entropy_change_begin(); + if (rc != 0) { + return rc; } - int rc = wr_port_wifi_start(); - if (rc == 0) { - radio_on = true; + if (!radio_on) { + radio_entropy_changing(true); + rc = wr_port_wifi_start(); + if (rc == 0) { + radio_on = true; + } + radio_entropy_changed(radio_on); } + radio_entropy_change_end(); return rc; } int radio_stop(void) { - if (!radio_on) { - return 0; - } - // A GET_RANDOM draw that overlaps the stop must not count as drawn with the radio on - epoch++; - radio_on = false; - int rc = wr_port_wifi_stop(); + int rc = radio_entropy_change_begin(); if (rc != 0) { - radio_on = true; + return rc; + } + if (radio_on) { + // A GET_RANDOM draw that overlaps the stop must not count as drawn with the radio on + epoch++; + radio_on = false; + radio_entropy_changing(false); + rc = wr_port_wifi_stop(); + if (rc != 0) { + radio_on = true; + } + radio_entropy_changed(radio_on); } + radio_entropy_change_end(); return rc; } diff --git a/software/wifi/common/wifi_radio.h b/software/wifi/common/wifi_radio.h index d57d33fc4..b81575d65 100644 --- a/software/wifi/common/wifi_radio.h +++ b/software/wifi/common/wifi_radio.h @@ -19,7 +19,8 @@ // Both are idempotent: asking for the state the radio is in already does nothing and // returns 0. Otherwise they return 0 or the esp_err_t of the start or stop, and a failed // call leaves the state as it was. Called by one task at a time (the boot, then the -// connector). +// connector). They also return the radio_entropy.h gate's RE_ERR_BUSY or +// RE_ERR_RECURSION, and change nothing then. int radio_start(void); int radio_stop(void); diff --git a/software/wifi/raw_u64/main/CMakeLists.txt b/software/wifi/raw_u64/main/CMakeLists.txt index fdfd7fe88..abf3f7079 100644 --- a/software/wifi/raw_u64/main/CMakeLists.txt +++ b/software/wifi/raw_u64/main/CMakeLists.txt @@ -1,5 +1,5 @@ set(EXTERNAL "../../../io/uart") set(COMMON "../../common") -idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_boot.c +idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_boot.c ${COMMON}/radio_entropy.c ${COMMON}/radio_entropy_esp.c INCLUDE_DIRS "." ${EXTERNAL} ${COMMON} LDFRAGMENTS "linker.lf") diff --git a/software/wifi/raw_u64/main/rpc_dispatch.c b/software/wifi/raw_u64/main/rpc_dispatch.c index 4bbf57863..30f7ab5d2 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.c +++ b/software/wifi/raw_u64/main/rpc_dispatch.c @@ -251,36 +251,12 @@ void cmd_clear_aps(command_buf_t *buf) my_uart_transmit_packet(UART_CHAN, buf); } +_Static_assert(RPC_ERR_ENTROPY_BUSY == ESP_ERR_TIMEOUT, "RPC_ERR_ENTROPY_BUSY is an esp_err_t"); + void cmd_get_random(command_buf_t *buf) { - rpc_get_random_req *req = (rpc_get_random_req *)buf->data; - rpc_get_random_resp *resp = (rpc_get_random_resp *)buf->data; - - // The response overlays the request, so take what we need from it first - uint16_t length = (buf->size >= (int)sizeof(rpc_get_random_req)) ? req->length : 0; - uint32_t epoch = entropy_epoch(); - entropy_source_t source = entropy_source(); - - // Clear the fixed part, padding included, so no stale buffer bytes go out - memset(&resp->esp_err, 0, sizeof(rpc_get_random_resp) - sizeof(rpc_header_t)); - resp->source = source; - if ((length == 0) || (length > RANDOM_MAX_BYTES)) { - resp->esp_err = ESP_ERR_INVALID_ARG; - } else if (source == ENTROPY_NONE) { - resp->esp_err = ESP_ERR_INVALID_STATE; - } else { - esp_fill_random(resp->data, length); - // This module stops the radio on request: bytes drawn while it stopped, even if - // it has started again, are not sent - if ((entropy_source() == ENTROPY_NONE) || (entropy_epoch() != epoch)) { - resp->source = ENTROPY_NONE; - resp->esp_err = ESP_ERR_INVALID_STATE; - } else { - resp->esp_err = ESP_OK; - resp->length = length; - } - } - buf->size = sizeof(rpc_get_random_resp) + resp->length; + buf->size = radio_entropy_serve_get_random(buf->data, buf->size, (void (*)(void *, size_t))esp_fill_random); + // The gate is released: the answer is sent without it my_uart_transmit_packet(UART_CHAN, buf); } diff --git a/software/wifi/raw_u64/main/rpc_dispatch.h b/software/wifi/raw_u64/main/rpc_dispatch.h index 56ce26361..d4a00f720 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.h +++ b/software/wifi/raw_u64/main/rpc_dispatch.h @@ -28,7 +28,7 @@ void send_keepalive(); #define IDENT_STRING "ESP32 WiFi Bridge V1.10" #define IDENT_MAJOR 1 -// 1.10: CMD_GET_RANDOM. +// 1.10: CMD_GET_RANDOM, served with the radio off too, from the SAR ADC source. // 1.9: turns its radio off and on when asked (CMD_WIFI_DISABLE / CMD_WIFI_ENABLE) and // starts with it off until the Ultimate sends Enable or Autoconnect (or, without the // switch, asks for the connection state); after a restart of its own it puts the radio diff --git a/software/wifi/raw_u64/main/wifi_modem.c b/software/wifi/raw_u64/main/wifi_modem.c index bb141d750..40b31eb00 100644 --- a/software/wifi/raw_u64/main/wifi_modem.c +++ b/software/wifi/raw_u64/main/wifi_modem.c @@ -72,19 +72,6 @@ void wifi_note_user_disconnect(void) user_disconnected = true; } -/* What feeds the RNG: esp_fill_random() is only truly random while the radio runs - * (esp_random.h). The radio counts as off from the moment a stop begins, and the epoch - * counts the stops, so that a stop and a start within one draw are noticed. */ -entropy_source_t entropy_source(void) -{ - return radio_is_on() ? ENTROPY_RADIO : ENTROPY_NONE; -} - -uint32_t entropy_epoch(void) -{ - return radio_epoch(); -} - // Allocate some buffers to work with command_buf_context_t work_buffers; @@ -1108,6 +1095,8 @@ void setup_modem() ESP_LOGI(TAG, "wifi_init..."); wifi_init(); + radio_entropy_init(); + radio_entropy_start_poll_task(); ESP_LOGI(TAG, "start wifi connector..."); // A restart that neither a power-up nor the Ultimate caused (the Ultimate drives the // module's enable pin, which reads as a power-up or an external reset) diff --git a/software/wifi/raw_u64/main/wifi_modem.h b/software/wifi/raw_u64/main/wifi_modem.h index 382543f4f..13d50ba1d 100644 --- a/software/wifi/raw_u64/main/wifi_modem.h +++ b/software/wifi/raw_u64/main/wifi_modem.h @@ -2,6 +2,7 @@ #define WIFI_MODEM_H #include "rpc_calls.h" +#include "radio_entropy.h" extern QueueHandle_t connect_commands; extern SemaphoreHandle_t connect_semaphore; @@ -30,7 +31,5 @@ void disable_hook(); uint8_t wifi_get_connection(); void wifi_report_disabled(void); void wifi_note_identify(void); -entropy_source_t entropy_source(void); -uint32_t entropy_epoch(void); #endif diff --git a/software/wifi/tests/Makefile b/software/wifi/tests/Makefile index 15e66a065..f9f476f7e 100644 --- a/software/wifi/tests/Makefile +++ b/software/wifi/tests/Makefile @@ -37,6 +37,8 @@ INC_u64ctrl := -I$(PATH_SW)/wifi/common HOSTTEST := $(PATH_SW)/io/usb/tests CASES := $(wildcard module_*_test.cpp) RADIO := $(wildcard radio_*test.cpp) +# radio_entropy.h includes rpc_calls.h of raw_u64, which needs lwIP's headers; the wifi_random test stubs them out +RADIO_INC := -I$(PATH_SW)/wifi/common -I$(PATH_SW)/wifi/raw_u64/main -I$(PATH_SW)/test/wifi_random COMMON := -g -O0 -Wall -Wno-unused-parameter -D_FORTIFY_SOURCE=0 CFLAGS := -std=gnu11 $(COMMON) -Wno-unused-variable -Wno-unused-function CXXFLAGS := -std=c++14 $(COMMON) -I$(HOSTTEST) -I. -Istub @@ -154,9 +156,9 @@ run: radio: @mkdir -p $(OUT)/radio - $(CC) -std=c99 $(COMMON) -I$(PATH_SW)/wifi/common -c -o $(OUT)/radio/wifi_radio.o $(PATH_SW)/wifi/common/wifi_radio.c + $(CC) -std=c99 $(COMMON) $(RADIO_INC) -c -o $(OUT)/radio/wifi_radio.o $(PATH_SW)/wifi/common/wifi_radio.c $(CC) -std=c99 $(COMMON) -I$(PATH_SW)/wifi/common -c -o $(OUT)/radio/radio_boot.o $(PATH_SW)/wifi/common/radio_boot.c - $(CXX) $(CXXFLAGS) -I$(PATH_SW)/wifi/common -o $(OUT)/radio/wifi_radio_test $(RADIO) $(HOSTTEST)/host_test_main.cpp \ + $(CXX) $(CXXFLAGS) $(RADIO_INC) -o $(OUT)/radio/wifi_radio_test $(RADIO) $(HOSTTEST)/host_test_main.cpp \ $(OUT)/radio/wifi_radio.o $(OUT)/radio/radio_boot.o -lpthread @echo "== radio"; $(OUT)/radio/wifi_radio_test diff --git a/software/wifi/tests/radio_test.cpp b/software/wifi/tests/radio_test.cpp index c3c1b4d90..2444de0bb 100644 --- a/software/wifi/tests/radio_test.cpp +++ b/software/wifi/tests/radio_test.cpp @@ -3,7 +3,8 @@ * * wifi_radio.c (the one place that starts and stops the radio of the U64 and U2+L modules) * against a chip stub that counts the Wi-Fi starts and stops and can be told to fail them, - * and radio_boot.c (the radio's state across a restart of the module). + * and radio_boot.c (the radio's state across a restart of the module), and a stub of the entropy gate + * (radio_entropy.c has its own test, target/pc/linux/radioentropy). */ #include @@ -12,6 +13,7 @@ extern "C" { #include "wifi_radio.h" #include "wifi_radio_port.h" #include "radio_boot.h" +#include "radio_entropy.h" } #define CHECK(cond, what) EXPECT_TRUE((cond) && (what)) @@ -22,10 +24,16 @@ static int starts, stops; static int start_result, stop_result; static int chip_on; // what the chip does, as opposed to what wifi_radio.c believes static int on_during_stop; // radio_is_on() while the chip was stopping +static int gate_result; // what radio_entropy_change_begin() answers +static int gate_held; // begun and not ended +static int changes; // radio_entropy_changing() calls +static int chip_in_gate; // chip calls made with the gate held + extern "C" int wr_port_wifi_start(void) { starts++; + chip_in_gate += (gate_held == 1); if (start_result == 0) { chip_on = 1; } @@ -35,6 +43,7 @@ extern "C" int wr_port_wifi_start(void) extern "C" int wr_port_wifi_stop(void) { stops++; + chip_in_gate += (gate_held == 1); on_during_stop = radio_is_on(); if (stop_result == 0) { chip_on = 0; @@ -42,12 +51,37 @@ extern "C" int wr_port_wifi_stop(void) return stop_result; } +extern "C" int radio_entropy_change_begin(void) +{ + if (gate_result == 0) { + gate_held++; + } + return gate_result; +} + +extern "C" void radio_entropy_changing(bool starting) +{ + (void)starting; + changes++; +} + +extern "C" void radio_entropy_changed(bool radio_on) +{ + (void)radio_on; +} + +extern "C" void radio_entropy_change_end(void) +{ + gate_held--; +} + // Each case starts with the radio off and the stub counting from zero static void reset(void) { start_result = stop_result = 0; + gate_result = 0; radio_stop(); - starts = stops = 0; + starts = stops = changes = chip_in_gate = 0; chip_on = 0; } @@ -163,3 +197,22 @@ TEST(Radio, a_stop_moves_the_epoch_first) radio_stop(); CHECK(radio_epoch() == e + 4, "a stop while off does not"); } + +// A gate that is not free in time changes nothing; every chip call is made inside it +TEST(Radio, busy_gate_changes_nothing) +{ + reset(); + gate_result = 0x107; + CHECK(radio_start() == 0x107, "the gate's error is passed on"); + CHECK(!radio_is_on() && (starts == 0) && (changes == 0), "nothing touched"); + gate_result = 0; + radio_start(); + gate_result = 0x107; + uint32_t e = radio_epoch(); + CHECK(radio_stop() == 0x107, "on a stop too"); + CHECK(radio_is_on() && (stops == 0) && (radio_epoch() == e), "still on, epoch kept"); + gate_result = 0; + radio_stop(); + CHECK((chip_in_gate == starts + stops) && (gate_held == 0), "chip calls inside the gate, gate released"); + CHECK(changes == 2, "the source told of each change"); +} diff --git a/target/pc/linux/radioentropy/Makefile b/target/pc/linux/radioentropy/Makefile new file mode 100644 index 000000000..24fb44f34 --- /dev/null +++ b/target/pc/linux/radioentropy/Makefile @@ -0,0 +1,40 @@ +# Host build of radio_entropy.c, the helper that keeps the hardware RNG fed with the radio +# on or off, with wifi_radio.c that starts and stops the radio through it, against a model +# of the chip that fails the test on any call the hardware would not allow. `make test` +# builds and runs it. +PRJ = radioentropy +PATH_SW = ../../../../software + +# rpc_calls.h of raw_u64 needs lwIP's headers, which the wifi_random test stubs out +VPATH = $(PATH_SW)/wifi/common $(PATH_SW)/test/radio_entropy $(PATH_SW)/test/wifi_random \ + $(PATH_SW)/wifi/raw_u64/main + +CC = gcc +CFLAGS = -std=gnu11 -g -O0 -Wall -Wextra -Wno-unused-parameter -pthread \ + $(addprefix -I, $(VPATH)) + +OUTPUT = output +RESULT = result +SRCS = radio_entropy.c wifi_radio.c radio_entropy_test.c +OBJS = $(addprefix $(OUTPUT)/, $(SRCS:%.c=%.o)) + +.PHONY: all run test clean + +all: $(RESULT)/$(PRJ) + +$(OUTPUT)/%.o: %.c + @mkdir -p $(OUTPUT) + $(CC) $(CFLAGS) -c -o $@ $< + +$(RESULT)/$(PRJ): $(OBJS) + @mkdir -p $(RESULT) + $(CC) $(CFLAGS) -o $@ $(OBJS) + +run: all + @$(RESULT)/$(PRJ) + + +test: run + +clean: + @rm -rf $(OUTPUT) $(RESULT) From 0813c6218fd471d0fd79d766560b586ae0afa02d Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:29:00 -0500 Subject: [PATCH 44/95] Report a busy WiFi module as UCI status 88 The module answers GET_RANDOM with a busy error when a radio change or a voltage read holds its entropy source. That is not a refusal: nothing was drawn and asking again is safe, so the Ultimate maps it to the busy status that the command interface already defines. Co-Authored-By: Claude Sonnet 5.5 Co-Authored-By: Claude Opus 5.5 --- software/io/wifi/wifi_random.cc | 4 +++ software/test/wifi_random/wifi_random_test.cc | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/software/io/wifi/wifi_random.cc b/software/io/wifi/wifi_random.cc index 52f3f8385..0bcb66eca 100644 --- a/software/io/wifi/wifi_random.cc +++ b/software/io/wifi/wifi_random.cc @@ -20,6 +20,10 @@ int wifi_random_take_reply(const uint8_t *reply, int size, uint16_t sequence, if (size < with_error) { return WIFI_RANDOM_INVALID; } + // The module holds its entropy source for a moment: nothing was drawn, asking again is safe + if (result->esp_err == RPC_ERR_ENTROPY_BUSY) { + return WIFI_RANDOM_BUSY; + } if (result->esp_err != 0) { return WIFI_RANDOM_REFUSED; } diff --git a/software/test/wifi_random/wifi_random_test.cc b/software/test/wifi_random/wifi_random_test.cc index e5c7bac35..b49d39917 100644 --- a/software/test/wifi_random/wifi_random_test.cc +++ b/software/test/wifi_random/wifi_random_test.cc @@ -116,6 +116,35 @@ static void reply_cases(void) } check(only_ours, "of all 256 commands only CMD_GET_RANDOM is ours"); + printf("The source behind the bytes\n"); + size = build(); + answer()->source = ENTROPY_ADC; + check(outcome(size, LEN, 0), "bytes from the ADC source, with the radio off, are handed out"); + + printf("The module is busy\n"); + size = build(); + answer()->esp_err = RPC_ERR_ENTROPY_BUSY; + answer()->source = ENTROPY_NONE; + answer()->length = 0; + check(outcome(HEADER, LEN, WIFI_RANDOM_BUSY), "busy with no bytes"); + size = build(); + answer()->esp_err = RPC_ERR_ENTROPY_BUSY; + check(outcome(size, LEN, WIFI_RANDOM_BUSY), "busy hands out nothing, even with len bytes behind it"); + size = build(); + answer()->esp_err = RPC_ERR_ENTROPY_BUSY; + check(outcome(8, LEN, WIFI_RANDOM_BUSY), "busy in the 8 byte form"); + size = build(); + answer()->esp_err = RPC_ERR_ENTROPY_BUSY + 1; + check(outcome(HEADER, LEN, WIFI_RANDOM_REFUSED), "the next error is a refusal"); + size = build(); + answer()->esp_err = RPC_ERR_ENTROPY_BUSY - 1; + check(outcome(HEADER, LEN, WIFI_RANDOM_REFUSED), "the error before it is a refusal"); + size = build(); + answer()->esp_err = RPC_ERR_ENTROPY_BUSY; + uint8_t sink[600]; + check(wifi_random_status(wifi_random_take_reply(reply.bytes, size, SEQUENCE, sink, LEN)) == 88, + "a busy answer is UCI status 88"); + printf("A refusal\n"); size = build(); answer()->esp_err = 0x103; // ESP_ERR_INVALID_STATE From 220995a8febc38a63027b21eff856611ab884490 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:29:00 -0500 Subject: [PATCH 45/95] Do not call it a low voltage when the module has no reading The control module now answers the voltage request with an error when it has nothing to give, for instance when its first read could not get the SAR ADC. The zeroed reading that came with it showed the Low input voltage message. Co-Authored-By: Claude Sonnet 5.5 Co-Authored-By: Claude Opus 5.5 --- software/io/wifi/wifi.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/software/io/wifi/wifi.cc b/software/io/wifi/wifi.cc index 845035d97..3815f63aa 100644 --- a/software/io/wifi/wifi.cc +++ b/software/io/wifi/wifi.cc @@ -294,7 +294,8 @@ void WiFi :: RunModeThread() memset(&voltages, 0, sizeof(voltages)); result = wifi_get_voltages(&voltages); printf("Result get voltages: %d %d %d %d %d %d %d %d\n", result, voltages.vbus, voltages.vaux, voltages.v50, voltages.v33, voltages.v18, voltages.v10, voltages.vusb); - if (voltages.vbus < 8500) { + // A module that has no reading to give says so; that is not a low voltage + if ((result == 0) && (voltages.vbus < 8500)) { UserInterface :: postMessage("Low input voltage."); } // These settings live in the module's NVS; keep them in sync. From 11780c10131187c25cc27c95d1697174cafd5198 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:37:36 -0500 Subject: [PATCH 46/95] Test the paths of GET_RANDOM that only the E2E suite covered Each is cut out of its file as it is and built on the host against stand-ins (target/pc/linux/getrandompaths): - the UCI network target's get_random() with the real wifi_random.cc behind it: 00,OK with the bytes, 88 for a busy module, 87 for a refusal, 82 for a length of 0 or above 512 without asking the module; - the receive interrupt's dispatch (wifi_rx_isr()): a reply on the dedicated channel that nobody waits for goes back to the pool, one that is waited for is queued with the pool's generation, other replies go to their task or the event queue; - the UART's buffer pool reset (ClearRxBuffer()): one generation per reset, after both resets, with the scheduler suspended; - the control module's voltage answer: a failed read carries its error and no stale bytes. The WiFi application test now also runs for the U64-II / C64 Ultimate, for its boot readout: no "Low input voltage" for a module that has no reading. Co-Authored-By: Claude Opus 5.5 --- Makefile | 1 + software/test/get_random_paths/isr_env.h | 71 +++++++++++ software/test/get_random_paths/isr_test.cc | 102 ++++++++++++++++ software/test/get_random_paths/net_env.h | 23 ++++ .../test/get_random_paths/net_target_test.cc | 114 ++++++++++++++++++ .../test/get_random_paths/stub/command_intf.h | 19 +++ .../test/get_random_paths/stub/lwip/netdb.h | 1 + .../test/get_random_paths/stub/lwip/sockets.h | 6 + .../test/get_random_paths/voltages_test.c | 62 ++++++++++ software/test/wifi_app/boot_test.cc | 36 ++++++ target/pc/linux/getrandompaths/Makefile | 75 ++++++++++++ 11 files changed, 510 insertions(+) create mode 100644 software/test/get_random_paths/isr_env.h create mode 100644 software/test/get_random_paths/isr_test.cc create mode 100644 software/test/get_random_paths/net_env.h create mode 100644 software/test/get_random_paths/net_target_test.cc create mode 100644 software/test/get_random_paths/stub/command_intf.h create mode 100644 software/test/get_random_paths/stub/lwip/netdb.h create mode 100644 software/test/get_random_paths/stub/lwip/sockets.h create mode 100644 software/test/get_random_paths/voltages_test.c create mode 100644 software/test/wifi_app/boot_test.cc create mode 100644 target/pc/linux/getrandompaths/Makefile diff --git a/Makefile b/Makefile index 5072485fa..6c951311a 100755 --- a/Makefile +++ b/Makefile @@ -89,6 +89,7 @@ host_tests: @$(MAKE) -C target/pc/linux/radioentropy test @$(MAKE) -C target/pc/linux/wifirandom test @$(MAKE) -C target/pc/linux/wifidedicated test + @$(MAKE) -C target/pc/linux/getrandompaths test esp32: esp32_raw_u64 esp32_raw_c3 esp32_u64ctrl diff --git a/software/test/get_random_paths/isr_env.h b/software/test/get_random_paths/isr_env.h new file mode 100644 index 000000000..bcf28a7f2 --- /dev/null +++ b/software/test/get_random_paths/isr_env.h @@ -0,0 +1,71 @@ +/* + * isr_env.h + * + * What the receive interrupt's dispatch (wifi_rx_isr(), cut out of wifi_cmd.cc as it is) and + * the UART's buffer pool reset (DmaUART::ClearRxBuffer(), cut out of dma_uart.cc) are built + * against on the build host. The real headers need the hardware; these are their parts that + * the two functions use. + */ + +#ifndef ISR_ENV_H_ +#define ISR_ENV_H_ + +#include +#include +#include +#include "rpc_calls.h" +#include "wifi_reply.h" + +typedef int BaseType_t; +typedef void *TaskHandle_t; +typedef void *QueueHandle_t; +#define pdTRUE 1 +#define pdFALSE 0 +typedef enum { eSetValueWithOverwrite } eNotifyAction; + +#define CMD_BUF_SIZE 1600 +#define NUM_TX_BUFFERS 12 +#define WIFI_DEDICATED_THREAD 0xFC // as wifi_cmd.h has it +typedef struct { + uint8_t data[CMD_BUF_SIZE]; + int bufnr; + int size; +} command_buf_t; +typedef struct { int dummy; } command_buf_context_t; +typedef struct { + command_buf_t *buf; + uint32_t generation; +} dedicated_reply_t; + +typedef struct { volatile uint8_t flowctrl; } dma_uart_t; +#define DMAUART_RESET 0x01 + +class DmaUART { +public: + volatile dma_uart_t *uart; + command_buf_context_t *packets; + QueueHandle_t rx_bufs; + volatile uint32_t generation; + void ClearRxBuffer(void); +}; +struct Esp32Stub { DmaUART *uart; }; +extern Esp32Stub esp32; + +extern wifi_reply_slot_t replySlots[WIFI_REPLY_SLOTS]; // static in wifi_cmd.cc +extern QueueHandle_t dedicated_replies; +extern volatile bool dedicated_waiting; + +BaseType_t xQueueSendFromISR(QueueHandle_t q, const void *item, BaseType_t *w); +// The value is the buffer's address in 32 bits on the target; the stub does not need it, +// so it is dropped here rather than cast on a 64-bit host +BaseType_t notify_from_isr(TaskHandle_t t, eNotifyAction a, BaseType_t *w); +#define xTaskNotifyFromISR(t, value, a, w) notify_from_isr((t), (a), (w)) +BaseType_t cmd_buffer_received_isr(command_buf_context_t *context, command_buf_t *b, BaseType_t *w); +void ioWrite8(int reg, uint8_t value); +#define UART_DATA 0 +void vTaskSuspendAll(void); +BaseType_t xTaskResumeAll(void); +BaseType_t xQueueGenericReset(QueueHandle_t q, BaseType_t new_queue); +void cmd_buffer_reset(command_buf_context_t *context); + +#endif /* ISR_ENV_H_ */ diff --git a/software/test/get_random_paths/isr_test.cc b/software/test/get_random_paths/isr_test.cc new file mode 100644 index 000000000..091c8986b --- /dev/null +++ b/software/test/get_random_paths/isr_test.cc @@ -0,0 +1,102 @@ +/* + * isr_test.cc + * + * The receive interrupt's dispatch of a frame (wifi_rx_isr()) and the UART's buffer pool + * reset (DmaUART::ClearRxBuffer()), both cut out of their files as they are, against + * recording stubs. + */ + +#include +#include "isr_env.h" + +static int failures; +#define CHECK(cond, what) do { if (!(cond)) { printf("FAIL %s:%d: %s (log \"%s\")\n", __func__, __LINE__, what, rlog); failures++; } } while (0) + +static char rlog[64]; +static void note(char c) { size_t n = strlen(rlog); if (n + 1 < sizeof(rlog)) { rlog[n] = c; rlog[n + 1] = 0; } } + +BaseType_t wifi_rx_isr(command_buf_context_t *context, command_buf_t *buf, BaseType_t *w); + +static DmaUART uart; +static dma_uart_t regs; +static command_buf_context_t packets; +static int queue_tag, task_tag; +Esp32Stub esp32 = { &uart }; +wifi_reply_slot_t replySlots[WIFI_REPLY_SLOTS]; +QueueHandle_t dedicated_replies = &queue_tag; +volatile bool dedicated_waiting; + +static dedicated_reply_t queued; +BaseType_t xQueueSendFromISR(QueueHandle_t q, const void *item, BaseType_t *w) { note('q'); queued = *(const dedicated_reply_t *)item; return pdTRUE; } +BaseType_t notify_from_isr(TaskHandle_t t, eNotifyAction a, BaseType_t *w) { note('n'); return pdTRUE; } +BaseType_t cmd_buffer_received_isr(command_buf_context_t *context, command_buf_t *b, BaseType_t *w) { note('e'); return pdTRUE; } +void ioWrite8(int reg, uint8_t value) {} +void vTaskSuspendAll(void) { note('{'); } +BaseType_t xTaskResumeAll(void) { note('}'); return pdFALSE; } +BaseType_t xQueueGenericReset(QueueHandle_t q, BaseType_t new_queue) { note('r'); return pdTRUE; } +static uint32_t gen_before; +void cmd_buffer_reset(command_buf_context_t *context) { note('c'); if (uart.generation != gen_before) note('!'); } + +static BaseType_t frame(uint8_t thread, uint16_t sequence = 0) +{ + static command_buf_t buf; + memset(&buf, 0, sizeof(buf)); + ((rpc_header_t *)buf.data)->thread = thread; + ((rpc_header_t *)buf.data)->sequence = sequence; + rlog[0] = 0; + BaseType_t w = pdFALSE; + return wifi_rx_isr(&packets, &buf, &w); +} + +static void dedicated_channel(void) +{ + dedicated_waiting = false; + CHECK(frame(WIFI_DEDICATED_THREAD) == pdFALSE, "nobody waits: the buffer goes back"); + CHECK(rlog[0] == 0, "and is not queued or handed on"); + dedicated_waiting = true; + uart.generation = 7; + CHECK(frame(WIFI_DEDICATED_THREAD) == pdTRUE, "a waiting caller"); + CHECK((strcmp(rlog, "q") == 0) && (queued.generation == 7), "gets it, with the pool's generation"); + dedicated_waiting = false; +} + +static void other_threads(void) +{ + replySlots[3].task = &task_tag; + replySlots[3].sequence = 77; + frame(3, 76); + CHECK(strcmp(rlog, "e") == 0, "a reply with another sequence number is not the slot's"); + frame(3, 77); + CHECK(strcmp(rlog, "n") == 0, "a reply goes to its waiting task"); + CHECK(replySlots[3].task == NULL, "once"); + frame(3, 77); + CHECK(strcmp(rlog, "e") == 0, "without one, to the event queue"); + frame(0xFF); + CHECK(strcmp(rlog, "e") == 0, "events too"); +} + +static void pool_reset(void) +{ + uart.uart = ®s; + uart.packets = &packets; + uart.generation = 41; + gen_before = 41; + rlog[0] = 0; + uart.ClearRxBuffer(); + CHECK(uart.generation == 42, "a reset counts as one generation"); + CHECK((rlog[0] == '{') && (rlog[strlen(rlog) - 1] == '}'), "with the scheduler suspended"); + CHECK((strchr(rlog, 'r') != NULL) && (strchr(rlog, 'c') != NULL) && (strchr(rlog, '!') == NULL), "after both resets"); +} + +int main(void) +{ + dedicated_channel(); + other_threads(); + pool_reset(); + if (failures) { + printf("getrandompaths isr: %d check(s) failed\n", failures); + return 1; + } + printf("getrandompaths isr: all checks passed\n"); + return 0; +} diff --git a/software/test/get_random_paths/net_env.h b/software/test/get_random_paths/net_env.h new file mode 100644 index 000000000..26d3219da --- /dev/null +++ b/software/test/get_random_paths/net_env.h @@ -0,0 +1,23 @@ +/* + * net_env.h + * + * What NetworkTarget::get_random() and the status messages, cut out of network_target.cc + * and command_intf.cc as they are (target/pc/linux/getrandompaths/Makefile), are built + * against on the build host. + */ + +#ifndef NET_ENV_H_ +#define NET_ENV_H_ + +#include +#include +#include "command_intf.h" +#define class struct // get_random() is private +#include "network_target.h" +#undef class +#include "wifi_random.h" + +extern Message c_message_empty; +extern Message c_status_ok; + +#endif /* NET_ENV_H_ */ diff --git a/software/test/get_random_paths/net_target_test.cc b/software/test/get_random_paths/net_target_test.cc new file mode 100644 index 000000000..ee057370b --- /dev/null +++ b/software/test/get_random_paths/net_target_test.cc @@ -0,0 +1,114 @@ +/* + * net_target_test.cc + * + * The UCI network target's GET_RANDOM (NetworkTarget::get_random(), the GET_RANDOM case of + * parse_command() and the status messages, cut out of network_target.cc as they are) with + * the real wifi_random.cc behind it, and the module's answer stubbed: which UCI status and + * which bytes each answer gives, and which command lengths are taken. + */ + +#include "net_env.h" + +static int failures; +#define CHECK(cond, what) do { if (!(cond)) { printf("FAIL %s:%d: %s\n", __func__, __LINE__, what); failures++; } } while (0) + +// The module's answer, as wifi_get_random() returns it +static int module_result; +static int asked; +int wifi_get_random(uint8_t *buf, uint16_t len) +{ + asked++; + if (module_result == 0) { + memset(buf, 0x5A, len); + } + return module_result; +} + +NetworkTarget :: NetworkTarget(int id) {} +NetworkTarget :: ~NetworkTarget() {} +void NetworkTarget :: get_more_data(Message **reply, Message **status) {} +void NetworkTarget :: abort(int a) {} +void NetworkTarget :: c64_reset(void) {} + +static uint8_t buffer[2048]; + +static void ask(NetworkTarget &t, uint16_t length, Message **reply, Message **status) +{ + uint8_t cmd[4] = { 0x03, 0x20, (uint8_t)(length & 0xFF), (uint8_t)(length >> 8) }; + Message m = { 4, true, cmd }; + t.data_message.message = buffer; + t.data_message.length = 0; + *reply = NULL; + *status = NULL; + t.get_random(&m, reply, status); +} + +static bool status_is(Message *status, const char *text) +{ + return status && (status->length == (int)strlen(text)) && (memcmp(status->message, text, status->length) == 0); +} + +static void answers(void) +{ + NetworkTarget t(0); + Message *reply, *status; + + module_result = 0; + ask(t, 16, &reply, &status); + CHECK(status_is(status, "00,OK"), "bytes: 00,OK"); + CHECK((reply == &t.data_message) && (reply->length == 16) && (buffer[0] == 0x5A), "and the bytes"); + + module_result = WIFI_RANDOM_BUSY; + ask(t, 16, &reply, &status); + CHECK(status_is(status, "88,ENTROPY SOURCE BUSY"), "busy: 88"); + CHECK(reply == &c_message_empty, "busy carries no bytes"); + + module_result = WIFI_RANDOM_REFUSED; + ask(t, 16, &reply, &status); + CHECK(status_is(status, "87,NO ENTROPY SOURCE"), "refused: 87"); + CHECK(reply == &c_message_empty, "refused carries no bytes"); + + // The length is checked before the module is asked + asked = 0; + ask(t, 0, &reply, &status); + CHECK(status_is(status, "82,PARAMETER(S) OUT OF RANGE") && (asked == 0), "0 bytes: 82, module not asked"); + ask(t, NET_MAX_RANDOM + 1, &reply, &status); + CHECK(status_is(status, "82,PARAMETER(S) OUT OF RANGE") && (asked == 0), "513 bytes: 82, module not asked"); + module_result = 0; + ask(t, NET_MAX_RANDOM, &reply, &status); + CHECK(status_is(status, "00,OK") && (asked == 1), "512 bytes: asked"); +} + +// The command is exactly four bytes: target, command, length low, length high +static void command_length(void) +{ + NetworkTarget t(0); + Message *reply, *status; + for (int len = 2; len <= 6; len++) { + uint8_t cmd[6] = { 0x03, 0x20, 16, 0, 0, 0 }; + Message m = { len, true, cmd }; + t.data_message.message = buffer; + asked = 0; + module_result = 0; + reply = status = NULL; + t.parse_command(&m, &reply, &status); + if (len == 4) { + CHECK(status_is(status, "00,OK") && (asked == 1), "four bytes: asked, 00,OK"); + } else { + CHECK(status_is(status, "81,INVALID PARAMS") && (asked == 0) && (reply == &c_message_empty), + "any other length: 81, no data, the module not asked"); + } + } +} + +int main(void) +{ + answers(); + command_length(); + if (failures) { + printf("getrandompaths net_target: %d check(s) failed\n", failures); + return 1; + } + printf("getrandompaths net_target: all checks passed\n"); + return 0; +} diff --git a/software/test/get_random_paths/stub/command_intf.h b/software/test/get_random_paths/stub/command_intf.h new file mode 100644 index 000000000..453cec000 --- /dev/null +++ b/software/test/get_random_paths/stub/command_intf.h @@ -0,0 +1,19 @@ +// Stand-in for command_intf.h: what network_target.h declares against +#ifndef COMMAND_INTF_H_STUB +#define COMMAND_INTF_H_STUB +#include +#define CMD_MAX_REPLY_BLOCK 895 +typedef struct _message { + int length; + bool last_part; + uint8_t *message; +} Message; +class CommandTarget { +public: + virtual ~CommandTarget() {} + virtual void parse_command(Message *command, Message **reply, Message **status) = 0; + virtual void get_more_data(Message **reply, Message **status) {} + virtual void abort(int a) {} + virtual void c64_reset(void) {} +}; +#endif diff --git a/software/test/get_random_paths/stub/lwip/netdb.h b/software/test/get_random_paths/stub/lwip/netdb.h new file mode 100644 index 000000000..72207e47d --- /dev/null +++ b/software/test/get_random_paths/stub/lwip/netdb.h @@ -0,0 +1 @@ +// Stand-in for lwIP's netdb.h on the build host. rpc_calls.h needs nothing from it. diff --git a/software/test/get_random_paths/stub/lwip/sockets.h b/software/test/get_random_paths/stub/lwip/sockets.h new file mode 100644 index 000000000..b78473080 --- /dev/null +++ b/software/test/get_random_paths/stub/lwip/sockets.h @@ -0,0 +1,6 @@ +// Stand-in for lwIP's sockets.h on the build host. rpc_calls.h needs only u16_t. +#ifndef LWIP_SOCKETS_H_STUB +#define LWIP_SOCKETS_H_STUB +#include +typedef uint16_t u16_t; +#endif diff --git a/software/test/get_random_paths/voltages_test.c b/software/test/get_random_paths/voltages_test.c new file mode 100644 index 000000000..5db3c956c --- /dev/null +++ b/software/test/get_random_paths/voltages_test.c @@ -0,0 +1,62 @@ +/* + * voltages_test.c + * + * The Elite II / C64 Ultimate module's answer to CMD_GET_VOLTAGES (cmd_get_voltages(), cut + * out of its rpc_dispatch.c as it is): a read that fails says so and carries no stale bytes. + */ + +#include +#include +#include +#include "rpc_calls.h" + +typedef int esp_err_t; +typedef int BaseType_t; +#define UART_NUM_0 0 +#define UART_NUM_1 1 +#define ESP_LOGI(tag, ...) ((void)0) +static const char *TAG = "test"; +typedef struct { uint8_t data[1600]; int bufnr; int size; } command_buf_t; +BaseType_t my_uart_transmit_packet(uint8_t uart_num, command_buf_t *buf); +esp_err_t read_adc_channels(uint16_t *adc_data); + +#include "voltages_extract.c" + +static int failures; +#define CHECK(cond, what) do { if (!(cond)) { printf("FAIL %s:%d: %s\n", __func__, __LINE__, what); failures++; } } while (0) + +static int read_result; +static int sent; +esp_err_t read_adc_channels(uint16_t *adc_data) +{ + if (read_result == 0) { + for (int i = 0; i < 7; i++) adc_data[i] = 1000 + i; + } + return read_result; +} +BaseType_t my_uart_transmit_packet(uint8_t uart_num, command_buf_t *buf) { sent++; return 1; } + +int main(void) +{ + static command_buf_t buf; + rpc_get_voltages_resp *resp = (rpc_get_voltages_resp *)buf.data; + + memset(buf.data, 0xAA, sizeof(buf.data)); + read_result = 0x107; + cmd_get_voltages(&buf); + CHECK(resp->esp_err == 0x107, "the read's error is the answer's"); + CHECK((resp->vbus == 0) && (resp->vusb == 0), "and no stale bytes in the voltages"); + CHECK((sent == 1) && (buf.size == sizeof(rpc_get_voltages_resp)), "sent, whole"); + + memset(buf.data, 0xAA, sizeof(buf.data)); + read_result = 0; + cmd_get_voltages(&buf); + CHECK((resp->esp_err == 0) && (resp->vbus == 1000) && (resp->vusb == 1006), "a good read"); + + if (failures) { + printf("getrandompaths voltages: %d check(s) failed\n", failures); + return 1; + } + printf("getrandompaths voltages: all checks passed\n"); + return 0; +} diff --git a/software/test/wifi_app/boot_test.cc b/software/test/wifi_app/boot_test.cc new file mode 100644 index 000000000..85753ea22 --- /dev/null +++ b/software/test/wifi_app/boot_test.cc @@ -0,0 +1,36 @@ +/* + * boot_test.cc + * + * The U64-II / C64 Ultimate's WiFi application when it finds its module (see + * wifi_app_script.h). + * + * CASES_FOR: U64=2 + */ + +#include "wifi_app_script.h" + +#if U64 == 2 +// The U64-II / C64 Ultimate reads the input voltage when it finds its module: a module that +// has no reading to give says so, and that is not a low voltage +static void voltages_at_boot(void) +{ + voltages_result = 0x107; + boot(true, 0, NULL, 0); + CHECK(strchr(rlog, '!') == NULL, "no reading: no Low input voltage"); + voltages_result = 0; + voltages_vbus = 7000; + boot(true, 0, NULL, 0); + CHECK(strchr(rlog, '!') != NULL, "a low reading: the message"); + voltages_vbus = 9000; + boot(true, 0, NULL, 0); + CHECK(strchr(rlog, '!') == NULL, "a good reading: none"); +} +#endif + + +void run_cases(void) +{ +#if U64 == 2 + voltages_at_boot(); +#endif +} diff --git a/target/pc/linux/getrandompaths/Makefile b/target/pc/linux/getrandompaths/Makefile new file mode 100644 index 000000000..f4f2001db --- /dev/null +++ b/target/pc/linux/getrandompaths/Makefile @@ -0,0 +1,75 @@ +# +# Host tests of the paths GET_RANDOM takes on the Ultimate and the control module that no +# other host test compiles. Each is cut out of its file as it is and built against +# stand-ins (software/test/get_random_paths): +# net_target NetworkTarget::get_random(), the GET_RANDOM case of parse_command() and the +# status messages, with wifi_random.cc +# isr wifi_rx_isr() from wifi_cmd.cc and DmaUART::ClearRxBuffer() from dma_uart.cc +# voltages cmd_get_voltages() from the u64ctrl module's rpc_dispatch.c +# +# make test build and run all three +# make SRC= test take the files from a copy of software/ (a mutant) +# +PATH_SW = ../../../../software +SRC ?= $(PATH_SW) +TESTDIR = $(PATH_SW)/test/get_random_paths +OUTPUT = output +RESULT = result + +CXX = g++ +CC = gcc +WARN = -Wall -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-format -Wno-unknown-warning-option + +# A function from its header line (its start, matched as text) to the first line that is "}" +FN = awk -v f="$(1)" 'index($$0, f "(") == 1 && $$0 !~ /;[[:space:]\r]*$$/ { p = 1 } p { print } p && /^\}/ { p = 0 }' $(2) + +.PHONY: all test clean + +all: $(RESULT)/net_target $(RESULT)/isr $(RESULT)/voltages + +$(OUTPUT)/net.cc: $(SRC)/io/network/network_target.cc $(SRC)/io/command_interface/command_intf.cc + @mkdir -p $(OUTPUT) + @{ echo '#include "net_env.h"'; \ + grep -E '^Message c_(message_empty|status_ok) ' $(SRC)/io/command_interface/command_intf.cc; \ + grep -E '^Message c_status_' $(SRC)/io/network/network_target.cc; \ + $(call FN,void NetworkTarget :: get_random,$(SRC)/io/network/network_target.cc); \ + echo 'void NetworkTarget :: parse_command(Message *command, Message **reply, Message **status)'; \ + echo '{'; echo ' switch (command->message[1]) {'; \ + awk '/case NET_CMD_GET_RANDOM:/ { p = 1 } p { print } p && /^ break;\r?$$/ { p = 0 }' $(SRC)/io/network/network_target.cc; \ + echo ' default:'; echo ' break;'; echo ' }'; echo '}'; } > $@ + @grep -q 'NetworkTarget :: get_random' $@ || { echo "getrandompaths: get_random not found"; exit 1; } + @grep -q 'case NET_CMD_GET_RANDOM:' $@ || { echo "getrandompaths: the GET_RANDOM case of parse_command not found"; exit 1; } + +$(RESULT)/net_target: $(OUTPUT)/net.cc $(TESTDIR)/net_target_test.cc + @mkdir -p $(RESULT) + $(CXX) -std=gnu++11 -g -O0 $(WARN) -DU64=1 -I$(TESTDIR)/stub -I$(TESTDIR) -I$(SRC)/io/network -I$(SRC)/io/wifi \ + -I$(PATH_SW)/test/wifi_random -I$(SRC)/wifi/raw_u64/main -I$(SRC)/wifi/common \ + -o $@ $(OUTPUT)/net.cc $(TESTDIR)/net_target_test.cc $(SRC)/io/wifi/wifi_random.cc + +$(OUTPUT)/isr.cc: $(SRC)/io/wifi/wifi_cmd.cc $(SRC)/io/uart/dma_uart.cc + @mkdir -p $(OUTPUT) + @{ echo '#include "isr_env.h"'; \ + $(call FN,BaseType_t wifi_rx_isr,$(SRC)/io/wifi/wifi_cmd.cc); \ + $(call FN,void DmaUART::ClearRxBuffer,$(SRC)/io/uart/dma_uart.cc); } > $@ + @grep -q 'wifi_rx_isr' $@ && grep -q 'ClearRxBuffer' $@ || { echo "getrandompaths: isr functions not found"; exit 1; } + +$(RESULT)/isr: $(OUTPUT)/isr.cc $(TESTDIR)/isr_test.cc + @mkdir -p $(RESULT) + $(CXX) -std=gnu++11 -g -O0 $(WARN) -DU64=1 -I$(TESTDIR)/stub -I$(TESTDIR) -I$(SRC)/io/wifi -I$(SRC)/wifi/raw_u64/main -I$(SRC)/wifi/common \ + -o $@ $(OUTPUT)/isr.cc $(TESTDIR)/isr_test.cc + +$(OUTPUT)/voltages_extract.c: $(SRC)/u64ctrl/main/rpc_dispatch.c + @mkdir -p $(OUTPUT) + @{ grep -E '^#define UART_CHAN' $<; $(call FN,void cmd_get_voltages,$<); } > $@ + @grep -q 'cmd_get_voltages' $@ || { echo "getrandompaths: cmd_get_voltages not found"; exit 1; } + +$(RESULT)/voltages: $(OUTPUT)/voltages_extract.c $(TESTDIR)/voltages_test.c + @mkdir -p $(RESULT) + $(CC) -std=gnu11 -g -O0 $(WARN) -I$(OUTPUT) -I$(TESTDIR)/stub -I$(SRC)/u64ctrl/main -I$(SRC)/wifi/common \ + -o $@ $(TESTDIR)/voltages_test.c + +test: all + @$(RESULT)/net_target && $(RESULT)/isr && $(RESULT)/voltages + +clean: + @rm -rf $(OUTPUT) $(RESULT) From f52f363c37cf4533b4a111bc255fbf01016daf57 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:56:31 -0500 Subject: [PATCH 47/95] Draw GET_RANDOM with the radio off in the E2E suite The suite said that an Ultimate 64-II refuses GET_RANDOM with its radio off and that writing "WiFi Enabled" back does not stop the module. Both are no longer so: the module draws from its SAR ADC source with the radio off, and the setting switches the radio at once. get-random-radio-off turns the radio off through "WiFi Enabled" on an Ultimate 64 or Ultimate 64 Elite and waits until the Ultimate's WiFi interface has lost its address, which it does on the module's EVENT_DISABLED; if the address stays, the radio did not go off and the scenario fails instead of drawing with the radio on. It then draws eight times and expects bytes, turns the radio on again, waits for the address to come back and checks a draw with the radio on. A draw that meets the radio change may answer 88, which the suite retries as for the other scenarios. It skips on the Ultimate 64-II, which has no setting the suite can switch; where the suite reaches the device over WiFi, since the off would cut it off; and where the WiFi interface has no address before it (no AP, or a static address), since the off could not be seen. That the RF itself is off is left to the bench's sniffer. Co-Authored-By: Claude Opus 5.5 --- .../io/command_interface/net_target_test.py | 130 ++++++++++++++++-- 1 file changed, 122 insertions(+), 8 deletions(-) diff --git a/tests/e2e/io/command_interface/net_target_test.py b/tests/e2e/io/command_interface/net_target_test.py index 9c2fa3734..675fe1b0c 100644 --- a/tests/e2e/io/command_interface/net_target_test.py +++ b/tests/e2e/io/command_interface/net_target_test.py @@ -48,12 +48,20 @@ the same either way. Whether bytes are owed at all is taken from the device's own report, not from GET_RANDOM's answer: an Ultimate 64 or Ultimate 64 Elite owes them, once "WiFi Enabled" is set and it reports a wifi_mac in -/v1/info. Any other product has to refuse. +/v1/info. An Ultimate 64-II or C64 Ultimate (the Elite II and the C64 Ultimate) owes them as +soon as its module reports a wifi_mac. Both owe them with the radio off too: the +module then draws them from its SAR ADC entropy source. get-random-radio-off +checks that on the products with the setting, by turning the radio off for the +scenario and on again after it; the Ultimate 64-II has no setting the suite can +switch (its menu's Enable and Disable are actions), so there it skips; it also +skips where the suite reaches the device over WiFi. Any other product has to refuse. Supported on any Ultimate whose FPGA provides the command interface. The suite enables the "Command Interface" setting and restores it on exit. On an Ultimate 64 or Ultimate 64 Elite it also sets "WiFi Enabled" and restores the stored -setting on exit; the module it started keeps running until the next reboot. +setting on exit; a change of the setting turns the module's radio on or off at +once. An Ultimate 64-II is left as it is. The suite must reach the device over +Ethernet: get-random-radio-off turns the WiFi radio off. """ import argparse @@ -85,6 +93,8 @@ OWNED_SETTINGS = (CFG_CMD_IF,) NET_CMD_IDENTIFY = 0x01 +NET_CMD_GET_INTERFACE_COUNT = 0x02 +NET_CMD_GET_NETADDR = 0x04 NET_CMD_GET_IPADDR = 0x05 NET_CMD_OPEN_TCP = 0x07 NET_CMD_OPEN_UDP = 0x08 @@ -193,14 +203,21 @@ U64_MK2_PRODUCTS = ("Ultimate 64-II", "C64 Ultimate") # Every other product answers 87, even with a wifi_mac: its ESP32 runs other code. GET_RANDOM_PRODUCTS = U64_MK1_PRODUCTS + U64_MK2_PRODUCTS -# The setting that starts the module there, by the store's exact name (the answer -# is keyed by it). Set for the run; writing Disabled back restores the setting but -# does not stop the module (network_esp32.cc, effectuate_settings). +# The setting that switches the module's radio there, by the store's exact name (the +# answer is keyed by it). Set for the run, and written back on exit; a change takes +# effect at once (network_esp32.cc, wifi_enable_change). CFG_WIFI_CATEGORY = "WiFi settings" CFG_WIFI_ENABLED = "WiFi Enabled" # How long a device with Wi-Fi enabled gets to report its wifi_mac, which it # does once the module has started; this covers a device that has just booted. WIFI_MAC_SECONDS = 30.0 +# How long the module gets to stop its radio after "WiFi Enabled" goes to Disabled +# (it takes the request between connect attempts, so this covers one attempt), and to +# associate and get an address again after Enabled. +RADIO_OFF_SECONDS = 30.0 +RADIO_ON_SECONDS = 60.0 +# How many draws get-random-radio-off makes with the radio off +RADIO_OFF_DRAWS = 8 # The most GET_RANDOM hands out in one command. 512 bytes fits one reply block, # so every GET_RANDOM reply arrives in one. @@ -259,11 +276,12 @@ "get-random-bytes-vary", "get-random-refusals", "get-random-leaves-sockets-alone", + "get-random-radio-off", "reset-closes-uci-sockets", ] # The scenarios that need no network peer, because they open no socket. PEERLESS_TESTS = ("read-length-limit", "get-random-lengths", "get-random-bytes-vary", - "get-random-refusals") + "get-random-refusals", "get-random-radio-off") def pattern(size: int, seed: int = 0) -> bytes: @@ -1376,8 +1394,9 @@ def require_random(result, length: int) -> bytes: f"{RANDOM_BUSY_DELAY_SECONDS:.1f}s apart") if result.status_text.startswith(STATUS_NO_ENTROPY_PREFIX): raise Failure(f"GET_RANDOM of {length} bytes answered {result.status_text!r}, expected " - f"{STATUS_OK!r}; if WiFi was disabled from the menu, enable it there or " - f"reboot, then run the suite again") + f"{STATUS_OK!r}: the module has bytes with its radio on and with it off, " + f"so 87 means it has no entropy source at all (a module without " + f"GET_RANDOM, or a SAR ADC source that failed its readback)") if result.status_text != STATUS_OK: raise Failure(f"GET_RANDOM of {length} bytes answered {result.status_text!r}, " f"expected {STATUS_OK!r}") @@ -1659,6 +1678,99 @@ def run_get_random_leaves_sockets_alone(net: Net, peer: Peer, duty: RandomDuty, return True +def wifi_interface_address(net: Net, wifi_mac: str) -> str | None: + """The address of the network target's interface whose MAC is `wifi_mac`, or None. + + The WiFi interface loses its address when its link goes down (dhcp_stop in + NetworkInterface::link_down), which is what the Ultimate does when the module + reports EVENT_DISABLED, so 0.0.0.0 here means the radio-off reached it. None + means no interface has that MAC. + """ + count = net.uci.transact(bytes([TARGET_NETWORK, NET_CMD_GET_INTERFACE_COUNT])).data + want = bytes.fromhex(wifi_mac.replace(":", "").replace("-", "")) + for index in range(count[0] if count else 0): + mac = net.uci.transact(bytes([TARGET_NETWORK, NET_CMD_GET_NETADDR, index])).data + if bytes(mac[:6]) == want: + reply = net.uci.transact(bytes([TARGET_NETWORK, NET_CMD_GET_IPADDR, index])).data + return ".".join(str(b) for b in reply[:4]) if len(reply) >= 4 else None + return None + + +def wait_for_wifi_address(net: Net, wifi_mac: str, gone: bool, seconds: float) -> str | None: + """Polls the WiFi interface's address until it is gone (0.0.0.0) or back, or the time is up.""" + deadline = time.monotonic() + seconds + while True: + address = wifi_interface_address(net, wifi_mac) + if (address == "0.0.0.0") == gone or time.monotonic() >= deadline: + return address + time.sleep(1.0) + + +def run_get_random_radio_off(net: Net, duty: RandomDuty, device, device_host: str) -> bool | None: + """GET_RANDOM hands out bytes with the WiFi radio off, from the SAR ADC source. + + On an Ultimate 64 or Ultimate 64 Elite, "WiFi Enabled" goes to Disabled for the + scenario, which turns the module's radio off at once, and back to Enabled after + it. The off counts as done once the Ultimate's WiFi interface has lost its address, + which it does on the module's EVENT_DISABLED; if it keeps it, the radio did not go + off and the scenario fails rather than draw with the radio on. That the RF itself + is off is the bench sniffer's check, not this suite's. The draws then come from + the module's SAR ADC entropy source; one that meets the radio change may answer + 88, which Net retries. + + Skips where it cannot work: on the Ultimate 64-II, whose radio is switched only + from its menu; where the suite reaches the device over WiFi (turning it off would + cut the suite off); and where the WiFi interface has no address before the + scenario (with a static address, or no AP), so the off could not be seen. + """ + section("get-random-radio-off") + if not random_expected(net, duty): + return None + check_start("GET_RANDOM hands out bytes with the radio off") + if duty.product not in U64_MK1_PRODUCTS: + check_skip(f"this {duty.product} has no {CFG_WIFI_ENABLED!r} setting to switch its " + f"radio with; its menu's Disable is an action the suite cannot reach") + return None + info = device.info() + wifi_mac = info.extra.get("wifi_mac", "") if reports_wifi_mac(info) else "" + address = wifi_interface_address(net, wifi_mac) if wifi_mac else None + try: + host_address = socket.gethostbyname(device_host) + except OSError: + host_address = device_host + if address is not None and address == host_address: + check_skip(f"the suite reaches the device at {host_address}, its WiFi address; turning " + f"the radio off would cut the suite off. Run it over Ethernet") + return None + if address in (None, "0.0.0.0"): + check_skip(f"the WiFi interface has no address before the scenario ({address!r}: no " + f"AP, or a static address), so the radio going off could not be seen") + return None + with check(f"set {CFG_WIFI_ENABLED!r} to Disabled, and the WiFi interface loses its " + f"address {address} within {RADIO_OFF_SECONDS:g}s"): + device.configs.set(CFG_WIFI_CATEGORY, CFG_WIFI_ENABLED, "Disabled") + after = wait_for_wifi_address(net, wifi_mac, True, RADIO_OFF_SECONDS) + if after != "0.0.0.0": + raise Failure(f"the WiFi interface still has {after!r}: the radio did not go off") + try: + with check(f"{RADIO_OFF_DRAWS} GET_RANDOM of {RANDOM_TYPICAL} bytes with the radio off " + f"answer {STATUS_OK.decode()} with the bytes"): + series = [require_random(net.get_random(RANDOM_TYPICAL), RANDOM_TYPICAL) + for _ in range(RADIO_OFF_DRAWS)] + if len(set(series)) != len(series): + raise Failure("a reply with the radio off repeated an earlier one") + finally: + with check(f"set {CFG_WIFI_ENABLED!r} back to Enabled, and the WiFi interface gets " + f"an address again within {RADIO_ON_SECONDS:g}s"): + device.configs.set(CFG_WIFI_CATEGORY, CFG_WIFI_ENABLED, "Enabled") + back = wait_for_wifi_address(net, wifi_mac, False, RADIO_ON_SECONDS) + if back in (None, "0.0.0.0"): + raise Failure(f"the WiFi interface has {back!r}: the radio did not come back") + with check("GET_RANDOM hands out bytes with the radio on again"): + require_random(net.get_random(RANDOM_TYPICAL), RANDOM_TYPICAL) + return True + + def close_quietly(net: Net, handles: list[int]) -> None: """Close every handle a scenario opened; an error means it was already gone.""" for handle in handles: @@ -1920,6 +2032,8 @@ def run(route: str, name: str, fn, *fn_args) -> None: if route == "native": run(route, "get-random-bytes-vary", run_get_random_bytes_vary, net, duty) run(route, "get-random-refusals", run_get_random_refusals, net, duty) + run(route, "get-random-radio-off", run_get_random_radio_off, net, duty, device, + target.device) if peer is None: for name in needs_peer: if duty_failure is not None and name.startswith("get-random-"): From 1c0747ffa62489d4e30e48d63e18bff6d7d99996 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 30 Oct 2026 14:18:11 -0500 Subject: [PATCH 48/95] Link the radio entropy hooks into the U2+L module wifi_radio.c makes every radio change under the entropy gate of radio_entropy.h. The U2+L module uses wifi_radio.c but does not serve GET_RANDOM, so it gets hooks that do nothing (radio_entropy_none.c). radio_entropy.h includes rpc_shared.h itself, which that module's rpc_calls.h does not, and its note on radio_entropy_init() says that the U64 module starts with its radio off. Co-Authored-By: Claude Opus 5.5 --- software/wifi/common/radio_entropy.h | 5 ++-- software/wifi/raw_c3/main/CMakeLists.txt | 2 +- .../wifi/raw_c3/main/radio_entropy_none.c | 26 +++++++++++++++++++ software/wifi/raw_c3/main/rpc_dispatch.h | 6 +++-- 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 software/wifi/raw_c3/main/radio_entropy_none.c diff --git a/software/wifi/common/radio_entropy.h b/software/wifi/common/radio_entropy.h index 3bbcf07c9..6d84d83ba 100644 --- a/software/wifi/common/radio_entropy.h +++ b/software/wifi/common/radio_entropy.h @@ -28,6 +28,7 @@ #include #include #include "rpc_calls.h" +#include "rpc_shared.h" // entropy_source_t; the U2+L module's rpc_calls.h does not include it // Results; the values are those of the esp_err_t they are passed on as (asserted in // radio_entropy_esp.c) @@ -52,8 +53,8 @@ entropy_source_t entropy_source(void); uint32_t entropy_epoch(void); -// Once, after the boot's radio start and before the first RPC is served. A boot that did -// not start the radio enables the ADC source here. +// Once, after wifi_init() and before the first RPC is served. The U64 module starts with +// its radio off, so it enables the ADC source here; a boot that started the radio does not. void radio_entropy_init(void); // Around every radio start and stop, by wifi_radio.c only. begin takes the gate diff --git a/software/wifi/raw_c3/main/CMakeLists.txt b/software/wifi/raw_c3/main/CMakeLists.txt index fdfd7fe88..a9393b4ce 100644 --- a/software/wifi/raw_c3/main/CMakeLists.txt +++ b/software/wifi/raw_c3/main/CMakeLists.txt @@ -1,5 +1,5 @@ set(EXTERNAL "../../../io/uart") set(COMMON "../../common") -idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_boot.c +idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_boot.c "radio_entropy_none.c" INCLUDE_DIRS "." ${EXTERNAL} ${COMMON} LDFRAGMENTS "linker.lf") diff --git a/software/wifi/raw_c3/main/radio_entropy_none.c b/software/wifi/raw_c3/main/radio_entropy_none.c new file mode 100644 index 000000000..fb91ef94e --- /dev/null +++ b/software/wifi/raw_c3/main/radio_entropy_none.c @@ -0,0 +1,26 @@ +/* + * radio_entropy_none.c + * + * The U2+L module does not serve GET_RANDOM, so it has no entropy source to switch when + * wifi_radio.c starts or stops the radio: its hooks do nothing here. + */ + +#include +#include "radio_entropy.h" + +int radio_entropy_change_begin(void) +{ + return RE_OK; +} + +void radio_entropy_changing(bool starting) +{ +} + +void radio_entropy_changed(bool radio_on) +{ +} + +void radio_entropy_change_end(void) +{ +} diff --git a/software/wifi/raw_c3/main/rpc_dispatch.h b/software/wifi/raw_c3/main/rpc_dispatch.h index c29bbe597..64a03c9ee 100644 --- a/software/wifi/raw_c3/main/rpc_dispatch.h +++ b/software/wifi/raw_c3/main/rpc_dispatch.h @@ -24,8 +24,10 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.9" +#define IDENT_STRING "ESP32 WiFi Bridge V1.10" #define IDENT_MAJOR 1 +// 1.10: starts and stops the radio under the entropy gate of wifi_radio.c, which this module +// does not use (radio_entropy_none.c). // 1.9: turns its radio off and on when asked (CMD_WIFI_DISABLE / CMD_WIFI_ENABLE) and // starts with it off until the Ultimate sends Enable or Autoconnect (or, without the // switch, asks for the connection state); after a restart of its own it puts the radio @@ -39,7 +41,7 @@ void send_keepalive(); // Disconnected forever. The Ultimate's updater only reflashes the module // when this differs from what the module reports, so a module change that // does not bump it is silently never installed. -#define IDENT_MINOR 9 +#define IDENT_MINOR 10 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 From 82a6568cbb0f443cd035b5942090cad4e706719a Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:28:59 -0500 Subject: [PATCH 49/95] Serve GET_RANDOM on the Ultimate 64 Elite II and C64 Ultimate as well as the U64 The UCI command, the dedicated reply channel and wifi_random now build for U64 == 2 too, and the U64-II Ultimate application compiles wifi_dedicated.cc and wifi_random.cc. Products without the WiFi module feature are unchanged. The GET_RANDOM E2E scenarios owed bytes on the U64 and U64 Elite only and required every other product to refuse, which an Ultimate 64-II no longer does. It now owes them too while its radio is on. It has no "WiFi Enabled" setting for the suite to read or set, so it is taken as it is, with the wifi_mac report as the sign that the module is up; a radio switched off in the menu makes the scenarios fail with the remedy in the message. NET_MAX_RANDOM, WIFI_RANDOM_MAX_BYTES and the module's RANDOM_MAX_BYTES are asserted equal. Co-Authored-By: Claude Opus 5.5 (1M context) --- software/io/network/network_target.cc | 5 +++-- software/io/network/network_target.h | 3 ++- software/io/wifi/wifi.cc | 2 +- software/io/wifi/wifi_cmd.cc | 6 +++--- software/io/wifi/wifi_cmd.h | 2 +- software/io/wifi/wifi_dedicated.h | 2 +- software/io/wifi/wifi_random.cc | 2 ++ software/io/wifi/wifi_random.h | 3 ++- software/test/wifi_reply/stubs/FreeRTOS.h | 3 +++ software/test/wifi_reply/stubs/dma_uart.h | 1 + target/u64ii/riscv/ultimate/Makefile | 2 ++ .../io/command_interface/net_target_test.py | 21 +++++++++++-------- 12 files changed, 33 insertions(+), 19 deletions(-) diff --git a/software/io/network/network_target.cc b/software/io/network/network_target.cc index 4caa3ef89..1c71c6139 100644 --- a/software/io/network/network_target.cc +++ b/software/io/network/network_target.cc @@ -12,7 +12,7 @@ #include "netdb.h" #include #include -#if U64 == 1 +#if U64 >= 1 #include "wifi_random.h" #endif @@ -435,7 +435,8 @@ void NetworkTarget :: get_random(Message *command, Message **reply, Message **st // The bytes come from the WiFi module's hardware generator and from // nowhere else, so without that module there are none. *status = &c_status_no_entropy; -#if U64 == 1 +#if U64 >= 1 + static_assert(NET_MAX_RANDOM == WIFI_RANDOM_MAX_BYTES, "the module's limit and the UCI's differ"); // The reply stays empty unless the result may carry data, and 87 stays // for any status not handled here. int result = wifi_get_random(data_message.message, length); diff --git a/software/io/network/network_target.h b/software/io/network/network_target.h index a7e0f1302..1c4a99a60 100644 --- a/software/io/network/network_target.h +++ b/software/io/network/network_target.h @@ -45,7 +45,8 @@ #define NET_FIRST_BLOCK_PAYLOAD (NET_MAX_REPLY_BLOCK - 2) // The most random bytes GET_RANDOM returns at once, which is what the WiFi -// module hands out per request (RANDOM_MAX_BYTES in its rpc_calls.h). +// module hands out per request (RANDOM_MAX_BYTES in software/wifi/common/rpc_shared.h; +// network_target.cc and wifi_random.cc assert the three agree). #define NET_MAX_RANDOM 512 #if NET_MAX_SOCKET_READ > NET_CMD_BUFSIZE diff --git a/software/io/wifi/wifi.cc b/software/io/wifi/wifi.cc index 3815f63aa..4922307f5 100644 --- a/software/io/wifi/wifi.cc +++ b/software/io/wifi/wifi.cc @@ -638,7 +638,7 @@ void wifi_free(void *driver, void *buffer) w->freeBuffer((command_buf_t *)buffer); } -#if U64 == 1 +#if U64 >= 1 bool wifi_module_ready(void) { return wifi.getState() >= eWifi_AppDetected; diff --git a/software/io/wifi/wifi_cmd.cc b/software/io/wifi/wifi_cmd.cc index 5af68f592..df020bcf7 100644 --- a/software/io/wifi/wifi_cmd.cc +++ b/software/io/wifi/wifi_cmd.cc @@ -4,7 +4,7 @@ /// C like functions to 'talk' with the WiFi Module uint16_t sequence_nr = 0; static wifi_reply_slot_t replySlots[WIFI_REPLY_SLOTS]; -#if U64 == 1 +#if U64 >= 1 QueueHandle_t dedicated_replies = NULL; volatile bool dedicated_waiting = false; #endif @@ -21,7 +21,7 @@ BaseType_t wifi_rx_isr(command_buf_context_t *context, command_buf_t *buf, BaseT rpc_header_t *hdr = (rpc_header_t *)buf->data; BaseType_t res; -#if U64 == 1 +#if U64 >= 1 if (hdr->thread == WIFI_DEDICATED_THREAD) { // pdFALSE makes the interrupt handler free the buffer. if (!dedicated_waiting) { @@ -96,7 +96,7 @@ void wifi_command_init(void) esp32.uart->FlowControl(true); esp32.uart->ClearRxBuffer(); esp32.uart->EnableSlip(true); -#if U64 == 1 +#if U64 >= 1 if (!dedicated_replies) { dedicated_replies = xQueueCreate(4, sizeof(dedicated_reply_t)); } diff --git a/software/io/wifi/wifi_cmd.h b/software/io/wifi/wifi_cmd.h index 16914423d..17d9803a8 100644 --- a/software/io/wifi/wifi_cmd.h +++ b/software/io/wifi/wifi_cmd.h @@ -81,7 +81,7 @@ extern uint16_t sequence_nr; // Not a reply slot (0 to WIFI_REPLY_SLOTS - 1), not 0xFF (no reply wanted), and not 0xFD to 0xFF, which // the HTTPS provider channels of CMD_IDENTIFY use (#936) #define WIFI_DEDICATED_THREAD 0xFC -#if U64 == 1 +#if U64 >= 1 typedef struct { command_buf_t *buf; uint32_t generation; diff --git a/software/io/wifi/wifi_dedicated.h b/software/io/wifi/wifi_dedicated.h index 8b2b9c055..5f031b762 100644 --- a/software/io/wifi/wifi_dedicated.h +++ b/software/io/wifi/wifi_dedicated.h @@ -25,7 +25,7 @@ typedef struct { void *context; } dedicated_call_t; -// Sends one request and waits for its answer. U64 only. +// Sends one request and waits for its answer. U64 == 1 and U64 == 2 (the Ultimate 64 Elite II and the C64 Ultimate) only. int wifi_dedicated_call(const dedicated_call_t *call); // Whether the module application has been detected. In wifi.cc. diff --git a/software/io/wifi/wifi_random.cc b/software/io/wifi/wifi_random.cc index 0bcb66eca..68221acd7 100644 --- a/software/io/wifi/wifi_random.cc +++ b/software/io/wifi/wifi_random.cc @@ -6,6 +6,8 @@ #include "rpc_calls.h" #include "wifi_random.h" +static_assert(WIFI_RANDOM_MAX_BYTES == RANDOM_MAX_BYTES, "the module's limit changed"); + int wifi_random_take_reply(const uint8_t *reply, int size, uint16_t sequence, uint8_t *buf, uint16_t len) { diff --git a/software/io/wifi/wifi_random.h b/software/io/wifi/wifi_random.h index fa8b803bb..531217063 100644 --- a/software/io/wifi/wifi_random.h +++ b/software/io/wifi/wifi_random.h @@ -8,8 +8,9 @@ // Fills buf with len bytes from the module's hardware random number generator // and returns 0, or returns one of the codes below and leaves buf untouched. -// U64 only. +// U64 == 1 and U64 == 2 (the Ultimate 64 Elite II and the C64 Ultimate) only. int wifi_get_random(uint8_t *buf, uint16_t len); +#define WIFI_RANDOM_MAX_BYTES 512 // the module's RANDOM_MAX_BYTES, asserted in wifi_random.cc #define WIFI_RANDOM_BUSY 1 // no answer in time; the module may be busy #define WIFI_RANDOM_REFUSED 2 // the module refused, or had no entropy source #define WIFI_RANDOM_INVALID 3 // the answer is not a well formed reply diff --git a/software/test/wifi_reply/stubs/FreeRTOS.h b/software/test/wifi_reply/stubs/FreeRTOS.h index 4c4f13777..3efaf927b 100644 --- a/software/test/wifi_reply/stubs/FreeRTOS.h +++ b/software/test/wifi_reply/stubs/FreeRTOS.h @@ -13,6 +13,9 @@ typedef long BaseType_t; typedef unsigned long TickType_t; typedef void *TaskHandle_t; typedef void *QueueHandle_t; +// The dedicated reply channel of wifi_cmd.cc (U64 >= 1) is not under test here +static inline QueueHandle_t xQueueCreate(int length, int item_size) { return NULL; } +static inline BaseType_t xQueueSendFromISR(QueueHandle_t q, const void *item, BaseType_t *w) { return 0; } #define pdFALSE 0 #define pdTRUE 1 #define portMAX_DELAY 0xFFFFFFFFUL diff --git a/software/test/wifi_reply/stubs/dma_uart.h b/software/test/wifi_reply/stubs/dma_uart.h index 7d5d325c8..78a0b4183 100644 --- a/software/test/wifi_reply/stubs/dma_uart.h +++ b/software/test/wifi_reply/stubs/dma_uart.h @@ -10,6 +10,7 @@ class DmaUART public: int buffers_free = 0; int transmitted = 0; + volatile uint32_t generation = 0; // U64 >= 1 builds of wifi_cmd.cc tag dedicated replies with it BaseType_t GetBuffer(command_buf_t **b, TickType_t t); void FreeBuffer(command_buf_t *b); void SetBaudRate(int b) {} diff --git a/target/u64ii/riscv/ultimate/Makefile b/target/u64ii/riscv/ultimate/Makefile index 59ff5e06a..337d413e1 100755 --- a/target/u64ii/riscv/ultimate/Makefile +++ b/target/u64ii/riscv/ultimate/Makefile @@ -200,6 +200,8 @@ SRCS_CC = u64ii_init.cc \ esp32.cc \ network_esp32.cc \ wifi_cmd.cc \ + wifi_random.cc \ + wifi_dedicated.cc \ wifi.cc \ sntp_time.cc \ $(PRJ).cc diff --git a/tests/e2e/io/command_interface/net_target_test.py b/tests/e2e/io/command_interface/net_target_test.py index 675fe1b0c..18e9ce6fb 100644 --- a/tests/e2e/io/command_interface/net_target_test.py +++ b/tests/e2e/io/command_interface/net_target_test.py @@ -1412,7 +1412,7 @@ def read_wifi_setting(device, info) -> object: """CFG_WIFI_ENABLED as the device reports it, or None where it has none. Asked only of the products that can owe bytes: the others either have no - such store or, on an Elite II, one whose Wi-Fi items are actions. + such store or, on an Ultimate 64-II, one whose Wi-Fi items are actions. """ if info.product not in U64_MK1_PRODUCTS: return None @@ -1439,7 +1439,8 @@ def read_duty(device, wifi_original: dict[str, str]) -> "RandomDuty": """What GET_RANDOM owes on this device, from its report. On an Ultimate 64 or Ultimate 64 Elite "WiFi Enabled" is set first, and its - stored value kept in `wifi_original` for the restore. A device that then cannot + stored value kept in `wifi_original` for the restore. An Ultimate 64-II has + no such setting and is taken as it is, radio on. A device that then cannot owe bytes fails this check, and the Failure is passed on for the GET_RANDOM scenarios to fail with. """ @@ -1453,7 +1454,7 @@ def read_duty(device, wifi_original: dict[str, str]) -> "RandomDuty": wifi_original[CFG_WIFI_ENABLED] = str(wifi_setting) device.configs.set(CFG_WIFI_CATEGORY, CFG_WIFI_ENABLED, "Enabled") wifi_setting = "Enabled" - if wifi_setting == "Enabled": + if wifi_setting == "Enabled" or info.product in U64_MK2_PRODUCTS: info = wait_for_wifi_mac(device, info) duty = random_duty(info) expected = ("has to hand out bytes" if duty.owed else "has to refuse with 87") @@ -1474,15 +1475,17 @@ class RandomDuty(NamedTuple): def random_duty(info) -> RandomDuty: """What a device with "WiFi Enabled" set has to answer to GET_RANDOM. - Only an Ultimate 64 or Ultimate 64 Elite draws bytes at all, so on any - other product a reply with bytes in it came from somewhere else, which + Only an Ultimate 64, Ultimate 64 Elite or Ultimate 64-II draws bytes at all, + so on any other product a reply with bytes in it came from somewhere else, which is the fallback the command must never have. On those two the bytes are owed, and one whose module never reported a wifi_mac fails rather than skips; otherwise a firmware that always refuses would pass. """ - owed = info.product in U64_MK1_PRODUCTS + owed = info.product in GET_RANDOM_PRODUCTS if owed and not reports_wifi_mac(info): - raise Failure(f"this {info.product} has {CFG_WIFI_ENABLED!r} set but reported no " + enabled = (f"has {CFG_WIFI_ENABLED!r} set" if info.product in U64_MK1_PRODUCTS + else "is taken as having its radio on") + raise Failure(f"this {info.product} {enabled} but reported no " f"wifi_mac in /v1/info within {WIFI_MAC_SECONDS:g}s, so its WiFi module " f"did not start. Check that the WiFi module is fitted and starts, " f"then run the suite again") @@ -1506,7 +1509,7 @@ def random_expected(net: Net, duty: RandomDuty) -> bool: with check(f"GET_RANDOM on this {duty.product} refuses rather than hand out bytes"): raise Failure(f"GET_RANDOM answered {STATUS_OK!r} with {len(probe.data)} bytes on " f"this {duty.product}, which has no source to draw them from: only an " - f"{' or '.join(U64_MK1_PRODUCTS)} does. The only correct answer " + f"{' or '.join(GET_RANDOM_PRODUCTS)} does. The only correct answer " f"here is {STATUS_NO_ENTROPY!r}, with no data") if not probe.status_text.startswith(STATUS_NO_ENTROPY_PREFIX): return True @@ -1515,7 +1518,7 @@ def random_expected(net: Net, duty: RandomDuty) -> bool: raise Failure(f"expected {STATUS_NO_ENTROPY!r}, got {probe.status_text!r}") check_start("GET_RANDOM hands out random bytes") check_skip(f"GET_RANDOM answered {probe.status_text[:2].decode()} on a device that owes " - f"no bytes: only an {' or '.join(U64_MK1_PRODUCTS)} serves them") + f"no bytes: only an {' or '.join(GET_RANDOM_PRODUCTS)} serves them") return False From 37611debf22a975f0d2c943857cd0e570f582718 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Wed, 14 Oct 2026 08:25:59 -0500 Subject: [PATCH 50/95] ESP32 bridge: TLS client sessions and the vendored Mozilla root store The bridge runs TLS 1.2/1.3 client sessions for the Ultimate: the ESP32 holds the handshake and the keys, the Ultimate moves the ciphertext. CMD_TLS_OPEN/STEP/CLOSE/STATS/CLOSE_ALL/SET_CA (0x30-0x35) go to their own task, so a handshake never blocks Wi-Fi TX. The engine is stock mbedTLS 4.1.1 as ESP-IDF 6 imports it (tls_engine.c). It refuses to open before the radio has started (no entropy), or in BUNDLE and CUSTOM mode without a trustworthy clock (SNTP, or the Ultimate's time in OPEN); the verdicts, downgrade checks and CA rules are in the code. The roots it trusts in BUNDLE mode are Mozilla's, vendored in software/wifi/ca_store/ (curl's cacert.pem, pinned by CA_PINS) instead of ESP-IDF's older copy. tools/ca_store/ca_store.py checks the store at every configure and every build, against the sdkconfig the build really uses; refresh.py regenerates it. software/esp_depends.py now hashes the store, so a refresh rebuilds the module in CI instead of handing back a cached binary. sdkconfig carries only the mbedTLS options the engine needs (TLS 1.3, client only, ChaCha-Poly, the custom bundle, no renegotiation, no TLS client in the supplicant). entropy_source_t and entropy_source() are the engine's gate and TLS_STATS's report. The module reports a new minor version, so the updater reflashes it. Host tests: tools/ca_store tests (make ca_store_test). The engine is exercised end to end by the E2E suite in the commits that follow. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/build.yml | 9 + Makefile | 8 +- software/wifi/ca_store/CA_PINS | 18 + software/wifi/ca_store/cacert.pem | 2950 ++++++++++++++++++ software/wifi/raw_u64/CMakeLists.txt | 19 + software/wifi/raw_u64/README.md | 64 + software/wifi/raw_u64/main/CMakeLists.txt | 8 +- software/wifi/raw_u64/main/rpc_calls.h | 168 + software/wifi/raw_u64/main/rpc_dispatch.c | 462 ++- software/wifi/raw_u64/main/rpc_dispatch.h | 12 +- software/wifi/raw_u64/main/sntp.c | 7 + software/wifi/raw_u64/main/sntp.h | 1 + software/wifi/raw_u64/main/tls_engine.c | 852 +++++ software/wifi/raw_u64/main/tls_engine.h | 71 + software/wifi/raw_u64/main/tls_engine_stub.c | 72 + software/wifi/raw_u64/sdkconfig | 51 +- tools/ca_store/ca_store.py | 480 +++ tools/ca_store/refresh.py | 377 +++ tools/ca_store/test_ca_store.py | 497 +++ tools/ca_store/test_refresh.py | 446 +++ 20 files changed, 6492 insertions(+), 80 deletions(-) create mode 100644 software/wifi/ca_store/CA_PINS create mode 100644 software/wifi/ca_store/cacert.pem create mode 100644 software/wifi/raw_u64/main/tls_engine.c create mode 100644 software/wifi/raw_u64/main/tls_engine.h create mode 100644 software/wifi/raw_u64/main/tls_engine_stub.c create mode 100644 tools/ca_store/ca_store.py create mode 100644 tools/ca_store/refresh.py create mode 100644 tools/ca_store/test_ca_store.py create mode 100644 tools/ca_store/test_refresh.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df1a9e27a..1f7a11297 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -184,6 +184,15 @@ jobs: docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp \ -v $GITHUB_WORKSPACE:/mnt/project:rw --workdir /mnt/project $IDF6_IMAGE make host_tests_idf6 + # The checks on the vendored root store the ESP32 bridge builds its certificate + # bundle from, and on the tool that refreshes it. Standard library only; in a + # stock Python image for the same reason as the lint step above. + - name: Test CA Store + run: | + docker run --rm -v $GITHUB_WORKSPACE:/mnt/project:rw --workdir /mnt/project \ + --user $(id -u):$(id -g) -e HOME=/tmp python:3.12-slim \ + python3 -m unittest discover -s tools/ca_store -p "test_*.py" + - name: Cache U2 FPGA id: cache-u2 uses: actions/cache@v6 diff --git a/Makefile b/Makefile index 6c951311a..d48117606 100755 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ OPENAPI = python3 tools/openapi/generate.py # make openapi_validate PYTHON=/path/to/venv/bin/python PYTHON ?= python3 -.PHONY: all app_space app_space_test d81_tracks_test observability_test lint_test host_tests host_tests_idf6 openapi openapi_check openapi_test openapi_validate +.PHONY: all app_space app_space_test d81_tracks_test observability_test lint_test host_tests host_tests_idf6 openapi openapi_check openapi_test openapi_validate ca_store_test all: esp32 u2_rv u2plus u2pl u64 u64ii @$(APP_SPACE) report @@ -91,6 +91,12 @@ host_tests: @$(MAKE) -C target/pc/linux/wifidedicated test @$(MAKE) -C target/pc/linux/getrandompaths test +# The Mozilla root store the ESP32 bridge (raw_u64) builds its certificate bundle from +# (software/wifi/ca_store). Its build checks the store at every configure; these are the +# tests of that check and of tools/ca_store/refresh.py. See software/wifi/raw_u64/README.md. +ca_store_test: + @python3 -m unittest discover -s tools/ca_store -p "test_*.py" + esp32: esp32_raw_u64 esp32_raw_c3 esp32_u64ctrl esp32_clean: esp32_raw_u64_clean esp32_raw_c3_clean esp32_u64ctrl_clean diff --git a/software/wifi/ca_store/CA_PINS b/software/wifi/ca_store/CA_PINS new file mode 100644 index 000000000..fb0ee3233 --- /dev/null +++ b/software/wifi/ca_store/CA_PINS @@ -0,0 +1,18 @@ +# The ESP32 bridge's TLS root store: cacert.pem beside this file (curl's extract of Mozilla's certdata.txt), the +# only input of the bundle (sdkconfig CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH). Every configure runs +# `tools/ca_store/ca_store.py check`, which fails the build on a mismatch; only refresh.py changes the two. +CA_SOURCE_URL=https://curl.se/ca/cacert.pem +# The "Certificate data from Mozilla as of:" line of cacert.pem, in UTC as ISO 8601. +CA_MOZILLA_DATE=2026-09-25T03:12:01Z +CA_SHA256=a41b5d356aea97a529fe27e0f7316d2f9d946d75927476cf9cf1b90637d00505 +# The certdata.txt, on GitHub, that cacert.pem was regenerated from with curl's mk-ca-bundle.pl +# to check it byte for byte: a second origin besides curl.se. +CA_CERTDATA_REF=mozilla-firefox/firefox@f6dd0159931e536991eaaa02d839bdffb92c3f22 +# sha256 over the sorted DER of every certificate in cacert.pem (the bundle's set): `check` fails when the set +# changes and this does not. refresh.py, which moves it, bumps IDENT_MINOR of every project attaching the +# bundle, since the updater reflashes a module only for a new version. +CA_BUNDLE_SET_SHA256=4e8015669428e25eef4dc88b4c7240a2466f9c9d84227fa7a7691d3904cf1aeb +# The ESP32 build warns when CA_MOZILLA_DATE is older than this, and a release build +# (RELEASE=1 in the environment of the configure step) fails. +# Mozilla's data changed at most 107 days apart in the ten updates to 2026-09-25. +CA_MAX_AGE_DAYS=180 diff --git a/software/wifi/ca_store/cacert.pem b/software/wifi/ca_store/cacert.pem new file mode 100644 index 000000000..4b694a502 --- /dev/null +++ b/software/wifi/ca_store/cacert.pem @@ -0,0 +1,2950 @@ +## +## Bundle of CA Root Certificates +## +## Certificate data from Mozilla as of: Fri Sep 25 03:12:01 2026 GMT +## +## Find updated versions here: https://curl.se/docs/caextract.html +## +## This is a bundle of X.509 certificates of public Certificate Authorities +## (CA). These were automatically extracted from Mozilla's root certificates +## file (certdata.txt). This file can be found in the mozilla source tree: +## https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/release/security/nss/lib/ckfw/builtins/certdata.txt +## +## It contains the certificates in PEM format and therefore +## can be directly used with curl / libcurl / php_curl, or with +## an Apache+mod_ssl webserver for SSL client authentication. +## Configure this file as the SSLCACertificateFile. +## +## Conversion done with mk-ca-bundle.pl version 1.33. +## SHA256: beb7e6dfe6499926e52c075c27bcfbe4c957f8609c575b3860273ae2806f63eb +## + + +COMODO ECC Certification Authority +================================== +-----BEGIN CERTIFICATE----- +MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC +R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE +ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB +dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix +GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR +Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo +b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X +4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni +wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E +BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG +FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA +U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY= +-----END CERTIFICATE----- + +NetLock Arany (Class Gold) FÅ‘tanúsítvány +======================================== +-----BEGIN CERTIFICATE----- +MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0G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CgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta +YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC +bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna +NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu +dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E= +-----END CERTIFICATE----- + +Microsec e-Szigno Root CA 2009 +============================== +-----BEGIN CERTIFICATE----- +MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER +MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv +c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o +dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE +BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt +U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw +DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA +fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG +0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA +pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm +1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC +AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf +QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE +FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o +lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX +I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775 +tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02 +yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi +LXpUq3DDfSJlgnCW +-----END CERTIFICATE----- + +GlobalSign Root CA - R3 +======================= +-----BEGIN CERTIFICATE----- +MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv +YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh +bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT +aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2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5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx +MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O +BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l +Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga +kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q +hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs +g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5 +aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5 +nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC +ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo +Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z +WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw== +-----END CERTIFICATE----- + +Go Daddy Root Certificate Authority - G2 +======================================== +-----BEGIN CERTIFICATE----- +MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT +B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29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eJ1usV2GDPO +LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1 +-----END CERTIFICATE----- + +Starfield Root Certificate Authority - G2 +========================================= +-----BEGIN CERTIFICATE----- +MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT +B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s +b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0 +eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw +DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg +VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB +dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv +W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs +bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk +N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf +ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU +JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC +AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol +TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx +4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw +F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K +pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ +c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0 +-----END CERTIFICATE----- + +Starfield Services Root Certificate Authority - G2 +================================================== +-----BEGIN CERTIFICATE----- +MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT +B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s +b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl +IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV +BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT +dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg +Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2 +h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa +hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP +LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB +rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw +AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG +SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP +E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy +xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd +iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza +YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6 +-----END CERTIFICATE----- + +Certum Trusted Network CA +========================= +-----BEGIN CERTIFICATE----- +MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK +ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy +MTIwNzM3WhcNMjkxM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- + +TWCA Root Certification Authority +================================= +-----BEGIN CERTIFICATE----- +MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ +VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG +EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB +IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK +AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx +QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC +oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP +4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r +y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB +BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG +9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC +mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW +QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY +T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny +Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw== +-----END CERTIFICATE----- + +Security Communication RootCA2 +============================== +-----BEGIN CERTIFICATE----- +MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc +U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh +dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC +SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy +aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB +ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++ ++T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R +3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV +spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K +EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8 +QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB +CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj +u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk +3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q +tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29 +mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03 +-----END CERTIFICATE----- + +Actalis Authentication Root CA +============================== +-----BEGIN CERTIFICATE----- +MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM +BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE +AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky +MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz +IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290 +IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ +wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa +by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6 +zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwuj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QbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz +lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem +OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9 +vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg== +-----END CERTIFICATE----- + +Buypass Class 2 Root CA +======================= +-----BEGIN CERTIFICATE----- +MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU +QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X +DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1 +eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw +DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1 +g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn +9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b +/+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU +CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff +awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9Jwnxg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xyYN +rJgWVqA= +-----END CERTIFICATE----- + +Buypass Class 3 Root CA +======================= +-----BEGIN CERTIFICATE----- +MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU +QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X +DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1 +eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw +DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH +sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR +5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh +7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ +ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH +2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV +/afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ +RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA +Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq +j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD +VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF +AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV +cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G +uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG +Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8 +ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2 +KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz +6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug +UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe +eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi +Cp/HuZc= +-----END CERTIFICATE----- + +T-TeleSec GlobalRoot Class 3 +============================ +-----BEGIN CERTIFICATE----- +MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM +IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU +cnVzd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6fUNOuIml +e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw== +-----END CERTIFICATE----- + +D-TRUST Root Class 3 CA 2 2009 +============================== +-----BEGIN CERTIFICATE----- +MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK +DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe +Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE +LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw +DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD +ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA +BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv +KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z +p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC +AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ +4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y +eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw +MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G +PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw +OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm +2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0 +o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV +dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph +X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I= +-----END CERTIFICATE----- + +D-TRUST Root Class 3 CA 2 EV 2009 +================================= +-----BEGIN CERTIFICATE----- +MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK +DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw +OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK +DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw +OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS +egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh +zRnp7hhPTFi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6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3 +zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0= +-----END CERTIFICATE----- + +T-TeleSec GlobalRoot Class 2 +============================ +-----BEGIN CERTIFICATE----- +MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM +IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU +cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx +MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz +dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD +ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ +SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F +vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970 +2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV +WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA +MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy +YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4 +r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf +vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR +3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN +9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg== +-----END CERTIFICATE----- + +QuoVadis Root CA 1 G3 +===================== +-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG +A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv +b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN +MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg +RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE +PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm +PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6 +Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hS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bJWqNjZgKAvQU6 +O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0 +FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV +hMJKzRwuJIczYOXD +-----END CERTIFICATE----- + +QuoVadis Root CA 2 G3 +===================== +-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG +A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv +b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN +MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg +RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh +ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY +NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t +oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o +MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l +V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo +L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT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IDAQABo0IwQDAPBgNVHRMBAf8EBTAD +AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI +hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px +KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS +t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ +TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du +DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib +Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD +hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX +0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW +dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2 +PpxxVJkES/1Y+Zj0 +-----END CERTIFICATE----- + +DigiCert Assured ID Root G2 +=========================== +-----BEGIN CERTIFICATE----- +MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw +IgYDVQQDExtEaWdpQ2VydCBBc3N1c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FICATE----- + +DigiCert Assured ID Root G3 +=========================== +-----BEGIN CERTIFICATE----- +MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV +UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD +VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1 +MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ +BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb +RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs +KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF +UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy +YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy +1vUhZscv6pZjamVFkpUBtA== +-----END CERTIFICATE----- + +DigiCert Global Root G2 +======================= +-----BEGIN CERTIFICATE----- +MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw +HgYDVQQDExdEaW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MrY= +-----END CERTIFICATE----- + +DigiCert Global Root G3 +======================= +-----BEGIN CERTIFICATE----- +MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV +UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD +VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw +MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k +aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C +AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O +YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP +BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp +Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y +3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34 +VOKa5Vt8sycX +-----END CERTIFICATE----- + +DigiCert Trusted Root G4 +======================== +-----BEGIN CERTIFICATE----- +MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw +HwYDVQQDEx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EMBQAD +ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY +ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr +yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy +7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah +ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN +5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb +/UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa +5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK +G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP +82Z+ +-----END CERTIFICATE----- + +COMODO RSA Certification Authority +================================== +-----BEGIN CERTIFICATE----- +MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE +BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG +A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBh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yTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt +rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+ +nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg +tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW +sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp +pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA +zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq +ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52 +7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I +LaZRfyHBNVOFBkpdn627G190 +-----END CERTIFICATE----- + +USERTrust RSA Certification Authority +===================================== +-----BEGIN CERTIFICATE----- +MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE +BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK +ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE +BhMCVVMxEzARBgNVBAgTCk5ldyBK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oBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ +7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ +Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM +8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi +FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi +yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c +J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw +sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx +Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9 +-----END CERTIFICATE----- + +USERTrust ECC Certification Authority +===================================== +-----BEGIN CERTIFICATE----- +MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC +VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU +aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC +VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR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nVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd +BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx +uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7 +yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3 +-----END CERTIFICATE----- + +IdenTrust Commercial Root CA 1 +============================== +-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG +EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS +b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES +MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB +IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld +hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/ +mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi +1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C +XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl +3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kz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6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R +cGzM7vRX+Bi6hG6H +-----END CERTIFICATE----- + +IdenTrust Public Sector Root CA 1 +================================= +-----BEGIN CERTIFICATE----- +MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG +EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv +ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV +UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS +b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy +P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6 +Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI +rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf +qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS +mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn +ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh +LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v +iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQR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EvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB +ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q +ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua +4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG +E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX +BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn +aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy +PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX +kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C +ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su +-----END CERTIFICATE----- + +OISTE WISeKey Global Root GB CA +=============================== +-----BEGIN CERTIFICATE----- +MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG +EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl +ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw +MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD +VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds +b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX +scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP +rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk +9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o +Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg +GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB +/zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI +hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD +dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0 +VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui +HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic +Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM= +-----END CERTIFICATE----- + +SZAFIR ROOT CA2 +=============== +-----BEGIN CERTIFICATE----- +M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UNLUYfrVFdvXn4dRVOul +4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6 ++/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw== +-----END CERTIFICATE----- + +Certum Trusted Network CA 2 +=========================== +-----BEGIN CERTIFICATE----- +MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE +BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1 +bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y +ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ +TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl +cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB +IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9 +7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o +CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b +Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p +uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130 +GO6IyY0XRSmZMnUCMe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4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7 +zAYspsbiDrW5viSP +-----END CERTIFICATE----- + +Hellenic Academic and Research Institutions RootCA 2015 +======================================================= +-----BEGIN CERTIFICATE----- +MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT +BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0 +aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl +YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx +MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg +QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV +BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw +MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv +bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh +iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+ +6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd +FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr +i5WY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KpXMgwDqvkPGa +JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q +p/UsQu0yrbYhnr68 +-----END CERTIFICATE----- + +Hellenic Academic and Research Institutions ECC RootCA 2015 +=========================================================== +-----BEGIN CERTIFICATE----- +MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0 +aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u +cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj +aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw +MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj +IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD +VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290 +Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP +dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK +Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O +BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA +GiecMjvAwNW6qef4BENThe5SId6d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EZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH +FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ +gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t +dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce +VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB +/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3 +DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM +CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy +8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa +2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2 +xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5 +-----END CERTIFICATE----- + +Amazon Root CA 2 +================ +-----BEGIN CERTIFICATE----- +MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD +VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24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HWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY ++gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE +YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW +xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ +gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW +aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV +Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3 +KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi +JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw= +-----END CERTIFICATE----- + +Amazon Root CA 3 +================ +-----BEGIN CERTIFICATE----- +MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG +EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy +NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ +MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB +f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr +Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43 +rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc +eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw== +-----END CERTIFICATE----- + +Amazon Root CA 4 +================ +-----BEGIN CERTIFICATE----- +MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG +EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy +NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ +MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN +/sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri +83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV +HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA +MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1 +AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA== +-----END CERTIFICATE----- + +TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1 +============================================= +-----BEGIN CERTIFICATE----- +MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA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gEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ +KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh +AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc +lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R +e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j +q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM= +-----END CERTIFICATE----- + +GDCA TrustAUTH R5 ROOT +====================== +-----BEGIN CERTIFICATE----- +MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw +BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD +DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow +YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ +IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs +AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p +OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9c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I7XpTrXmKGcjBBV09tL7ECQ +8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv +/EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT +aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g== +-----END CERTIFICATE----- + +SSL.com Root Certification Authority RSA +======================================== +-----BEGIN CERTIFICATE----- +MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM +BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x +MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw +MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx +EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM +LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C +Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8 +P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge +oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5H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/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI +Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y +wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI +WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k= +-----END CERTIFICATE----- + +SSL.com Root Certification Authority ECC +======================================== +-----BEGIN CERTIFICATE----- +MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV +BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv +BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy +MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO +BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv +bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA +BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+ +8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR +hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT +jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW +e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z +5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl +-----END CERTIFICATE----- + +SSL.com EV Root Certification Authority RSA R2 +============================================== +-----BEGIN CERTIFICATE----- +MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w +DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u +MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy +MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI +DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD +VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN +BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh +hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w +cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO +Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+ +B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh +CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83Xq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wApRmLER/y5UnlhetCTCstnEXbosX +9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w== +-----END CERTIFICATE----- + +SSL.com EV Root Certification Authority ECC +=========================================== +-----BEGIN CERTIFICATE----- +MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV +BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy +BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw +MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx +EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM +LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB +BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy +3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O +BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe +5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ +N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm +m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg== +-----END CERTIFICATE----- + +GlobalSign Root CA - R6 +======================= +-----BEGIN CERTIFICATE----- +MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX +R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds +b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i +YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs +U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss +grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE +3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF +vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM +PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+ +azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O +WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy +CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP +0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN +b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE +AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV +HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN +nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0 +lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY +BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym +Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr +3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1 +0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T +uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK +oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t +JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA= +-----END CERTIFICATE----- + +OISTE WISeKey Global Root GC CA +=============================== +-----BEGIN CERTIFICATE----- +MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD +SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo +MCYGA1UEAxMfT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FFJqIRNow6rSn4+7vW4LVPtateJLbXDzz2K36uGt/xDYotgIVilQsnLAX +c47QN6MUPJiVAAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo +jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk +bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x +ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn +RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A== +-----END CERTIFICATE----- + +UCA Extended Validation Root +============================ +-----BEGIN CERTIFICATE----- +MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG +EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u +IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G +A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi +MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs +iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF +Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu +eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dks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mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2CxR9GUeOc +GMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi +djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr +dhh2n1ax +-----END CERTIFICATE----- + +Certigna Root CA +================ +-----BEGIN CERTIFICATE----- +MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE +BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ +MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda +MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz +MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC +DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX +stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz +KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8 +JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16 +XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq +4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT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TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH +hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG +MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2 +vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q +NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q ++Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih +U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx +iN66zB+Afko= +-----END CERTIFICATE----- + +emSign ECC Root CA - G3 +======================= +-----BEGIN CERTIFICATE----- +MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG +A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg +MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4 +MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11 +ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g +RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc +58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr +MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC +AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D +CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7 +jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj +-----END CERTIFICATE----- + +emSign Root CA - C1 +=================== +-----BEGIN CERTIFICATE----- +MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx +EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp +Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE +BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD +ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up +ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/ +Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX +OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V +I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms +lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+ +XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD +ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp +/6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1 +NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9 +wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ +BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI= +-----END CERTIFICATE----- + +emSign ECC Root CA - C3 +======================= +-----BEGIN CERTIFICATE----- +MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG +A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF +Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE +BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD +ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd +6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9 +SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA +B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA +MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU +ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ== +-----END CERTIFICATE----- + +Hongkong Post Root CA 3 +======================= +-----BEGIN CERTIFICATE----- +MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG +A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK +Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2 +MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv +bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX +SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz +iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf +jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim +5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe +sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj +0mRiikKYvL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urQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB +60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq +dBb9HxEGmpv0 +-----END CERTIFICATE----- + +Microsoft ECC Root Certificate Authority 2017 +============================================= +-----BEGIN CERTIFICATE----- +MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV +UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND +IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4 +MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw +NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ +BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6 +thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB +eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM ++Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf +Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR +eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M= +-----END CERTIFICATE----- + +Microsoft RSA Root Certificate Authority 2017 +============================================= +-----BEGIN CERTIFICATE----- +MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG +EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg +UlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIw +NzE4MjMwMDIzWjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u +MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcw +ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZNt9GkMml +7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0ZdDMbRnMlfl7rEqUrQ7e +S0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw7 +1VdyvD/IybLeS2v4I2wDwAW9lcfNcztmgGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+ +dkC0zVJhUXAoP8XFWvLJjEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49F +yGcohJUcaDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaGYaRS +MLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6W6IYZVcSn2i51BVr +lMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4KUGsTuqwPN1q3ErWQgR5WrlcihtnJ +0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH+FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJ +ClTUFLkqqNfs+avNJVgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw +DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC +NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og +6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80 +dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk ++ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex +/2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy +AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW +ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE +7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT +c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D +5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E +-----END CERTIFICATE----- + +e-Szigno Root CA 2017 +===================== +-----BEGIN CERTIFICATE----- +MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgN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GzcgbJceaBxXntC6Z5 +8hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+cNywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5 +BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW +atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU +Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M +NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N +0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc= +-----END CERTIFICATE----- + +NAVER Global Root Certification Authority +========================================= +-----BEGIN CERTIFICATE----- +MIIFojCCA4qgAwIBAgIUAZQwHqIL3fXFMyqxQ0Rx+NZQTQ0wDQYJKoZIhvcNAQEMBQAwaTELMAkG +A1UEBhMCS1IxJjAkBgNVBAoMHU5BVkVSIEJVU0lORVNTIFBMQVRGT1JNIENvcnAuMTIwMAYDVQQD +DClOQVZFUiBHbG9iYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MTgwODU4 +NDJaFw0zNzA4MTgyMzU5NTlaMGkxCzAJBgNVBAYTAktSMSYwJAYDVQQKDB1OQVZFUiBCVVNJTkVT +UyBQTEFURk9STSBDb3JwLjEyMDAGA1UEAwwpTkFWRVIgR2xvYmFsIFJvb3QgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC21PGTXLVAiQqrDZBb +UGOukJR0F0Vy1ntlWilLp1agS7gvQnXp2XskWjFlqxcX0TM62RHcQDaH38dq6SZeWYp34+hInDEW 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330DTH +D8z7p/8Dvq1wkNoL3chtl1+afwkyQf3NosxabUzyqkn+Zvjp2DXrDige7kgvOtB5CTh8piKCk5XQ +A76+AqAF3SAi428diDRgxuYKuQl1C/AH6GmWNcf7I4GOODm4RStDeKLRLBT/DShycpWbXgnbiUSY +qqFJu3FS8r/2/yehNq+4tneI3TqkbZs0kNwUXTC/t+sX5Ie3cdCh13cV1ELX8vMxmV2b3RZtP+oG +I/hGoiLtk/bdmuYqh7GYVPEi92tF4+KOdh2ajcQGjTa3FPOdVGm3jjzVpG2Tgbet9r1ke8LJaDmg +kpzNNIaRkPpkUZ3+/uul9XXeifdy +-----END CERTIFICATE----- + +AC RAIZ FNMT-RCM SERVIDORES SEGUROS +=================================== +-----BEGIN CERTIFICATE----- +MIICbjCCAfOgAwIBAgIQYvYybOXE42hcG2LdnC6dlTAKBggqhkjOPQQDAzB4MQswCQYDVQQGEwJF +UzERMA8GA1UECgwIRk5NVC1SQ00xDjAMBgNVBAsMBUNlcmVzMRgwFgYDVQRhDA9WQVRFUy1RMjgy +NjAwNEoxLDAqBgNVBAMMI0FDIFJBSVogRk5NVC1SQ00gU0VSVklET1JFUyBTRUdVUk9TMB4XDTE4 +MTIyMDA5MzczM1oXDTQzMTIyMDA5MzczM1oweDELMAkGA1UEBhMCRVMxETAPBgNVBAoMCEZOTVQt +UkNNMQ4wDAYDVQQLDAVDZXJlczEYMBYGA1UEYQwPVkFURVMtUTI4MjYwMDRKMSwwKgYDVQQDDCNB +QyBSQUlaIEZOTVQtUkNNIFNFUlZJRE9SRVMgU0VHVVJPUzB2MBAGByqGSM49AgEGBSuBBAAiA2IA +BPa6V1PIyqvfNkpSIeSX0oNnnvBlUdBeh8dHsVnyV0ebAAKTRBdp20LHsbI6GA60XYyzZl2hNPk2 +LEnb80b8s0RpRBNm/dfF/a82Tc4DTQdxz69qBdKiQ1oKUm8BA06Oi6NCMEAwDwYDVR0TAQH/BAUw +AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDV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ICATE----- + +GlobalSign Root E46 +=================== +-----BEGIN CERTIFICATE----- +MIICCzCCAZGgAwIBAgISEdK7ujNu1LzmJGjFDYQdmOhDMAoGCCqGSM49BAMDMEYxCzAJBgNVBAYT +AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJvb3Qg +RTQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAXBgNV +BAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBFNDYwdjAQBgcq +hkjOPQIBBgUrgQQAIgNiAAScDrHPt+ieUnd1NPqlRqetMhkytAepJ8qUuwzSChDH2omwlwxwEwkB +jtjqR+q+soArzfwoDdusvKSGN+1wCAB16pMLey5SnCNoIwZD7JIvU4Tb+0cUB+hflGddyXqBPCCj +QjBAMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQxCpCPtsad0kRL +gLWi5h+xEk8blTAKBggqhkjOPQQDAwNoADBlAjEA31SQ7Zvvi5QCkxeCmb6zniz2C5GMn0oUsfZk +vLtoURMMA/cVi4RguYv/Uo7njLwcAjA8+RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+ +CAezNIm8BZ/3Hobui3A= +-----END CERTIFICATE----- + +ANF Secure Server Root CA +========================= +-----BEGIN CERTIFICATE----- +MIIF7zCCA9egAwIBAgIIDdPjvGz5a7EwDQYJKoZIhvcNAQELBQAwgYQxEjAQBgNVBAUTCUc2MzI4 +NzUxMDELMAkGA1UEBhMCRVMxJzAlBgNVBAoTHkFORiBBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lv +bjEUMBIGA1UECxMLQU5GIENBIFJhaXoxIjAgBgNVBAMTGUFORiBTZWN1cmUgU2VydmVyIFJvb3Qg +Q0EwHhcNMTkwOTA0MTAwM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BgNVHQ8BAf8E +BAMCAYYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEATh65isagmD9uw2nAalxJ +UqzLK114OMHVVISfk/CHGT0sZonrDUL8zPB1hT+L9IBdeeUXZ701guLyPI59WzbLWoAAKfLOKyzx +j6ptBZNscsdW699QIyjlRRA96Gejrw5VD5AJYu9LWaL2U/HANeQvwSS9eS9OICI7/RogsKQOLHDt +dD+4E5UGUcjohybKpFtqFiGS3XNgnhAY3jyB6ugYw3yJ8otQPr0R4hUDqDZ9MwFsSBXXiJCZBMXM +5gf0vPSQ7RPi6ovDj6MzD8EpTBNO2hVWcXNyglD2mjN8orGoGjR0ZVzO0eurU+AagNjqOknkJjCb +5RyKqKkVMoaZkgoQI1YS4PbOTOK7vtuNknMBZi9iPrJyJ0U27U1W45eZ/zo1PqVUSlJZS2Db7v54 +EX9K3BR5YLZrZAPbFYPhor72I5dQ8AkzNqdxliXzuUJ92zg/LFis6ELhDtjTO0wugumDLmsx2d1H +hk9tl5EuT+IocTUW0fJz/iUrB0ckYyfI+PbZa/wSMVYIwFNCr5zQM378BvAxRAMU8Vjq8moNqRGy +g77FGr8H6lnco4g175x2MjxNBiLOFeXdntiP2t7SxDnlF4HPOEfrf4htWRvfn0IUrn7PqLBmZdo3 +r5+qPeoott7VMVgWglvquxl1AnMaykgaIZOQCo6ThKd9OyMYkomgjaw= +-----END CERTIFICATE----- + +Certum EC-384 CA +================ +-----BEGIN CERTIFICATE----- +MIICZTCCAeugAwIBAgIQeI8nXIESUiClBNAt3bpz9DAKBggqhkjOPQQDAzB0MQswCQYDVQQGEwJQ +TDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2Vy +dGlmaWNhdGlvbiBBdXRob3JpdHkxGTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwHhcNMTgwMzI2 +MDcyNDU0WhcNNDMwMzI2MDcyNDU0WjB0MQswCQYDVQQGEwJQTDEhMB8GA1UEChMYQXNzZWNvIERh +dGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx +GTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATEKI6rGFtq +vm5kN2PkzeyrOvfMobgOgknXhimfoZTy42B4mIF4Bk3y7JoOV2CDn7TmFy8as10CW4kjPMIRBSqn +iBMY81CE1700LCeJVf/OTOffph8oxPBUw7l8t1Ot68KjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD +VR0OBBYEFI0GZnQkdjrzife81r1HfS+8EF9LMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNo +ADBlAjADVS2m5hjEfO/JUG7BJw+ch69u1RsIGL2SKcHvlJF40jocVYli5RsJHrpka/F2tNQCMQC0 +QoSZ/6vnnvuRlydd3LBbMHHOXjgaatkl5+r3YZJW+OraNsKHZZYuciUvf9/DE8k= +-----END CERTIFICATE----- + +Certum Trusted Root CA +====================== +-----BEGIN CERTIFICATE----- +MIIFwDCCA6igAwIBAgIQHr9ZULjJgDdMBvfrVU+17TANBgkqhkiG9w0BAQ0FADB6MQswCQYDVQQG +EwJQTDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0g +Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0Ew +HhcNMTgwMzE2MTIxMDEzWhcNNDMwMzE2MTIxMDEzWjB6MQswCQYDVQQGEwJQTDEhMB8GA1UEChMY +QXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBB +dXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ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EZtdmYu65x +xBzndFlY7wyJz4sfdZMaBBSSSFCp61cpABbjNhzI+L/wM9VBD8TMPN3pM0MBkRArHtG5Xc0yGYuP +jCB31yLEQtyEFpslbei0VXF/sHyz03FJuc9SpAQ/3D2gu68zngowYI7bnV2UqL1g52KAdoGDDIzM +MEZJ4gzSqK/rYXHv5yJiqfdcZGyfFoxnNidF9Ql7v/YQCvGwjVRDjAS6oz/v4jXH+XTgbzRB0L9z +ZVcg+ZtnemZoJE6AZb0QmQZZ8mWvuMZHu/2QeItBcy6vVR/cO5JyboTT0GFMDcx2V+IthSIVNg3r +AZ3r2OvEhJn7wAzMMujjd9qDRIueVSjAi1jTkD5OGwDxFa2DK5o= +-----END CERTIFICATE----- + +HARICA TLS RSA Root CA 2021 +=========================== +-----BEGIN CERTIFICATE----- +MIIFpDCCA4ygAwIBAgIQOcqTHO9D88aOk8f0ZIk4fjANBgkqhkiG9w0BAQsFADBsMQswCQYDVQQG +EwJHUjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u +cyBDQTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBSU0EgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTEwNTUz +OFoXDTQ1MDIxMzEwNTUzN1owbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRl +bWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgUlNB +IFJvb3QgQ0EgMjAyMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAIvC569lmwVnlskN +JLnQDmT8zuIkGCyEf3dRywQRNrhe7Wlxp57kJQmXZ8FHws+RFjZiPTgE4VGC/6zStGndLuwRo0Xu +a2s7TL+MjaQenRG56Tj5eg4MmOIjHdFOY9TnuEFE+2uva9of08WRiFukiZLRgeaMOVig1mlDqa2Y +Ulhu2wr7a89o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0 +qPzVMIho7suuyWPEdr6sOBjhXlzPrjoiUevRi7PzKzMHVIf6tLITe7pTBGIBnfHAT+7hOtSLIBD6 +Alfm78ELt5BGnBkpjNxvoEppaZS3JGWg/6w/zgH7IS79aPib8qXPMThcFarmlwDB31qlpzmq6YR/ +PFGoOtmUW4y/Twhx5duoXNTSpv4Ao8YWxw/ogM4cKGR0GQjTQuPOAF1/sdwTsOEFy9EgqoZ0njnn +kf3/W9b3raYvAwtt41dU63ZTGI0RmLo= +-----END CERTIFICATE----- + +HARICA TLS ECC Root CA 2021 +=========================== +-----BEGIN CERTIFICATE----- +MIICVDCCAdugAwIBAgIQZ3SdjXfYO2rbIvT/WeK/zjAKBggqhkjOPQQDAzBsMQswCQYDVQQGEwJH +UjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBD +QTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBFQ0MgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTExMDExMFoX +DTQ1MDIxMzExMDEwOVowbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRlbWlj +IGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgRUNDIFJv +b3QgQ0EgMjAyMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABDgI/rGgltJ6rK9JOtDA4MM7KKrxcm1l +AEeIhPyaJmuqS7psBAqIXhfyVYf8MLA04jRYVxqEU+kw2anylnTDUR9YSTHMmE5gEYd103KUkE+b +ECUqqHgtvpBBWJAVcqeht6NCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUyRtTgRL+BNUW +0aq8mm+3oJUZbsowDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2cAMGQCMBHervjcToiwqfAi +rcJRQO9gcS3ujwLEXQNwSaSS6sUUiHCm0w2wqsosQJz76YJumgIwK0eaB8bRwoF8yguWGEEbo/Qw +CZ61IygNnxS2PFOiTAZpffpskcYqSUXm7LcT4Tps +-----END CERTIFICATE----- + +Autoridad de Certificacion Firmaprofesional CIF A62634068 +========================================================= +-----BEGIN CERTIFICATE----- +MIIGFDCCA/ygAwIBAgIIG3Dp0v+ubHEwDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCRVMxQjBA +BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2 +MjYzNDA2ODAeFw0xNDA5MjMxNTIyMDdaFw0zNjA1MDUxNTIyMDdaMFExCzAJBgNVBAYTAkVTMUIw +QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB +NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD +Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P +B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY +7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH +ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI +plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX +MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX +LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmt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qtjTcNAuuuuUavpf +NIbnYrX9ivAwhZTJryQCL2/W3Wf+47BVTwSYT6RBVuKT0Gro1vP7ZeDOdcQxWQzugsgMYDNKGbqE +ZycPvEJdvSRUDewdcAZfpLz6IHxV +-----END CERTIFICATE----- + +vTrus ECC Root CA +================= +-----BEGIN CERTIFICATE----- +MIICDzCCAZWgAwIBAgIUbmq8WapTvpg5Z6LSa6Q75m0c1towCgYIKoZIzj0EAwMwRzELMAkGA1UE +BhMCQ04xHDAaBgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xGjAYBgNVBAMTEXZUcnVzIEVDQyBS +b290IENBMB4XDTE4MDczMTA3MjY0NFoXDTQzMDczMTA3MjY0NFowRzELMAkGA1UEBhMCQ04xHDAa +BgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xGjAYBgNVBAMTEXZUcnVzIEVDQyBSb290IENBMHYw +EAYHKoZIzj0CAQYFK4EEACIDYgAEZVBKrox5lkqqHAjDo6LN/llWQXf9JpRCux3NCNtzslt188+c +ToL0v/hhJoVs1oVbcnDS/dtitN9Ti72xRFhiQgnH+n9bEOf+QP3A2MMrMudwpremIFUde4BdS49n +TPEQo0IwQDAdBgNVHQ4EFgQUmDnNvtiyjPeyq+GtJK97fKHbH88wDwYDVR0TAQH/BAUwAwEB/zAO +BgNVHQ8BAf8EBAMCAQYwCgYIKoZIzj0EAwMDaAAwZQIwV53dVvHH4+m4SVBrm2nDb+zDfSXkV5UT +QJtS0zvzQBm8JsctBp61ezaf9SXUY2sAAjEA6dPGnlaaKsyh2j/IZivTWJwghfqrkYpwcBE4YGQL +YgmRWAD5Tfs0aNoJrSEGGJTO +-----END CERTIFICATE----- + +vTrus Root CA +============= +-----BEGIN CERTIFICATE----- +MIIFVjCCAz6gAwIBAgIUQ+NxE9izWRRdt86M/TX9b7wFjUUwDQYJKoZIhvcNAQELBQAwQzELMAkG +A1UEBhMCQ04xHDAaBgNVBAoTE2lUcnVzQ2hpbmEgQ28uL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Fww+SX8J+pJdVrnjT+5hpk9jprUrIQeBqfTNqK2uwcN1LgQkv7bHbKJAs5EhWd +nxEt/Hlk3ODg9d3gV8mlsnZwUKT+twpw1aA08XXXTUm6EdGz2OyC/+sOxL9kLX1jbhd47F18iMjr +jld22VkE+rxSH0Ws8HqA7Oxvdq6R2xCOBNyS36D25q5J08FsEhvMKar5CKXiNxTKsbhm7xqC5PD4 +8acWabfbqWE8n/Uxy+QARsIvdLGx14HuqCaVvIivTDUHKgLKeBRtRytAVunLKmChZwOgzoy8sHJn +xDHO2zTlJQNgJXtxmOTAGytfdELSS8VZCAeHvsXDf+eW2eHcKJfWjwXj9ZtOyh1QRwVTsMo554Wg +icEFOwE30z9J4nfrI8iIZjs9OXYhRvHsXyO466JmdXTBQPfYaJqT4i2pLr0cox7IdMakLXogqzu4 +sEb9b91fUlV1YvCXoHzXOP0l382gmxDPi7g4Xl7FtKYCNqEeXxzP4padKar9mK5S4fNBUvupLnKW +nyfjqnN9+BojZns7q2WwMgFLFT49ok8MKzWixtlnEjUwzXYuFrOZnk1PTi07NEPhmg4NpGaXutIc +SkwsKouLgU9xGqndXHt7CMUADTdA43x7VF8vhV929vensBxXVsFy6K2ir40zSbofitzmdHxghm+H +l3s= +-----END CERTIFICATE----- + +ISRG Root X2 +============ +-----BEGIN CERTIFICATE----- +MIICGzCCAaGgAwIBAgIQQdKd0XLq7qeAwSxs6S+HUjAKBggqhkjOPQQDAzBPMQswCQYDVQQGEwJV +UzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElT +UkcgUm9vdCBYMjAeFw0yMDA5MDQwMDAwMDBaFw00MDA5MTcxNjAwMDBaME8xCzAJBgNVBAYTAlVT +MSkwJwYDVQQKEyBJbnRlcm5ldCBTZWN1cml0eSBSZXNlYXJjaCBHcm91cDEVMBMGA1UEAxMMSVNS +RyBSb290IFgyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEzZ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N0aqwdmaTd5a+g744tiROJgvM7XpWGuDpWsZkrUx6AEhEL7lAuxM+vhV4nYWBSipX3tUZQ9rb +yltHhoMLP7YNdnhzeSJesYAfz77RP1YQmCuVh6EfnWQUYDksswBVLuT1sw5XxJFBAJw/6KXf6vb/ +yPCtbVKoF6ubYfwSUTXkJf2vqmqGOQ== +-----END CERTIFICATE----- + +GlobalSign ECC Root CA - R4 +=========================== +-----BEGIN CERTIFICATE----- +MIIB3DCCAYOgAwIBAgINAgPlfvU/k/2lCSGypjAKBggqhkjOPQQDAjBQMSQwIgYDVQQLExtHbG9i +YWxTaWduIEVDQyBSb290IENBIC0gUjQxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds +b2JhbFNpZ24wHhcNMTIxMTEzMDAwMDAwWhcNMzgwMTE5MDMxNDA3WjBQMSQwIgYDVQQLExtHbG9i +YWxTaWduIEVDQyBSb290IENBIC0gUjQxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds +b2JhbFNpZ24wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAS4xnnTj2wlDp8uORkcA6SumuU5BwkW +ymOxuYb4ilfBV85C+nOh92VC/x7BALJucw7/xyHlGKSq2XE/qNS5zowdo0IwQDAOBgNVHQ8BAf8E +BAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVLB7rUW44kB/+wpu+74zyTyjhNUwCgYI +KoZIzj0EAwIDRwAwRAIgIk90crlgr/HmnKAWBVBfw147bmF0774BxL4YSFlhgjICICadVGNA3jdg +UM/I2O2dgq43mLyjj0xMqTQrbO/7lZsm +-----END CERTIFICATE----- + +GTS Root R1 +=========== +-----BEGIN CERTIFICATE----- +MIIFVzCCAz+gAwIBAgINAgPlk28xsBNJiGuiFzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQGEwJV +UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR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rsUecrNIdSUtUlD +-----END CERTIFICATE----- + +Telia Root CA v2 +================ +-----BEGIN CERTIFICATE----- +MIIFdDCCA1ygAwIBAgIPAWdfJ9b+euPkrL4JWwWeMA0GCSqGSIb3DQEBCwUAMEQxCzAJBgNVBAYT +AkZJMRowGAYDVQQKDBFUZWxpYSBGaW5sYW5kIE95ajEZMBcGA1UEAwwQVGVsaWEgUm9vdCBDQSB2 +MjAeFw0xODExMjkxMTU1NTRaFw00MzExMjkxMTU1NTRaMEQxCzAJBgNVBAYTAkZJMRowGAYDVQQK +DBFUZWxpYSBGaW5sYW5kIE95ajEZMBcGA1UEAwwQVGVsaWEgUm9vdCBDQSB2MjCCAiIwDQYJKoZI +hvcNAQEBBQADggIPADCCAgoCggIBALLQPwe84nvQa5n44ndp586dpAO8gm2h/oFlH0wnrI4AuhZ7 +6zBqAMCzdGh+sq/H1WKzej9Qyow2RCRj0jbpDIX2Q3bVTKFgcmfiKDOlyzG4OiIjNLh9vVYiQJ3q +9HsDrWj8soFPmNB06o3lfc1jw6P23pLCWBnglrvFxKk9pXSW/q/5iaq9lRdU2HhE8Qx3FZLgmEKn +pNaqIJLNwaCzlrI6hEKNfdWV5Nbb6WLEWLN5xYzTNTODn3WhUidhOPFZPY5Q4L15POdslv5e2QJl +tI5c0BE0312/UqeBAMN/mUWZFdUXyApT7GPzmX3MaRKGwhfwAZ6/hLzRUssbkmbOpFPlob/E2wnW +5olWK8jjfN7j/4nlNW4o6GwLI1GpJQXrSPjdscr6bAhR77cYbETKJuFzxokGgeWKrLDiKca5JLNr +RBH0pUPCTEPlcDaMtjNXepUugqD0XBCzYYP2AgWGLnwtbNwDRm41k9V6lS/eINhbfpSQBGq6WT0E +BXWdN6IOLj3rwaRSg/7Qa9RmjtzG6RJOHSpXqhC8fF6CfaamyfItufUXJ63RDolUK5X6wK0dmBR4 +M0KGCqlztft0DbcbMBnEWg4cJ7faGND/isgFuvGqHKI3t+ZIpEYslOqodmJHixBTB0hXbOKSTbau +BcvcwUpej6w9GU7C7WB1K9vBykLVAgMBAAGjYzBhMB8GA1UdIwQYMBaAFHKs5DN5qkWH9v2sHZ7W +xy+G2CQ5MB0GA1UdDgQWBBRyrOQzeapFh/b9rB2e1scvhtgkOTAOBgNVHQ8BAf8EBAMCAQYwDwYD +VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAoDtZpwmUPjaE0n4vOaWWl/oRrfxn83EJ +8rKJhGdEr7nv7ZbsnGTbMjBvZ5qsfl+yqwE2foH65IRe0qw24GtixX1LDoJt0nZi0f6X+J8wfBj5 +tFJ3gh1229MdqfDBmgC9bXXYfef6xzijnHDoRnkDry5023X4blMMA8iZGok1GTzTyVR8qPAs5m4H +eW9q4ebqkYJpCh3DflminmtGFZhb069GHWLIzoBSSRE/yQQSwxN8PzuKlts8oB4KtItUsiRnDe+C +y748fdHif64W1lZYudogsYMVoe+KTTJvQS8TUoKU1xrBeKJR3Stwbbca+few4GeXVtt8YVMJAygC +QMez2P2ccGrGKMOF6eLtGpOg3kuYooQ+BXcBlj37tCAPnHICehIv1aO6UXivKitEZU61/Qrowc15 +h2Er3oBXRb9n8ZuRXqWk7FlIEA04x7D6w0RtBPV4UBySllva9bguulvP5fBqnUsvWHMtTy3EHD70 +sz+rFQ47GUGKpMFXEmZxTPpT41frYpUJnlTd0cI8Vzy9OK2YZLe4A5pTVmBds9hCG1xLEooc6+t9 +xnppxyd/pPiL8uSUZodL6ZQHCRJ5irLrdATczvREWeAWysUsWNc8e89ihmpQfTU2Zqf7N+cox9jQ +raVplI/owd8k+BsHMYeB2F326CjYSlKArBPuUBQemMc= +-----END CERTIFICATE----- + +D-TRUST BR Root CA 1 2020 +========================= +-----BEGIN CERTIFICATE----- +MIIC2zCCAmCgAwIBAgIQfMmPK4TX3+oPyWWa00tNljAKBggqhkjOPQQDAzBIMQswCQYDVQQGEwJE +RTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEJSIFJvb3QgQ0EgMSAy +MDIwMB4XDTIwMDIxMTA5NDUwMFoXDTM1MDIxMTA5NDQ1OVowSDELMAkGA1UEBhMCREUxFTATBgNV +BAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBCUiBSb290IENBIDEgMjAyMDB2MBAG +ByqGSM49AgEGBSuBBAAiA2IABMbLxyjR+4T1mu9CFCDhQ2tuda38KwOE1HaTJddZO0Flax7mNCq7 +dPYSzuht56vkPE4/RAiLzRZxy7+SmfSk1zxQVFKQhYN4lGdnoxwJGT11NIXe7WB9xwy0QVK5buXu +QqOCAQ0wggEJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFHOREKv/VbNafAkl1bK6CKBrqx9t +MA4GA1UdDwEB/wQEAwIBBjCBxgYDVR0fBIG+MIG7MD6gPKA6hjhodHRwOi8vY3JsLmQtdHJ1c3Qu +bmV0L2NybC9kLXRydXN0X2JyX3Jvb3RfY2FfMV8yMDIwLmNybDB5oHegdYZzbGRhcDovL2RpcmVj +dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwQlIlMjBSb290JTIwQ0ElMjAxJTIwMjAyMCxP +PUQtVHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdDAKBggqhkjOPQQD +AwNpADBmAjEAlJAtE/rhY/hhY+ithXhUkZy4kzg+GkHaQBZTQgjKL47xPoFWwKrY7RjEsK70Pvom +AjEA8yjixtsrmfu3Ubgko6SUeho/5jbiA1czijDLgsfWFBHVdWNbFJWcHwHP2NVypw87 +-----END CERTIFICATE----- + +D-TRUST EV Root CA 1 2020 +========================= +-----BEGIN CERTIFICATE----- +MIIC2zCCAmCgAwIBAgIQXwJB13qHfEwDo6yWjfv/0DAKBggqhkjOPQQDAzBIMQswCQYDVQQGEwJE +RTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEVWIFJvb3QgQ0EgMSAy +MDIwMB4XDTIwMDIxMTEwMDAwMFoXDTM1MDIxMTA5NTk1OVowSDELMAkGA1UEBhMCREUxFTATBgNV +BAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBFViBSb290IENBIDEgMjAyMDB2MBAG +ByqGSM49AgEGBSuBBAAiA2IABPEL3YZDIBnfl4XoIkqbz52Yv7QFJsnL46bSj8WeeHsxiamJrSc8 +ZRCC/N/DnU7wMyPE0jL1HLDfMxddxfCxivnvubcUyilKwg+pf3VlSSowZ/Rk99Yad9rDwpdhQntJ +raOCAQ0wggEJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFH8QARY3OqQo5FD4pPfsazK2/umL +MA4GA1UdDwEB/wQEAwIBBjCBxgYDVR0fBIG+MIG7MD6gPKA6hjhodHRwOi8vY3JsLmQtdHJ1c3Qu +bmV0L2NybC9kLXRydXN0X2V2X3Jvb3RfY2FfMV8yMDIwLmNybDB5oHegdYZzbGRhcDovL2RpcmVj +dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwRVYlMjBSb290JTIwQ0ElMjAxJTIwMjAyMCxP +PUQtVHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdDAKBggqhkjOPQQD +AwNpADBmAjEAyjzGKnXCXnViOTYAYFqLwZOZzNnbQTs7h5kXO9XMT8oi96CAy/m0sRtW9XLS/BnR +AjEAkfcwkz8QRitxpNA7RJvAKQIFskF3UfN5Wp6OFKBOQtJbgfM0agPnIjhQW+0ZT0MW +-----END CERTIFICATE----- + +DigiCert TLS ECC P384 Root G5 +============================= +-----BEGIN CERTIFICATE----- +MIICGTCCAZ+gAwIBAgIQCeCTZaz32ci5PhwLBCou8zAKBggqhkjOPQQDAzBOMQswCQYDVQQGEwJV +UzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJjAkBgNVBAMTHURpZ2lDZXJ0IFRMUyBFQ0MgUDM4 +NC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ZZvWltwGUb+hmA+rYAQCd05JS9Yf7vSdPD3Rh9G +OUrYU9DzLjtxpdRv/PNn5AeP3SYZ4Y1b+qOTEZvpyDrDVWiakuFSdjjo4bq9+0/V77PnSIMx8IIh +47a+p6tv75/fTM8BuGJqIz3nCU2AG3swpMPdB380vqQmsvZB6Akd4yCYqjdP//fx4ilwMUc/dNAU +FvohigLVigmUdy7yWSiLfFCSCmZ4OIN1xLVaqBHG5cGdZlXPU8Sv13WFqUITVuwhd4GTWgzqltlJ +yqEI8pc7bZsEGCREjnwB8twl2F6GmrE52/WRMmrRpnCKovfepEWFJqgejF0pW8hL2JpqA15w8oVP +bEtoL8pU9ozaMv7Da4M/OMZ+ +-----END CERTIFICATE----- + +Certainly Root R1 +================= +-----BEGIN CERTIFICATE----- +MIIFRzCCAy+gAwIBAgIRAI4P+UuQcWhlM1T01EQ5t+AwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UE +BhMCVVMxEjAQBgNVBAoTCUNlcnRhaW5seTEaMBgGA1UEAxMRQ2VydGFpbmx5IFJvb3QgUjEwHhcN +MjEwNDAxMDAwMDAwWhcNNDYwNDAxMDAwMDAwWjA9MQswCQYDVQQGEwJVUzESMBAGA1UEChMJQ2Vy +dGFpbmx5MRowGAYDVQQDExFDZXJ0YWlubHkgUm9vdCBSMTCCAiIwDQYJKoZIhvcNAQEBBQADggIP +ADCCAgoCggIBANA21B/q3avk0bbm+yLA3RMNansiExyXPGhjZjKcA7WNpIGD2ngwEc/csiu+kr+O +5MQTvqRoTNoCaBZ0vrLdBORrKt03H2As2/X3oXyVtwxwhi7xOu9S98zTm/mLvg7fMbedaFySpvXl +8wo0tf97ouSHocavFwDvA5HtqRxOcT3Si2yJ9HiG5mpJoM610rCrm/b01C7jcvk2xusVtyWMOvwl +DbMicyF0yEqWYZL1LwsYpfSt4u5BvQF5+paMjRcCMLT5r3gajLQ2EBAHBXDQ9DGQilHFhiZ5shGI +XsXwClTNSaa/ApzSRKft43jvRl5tcdF5cBx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Bf9JBeW0Y3COmor6xOLRPIh80oat3df1+2IpHLlOR+Vnb5nwXARPbv0+Em34yaXOp/S +X3z7wJl8OSngex2/DaeP0ik0biQVy96QXr8axGbqwua6OV+KmalBWQewLK8= +-----END CERTIFICATE----- + +Certainly Root E1 +================= +-----BEGIN CERTIFICATE----- +MIIB9zCCAX2gAwIBAgIQBiUzsUcDMydc+Y2aub/M+DAKBggqhkjOPQQDAzA9MQswCQYDVQQGEwJV +UzESMBAGA1UEChMJQ2VydGFpbmx5MRowGAYDVQQDExFDZXJ0YWlubHkgUm9vdCBFMTAeFw0yMTA0 +MDEwMDAwMDBaFw00NjA0MDEwMDAwMDBaMD0xCzAJBgNVBAYTAlVTMRIwEAYDVQQKEwlDZXJ0YWlu +bHkxGjAYBgNVBAMTEUNlcnRhaW5seSBSb290IEUxMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE3m/4 +fxzf7flHh4axpMCK+IKXgOqPyEpeKn2IaKcBYhSRJHpcnqMXfYqGITQYUBsQ3tA3SybHGWCA6TS9 +YBk2QNYphwk8kXr2vBMj3VlOBF7PyAIcGFPBMdjaIOlEjeR2o0IwQDAOBgNVHQ8BAf8EBAMCAQYw +DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU8ygYy2R17ikq6+2uI1g4hevIIgcwCgYIKoZIzj0E +AwMDaAAwZQIxALGOWiDDshliTd6wT99u0nCK8Z9+aozmut6Dacpps6kFtZaSF4fC0urQe87YQVt8 +rgIwRt7qy12a7DLCZRawTDBcMPPaTnOGBtjOiQRINzf43TNRnXCve1XYAS59BWQOhriR +-----END CERTIFICATE----- + +Security Communication ECC RootCA1 +================================== +-----BEGIN CERTIFICATE----- +MIICODCCAb6gAwIBAgIJANZdm7N4gS7rMAoGCCqGSM49BAMDMGExCzAJBgNVBAYTAkpQMSUwIwYD +VQQKExxTRUNPTSBUcnVzdCBTeXN0ZW1zIENPLixMVEQuMSswKQYDVQQDEyJTZWN1cml0eSBDb21t +dW5pY2F0aW9uIEVDQyBSb290Q0ExMB4XDTE2MDYxNjA1MTUyOFoXDTM4MDExODA1MTUyOFowYTEL +MAkGA1UEBhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xKzApBgNV +BAMTIlNlY3VyaXR5IENvbW11bmljYXRpb24gRUNDIFJvb3RDQTEwdjAQBgcqhkjOPQIBBgUrgQQA +IgNiAASkpW9gAwPDvTH00xecK4R1rOX9PVdu12O/5gSJko6BnOPpR27KkBLIE+CnnfdldB9sELLo +5OnvbYUymUSxXv3MdhDYW72ixvnWQuRXdtyQwjWpS4g8EkdtXP9JTxpKULGjQjBAMB0GA1UdDgQW +BBSGHOf+LaVKiwj+KBH6vqNm+GBZLzAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAK +BggqhkjOPQQDAwNoADBlAjAVXUI9/Lbu9zuxNuie9sRGKEkz0FhDKmMpzE2xtHqiuQ04pV1IKv3L +snNdo4gIxwwCMQDAqy0Obe0YottT6SXbVQjgUMzfRGEWgqtJsLKB7HOHeLRMsmIbEvoWTSVLY70e +N9k= +-----END CERTIFICATE----- + +BJCA Global Root CA1 +==================== +-----BEGIN CERTIFICATE----- +MIIFdDCCA1ygAwIBAgIQVW9l47TZkGobCdFsPsBsIDANBgkqhkiG9w0BAQsFADBUMQswCQYDVQQG +EwJDTjEmMCQGA1UECgwdQkVJSklORyBDRVJUSUZJQ0FURSBBVVRIT1JJVFkxHTAbBgNVBAMMFEJK +Q0EgR2xvYmFsIFJvb3QgQ0ExMB4XDTE5MTIxOTAzMTYxN1oXDTQ0MTIxMjAzMTYxN1owVDELMAkG +A1UEBhMCQ04xJjAkBgNVBAoMHUJFSUpJTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZMR0wGwYDVQQD +DBRCSkNBIEdsb2JhbCBSb290IENBMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAPFm +CL3ZxRVhy4QEQaVp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QDAgEGMAoGCCqGSM49BAMDA2gAMGUCMBq8 +W9f+qdJUDkpd0m2xQNz0Q9XSSpkZElaA94M04TVOSG0ED1cxMDAtsaqdAzjbBgIxAMvMh1PLet8g +UXOQwKhbYdDFUDn9hf7B43j4ptZLvZuHjw/l1lOWqzzIQNph91Oj9w== +-----END CERTIFICATE----- + +Sectigo Public Server Authentication Root E46 +============================================= +-----BEGIN CERTIFICATE----- +MIICOjCCAcGgAwIBAgIQQvLM2htpN0RfFf51KBC49DAKBggqhkjOPQQDAzBfMQswCQYDVQQGEwJH +QjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0aWdvIFB1YmxpYyBTZXJ2 +ZXIgQXV0aGVudGljYXRpb24gUm9vdCBFNDYwHhcNMjEwMzIyMDAwMDAwWhcNNDYwMzIxMjM1OTU5 +WjBfMQswCQYDVQQGEwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0 +aWdvIFB1YmxpYyBTZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBFNDYwdjAQBgcqhkjOPQIBBgUr +gQQAIgNiAAR2+pmpbiDt+dd34wc7qNs9Xzjoq1WmVk/WSOrsfy2qw7LFeeyZYX8QeccCWvkEN/U0 +NSt3zn8gj1KjAIns1aeibVvjS5KToID1AZTc8GgHHs3u/iVStSBDHBv+6xnOQ6OjQjBAMB0GA1Ud +DgQWBBTRItpMWfFLXyY4qp3W7usNw/upYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB +/zAKBggqhkjOPQQDAwNnADBkAjAn7qRaqCG76UeXlImldCBteU/IvZNeWBj7LRoAasm4PdCkT0RH +lAFWovgzJQxC36oCMB3q4S6ILuH5px0CMk7yn2xVdOOurvulGu7t0vzCAxHrRVxgED1cf5kDW21U +SAGKcw== +-----END CERTIFICATE----- + +Sectigo Public Server Authentication Root R46 +============================================= +-----BEGIN CERTIFICAT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Xlynt8xhW +6aWWrL3DkJiy4Pmi1KZHQ3xtzwIDAQABo0IwQDAdBgNVHQ4EFgQUVnNYZJX5khqwEioEYnmhQBWI +IUkwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAC9c +mTz8Bl6MlC5w6tIyMY208FHVvArzZJ8HXtXBc2hkeqK5Duj5XYUtqDdFqij0lgVQYKlJfp/imTYp +E0RHap1VIDzYm/EDMrraQKFz6oOht0SmDpkBm+S8f74TlH7Kph52gDY9hAaLMyZlbcp+nv4fjFg4 +exqDsQ+8FxG75gbMY/qB8oFM2gsQa6H61SilzwZAFv97fRheORKkU55+MkIQpiGRqRxOF3yEvJ+M +0ejf5lG5Nkc/kLnHvALcWxxPDkjBJYOcCj+esQMzEhonrPcibCTRAUH4WAP+JWgiH5paPHxsnnVI +84HxZmduTILA7rpXDhjvLpr3Etiga+kFpaHpaPi8TD8SHkXoUsCjvxInebnMMTzD9joiFgOgyY9m +pFuiTdaBJQbpdqQACj7LzTWb4OE4y2BThihCQRxEV+ioratF4yUQvNs+ZUH7G6aXD+u5dHn5Hrwd +Vw1Hr8Mvn4dGp+smWg9WY7ViYG4A++MnESLn/pmPNPW56MORcr3Ywx65LvKRRFHQV80MNNVIIb/b +E/FmJUNS0nAiNs2fxBx1IK1jcmMGDw4nztJqDby1ORrp0XZ60Vzk50lJLVU3aPAaOpg+VBeHVOmm +J1CJeyAvP/+/oYtKR5j/K3tJPsMpRmAYQqszKbrAKbkTidOIijlBO8n9pu0f9GBj39ItVQGL +-----END CERTIFICATE----- + +SSL.com TLS RSA Root CA 2022 +============================ +-----BEGIN CERTIFICATE----- +MIIFiTCCA3GgAwIBAgIQb77arXO9CEDii02+1PdbkTANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQG +EwJVUzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQDDBxTU0wuY29tIFRMUyBSU0Eg +Um9vdCB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EUY8U+zoO9opMAdrDC8Z2awms22qyIZZtM7QbUQnRC6cm4pJCAcAZli05bg4vsMQtfhWsSWTVTN +j8pDU/0quOr4ZcoBwq1gaAafORpR2eCNJvkLTqVTJXojpBzOCBvfR4iyrT7gJ4eLSYwfqUdYe5by +iB0YrrPRpgqU+tvT5TgKa3kSM/tKWTcWQA673vWJDPFs0/dRa1419dvAJuoSc06pkZCmF8NsLzjU +o3KUQyxi4U5cMj29TH0ZR6LDSeeWP4+a0zvkEdiLA9z2tmBVGKaBUfPhqBVq6+AL8BQx1rmMRTqo +ENjwuSfr98t67wVylrXEj5ZzxOhWc5y8aVFjvO9nHEMaX3cZHxj4HCUp+UmZKbaSPaKDN7Egkaib +MOlqbLQjk2UEqxHzDh1TJElTHaE/nUiSEeJ9DU/1172iWD54nR4fK/4huxoTtrEoZP2wAgDHbICi +vRZQIA9ygV/MlP+7mea6kMvq+cYMwq7FGc4zoWtcu358NFcXrfA/rs3qr5nsLFR+jM4uElZI7xc7 +P0peYNLcdDa8pUNjyw9bowJWCZ4kLOGGgYz+qxcs+sjiMho6/4UIyYOf8kpIEFR3N+2ivEC+5BB0 +9+Rbu7nzifmPQdjH5FCQNYA+HLhNkNPU98OwoX6EyneSMSy4kLGCenROmxMmtNVQZlR4rmA= +-----END CERTIFICATE----- + +SSL.com TLS ECC Root CA 2022 +============================ +-----BEGIN CERTIFICATE----- +MIICOjCCAcCgAwIBAgIQFAP1q/s3ixdAW+JDsqXRxDAKBggqhkjOPQQDAzBOMQswCQYDVQQGEwJV +UzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQDDBxTU0wuY29tIFRMUyBFQ0MgUm9v +dCBDQSAyMDIyMB4XDTIyMDgyNTE2MzM0OFoXDTQ2MDgxOTE2MzM0N1owTjELMAkGA1UEBhMCVVMx +GDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjElMCMGA1UEAwwcU1NMLmNvbSBUTFMgRUNDIFJvb3Qg +Q0EgMjAyMjB2MBAGByqGSM49AgEGBSuBBAAiA2IABEUpNXP6wrgjzhR9qLFNoFs27iosU8NgCTWy +JGYmacCzldZdkkAZDsalE3D07xJRKF3nzL35PIXBz5SQySvOkkJYWWf9lCcQZIxPBLFNSeR7T5v1 +5wj4A4j3p8OSSxlUgaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBSJjy+j6CugFFR7 +81a4Jl9nOAuc0DAdBgNVHQ4EFgQUiY8vo+groBRUe/NWuCZfZzgLnNAwDgYDVR0PAQH/BAQDAgGG +MAoGCCqGSM49BAMDA2gAMGUCMFXjIlbp15IkWE8elDIPDAI2wv2sdDJO4fscgIijzPvX6yv/N33w +7deedWo1dlJF4AIxAMeNb0Igj762TVntd00pxCAgRWSGOlDGxK0tk/UYfXLtqc/ErFc2KAhl3zx5 +Zn6g6g== +-----END CERTIFICATE----- + +Atos TrustedRoot Root CA ECC TLS 2021 +===================================== +-----BEGIN CERTIFICATE----- +MIICFTCCAZugAwIBAgIQPZg7pmY9kGP3fiZXOATvADAKBggqhkjOPQQDAzBMMS4wLAYDVQQDDCVB +dG9zIFRydXN0ZWRSb290IFJvb3QgQ0EgRUNDIFRMUyAyMDIxMQ0wCwYDVQQKDARBdG9zMQswCQYD +VQQGEwJERTAeFw0yMTA0MjIwOTI2MjNaFw00MTA0MTcwOTI2MjJaMEwxLjAsBgNVBAMMJUF0b3Mg +VHJ1c3RlZFJvb3QgUm9vdCBDQSBFQ0MgVExTIDIwMjExDTALBgNVBAoMBEF0b3MxCzAJBgNVBAYT +AkRFMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEloZYKDcKZ9Cg3iQZGeHkBQcfl+3oZIK59sRxUM6K +DP/XtXa7oWyTbIOiaG6l2b4siJVBzV3dscqDY4PMwL502eCdpO5KTlbgmClBk1IQ1SQ4AjJn8ZQS +b+/Xxd4u/RmAo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR2KCXWfeBmmnoJsmo7jjPX +NtNPojAOBgNVHQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwMDaAAwZQIwW5kp85wxtolrbNa9d+F851F+ +uDrNozZffPc8dz7kUK2o59JZDCaOMDtuCCrCp1rIAjEAmeMM56PDr9NJLkaCI2ZdyQAUEv049OGY +a3cpetskz2VAv9LcjBHo9H1/IISpQuQo +-----END CERTIFICATE----- + +Atos TrustedRoot Root CA RSA TLS 2021 +===================================== +-----BEGIN CERTIFICATE----- +MIIFZDCCA0ygAwIBAgIQU9XP5hmTC/srBRLYwiqipDANBgkqhkiG9w0BAQwFADBMMS4wLAYDVQQD +DCVBdG9zIFRydXN0ZWRSb290IFJvb3QgQ0EgUlNBIFRMUyAyMDIxMQ0wCwYDVQQKDARBdG9zMQsw +CQYDVQQGEwJERTAeFw0yMTA0MjIwOTIxMTBaFw00MTA0MTcwOTIxMDlaMEwxLjAsBgNVBAMMJUF0 +b3MgVHJ1c3RlZFJvb3QgUm9vdCBDQSBSU0EgVExTIDIwMjExDTALBgNVBAoMBEF0b3MxCzAJBgNV +BAYTAkRFMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtoAOxHm9BYx9sKOdTSJNy/BB +l01Z4NH+VoyX8te9j2y3I49f1cTYQcvyAh5x5en2XssIKl4w8i1mx4QbZFc4nXUtVsYvYe+W/CBG +vevUez8/fEc4BKkbqlLfEzfTFRVOvV98r61jx3ncCHvVoOX3W3WsgFWZkmGbzSoXfduP9LVq6hdK +ZChmFSlsAvFr1bqjM9xaZ6cF4r9lthawEO3NUDPJcFDsGY6wx/J0W2tExn2WuZgIWWbeKQGb9Cpt +0xU6kGpn8bRrZtkh68rZYnxGEFzedUlnnkL5/nWpo63/dgpnQOPF943HhZpZnmKaau1Fh5hnstVK +PNe0OwANwI8f4UDErmwh3El+fsqyjW22v5MvoVw+j8rtgI5Y4dtXz4U2OLJxpAmMkokIiEjxQGMY +sluMWuPD0xeqqxmjLBvk1cbiZnrXghmmOxYsL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ZRe0Blqq/DPNL0WP3E1jAuPP6Z92bfW1K/zJMtSU7/xxnD4UiWQWRkUF3gdCF +TIcQcf+eQxuulXUtgQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFEDk5PIj +7zjKsK5Xf/IhMBY027ySMB0GA1UdDgQWBBRA5OTyI+84yrCuV3/yITAWNNu8kjAOBgNVHQ8BAf8E +BAMCAQYwDQYJKoZIhvcNAQEMBQADggIBACY7UeFNOPMyGLS0XuFlXsSUT9SnYaP4wM8zAQLpw6o1 +D/GUE3d3NZ4tVlFEbuHGLige/9rsR82XRBf34EzC4Xx8MnpmyFq2XFNFV1pF1AWZLy4jVe5jaN/T +G3inEpQGAHUNcoTpLrxaatXeL1nHo+zSh2bbt1S1JKv0Q3jbSwTEb93mPmY+KfJLaHEih6D4sTNj +duMNhXJEIlU/HHzp/LgV6FL6qj6jITk1dImmasI5+njPtqzn59ZW/yOSLlALqbUHM/Q4X6RJpstl +cHboCoWASzY9M/eVVHUl2qzEc4Jl6VL1XP04lQJqaTDFHApXB64ipCz5xUG3uOyfT0gA+QEEVcys ++TIxxHWVBqB/0Y0n3bOppHKH/lmLmnp0Ft0WpWIp6zqW3IunaFnT63eROfjXy9mPX1onAX1daBli +2MjN9LdyR75bl87yraKZk62Uy5P2EgmVtqvXO9A/EcswFi55gORngS1d7XB4tmBZrOFdRWOPyN9y +aFvqHbgB8X7754qz41SgOAngPN5C8sLtLpvzHzW2NtjjgKGLzZlkD8Kqq7HK9W+eQ42EVJmzbsAS +ZthwEPEGNTNDqJwuuhQxzhB/HIbjj9LV+Hfsm6vxL2PZQl/gZ4FkkfGXL/xuJvYz+NO1+MRiqzFR +JQJ6+N1rZdVtTTDIZbpoFGWsJwt0ivKH +-----END CERTIFICATE----- + +TrustAsia Global Root CA G4 +=========================== +-----BEGIN CERTIFICATE----- +MIICVTCCAdygAwIBAgIUTyNkuI6XY57GU4HBdk7LKnQV1tcwCgYIKoZIzj0EAwMwWjELMAkGA1UE +BhMCQ04xJTAjBgNVBAoMHFRydXN0QXNpYSBUZWNobm9sb2dpZXMsIEluYy4xJDAiBgNVBAMMG1Ry +dXN0QXNpYSBHbG9iYWwgUm9vdCBDQSBHNDAeFw0yMTA1MjAwMjEwMjJaFw00NjA1MTkwMjEwMjJa +MFoxCzAJBgNVBAYTAkNOMSUwIwYDVQQKDBxUcnVzdEFzaWEgVGVjaG5vbG9naWVzLCBJbmMuMSQw +IgYDVQQDDBtUcnVzdEFzaWEgR2xvYmFsIFJvb3QgQ0EgRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNi +AATxs8045CVD5d4ZCbuBeaIVXxVjAd7Cq92zphtnS4CDr5nLrBfbK5bKfFJV4hrhPVbwLxYI+hW8 +m7tH5j/uqOFMjPXTNvk4XatwmkcN4oFBButJ+bAp3TPsUKV/eSm4IJijYzBhMA8GA1UdEwEB/wQF +MAMBAf8wHwYDVR0jBBgwFoAUpbtKl86zK3+kMd6Xg1mDpm9xy94wHQYDVR0OBBYEFKW7SpfOsyt/ +pDHel4NZg6ZvccveMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjBe8usGzEkxn0AA +bbd+NvBNEU/zy4k6LHiRUKNbwMp1JvK/kF0LgoxgKJ/GcJpo5PECMFxYDlZ2z1jD1xCMuo6u47xk +dUfFVZDj/bpV6wfEU6s3qe4hsiFbYI89MvHVI5TWWA== +-----END CERTIFICATE----- + +Telekom Security TLS ECC Root 2020 +================================== +-----BEGIN CERTIFICATE----- +MIICQjCCAcmgAwIBAgIQNjqWjMlcsljN0AFdxeVXADAKBggqhkjOPQQDAzBjMQswCQYDVQQGEwJE +RTEnMCUGA1UECgweRGV1dHNjaGUgVGVsZWtvbSBTZWN1cml0eSBHbWJIMSswKQYDVQQDDCJUZWxl +a29tIFNlY3VyaXR5IFRMUyBFQ0MgUm9vdCAyMDIwMB4XDTIwMDgyNTA3NDgyMFoXDTQ1MDgyNTIz +NTk1OVowYzELMAkGA1UEBhMCREUxJzAlBgNVBAoMHkRldXRzY2hlIFRlbGVrb20gU2VjdXJpdHkg +R21iSDErMCkGA1UEAwwiVGVsZWtvbSBTZWN1cml0eSBUTFMgRUNDIFJvb3QgMjAyMDB2MBAGByqG +SM49AgEGBSuBBAAiA2IABM6//leov9Wq9xCazbzREaK9Z0LMkOsVGJDZos0MKiXrPk/OtdKPD/M1 +2kOLAoC+b1EkHQ9rK8qfwm9QMuU3ILYg/4gND21Ju9sGpIeQkpT0CdDPf8iAC8GXs7s1J8nCG6NC +MEAwHQYDVR0OBBYEFONyzG6VmUex5rNhTNHLq+O6zd6fMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P +AQH/BAQDAgEGMAoGCCqGSM49BAMDA2cAMGQCMHVSi7ekEE+uShCLsoRbQuHmKjYC2qBuGT8lv9pZ +Mo7k+5Dck2TOrbRBR2Diz6fLHgIwN0GMZt9Ba9aDAEH9L1r3ULRn0SyocddDypwnJJGDSA3PzfdU +ga/sf+Rn27iQ7t0l +-----END CERTIFICATE----- + +Telekom Security TLS RSA Root 2023 +================================== +-----BEGIN CERTIFICATE----- +MIIFszCCA5ugAwIBAgIQIZxULej27HF3+k7ow3BXlzANBgkqhkiG9w0BAQwFADBjMQswCQYDVQQG +EwJERTEnMCUGA1UECgweRGV1dHNjaGUgVGVsZWtvbSBTZWN1cml0eSBHbWJIMSswKQYDVQQDDCJU +ZWxla29tIFNlY3VyaXR5IFRMUyBSU0EgUm9vdCAyMDIzMB4XDTIzMDMyODEyMTY0NVoXDTQ4MDMy +NzIzNTk1OVowYzELMAkGA1UEBhMCREUxJzAlBgNVBAoMHkRldXRzY2hlIFRlbGVrb20gU2VjdXJp +dHkgR21iSDErMCkGA1UEAwwiVGVsZWtvbSBTZWN1cml0eSBUTFMgUlNBIFJvb3QgMjAyMzCCAiIw +DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAO01oYGA88tKaVvC+1GDrib94W7zgRJ9cUD/h3VC +KSHtgVI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V4 +mZqTuXNnQkYRIer+CqkbGmVps4+uFrb2S1ayLfmlyOw7YqPta9BO1UAJpB+Y1zqlklkg5LB9zVtz +aL1txKITDmcZuI1CfmwMmm6gJC3VRRvcxAIU/oVbZZfKTpBQCHpCNfnqwmbU+AGuHrS+w6jv/naa +oqYfRvaE7fzbzsQCzndILIyy7MMAo+wsVRjBfhnu4S/yrYObnqsZ38aKL4x35bcF7DvB7L6Gs4a8 +wPfc5+pbrrLMtTWGS9DiP7bY+A4A7l3j941Y/8+LN+ljX273CXE2whJdV/LItM3z7gLfEdxquVeE +HVlNjM7IDiPCtyaaEBRx/pOyiriA8A4QntOoUAw3gi/q4Iqd4Sw5/7W0cwDk90imc6y/st53BIe0 +o82bNSQ3+pCTE4FCxpgmdTdmQRCsu/WU48IxK63nI1bMNSWSs1A= +-----END CERTIFICATE----- + +TWCA CYBER Root CA +================== +-----BEGIN CERTIFICATE----- +MIIFjTCCA3WgAwIBAgIQQAE0jMIAAAAAAAAAATzyxjANBgkqhkiG9w0BAQwFADBQMQswCQYDVQQG +EwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJUV0NB +IENZQkVSIFJvb3QgQ0EwHhcNMjIxMTIyMDY1NDI5WhcNNDcxMTIyMTU1OTU5WjBQMQswCQYDVQQG +EwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJUV0NB +IENZQkVSIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDG+Moe2Qkgfh1s +Ts6P40czRJzHyWmqOlt47nDSkvgEs1JSHWdyKKHfi12VCv7qze33Kc7wb3+szT3vsxxFavcokPFh +V8UMxKNQXd7UtcsZyoC5dc4pztKFIuwCY8xEMCDa6pFbVuYdHNWdZsc/34bKS1PE2Y2yHer43CdT +o0fhYcx9tbD47nORxc5zb87uEB8aBs/pJ2DFTxnk684iJkXX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SkquLvWL69J1bY73NxW0Qz8ppy6rBe +Pm6pUlvscG21h483XjyMnM7k8M4MZ0HMzvaAq07MTFb1wWFZk7Q+ptq4NxKfKjLji7gh7MMrZQzv +It6IKTtM1/r+t+FHvpw+PoP7UV31aPcuIYXcv/Fa4nzXxeSDwWrruoBa3lwtcHb4yOWHh8qgnaHl +IhInD0Q9HWzq1MKLL295q39QpsQZp6F6t5b5wR9iWqJDB0BeJsas7a5wFsWqynKKTbDPAYsDP27X +-----END CERTIFICATE----- + +SecureSign Root CA14 +==================== +-----BEGIN CERTIFICATE----- +MIIFcjCCA1qgAwIBAgIUZNtaDCBO6Ncpd8hQJ6JaJ90t8sswDQYJKoZIhvcNAQEMBQAwUTELMAkG +A1UEBhMCSlAxIzAhBgNVBAoTGkN5YmVydHJ1c3QgSmFwYW4gQ28uLCBMdGQuMR0wGwYDVQQDExRT +ZWN1cmVTaWduIFJvb3QgQ0ExNDAeFw0yMDA0MDgwNzA2MTlaFw00NTA0MDgwNzA2MTlaMFExCzAJ +BgNVBAYTAkpQMSMwIQYDVQQKExpDeWJlcnRydXN0IEphcGFuIENvLiwgTHRkLjEdMBsGA1UEAxMU +U2VjdXJlU2lnbiBSb290IENBMTQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDF0nqh +1oq/FjHQmNE6lPxauG4iwWL3pwon71D2LrGeaBLwbCRjOfHw3xDG3rdSINVSW0KZnvOgvlIfX8xn +bacuUKLBl422+JX1sLrcneC+y9/3OPJH9aaakpUqYllQC6KxNedlsmGy6pJxaeQp8E+BgQQ8sqVb +1MWoWWd7VRxJq3qdwudzTe/NCcLEVxLbAQ4jeQkHO6Lo/IrPj8BGJJw4J+CDnRugv3gVEOuGTgpa +/d/aLIJ+7sr2KeH6caH3iGicnPCNvg9JkdjqOvn90Ghx2+m1K06Ckm9mH+Dw3EzsytHqunQG+bOE +kJTRX45zGRBdAuVwpcAQ0BB8b8VYSbSwbprafZX1zNoCr7gsfXmPvkPx+S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hZ+PmhIIynJkBugnLN +eLLIjzwec+fBH7/PzqUqm9tEZDKgu39cJRNItX+S +-----END CERTIFICATE----- + +SecureSign Root CA15 +==================== +-----BEGIN CERTIFICATE----- +MIICIzCCAamgAwIBAgIUFhXHw9hJp75pDIqI7fBw+d23PocwCgYIKoZIzj0EAwMwUTELMAkGA1UE +BhMCSlAxIzAhBgNVBAoTGkN5YmVydHJ1c3QgSmFwYW4gQ28uLCBMdGQuMR0wGwYDVQQDExRTZWN1 +cmVTaWduIFJvb3QgQ0ExNTAeFw0yMDA0MDgwODMyNTZaFw00NTA0MDgwODMyNTZaMFExCzAJBgNV +BAYTAkpQMSMwIQYDVQQKExpDeWJlcnRydXN0IEphcGFuIENvLiwgTHRkLjEdMBsGA1UEAxMUU2Vj +dXJlU2lnbiBSb290IENBMTUwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQLUHSNZDKZmbPSYAi4Io5G +dCx4wCtELW1fHcmuS1Iggz24FG1Th2CeX2yF2wYUleDHKP+dX+Sq8bOLbe1PL0vJSpSRZHX+AezB +2Ot6lHhWGENfa4HL9rzatAy2KZMIaY+jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD +AgEGMB0GA1UdDgQWBBTrQciu/NWeUUj1vYv0hyCTQSvT9DAKBggqhkjOPQQDAwNoADBlAjEA2S6J +fl5OpBEHvVnCB96rMjhTKkZEBhd6zlHp4P9mLQlO4E/0BdGF9jVg3PVys0Z9AjBEmEYagoUeYWmJ +SwdLZrWeqrqgHkHZAXQ6bkU6iYAZezKYVWOr62Nuk22rGwlgMU4= +-----END CERTIFICATE----- + +D-TRUST BR Root CA 2 2023 +========================= +-----BEGIN CERTIFICATE----- +MIIFqTCCA5GgAwIBAgIQczswBEhb2U14LnNLyaHcZjANBgkqhkiG9w0BAQ0FADBIMQswCQYDVQQG +EwJERTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEJSIFJvb3QgQ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fYnJfcm9vdF9jYV8y +XzIwMjMuY3JsMA0GCSqGSIb3DQEBDQUAA4ICAQA097N3U9swFrktpSHxQCF16+tIFoE9c+CeJyrr +d6kTpGoKWloUMz1oH4Guaf2Mn2VsNELZLdB/eBaxOqwjMa1ef67nriv6uvw8l5VAk1/DLQOj7aRv +U9f6QA4w9QAgLABMjDu0ox+2v5Eyq6+SmNMW5tTRVFxDWy6u71cqqLRvpO8NVhTaIasgdp4D/Ca4 +nj8+AybmTNudX0KEPUUDAxxZiMrcLmEkWqTqJwtzEr5SswrPMhfiHocaFpVIbVrg0M8JkiZmkdij +YQ6qgYF/6FKC0ULn4B0Y+qSFNueG4A3rvNTJ1jxD8V1Jbn6Bm2m1iWKPiFLY1/4nwSPFyysCu7Ff +/vtDhQNGvl3GyiEm/9cCnnRK3PgTFbGBVzbLZVzRHTF36SXDw7IyN9XxmAnkbWOACKsGkoHU6XCP +pz+y7YaMgmo1yEJagtFSGkUPFaUA8JR7ZSdXOUPPfH/mvTWze/EZTN46ls/pdu4D58JDUjxqgejB +WoC9EV2Ta/vH5mQ/u2kc6d0li690yVRAysuTEwrt+2aSEcr1wPrYg1UDfNPFIkZ1cGt5SAYqgpq/ +5usWDiJFAbzdNpQ0qTUmiteXue4Icr80knCDgKs4qllo3UCkGJCy89UDyibK79XH4I9TjvAA46jt +n/mtd+ArY0+ew+43u3gJhJ65bvspmZDogNOfJA== +-----END CERTIFICATE----- + +TrustAsia TLS ECC Root CA +========================= +-----BEGIN CERTIFICATE----- +MIICMTCCAbegAwIBAgIUNnThTXxlE8msg1UloD5Sfi9QaMcwCgYIKoZIzj0EAwMwWDELMAkGA1UE +BhMCQ04xJTAjBgNVBAoTHFRydXN0QXNpYSBUZWNobm9sb2dpZXMsIEluYy4xIjAgBgNVBAMTGVRy +dXN0QXNpYSBUTFMgRUNDIFJvb3QgQ0EwHhcNMjQwNTE1MDU0MTU2WhcNNDQwNTE1MDU0MTU1WjBY +MQswCQYDVQQGEwJDTjElMCMGA1UEChMcVHJ1c3RBc2lhIFRlY2hub2xvZ2llcywgSW5jLjEiMCAG +A1UEAxMZVHJ1c3RBc2lhIFRMUyBFQ0MgUm9vdCBDQTB2MBAGByqGSM49AgEGBSuBBAAiA2IABLh/ +pVs/AT598IhtrimY4ZtcU5nb9wj/1WrgjstEpvDBjL1P1M7UiFPoXlfXTr4sP/MSpwDpguMqWzJ8 +S5sUKZ74LYO1644xST0mYekdcouJtgq7nDM1D9rs3qlKH8kzsaNCMEAwDwYDVR0TAQH/BAUwAwEB +/zAdBgNVHQ4EFgQULIVTu7FDzTLqnqOH/qKYqKaT6RAwDgYDVR0PAQH/BAQDAgEGMAoGCCqGSM49 +BAMDA2gAMGUCMFRH18MtYYZI9HlaVQ01L18N9mdsd0AaRuf4aFtOJx24mH1/k78ITcTaRTChD15K +eAIxAKORh/IRM4PDwYqROkwrULG9IpRdNYlzg8WbGf60oenUoWa2AaU2+dhoYSi3dOGiMQ== +-----END CERTIFICATE----- + +TrustAsia TLS RSA Root CA +========================= +-----BEGIN CERTIFICATE----- +MIIFgDCCA2igAwIBAgIUHBjYz+VTPyI1RlNUJDxsR9FcSpwwDQYJKoZIhvcNAQEMBQAwWDELMAkG +A1UEBhMCQ04xJTAjBgNVBAoTHFRydXN0QXNpYSBUZWNobm9sb2dpZXMsIEluYy4xIjAgBgNVBAMT +GVRydXN0QXNpYSBUTFMgUlNBIFJvb3QgQ0EwHhcNMjQwNTE1MDU0MTU3WhcNNDQwNTE1MDU0MTU2 +WjBYMQswCQYDVQQGEwJDTjElMCMGA1UEChMcVHJ1c3RBc2lhIFRlY2hub2xvZ2llcywgSW5jLjEi +MCAGA1UEAxMZVHJ1c3RBc2lhIFRMUyBSU0EgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIP +ADCCAgoCggIBAMMWuBtqpERz5dZO9LnPWwvB0ZqB9WOwj0PBuwhaGnrhB3YmH49pVr7+NmDQDIPN +lOrnxS1cLwUWAp4KqC/lYCZUlviYQ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7hRGU+isFqMB3iYPg6qocJQrmBktwliJiJ8Xw18WLK7nn4GS/+X/jbh87q +qA8MpugLoDzga5SYnH+tBuYc6kIQX+ImFTw3OffXvO645e8D7r0i+yiGNFjEWn9hongPXvPKnbwb +PKfILfanIhHKA9jnZwqKDss1jjQ52MjqjZ9k4DewbNfFj8GQYSbbJIweSsCI3zWQzj8C9GRh3sfI +B5XeMhg6j6JCQCTl1jNdfK7vsU1P1FeQNWrcrgSXSYk0ly4wBOeY99sLAZDBHwo/+ML+TvrbmnNz +FrwFuHnYWa8G5z9nODmxfKuU4CkUpijy323imttUQ/hHWKNddBWcwauwxzQ= +-----END CERTIFICATE----- + +D-TRUST EV Root CA 2 2023 +========================= +-----BEGIN CERTIFICATE----- +MIIFqTCCA5GgAwIBAgIQaSYJfoBLTKCnjHhiU19abzANBgkqhkiG9w0BAQ0FADBIMQswCQYDVQQG +EwJERTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEVWIFJvb3QgQ0Eg +MiAyMDIzMB4XDTIzMDUwOTA5MTAzM1oXDTM4MDUwOTA5MTAzMlowSDELMAkGA1UEBhMCREUxFTAT +BgNVBAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBFViBSb290IENBIDIgMjAyMzCC +AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANiOo4mAC7JXUtypU0w3uX9jFxPvp1sjW2l1 +sJkKF8GLxNuo4MwxusLyzV3pt/gdr2rElYfXR8mV2IIEUD2BCP/kPbOx1sWy/YgJ25yE7CUXFId/ +MHibaljJtnMoPDT3mfd/06b4HEV8rSyMlD/YZxBTfiLNTiVR8CUkNRFeEMbsh2aJgWi6zCudR3Mf +vc2RpHJqnKIbGKBv7FD0fUDCqDDPvXPIEysQEx6Lmqg6lHPTGGkKSv/BAQP/eX+1SH977ugpbzZM +lWGG2Pmic4ruri+W7mjNPU0oQvlFKzIbRlUWaqZLKfm7lVa/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kFMhtYVRFP0OUnR3Hs7dpn1mKmS00PaaLJvOwi +S5THaJQXfuKOKD62xur1NGyfN4gHONuGcfrNlUhDbqNPgofXNJhuS5N5YHVpD/Aa1VP6IQzCP+k/ +HxiMkl14p3ZnGbuy6n/pcAlWVqOwDAstNl7F6cTVg8uGF5csbBNvh1qvSaYd2804BC5f4ko1Di1L ++KIkBI3Y4WNeApI02phhXBxvWHZks/wCuPWdCg== +-----END CERTIFICATE----- + +SwissSign RSA TLS Root CA 2022 - 1 +================================== +-----BEGIN CERTIFICATE----- +MIIFkzCCA3ugAwIBAgIUQ/oMX04bgBhE79G0TzUfRPSA7cswDQYJKoZIhvcNAQELBQAwUTELMAkG +A1UEBhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzErMCkGA1UEAxMiU3dpc3NTaWduIFJTQSBU +TFMgUm9vdCBDQSAyMDIyIC0gMTAeFw0yMjA2MDgxMTA4MjJaFw00NzA2MDgxMTA4MjJaMFExCzAJ +BgNVBAYTAkNIMRUwEwYDVQQKEwxTd2lzc1NpZ24gQUcxKzApBgNVBAMTIlN3aXNzU2lnbiBSU0Eg +VExTIFJvb3QgQ0EgMjAyMiAtIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDLKmji +C8NXvDVjvHClO/OMPE5Xlm7DTjak9gLKHqquuN6orx122ro10JFwB9+zBvKK8i5VUXu7LCTLf5Im +gKO0lPaCoaTo+nUdWfMHamFk4saMla+ju45vVs9xzF6BYQ1t8qsCLqSX5XH8irCRIFucdFJtrhUn +WXjyCcplDn/L9Ovn3KlMd/YrFgSVrpxxpT8q2kFC5zyEEPThPYxr4iuRR1VPuFa+Rd4iUU1OKNlf +GUEGjw5NBuBwQCMBauTLE5tzrE0USJIt/m2n+IdreXXhvhCxqohAWVTXz8TQm0SzOGlkjIHRI36q +OTw7D59Ke4LKa2/KIj4x0LDQKhySio/YGZxH5D4MucLNvkEM+KRHBdvBFzA4OmnczcNpI/2aDwLO +E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+MF7psYC0n +hzck5npgL7XTgwSqT0N1osGDsieYK7EOgLrAhV5Cud+xYJHT6xh+cHiudoO+cVrQkOPKwRYlZ0rw +tnu64ZzZ +-----END CERTIFICATE----- + +OISTE Server Root ECC G1 +======================== +-----BEGIN CERTIFICATE----- +MIICNTCCAbqgAwIBAgIQI/nD1jWvjyhLH/BU6n6XnTAKBggqhkjOPQQDAzBLMQswCQYDVQQGEwJD +SDEZMBcGA1UECgwQT0lTVEUgRm91bmRhdGlvbjEhMB8GA1UEAwwYT0lTVEUgU2VydmVyIFJvb3Qg +RUNDIEcxMB4XDTIzMDUzMTE0NDIyOFoXDTQ4MDUyNDE0NDIyN1owSzELMAkGA1UEBhMCQ0gxGTAX +BgNVBAoMEE9JU1RFIEZvdW5kYXRpb24xITAfBgNVBAMMGE9JU1RFIFNlcnZlciBSb290IEVDQyBH +MTB2MBAGByqGSM49AgEGBSuBBAAiA2IABBcv+hK8rBjzCvRE1nZCnrPoH7d5qVi2+GXROiFPqOuj +vqQycvO2Ackr/XeFblPdreqqLiWStukhEaivtUwL85Zgmjvn6hp4LrQ95SjeHIC6XG4N2xml4z+c +KrhAS93mT6NjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBQ3TYhlz/w9itWj8UnATgwQ +b0K0nDAdBgNVHQ4EFgQUN02IZc/8PYrVo/FJwE4MEG9CtJwwDgYDVR0PAQH/BAQDAgGGMAoGCCqG +SM49BAMDA2kAMGYCMQCpKjAd0MKfkFFRQD6VVCHNFmb3U2wIFjnQEnx/Yxvf4zgAOdktUyBFCxxg +ZzFDJe0CMQCSia7pXGKDYmH5LVerVrkR3SW+ak5KGoJr3M/TvEqzPNcum9v4KGm8ay3sMaE641c= +-----END CERTIFICATE----- + +OISTE Server Root RSA G1 +======================== +-----BEGIN CERTIFICATE----- +MIIFgzCCA2ugAwIBAgIQVaXZZ5Qoxu0M+ifdWwFNGDANBgkqhkiG9w0BAQwFADBLMQswCQYDVQQG +EwJDSDEZ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OSh+1sbM2zQ6NMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQwFAAOCAgEANGd5sjrG5T33 +I3K5Ce+SrScfoE4KsvXaFwyihdJ+klH9FWXXXGtkFu6KRcoMQzZENdl//nk6HOjG5D1rd9QhEOP2 +8yBOqb6J8xycqd+8MDoX0TJD0KqKchxRKEzdNsjkLWd9kYccnbz8qyiWXmFcuCIzGEgWUOrKL+ml +Sdx/PKQZvDatkuK59EvV6wit53j+F8Bdh3foZ3dPAGav9LEDOr4SfEE15fSmG0eLy3n31r8Xbk5l +8PjaV8GUgeV6Vg27Rn9vkf195hfkgSe7BYhW3SCl95gtkRlpMV+bMPKZrXJAlszYd2abtNUOshD+ +FKrDgHGdPY3ofRRsYWSGRqbXVMW215AWRqWFyp464+YTFrYVI8ypKVL9AMb2kI5Wj4kI3Zaq5tNq +qYY19tVFeEJKRvwDyF7YZvZFZSS0vod7VSCd9521Kvy5YhnLbDuv0204bKt7ph6N/Ome/msVuduC +msuY33OhkKCgxeDoAaijFJzIwZqsFVAzje18KotzlUBDJvyBpCpfOZC3J8tRd/iWkx7P8nd9H0aT +olkelUTFLXVksNb54Dxp6gS1HAviRkRNQzuXSXERvSS2wq1yVAb+axj5d9spLFKebXd7Yv0PTY6Y +MjAwcRLWJTXjn/hvnLXrahut6hDTlhZyBiElxky8j3C7DOReIoMt0r7+hVu05L0= +-----END CERTIFICATE----- + +e-Szigno TLS Root CA 2023 +========================= +-----BEGIN CERTIFICATE----- +MIICzzCCAjGgAwIBAgINAOhvGHvWOWuYSkmYCjAKBggqhkjOPQQDBDB1MQswCQYDVQQGEwJIVTER +MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xFzAVBgNVBGEMDlZBVEhV +LTIzNTg0NDk3MSIwIAYDVQQDDBllLVN6aWdubyBUTFMgUm9vdCBDQSAyMDIzMB4XDTIzMDcxNzE0 +MDAwMFoXDTM4MDcxNzE0MDAwMFowd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uE8LrlZqhGZM9pJQXGmGzResDJV6JgRBna+j4sA1M7yId +lvL0sAfFXFCTRaWTD4E1V99RLrFzWfTcC+e180hDuNMpqOEo46+lMeW/Wvh7ifOQs+kiK0O2gHxQ +DNxslSavnCs4V7l8HRDJ2La10o70Bo7VLzf1W8MBvv0VTnxB+NjT5qTAbhGFh9Gvp4BaJpmdUf0C +5CEP6dbQlfgxWfzYr69yVT6dPQB+GFEaY03IMY+AcBCs+om1fNxrQXt9zoofMBNFbLhvpNH/JsXW +dGUzfNbO12uswTa5wah8LB18FTQN2/zPHYmvBEoLuyUgZ09VNLJo5YA0kXItVYkLjMe2SixzK4sc +UHv81IK99I91DWx7FwMVKw2xgFp+ZLYB2dnpQQrqwlW64glHUcK2N9BDsnjLSxeZ+UPECh9RxH4W +AcKiZW+cqaKMmhP2WBfR4IcR7NOL32ml11ds87hhV1CZWWFCJAcCidYZz6CZa8exzHojP9SB5RH0 +/v1KdHAisqhSjtJl/UIAHIQ48elOn8wrTdFap4Yb5aHglmMeNx+fAIhDluWVfxTO7H4dTPU+SFVR +MLAh+wwKZfqb94nMeQ== +-----END CERTIFICATE----- + +SECOM TLS ECC Root CA 2024 +========================== +-----BEGIN CERTIFICATE----- +MIICTDCCAdGgAwIBAgIJAIF6LO+PI3pEMAoGCCqGSM49BAMDMFoxCzAJBgNVBAYTAkpQMSYwJAYD +VQQKEx1TRUNPTSBUcnVzdCBTeXN0ZW1zIENvLiwgTHRkLjEjMCEGA1UEAxMaU0VDT00gVExTIEVD +QyBSb290IENBIDIwMjQwHhcNMjQwMTMxMDU1MjM0WhcNNDkwMTE0MDU1MjM0WjBaMQswCQYDVQQG +EwJKUDEmMCQGA1UEChMdU0VDT00gVHJ1c3QgU3lzdGVtcyBDby4sIEx0ZC4xIzAhBgNVBAMTGlNF +Q09NIFRMUyBFQ0MgUm9vdCBDQSAyMDI0MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE7NzFMtu9dzQX +SNC12fabk0+GlC5finB3R7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CqGSM49 +BAMDA2kAMGYCMQCXAUdS/9bbJ8A1JYaGf/bWt/s7Ta0ot5Ulno8OjSNYRWQIlS4tVWldvTAVA7he +OFgCMQCvKr8+Z2Rn+OBr5UHzlgBObpad1LuwNTRcdNgUJxIWadcki+UBLEi1/AURKV5md2M= +-----END CERTIFICATE----- + +Telia RSA TLS Root CA v3 +======================== +-----BEGIN CERTIFICATE----- +MIIFgjCCA2qgAwIBAgIPAYvSUKtCVSxHWr2h3BrFMA0GCSqGSIb3DQEBDAUAMEsxCzAJBgNVBAYT +AlNFMRkwFwYDVQQKDBBUZWxpYSBDb21wYW55IEFCMSEwHwYDVQQDDBhUZWxpYSBSU0EgVExTIFJv +b3QgQ0EgdjMwHhcNMjMxMTE1MDk0NzQyWhcNNDgwNTIzMTEwMDAwWjBLMQswCQYDVQQGEwJTRTEZ +MBcGA1UECgwQVGVsaWEgQ29tcGFueSBBQjEhMB8GA1UEAwwYVGVsaWEgUlNBIFRMUyBSb290IENB +IHYzMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsV89KG19hCf4S1Fvk8D3TyDERhmc +vx8F7Kmb4WATx3ije1id3KHxRE0TKmcNCbAQ57bvHFEYa4hR2l20VjVadExqOW+2ld99MbEiO+jR +VOz+BbxLxJnmGwCqI+BfuTjjVReDxsxjQvjgBsClaO/sm5i70nlZcWGRtIkvWDK3NNkT5RtwXc/O +8NTFVpbUqT6cRjIj3olAblR+lRf4Ffy5o+Q9fabjYn9Z9S4itruElcEFf9Ljk7fwdTycT/rvJW9w +/B3G2a3r0f/zXNOVruIBcqE6pkSospACU2bG42fYKrbM/GWnp7u+p9Frz4jaNwpb4YHuEeS8Brat +NcP8X62jXIvvKHxlsMDJCnb4U8JzFOLsU6mohVY58BdZrvi0Gk9UOuqmgoG6dskHoksjZTlK61D/ +InzmEoA1yAYJFDVysjRxDUOu9cAwANbqmq77WIFL6BpnZgVqPtMfG6wN8BrTKdapvilVsYR59BFg +IsAVBMxrGh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git a/software/wifi/raw_u64/CMakeLists.txt b/software/wifi/raw_u64/CMakeLists.txt index ecffda6a1..5fa75d887 100644 --- a/software/wifi/raw_u64/CMakeLists.txt +++ b/software/wifi/raw_u64/CMakeLists.txt @@ -7,3 +7,22 @@ if(IDF_VERSION_MAJOR LESS 6) message(FATAL_ERROR "raw_u64 needs ESP-IDF 6, not ${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR} (see software/wifi/raw_u64/README.md)") endif() project(bridge) + +# The certificate bundle is the vendored Mozilla root store, ../ca_store/cacert.pem. ca_store.py checks it against +# CA_PINS and the configuration this build really uses (sdkconfig.json) at every configure and again at every build, +# before the bundle is made, so an earlier configure cannot skip it. RELEASE=1 also fails a stale store. See README.md. +set(CA_STORE ${CMAKE_CURRENT_LIST_DIR}/../ca_store) +set(CA_STORE_CHECK ${CMAKE_CURRENT_LIST_DIR}/../../../tools/ca_store/ca_store.py) +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CA_STORE}/cacert.pem ${CA_STORE}/CA_PINS ${CA_STORE_CHECK}) +idf_build_get_property(_python PYTHON) +idf_build_get_property(_sdkconfig_json SDKCONFIG_JSON) +set(_ca_check ${_python} ${CA_STORE_CHECK} check --project ${CMAKE_CURRENT_LIST_DIR} --sdkconfig-json ${_sdkconfig_json}) +execute_process(COMMAND ${_ca_check} RESULT_VARIABLE _ca_rc) +if(NOT _ca_rc EQUAL 0) + message(FATAL_ERROR "The Mozilla root store (software/wifi/ca_store) failed its check; see README.md") +endif() +add_custom_target(ca_store_check ALL COMMAND ${_ca_check} COMMENT "Checking the Mozilla root store" VERBATIM) +# The bundle (and so the mbedtls library and the image) waits for it +if(TARGET custom_bundle) + add_dependencies(custom_bundle ca_store_check) +endif() diff --git a/software/wifi/raw_u64/README.md b/software/wifi/raw_u64/README.md index 0194d5e34..87b57e98f 100644 --- a/software/wifi/raw_u64/README.md +++ b/software/wifi/raw_u64/README.md @@ -19,6 +19,70 @@ then `make u64_no_esp` packs `build/bridge.bin` into `update.u64`. `make esp32_r `sdkconfig` marks values that follow ESP-IDF's defaults with `# default:`; a reconfigure on a newer ESP-IDF takes its new defaults there. After any ESP-IDF update, diff the values, not just the build. +mbedTLS is ESP-IDF's own, as ESP-IDF imports it: the build carries no patch to it. Known issue: +stock mbedTLS refuses a cookie in a TLS 1.3 HelloRetryRequest (Mbed-TLS/mbedtls#9543), so a +server that sends one, as OpenJDK's JSSE does, fails the handshake. + +## Testing the TLS engine + +The engine (`main/tls_engine.c`, `main/rpc_dispatch.c`) is checked from the C64's side by the E2E +suite `tests/e2e/io/command_interface/net_tls_test.py` (against a device) and `net_tls_selftest.py` +(against a simulated one), and the Ultimate's side of the module calls by +`make -C target/pc/linux/wifitls test`. The engine can also be run on its own, on QEMU or an +ESP32 dev board, with a red/green gate: . + +## The certificate bundle: the Mozilla root store, vendored + +The roots the bridge trusts in BUNDLE mode come from `software/wifi/ca_store/cacert.pem`, not +from ESP-IDF's copy. ESP-IDF refreshes its own `cacrt_all.pem` on its release branches only now +and then: v6.0.3 ships Mozilla's data of 2025-12-02, with roots Mozilla has since dropped. + +- **Where it comes from.** `cacert.pem` is curl's extract of Mozilla's `certdata.txt` + (), byte for byte. `CA_PINS` beside it records the source URL, + the Mozilla date, the file's sha256 (`CA_SHA256`), the `certdata.txt` commit on GitHub it was + regenerated from as a cross-check (`CA_CERTDATA_REF`), the sha256 of its set of certificates + (`CA_BUNDLE_SET_SHA256`) and the age limit (`CA_MAX_AGE_DAYS`). +- **How the build uses it.** `sdkconfig` selects `CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE`, + so none of ESP-IDF's roots are merged in, and points `CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH` + at `../ca_store/cacert.pem`; ESP-IDF's `gen_crt_bundle.py` builds the bundle from that file and + builds it again whenever the file changes. +- **How the build verifies it.** `CMakeLists.txt` runs `python3 tools/ca_store/ca_store.py check` + at every configure (an edit to `cacert.pem`, `CA_PINS` or the checker configures again) and + again at every build, before the bundle is made, so an already-configured tree cannot skip it. + It checks the configuration the build really uses (its `config/sdkconfig.json`, which + `idf.py -D SDKCONFIG=...` can point away from this directory's `sdkconfig`). The build fails + when `cacert.pem` does not match `CA_SHA256`, when its date disagrees with the pins, when its + certificates changed without `CA_BUNDLE_SET_SHA256`, when another certificate file (such as an + `anchors.pem`) is in the store, or when the configuration no longer builds the bundle from the + store alone with `CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y`. A store older than + `CA_MAX_AGE_DAYS` is a warning, and an error when the build runs with `RELEASE=1` in its + environment (`RELEASE=1 idf.py build`, `make RELEASE=1 esp32_raw_u64`). Run the check by hand + with `python3 tools/ca_store/ca_store.py check`, and its tests with `make ca_store_test`. +- **How to refresh it.** `python3 tools/ca_store/refresh.py --ident-minor N` (needs the network + and Perl) fetches curl's file and its sum, and takes it only when curl's own `mk-ca-bundle.pl`, + pinned by commit and sha256, gives the same file from the newest `certdata.txt` on Firefox's + release branch, which must descend from `CA_CERTDATA_REF`. It writes `cacert.pem` and `CA_PINS`. + When the certificates changed it also sets `IDENT_MINOR` (and `IDENT_STRING`) in + `main/rpc_dispatch.h` to N, since the updater reflashes a module only for a new version. N must + be allocated for this image and above the current minor: the tool refuses a certificate change + without `--ident-minor`, because on a development line the next number may already belong to + another image. `--summary FILE` lists what changed by fingerprint, for review. Commit the + result. Never edit `cacert.pem` by hand: the build refuses it. Moving the pins by hand without + a new `IDENT_MINOR` is not caught by the check, so review that the two move together. +- **Roots with serial number zero.** Six roots in Mozilla's set as of 2026-09-25 (Go Daddy Root + CA - G2, Starfield Root CA - G2, Starfield Services Root CA - G2, Security Communication + RootCA2 and the two HARICA 2015 roots) have serial number 0, which the `cryptography` package + (48.0) warns is not positive. ESP-IDF's `gen_crt_bundle.py` silences that warning + today; if a future `cryptography` refuses such certificates, the bundle step fails and the build + stops (it fails closed, as it would with ESP-IDF's own bundle, which holds the same roots). +- **No anchors.** ESP-IDF 6 verifies cross-signed chains itself + (`CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY`), so the store needs no hand-kept + roots: `sdkconfig` sets it explicitly, `main/tls_engine.c` refuses to build without it, and the + check refuses an anchor file. Only raw_u64 uses the store; raw_c3 and u64ctrl keep ESP-IDF's + bundle. + +## The Wi-Fi scan (from the ESP-IDF example this project started as) + This example shows how to use the scan functionality of the Wi-Fi driver of ESP32. Two scan methods are supported: fast scan and all channel scan. diff --git a/software/wifi/raw_u64/main/CMakeLists.txt b/software/wifi/raw_u64/main/CMakeLists.txt index abf3f7079..4bab394b1 100644 --- a/software/wifi/raw_u64/main/CMakeLists.txt +++ b/software/wifi/raw_u64/main/CMakeLists.txt @@ -1,5 +1,11 @@ set(EXTERNAL "../../../io/uart") +# BRIDGE_TLS_STUB (idf.py -D BRIDGE_TLS_STUB=1) builds a size-measurement image without the TLS engine +if(BRIDGE_TLS_STUB) + set(TLS_SRCS "tls_engine_stub.c") +else() + set(TLS_SRCS "tls_engine.c") +endif() set(COMMON "../../common") -idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_boot.c ${COMMON}/radio_entropy.c ${COMMON}/radio_entropy_esp.c +idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${TLS_SRCS} ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_boot.c ${COMMON}/radio_entropy.c ${COMMON}/radio_entropy_esp.c INCLUDE_DIRS "." ${EXTERNAL} ${COMMON} LDFRAGMENTS "linker.lf") diff --git a/software/wifi/raw_u64/main/rpc_calls.h b/software/wifi/raw_u64/main/rpc_calls.h index 9e58d8b7c..bf854b3d5 100644 --- a/software/wifi/raw_u64/main/rpc_calls.h +++ b/software/wifi/raw_u64/main/rpc_calls.h @@ -129,6 +129,168 @@ typedef struct { esp_datetime_t datetime; } rpc_get_time_resp; +//---------------------------------- +//---------------------------------- +// TLS sessions, named by (slot, tag): the ESP32 runs the engine, the Ultimate moves the ciphertext. Fixed fields first, +// variable data last; rpc_dispatch.c and wifi_tls.cc assert these layouts at fixed offsets. +#define TLS_MAX_SESSIONS 2 +#define TLS_SNI_MAX_LEN 253 // longest DNS name +#define TLS_STEP_IN_MAX 1536 // ct_in_len + pt_in_len per step +#define TLS_STEP_OUT_MAX 1024 // ct_out_len + pt_out_len per step +#define TLS_SLOT_GLOBAL 0xFF // CMD_TLS_STATS without a session (tag 0) +#define TLS_PIN_LEN 32 // SHA-256 of the server's SubjectPublicKeyInfo, digest order +#define TLS_CA_MAX_LEN 1472 // one DER certificate for trust mode CUSTOM +#define TLS_ALERT_NONE 0xFF + +typedef enum { + TLS_TRUST_BUNDLE = 0, // the ESP-IDF certificate bundle + TLS_TRUST_CUSTOM = 1, // the one CA loaded with CMD_TLS_SET_CA, matched by ca_tag + TLS_TRUST_PIN = 2, // the leaf key's SHA-256 only +} tls_trust_t; + +#define TLS_OPT_REQUIRE_TLS13 0x01 // rpc_tls_open_req.opts: offer TLS 1.3 only +#define TLS_STEP_NO_READ 0x01 // rpc_tls_step_req.flags: no plaintext out of this step + +// rpc_tls_open_resp.reason, telling the ESP_ERR_INVALID_STATE refusals apart +#define TLS_OPEN_REASON_NONE 0 +#define TLS_OPEN_REASON_NO_ENTROPY 1 // the radio has not started: no RNG seed +#define TLS_OPEN_REASON_NO_TIME 2 // BUNDLE or CUSTOM, but no trustworthy clock +#define TLS_OPEN_REASON_NO_CUSTOM_CA 3 // CUSTOM, but no CA held under the request's ca_tag + +typedef enum { + TLS_TIME_NONE = 0, // clock not later than the build date + TLS_TIME_NIOS = 1, // set from unix_time in a CMD_TLS_OPEN (the Ultimate's SNTP time) + TLS_TIME_SNTP = 2, // already valid without the Ultimate: SNTP over the ESP32's own Wi-Fi (STATS only) +} tls_time_source_t; + +typedef enum { + TLS_STATE_HANDSHAKING = 0, + TLS_STATE_ESTABLISHED = 1, + TLS_STATE_CLOSED = 2, + TLS_STATE_FAILED = 3, // esp_err holds the mbedTLS error code, fail_reason says more +} tls_state_t; + +// rpc_tls_step_resp.fail_reason, set with FAILED +typedef enum { + TLS_FAIL_NONE = 0, // generic: esp_err has the mbedTLS code (alert_in the alert, if any) + TLS_FAIL_VERSION_REFUSED = 1, // the ServerHello chose a version not offered; it is in verify_flags' low 16 bits + TLS_FAIL_DOWNGRADE = 2, // TLS 1.2 chosen by a ServerHello carrying the RFC 8446 downgrade sentinel + TLS_FAIL_NO_EMS = 3, // a TLS 1.2 server without the extended master secret + TLS_FAIL_CERT_VERIFY = 4, // verify_flags = mbedtls_ssl_get_verify_result(), 0xFFFFFFFF if it never completed + TLS_FAIL_PIN_MISMATCH = 5, // PIN: the leaf key is not the pinned one + TLS_FAIL_PEER_CLOSED = 6, // close_notify during the handshake +} tls_fail_reason_t; + +// rpc_tls_set_ca_resp.reject, with ESP_ERR_INVALID_ARG +#define TLS_CA_REJECT_NONE 0 +#define TLS_CA_REJECT_RSA_KEY_SHORT 1 // RSA key below 2048 bits +#define TLS_CA_REJECT_RESERVED 2 // never sent +#define TLS_CA_REJECT_CURVE 3 // EC key on a curve the X.509 profile does not accept +#define TLS_CA_REJECT_NOT_CA 4 // v3 without basicConstraints cA, or a keyUsage without keyCertSign + +typedef struct { + rpc_header_t hdr; + uint8_t trust; // tls_trust_t + uint8_t sni_len; // 0..TLS_SNI_MAX_LEN, no terminator; 0 = no name (PIN only) + uint8_t slot; // 0..TLS_MAX_SESSIONS-1, chosen by the Ultimate + uint8_t time_source; // TLS_TIME_NONE, or TLS_TIME_NIOS when unix_time is the Ultimate's SNTP time + uint32_t unix_time; // UTC seconds + uint16_t tag; // names the session with slot; never 0 + uint8_t opts; // TLS_OPT_* + uint8_t reserved; + uint16_t ca_tag; // CUSTOM: the Ultimate's current ca_tag; 0 otherwise + uint16_t reserved2; + uint8_t pin[TLS_PIN_LEN]; // read only when trust is PIN + char sni[]; +} rpc_tls_open_req; + +typedef struct { + rpc_header_t hdr; + int esp_err; // ESP_OK, an esp_err_t, or a negative mbedTLS code + uint8_t slot; // TLS_SLOT_GLOBAL when esp_err != ESP_OK + uint8_t reason; // TLS_OPEN_REASON_* + uint16_t reserved; // 0 +} rpc_tls_open_resp; + +typedef struct { + rpc_header_t hdr; + uint8_t slot; + uint8_t flags; // TLS_STEP_NO_READ + uint16_t tag; + uint16_t ct_in_len; + uint16_t pt_in_len; + uint8_t data[]; // ct_in, then pt_in +} rpc_tls_step_req; + +typedef struct { + rpc_header_t hdr; + int esp_err; + uint8_t state; // tls_state_t + uint8_t alert_in; // fatal alert received, TLS_ALERT_NONE if none + uint16_t ct_out_len; + uint16_t pt_out_len; + uint8_t alert_out; // alert this engine sent unencrypted, TLS_ALERT_NONE if none (or encrypted) + uint8_t fail_reason; // tls_fail_reason_t, with FAILED + uint32_t verify_flags; // see tls_fail_reason_t + uint8_t data[]; // ct_out, then pt_out +} rpc_tls_step_resp; + +typedef struct { + rpc_header_t hdr; + uint8_t slot; + uint8_t reserved; + uint16_t tag; +} rpc_tls_session_req; // CMD_TLS_CLOSE and CMD_TLS_STATS + +typedef struct { + rpc_header_t hdr; + int esp_err; + uint16_t ct_out_len; + uint16_t reserved; + uint8_t data[]; // the close_notify record +} rpc_tls_close_resp; + +typedef struct { + rpc_header_t hdr; + int esp_err; + uint32_t heap_free; // internal 8-bit capable heap + uint32_t heap_min; // low-water mark since the OPEN that found no session open + uint32_t largest_block; + uint32_t ct_in_bytes; // session counters, 0 for TLS_SLOT_GLOBAL + uint32_t ct_out_bytes; + uint32_t pt_in_bytes; + uint32_t pt_out_bytes; + uint32_t handshake_us; // ESP32 time spent in handshake steps + uint16_t tls_version; // 0x0304 for TLS 1.3 + uint16_t ciphersuite; // IANA id + uint16_t group; // IANA NamedGroup, never 0 once ESTABLISHED + uint8_t state; // tls_state_t + uint8_t sessions_open; + uint32_t stack_free; // TLS task stack high-water mark, bytes + uint32_t esp_time; // ESP32 clock at the session's OPEN (now, for TLS_SLOT_GLOBAL), 0 = no time + uint8_t time_source; // tls_time_source_t of that clock + uint8_t entropy_source; // entropy_source_t, now + uint8_t ems; // 1: TLS 1.2 with the extended master secret + uint8_t reserved; + uint16_t block_max_ms; // longest dispatcher iteration since boot + uint16_t reserved2; + uint8_t spki_sha256[32]; // SHA-256 of the leaf's SubjectPublicKeyInfo, digest order +} rpc_tls_stats_resp; + +typedef struct { + rpc_header_t hdr; + uint16_t der_len; // 1..TLS_CA_MAX_LEN + uint16_t ca_tag; // never 0 + uint8_t der[]; +} rpc_tls_set_ca_req; + +typedef struct { + rpc_header_t hdr; + int esp_err; // ESP_OK, a negative mbedTLS parse code, or ESP_ERR_INVALID_ARG with a reject reason + uint8_t reject; // TLS_CA_REJECT_* + uint8_t reserved[3]; +} rpc_tls_set_ca_resp; + //---------------------------------- // send raw packet typedef struct { @@ -181,6 +343,12 @@ typedef struct { #define CMD_CLEAR_APS 0x11 #define CMD_WIFI_AUTOCONNECT 0x12 // 0x13-0x1F are u64ctrl's; 0x20 is CMD_GET_RANDOM, in rpc_shared.h +#define CMD_TLS_OPEN 0x30 +#define CMD_TLS_STEP 0x31 +#define CMD_TLS_CLOSE 0x32 +#define CMD_TLS_STATS 0x33 +#define CMD_TLS_CLOSE_ALL 0x34 +#define CMD_TLS_SET_CA 0x35 /* #define CMD_SOCKET 0x11 diff --git a/software/wifi/raw_u64/main/rpc_dispatch.c b/software/wifi/raw_u64/main/rpc_dispatch.c index 30f7ab5d2..3fb200b8d 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.c +++ b/software/wifi/raw_u64/main/rpc_dispatch.c @@ -13,6 +13,8 @@ #include "esp_log.h" #include "driver/uart.h" #include "esp_random.h" +#include "esp_heap_caps.h" +#include "esp_timer.h" #include "rpc_calls.h" #include "rpc_dispatch.h" #include "my_uart.h" @@ -20,6 +22,7 @@ #include "pinout.h" #include "wifi_modem.h" #include "sntp.h" +#include "tls_engine.h" // not officially supported #include "../lwip/esp_netif_lwip_internal.h" @@ -260,6 +263,323 @@ void cmd_get_random(command_buf_t *buf) my_uart_transmit_packet(UART_CHAN, buf); } + +// TLS. The layout is part of the wire, the header is echoed, and the fixed part of every reply is zeroed +// before it is filled. The Ultimate decodes these by offset and asserts the same ones: a layout change must +// break the build, not the wire. +_Static_assert(sizeof(rpc_tls_open_req) == 52, "rpc_tls_open_req size"); +_Static_assert(offsetof(rpc_tls_open_req, trust) == 4, "rpc_tls_open_req.trust"); +_Static_assert(offsetof(rpc_tls_open_req, sni_len) == 5, "rpc_tls_open_req.sni_len"); +_Static_assert(offsetof(rpc_tls_open_req, slot) == 6, "rpc_tls_open_req.slot"); +_Static_assert(offsetof(rpc_tls_open_req, time_source) == 7, "rpc_tls_open_req.time_source"); +_Static_assert(offsetof(rpc_tls_open_req, unix_time) == 8, "rpc_tls_open_req.unix_time"); +_Static_assert(offsetof(rpc_tls_open_req, tag) == 12, "rpc_tls_open_req.tag"); +_Static_assert(offsetof(rpc_tls_open_req, opts) == 14, "rpc_tls_open_req.opts"); +_Static_assert(offsetof(rpc_tls_open_req, reserved) == 15, "rpc_tls_open_req.reserved"); +_Static_assert(offsetof(rpc_tls_open_req, ca_tag) == 16, "rpc_tls_open_req.ca_tag"); +_Static_assert(offsetof(rpc_tls_open_req, reserved2) == 18, "rpc_tls_open_req.reserved2"); +_Static_assert(offsetof(rpc_tls_open_req, pin) == 20, "rpc_tls_open_req.pin"); +_Static_assert(offsetof(rpc_tls_open_req, sni) == 52, "rpc_tls_open_req.sni"); +_Static_assert(sizeof(rpc_tls_open_resp) == 12, "rpc_tls_open_resp size"); +_Static_assert(offsetof(rpc_tls_open_resp, esp_err) == 4, "rpc_tls_open_resp.esp_err"); +_Static_assert(offsetof(rpc_tls_open_resp, slot) == 8, "rpc_tls_open_resp.slot"); +_Static_assert(offsetof(rpc_tls_open_resp, reason) == 9, "rpc_tls_open_resp.reason"); +_Static_assert(offsetof(rpc_tls_open_resp, reserved) == 10, "rpc_tls_open_resp.reserved"); +_Static_assert(sizeof(rpc_tls_step_req) == 12, "rpc_tls_step_req size"); +_Static_assert(offsetof(rpc_tls_step_req, slot) == 4, "rpc_tls_step_req.slot"); +_Static_assert(offsetof(rpc_tls_step_req, flags) == 5, "rpc_tls_step_req.flags"); +_Static_assert(offsetof(rpc_tls_step_req, tag) == 6, "rpc_tls_step_req.tag"); +_Static_assert(offsetof(rpc_tls_step_req, ct_in_len) == 8, "rpc_tls_step_req.ct_in_len"); +_Static_assert(offsetof(rpc_tls_step_req, pt_in_len) == 10, "rpc_tls_step_req.pt_in_len"); +_Static_assert(offsetof(rpc_tls_step_req, data) == 12, "rpc_tls_step_req.data"); +_Static_assert(sizeof(rpc_tls_step_resp) == 20, "rpc_tls_step_resp size"); +_Static_assert(offsetof(rpc_tls_step_resp, esp_err) == 4, "rpc_tls_step_resp.esp_err"); +_Static_assert(offsetof(rpc_tls_step_resp, state) == 8, "rpc_tls_step_resp.state"); +_Static_assert(offsetof(rpc_tls_step_resp, alert_in) == 9, "rpc_tls_step_resp.alert_in"); +_Static_assert(offsetof(rpc_tls_step_resp, ct_out_len) == 10, "rpc_tls_step_resp.ct_out_len"); +_Static_assert(offsetof(rpc_tls_step_resp, pt_out_len) == 12, "rpc_tls_step_resp.pt_out_len"); +_Static_assert(offsetof(rpc_tls_step_resp, alert_out) == 14, "rpc_tls_step_resp.alert_out"); +_Static_assert(offsetof(rpc_tls_step_resp, fail_reason) == 15, "rpc_tls_step_resp.fail_reason"); +_Static_assert(offsetof(rpc_tls_step_resp, verify_flags) == 16, "rpc_tls_step_resp.verify_flags"); +_Static_assert(offsetof(rpc_tls_step_resp, data) == 20, "rpc_tls_step_resp.data"); +_Static_assert(sizeof(rpc_tls_session_req) == 8, "rpc_tls_session_req size"); +_Static_assert(offsetof(rpc_tls_session_req, slot) == 4, "rpc_tls_session_req.slot"); +_Static_assert(offsetof(rpc_tls_session_req, reserved) == 5, "rpc_tls_session_req.reserved"); +_Static_assert(offsetof(rpc_tls_session_req, tag) == 6, "rpc_tls_session_req.tag"); +_Static_assert(sizeof(rpc_tls_close_resp) == 12, "rpc_tls_close_resp size"); +_Static_assert(offsetof(rpc_tls_close_resp, esp_err) == 4, "rpc_tls_close_resp.esp_err"); +_Static_assert(offsetof(rpc_tls_close_resp, ct_out_len) == 8, "rpc_tls_close_resp.ct_out_len"); +_Static_assert(offsetof(rpc_tls_close_resp, reserved) == 10, "rpc_tls_close_resp.reserved"); +_Static_assert(offsetof(rpc_tls_close_resp, data) == 12, "rpc_tls_close_resp.data"); +_Static_assert(sizeof(rpc_espcmd_resp) == 8, "rpc_espcmd_resp size"); +_Static_assert(offsetof(rpc_espcmd_resp, esp_err) == 4, "rpc_espcmd_resp.esp_err"); +_Static_assert(sizeof(rpc_tls_stats_resp) == 96, "rpc_tls_stats_resp size"); +_Static_assert(offsetof(rpc_tls_stats_resp, esp_err) == 4, "rpc_tls_stats_resp.esp_err"); +_Static_assert(offsetof(rpc_tls_stats_resp, heap_free) == 8, "rpc_tls_stats_resp.heap_free"); +_Static_assert(offsetof(rpc_tls_stats_resp, heap_min) == 12, "rpc_tls_stats_resp.heap_min"); +_Static_assert(offsetof(rpc_tls_stats_resp, largest_block) == 16, "rpc_tls_stats_resp.largest_block"); +_Static_assert(offsetof(rpc_tls_stats_resp, ct_in_bytes) == 20, "rpc_tls_stats_resp.ct_in_bytes"); +_Static_assert(offsetof(rpc_tls_stats_resp, ct_out_bytes) == 24, "rpc_tls_stats_resp.ct_out_bytes"); +_Static_assert(offsetof(rpc_tls_stats_resp, pt_in_bytes) == 28, "rpc_tls_stats_resp.pt_in_bytes"); +_Static_assert(offsetof(rpc_tls_stats_resp, pt_out_bytes) == 32, "rpc_tls_stats_resp.pt_out_bytes"); +_Static_assert(offsetof(rpc_tls_stats_resp, handshake_us) == 36, "rpc_tls_stats_resp.handshake_us"); +_Static_assert(offsetof(rpc_tls_stats_resp, tls_version) == 40, "rpc_tls_stats_resp.tls_version"); +_Static_assert(offsetof(rpc_tls_stats_resp, ciphersuite) == 42, "rpc_tls_stats_resp.ciphersuite"); +_Static_assert(offsetof(rpc_tls_stats_resp, group) == 44, "rpc_tls_stats_resp.group"); +_Static_assert(offsetof(rpc_tls_stats_resp, state) == 46, "rpc_tls_stats_resp.state"); +_Static_assert(offsetof(rpc_tls_stats_resp, sessions_open) == 47, "rpc_tls_stats_resp.sessions_open"); +_Static_assert(offsetof(rpc_tls_stats_resp, stack_free) == 48, "rpc_tls_stats_resp.stack_free"); +_Static_assert(offsetof(rpc_tls_stats_resp, esp_time) == 52, "rpc_tls_stats_resp.esp_time"); +_Static_assert(offsetof(rpc_tls_stats_resp, time_source) == 56, "rpc_tls_stats_resp.time_source"); +_Static_assert(offsetof(rpc_tls_stats_resp, entropy_source) == 57, "rpc_tls_stats_resp.entropy_source"); +_Static_assert(offsetof(rpc_tls_stats_resp, ems) == 58, "rpc_tls_stats_resp.ems"); +_Static_assert(offsetof(rpc_tls_stats_resp, reserved) == 59, "rpc_tls_stats_resp.reserved"); +_Static_assert(offsetof(rpc_tls_stats_resp, block_max_ms) == 60, "rpc_tls_stats_resp.block_max_ms"); +_Static_assert(offsetof(rpc_tls_stats_resp, reserved2) == 62, "rpc_tls_stats_resp.reserved2"); +_Static_assert(offsetof(rpc_tls_stats_resp, spki_sha256) == 64, "rpc_tls_stats_resp.spki_sha256"); +_Static_assert(sizeof(rpc_tls_set_ca_req) == 8, "rpc_tls_set_ca_req size"); +_Static_assert(offsetof(rpc_tls_set_ca_req, der_len) == 4, "rpc_tls_set_ca_req.der_len"); +_Static_assert(offsetof(rpc_tls_set_ca_req, ca_tag) == 6, "rpc_tls_set_ca_req.ca_tag"); +_Static_assert(offsetof(rpc_tls_set_ca_req, der) == 8, "rpc_tls_set_ca_req.der"); +_Static_assert(sizeof(rpc_tls_set_ca_resp) == 12, "rpc_tls_set_ca_resp size"); +_Static_assert(offsetof(rpc_tls_set_ca_resp, esp_err) == 4, "rpc_tls_set_ca_resp.esp_err"); +_Static_assert(offsetof(rpc_tls_set_ca_resp, reject) == 8, "rpc_tls_set_ca_resp.reject"); +_Static_assert((TLS_TIME_NONE == 0) && (TLS_TIME_NIOS == 1) && (TLS_TIME_SNTP == 2), "tls_time_source_t"); +_Static_assert((TLS_STATE_HANDSHAKING == 0) && (TLS_STATE_ESTABLISHED == 1) && + (TLS_STATE_CLOSED == 2) && (TLS_STATE_FAILED == 3), "tls_state_t"); +_Static_assert((TLS_TRUST_BUNDLE == 0) && (TLS_TRUST_CUSTOM == 1) && (TLS_TRUST_PIN == 2), "tls_trust_t"); +_Static_assert((TLS_FAIL_VERSION_REFUSED == 1) && (TLS_FAIL_DOWNGRADE == 2) && (TLS_FAIL_NO_EMS == 3) && + (TLS_FAIL_CERT_VERIFY == 4) && (TLS_FAIL_PIN_MISMATCH == 5) && (TLS_FAIL_PEER_CLOSED == 6), "tls_fail_reason_t"); +_Static_assert((TLS_OPEN_REASON_NO_ENTROPY == 1) && (TLS_OPEN_REASON_NO_TIME == 2) && (TLS_OPEN_REASON_NO_CUSTOM_CA == 3), + "rpc_tls_open_resp.reason"); +_Static_assert((TLS_CA_REJECT_RSA_KEY_SHORT == 1) && (TLS_CA_REJECT_CURVE == 3) && (TLS_CA_REJECT_NOT_CA == 4), + "rpc_tls_set_ca_resp.reject"); +// Every request and reply must fit one command buffer +_Static_assert(sizeof(rpc_tls_open_req) + TLS_SNI_MAX_LEN <= CMD_BUF_SIZE, "largest CMD_TLS_OPEN request"); +_Static_assert(sizeof(rpc_tls_step_req) + TLS_STEP_IN_MAX <= CMD_BUF_SIZE, "largest CMD_TLS_STEP request"); +_Static_assert(sizeof(rpc_tls_step_resp) + TLS_STEP_OUT_MAX <= CMD_BUF_SIZE, "largest CMD_TLS_STEP reply"); +_Static_assert(sizeof(rpc_tls_close_resp) + TLS_STEP_OUT_MAX <= CMD_BUF_SIZE, "largest CMD_TLS_CLOSE reply"); +_Static_assert(sizeof(rpc_tls_set_ca_req) + TLS_CA_MAX_LEN <= CMD_BUF_SIZE, "largest CMD_TLS_SET_CA request"); +_Static_assert(sizeof(rpc_tls_stats_resp) <= CMD_BUF_SIZE, "CMD_TLS_STATS reply"); +_Static_assert(TLS_SNI_MAX_LEN <= 255, "sni_len is a byte"); + +void cmd_not_implemented(command_buf_t *buf); + +static QueueHandle_t tls_queue; +static volatile uint16_t block_max_ms; // the longest dispatcher iteration since boot, read by the TLS task + +void cmd_tls_open(command_buf_t *buf) +{ + rpc_tls_open_req *req = (rpc_tls_open_req *)buf->data; + rpc_tls_open_resp *resp = (rpc_tls_open_resp *)buf->data; + + // tls_open() copies the pin and the host name before the response overwrites them + uint8_t slot = TLS_SLOT_GLOBAL; + uint8_t reason = TLS_OPEN_REASON_NONE; + int err = ESP_ERR_INVALID_ARG; + if ((buf->size >= (int)sizeof(rpc_tls_open_req)) && (buf->size == (int)sizeof(rpc_tls_open_req) + req->sni_len)) { + tls_open_params_t p = { + .trust = req->trust, .opts = req->opts, .time_source = req->time_source, .ca_tag = req->ca_tag, + .unix_time = req->unix_time, .pin = req->pin, .sni = req->sni, .sni_len = req->sni_len, + }; + err = tls_open(req->slot, req->tag, &p, &reason); + if (err == ESP_OK) { + slot = req->slot; + } + } + memset(&resp->esp_err, 0, sizeof(rpc_tls_open_resp) - sizeof(rpc_header_t)); + resp->esp_err = err; + resp->slot = slot; + resp->reason = reason; + buf->size = sizeof(rpc_tls_open_resp); + my_uart_transmit_packet(UART_CHAN, buf); +} + +void cmd_tls_step(command_buf_t *buf) +{ + rpc_tls_step_req *req = (rpc_tls_step_req *)buf->data; + rpc_tls_step_resp *resp = (rpc_tls_step_resp *)buf->data; + + // The response overlays the request: tls_step() consumes ct_in and pt_in before it writes resp->data + uint16_t ct_out_len = 0; + uint16_t pt_out_len = 0; + tls_step_result_t result = { .state = TLS_STATE_CLOSED, .alert_in = TLS_ALERT_NONE, .alert_out = TLS_ALERT_NONE }; + int err = ESP_ERR_INVALID_ARG; + if (buf->size >= (int)sizeof(rpc_tls_step_req)) { + int ct_in_len = req->ct_in_len; + int pt_in_len = req->pt_in_len; + if (buf->size == (int)sizeof(rpc_tls_step_req) + ct_in_len + pt_in_len) { + err = tls_step(req->slot, req->tag, req->flags, req->data, ct_in_len, req->data + ct_in_len, pt_in_len, + resp->data, &ct_out_len, &pt_out_len, &result); + } else { + tls_session_stats_t stats; + tls_get_stats(req->slot, req->tag, &stats); + result.state = stats.state; + } + } + memset(&resp->esp_err, 0, sizeof(rpc_tls_step_resp) - sizeof(rpc_header_t)); + resp->esp_err = err; + resp->state = result.state; + resp->alert_in = result.alert_in; + resp->ct_out_len = ct_out_len; + resp->pt_out_len = pt_out_len; + resp->alert_out = result.alert_out; + resp->fail_reason = result.fail_reason; + resp->verify_flags = result.verify_flags; + buf->size = sizeof(rpc_tls_step_resp) + ct_out_len + pt_out_len; + my_uart_transmit_packet(UART_CHAN, buf); +} + +void cmd_tls_close(command_buf_t *buf) +{ + rpc_tls_session_req *req = (rpc_tls_session_req *)buf->data; + rpc_tls_close_resp *resp = (rpc_tls_close_resp *)buf->data; + + // The close_notify goes to resp->data, which starts past the request + uint16_t ct_out_len = 0; + int err = ESP_ERR_INVALID_ARG; + if (buf->size >= (int)sizeof(rpc_tls_session_req)) { + err = tls_close(req->slot, req->tag, resp->data, &ct_out_len); + } + memset(&resp->esp_err, 0, sizeof(rpc_tls_close_resp) - sizeof(rpc_header_t)); + resp->esp_err = err; + resp->ct_out_len = ct_out_len; + buf->size = sizeof(rpc_tls_close_resp) + ct_out_len; + my_uart_transmit_packet(UART_CHAN, buf); +} + +void cmd_tls_stats(command_buf_t *buf) +{ + rpc_tls_session_req *req = (rpc_tls_session_req *)buf->data; + rpc_tls_stats_resp *resp = (rpc_tls_stats_resp *)buf->data; + + // Heap figures come with every reply, also when the session is gone + tls_session_stats_t stats; + int err = ESP_ERR_INVALID_ARG; + if (buf->size >= (int)sizeof(rpc_tls_session_req)) { + err = tls_get_stats(req->slot, req->tag, &stats); + } else { + tls_get_stats(TLS_SLOT_GLOBAL, 0, &stats); + } + memset(&resp->esp_err, 0, sizeof(rpc_tls_stats_resp) - sizeof(rpc_header_t)); + resp->esp_err = err; + resp->heap_free = heap_caps_get_free_size(TLS_HEAP_CAPS); + resp->heap_min = heap_caps_get_minimum_free_size(TLS_HEAP_CAPS); + resp->largest_block = heap_caps_get_largest_free_block(TLS_HEAP_CAPS); + resp->ct_in_bytes = stats.ct_in_bytes; + resp->ct_out_bytes = stats.ct_out_bytes; + resp->pt_in_bytes = stats.pt_in_bytes; + resp->pt_out_bytes = stats.pt_out_bytes; + resp->handshake_us = stats.handshake_us; + resp->tls_version = stats.tls_version; + resp->ciphersuite = stats.ciphersuite; + resp->group = stats.group; + resp->state = stats.state; + resp->sessions_open = tls_sessions_open(); + resp->stack_free = uxTaskGetStackHighWaterMark(NULL); // this runs on the TLS task + resp->esp_time = stats.esp_time; + resp->time_source = stats.time_source; + resp->entropy_source = entropy_source(); + resp->ems = stats.ems; + resp->block_max_ms = block_max_ms; + memcpy(resp->spki_sha256, stats.spki_sha256, sizeof(resp->spki_sha256)); + buf->size = sizeof(rpc_tls_stats_resp); + my_uart_transmit_packet(UART_CHAN, buf); +} + +void cmd_tls_close_all(command_buf_t *buf) +{ + rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; + tls_close_all(); + resp->esp_err = ESP_OK; + buf->size = sizeof(rpc_espcmd_resp); + my_uart_transmit_packet(UART_CHAN, buf); +} + +void cmd_tls_set_ca(command_buf_t *buf) +{ + rpc_tls_set_ca_req *req = (rpc_tls_set_ca_req *)buf->data; + rpc_tls_set_ca_resp *resp = (rpc_tls_set_ca_resp *)buf->data; + + // tls_set_ca() parses the certificate before the response overwrites it + uint8_t reject = TLS_CA_REJECT_NONE; + int err = ESP_ERR_INVALID_ARG; + if ((buf->size >= (int)sizeof(rpc_tls_set_ca_req)) && (buf->size == (int)sizeof(rpc_tls_set_ca_req) + req->der_len)) { + err = tls_set_ca(req->der, req->der_len, req->ca_tag, &reject); + } else { + tls_set_ca(NULL, 0, 0, &reject); // a malformed upload still leaves no CA held + } + memset(&resp->esp_err, 0, sizeof(rpc_tls_set_ca_resp) - sizeof(rpc_header_t)); + resp->esp_err = err; + resp->reject = reject; + buf->size = sizeof(rpc_tls_set_ca_resp); + my_uart_transmit_packet(UART_CHAN, buf); +} + +// The TLS task's side: runs one TLS command and transmits its reply +void tls_serve(command_buf_t *buf) +{ + rpc_header_t *hdr = (rpc_header_t *)buf->data; + switch (hdr->command) { + case CMD_TLS_OPEN: + cmd_tls_open(buf); + break; + case CMD_TLS_STEP: + cmd_tls_step(buf); + break; + case CMD_TLS_CLOSE: + cmd_tls_close(buf); + break; + case CMD_TLS_STATS: + cmd_tls_stats(buf); + break; + case CMD_TLS_CLOSE_ALL: + cmd_tls_close_all(buf); + break; + case CMD_TLS_SET_CA: + cmd_tls_set_ca(buf); + break; + default: + cmd_not_implemented(buf); + break; + } +} + +static void tls_task(void *arg) +{ + command_buf_t *buf; + while (1) { + if (xQueueReceive(tls_queue, &buf, portMAX_DELAY) == pdTRUE) { + tls_serve(buf); + } + } +} + +// The TLS queue is full: the command's own reply shape, all zero but for ESP_ERR_TIMEOUT +static void cmd_tls_busy(command_buf_t *buf) +{ + rpc_header_t *hdr = (rpc_header_t *)buf->data; + int size; + switch (hdr->command) { + case CMD_TLS_OPEN: size = sizeof(rpc_tls_open_resp); break; + case CMD_TLS_STEP: size = sizeof(rpc_tls_step_resp); break; + case CMD_TLS_CLOSE: size = sizeof(rpc_tls_close_resp); break; + case CMD_TLS_STATS: size = sizeof(rpc_tls_stats_resp); break; + case CMD_TLS_SET_CA: size = sizeof(rpc_tls_set_ca_resp); break; + default: size = sizeof(rpc_espcmd_resp); break; + } + memset(buf->data + sizeof(rpc_header_t), 0, size - sizeof(rpc_header_t)); + ((rpc_espcmd_resp *)buf->data)->esp_err = ESP_ERR_TIMEOUT; + if (hdr->command == CMD_TLS_OPEN) { + ((rpc_tls_open_resp *)buf->data)->slot = TLS_SLOT_GLOBAL; + } else if (hdr->command == CMD_TLS_STEP) { + ((rpc_tls_step_resp *)buf->data)->alert_in = TLS_ALERT_NONE; + ((rpc_tls_step_resp *)buf->data)->alert_out = TLS_ALERT_NONE; + } + buf->size = size; + my_uart_transmit_packet(UART_CHAN, buf); +} + void cmd_not_implemented(command_buf_t *buf) { rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; @@ -283,11 +603,89 @@ void send_keepalive() } } +// One command on the dispatcher. TLS commands go to the TLS task, so a handshake never blocks +// Wi-Fi TX; the time each command holds the dispatcher is what TLS_STATS reports as block_max_ms. +void dispatch_command(command_buf_t *pbuffer) +{ + rpc_header_t *hdr = (rpc_header_t *)(pbuffer->data); + int64_t start = esp_timer_get_time(); + switch(hdr->command) { + case CMD_SEND_PACKET: + cmd_send_eth_packet(pbuffer); + break; + case CMD_ECHO: + cmd_echo(pbuffer); + break; + case CMD_IDENTIFY: + cmd_identify(pbuffer); + break; + case CMD_SET_BAUD: + cmd_setbaud(pbuffer); + break; + case CMD_WIFI_SCAN: + cmd_scan(pbuffer); + break; + case CMD_WIFI_CONNECT: + cmd_wifi_connect(pbuffer); + break; + case CMD_WIFI_DISCONNECT: + cmd_wifi_disconnect(pbuffer); + break; + case CMD_WIFI_AUTOCONNECT: + cmd_wifi_autoconnect(pbuffer); + break; + case CMD_WIFI_GETMAC: + cmd_getmac(pbuffer); + break; + case CMD_MACHINE_OFF: + cmd_off(pbuffer); + break; + case CMD_MODEM_ON: + cmd_modem_on(pbuffer); + break; + case CMD_MODEM_OFF: + cmd_modem_off(pbuffer); + break; + case CMD_WIFI_DISABLE: + case CMD_WIFI_ENABLE: + cmd_wifi_endisable(pbuffer); + break; + case CMD_WIFI_IS_CONNECTED: + cmd_get_connection(pbuffer); + break; + case CMD_GET_TIME: + cmd_get_time(pbuffer); + break; + case CMD_CLEAR_APS: + cmd_clear_aps(pbuffer); + break; + case CMD_GET_RANDOM: + cmd_get_random(pbuffer); + break; + case CMD_TLS_OPEN: + case CMD_TLS_STEP: + case CMD_TLS_CLOSE: + case CMD_TLS_STATS: + case CMD_TLS_CLOSE_ALL: + case CMD_TLS_SET_CA: + if (xQueueSend(tls_queue, &pbuffer, 0) != pdTRUE) { + cmd_tls_busy(pbuffer); + } + break; + default: + cmd_not_implemented(pbuffer); + break; + } + int64_t ms = (esp_timer_get_time() - start) / 1000; + if (ms > block_max_ms) { + block_max_ms = (ms > 0xFFFF) ? 0xFFFF : (uint16_t)ms; + } +} + void dispatch(void *ct) { QueueHandle_t queue = (QueueHandle_t)ct; command_buf_t *pbuffer; - rpc_header_t *hdr; int led = 0; printf("Dispatcher Start. Queue = %p\n", queue); @@ -302,69 +700,15 @@ void dispatch(void *ct) #if UART_DEBUG_RX printf("Received buffer %d with %d bytes.\n", pbuffer->bufnr, pbuffer->size); #endif - hdr = (rpc_header_t *)(pbuffer->data); - switch(hdr->command) { - case CMD_SEND_PACKET: - cmd_send_eth_packet(pbuffer); - break; - case CMD_ECHO: - cmd_echo(pbuffer); - break; - case CMD_IDENTIFY: - cmd_identify(pbuffer); - break; - case CMD_SET_BAUD: - cmd_setbaud(pbuffer); - break; - case CMD_WIFI_SCAN: - cmd_scan(pbuffer); - break; - case CMD_WIFI_CONNECT: - cmd_wifi_connect(pbuffer); - break; - case CMD_WIFI_DISCONNECT: - cmd_wifi_disconnect(pbuffer); - break; - case CMD_WIFI_AUTOCONNECT: - cmd_wifi_autoconnect(pbuffer); - break; - case CMD_WIFI_GETMAC: - cmd_getmac(pbuffer); - break; - case CMD_MACHINE_OFF: - cmd_off(pbuffer); - break; - case CMD_MODEM_ON: - cmd_modem_on(pbuffer); - break; - case CMD_MODEM_OFF: - cmd_modem_off(pbuffer); - break; - case CMD_WIFI_DISABLE: - case CMD_WIFI_ENABLE: - cmd_wifi_endisable(pbuffer); - break; - case CMD_WIFI_IS_CONNECTED: - cmd_get_connection(pbuffer); - break; - case CMD_GET_TIME: - cmd_get_time(pbuffer); - break; - case CMD_CLEAR_APS: - cmd_clear_aps(pbuffer); - break; - case CMD_GET_RANDOM: - cmd_get_random(pbuffer); - break; - default: - cmd_not_implemented(pbuffer); - break; - } + dispatch_command(pbuffer); } } void start_dispatch(QueueHandle_t queue) { + // TLS on core 1, as Wi-Fi is pinned to core 0 (CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0), at the dispatcher's priority + tls_queue = xQueueCreate(TLS_QUEUE_DEPTH, sizeof(command_buf_t *)); + xTaskCreatePinnedToCore(tls_task, "TLS", TLS_TASK_STACK, NULL, tskIDLE_PRIORITY + 1, NULL, 1); // Core 1, above the system tasks: the UART ISR that feeds this queue runs on core 1 too xTaskCreatePinnedToCore( dispatch, "Dispatch Task", DISPATCHER_STACK, queue, 19, NULL, 1 ); } diff --git a/software/wifi/raw_u64/main/rpc_dispatch.h b/software/wifi/raw_u64/main/rpc_dispatch.h index d4a00f720..3c6541e01 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.h +++ b/software/wifi/raw_u64/main/rpc_dispatch.h @@ -22,12 +22,16 @@ typedef struct { void create_dispatchers(int stacksize, command_buf_context_t *bufs); void dispatch(void *ct); +void dispatch_command(command_buf_t *buf); +void tls_serve(command_buf_t *buf); void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.10" +#define IDENT_STRING "ESP32 WiFi Bridge V1.11" #define IDENT_MAJOR 1 +// 1.11: TLS client sessions (CMD_TLS_*) on their own task, and the Mozilla root list of +// software/u64ctrl/ca as the certificate bundle. // 1.10: CMD_GET_RANDOM, served with the radio off too, from the SAR ADC source. // 1.9: turns its radio off and on when asked (CMD_WIFI_DISABLE / CMD_WIFI_ENABLE) and // starts with it off until the Ultimate sends Enable or Autoconnect (or, without the @@ -42,8 +46,10 @@ void send_keepalive(); // Disconnected forever. The Ultimate's updater only reflashes the module // when this differs from what the module reports, so a module change that // does not bump it is silently never installed. -#define IDENT_MINOR 10 +#define IDENT_MINOR 11 #define MULTITHREADED 0 -#define DISPATCHER_STACK 3072 +#define DISPATCHER_STACK 3072 // TLS runs on its own task, so this stays small +#define TLS_TASK_STACK 8192 // twice the stack handshakes were measured to use on the dispatcher +#define TLS_QUEUE_DEPTH 2 // one request outstanding, and a CLOSE behind a step that timed out #endif /* SOFTWARE_WIFI_SCAN_MAIN_RPC_DISPATCH_H_ */ diff --git a/software/wifi/raw_u64/main/sntp.c b/software/wifi/raw_u64/main/sntp.c index 0b471d5df..271a15d28 100644 --- a/software/wifi/raw_u64/main/sntp.c +++ b/software/wifi/raw_u64/main/sntp.c @@ -21,6 +21,12 @@ #include "rpc_calls.h" static const char *TAG = "sntp"; +static volatile int time_synced; + +int sntp_has_time(void) +{ + return time_synced; +} void ____sntp_sync_time(struct timeval *tv) { @@ -33,6 +39,7 @@ void time_sync_notification_cb(struct timeval *tv) { ESP_LOGI(TAG, "Notification of a time synchronization event, time set to %ld s %ld us", (long int)tv->tv_sec, (long int)tv->tv_usec); settimeofday(tv, NULL); + time_synced = 1; } #ifndef INET6_ADDRSTRLEN diff --git a/software/wifi/raw_u64/main/sntp.h b/software/wifi/raw_u64/main/sntp.h index 5b4b64099..6ad2f14db 100644 --- a/software/wifi/raw_u64/main/sntp.h +++ b/software/wifi/raw_u64/main/sntp.h @@ -8,6 +8,7 @@ void configure_sntp_servers(void); void obtain_time(void); void print_time(void); void sntp_get_time(const char *zone, esp_datetime_t *datetime); +int sntp_has_time(void); // nonzero once an SNTP sync has set the clock void print_all_zones(void); void print_time_for_zone(const char *zone); diff --git a/software/wifi/raw_u64/main/tls_engine.c b/software/wifi/raw_u64/main/tls_engine.c new file mode 100644 index 000000000..a3d8dc3d9 --- /dev/null +++ b/software/wifi/raw_u64/main/tls_engine.c @@ -0,0 +1,852 @@ +/* tls_engine.c: TLS sessions on the UCI network target. mbedTLS runs a TLS 1.3 client with a hardened TLS 1.2 fallback; + * the Ultimate pumps the ciphertext between its TCP socket and CMD_TLS_STEP. The bio callbacks never block (per-session + * input and output buffers). Everything here runs on the TLS task only. */ + +// Reads a few private mbedtls_ssl_context fields that have no getter (handshake state and version, the message just +// processed). It includes nothing from mbedTLS's library/ (ssl_misc.h): a fork with another +// mbedtls_ssl_handshake_params layout would otherwise be read at the wrong offsets. +#define MBEDTLS_ALLOW_PRIVATE_ACCESS +#include +#include +#include +#include +#include "sdkconfig.h" +#include "freertos/FreeRTOS.h" +#include "esp_err.h" +#include "esp_log.h" +#include "esp_timer.h" +#include "esp_heap_caps.h" +#include "mbedtls/ssl.h" +#include "mbedtls/x509_crt.h" +#include "psa/crypto.h" +#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE +#include "esp_crt_bundle.h" +#endif +#include "cmd_buffer.h" +#include "wifi_modem.h" +#include "sntp.h" +#include "tls_engine.h" + +#if !CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 || !CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 +#error "The engine offers TLS 1.3 with a TLS 1.2 fallback: enable CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 and _TLS1_2" +#endif +#if MBEDTLS_VERSION_MAJOR < 4 +#error "This engine is written for mbedTLS 4 (ESP-IDF 6): randomness and allocation failures come from PSA" +#endif +#if !CONFIG_MBEDTLS_HAVE_TIME_DATE +#error "Without CONFIG_MBEDTLS_HAVE_TIME_DATE certificate dates are ignored: an expired certificate would verify" +#endif +#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE && !CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY +#error "The bundle needs CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY: without it most servers' cross-signed chains fail" +#endif +#if !defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) +#error "TLS 1.2 needs the extended master secret, which this mbedTLS configuration leaves out" +#endif +#if defined(MBEDTLS_SSL_RENEGOTIATION) +#error "Renegotiation must stay off (CONFIG_MBEDTLS_SSL_RENEGOTIATION)" +#endif + +#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE +// esp_crt_bundle.c's verify callback: external linkage but not in its header (as IDF's own unit test declares it) +int esp_crt_verify_callback(void *buf, mbedtls_x509_crt *crt, int depth, uint32_t *flags); +#endif + +#ifndef TLS_IN_BUF_SIZE // a host test shrinks it to reach a full input buffer while handshaking +#define TLS_IN_BUF_SIZE (2 * TLS_STEP_IN_MAX) // unread ciphertext from the Ultimate +#endif +#define TLS_OUT_BUF_SIZE 2048 // ciphertext not yet collected by a step +// Step room kept free of plaintext for an alert that a failing read writes: header 5 + tag 16 + +// alert padded to at most 32 (CONFIG_MBEDTLS_SSL_CID_PADDING_GRANULARITY range 0..32) = 53 +#define TLS_ALERT_ROOM 64 +// NewSessionTickets one mbedtls_ssl_write() may run into; each is taken on its own, so this only bounds a loop +#define TLS_TICKET_RETRIES 4 + +_Static_assert(TLS_OUT_BUF_SIZE > TLS_STEP_IN_MAX, "one step of plaintext must fit the output buffer"); + +// The CUSTOM CA. A session holds its own reference, so replacing or clearing the CA never frees it under a +// session that is still verifying with it. +typedef struct { + mbedtls_x509_crt crt; + uint16_t tag; + int refs; +} tls_ca_t; + +typedef struct { + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + tls_ca_t *ca; // CUSTOM + uint16_t tag; + uint8_t trust; + uint8_t opts; + uint8_t pin[TLS_PIN_LEN]; + uint8_t pin_mismatch; + uint8_t bundle_rejected; + uint8_t ems_checked; + tls_session_stats_t stats; + int in_off; + int in_len; + int out_len; + uint8_t in_buf[TLS_IN_BUF_SIZE]; + uint8_t out_buf[TLS_OUT_BUF_SIZE]; +} tls_session_t; + +static const char *TAG = "tls"; +static tls_session_t *sessions[TLS_MAX_SESSIONS]; +static tls_ca_t *custom_ca; +// PIN: mbedTLS verifies only with a CA chain configured (and a TLS 1.3 client needs one), so an empty one. +// Zeroed is the state mbedtls_x509_crt_init() leaves; verification only reads it. +static mbedtls_x509_crt tls_empty_ca; +static int psa_ready; +static int clock_set_by_nios; + +// The six hardened TLS 1.2 suites and the three TLS 1.3 ones, in mbedTLS's own order of preference +static const int tls_ciphersuites[] = { + MBEDTLS_TLS1_3_CHACHA20_POLY1305_SHA256, + MBEDTLS_TLS1_3_AES_256_GCM_SHA384, + MBEDTLS_TLS1_3_AES_128_GCM_SHA256, + MBEDTLS_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + 0 +}; + +// Key-exchange groups for both versions: mbedTLS 4's default list adds x448 and FFDHE +// 2048-8192 (an 8192-bit modexp on the ESP32). mbedTLS keeps the pointer, so static. +static const uint16_t tls_groups[] = { + MBEDTLS_SSL_IANA_TLS_GROUP_X25519, MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1, + MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1, MBEDTLS_SSL_IANA_TLS_GROUP_SECP521R1, + MBEDTLS_SSL_IANA_TLS_GROUP_NONE +}; + +static int tls_bio_send(void *ctx, const unsigned char *buf, size_t len) +{ + tls_session_t *s = (tls_session_t *)ctx; + size_t room = TLS_OUT_BUF_SIZE - s->out_len; + if (room == 0) { + return MBEDTLS_ERR_SSL_WANT_WRITE; + } + if (len > room) { + len = room; + } + memcpy(s->out_buf + s->out_len, buf, len); + s->out_len += len; + return (int)len; +} + +static int tls_bio_recv(void *ctx, unsigned char *buf, size_t len) +{ + tls_session_t *s = (tls_session_t *)ctx; + size_t avail = s->in_len - s->in_off; + if (avail == 0) { + return MBEDTLS_ERR_SSL_WANT_READ; + } + if (len > avail) { + len = avail; + } + memcpy(buf, s->in_buf + s->in_off, len); + s->in_off += len; + return (int)len; +} + +// Every session's verify callback, set on the ssl context (mbedtls_ssl_set_verify) so it overrides the config's and +// esp_crt_bundle_attach() cannot replace it. It returns 0 so the verify result stays decodable; a rejection still +// fails the handshake because it leaves flags set. +static int tls_verify(void *ctx, mbedtls_x509_crt *crt, int depth, uint32_t *flags) +{ + tls_session_t *s = (tls_session_t *)ctx; + int hashed = 0; + if (depth == 0) { + size_t n = 0; + hashed = psa_hash_compute(PSA_ALG_SHA_256, crt->pk_raw.p, crt->pk_raw.len, s->stats.spki_sha256, + sizeof(s->stats.spki_sha256), &n) == PSA_SUCCESS; + if (!hashed) { + memset(s->stats.spki_sha256, 0, sizeof(s->stats.spki_sha256)); + } + } + switch (s->trust) { +#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE + case TLS_TRUST_BUNDLE: + if (esp_crt_verify_callback(NULL, crt, depth, flags) != 0) { + *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + s->bundle_rejected = 1; + } + break; +#endif + case TLS_TRUST_PIN: + // The key is the identity: chain, dates and name are not checked. The mode comes from trust alone. + *flags = 0; + if ((depth == 0) && (!hashed || memcmp(s->stats.spki_sha256, s->pin, TLS_PIN_LEN) != 0)) { + s->pin_mismatch = 1; + *flags = MBEDTLS_X509_BADCERT_NOT_TRUSTED; + } + break; + default: // CUSTOM: mbedTLS's own chain verification against the uploaded CA + break; + } + return 0; +} + +// 00:00 UTC on the day this file was compiled: a clock before it cannot be right +static time_t tls_build_time(void) +{ + static const char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; + const char *date = __DATE__; // "Mmm dd yyyy" + int m = 1; + while ((m < 12) && strncmp(months + 3 * (m - 1), date, 3)) { + m++; + } + int d = atoi(date + 4); + int y = atoi(date + 7) - (m <= 2); + // Days since 1970-01-01 in the proleptic Gregorian calendar (days_from_civil) + int era = y / 400; + int yoe = y - era * 400; + int doy = (153 * (m + ((m > 2) ? -3 : 9)) + 2) / 5 + d - 1; + int doe = yoe * 365 + yoe / 4 - yoe / 100 + doy; + return (time_t)(era * 146097 + doe - 719468) * 86400; +} + +// The clock an OPEN may use. SNTP wins: the Ultimate's time is only taken when the ESP32 has no SNTP time, +// and only when the Ultimate says it is SNTP time too (time_source). Reports the source used for this OPEN; +// a clock an earlier OPEN set does not count. +static uint8_t tls_set_clock(uint8_t time_source, uint32_t unix_time) +{ + time_t floor = tls_build_time(); + if (sntp_has_time() && (time(NULL) > floor)) { + return TLS_TIME_SNTP; + } + if ((time_source == TLS_TIME_NIOS) && ((time_t)unix_time > floor)) { + struct timeval tv = { .tv_sec = (time_t)unix_time, .tv_usec = 0 }; + if (settimeofday(&tv, NULL) == 0) { + clock_set_by_nios = 1; + return TLS_TIME_NIOS; + } + } + return TLS_TIME_NONE; +} + +// ESP-IDF 6 initialises PSA at startup, so this is a no-op there; it stays for builds that do not. Neither +// the init nor a certificate parse draws random bytes. +static int tls_psa_ready(void) +{ + if (!psa_ready) { + psa_status_t status = psa_crypto_init(); + if (status != PSA_SUCCESS) { + ESP_LOGE(TAG, "psa_crypto_init: %d", (int)status); + return 0; + } + psa_ready = 1; + } + return 1; +} + +static tls_session_t *tls_find(uint8_t slot, uint16_t tag) +{ + if (slot >= TLS_MAX_SESSIONS) { + return NULL; + } + tls_session_t *s = sessions[slot]; + return (s && (s->tag == tag)) ? s : NULL; +} + +static void tls_ca_release(tls_ca_t *ca) +{ + if (ca && (--ca->refs == 0)) { + mbedtls_x509_crt_free(&ca->crt); + free(ca); + } +} + +static void tls_free(tls_session_t *s) +{ + for (int i = 0; i < TLS_MAX_SESSIONS; i++) { + if (sessions[i] == s) { + sessions[i] = NULL; + } + } + mbedtls_ssl_free(&s->ssl); + mbedtls_ssl_config_free(&s->conf); + tls_ca_release(s->ca); + // The certificate bundle is shared: esp_crt_bundle_detach() would free it under the other session + free(s); +} + +int tls_sessions_open(void) +{ + int n = 0; + for (int i = 0; i < TLS_MAX_SESSIONS; i++) { + if (sessions[i]) { + n++; + } + } + return n; +} + +// Builds a complete session without putting it in the table; frees it on failure +static int tls_setup(tls_session_t **out, uint16_t tag, const tls_open_params_t *p, const char *hostname, + uint8_t time_source) +{ + *out = NULL; + tls_session_t *s = calloc(1, sizeof(tls_session_t)); + if (!s) { + return ESP_ERR_NO_MEM; + } + s->tag = tag; + s->trust = p->trust; + s->opts = p->opts; + if (p->trust == TLS_TRUST_PIN) { + memcpy(s->pin, p->pin, TLS_PIN_LEN); + } + s->stats.state = TLS_STATE_HANDSHAKING; + s->stats.time_source = time_source; + s->stats.esp_time = (time_source == TLS_TIME_NONE) ? 0 : (uint32_t)time(NULL); + mbedtls_ssl_init(&s->ssl); + mbedtls_ssl_config_init(&s->conf); + + // Every random byte (client random, key shares) comes from PSA: see tls_open() + int ret = mbedtls_ssl_config_defaults(&s->conf, MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT); + if (ret == 0) { + // TLS 1.3, and the hardened TLS 1.2 unless the program requires 1.3 + mbedtls_ssl_conf_min_tls_version(&s->conf, (p->opts & TLS_OPT_REQUIRE_TLS13) ? MBEDTLS_SSL_VERSION_TLS1_3 + : MBEDTLS_SSL_VERSION_TLS1_2); + mbedtls_ssl_conf_max_tls_version(&s->conf, MBEDTLS_SSL_VERSION_TLS1_3); + // The CBC suites are compiled in (wpa_supplicant needs AES-CBC): only this list keeps them out + mbedtls_ssl_conf_ciphersuites(&s->conf, tls_ciphersuites); + mbedtls_ssl_conf_groups(&s->conf, tls_groups); + // Offered here, and required after the ServerHello (tls_note_handshake): mbedTLS has no switch for that + mbedtls_ssl_conf_extended_master_secret(&s->conf, MBEDTLS_SSL_EXTENDED_MS_ENABLED); + // No session_ticket extension in TLS 1.2 (TLS 1.3 tickets are taken and dropped as before) + mbedtls_ssl_conf_session_tickets(&s->conf, MBEDTLS_SSL_SESSION_TICKETS_DISABLED); + mbedtls_ssl_conf_authmode(&s->conf, MBEDTLS_SSL_VERIFY_REQUIRED); + // One config per session: a CUSTOM or PIN config never has the bundle attached, since a config with the + // bundle's CA callback makes mbedTLS ignore conf->ca_chain + if (p->trust == TLS_TRUST_CUSTOM) { + s->ca = custom_ca; + s->ca->refs++; + mbedtls_ssl_conf_ca_chain(&s->conf, &s->ca->crt, NULL); + } else if (p->trust == TLS_TRUST_PIN) { + mbedtls_ssl_conf_ca_chain(&s->conf, &tls_empty_ca, NULL); + } +#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE + if (p->trust == TLS_TRUST_BUNDLE) { + ret = esp_crt_bundle_attach(&s->conf); + } +#endif + } + if (ret == 0) { + ret = mbedtls_ssl_setup(&s->ssl, &s->conf); + } + if (ret == 0) { + // No name: mbedTLS 4 refuses to verify unless set_hostname was called, so NULL explicitly (no SNI) + ret = mbedtls_ssl_set_hostname(&s->ssl, p->sni_len ? hostname : NULL); + } + if (ret != 0) { + ESP_LOGW(TAG, "Open failed: -0x%04x", (unsigned)-ret); + tls_free(s); + return ret; + } + mbedtls_ssl_set_verify(&s->ssl, tls_verify, s); + mbedtls_ssl_set_bio(&s->ssl, s, tls_bio_send, tls_bio_recv, NULL); + *out = s; + return 0; +} + +int tls_open(uint8_t slot, uint16_t tag, const tls_open_params_t *p, uint8_t *reason) +{ + char hostname[TLS_SNI_MAX_LEN + 1]; + + *reason = TLS_OPEN_REASON_NONE; + // Verifying without a host name would skip the name check, so only PIN may go without one + if ((slot >= TLS_MAX_SESSIONS) || (tag == 0) || (p->trust > TLS_TRUST_PIN) || + (p->opts & ~TLS_OPT_REQUIRE_TLS13) || (p->time_source > TLS_TIME_NIOS) || + (p->sni_len < 0) || (p->sni_len > TLS_SNI_MAX_LEN) || (memchr(p->sni, 0, p->sni_len) != NULL) || + ((p->trust != TLS_TRUST_PIN) && (p->sni_len == 0))) { + return ESP_ERR_INVALID_ARG; + } + // The slot is the Ultimate's: whatever it still holds there is an orphan (its OPEN or CLOSE was lost) + if (sessions[slot]) { + ESP_LOGW(TAG, "OPEN into slot %d frees the session held there under tag %u", slot, sessions[slot]->tag); + tls_free(sessions[slot]); + } + if (entropy_source() == ENTROPY_NONE) { + *reason = TLS_OPEN_REASON_NO_ENTROPY; + return ESP_ERR_INVALID_STATE; + } + uint8_t time_source = tls_set_clock(p->time_source, p->unix_time); + if ((p->trust != TLS_TRUST_PIN) && (time_source == TLS_TIME_NONE)) { + // Never verify against a 1970 clock: every validity check would be meaningless + ESP_LOGW(TAG, "Open refused: BUNDLE and CUSTOM need a clock, and neither unix_time nor SNTP gave one"); + *reason = TLS_OPEN_REASON_NO_TIME; + return ESP_ERR_INVALID_STATE; + } + if ((p->trust == TLS_TRUST_CUSTOM) && !(custom_ca && (p->ca_tag != 0) && (custom_ca->tag == p->ca_tag))) { + *reason = TLS_OPEN_REASON_NO_CUSTOM_CA; + return ESP_ERR_INVALID_STATE; + } +#if !CONFIG_MBEDTLS_CERTIFICATE_BUNDLE + if (p->trust == TLS_TRUST_BUNDLE) { + return ESP_ERR_NOT_SUPPORTED; + } +#endif + // All randomness comes from PSA, which (MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) keeps no seeded state and draws every byte + // from esp_fill_random() when needed. The entropy gate above runs at OPEN only and the handshake steps draw later: + // this relies on the bridge never stopping the radio once started. + if (!tls_psa_ready()) { + return ESP_FAIL; + } + memcpy(hostname, p->sni, p->sni_len); + hostname[p->sni_len] = 0; + + if (tls_sessions_open() == 0) { + // heap_min then reports the peak of this burst of sessions, not of the Wi-Fi start + heap_caps_monitor_local_minimum_free_size_stop(); + heap_caps_monitor_local_minimum_free_size_start(); + } + tls_session_t *s = NULL; + int ret = tls_setup(&s, tag, p, hostname, time_source); + if (ret != 0) { + return ret; + } + sessions[slot] = s; + return ESP_OK; +} + +// The handshake message mbedTLS has just processed (ssl->in_msg, reassembled, header included), when it is +// of the given type and complete; NULL otherwise +static const uint8_t *tls_hs_msg(tls_session_t *s, uint8_t type, size_t *len) +{ + const uint8_t *m = s->ssl.in_msg; + size_t n = s->ssl.in_hslen; + if (!m || (s->ssl.in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE) || (n < 4) || (m[0] != type) || + ((size_t)((m[1] << 16) | (m[2] << 8) | m[3]) != n - 4)) { + return NULL; + } + *len = n; + return m; +} + +// Finds an extension of a ServerHello (or HelloRetryRequest); returns its data length, -1 when absent (also when +// a TLS 1.2 ServerHello has no extensions block at all), or -2 when the message is malformed +static int tls_sh_ext(const uint8_t *m, size_t len, uint16_t type, const uint8_t **data) +{ + const uint8_t *p = m + 4, *end = m + len; + if (end - p < 2 + 32 + 1) { + return -2; + } + p += 2 + 32; // legacy_version, random + if (end - p < 1 + p[0] + 2 + 1) { + return -2; + } + p += 1 + p[0]; // session id + p += 2 + 1; // cipher suite, compression + if (p == end) { + return -1; + } + if (end - p < 2) { + return -2; + } + const uint8_t *eend = p + 2 + ((p[0] << 8) | p[1]); + p += 2; + if (eend > end) { + return -2; + } + while (eend - p >= 4) { + int t = (p[0] << 8) | p[1], n = (p[2] << 8) | p[3]; + if (eend - p - 4 < n) { + return -2; + } + if (t == type) { + *data = p + 4; + return n; + } + p += 4 + n; + } + return -1; +} + +// After each successful handshake step: records the negotiated group (no mbedTLS getter) from the TLS 1.3 ServerHello +// key_share (or the HelloRetryRequest group) or the TLS 1.2 ServerKeyExchange curve, and requires EMS in a TLS 1.2 +// ServerHello, as mbedTLS has just parsed them. Returns MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE when EMS is not echoed. +static int tls_note_handshake(tls_session_t *s, int state_before, int version_before) +{ + int state = s->ssl.state; + const uint8_t *m, *d; + size_t len; + if ((state_before == MBEDTLS_SSL_SERVER_HELLO) && (state != MBEDTLS_SSL_SERVER_HELLO)) { + m = tls_hs_msg(s, MBEDTLS_SSL_HS_SERVER_HELLO, &len); + if (version_before == MBEDTLS_SSL_VERSION_TLS1_3) { + if (m && (tls_sh_ext(m, len, 51, &d) >= 2)) { // key_share: the group comes first in both forms + s->stats.group = (d[0] << 8) | d[1]; + } + // Not found: the group stays 0, and tls_handshake() refuses the session + } else if (!s->ems_checked) { + // mbedtls_ssl_conf_extended_master_secret() only offers it: a server that does not echo it is accepted + // (ssl_tls12_client.c:742-759), so the engine refuses it here, before any key is derived. A ServerHello + // it cannot find counts as one without EMS: fail closed. + s->ems_checked = 1; + s->stats.ems = m && (tls_sh_ext(m, len, 23, &d) == 0); + if (!s->stats.ems) { + ESP_LOGW(TAG, "TLS 1.2 server without the extended master secret: refused"); + mbedtls_ssl_send_alert_message(&s->ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE); + return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; + } + } + } + if ((state_before == MBEDTLS_SSL_SERVER_KEY_EXCHANGE) && (version_before == MBEDTLS_SSL_VERSION_TLS1_2) && + (m = tls_hs_msg(s, MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE, &len)) != NULL && (len >= 4 + 3) && (m[4] == 3)) { + s->stats.group = (m[5] << 8) | m[6]; // ECParameters: named_curve (3), then the NamedGroup + } + return 0; +} + +// Classifies a failed handshake step for the Ultimate's failure reasons. The Ultimate infers nothing from bare mbedTLS codes. +static void tls_classify(tls_session_t *s, int ret, int state_before, int version_before, tls_step_result_t *r) +{ + if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { + r->fail_reason = TLS_FAIL_PEER_CLOSED; + } else if ((state_before == MBEDTLS_SSL_SERVER_HELLO) && (ret == MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION)) { + // A TLS 1.2 ServerHello below the minimum: the 1.2 parser has set tls_version to the server's choice + r->fail_reason = TLS_FAIL_VERSION_REFUSED; + r->verify_flags = (uint16_t)s->ssl.tls_version; + } else if ((state_before == MBEDTLS_SSL_SERVER_HELLO) && (version_before == MBEDTLS_SSL_VERSION_TLS1_3) && + (ret == MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER)) { + // This one step is all of mbedTLS's TLS 1.3 ServerHello processing (ssl_tls13_client.c:1995-2060), so + // ILLEGAL_PARAMETER has many causes. Only a ServerHello without supported_versions chose TLS 1.2 or lower, and + // of those only one whose random ends in the RFC 8446 4.1.3 sentinel is a downgrade; all else is fail_reason 0. + size_t len; + const uint8_t *d, *m = tls_hs_msg(s, MBEDTLS_SSL_HS_SERVER_HELLO, &len); + if (m && (len >= 4 + 2 + 32) && (tls_sh_ext(m, len, 43, &d) == -1)) { + const uint8_t *tail = m + 4 + 2 + 32 - 8; // the last 8 bytes of the random + if (s->opts & TLS_OPT_REQUIRE_TLS13) { + r->fail_reason = TLS_FAIL_VERSION_REFUSED; + r->verify_flags = (m[4] << 8) | m[5]; // legacy_version: the version it chose + } else if (!memcmp(tail, "\x44\x4F\x57\x4E\x47\x52\x44", 7) && (tail[7] <= 1)) { + r->fail_reason = TLS_FAIL_DOWNGRADE; + } + } + } else if (ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) { + r->fail_reason = ((s->trust == TLS_TRUST_PIN) && s->pin_mismatch) ? TLS_FAIL_PIN_MISMATCH : TLS_FAIL_CERT_VERIFY; + r->verify_flags = mbedtls_ssl_get_verify_result(&s->ssl); + } else if (ret == MBEDTLS_ERR_SSL_BAD_CERTIFICATE) { + // A secondary check (usage, TLS 1.2 curve), or a Certificate message refused before verification ran + r->fail_reason = TLS_FAIL_CERT_VERIFY; + r->verify_flags = mbedtls_ssl_get_verify_result(&s->ssl); + } else if (ret == MBEDTLS_ERR_X509_FATAL_ERROR) { + r->fail_reason = TLS_FAIL_CERT_VERIFY; + r->verify_flags = 0xFFFFFFFF; + } +} + +// Runs handshake steps until mbedTLS wants input or output, the handshake is over, or it fails +static int tls_handshake(tls_session_t *s, tls_step_result_t *r) +{ + while (!mbedtls_ssl_is_handshake_over(&s->ssl)) { + int state_before = s->ssl.state; + int version_before = s->ssl.tls_version; + int64_t start = esp_timer_get_time(); + int ret = mbedtls_ssl_handshake_step(&s->ssl); + s->stats.handshake_us += (uint32_t)(esp_timer_get_time() - start); + int ems = (ret == 0) ? tls_note_handshake(s, state_before, version_before) : 0; + if (ems) { + r->fail_reason = TLS_FAIL_NO_EMS; + return ems; + } + if ((ret == MBEDTLS_ERR_SSL_WANT_READ) || (ret == MBEDTLS_ERR_SSL_WANT_WRITE)) { + return 0; + } + if (ret != 0) { + tls_classify(s, ret, state_before, version_before, r); + return ret; + } + } + if (s->stats.group == 0) { + // The group is never 0 once ESTABLISHED: if it was not found, the reads above no longer match this + // mbedTLS, and nothing they check (EMS) can be trusted either. Fail closed. + ESP_LOGE(TAG, "Negotiated group not found in the server's messages: session refused"); + mbedtls_ssl_send_alert_message(&s->ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR); + return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; + } + s->stats.state = TLS_STATE_ESTABLISHED; + s->stats.tls_version = (uint16_t)mbedtls_ssl_get_version_number(&s->ssl); + s->stats.ciphersuite = (uint16_t)mbedtls_ssl_get_ciphersuite_id_from_ssl(&s->ssl); + return 0; +} + +int tls_step(uint8_t slot, uint16_t tag, uint8_t flags, const uint8_t *ct_in, int ct_in_len, const uint8_t *pt_in, + int pt_in_len, uint8_t *out, uint16_t *ct_out_len, uint16_t *pt_out_len, tls_step_result_t *r) +{ + tls_session_t *s = tls_find(slot, tag); + *ct_out_len = 0; + *pt_out_len = 0; + r->alert_in = TLS_ALERT_NONE; + r->alert_out = TLS_ALERT_NONE; + r->fail_reason = TLS_FAIL_NONE; + r->verify_flags = 0; + if (!s) { + r->state = TLS_STATE_CLOSED; + return ESP_ERR_NOT_FOUND; + } + r->state = s->stats.state; + + // Caller errors consume nothing, return nothing and leave the session as it is + if ((flags & ~TLS_STEP_NO_READ) || (ct_in_len < 0) || (pt_in_len < 0) || (ct_in_len + pt_in_len > TLS_STEP_IN_MAX)) { + return ESP_ERR_INVALID_ARG; + } + if (pt_in_len && (s->stats.state != TLS_STATE_ESTABLISHED)) { + return ESP_ERR_INVALID_STATE; + } + // A full buffer refuses the input with ESP_ERR_NO_MEM, but the step still returns output, + // so the Ultimate can send the same step again until it is taken + int ret = 0; + int refused = (ct_in_len > TLS_IN_BUF_SIZE - (s->in_len - s->in_off)) ? ESP_ERR_NO_MEM : ESP_OK; + if (!refused && pt_in_len) { + // mbedtls_ssl_write() must never see WANT_WRITE: it would keep part of pt_in for a + // repeat call, and with output pending it reports len written without copying it + int payload = mbedtls_ssl_get_max_out_record_payload(&s->ssl); + int expansion = mbedtls_ssl_get_record_expansion(&s->ssl); + if (payload <= 0) { + ret = payload ? payload : MBEDTLS_ERR_SSL_INTERNAL_ERROR; + } else if (expansion < 0) { + ret = expansion; + } else { + int need = pt_in_len + ((pt_in_len + payload - 1) / payload) * expansion; + if (need > TLS_OUT_BUF_SIZE) { + return ESP_ERR_INVALID_ARG; // could never fit: send less plaintext per step + } + if (need > TLS_OUT_BUF_SIZE - s->out_len) { + refused = ESP_ERR_NO_MEM; + } + } + } + + if (!refused && (ret == 0)) { + if (s->in_off) { + memmove(s->in_buf, s->in_buf + s->in_off, s->in_len - s->in_off); + s->in_len -= s->in_off; + s->in_off = 0; + } + memcpy(s->in_buf + s->in_len, ct_in, ct_in_len); + s->in_len += ct_in_len; + s->stats.ct_in_bytes += ct_in_len; + } + // While handshaking only the handshake drains in_buf, so it also runs when the input was refused: + // otherwise a full in_buf would refuse every resend of the step + int just_established = 0; + if (ret == 0) { + if (s->stats.state == TLS_STATE_HANDSHAKING) { + ret = tls_handshake(s, r); + just_established = (s->stats.state == TLS_STATE_ESTABLISHED); + } else if (!refused && pt_in_len) { + if (s->ssl.out_left != 0) { + ret = MBEDTLS_ERR_SSL_INTERNAL_ERROR; + } + for (int done = 0, tickets = 0; (ret == 0) && (done < pt_in_len); ) { + int n = mbedtls_ssl_write(&s->ssl, pt_in + done, pt_in_len - done); + if (n > 0) { + done += n; + } else if ((n == MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET) && (++tickets <= TLS_TICKET_RETRIES)) { + // A ticket an earlier read left pending: mbedtls_ssl_write() took it first and wrote + // nothing, so write again (ssl_msg.c:5938-5942 in mbedTLS 4.1.1). Not a failure. + continue; + } else { + ret = n ? n : MBEDTLS_ERR_SSL_INTERNAL_ERROR; + } + } + if (ret == 0) { + s->stats.pt_in_bytes += pt_in_len; + } + } + } + // From here on out may be written: the input is either consumed or refused + + // No plaintext from the step that reaches ESTABLISHED (the Ultimate reads STATS right after it), nor from + // a NO_READ step (a WRITE's): what is pending stays in the engine for the next plain step + int ct_len = (s->out_len < TLS_STEP_OUT_MAX) ? s->out_len : TLS_STEP_OUT_MAX; + int pt_len = 0; + while ((ret == 0) && (s->stats.state == TLS_STATE_ESTABLISHED) && !just_established && !(flags & TLS_STEP_NO_READ) && + (ct_len + pt_len + TLS_ALERT_ROOM < TLS_STEP_OUT_MAX)) { + int in_before = s->in_off; + int n = mbedtls_ssl_read(&s->ssl, out + ct_len + pt_len, TLS_STEP_OUT_MAX - TLS_ALERT_ROOM - ct_len - pt_len); + if (n > 0) { + pt_len += n; + } else if ((n == MBEDTLS_ERR_SSL_WANT_READ) && mbedtls_ssl_check_pending(&s->ssl)) { + // A complete ticket makes mbedtls_ssl_read() return WANT_READ with the ticket kept for the + // next call (ssl_msg.c:5466-5473 in mbedTLS 4.1.1), which takes it without new input. + // Take every one now, or the reply behind them waits for a step the Ultimate never sends. + continue; + } else if ((n == MBEDTLS_ERR_SSL_WANT_READ) && (s->in_off > in_before) && (s->in_off < s->in_len)) { + // A record mbedTLS skipped with WANT_READ (a TLS 1.2 no_renegotiation warning alert, + // ssl_msg.c:5002-5006) while more input waits: read on, or the data behind it would wait + // for another step. The read took input, so this ends. + continue; + } else if ((n == MBEDTLS_ERR_SSL_WANT_READ) || (n == MBEDTLS_ERR_SSL_WANT_WRITE)) { + break; + } else if (n == MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET) { + continue; // a TLS 1.3 ticket after the handshake: no plaintext yet, read again (never FAILED) + } else if (n == 0) { + // An empty application data record, which RFC 8446 allows: read on. It never means the + // connection closed, because tls_bio_recv() never reports end of input. + continue; + } else if (n == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { + s->stats.state = TLS_STATE_CLOSED; + } else { + ret = n; + } + } + s->stats.pt_out_bytes += pt_len; + + if (ret != 0) { + s->stats.state = TLS_STATE_FAILED; + if (ret == MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE) { + int alert = mbedtls_ssl_get_fatal_alert(&s->ssl); + r->alert_in = (alert >= 0) ? (uint8_t)alert : TLS_ALERT_NONE; + } + // The alert this engine sent, when mbedTLS wrote it before any keys (mbedTLS has no getter for it) + if ((s->ssl.out_msgtype == MBEDTLS_SSL_MSG_ALERT) && (s->ssl.transform_out == NULL) && + (s->ssl.out_msg[0] == MBEDTLS_SSL_ALERT_LEVEL_FATAL)) { + r->alert_out = s->ssl.out_msg[1]; + } + ESP_LOGW(TAG, "Session %d/%u failed: -0x%04x, reason %d, verify 0x%x", slot, tag, (unsigned)-ret, r->fail_reason, + (unsigned)r->verify_flags); + } + + // Ciphertext the reads produced (a fatal alert before the session is freed) goes out in this + // step too: move the plaintext up into the room the reads left for it + int ct_all = (s->out_len < TLS_STEP_OUT_MAX - pt_len) ? s->out_len : TLS_STEP_OUT_MAX - pt_len; + if (ct_all > ct_len) { + memmove(out + ct_all, out + ct_len, pt_len); + ct_len = ct_all; + } + memcpy(out, s->out_buf, ct_len); + memmove(s->out_buf, s->out_buf + ct_len, s->out_len - ct_len); + s->out_len -= ct_len; + s->stats.ct_out_bytes += ct_len; + *ct_out_len = ct_len; + *pt_out_len = pt_len; + + r->state = s->stats.state; + if ((s->stats.state == TLS_STATE_FAILED) || (s->stats.state == TLS_STATE_CLOSED)) { + tls_free(s); + } + return ret ? ret : refused; +} + +int tls_close(uint8_t slot, uint16_t tag, uint8_t *out, uint16_t *ct_out_len) +{ + *ct_out_len = 0; + tls_session_t *s = tls_find(slot, tag); + if (!s) { + return ESP_ERR_NOT_FOUND; + } + // Best effort: close_notify lands in out_buf behind anything still pending there. A session still + // handshaking has nothing to close, and its half flight is not sent. + if (s->stats.state == TLS_STATE_ESTABLISHED) { + mbedtls_ssl_close_notify(&s->ssl); + int n = (s->out_len < TLS_STEP_OUT_MAX) ? s->out_len : TLS_STEP_OUT_MAX; + memcpy(out, s->out_buf, n); + *ct_out_len = n; + } + tls_free(s); + return ESP_OK; +} + +void tls_close_all(void) +{ + for (int i = 0; i < TLS_MAX_SESSIONS; i++) { + if (sessions[i]) { + tls_free(sessions[i]); + } + } + tls_ca_release(custom_ca); + custom_ca = NULL; +} + +// SET_CA: the upload-time refusals, in their order of precedence +static uint8_t tls_ca_reject(const mbedtls_x509_crt *crt) +{ + psa_key_type_t type = mbedtls_pk_get_key_type(&crt->pk); + size_t bits = mbedtls_pk_get_bitlen(&crt->pk); + if (PSA_KEY_TYPE_IS_RSA(type) && (bits < mbedtls_x509_crt_profile_default.rsa_min_bitlen)) { + return TLS_CA_REJECT_RSA_KEY_SHORT; + } + if (PSA_KEY_TYPE_IS_ECC(type)) { + // The curves of mbedtls_x509_crt_profile_default, which the engine verifies with (x509_crt.c:98-104 in + // 4.1.1), not the key-exchange groups + psa_ecc_family_t family = PSA_KEY_TYPE_ECC_GET_FAMILY(type); + int ok = ((family == PSA_ECC_FAMILY_SECP_R1) && ((bits == 256) || (bits == 384) || (bits == 521))) || + ((family == PSA_ECC_FAMILY_BRAINPOOL_P_R1) && ((bits == 256) || (bits == 384) || (bits == 512))); + if (!ok) { + return TLS_CA_REJECT_CURVE; + } + } + // mbedTLS refuses such a certificate as an issuer. A v1 root has no extensions and is an anchor as it is; + // a keyUsage extension that is absent passes check_key_usage. + if (((crt->version >= 3) && (mbedtls_x509_crt_get_ca_istrue(crt) != 1)) || + (mbedtls_x509_crt_check_key_usage(crt, MBEDTLS_X509_KU_KEY_CERT_SIGN) != 0)) { + return TLS_CA_REJECT_NOT_CA; + } + return TLS_CA_REJECT_NONE; +} + +int tls_set_ca(const uint8_t *der, int der_len, uint16_t ca_tag, uint8_t *reject) +{ + *reject = TLS_CA_REJECT_NONE; + // The one held is dropped first: on any error none is held (a session keeps its own reference) + tls_ca_release(custom_ca); + custom_ca = NULL; + if ((der_len <= 0) || (der_len > TLS_CA_MAX_LEN) || (ca_tag == 0)) { + return ESP_ERR_INVALID_ARG; + } + if (!tls_psa_ready()) { + return ESP_ERR_INVALID_STATE; // never ESP_FAIL: the Ultimate reads a SET_CA ESP_FAIL as no reply + } + tls_ca_t *ca = calloc(1, sizeof(tls_ca_t)); + if (!ca) { + return ESP_ERR_NO_MEM; + } + mbedtls_x509_crt_init(&ca->crt); + ca->tag = ca_tag; + ca->refs = 1; + int ret = mbedtls_x509_crt_parse_der(&ca->crt, der, der_len); + if (ret == 0) { + *reject = tls_ca_reject(&ca->crt); + if (*reject != TLS_CA_REJECT_NONE) { + ret = ESP_ERR_INVALID_ARG; + } + } else if (ret > -2) { + ret = MBEDTLS_ERR_X509_INVALID_FORMAT; // never ESP_FAIL (-1), which the Ultimate does not read as a parse code + } + if (ret != 0) { + ESP_LOGW(TAG, "CA refused: %d, reject %d", ret, *reject); + tls_ca_release(ca); + return ret; + } + custom_ca = ca; + return ESP_OK; +} + +int tls_get_stats(uint8_t slot, uint16_t tag, tls_session_stats_t *stats) +{ + memset(stats, 0, sizeof(tls_session_stats_t)); + stats->state = TLS_STATE_CLOSED; + if ((slot == TLS_SLOT_GLOBAL) && (tag == 0)) { + time_t now = time(NULL); + if (now <= tls_build_time()) { + stats->time_source = TLS_TIME_NONE; + } else { + stats->time_source = sntp_has_time() ? TLS_TIME_SNTP : (clock_set_by_nios ? TLS_TIME_NIOS : TLS_TIME_NONE); + } + stats->esp_time = (stats->time_source == TLS_TIME_NONE) ? 0 : (uint32_t)now; + return ESP_OK; + } + tls_session_t *s = tls_find(slot, tag); + if (!s) { + return ESP_ERR_NOT_FOUND; + } + *stats = s->stats; + return ESP_OK; +} diff --git a/software/wifi/raw_u64/main/tls_engine.h b/software/wifi/raw_u64/main/tls_engine.h new file mode 100644 index 000000000..7c5f6e345 --- /dev/null +++ b/software/wifi/raw_u64/main/tls_engine.h @@ -0,0 +1,71 @@ +/* tls_engine.h: TLS client sessions whose ciphertext the Ultimate carries; the ESP32 never touches a socket. + * Every call is lock-step, and all of them run on the TLS task only. */ + +#ifndef TLS_ENGINE_H_ +#define TLS_ENGINE_H_ + +#include +#include "rpc_calls.h" + +#define TLS_HEAP_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) // what mbedTLS allocates from (esp_heap_caps.h) + +typedef struct { + uint32_t ct_in_bytes; + uint32_t ct_out_bytes; + uint32_t pt_in_bytes; + uint32_t pt_out_bytes; + uint32_t handshake_us; + uint16_t tls_version; + uint16_t ciphersuite; + uint16_t group; + uint8_t state; + uint8_t time_source; + uint8_t ems; + uint32_t esp_time; + uint8_t spki_sha256[TLS_PIN_LEN]; +} tls_session_stats_t; + +typedef struct { + uint8_t trust; // tls_trust_t + uint8_t opts; // TLS_OPT_* + uint8_t time_source; // TLS_TIME_NONE or TLS_TIME_NIOS: whether unix_time is a clock + uint16_t ca_tag; // CUSTOM: must equal the held CA's + uint32_t unix_time; + const uint8_t *pin; // TLS_PIN_LEN bytes, read for PIN only + const char *sni; // sni_len bytes, no terminator; none (sni_len 0) only with PIN + int sni_len; +} tls_open_params_t; + +typedef struct { + uint8_t state; // tls_state_t + uint8_t alert_in; // TLS_ALERT_NONE unless a fatal alert was received + uint8_t alert_out; // TLS_ALERT_NONE unless this engine sent an unencrypted fatal alert + uint8_t fail_reason; // tls_fail_reason_t, with FAILED + uint32_t verify_flags; +} tls_step_result_t; + +// All return ESP_OK, an esp_err_t, or a negative mbedTLS code. A (slot, tag) that is not the live session in that slot +// gets ESP_ERR_NOT_FOUND and touches nothing. A session is freed on FAILED, on CLOSED, by tls_close() and +// tls_close_all(), and when an OPEN names its slot again. + +// unix_time sets the ESP32 clock (time_source TLS_TIME_NIOS, and no SNTP time of its own). BUNDLE and CUSTOM need a +// trustworthy clock: without one OPEN fails with ESP_ERR_INVALID_STATE, reason NO_TIME. +int tls_open(uint8_t slot, uint16_t tag, const tls_open_params_t *params, uint8_t *reason); + +// Consumes all of ct_in (pt_in only when ESTABLISHED) or none, then writes ct_out and pt_out (no pt with NO_READ) to out, +// at most TLS_STEP_OUT_MAX; out may overlap the inputs. ESP_ERR_NO_MEM: buffer full, nothing consumed, output returned, +// resend. INVALID_ARG/INVALID_STATE/NOT_FOUND: nothing consumed or returned. A negative code comes with state FAILED. +int tls_step(uint8_t slot, uint16_t tag, uint8_t flags, const uint8_t *ct_in, int ct_in_len, const uint8_t *pt_in, + int pt_in_len, uint8_t *out, uint16_t *ct_out_len, uint16_t *pt_out_len, tls_step_result_t *result); + +// Frees the session; out gets its pending ciphertext and a close_notify (at most TLS_STEP_OUT_MAX) +int tls_close(uint8_t slot, uint16_t tag, uint8_t *out, uint16_t *ct_out_len); +// Frees every session and the CUSTOM CA +void tls_close_all(void); +// Parses one DER certificate as the CUSTOM CA under ca_tag, replacing the one held. On any error none is held. +int tls_set_ca(const uint8_t *der, int der_len, uint16_t ca_tag, uint8_t *reject); +// slot TLS_SLOT_GLOBAL with tag 0: the clock only +int tls_get_stats(uint8_t slot, uint16_t tag, tls_session_stats_t *stats); +int tls_sessions_open(void); + +#endif /* TLS_ENGINE_H_ */ diff --git a/software/wifi/raw_u64/main/tls_engine_stub.c b/software/wifi/raw_u64/main/tls_engine_stub.c new file mode 100644 index 000000000..7720a394a --- /dev/null +++ b/software/wifi/raw_u64/main/tls_engine_stub.c @@ -0,0 +1,72 @@ +/* tls_engine_stub.c: stands in for tls_engine.c in a size-measurement build (idf.py -D BRIDGE_TLS_STUB=1). The RPC + * commands stay and every TLS call answers ESP_ERR_NOT_SUPPORTED, so mbedTLS's TLS and X.509 code is not linked. + * Never flashed to a device. */ + +#include +#include "esp_err.h" +#include "tls_engine.h" + +int tls_open(uint8_t slot, uint16_t tag, const tls_open_params_t *params, uint8_t *reason) +{ + (void)slot; + (void)tag; + (void)params; + *reason = TLS_OPEN_REASON_NONE; + return ESP_ERR_NOT_SUPPORTED; +} + +int tls_step(uint8_t slot, uint16_t tag, uint8_t flags, const uint8_t *ct_in, int ct_in_len, const uint8_t *pt_in, + int pt_in_len, uint8_t *out, uint16_t *ct_out_len, uint16_t *pt_out_len, tls_step_result_t *result) +{ + (void)slot; + (void)tag; + (void)flags; + (void)ct_in; + (void)ct_in_len; + (void)pt_in; + (void)pt_in_len; + (void)out; + *ct_out_len = 0; + *pt_out_len = 0; + memset(result, 0, sizeof(tls_step_result_t)); + result->state = TLS_STATE_CLOSED; + result->alert_in = TLS_ALERT_NONE; + result->alert_out = TLS_ALERT_NONE; + return ESP_ERR_NOT_FOUND; +} + +int tls_close(uint8_t slot, uint16_t tag, uint8_t *out, uint16_t *ct_out_len) +{ + (void)slot; + (void)tag; + (void)out; + *ct_out_len = 0; + return ESP_ERR_NOT_FOUND; +} + +void tls_close_all(void) +{ +} + +int tls_set_ca(const uint8_t *der, int der_len, uint16_t ca_tag, uint8_t *reject) +{ + (void)der; + (void)der_len; + (void)ca_tag; + *reject = TLS_CA_REJECT_NONE; + return ESP_ERR_NOT_SUPPORTED; +} + +int tls_get_stats(uint8_t slot, uint16_t tag, tls_session_stats_t *stats) +{ + (void)slot; + (void)tag; + memset(stats, 0, sizeof(tls_session_stats_t)); + stats->state = TLS_STATE_CLOSED; + return ESP_ERR_NOT_SUPPORTED; +} + +int tls_sessions_open(void) +{ + return 0; +} diff --git a/software/wifi/raw_u64/sdkconfig b/software/wifi/raw_u64/sdkconfig index 2db5170f5..c8c754e8e 100644 --- a/software/wifi/raw_u64/sdkconfig +++ b/software/wifi/raw_u64/sdkconfig @@ -1099,7 +1099,6 @@ CONFIG_ESP_HTTPS_OTA_EVENT_POST_TIMEOUT=2000 # # ESP HTTPS server # -# CONFIG_ESP_HTTPS_SERVER_ENABLE is not set # default: # CONFIG_ESP_HTTPS_SERVER_CERT_SELECT_HOOK is not set # end of ESP HTTPS server @@ -1554,7 +1553,7 @@ CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=7 # CONFIG_ESP_WIFI_NAN_SYNC_ENABLE is not set CONFIG_ESP_WIFI_MBEDTLS_CRYPTO=y -CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y +# CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT is not set # CONFIG_ESP_WIFI_WAPI_PSK is not set # CONFIG_ESP_WIFI_11KV_SUPPORT is not set # CONFIG_ESP_WIFI_MBO_SUPPORT is not set @@ -2050,7 +2049,7 @@ CONFIG_MBEDTLS_ERROR_STRINGS=y CONFIG_MBEDTLS_VERSION_C=y CONFIG_MBEDTLS_HAVE_TIME=y # CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set -# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set +CONFIG_MBEDTLS_HAVE_TIME_DATE=y CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y # CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set # CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set @@ -2098,11 +2097,11 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y # # Certificate Bundle Configuration # -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL is not set # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set -# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEPRECATED_LIST is not set +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y +CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y +CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="../ca_store/cacert.pem" CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 # end of Certificate Bundle Configuration @@ -2118,15 +2117,31 @@ CONFIG_MBEDTLS_TLS_ENABLED=y # TLS Protocol Configuration # CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y -# CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 is not set -# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set +CONFIG_MBEDTLS_SSL_PROTO_TLS1_3=y + +# +# TLS 1.3 Configuration +# +# default: +CONFIG_MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE=y +# default: +CONFIG_MBEDTLS_SSL_TLS1_3_KEXM_PSK=y +# default: +CONFIG_MBEDTLS_SSL_TLS1_3_KEXM_EPHEMERAL=y # default: -CONFIG_MBEDTLS_TLS_SERVER=y +CONFIG_MBEDTLS_SSL_TLS1_3_KEXM_PSK_EPHEMERAL=y +# default: +# CONFIG_MBEDTLS_SSL_EARLY_DATA is not set +# end of TLS 1.3 Configuration + +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set # default: CONFIG_MBEDTLS_TLS_CLIENT=y -CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y +# CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT is not set # CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set -# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set +CONFIG_MBEDTLS_TLS_CLIENT_ONLY=y +# default: +CONFIG_MBEDTLS_SSL_CID_PADDING_GRANULARITY=16 CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y # CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set # default: @@ -2149,8 +2164,10 @@ CONFIG_MBEDTLS_SSL_SERVER_NAME_INDICATION=y CONFIG_MBEDTLS_SSL_ALPN=y # default: CONFIG_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH=y +# default: +# CONFIG_MBEDTLS_SSL_RECORD_SIZE_LIMIT is not set # CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set -CONFIG_MBEDTLS_SSL_RENEGOTIATION=y +# CONFIG_MBEDTLS_SSL_RENEGOTIATION is not set CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y # default: @@ -2254,7 +2271,7 @@ CONFIG_MBEDTLS_ROM_MD5=y # CONFIG_MBEDTLS_HARDWARE_SHA=y CONFIG_MBEDTLS_HARDWARE_MPI=y -# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set +CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI=y # # Security hardening @@ -2298,7 +2315,9 @@ CONFIG_MBEDTLS_PKCS1_V21=y # # Stream Cipher # -# CONFIG_MBEDTLS_CHACHA20_C is not set +# default: +CONFIG_MBEDTLS_CHACHAPOLY_C=y +CONFIG_MBEDTLS_CHACHA20_C=y # end of Stream Cipher # end of mbedTLS @@ -2718,7 +2737,7 @@ CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA=y # CONFIG_ESP_WIFI_NAN_ENABLE is not set CONFIG_WPA_MBEDTLS_CRYPTO=y -CONFIG_WPA_MBEDTLS_TLS_CLIENT=y +# CONFIG_WPA_MBEDTLS_TLS_CLIENT is not set # CONFIG_WPA_WAPI_PSK is not set # CONFIG_WPA_11KV_SUPPORT is not set # CONFIG_WPA_MBO_SUPPORT is not set diff --git a/tools/ca_store/ca_store.py b/tools/ca_store/ca_store.py new file mode 100644 index 000000000..5b75c69d4 --- /dev/null +++ b/tools/ca_store/ca_store.py @@ -0,0 +1,480 @@ +#!/usr/bin/env python3 +"""Checks the Mozilla root store the ESP32 bridge trusts for TLS, before every ESP32 build. + + ca_store.py check fail if the store, its pins and the sdkconfigs disagree; warn when + the store is older than CA_MAX_AGE_DAYS, and fail instead with + --release or RELEASE (not 0) in the environment + +The bridge's build runs the check at its configure step and again at every build, with +--project and --sdkconfig-json naming the configuration that build actually uses (which +`idf.py -D SDKCONFIG=...` can point away from the project's own sdkconfig). + +The store is the directory software/wifi/ca_store: cacert.pem, the bundle curl extracts from +Mozilla's certdata.txt (the same source ESP-IDF's own cacrt_all.pem comes from), and CA_PINS. +Each project in PROJECTS selects CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE and points +CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH at cacert.pem, so ESP-IDF's gen_crt_bundle.py builds +the device's bundle from it alone, and again whenever it changes. ESP-IDF refreshes its own copy +only on its release branches, and not always then: v6.0.3 ships Mozilla's data of 2025-12-02. + +There are no hand-kept anchors. ESP-IDF 6 verifies cross-signed chains +(CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY, which the bridge pins to y and its engine +refuses to build without), so a chain a server sends through a cross-sign verifies against the +newer root Mozilla still trusts. `check` refuses anchors.pem, or any other certificate file, in +the store. + +The Ultimate's updater reflashes a module only when the version the module reports differs from +the one it carries. CA_BUNDLE_SET_SHA256 pins the set of certificates the bundle is built from, +so `check` fails when that set changes without the pin, and refresh.py moves the pin together +with IDENT_MINOR of every project whose own sources attach the bundle. + +Only the standard library, so it runs in the build image and on a stock runner alike. +""" + +import argparse +import base64 +import datetime +import hashlib +import json +import os +import pathlib +import re +import sys + +REPO_ROOT = pathlib.Path(__file__).resolve().parents[2] +STORE_DIR = "software/wifi/ca_store" +PEM_NAME = "cacert.pem" +PINS_NAME = "CA_PINS" +# A file that must not be in the store: ESP-IDF 6 verifies cross-signed chains itself, so no hand-kept roots are needed. +ANCHORS_NAME = "anchors.pem" +PIN_KEYS = ("CA_SOURCE_URL", "CA_MOZILLA_DATE", "CA_SHA256", "CA_MAX_AGE_DAYS", "CA_CERTDATA_REF", + "CA_BUNDLE_SET_SHA256") +# The ESP-IDF 6 projects whose bundle comes from the store. raw_c3 and u64ctrl are built with +# ESP-IDF 5.3's bundle, which looks up only the issuer of the topmost certificate a server +# sends, so they would need hand-kept anchor roots; they keep ESP-IDF's own bundle. +PROJECTS = ("software/wifi/raw_u64",) + +DATE_PREFIX = "## Certificate data from Mozilla as of: " +BEGIN = "-----BEGIN CERTIFICATE-----" +END = "-----END CERTIFICATE-----" +ISO_FORMAT = "%Y-%m-%dT%H:%M:%SZ" +MONTHS = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") +# How far ahead of this host's clock a Mozilla date may be. A later one would make every real +# update look like a rollback, and the age gate would never fire again. +CLOCK_SLACK = datetime.timedelta(days=1) +# What a project's sources call when they verify servers against the bundle. A project that +# never calls it has no bundle in its image. +ATTACH = "esp_crt_bundle_attach" + + +class StoreError(Exception): + pass + + +def store_paths(repo_root): + store = pathlib.Path(repo_root) / STORE_DIR + return store / PEM_NAME, store / PINS_NAME + + +def write_atomically(path, data): + """Writes through a new file renamed into place, so a build never reads half a file.""" + path = pathlib.Path(path) + temporary = path.with_name(path.name + ".new") + temporary.write_bytes(data) + os.replace(str(temporary), str(path)) + + +# CA_PINS: KEY=VALUE lines and # comments, parsed like tests/crypto/PINS and shell-sourceable, +# so no value has quotes or spaces. + + +def read_pins(path): + pins = {} + for line in pathlib.Path(path).read_text().split("\n"): + line = line.split("#", 1)[0].strip() + if line: + if "=" not in line: + raise StoreError("%s: %r is not KEY=VALUE" % (path, line)) + key, value = line.split("=", 1) + pins[key] = value + missing = [key for key in PIN_KEYS if key not in pins] + if missing: + raise StoreError("%s: missing %s" % (path, ", ".join(missing))) + if not pins["CA_MAX_AGE_DAYS"].isdigit(): + raise StoreError("%s: CA_MAX_AGE_DAYS=%s is not a number of days" + % (path, pins["CA_MAX_AGE_DAYS"])) + return pins + + +def utc_now(): + return datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) + + +def write_pins(path, updates): + """Rewrites the given keys in place, keeping the order and the comments.""" + out = [] + for line in pathlib.Path(path).read_text().split("\n"): + key = line.split("=", 1)[0] + if "=" in line and not line.startswith("#") and key in updates: + line = "%s=%s" % (key, updates[key]) + out.append(line) + write_atomically(path, "\n".join(out).encode()) + + +# The PEM. + + +def mozilla_date(text): + for line in text.split("\n"): + if line.startswith(DATE_PREFIX): + return line[len(DATE_PREFIX):].strip() + raise StoreError("no '%s' line" % DATE_PREFIX.strip("# ")) + + +def parse_date(stamp): + # "Fri Sep 25 03:12:01 2026 GMT", parsed by hand so the host's locale cannot change it. + match = re.fullmatch(r"\w{3} (\w{3}) +(\d{1,2}) (\d\d):(\d\d):(\d\d) (\d{4}) GMT", stamp) + if not match or match.group(1) not in MONTHS: + raise StoreError("unrecognised Mozilla date %r" % stamp) + month, day, hour, minute, second, year = match.groups() + return datetime.datetime(int(year), MONTHS.index(month) + 1, int(day), + int(hour), int(minute), int(second)) + + +def iso(stamp): + """The header's date as CA_PINS holds it: 2026-09-25T03:12:01Z.""" + return parse_date(stamp).strftime(ISO_FORMAT) + + +def parse_iso(value): + try: + return datetime.datetime.strptime(value, ISO_FORMAT) + except ValueError: + raise StoreError("CA_MOZILLA_DATE=%s is not of the form 2026-09-25T03:12:01Z" % value) + + +def certificates(text): + """The DER of each certificate, after checking the file is whole.""" + ders = [] + inside = None + for line in text.split("\n"): + if line == BEGIN: + if inside is not None: + raise StoreError("certificate %d is not closed" % (len(ders) + 1)) + inside = [] + elif line == END: + if inside is None: + raise StoreError("END without BEGIN after certificate %d" % len(ders)) + try: + der = base64.b64decode("".join(inside), validate=True) + except ValueError: + raise StoreError("certificate %d is not valid base64" % (len(ders) + 1)) + if len(der) < 4 or der[0] != 0x30: + raise StoreError("certificate %d is not DER" % (len(ders) + 1)) + ders.append(der) + inside = None + elif inside is not None: + inside.append(line) + if inside is not None: + raise StoreError("the file ends inside certificate %d (truncated?)" % (len(ders) + 1)) + if not ders: + raise StoreError("no certificates") + if not text.endswith(END + "\n"): + raise StoreError("the file does not end with a whole certificate (truncated?)") + return ders + + +def names(text): + """The label curl writes above each certificate, in file order.""" + lines = text.split("\n") + return [lines[i - 2] for i, line in enumerate(lines) + if line == BEGIN and i >= 2 and lines[i - 1].startswith("=")] + + +def _tlv(der, pos): + """(tag, start of the value, end of the element) of the DER element at pos.""" + if pos + 2 > len(der): + raise StoreError("DER ends early") + tag, length = der[pos], der[pos + 1] + pos += 2 + if length & 0x80: + count = length & 0x7F + if count == 0 or count > 4 or pos + count > len(der): + raise StoreError("bad DER length") + length = int.from_bytes(der[pos:pos + count], "big") + pos += count + if pos + length > len(der): + raise StoreError("DER element runs past its end") + return tag, pos, pos + length + + +def subject_and_key(der): + """The subject name and the SubjectPublicKeyInfo of a certificate, each as DER. These are + the two things ESP-IDF's bundle keeps of a root.""" + _, start, _ = _tlv(der, 0) # Certificate + _, pos, _ = _tlv(der, start) # tbsCertificate + fields = [] + while len(fields) < 7: + tag, _, end = _tlv(der, pos) + if not (tag == 0xA0 and not fields): # skip the optional [0] version + fields.append(der[pos:end]) + pos = end + # serial, signature, issuer, validity, subject, subjectPublicKeyInfo + return fields[4], fields[5] + + +def roots(text): + """{sha256 fingerprint: (label, subject DER, key DER)} of every certificate in a store.""" + if not text: + return {} + ders = certificates(text) + labels = names(text) + if len(labels) != len(ders): + labels = ["(no label)"] * len(ders) + return {hashlib.sha256(der).hexdigest(): (label, *subject_and_key(der)) + for label, der in zip(labels, ders)} + + +def bundle_set_sha256(ders): + """CA_BUNDLE_SET_SHA256: the sha256 over the DER encodings, sorted and concatenated. DER is + self-delimiting, so the concatenation is unambiguous, and the order of the certificates does + not matter, as it does not to gen_crt_bundle.py.""" + return hashlib.sha256(b"".join(sorted(set(ders)))).hexdigest() + + +# The ESP32 projects that build their bundle from the store. + + +def has_line(text, line): + return line in text.split("\n") + + +def sdkconfig_from_json(path): + """A build's config/sdkconfig.json (what it really uses) in sdkconfig's own syntax.""" + try: + config = json.loads(pathlib.Path(path).read_text()) + except (OSError, ValueError) as error: + raise StoreError("cannot read the build's configuration %s: %s" % (path, error)) + lines = [] + for key, value in config.items(): + if value is True: + lines.append("CONFIG_%s=y" % key) + elif value is False: + lines.append("# CONFIG_%s is not set" % key) + elif isinstance(value, str): + lines.append('CONFIG_%s="%s"' % (key, value)) + else: + lines.append("CONFIG_%s=%s" % (key, value)) + return "\n".join(lines) + "\n" + + +def projects(repo_root, effective=None): + """(project dir, sdkconfig text) of every project in PROJECTS. effective maps a project dir + to the sdkconfig.json of the build at hand, which then stands for its sdkconfig.""" + repo_root = pathlib.Path(repo_root) + effective = {pathlib.Path(p).resolve(): j for p, j in (effective or {}).items()} + for project in effective: + if project not in [(repo_root / path).resolve() for path in PROJECTS]: + raise StoreError("%s is not one of the projects that use the store" % project) + found = [] + for path in PROJECTS: + project = repo_root / path + if project.resolve() in effective: + found.append((project, sdkconfig_from_json(effective[project.resolve()]))) + continue + sdkconfig = project / "sdkconfig" + if not sdkconfig.exists(): + raise StoreError("%s: no sdkconfig, but PROJECTS names it" % path) + found.append((project, sdkconfig.read_text())) + return found + + +def attaching(project): + """Whether a project's own sources (under main/, not ESP-IDF's) attach the bundle.""" + for path in sorted((pathlib.Path(project) / "main").rglob("*")): + if (path.suffix in (".c", ".cc", ".cpp", ".h") + and ATTACH in path.read_text(errors="replace")): + return True + return False + + +def bundle_misconfigured(repo_root, effective=None): + """Each project builds its bundle from cacert.pem and nothing else, and verifies cross-signed + chains, which is what lets the store go without anchors.""" + repo_root = pathlib.Path(repo_root) + pem = (repo_root / STORE_DIR / PEM_NAME).resolve() + problems = [] + for project, text in projects(repo_root, effective): + relative = (project / "sdkconfig").relative_to(repo_root) + if not has_line(text, "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y"): + problems.append("%s: CONFIG_MBEDTLS_CERTIFICATE_BUNDLE is off, so the store is not " + "used" % relative) + continue + match = re.search(r'^CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="(.*)"$', text, re.M) + if not match or (project / match.group(1)).resolve() != pem: + problems.append("%s: CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH does not name " + "%s/%s" % (relative, STORE_DIR, PEM_NAME)) + elif not has_line(text, "CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y"): + problems.append("%s: names the store but does not set " + "CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y, so the path is ignored" + % relative) + if not has_line(text, "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y"): + problems.append("%s: also takes ESP-IDF's default bundle; select " + "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE" % relative) + if not has_line(text, "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y"): + problems.append("%s: the store holds no anchors, so it needs " + "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y" % relative) + return problems + + +def max_certs(text): + match = re.search(r"^CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=(\d+)$", text, re.M) + return int(match.group(1)) if match else None + + +def bump_ident(project, date, new): + """IDENT_MINOR and IDENT_STRING moved to `new`, which must be above the current minor, with a + line saying why, as the header keeps them. The caller names the number: on a development line + the next one may already belong to another image. + + Returns (header, new text, new version) and writes nothing, so a caller can check every + project before it changes any file.""" + header = project / "main" / "rpc_dispatch.h" + if not header.exists(): + raise StoreError("%s uses the store but has no %s" % (project, header)) + text = header.read_text() + major = re.search(r"^#define IDENT_MAJOR\s+(\d+)$", text, re.M) + minor = re.search(r"^#define IDENT_MINOR\s+(\d+)$", text, re.M) + string = re.search(r'^#define IDENT_STRING "(.* V)(\d+)\.(\d+)"$', text, re.M) + if not (major and minor and string): + raise StoreError("%s: IDENT_MAJOR, IDENT_MINOR or IDENT_STRING not found" % header) + if (string.group(2), string.group(3)) != (major.group(1), minor.group(1)): + raise StoreError("%s: IDENT_STRING says %s.%s, IDENT_MAJOR/MINOR say %s.%s" % ( + header, string.group(2), string.group(3), major.group(1), minor.group(1))) + if new <= int(minor.group(1)): + raise StoreError("%s: IDENT_MINOR %d is not above %s" % (header, new, minor.group(1))) + version = "%s.%d" % (major.group(1), new) + text = (text[:minor.start()] + minor.group(0).replace(minor.group(1), str(new)) + + text[minor.end():]) + text = (text[:string.start()] + '#define IDENT_STRING "%s%s"' % (string.group(1), version) + + text[string.end():]) + major = re.search(r"^#define IDENT_MAJOR\s+\d+\n", text, re.M) + note = "// %s: the Mozilla root store as of %s.\n" % (version, date) + return header, text[:major.end()] + note + text[major.end():], version + + +# The check. + + +def check_store_dir(store_dir): + """Nothing but cacert.pem may hold certificates in the store: the anchors are retired, and a + directory bundle path would take every .pem and .der in it.""" + errors = [] + for path in sorted(pathlib.Path(store_dir).iterdir()): + if path.name == ANCHORS_NAME: + errors.append("%s: the anchors are retired on ESP-IDF 6, which verifies cross-signed " + "chains (CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY); remove " + "it" % ANCHORS_NAME) + elif path.suffix in (".pem", ".der", ".crt") and path.name != PEM_NAME: + errors.append("%s: only %s holds certificates in %s" % (path.name, PEM_NAME, STORE_DIR)) + return errors + + +def check(repo_root, release=False, today=None, now=None, effective=None): + """Returns (errors, warnings). effective: see projects().""" + pem_path, pins_path = store_paths(repo_root) + pins = read_pins(pins_path) + now = now or utc_now() + errors = [] + if not re.fullmatch(r"[\w.-]+/[\w.-]+@[0-9a-f]{40}", pins["CA_CERTDATA_REF"]): + errors.append("CA_CERTDATA_REF=%s is not owner/repo@" + % pins["CA_CERTDATA_REF"]) + if parse_iso(pins["CA_MOZILLA_DATE"]) > now + CLOCK_SLACK: + errors.append("CA_MOZILLA_DATE=%s is in the future" % pins["CA_MOZILLA_DATE"]) + data = pem_path.read_bytes() + if hashlib.sha256(data).hexdigest() != pins["CA_SHA256"]: + errors.append("%s does not match CA_SHA256 in %s: the vendored store changed without " + "tools/ca_store/refresh.py" % (pem_path.name, PINS_NAME)) + text = data.decode("utf-8", "replace") + try: + if iso(mozilla_date(text)) != pins["CA_MOZILLA_DATE"]: + errors.append("%s is from %s, CA_MOZILLA_DATE says %s" + % (pem_path.name, iso(mozilla_date(text)), pins["CA_MOZILLA_DATE"])) + store = certificates(text) + subjects = {} + for der in store: + subject = subject_and_key(der)[0] + if subject in subjects and subjects[subject] != der: + # ESP-IDF's lookup is a binary search that tries one root per subject, so which + # of two would be used depends on where they sort. + errors.append("two roots in the bundle have the same subject: %s and %s" + % (hashlib.sha256(subjects[subject]).hexdigest()[:16], + hashlib.sha256(der).hexdigest()[:16])) + subjects[subject] = der + except StoreError as error: + errors.append("%s: %s" % (pem_path.name, error)) + store = [] + errors += check_store_dir(pem_path.parent) + if store and bundle_set_sha256(store) != pins["CA_BUNDLE_SET_SHA256"]: + modules = [os.path.relpath(p, repo_root) for p, _ in projects(repo_root) if attaching(p)] + errors.append("the bundle's certificates changed but CA_BUNDLE_SET_SHA256 did not: " + "update the store with tools/ca_store/refresh.py, which bumps IDENT_MINOR " + "of %s" % (", ".join(modules) or "no project (none attaches the bundle)")) + errors += bundle_misconfigured(repo_root, effective) + for project, sdkconfig in projects(repo_root, effective): + limit = max_certs(sdkconfig) + if limit is not None and len(store) > limit: + errors.append("%s/sdkconfig: CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=%d, " + "the store has %d" % (os.path.relpath(project, repo_root), limit, + len(store))) + + warnings = [] + today = today or now.date() + age = (today - parse_iso(pins["CA_MOZILLA_DATE"]).date()).days + limit = int(pins["CA_MAX_AGE_DAYS"]) + if age > limit: + message = ("the Mozilla root store is %d days old (as of %s), over CA_MAX_AGE_DAYS=%d: " + "run tools/ca_store/refresh.py" + % (age, pins["CA_MOZILLA_DATE"], limit)) + (errors if release else warnings).append(message) + return errors, warnings + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__.split("\n")[0]) + parser.add_argument("command", choices=("check",)) + parser.add_argument("--repo-root", default=str(REPO_ROOT)) + parser.add_argument("--release", action="store_true", + help="a stale store is an error, not a warning (also RELEASE=1 in the " + "environment)") + parser.add_argument("--project", help="with --sdkconfig-json: the project being built") + parser.add_argument("--sdkconfig-json", + help="the build's config/sdkconfig.json, checked instead of the project's " + "sdkconfig") + parser.add_argument("--today", type=datetime.date.fromisoformat, help=argparse.SUPPRESS) + arguments = parser.parse_args(argv) + repo_root = pathlib.Path(arguments.repo_root) + if bool(arguments.project) != bool(arguments.sdkconfig_json): + parser.error("--project and --sdkconfig-json go together") + effective = {arguments.project: arguments.sdkconfig_json} if arguments.project else None + release = arguments.release or os.environ.get("RELEASE", "") not in ("", "0") + + try: + errors, warnings = check(repo_root, release, arguments.today, effective=effective) + except (StoreError, OSError) as error: + print("ca_store: %s" % error, file=sys.stderr) + return 1 + + for message in warnings: + print("ca_store: warning: %s" % message, file=sys.stderr) + for message in errors: + print("ca_store: %s" % message, file=sys.stderr) + if errors: + return 1 + pins = read_pins(store_paths(repo_root)[1]) + print("ca_store: the Mozilla root store as of %s, sha256 %s" + % (pins["CA_MOZILLA_DATE"], pins["CA_SHA256"])) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/ca_store/refresh.py b/tools/ca_store/refresh.py new file mode 100644 index 000000000..7cb011fea --- /dev/null +++ b/tools/ca_store/refresh.py @@ -0,0 +1,377 @@ +#!/usr/bin/env python3 +"""Refreshes the Mozilla root store the ESP32 bridge trusts (software/wifi/ca_store). + + refresh.py [--source URL] [--summary FILE] [--ident-minor N] + +Fetches curl's cacert.pem and its published sum, and checks the file against a copy made again +from Mozilla's own certdata.txt on GitHub. If Mozilla's data changed, it writes cacert.pem and +CA_PINS and, when the bundle's certificates changed, moves IDENT_MINOR of every project that +attaches the bundle (ca_store.PROJECTS) to --ident-minor N. Without it such a change is refused: +the updater reflashes a module only for a new version, and on a development line the next number +may already belong to another image, so the number is allocated by a person, not taken. + +curl.se publishes the file and its sum from the same server, so the sum proves only that the +download is whole. The second copy is made from certdata.txt on Firefox's release branch (the +revision whose sha256 curl's header names) with curl's own mk-ca-bundle.pl, pinned by commit and +sha256, and curl's file is taken only if the two are the same byte for byte. That revision must +also be the newest certdata.txt on the branch (see GRACE), and a descendant of the committed CA_CERTDATA_REF, so a server serving an older conversion under +a new date is refused too. Changing the store then takes both curl.se and GitHub. + +Needs Perl for mk-ca-bundle.pl, and the network; nothing else beyond the standard library. +""" + +import argparse +import calendar +import datetime +import hashlib +import json +import os +import pathlib +import re +import subprocess +import sys +import tempfile +import urllib.error +import urllib.request + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) + +import ca_store +from ca_store import (CLOCK_SLACK, REPO_ROOT, StoreError, attaching, bump_ident, + bundle_set_sha256, certificates, iso, max_certs, mozilla_date, + parse_date, parse_iso, projects, read_pins, roots, + store_paths, utc_now, write_atomically, write_pins) + +# The second origin: Mozilla's certdata.txt as Firefox's release branch carries it, and the +# script curl converts it with. +CERTDATA_REPO = "mozilla-firefox/firefox" +CERTDATA_BRANCH = "release" +CERTDATA_PATH = "security/nss/lib/ckfw/builtins/certdata.txt" +CERTDATA_COMMITS = 10 +# How old (by commit date) the newest certdata.txt on `release` may be for curl's file to match an older one. +# Newer revisions arrive older than this, so only the newest is ever taken: no rollback, at the cost of a +# red run, healed the next week, when `release` moves between curl's daily run and ours. +GRACE = datetime.timedelta(days=14) +MK_CA_BUNDLE_COMMIT = "d48f2f4ec867783e611beeb2ad53fbabcb94aa6f" +MK_CA_BUNDLE_SHA256 = "8e278f4982210b37e4f9a048bd6ed23df41e4a054085bd73f8242628f03d09ca" +MK_CA_BUNDLE_URL = "https://raw.githubusercontent.com/curl/curl/%s/scripts/mk-ca-bundle.pl" +RAW_URL = "https://raw.githubusercontent.com/%s/%s/%s" +API_URL = "https://api.github.com/repos/%s/commits?sha=%s&path=%s&per_page=%d" +COMPARE_URL = "https://api.github.com/repos/%s/compare/%s...%s" +CERTDATA_PREFIX = "## SHA256: " +FETCH_TIMEOUT = 60 + + +def changes(old_text, new_text): + """(added, removed, rekeyed) as sorted lists: fingerprints for the first two, and + (label, old fingerprint, new fingerprint) for a subject that stays with a different key or + certificate, which is the case to look at by hand because ESP-IDF looks roots up by + subject.""" + old, new = roots(old_text), roots(new_text) + by_subject = {subject: fp for fp, (_, subject, _) in old.items()} + added = sorted(set(new) - set(old)) + removed = sorted(set(old) - set(new)) + rekeyed = [] + for fp in list(added): + old_fp = by_subject.get(new[fp][1]) + if old_fp in removed: + rekeyed.append((new[fp][0], old_fp, fp)) + added.remove(fp) + removed.remove(old_fp) + return added, removed, sorted(rekeyed) + + +def plain(label): + """A label safe to paste into a pull request description.""" + return re.sub(r"[^A-Za-z0-9 .,()&'/:_+-]", "?", label)[:100] + + +def name_key(subject): + """A subject name with its string types and case set aside, to catch a look-alike: the same + name spelled with UTF8String where the real one uses PrintableString is a different subject + to ESP-IDF, and to the SAME SUBJECT section, but not to a reader.""" + tlv = ca_store._tlv + _, start, end = tlv(subject, 0) + parts = [] + while start < end: # SET OF AttributeTypeAndValue + _, set_start, set_end = tlv(subject, start) + while set_start < set_end: + _, seq_start, seq_end = tlv(subject, set_start) + _, oid_start, oid_end = tlv(subject, seq_start) + _, value_start, value_end = tlv(subject, oid_end) + value = subject[value_start:value_end].decode("utf-8", "replace").strip().lower() + parts.append((subject[oid_start:oid_end], value)) + set_start = seq_end + start = set_end + return tuple(sorted(parts)) + + +def certdata_sha256(text): + for line in text.split("\n"): + if line.startswith(CERTDATA_PREFIX) and re.fullmatch(r"[0-9a-f]{64}", + line[len(CERTDATA_PREFIX):]): + return line[len(CERTDATA_PREFIX):] + raise StoreError("no '%s' line naming the certdata.txt it came from" + % CERTDATA_PREFIX.strip("# :")) + + +def validate(data, expected_sha256): + actual = hashlib.sha256(data).hexdigest() + if actual != expected_sha256: + raise StoreError("sha256 mismatch: the file is %s, the published sum is %s" + % (actual, expected_sha256)) + try: + text = data.decode("utf-8") + except UnicodeDecodeError: + raise StoreError("not UTF-8") + date = mozilla_date(text) + parse_date(date) + return text, date, certificates(text) + + +# The second origin. + + +def fetch(url, token=False): + request = urllib.request.Request(url) + # A token only raises the API's rate limit; nothing here needs its permissions. + if token and os.environ.get("GITHUB_TOKEN"): + request.add_header("Authorization", "Bearer " + os.environ["GITHUB_TOKEN"]) + try: + with urllib.request.urlopen(request, timeout=FETCH_TIMEOUT) as response: + return response.read() + except (urllib.error.URLError, OSError) as error: + raise StoreError("cannot fetch %s: %s" % (url, error)) + + +def fetch_json(url): + try: + return json.loads(fetch(url, token=True)) + except ValueError: + raise StoreError("%s did not return JSON" % url) + + +def find_certdata(wanted, now): + """(CA_CERTDATA_REF, contents, commit date) of the certdata.txt revision on Firefox's + release branch whose sha256 is the one curl's file names. It must be the newest revision, + or the newest must have been committed less than GRACE ago.""" + url = API_URL % (CERTDATA_REPO, CERTDATA_BRANCH, CERTDATA_PATH, CERTDATA_COMMITS) + try: + commits = [(c["sha"], c["commit"]["committer"]["date"]) for c in fetch_json(url)] + except (KeyError, TypeError): + raise StoreError("%s did not return a list of commits" % url) + for index, (commit, date) in enumerate(commits): + data = fetch(RAW_URL % (CERTDATA_REPO, commit, CERTDATA_PATH)) + if hashlib.sha256(data).hexdigest() != wanted: + continue + if index: + newest, newest_date = commits[0] + since = now - datetime.datetime.strptime(newest_date, ca_store.ISO_FORMAT) + if since > GRACE: + raise StoreError( + "curl's file is certdata.txt from %s (committed %s), but the release branch " + "now carries a newer one, %s@%s, committed %s (%d days ago). Either the " + "branch moved after curl's last daily run, which the next run heals once " + "curl publishes it, or this is an old file served as new" + % (commit[:12], date, CERTDATA_REPO, newest[:12], newest_date, since.days)) + return "%s@%s" % (CERTDATA_REPO, commit), data, date + raise StoreError("none of the last %d revisions of %s in %s is the certdata.txt curl's file " + "names (sha256 %s)" % (len(commits), CERTDATA_PATH, CERTDATA_REPO, wanted)) + + +def descends(old_ref, new_ref): + """Whether new_ref is old_ref or a later commit on top of it.""" + if old_ref == new_ref: + return True + old_repo, old = old_ref.split("@", 1) + new_repo, new = new_ref.split("@", 1) + if old_repo != new_repo: + return False + result = fetch_json(COMPARE_URL % (new_repo, old, new)) + if not isinstance(result, dict): + raise StoreError("GitHub's compare of %s...%s did not return an object" % (old, new)) + return result.get("status") == "ahead" and result.get("behind_by") == 0 + + +def regenerate(text, now): + """(CA_CERTDATA_REF, bytes, commit date): curl's file made again from Mozilla's + certdata.txt on GitHub with curl's own pinned mk-ca-bundle.pl. Its "as of" line comes from + the input's modification time, which is set to curl's date, so an honest file comes out + identical.""" + ref, certdata, date = find_certdata(certdata_sha256(text), now) + script = fetch(MK_CA_BUNDLE_URL % MK_CA_BUNDLE_COMMIT) + if hashlib.sha256(script).hexdigest() != MK_CA_BUNDLE_SHA256: + raise StoreError("mk-ca-bundle.pl at %s is not the pinned file" % MK_CA_BUNDLE_COMMIT) + stamp = calendar.timegm(parse_date(mozilla_date(text)).timetuple()) + with tempfile.TemporaryDirectory() as work: + work = pathlib.Path(work) + (work / "mk-ca-bundle.pl").write_bytes(script) + (work / "certdata.txt").write_bytes(certdata) + os.utime(work / "certdata.txt", (stamp, stamp)) + try: + run = subprocess.run(["perl", "mk-ca-bundle.pl", "-n", "-q", "cacert.pem"], cwd=work, + capture_output=True, check=False) + except OSError as error: + raise StoreError("cannot run perl: %s" % error) + if run.returncode != 0: + raise StoreError("mk-ca-bundle.pl failed: %s" + % run.stderr.decode("utf-8", "replace").strip()) + return ref, (work / "cacert.pem").read_bytes(), date + + +def published_sha256(data, url): + match = re.match(r"([0-9a-f]{64})\s", data.decode("ascii", "replace") + "\n") + if not match: + raise StoreError("%s is not a sha256 sum" % url) + return match.group(1) + + +# The refresh. + + +def refresh(repo_root, source=None, summary=None, now=None, regenerate=regenerate, + descends=descends, ident_minor=None): + """Returns the paths written, empty when Mozilla's data has not changed.""" + pem_path, pins_path = store_paths(repo_root) + pins = read_pins(pins_path) + now = now or utc_now() + url = source or pins["CA_SOURCE_URL"] + data = fetch(url) + text, date, ders = validate(data, published_sha256(fetch(url + ".sha256"), url + ".sha256")) + + when, old_date = parse_date(date), pins["CA_MOZILLA_DATE"] + if when > now + CLOCK_SLACK: + raise StoreError("%s is dated %s, in the future" % (url, iso(date))) + if when < parse_iso(old_date): + raise StoreError("%s is older than the committed store (%s, committed %s)" + % (url, iso(date), old_date)) + + # Every run, changed or not, so a weekly job keeps checking curl.se against Mozilla. + ref, again, ref_date = regenerate(text, now) + if again != data: + try: + added, removed, rekeyed = changes(again.decode("utf-8"), text) + detail = ("; in curl's file only: %s; in Mozilla's only: %s" + % (", ".join(added + [new for _, _, new in rekeyed]) or "none", + ", ".join(removed + [old for _, old, _ in rekeyed]) or "none")) + except (StoreError, UnicodeDecodeError): + detail = "" + raise StoreError("%s is not what %s gives when converted with mk-ca-bundle.pl %s%s" + % (url, ref, MK_CA_BUNDLE_COMMIT, detail)) + if not descends(pins["CA_CERTDATA_REF"], ref): + raise StoreError("%s comes from %s, which is not the committed %s or a later commit on " + "top of it: an older certdata.txt under a newer date, or the branch's " + "history was rewritten (then move CA_CERTDATA_REF by hand after a look)" + % (url, ref, pins["CA_CERTDATA_REF"])) + + old_text = pem_path.read_text() if pem_path.exists() else "" + if iso(date) == old_date: + if old_text and set(ders) != set(certificates(old_text)): + raise StoreError("the certificates changed but the Mozilla date did not (%s)" % date) + return [] + + using = projects(repo_root) + for project, sdkconfig in using: + limit = max_certs(sdkconfig) + if limit is not None and len(ders) > limit: + raise StoreError("%d certificates, but %s/sdkconfig allows %d " + "(CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS)" + % (len(ders), project, limit)) + + # The bundle is built from the certificates alone, so only a change to them needs the + # modules that carry it reflashed. Every header is checked before anything is written. + new_set = bundle_set_sha256(ders) + day = when.date().isoformat() + carrying = ([project for project, _ in using if attaching(project)] + if new_set != pins["CA_BUNDLE_SET_SHA256"] else []) + if carrying and ident_minor is None: + raise StoreError("the bundle's certificates changed, so %s needs a new IDENT_MINOR: pass " + "--ident-minor N with a number allocated for this image" + % ", ".join(os.path.relpath(p, repo_root) for p in carrying)) + bumps = [bump_ident(project, day, ident_minor) for project in carrying] + + write_atomically(pem_path, data) + write_pins(pins_path, {"CA_MOZILLA_DATE": iso(date), + "CA_SHA256": hashlib.sha256(data).hexdigest(), + "CA_CERTDATA_REF": ref, + "CA_BUNDLE_SET_SHA256": new_set}) + written = [pem_path, pins_path] + bumped = [] + for header, text_after, version in bumps: + write_atomically(header, text_after.encode()) + written.append(header) + bumped.append((header.parent.parent, version)) + + if summary: + pathlib.Path(summary).write_text(describe( + old_text, text, url, ref, ref_date, iso(date), old_date, len(ders), + new_set != pins["CA_BUNDLE_SET_SHA256"], bumped, repo_root)) + return written + + +def describe(old_text, text, url, ref, ref_date, date, old_date, count, set_changed, bumped, + repo_root): + """The pull request description: what changed, by SHA-256 fingerprint.""" + added, removed, rekeyed = changes(old_text, text) + new, old = roots(text), roots(old_text) + lines = ["Mozilla root store as of %s (was %s), %d certificates." % (date, old_date, count), + "", + "Fetched from %s. Regenerated from `%s` (committed %s) with curl's mk-ca-bundle.pl " + "at %s, byte for byte the same." % (url, ref, ref_date, MK_CA_BUNDLE_COMMIT), ""] + if rekeyed: + lines += ["## SAME SUBJECT, DIFFERENT CERTIFICATE: check each of these by hand", "", + "ESP-IDF finds a root by its subject name, so a changed key under the same " + "subject changes what the modules trust for every server that names it.", ""] + lines += ["- %s: `%s` became `%s`" % (plain(label), old_fp, new_fp) + for label, old_fp, new_fp in rekeyed] + lines += [""] + kept = {name_key(subject): label for fp, (label, subject, _) in old.items() + if fp not in removed} + kept_labels = {label for label in kept.values()} + lookalikes = [fp for fp in added + if name_key(new[fp][1]) in kept or new[fp][0] in kept_labels] + if lookalikes: + lines += ["## ADDED UNDER THE NAME OF A ROOT ALREADY HERE: check each of these by hand", + "", "A new root whose name reads like one the store already has.", ""] + lines += ["- `%s` %s" % (fp, plain(new[fp][0])) for fp in lookalikes] + [""] + lines += ["## Added", ""] + (["- `%s` %s" % (fp, plain(new[fp][0])) for fp in added] + or ["None."]) + [""] + lines += ["## Removed", ""] + (["- `%s` %s" % (fp, plain(old[fp][0])) for fp in removed] + or ["None."]) + [""] + if bumped: + lines += ["## Module versions", ""] + lines += ["- %s now reports %s." % (os.path.relpath(p, repo_root), v) for p, v in bumped] + elif set_changed: + lines += ["No project attaches the bundle, so no module version changes."] + else: + lines += ["The certificates did not change, so the bundle and the module versions do " + "not either."] + return "\n".join(lines) + "\n" + + +def main(argv=None): + parser = argparse.ArgumentParser(description=__doc__.split("\n")[0]) + parser.add_argument("--repo-root", default=str(REPO_ROOT)) + parser.add_argument("--source", help="fetch from this URL instead of CA_SOURCE_URL " + "(its sum from the same URL + .sha256)") + parser.add_argument("--summary", help="write what changed to this file") + parser.add_argument("--ident-minor", type=int, + help="the IDENT_MINOR allocated for the image, needed when the " + "certificates change") + arguments = parser.parse_args(argv) + repo_root = pathlib.Path(arguments.repo_root) + try: + written = refresh(repo_root, arguments.source, arguments.summary, + ident_minor=arguments.ident_minor) + except (StoreError, OSError) as error: + print("refresh: %s" % error, file=sys.stderr) + return 1 + if not written: + print("refresh: the Mozilla root store is current, nothing to do") + for path in written: + print("refresh: wrote %s" % os.path.relpath(path, repo_root)) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/ca_store/test_ca_store.py b/tools/ca_store/test_ca_store.py new file mode 100644 index 000000000..66df3e9fc --- /dev/null +++ b/tools/ca_store/test_ca_store.py @@ -0,0 +1,497 @@ +#!/usr/bin/env python3 +"""Tests for the Mozilla root store's build gate (ca_store.py). Need no network.""" + +import base64 +import contextlib +import datetime +import hashlib +import io +import os +import pathlib +import shutil +import subprocess +import sys +import tempfile +import unittest +from unittest import mock + +sys.path.insert(0, str(pathlib.Path(__file__).parent)) + +import ca_store + + +REPO_ROOT = pathlib.Path(__file__).resolve().parents[2] +COMMITTED = (REPO_ROOT / ca_store.STORE_DIR / ca_store.PEM_NAME).read_text() +OLD_DATE = "Tue Jul 14 03:12:01 2026 GMT" +NEW_DATE = "Fri Sep 25 03:12:01 2026 GMT" +OLD_ISO = "2026-07-14T03:12:01Z" +NEW_ISO = "2026-09-25T03:12:01Z" +NOW = datetime.datetime(2026, 9, 29, 12, 0, 0) +OLD_REF = "mozilla-firefox/firefox@" + "1" * 40 +NEW_REF = "mozilla-firefox/firefox@" + "2" * 40 +BRIDGE = "software/wifi/raw_u64" + +SDKCONFIG = """\ +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL is not set +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y +CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y +CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="%s" +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=%d +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y +""" + +HEADER = """\ +#define IDENT_STRING "ESP32 WiFi Bridge V1.%d" +#define IDENT_MAJOR 1 +// 1.%d: something earlier. +#define IDENT_MINOR %d +""" + + +def pem(date, first=0, count=20): + """A store in curl's layout: its header with the given date, then some real roots.""" + header, _, body = COMMITTED.partition("\n\n") + header = "\n".join(ca_store.DATE_PREFIX + date if line.startswith(ca_store.DATE_PREFIX) + else line for line in header.split("\n")) + blocks = body.strip("\n").split("\n\n") + return header + "\n\n\n" + "\n\n".join(blocks[first:first + count]) + "\n" + + +def der_length(n): + if n < 0x80: + return bytes([n]) + body = n.to_bytes((n.bit_length() + 7) // 8, "big") + return bytes([0x80 | len(body)]) + body + + +def with_key(der, key): + """der with its SubjectPublicKeyInfo replaced (the signature no longer matches).""" + _, start, _ = ca_store._tlv(der, 0) + _, tbs_start, tbs_end = ca_store._tlv(der, start) + fields, pos = [], tbs_start + while pos < tbs_end: + _, _, end = ca_store._tlv(der, pos) + fields.append(der[pos:end]) + pos = end + fields[6 if fields[0][0] == 0xA0 else 5] = key + tbs = b"".join(fields) + tbs = bytes([0x30]) + der_length(len(tbs)) + tbs + body = tbs + der[tbs_end:] + return bytes([0x30]) + der_length(len(body)) + body + + +def rekeyed(text, victim, donor): + """text with certificate number `victim` given the public key of number `donor`, keeping its + subject and label: the swap a compromised mirror would make.""" + ders = ca_store.certificates(text) + swapped = with_key(ders[victim], ca_store.subject_and_key(ders[donor])[1]) + old_b64 = base64.encodebytes(ders[victim]).decode().replace("\n", "") + new_b64 = base64.b64encode(swapped).decode() + old_block = "\n".join(old_b64[i:i + 76] for i in range(0, len(old_b64), 76)) + new_block = "\n".join(new_b64[i:i + 76] for i in range(0, len(new_b64), 76)) + assert old_block in text + return text.replace(old_block, new_block) + + +def pem_block(der): + text = base64.b64encode(der).decode() + return (ca_store.BEGIN + "\n" + "\n".join(text[i:i + 76] for i in range(0, len(text), 76)) + + "\n" + ca_store.END + "\n") + + +class Tree: + """A repository with the store, the bridge that builds its bundle from it (and attaches it), + and a project still on ESP-IDF's own bundle, which the store leaves alone.""" + + def __init__(self, root, date=OLD_DATE, max_certs=200): + self.root = pathlib.Path(root) + store = self.root / ca_store.STORE_DIR + store.mkdir(parents=True) + self.pem = store / ca_store.PEM_NAME + self.pins = store / ca_store.PINS_NAME + text = pem(date) + self.pem.write_text(text) + self.pins.write_text( + "# comment kept\nCA_SOURCE_URL=https://curl.se/ca/cacert.pem\n" + "CA_MOZILLA_DATE=%s\nCA_SHA256=%s\nCA_MAX_AGE_DAYS=180\nCA_CERTDATA_REF=%s\n" + "CA_BUNDLE_SET_SHA256=%s\n" + % (ca_store.iso(date), hashlib.sha256(text.encode()).hexdigest(), OLD_REF, + ca_store.bundle_set_sha256(ca_store.certificates(text)))) + self.bridge = self.project(BRIDGE, "../ca_store/cacert.pem", 6, max_certs) + (self.bridge / "main/tls.c").write_text( + "void setup(void) { esp_crt_bundle_attach(&conf); }\n") + self.sdkconfig = self.bridge / "sdkconfig" + other = self.root / "software/u64ctrl" + (other / "main").mkdir(parents=True) + (other / "sdkconfig").write_text("CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y\n" + "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y\n") + (other / "main/rpc_dispatch.h").write_text(HEADER % (14, 14, 14)) + + def project(self, path, relative, minor, max_certs): + project = self.root / path + (project / "main").mkdir(parents=True) + (project / "sdkconfig").write_text(SDKCONFIG % (relative, max_certs)) + (project / "main/rpc_dispatch.h").write_text(HEADER % (minor, minor, minor)) + return project + + def repin(self): + """A pins file that agrees with cacert.pem's bytes again, but not its set pin.""" + self.pins.write_text(self.pins.read_text().replace( + ca_store.read_pins(self.pins)["CA_SHA256"], + hashlib.sha256(self.pem.read_bytes()).hexdigest())) + + def snapshot(self): + return {p: p.read_bytes() for p in self.root.rglob("*") if p.is_file()} + + +class CheckTest(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, self.tmp) + self.tree = Tree(self.tmp) # as of 2026-07-14, limit 180 days + + def errors(self): + return ca_store.check(self.tree.root, today=datetime.date(2026, 9, 29), now=NOW)[0] + + def test_a_fresh_store_passes(self): + self.assertEqual(ca_store.check(self.tree.root, today=datetime.date(2027, 1, 10), now=NOW), ([], [])) + + def test_a_stale_store_warns(self): + errors, warnings = ca_store.check(self.tree.root, today=datetime.date(2027, 1, 11), now=NOW) + self.assertEqual(errors, []) + self.assertIn("181 days old", warnings[0]) + + def test_a_stale_store_fails_a_release(self): + errors, warnings = ca_store.check(self.tree.root, release=True, + today=datetime.date(2027, 1, 11), now=NOW) + self.assertEqual(warnings, []) + self.assertIn("181 days old", errors[0]) + + def test_a_fresh_store_passes_a_release(self): + self.assertEqual(ca_store.check(self.tree.root, release=True, + today=datetime.date(2026, 9, 29), now=NOW), ([], [])) + + def test_the_release_flag_sets_the_exit_status(self): + arguments = ["check", "--repo-root", str(self.tree.root), "--today", "2027-06-01"] + with contextlib.redirect_stderr(io.StringIO()), contextlib.redirect_stdout(io.StringIO()): + self.assertEqual(ca_store.main(arguments), 0) + self.assertEqual(ca_store.main([*arguments, "--release"]), 1) + + def test_a_pins_date_that_disagrees_with_the_store_fails(self): + self.tree.pins.write_text(self.tree.pins.read_text().replace(OLD_ISO, NEW_ISO)) + self.assertIn("is from %s, CA_MOZILLA_DATE says %s" % (OLD_ISO, NEW_ISO), self.errors()[0]) + + def test_a_pins_date_that_is_not_iso_fails(self): + self.tree.pins.write_text(self.tree.pins.read_text().replace(OLD_ISO, "2026-07-14")) + with self.assertRaisesRegex(ca_store.StoreError, "not of the form"): + self.errors() + + def test_more_certificates_than_the_bundle_allows_fails(self): + shutil.rmtree(self.tree.root) + self.tree = Tree(self.tree.root, max_certs=19) + errors = self.errors() + self.assertEqual(len(errors), 1) + self.assertIn("MAX_CERTS=19, the store has 20", errors[0]) + shutil.rmtree(self.tree.root) + self.tree = Tree(self.tree.root, max_certs=20) + self.assertEqual(self.errors(), []) + + def test_a_date_in_the_future_fails(self): + errors, _ = ca_store.check(self.tree.root, now=datetime.datetime(2026, 7, 13, 3, 12, 0)) + self.assertIn("in the future", errors[0]) + + def test_a_certdata_ref_that_is_not_a_commit_fails(self): + self.tree.pins.write_text(self.tree.pins.read_text().replace(OLD_REF, "firefox@release")) + self.assertIn("CA_CERTDATA_REF=firefox@release", self.errors()[0]) + + def test_a_malformed_pins_file_is_an_error_not_a_crash(self): + text = self.tree.pins.read_text() + for broken in (text + "garbage\n", + text.replace("CA_MAX_AGE_DAYS=180", "CA_MAX_AGE_DAYS=x"), + text.replace("CA_BUNDLE_SET_SHA256", "# CA_BUNDLE_SET_SHA256")): + self.tree.pins.write_text(broken) + with self.assertRaises(ca_store.StoreError): + ca_store.check(self.tree.root) + + @unittest.skipUnless(hasattr(__import__("time"), "tzset"), "needs time.tzset") + def test_the_age_is_counted_in_utc_not_local_time(self): + import time + now = datetime.datetime.now(datetime.timezone.utc) + # A zone whose date differs from UTC's at this moment. + zone = "Etc/GMT-14" if now.hour >= 10 else "Etc/GMT+12" + shutil.rmtree(self.tree.root) + # Exactly CA_MAX_AGE_DAYS old by UTC's date, so any other date makes it stale or not. + date = (now - datetime.timedelta(days=180)).strftime("%a %b %d 00:00:00 %Y GMT") + self.tree = Tree(self.tree.root, date=date) + saved = os.environ.get("TZ") + os.environ["TZ"] = zone + time.tzset() + try: + errors, warnings = ca_store.check(self.tree.root, release=True) + finally: + if saved is None: + del os.environ["TZ"] + else: + os.environ["TZ"] = saved + time.tzset() + self.assertEqual((errors, warnings), ([], [])) + + def test_a_store_edited_by_hand_fails(self): + self.tree.pem.write_text(self.tree.pem.read_text() + "\n") + self.assertIn("does not match CA_SHA256", self.errors()[0]) + + def test_one_flipped_byte_in_a_certificate_fails(self): + text = self.tree.pem.read_text() + at = text.index(ca_store.BEGIN) + len(ca_store.BEGIN) + 40 + self.tree.pem.write_text(text[:at] + ("A" if text[at] != "A" else "B") + text[at + 1:]) + self.assertIn("does not match CA_SHA256", self.errors()[0]) + + def test_a_flipped_byte_that_breaks_a_certificate_is_an_error_not_a_crash(self): + # The flip the ESP32 build's tamper case made: the base64 still decodes, the DER does not. + text = self.tree.pem.read_text() + at = text.index(ca_store.BEGIN) + 40 + self.tree.pem.write_text(text[:at] + ("A" if text[at] != "A" else "B") + text[at + 1:]) + errors = self.errors() + self.assertIn("does not match CA_SHA256", errors[0]) + self.assertIn("cacert.pem: bad DER length", errors[1]) + + def test_a_truncated_store_fails(self): + text = self.tree.pem.read_text() + self.tree.pem.write_text(text[:text.rindex(ca_store.END)]) + self.tree.repin() + self.assertTrue(any("truncated" in e for e in self.errors()), self.errors()) + + def test_the_bridge_back_on_the_default_bundle_fails(self): + self.tree.sdkconfig.write_text("CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y\n" + "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y\n" + "# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set\n" + "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y\n") + errors = self.errors() + self.assertEqual(len(errors), 2) + self.assertIn("does not name software/wifi/ca_store/cacert.pem", errors[0]) + self.assertIn("DEFAULT_NONE", errors[1]) + + def test_the_bridge_adding_the_default_bundle_to_the_store_fails(self): + self.tree.sdkconfig.write_text(self.tree.sdkconfig.read_text().replace( + "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y", + "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y")) + self.assertIn("DEFAULT_NONE", self.errors()[0]) + + def test_a_store_path_without_the_custom_bundle_switch_fails(self): + self.tree.sdkconfig.write_text(self.tree.sdkconfig.read_text().replace( + "CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y\n", + "# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set\n")) + self.assertIn("does not set CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y", self.errors()[0]) + + def test_a_path_to_another_file_or_to_the_directory_fails(self): + for path in ("../ca_store", "../ca_store/other.pem", "cacert.pem"): + self.tree.sdkconfig.write_text(SDKCONFIG % (path, 200)) + self.assertIn("does not name software/wifi/ca_store/cacert.pem", self.errors()[0], path) + + def test_the_bundle_off_fails(self): + self.tree.sdkconfig.write_text("# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE is not set\n") + self.assertIn("CONFIG_MBEDTLS_CERTIFICATE_BUNDLE is off", self.errors()[0]) + + def test_without_cross_signed_verification_fails(self): + self.tree.sdkconfig.write_text(self.tree.sdkconfig.read_text().replace( + "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y", + "# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY is not set")) + self.assertIn("needs CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y", + self.errors()[0]) + + def test_a_project_outside_projects_is_left_alone(self): + # u64ctrl takes ESP-IDF's own bundle; that is no error, and nothing reads it. + self.assertEqual(self.errors(), []) + self.assertEqual([p for p, _ in ca_store.projects(self.tree.root)], [self.tree.bridge]) + + def test_a_project_named_but_missing_is_an_error_not_a_crash(self): + self.tree.sdkconfig.unlink() + with self.assertRaisesRegex(ca_store.StoreError, "no sdkconfig"): + self.errors() + + +class EffectiveConfigTest(unittest.TestCase): + """What the build actually uses: its sdkconfig.json (the build passes it), and RELEASE from the + environment of every build, not only of the configure step.""" + + def setUp(self): + self.tmp = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, self.tmp) + self.tree = Tree(self.tmp) + self.json = pathlib.Path(self.tmp) / "sdkconfig.json" + + def write_json(self, **changes): + config = {"MBEDTLS_CERTIFICATE_BUNDLE": True, "MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL": False, + "MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN": False, + "MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE": True, + "MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE": True, + "MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH": "../ca_store/cacert.pem", + "MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS": 200, + "MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY": True} + config.update(changes) + self.json.write_text(__import__("json").dumps(config)) + + def errors(self, **kwargs): + return ca_store.check(self.tree.root, today=datetime.date(2026, 9, 29), now=NOW, + effective={self.tree.bridge: self.json}, **kwargs)[0] + + def test_the_effective_config_passes_when_it_agrees(self): + self.write_json() + self.assertEqual(self.errors(), []) + + def test_an_effective_config_that_takes_the_default_bundle_fails(self): + # idf.py -D SDKCONFIG=alt with DEFAULT_CMN: the project's own sdkconfig still says NONE. + self.write_json(MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=True, + MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=False) + self.assertIn("DEFAULT_NONE", self.errors()[0]) + + def test_the_effective_limit_and_cross_signed_setting_count(self): + self.write_json(MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=19, + MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=False) + errors = self.errors() + self.assertTrue(any("CROSS_SIGNED_VERIFY=y" in e for e in errors), errors) + self.assertTrue(any("MAX_CERTS=19, the store has 20" in e for e in errors), errors) + + def test_the_command_line_takes_the_effective_config(self): + self.write_json(MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=False, + MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=True) + arguments = ["check", "--repo-root", str(self.tree.root), "--today", "2026-09-29"] + with contextlib.redirect_stderr(io.StringIO()), contextlib.redirect_stdout(io.StringIO()): + self.assertEqual(ca_store.main(arguments), 0) + self.assertEqual(ca_store.main([*arguments, "--project", str(self.tree.bridge), + "--sdkconfig-json", str(self.json)]), 1) + + def test_release_in_the_environment_fails_a_stale_store(self): + arguments = ["check", "--repo-root", str(self.tree.root), "--today", "2027-06-01"] + for value, status in (("", 0), ("0", 0), ("1", 1), ("yes", 1)): + with mock.patch.dict(os.environ, {"RELEASE": value}), \ + contextlib.redirect_stderr(io.StringIO()), contextlib.redirect_stdout(io.StringIO()): + self.assertEqual(ca_store.main(arguments), status, value) + + +class StoreDirTest(unittest.TestCase): + """Only cacert.pem holds certificates in the store.""" + + def setUp(self): + self.tmp = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, self.tmp) + self.tree = Tree(self.tmp) + + def errors(self): + return ca_store.check(self.tree.root, today=datetime.date(2026, 9, 29), now=NOW)[0] + + def test_an_anchors_file_is_refused_as_retired(self): + (self.tree.pem.parent / ca_store.ANCHORS_NAME).write_text(pem_block( + ca_store.certificates(self.tree.pem.read_text())[0])) + errors = self.errors() + self.assertEqual(len(errors), 1) + self.assertIn("anchors.pem: the anchors are retired on ESP-IDF 6", errors[0]) + + def test_a_stray_certificate_file_is_refused(self): + for name in ("extra.pem", "extra.der", "extra.crt"): + (self.tree.pem.parent / name).write_text("x") + self.assertIn("%s: only cacert.pem holds certificates" % name, self.errors()[0]) + (self.tree.pem.parent / name).unlink() + + def test_other_files_are_allowed(self): + (self.tree.pem.parent / "README.md").write_text("notes\n") + self.assertEqual(self.errors(), []) + + +class BundleSetTest(unittest.TestCase): + """CA_BUNDLE_SET_SHA256 and the IDENT rule it drives.""" + + def setUp(self): + self.tmp = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, self.tmp) + self.tree = Tree(self.tmp) + + def errors(self): + return ca_store.check(self.tree.root, today=datetime.date(2026, 9, 29), now=NOW)[0] + + def test_a_certificate_change_without_the_set_pin_fails_and_names_what_to_bump(self): + # A hand edit that moved CA_SHA256 along with the file, but not the set pin. + text = self.tree.pem.read_text() + self.tree.pem.write_text(text[:text.rindex("\n\n") + 1]) + self.tree.repin() + errors = self.errors() + self.assertEqual(len(errors), 1) + self.assertIn("CA_BUNDLE_SET_SHA256 did not", errors[0]) + self.assertIn("IDENT_MINOR of software/wifi/raw_u64", errors[0]) + + def test_a_comment_only_edit_changes_no_certificate(self): + self.tree.pem.write_text("## another comment\n" + self.tree.pem.read_text()) + self.tree.repin() + self.assertEqual(self.errors(), []) + + def test_the_set_does_not_depend_on_order(self): + ders = ca_store.certificates(COMMITTED)[:5] + self.assertEqual(ca_store.bundle_set_sha256(ders), + ca_store.bundle_set_sha256(list(reversed(ders)))) + self.assertNotEqual(ca_store.bundle_set_sha256(ders), ca_store.bundle_set_sha256(ders[1:])) + + def test_attaching_reads_only_the_projects_own_sources(self): + self.assertTrue(ca_store.attaching(self.tree.bridge)) + self.assertFalse(ca_store.attaching(self.tree.root / "software/u64ctrl")) + + def test_two_roots_with_one_subject_fail(self): + store = ca_store.certificates(self.tree.pem.read_text()) + double = with_key(store[0], ca_store.subject_and_key(store[1])[1]) + self.tree.pem.write_text(self.tree.pem.read_text() + "\nDouble\n======\n" + + pem_block(double)) + self.tree.repin() + self.assertTrue(any("same subject" in e for e in self.errors()), self.errors()) + + def test_bump_ident_refuses_a_header_whose_string_disagrees(self): + header = self.tree.bridge / "main/rpc_dispatch.h" + header.write_text(HEADER.replace("V1.%d", "V1.5") % (6, 6)) + with self.assertRaisesRegex(ca_store.StoreError, "IDENT_STRING says 1.5"): + ca_store.bump_ident(self.tree.bridge, "2026-09-29", 7) + + +class CommittedStoreTest(unittest.TestCase): + """The tree as committed.""" + + def test_the_committed_store_is_consistent(self): + errors, _ = ca_store.check(REPO_ROOT) + self.assertEqual(errors, []) + + def test_the_committed_store_holds_no_anchors(self): + store = REPO_ROOT / ca_store.STORE_DIR + self.assertEqual(sorted(p.name for p in store.iterdir() if p.suffix == ".pem"), + [ca_store.PEM_NAME]) + + def test_the_committed_pins_parse_like_pins_and_as_shell(self): + path = REPO_ROOT / ca_store.STORE_DIR / ca_store.PINS_NAME + pins = ca_store.read_pins(path) + for value in pins.values(): + self.assertNotRegex(value, "[\"' ]") + shell = subprocess.run( + ["sh", "-c", '. "$1" && echo "$CA_MOZILLA_DATE $CA_MAX_AGE_DAYS"', "sh", str(path)], + capture_output=True, text=True, check=True) + self.assertEqual(shell.stdout.split(), + [pins["CA_MOZILLA_DATE"], pins["CA_MAX_AGE_DAYS"]]) + + def test_the_bridge_builds_its_bundle_from_the_store_and_attaches_it(self): + found = [(str(p.relative_to(REPO_ROOT)), ca_store.attaching(p)) + for p, _ in ca_store.projects(REPO_ROOT)] + self.assertEqual(found, [(BRIDGE, True)]) + + def test_every_project_that_uses_the_store_has_a_version_to_bump(self): + for project, _ in ca_store.projects(REPO_ROOT): + _, text, version = ca_store.bump_ident(project, "2026-09-25", 999) + self.assertIn('%s"' % version, text) + + def test_the_bridge_cmake_runs_the_check_at_configure_and_at_every_build(self): + cmake = (REPO_ROOT / BRIDGE / "CMakeLists.txt").read_text() + self.assertIn("tools/ca_store/ca_store.py", cmake) + self.assertIn("FATAL_ERROR", cmake) + self.assertIn("--sdkconfig-json", cmake) + self.assertIn("add_custom_target(ca_store_check ALL", cmake) + self.assertIn("add_dependencies(custom_bundle ca_store_check)", cmake) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/ca_store/test_refresh.py b/tools/ca_store/test_refresh.py new file mode 100644 index 000000000..555b4a0cf --- /dev/null +++ b/tools/ca_store/test_refresh.py @@ -0,0 +1,446 @@ +#!/usr/bin/env python3 +"""Tests for refresh.py. Need no network: the store is served from file:// URLs built from +the committed cacert.pem, and GitHub (the regeneration from certdata.txt and the revision +checks) is stood in for. CA_STORE_ONLINE=1 adds tests that run the real ones.""" + +import contextlib +import datetime +import hashlib +import io +import json +import os +import pathlib +import shutil +import sys +import tempfile +import unittest +from unittest import mock + +sys.path.insert(0, str(pathlib.Path(__file__).parent)) + +import ca_store +import refresh +from test_ca_store import (COMMITTED, HEADER, NEW_DATE, NEW_ISO, NEW_REF, NOW, OLD_DATE, + OLD_ISO, OLD_REF, REPO_ROOT, Tree, der_length, pem, pem_block, rekeyed) + +REF_DATE = "2026-09-08T20:22:24Z" + + +def agree(text, now): + """A regeneration that comes out the same as curl's file.""" + return NEW_REF, text.encode(), REF_DATE + + +def with_subject(der, subject): + """der with its subject replaced (the signature no longer matches; nothing here checks it).""" + _, start, _ = ca_store._tlv(der, 0) + _, tbs_start, tbs_end = ca_store._tlv(der, start) + fields, pos = [], tbs_start + while pos < tbs_end: + _, _, end = ca_store._tlv(der, pos) + fields.append(der[pos:end]) + pos = end + fields[5 if fields[0][0] == 0xA0 else 4] = subject + tbs = b"".join(fields) + tbs = bytes([0x30]) + der_length(len(tbs)) + tbs + body = tbs + der[tbs_end:] + return bytes([0x30]) + der_length(len(body)) + body + + +class Served: + """A cacert.pem and its .sha256 as file:// URLs.""" + + def __init__(self, directory, text, sha256=None): + self.path = pathlib.Path(directory) / "cacert.pem" + self.path.write_bytes(text.encode()) + digest = sha256 or hashlib.sha256(text.encode()).hexdigest() + pathlib.Path(str(self.path) + ".sha256").write_text("%s cacert.pem\n" % digest) + self.url = self.path.as_uri() + + +class RefreshTest(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, self.tmp) + self.tree = Tree(pathlib.Path(self.tmp) / "repo") + self.serve_dir = pathlib.Path(self.tmp) / "served" + self.serve_dir.mkdir() + + def refresh(self, text, sha256=None, **kwargs): + kwargs.setdefault("regenerate", agree) + kwargs.setdefault("descends", lambda old, new: True) + kwargs.setdefault("now", NOW) + kwargs.setdefault("ident_minor", 7) # the bridge in Tree is 1.6 + return refresh.refresh(self.tree.root, Served(self.serve_dir, text, sha256).url, **kwargs) + + def test_a_new_date_writes_the_store_the_pins_and_bumps_the_bridge(self): + new = pem(NEW_DATE, first=5, count=30) + summary = pathlib.Path(self.tmp) / "summary.md" + + written = self.refresh(new, summary=summary) + + self.assertEqual(self.tree.pem.read_text(), new) + pins = ca_store.read_pins(self.tree.pins) + self.assertEqual(pins["CA_MOZILLA_DATE"], NEW_ISO) + self.assertEqual(pins["CA_SHA256"], hashlib.sha256(new.encode()).hexdigest()) + self.assertEqual(pins["CA_SOURCE_URL"], "https://curl.se/ca/cacert.pem") + self.assertEqual(pins["CA_CERTDATA_REF"], NEW_REF) + self.assertIn("# comment kept\n", self.tree.pins.read_text()) + self.assertIn("\nCA_MOZILLA_DATE=%s\n" % NEW_ISO, self.tree.pins.read_text()) + bridge = (self.tree.bridge / "main/rpc_dispatch.h").read_text() + self.assertEqual(bridge, '#define IDENT_STRING "ESP32 WiFi Bridge V1.7"\n' + "#define IDENT_MAJOR 1\n" + "// 1.7: the Mozilla root store as of 2026-09-25.\n" + "// 1.6: something earlier.\n" + "#define IDENT_MINOR 7\n") + u64ctrl = (self.tree.root / "software/u64ctrl/main/rpc_dispatch.h").read_text() + self.assertEqual(u64ctrl, HEADER % (14, 14, 14)) + self.assertEqual(len(written), 3) + self.assertEqual(pins["CA_BUNDLE_SET_SHA256"], + ca_store.bundle_set_sha256(ca_store.certificates(new))) + report = summary.read_text() + self.assertIn("as of %s (was %s), 30 certificates" % (NEW_ISO, OLD_ISO), report) + old_fps = set(ca_store.roots(pem(OLD_DATE))) + new_fps = set(ca_store.roots(new)) + for fp in new_fps - old_fps: + self.assertIn("- `%s` " % fp, report.split("## Added")[1].split("## Removed")[0]) + for fp in old_fps - new_fps: + self.assertIn("- `%s` " % fp, report.split("## Removed")[1]) + self.assertEqual(len(new_fps - old_fps), 15) + self.assertEqual(len(old_fps - new_fps), 5) + self.assertNotIn("SAME SUBJECT", report) + self.assertIn("`%s` (committed %s)" % (NEW_REF, REF_DATE), report) + self.assertEqual(ca_store.check(self.tree.root, today=datetime.date(2026, 9, 29)), ([], [])) + + def test_files_are_replaced_not_rewritten_in_place(self): + # A build that reads the store meanwhile sees the old file or the new one, never half. + before = {p: p.stat().st_ino for p in (self.tree.pem, self.tree.pins)} + self.refresh(pem(NEW_DATE, first=5, count=30)) + for path, inode in before.items(): + self.assertNotEqual(path.stat().st_ino, inode, path.name) + self.assertEqual(sorted(p.name for p in self.tree.pem.parent.iterdir()), + ["CA_PINS", "cacert.pem"]) + + def test_a_second_run_with_the_same_data_changes_nothing(self): + new = pem(NEW_DATE, first=5, count=30) + self.refresh(new) + before = self.tree.snapshot() + + self.assertEqual(self.refresh(new), []) + self.assertEqual(self.tree.snapshot(), before) + + def test_the_same_date_changes_nothing(self): + before = self.tree.snapshot() + + self.assertEqual(self.refresh(pem(OLD_DATE)), []) + self.assertEqual(self.tree.snapshot(), before) + + def test_the_same_date_with_only_a_different_header_changes_nothing(self): + before = self.tree.snapshot() + + self.assertEqual(self.refresh(pem(OLD_DATE).replace("version 1.33", "version 1.34")), []) + self.assertEqual(self.tree.snapshot(), before) + + def assertRefused(self, message, text, sha256=None): + before = self.tree.snapshot() + with self.assertRaisesRegex(ca_store.StoreError, message): + self.refresh(text, sha256) + self.assertEqual(self.tree.snapshot(), before) + + def test_a_wrong_sha256_writes_nothing(self): + self.assertRefused("sha256 mismatch", pem(NEW_DATE), sha256="0" * 64) + + def test_a_sum_file_that_is_not_a_sum_writes_nothing(self): + self.assertRefused("not a sha256 sum", pem(NEW_DATE), sha256="") + + def test_a_truncated_download_fails_its_sum(self): + new = pem(NEW_DATE) + good_sum = hashlib.sha256(new.encode()).hexdigest() + self.assertRefused("sha256 mismatch", new[: len(new) // 2], sha256=good_sum) + + def test_a_truncated_file_is_refused_even_when_its_sum_matches(self): + new = pem(NEW_DATE) + self.assertRefused("truncated", new[: new.rindex(ca_store.END)]) + self.assertRefused("truncated", new[: new.rindex(ca_store.END) + 10]) + self.assertRefused("truncated", new[:-1]) + + def test_a_certificate_that_is_not_der_is_refused(self): + new = pem(NEW_DATE).replace("\nMII", "\nXII", 1) + self.assertRefused("not DER", new) + + def test_a_file_without_the_mozilla_date_is_refused(self): + self.assertRefused("Certificate data from Mozilla", + pem(NEW_DATE).replace("as of: ", "at: ")) + + def test_an_older_store_is_refused(self): + self.assertRefused("older than the committed store", pem("Mon Mar 11 15:25:27 2024 GMT")) + + def test_different_certificates_under_the_same_date_are_refused(self): + self.assertRefused("certificates changed but the Mozilla date did not", + pem(OLD_DATE, first=1)) + + def test_more_certificates_than_the_bundle_allows_are_refused(self): + shutil.rmtree(self.tree.root) + self.tree = Tree(self.tree.root, max_certs=10) + self.assertRefused("11 certificates, but .* allows 10", pem(NEW_DATE, count=11)) + + def test_a_project_whose_version_does_not_parse_writes_nothing(self): + (self.tree.bridge / "main/rpc_dispatch.h").write_text( + HEADER.replace("V1.%d", "V2.%d") % (6, 6, 6)) + self.assertRefused("IDENT_STRING says 2.6", pem(NEW_DATE, first=1)) + + def test_a_network_failure_writes_nothing(self): + before = self.tree.snapshot() + for url in ((self.serve_dir / "missing.pem").as_uri(), "http://127.0.0.1:9/cacert.pem"): + with mock.patch.object(refresh, "FETCH_TIMEOUT", 5): + with self.assertRaisesRegex(ca_store.StoreError, "cannot fetch"): + refresh.refresh(self.tree.root, url) + self.assertEqual(self.tree.snapshot(), before) + + def test_the_command_line_reports_a_failure_with_a_nonzero_status(self): + served = Served(self.serve_dir, pem(NEW_DATE), sha256="0" * 64) + stderr = io.StringIO() + with contextlib.redirect_stderr(stderr): + status = refresh.main(["--repo-root", str(self.tree.root), + "--source", served.url]) + self.assertEqual(status, 1) + self.assertIn("sha256 mismatch", stderr.getvalue()) + + + def test_changed_certificates_without_an_allocated_version_write_nothing(self): + # The next minor is not necessarily free on a development line. + before = self.tree.snapshot() + with self.assertRaisesRegex(ca_store.StoreError, "--ident-minor"): + self.refresh(pem(NEW_DATE, first=5, count=30), ident_minor=None) + self.assertEqual(self.tree.snapshot(), before) + + def test_a_version_that_does_not_move_forward_is_refused(self): + for minor in (6, 5): + self.assertRefusedWith("IDENT_MINOR %d is not above 6" % minor, pem(NEW_DATE, first=5, count=30), + agree, ident_minor=minor) + + def test_the_allocated_version_is_the_one_written(self): + self.refresh(pem(NEW_DATE, first=5, count=30), ident_minor=309) + header = (self.tree.bridge / "main/rpc_dispatch.h").read_text() + self.assertIn('#define IDENT_STRING "ESP32 WiFi Bridge V1.309"', header) + self.assertIn("#define IDENT_MINOR 309\n", header) + self.assertIn("// 1.309: the Mozilla root store as of 2026-09-25.", header) + + def test_the_same_certificates_need_no_version(self): + self.assertEqual(len(self.refresh(pem(NEW_DATE), ident_minor=None)), 2) + + def test_the_command_line_passes_the_version(self): + served = Served(self.serve_dir, pem(NEW_DATE, first=5, count=30)) + real = refresh.refresh + + def offline(*args, **kwargs): + return real(*args, regenerate=agree, descends=lambda old, new: True, now=NOW, **kwargs) + with mock.patch.object(refresh, "refresh", offline), \ + contextlib.redirect_stderr(io.StringIO()) as err, contextlib.redirect_stdout(io.StringIO()): + self.assertEqual(refresh.main(["--repo-root", str(self.tree.root), "--source", served.url]), 1) + self.assertIn("--ident-minor", err.getvalue()) + self.assertEqual(refresh.main(["--repo-root", str(self.tree.root), "--source", served.url, + "--ident-minor", "8"]), 0) + self.assertIn("V1.8", (self.tree.bridge / "main/rpc_dispatch.h").read_text()) + + def test_a_new_date_with_the_same_certificates_bumps_nothing(self): + new = pem(NEW_DATE) + summary = pathlib.Path(self.tmp) / "summary.md" + headers = {p: p.read_text() for p in self.tree.root.rglob("rpc_dispatch.h")} + + written = self.refresh(new, summary=summary) + + self.assertEqual(written, [self.tree.pem, self.tree.pins]) + self.assertEqual({p: p.read_text() for p in headers}, headers) + self.assertEqual(ca_store.read_pins(self.tree.pins)["CA_MOZILLA_DATE"], NEW_ISO) + self.assertIn("did not change", summary.read_text()) + + def test_a_file_that_mozillas_data_does_not_give_is_refused(self): + # A mirror serving its own key under ISRG Root X1's name, with a matching sum: the + # regeneration from certdata.txt still gives the real one. + honest = pem(NEW_DATE) + forged = rekeyed(honest, 3, 7) + self.assertNotEqual(forged, honest) + before = self.tree.snapshot() + with self.assertRaisesRegex(ca_store.StoreError, "is not what .* gives"): + self.refresh(forged, regenerate=lambda text, now: (NEW_REF, honest.encode(), REF_DATE)) + self.assertEqual(self.tree.snapshot(), before) + + def test_a_different_header_alone_is_refused_too(self): + honest = pem(NEW_DATE) + with self.assertRaisesRegex(ca_store.StoreError, "is not what"): + self.refresh(honest.replace("version 1.33", "version 1.34"), + regenerate=lambda text, now: (NEW_REF, honest.encode(), REF_DATE)) + + def test_a_key_change_under_the_same_subject_gets_its_own_section(self): + # When Mozilla itself makes the change, both origins agree and the store is written, + # but the description puts it apart from ordinary additions and removals. + new = rekeyed(pem(NEW_DATE), 3, 7) + summary = pathlib.Path(self.tmp) / "summary.md" + + self.refresh(new, summary=summary) + + report = summary.read_text() + section = report.split("## SAME SUBJECT, DIFFERENT CERTIFICATE")[1].split("## Added")[0] + old_fp = hashlib.sha256(ca_store.certificates(pem(OLD_DATE))[3]).hexdigest() + new_fp = hashlib.sha256(ca_store.certificates(new)[3]).hexdigest() + self.assertIn("`%s` became `%s`" % (old_fp, new_fp), section) + self.assertEqual(report.split("## Added")[1].split("## Removed")[0].strip(), "None.") + self.assertIn("V1.7", (self.tree.bridge / "main/rpc_dispatch.h").read_text()) + + def test_labels_cannot_inject_markup_into_the_description(self): + new = pem(NEW_DATE, first=5, count=30) + label = ca_store.names(new)[-1] + new = new.replace("\n%s\n" % label, "\n[x](https://evil)`\n", 1) + summary = pathlib.Path(self.tmp) / "summary.md" + self.refresh(new, summary=summary) + self.assertNotIn("](https", summary.read_text()) + self.assertNotIn("", summary.read_text()) + + def test_a_date_in_the_future_is_refused(self): + self.assertRefused("in the future", pem("Thu Oct 01 12:00:01 2026 GMT")) + + def test_a_date_within_a_day_of_the_clock_is_accepted(self): + self.refresh(pem("Wed Sep 30 11:59:59 2026 GMT")) + self.assertEqual(ca_store.read_pins(self.tree.pins)["CA_MOZILLA_DATE"], + "2026-09-30T11:59:59Z") + + def test_an_earlier_time_on_the_same_day_is_a_rollback(self): + self.assertRefused("older than the committed store", pem("Tue Jul 14 03:12:00 2026 GMT")) + + def test_exactly_as_many_certificates_as_the_bundle_allows_is_accepted(self): + shutil.rmtree(self.tree.root) + self.tree = Tree(self.tree.root, max_certs=10) + self.assertTrue(self.refresh(pem(NEW_DATE, count=10))) + + def test_a_failing_regeneration_writes_nothing(self): + def broken(text, now): + raise ca_store.StoreError("cannot fetch certdata.txt") + self.assertRefusedWith("cannot fetch certdata", pem(NEW_DATE), broken) + + def assertRefusedWith(self, message, text, regenerate, **kwargs): + before = self.tree.snapshot() + with self.assertRaisesRegex(ca_store.StoreError, message): + self.refresh(text, regenerate=regenerate, **kwargs) + self.assertEqual(self.tree.snapshot(), before) + + def test_an_older_certdata_revision_is_refused(self): + # curl.se alone serving an honest conversion of an older certdata.txt under a new date. + seen = [] + + def older(old, new): + seen.append((old, new)) + return False + before = self.tree.snapshot() + with self.assertRaisesRegex(ca_store.StoreError, "not the committed .* or a later commit"): + self.refresh(pem(NEW_DATE, first=5, count=30), descends=older) + self.assertEqual(seen, [(OLD_REF, NEW_REF)]) + self.assertEqual(self.tree.snapshot(), before) + + def test_no_module_attaching_the_bundle_means_no_bump(self): + (self.tree.bridge / "main/tls.c").unlink() + summary = pathlib.Path(self.tmp) / "summary.md" + written = self.refresh(pem(NEW_DATE, first=5, count=30), summary=summary) + self.assertEqual(written, [self.tree.pem, self.tree.pins]) + self.assertIn("No project attaches the bundle", summary.read_text()) + + def test_a_look_alike_added_beside_the_real_root_gets_its_own_section(self): + # The same name spelled with UTF8String where the real root uses PrintableString is a + # different subject, so it is neither the SAME SUBJECT case nor visible in a plain list. + base = pem(NEW_DATE) + victim = ca_store.certificates(base)[0] + label = ca_store.names(base)[0] + subject, _ = ca_store.subject_and_key(victim) + look = subject.replace(b"\x13", b"\x0c") # PrintableString -> UTF8String + self.assertNotEqual(look, subject) + forged = base.rstrip("\n") + "\n\n" + label + "\n" + "=" * len(label) + "\n" + \ + pem_block(with_subject(ca_store.certificates(base)[7], look)) + summary = pathlib.Path(self.tmp) / "summary.md" + self.refresh(forged, summary=summary) + section = summary.read_text().split("## ADDED UNDER THE NAME")[1].split("## Added")[0] + self.assertIn(label, section) + + def test_a_look_alike_under_another_label_is_caught_by_its_name(self): + base = pem(NEW_DATE) + subject, _ = ca_store.subject_and_key(ca_store.certificates(base)[0]) + look = subject.replace(b"\x13", b"\x0c") + forged = base.rstrip("\n") + "\n\nHarmless Root\n=============\n" + \ + pem_block(with_subject(ca_store.certificates(base)[7], look)) + summary = pathlib.Path(self.tmp) / "summary.md" + self.refresh(forged, summary=summary) + section = summary.read_text().split("## ADDED UNDER THE NAME")[1].split("## Added")[0] + self.assertIn("Harmless Root", section) + + +class FindCertdataTest(unittest.TestCase): + """The revision check against Firefox's release branch, with GitHub stood in for.""" + + def serve(self, commits, blobs): + listing = json.dumps([{"sha": sha, "commit": {"committer": {"date": date}}} + for sha, date in commits]).encode() + + def fetch(url, token=False): + if "/commits?" in url: + return listing + return blobs[url.split("/")[5]] + return mock.patch.object(refresh, "fetch", fetch) + + def test_the_newest_revision_is_taken(self): + blob = b"certdata new" + with self.serve([("a" * 40, "2026-09-08T20:22:24Z"), ("b" * 40, "2026-07-15T00:00:00Z")], + {"a" * 40: blob, "b" * 40: b"old"}): + ref, data, date = refresh.find_certdata(hashlib.sha256(blob).hexdigest(), NOW) + self.assertEqual((ref, data, date), ("mozilla-firefox/firefox@" + "a" * 40, blob, + "2026-09-08T20:22:24Z")) + + def test_an_older_revision_is_taken_only_within_the_grace_period(self): + old = b"certdata old" + commits = [("a" * 40, "2026-09-20T00:00:00Z"), ("b" * 40, "2026-07-15T00:00:00Z")] + blobs = {"a" * 40: b"new", "b" * 40: old} + with self.serve(commits, blobs): + ref, _, _ = refresh.find_certdata(hashlib.sha256(old).hexdigest(), + datetime.datetime(2026, 10, 4)) + self.assertTrue(ref.endswith("b" * 40)) + with self.serve(commits, blobs): + with self.assertRaisesRegex(ca_store.StoreError, "now carries a newer one"): + refresh.find_certdata(hashlib.sha256(old).hexdigest(), + datetime.datetime(2026, 10, 4, 0, 0, 1)) + + def test_an_unknown_certdata_is_refused(self): + with self.serve([("a" * 40, "2026-09-08T20:22:24Z")], {"a" * 40: b"x"}): + with self.assertRaisesRegex(ca_store.StoreError, "none of the last 1 revisions"): + refresh.find_certdata("0" * 64, NOW) + + def test_descent_is_asked_of_githubs_compare(self): + answers = {"ahead": ({"status": "ahead", "behind_by": 0}, True), + "behind": ({"status": "behind", "behind_by": 3}, False), + "diverged": ({"status": "diverged", "behind_by": 1}, False)} + for name, (answer, expected) in answers.items(): + with mock.patch.object(refresh, "fetch_json", lambda url: answer) as _: + self.assertEqual(refresh.descends(OLD_REF, NEW_REF), expected, name) + self.assertTrue(refresh.descends(OLD_REF, OLD_REF)) + with mock.patch.object(refresh, "fetch_json", lambda url: []): + with self.assertRaisesRegex(ca_store.StoreError, "did not return an object"): + refresh.descends(OLD_REF, NEW_REF) + self.assertFalse(refresh.descends(OLD_REF, "someone/firefox@" + "2" * 40)) + + +class OnlineTest(unittest.TestCase): + @unittest.skipUnless(os.environ.get("CA_STORE_ONLINE") == "1", "set CA_STORE_ONLINE=1") + def test_the_committed_store_is_what_mozillas_certdata_gives(self): + pins = ca_store.read_pins(REPO_ROOT / ca_store.STORE_DIR / ca_store.PINS_NAME) + ref, again, _ = refresh.regenerate(COMMITTED, ca_store.utc_now()) + self.assertEqual(ref, pins["CA_CERTDATA_REF"]) + self.assertEqual(again, COMMITTED.encode()) + + + @unittest.skipUnless(os.environ.get("CA_STORE_ONLINE") == "1", "set CA_STORE_ONLINE=1") + def test_the_committed_ref_descends_from_itself_and_not_from_a_later_one(self): + pins = ca_store.read_pins(REPO_ROOT / ca_store.STORE_DIR / ca_store.PINS_NAME) + older = "mozilla-firefox/firefox@4e9426ae522c67de47ff3e060774328b42df0134" + self.assertTrue(refresh.descends(older, pins["CA_CERTDATA_REF"])) + self.assertFalse(refresh.descends(pins["CA_CERTDATA_REF"], older)) + + +if __name__ == "__main__": + unittest.main() From f2c1a8588bc51ef4f2b1cdb031b17d6b54bc6f5e Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Wed, 14 Oct 2026 08:27:54 -0500 Subject: [PATCH 51/95] UCI network target: TLS sockets, commands $21-$25 OPEN_TLS ($21), TLS_TRUST_CA ($22), TLS_INFO ($23), START_TLS ($24) and TLS_RELEASE ($25) give a C64 program TLS sockets on the U64. The network target keeps the TCP socket and moves the ciphertext; the session, the keys and the certificate checks are on the WiFi module (CMD_TLS_*). Elsewhere the commands exist and answer that TLS is not available. The TLS code is in network_target_tls.cc; doc/uci_tls.md describes the commands. - wifi_tls.{h,cc}: the module calls, each answer checked byte by byte against the wire layout before any of it is taken. - wifi_dedicated.{h,cc}: one request to the module outstanding, its reply on a queue of its own, a deadline, and a cancel predicate. The receive interrupt hands those replies over tagged with the UART's buffer generation (dma_uart.*), so a reply that was queued before a buffer pool reset is dropped unread instead of freed into the new pool. - command_intf: reset_pending(), so a long TLS command ends when the C64 resets. - sntp_time: sntp_utc_now(), the time the module is given in OPEN. - set_status() clamps a status to 255 bytes, not CMD_MAX_STATUS_LEN (256): the status length register is 8 bits. No status in the code is that long today. Host tests: target/pc/linux/wifitls (make host_tests): the module calls and the dedicated channel, and the network target's TLS commands against a simulated module. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/build.yml | 9 + Makefile | 1 + doc/uci_tls.md | 291 +++ software/io/command_interface/command_intf.cc | 5 + software/io/command_interface/command_intf.h | 4 + software/io/network/network_target.cc | 52 + software/io/network/network_target.h | 105 + software/io/network/network_target_tls.cc | 1661 ++++++++++++++++ software/io/uart/dma_uart.cc | 5 +- software/io/wifi/tests/wifi_task_env.h | 3 + software/io/wifi/wifi.cc | 19 + software/io/wifi/wifi_dedicated.cc | 65 +- software/io/wifi/wifi_dedicated.h | 25 +- software/io/wifi/wifi_tls.cc | 559 ++++++ software/io/wifi/wifi_tls.h | 179 ++ software/network/sntp_time.cc | 26 + software/network/sntp_time.h | 5 + software/test/wifi_tls/check.h | 8 + software/test/wifi_tls/ip4addr_aton.cc | 97 + software/test/wifi_tls/net_tls_test.cc | 1732 +++++++++++++++++ software/test/wifi_tls/net_world.cc | 970 +++++++++ software/test/wifi_tls/net_world.h | 202 ++ software/test/wifi_tls/netstub/command_intf.h | 14 + software/test/wifi_tls/netstub/dump_hex.h | 1 + software/test/wifi_tls/netstub/lwip/dns.h | 19 + software/test/wifi_tls/netstub/lwip/opt.h | 5 + software/test/wifi_tls/netstub/lwip/tcpip.h | 8 + software/test/wifi_tls/netstub/netdb.h | 8 + .../test/wifi_tls/netstub/network_interface.h | 14 + software/test/wifi_tls/netstub/socket.h | 37 + software/test/wifi_tls/stub/FreeRTOS.h | 17 + software/test/wifi_tls/stub/lwip/inet.h | 6 + software/test/wifi_tls/stub/lwip/netdb.h | 1 + software/test/wifi_tls/stub/lwip/sockets.h | 36 + software/test/wifi_tls/stub/queue.h | 5 + software/test/wifi_tls/stub/sntp_time.h | 6 + software/test/wifi_tls/stub/task.h | 8 + software/test/wifi_tls/stub/wifi_cmd.h | 51 + software/test/wifi_tls/wifi_tls_test.cc | 705 +++++++ software/test/wifi_tls/world.cc | 269 +++ software/test/wifi_tls/world.h | 31 + target/pc/linux/wifitls/Makefile | 66 + target/u2/microblaze/mb_ultimate/Makefile | 1 + target/u2/riscv/ultimate/Makefile | 1 + target/u2plus/nios/ultimate/Makefile | 1 + target/u2plus_L/riscv/ultimate/Makefile | 1 + target/u64/nios2/ultimate/Makefile | 2 + target/u64/riscv/ultimate/Makefile | 1 + target/u64ii/riscv/ultimate/Makefile | 1 + 49 files changed, 7314 insertions(+), 24 deletions(-) create mode 100644 doc/uci_tls.md create mode 100644 software/io/network/network_target_tls.cc create mode 100644 software/io/wifi/wifi_tls.cc create mode 100644 software/io/wifi/wifi_tls.h create mode 100644 software/test/wifi_tls/check.h create mode 100644 software/test/wifi_tls/ip4addr_aton.cc create mode 100644 software/test/wifi_tls/net_tls_test.cc create mode 100644 software/test/wifi_tls/net_world.cc create mode 100644 software/test/wifi_tls/net_world.h create mode 100644 software/test/wifi_tls/netstub/command_intf.h create mode 100644 software/test/wifi_tls/netstub/dump_hex.h create mode 100644 software/test/wifi_tls/netstub/lwip/dns.h create mode 100644 software/test/wifi_tls/netstub/lwip/opt.h create mode 100644 software/test/wifi_tls/netstub/lwip/tcpip.h create mode 100644 software/test/wifi_tls/netstub/netdb.h create mode 100644 software/test/wifi_tls/netstub/network_interface.h create mode 100644 software/test/wifi_tls/netstub/socket.h create mode 100644 software/test/wifi_tls/stub/FreeRTOS.h create mode 100644 software/test/wifi_tls/stub/lwip/inet.h create mode 100644 software/test/wifi_tls/stub/lwip/netdb.h create mode 100644 software/test/wifi_tls/stub/lwip/sockets.h create mode 100644 software/test/wifi_tls/stub/queue.h create mode 100644 software/test/wifi_tls/stub/sntp_time.h create mode 100644 software/test/wifi_tls/stub/task.h create mode 100644 software/test/wifi_tls/stub/wifi_cmd.h create mode 100644 software/test/wifi_tls/wifi_tls_test.cc create mode 100644 software/test/wifi_tls/world.cc create mode 100644 software/test/wifi_tls/world.h create mode 100644 target/pc/linux/wifitls/Makefile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f7a11297..6e68f0b1a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -184,6 +184,15 @@ jobs: docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp \ -v $GITHUB_WORKSPACE:/mnt/project:rw --workdir /mnt/project $IDF6_IMAGE make host_tests_idf6 + # The UCI TLS commands against stand-ins for FreeRTOS, the UART, lwIP and the + # WiFi module: the module calls, the dedicated channel and the network target + # (network_target.cc, network_target_tls.cc) itself. Needs no device and no network beyond loopback. + - name: Test UCI TLS Sockets + run: | + docker run --rm \ + -v /opt/build-tools:/mnt/build-tools:ro \ + -v $GITHUB_WORKSPACE:/mnt/project:rw my_docker_image /bin/bash -c "cd /mnt/project && make -C target/pc/linux/wifitls test" + # The checks on the vendored root store the ESP32 bridge builds its certificate # bundle from, and on the tool that refreshes it. Standard library only; in a # stock Python image for the same reason as the lint step above. diff --git a/Makefile b/Makefile index d48117606..5788068b4 100755 --- a/Makefile +++ b/Makefile @@ -90,6 +90,7 @@ host_tests: @$(MAKE) -C target/pc/linux/wifirandom test @$(MAKE) -C target/pc/linux/wifidedicated test @$(MAKE) -C target/pc/linux/getrandompaths test + @$(MAKE) -C target/pc/linux/wifitls test # The Mozilla root store the ESP32 bridge (raw_u64) builds its certificate bundle from # (software/wifi/ca_store). Its build checks the store at every configure; these are the diff --git a/doc/uci_tls.md b/doc/uci_tls.md new file mode 100644 index 000000000..91f85f123 --- /dev/null +++ b/doc/uci_tls.md @@ -0,0 +1,291 @@ +# TLS sockets on the UCI network target + +Commands `$21`-`$25` of network target 3 open TLS client connections. The WiFi module (ESP32) runs the TLS +sessions. The Ultimate keeps the TCP socket and carries the ciphertext between it and the module, so the C64 only ever +sees plaintext. Implementation: `software/io/network/network_target_tls.cc` (Ultimate side), +`software/wifi/raw_u64/main/tls_engine.c` (module side). + +## Conventions + +- Byte 0 of a command is the target (`$03`), byte 1 the command. A command is at most 895 bytes. +- Multi-byte integers in commands and replies are little endian, the IANA values too: TLS 1.3 (`0x0304`) travels as + `04 03`. +- Hash bytes (the pin, the SPKI hash) are in digest order, as `openssl dgst` prints them. +- A reply is data (possibly empty) plus one status string `NN,TEXT`. Hex in status texts is upper case and zero + padded: mbedTLS codes `-0x%04X`, flag words `0x%08X`, versions `0x%04X`. +- A TLS handle is an lwIP descriptor number, in the same space as TCP and UDP handles. +- `$21` and `$24` with the no-reply bit (`$80` in byte 0) are refused with 81 and open nothing. (A build without TLS + answers them from their layout alone, 81 or 90.) +- TLS is built for the Ultimate 64 (Nios II) only. Every other build has the commands without TLS, see + [Builds without TLS](#builds-without-tls). + +## Commands + +### `$21` OPEN_TLS + +``` +[2..3] port (LE) +[4] trust: 0 BUNDLE, 1 CUSTOM, 2 PIN +[5] flags: bit 0 REQUIRE_TLS13; bits 1-7 reserved (a set bit answers 82) +[6..37] pin, 32 bytes, only when trust = 2 (all zero answers 82) +tail host [ $00 [ name [ $00 ] ] ] +``` + +`host` is 1..253 bytes without `$00` (a DNS name or an IPv4 literal). `name` is 1..253 bytes without `$00`: the server +name for SNI and certificate checking. `host`, or `host $00`, gives no explicit name. Anything else in the tail +(empty host, `host $00 $00`, `$00` inside a name, bytes after the name's `$00`, a host or name over 253 bytes) +answers 81. + +The effective server name is the explicit name; else the host unless it is an IPv4 literal (anything lwIP's +`ip4addr_aton` accepts); else none. + +| Trust | Effective name | Server name sent and checked | +|---|---|---| +| BUNDLE, CUSTOM | must exist and must not be an IPv4 literal, else 81 | SNI sent, certificate must carry the name | +| PIN | any; an IPv4 literal counts as none | SNI sent for a DNS name, name not checked; none: no SNI | + +Success reply, 8 bytes, then `00,OK`: + +| Byte | Content | +|---|---| +| 0 | handle | +| 1..2 | negotiated version (`04 03` TLS 1.3, `03 03` TLS 1.2) | +| 3..4 | cipher suite (`01 13` TLS_AES_128_GCM_SHA256) | +| 5..6 | key exchange group (`1D 00` x25519, `17 00` secp256r1); never 0 | +| 7 | bit 0 extended master secret used (1 on TLS 1.2, 0 on 1.3); other bits 0 | + +A failure replies with no data and one status, and leaves nothing open. Refusals are applied in this order, and +nothing touches the network before step 5: + +1. Layout, lengths and tail grammar: 81. Then the name rule for BUNDLE/CUSTOM: 81. Then trust > 2, reserved flag bits, + all-zero pin: 82. +2. Module not available (no module, WiFi off, module image without TLS): 90. +3. No free table entry: 91. +4. CUSTOM and no CA loaded: 97 `NO CUSTOM CA`. +5. The module's open: 17, 87, 90, 92 or 97 (see the status table). +6. DNS: 84, or 17 if a C64 reset cut the wait short. +7. Socket and connect: 85, 11; 17 if a C64 reset cut the wait short; 86 if lwIP hands out a descriptor above 255. +8. Handshake: 13-19, 93-96. + +### `$22` TLS_TRUST_CA + +``` +[2..3] offset (LE) [4..5] total (LE) [6..] DER bytes of this chunk (0..889) +``` + +Uploads the one custom CA that trust mode CUSTOM uses. At most one is held, not stored in flash, and cleared by a +C64 reset or a module restart. + +| Command | Result | +|---|---| +| offset 0, total 1..1472 | starts an upload; any installed CA is dropped at once | +| offset 0, total 0, no data | clears the CA, `00,OK` | +| offset 0, total 0, with data | 81 | +| offset 0, total > 1472 | 82, no CA | +| offset > 0 | must continue the pending upload (offset = bytes so far, same total, not past total), else 81 and the upload is dropped. With no upload pending: 81, an installed CA untouched | +| intermediate chunk | empty reply, `00,OK` | +| final chunk | the module parses it: `00,OK` and the CA is LOADED, or one of the 97 texts below, or 90 / 17; the CA is then EMPTY | + +Any other network target command while an upload is pending cancels it. An ABORT does not. + +### `$23` TLS_INFO + +`[2]` handle. The command must be exactly 3 bytes, else 81. + +Handle `$FF`, the capability record, 16 bytes, `00,OK`. It makes one module STATS call, waited for at most 1 s: + +| Byte | Content | +|---|---| +| 0 | interface version, 1 | +| 1 | maximum sessions, 2 | +| 2 | table entries in use, including failed ones not yet closed | +| 3 | trust modes: bit 0 BUNDLE, bit 1 CUSTOM, bit 2 PIN (always `07`) | +| 4 | ready: bit 0 the module answered a STATS (kept while the module is merely busy, cleared when it stops, has no TLS or restarts); bit 1 entropy (radio started, never set without bit 0); bit 2 trusted time (SNTP time not before 2025-01-01, or the module's clock while bit 0); bit 3 custom CA LOADED | +| 5 | versions: bit 0 TLS 1.2, bit 1 TLS 1.3 (always `03`) | +| 6 | module major version (0 with no module) | +| 7..8 | module minor version (LE). 0 while no module application is detected, and on builds without TLS | +| 9..11 | `FF FF FF` while bit 0 of byte 4 is set (a bundle is present, the date is unknown; not a date), else 0 | +| 12..13 | the longest the module's dispatcher was blocked since boot, ms (LE); 0 while bit 0 is clear | +| 14 | entries not yet claimed (0 or 1; what `$25` would close) | +| 15 | 0 | + +Bytes 3 and 5 do not say whether a device has TLS: test bit 0 of byte 4. A device where it never sets has none. + +A TLS handle, 48 bytes, `00,OK`. A handle that failed after its handshake still reports the handshake's values: + +| Byte | Content | +|---|---| +| 0..1 | TLS version (LE) | +| 2..3 | cipher suite (LE) | +| 4..5 | group (LE) | +| 6 | trust mode used | +| 7 | the same bits as byte 7 of the open reply | +| 8..39 | SHA-256 of the leaf certificate's SubjectPublicKeyInfo | +| 40..43 | handshake time, ms (LE) | +| 44..47 | 0 | + +Any other handle: no data, 81. + +### `$24` START_TLS + +Starts TLS on a TCP socket this target already owns and has connected. + +``` +[2] handle +[3] trust [4] flags (as $21 [4] and [5]) +[5..36] pin, only when trust = 2 +tail [ name ] [ $00 ] name 1..253 bytes without $00; a lone $00 means no name +``` + +BUNDLE and CUSTOM need a name that is not an IPv4 literal (else 81). PIN with no name sends no SNI. The handle must +be an owned, not yet TLS, stream socket: the check comes first and a UDP handle, a TLS handle or an unowned number +answers 81 with the socket untouched. The TLS layer starts at the socket's current read position. Success replies like +`$21`, with the same handle. + +On failure the code decides what the handle is: + +| Codes | Handle afterwards | +|---|---| +| 81, 82, 87, 90, 91, 92, 97 | unchanged: still an open TCP handle, nothing was sent | +| every other code (11-19, 93-96, 17, 86) | gone: closed and untracked; do not close it | + +### `$25` TLS_RELEASE + +Exactly 2 bytes, else 81. Closes every TLS entry that is still unclaimed (see below) and replies one byte, the number +closed (0 or 1), `00,OK`. The no-reply bit is allowed. It is for one use only: as the next network target command +after an `$21` whose reply the program did not read, so that a session the abandoned open may have created is closed. + +## Sessions after an ABORT + +An ABORT never closes or frees a session. Every network target command except `$25` and `$23 $FF` (exactly 3 bytes) +marks all open entries as claimed, so only the entry the most recent `$21`/`$24` created can be unclaimed, and only +until the next command. + +- After an ABORTed `$21`: treat any handle from it as gone and send `$25` next. `$23 $FF` is allowed in between. +- After an ABORTed `$24`: send CLOSE on the handle. It answers `12,ERROR ON CLOSE: 9` if the handle was already gone, + which is harmless if nothing was opened in between. +- After an ABORT during a READ, or before all of a READ reply was read, plaintext is lost from the stream without an + error: CLOSE the handle. +- After an ABORTed WRITE: it was carried out in full, or the handle is failed. Do not resend it. +- A program that exits without a C64 reset leaves its sessions behind, claimed. The next program finds them with + `$23 $FF` (byte 2 is the count) and `$23 h` for each handle, and CLOSEs those that answer `00,OK`. A C64 reset + closes everything. + +## Existing commands on a TLS handle + +| Command | Behaviour | +|---|---| +| `$10` READ_SOCKET `[2]h [3..4]maxlen` | maxlen 1..1472 (else 82). Reply: 2-byte count, then that much plaintext, in blocks as for TCP. Plaintext already received is returned first; otherwise the target steps the session until plaintext arrives, the stream ends, or the read budget is spent. See the result table. | +| `$11` WRITE_SOCKET `[2]h [3..]data` | 0..892 bytes of plaintext. All or nothing: header `n` = bytes taken, then `00,OK`. 0 bytes: header 0, `00,OK`, nothing sent. A failure answers header `$FFFF`. Sent as TLS records; the plaintext never reaches the TCP socket. | +| `$16` WRITE_SOCKET_CHUNK `[2]h [3..4]offset [5..6]total [7..]data` | Where the firmware has it. The chunks are collected as for a plain socket (total at most 1472); the intermediate chunks answer an empty reply and `00,OK`, and the final chunk is written as one TLS write exactly as `$11` would, with header = total. | +| `$09` CLOSE_SOCKET `[2]h` | Sends close_notify (best effort, 100 ms) if the session is live, then closes the TCP socket. Always `00,OK`, failed or not. No module call if the session is already gone. | + +A pending chunk of `$16` is dropped by any other command, as for plain sockets. + +### READ and WRITE results + +| Situation | READ header | WRITE header | Status | Handle afterwards | +|---|---|---|---|---| +| Data | n | n | `00,OK` | open | +| Nothing yet | `$FFFF` | | `02,NO DATA: 11` | open | +| close_notify from the peer, all delivered | `$0000` | | `01,CONNECTION CLOSED BY HOST` | gone | +| TCP end without close_notify, all delivered | `$0000` | | `05,TLS CLOSED WITHOUT NOTIFY` | gone | +| Fatal alert from the peer | `$0000` | `$FFFF` | `14,TLS ALERT RECEIVED: ` | failed, owned until CLOSE | +| Record or decode failure | `$0000` | `$FFFF` | `16,TLS SESSION FAILED: -0xNNNN` | failed | +| Module timeout, restart, bad reply, WRITE stall | `$0000` | `$FFFF` | `17,TLS MODULE NOT RESPONDING` | failed | +| TCP send failed | `$0000` (later READs) | `$FFFF` | `12,SEND ERROR: ` | failed | +| TCP receive error (peer RST) | `$0000` | `$FFFF` | `12,RECEIVE ERROR: ` | failed (see below) | + +- A receive error fails the handle only when a READ ends in it, after all received plaintext was delivered. A WRITE + that meets it answers `$FFFF` and the same 12 but sends nothing; the READs go on and end in that 12. +- `$0000` on READ means the stream is over. After 01 and 05 the handle is gone: do not CLOSE it, because the number + may already belong to a newer socket. After 12, 14, 16 and 17 the handle is still owned: CLOSE it. +- `$FFFF` with `02,NO DATA: 9` means the number is not the program's handle any more; stop polling. +- 01, 05 and `12,RECEIVE ERROR` come only after every authenticated plaintext byte has been delivered. When a failure + (12 SEND ERROR, 14, 16, 17) is recorded, plaintext received but not yet read is discarded. +- A WRITE ends only when the module has taken all the plaintext and has no more ciphertext to send. If it cannot + within 4 module steps or 10 s, the handle fails with 17. +- Before a WRITE, READ until `$FFFF` with `02,NO DATA: 11` or `$0000`. If a WRITE still answers `$FFFF` with a `12` + other than `RECEIVE ERROR`, CLOSE the handle at once. + +## Status codes + +| Code | Text | From | Meaning | +|---|---|---|---| +| 01 | CONNECTION CLOSED BY HOST | READ | clean close; handle gone | +| 05 | TLS CLOSED WITHOUT NOTIFY | READ | TCP end without close_notify, possible truncation; handle gone | +| 11 | ERROR ON CONNECT: errno | OPEN | as OPEN_TCP, including the connect timeout | +| 12 | SEND ERROR: errno, RECEIVE ERROR: errno | READ, WRITE | failed handle; never from `$21` or `$24` | +| 13 | TLS HANDSHAKE FAILED: -0xNNNN, or `: NO EMS`, `: PEER CLOSED`, `: PEER RESET: errno`, `: SEND ERROR: errno` | OPEN | a handshake failure that is none of 14, 15, 18, 19, 93-96 | +| 14 | TLS ALERT RECEIVED: n | OPEN, READ, WRITE | fatal alert n from the server; 70 is protocol_version | +| 15 | TLS HANDSHAKE TIMEOUT | OPEN | no established session in 15 s, or the 40 s open budget ran out in the handshake | +| 16 | TLS SESSION FAILED: -0xNNNN | READ, WRITE | bad record MAC, decode error, too many empty records, KeyUpdate | +| 17 | TLS MODULE NOT RESPONDING | any | module timeout, full queue, malformed reply, restart or WRITE stall | +| 18 | TLS VERSION REFUSED: 0xNNNN | OPEN | the ServerHello chose a version not offered (TLS 1.2 under REQUIRE_TLS13, or below 1.2) | +| 19 | TLS DOWNGRADE DETECTED | OPEN | a TLS 1.2 ServerHello carrying the RFC 8446 4.1.3 downgrade sentinel | +| 81 | INVALID PARAMS | all | layout, lengths, tail grammar, name rule, not a TLS handle for `$23`, bad handle for `$24`, `$22` sequence error, no-reply bit on `$21`/`$24` | +| 82 | PARAMETER(S) OUT OF RANGE | all | trust > 2, reserved flag bit, all-zero pin, READ maxlen 0 or > 1472, CA total > 1472 | +| 84 | UNRESOLVED HOST | OPEN | as OPEN_TCP, also a 10 s DNS timeout | +| 85 | ERROR OPENING SOCKET | OPEN | as OPEN_TCP | +| 86 | INTERNAL ERROR | any | | +| 87 | NO ENTROPY SOURCE | OPEN, START_TLS | the radio has not started, so there is no random seed | +| 90 | TLS NOT AVAILABLE | OPEN, START_TLS, TRUST | no module, WiFi disabled, a module image without TLS, or a build without TLS | +| 91 | TLS SESSIONS IN USE | OPEN, START_TLS | both table entries are used, failed ones included; none is ever evicted | +| 92 | NO TRUSTED TIME | OPEN, START_TLS | BUNDLE and CUSTOM need a trusted clock; PIN does not | +| 93 | CERTIFICATE NOT TRUSTED: 0xNNNNNNNN | OPEN | chain not trusted, bad signature, weak key or hash, bad key usage; `0xFFFFFFFF` when verification did not complete | +| 94 | CERTIFICATE NAME MISMATCH: 0xNNNNNNNN | OPEN | the certificate is not for the server name | +| 95 | CERTIFICATE EXPIRED: 0xNNNNNNNN | OPEN | expired or not yet valid by the trusted clock | +| 96 | PINNED KEY MISMATCH | OPEN | PIN only: the leaf key is not the pinned key | +| 97 | CUSTOM CA INVALID: -0xNNNN, CUSTOM CA REJECTED: RSA KEY < 2048, CURVE or NOT A CA, NO CUSTOM CA | TRUST, OPEN | the upload did not parse or was refused when uploaded, or CUSTOM without a loaded CA the module holds | + +Where a chain is both untrusted and has the wrong name, the answer is 94. Only the first two digits are the code: a +client matches on those. + +## Trust modes and flags + +| Trust | Verifies against | +|---|---| +| 0 BUNDLE | the Mozilla root store built into the module (`software/wifi/ca_store`) | +| 1 CUSTOM | the one CA uploaded with `$22`, and nothing else | +| 2 PIN | the SHA-256 of the server leaf's SubjectPublicKeyInfo. The certificate chain and name are not checked; key usage and extended key usage still are | + +There is no mode without verification. BUNDLE and CUSTOM need a trusted time, so 92 until the SNTP clock is set. + +| Flag | Meaning | +|---|---| +| bit 0 REQUIRE_TLS13 | offer TLS 1.3 only. Clear: offer TLS 1.3 and hardened TLS 1.2 | +| bits 1-7 | reserved, answer 82 | + +Policy of the module's client, for both versions: + +- TLS 1.2 suites: ECDHE-ECDSA and ECDHE-RSA with AES-128-GCM, AES-256-GCM or ChaCha20-Poly1305 (`C02B C02C C02F C030 + CCA9 CCA8`). TLS 1.3 suites `1301 1302 1303`. No CBC, static key exchange, finite-field DH, PSK or SHA-1/MD5 + signatures. +- Key exchange groups, in order: x25519, secp256r1, secp384r1, secp521r1. +- TLS 1.2 requires the extended master secret (else `13,...: NO EMS`). No renegotiation, no session tickets or + resumption. +- A ServerHello without `supported_versions` is 18 under REQUIRE_TLS13; in default mode it is 19 only when its random + ends in the downgrade sentinel, else 13. A protocol_version alert is always 14 with 70. + +## Timing + +| Stage | Limit | +|---|---| +| module open | 5 s | +| DNS (inside `$21` only) | 10 s | +| TCP connect | 10 s | +| handshake | 15 s | +| `$21` or `$24` in total | 40 s; the command can take about 41 s before it answers | +| every other TLS command | 12 s at most | + +A program waits at least 45 s for `$21` and `$24` and 12 s for the others before it treats the interface as wedged. Only +a C64 reset ends a command early. + +## Builds without TLS + +Builds other than the Ultimate 64 (the U2 family, the Ultimate 64-II) have the commands but no TLS: + +- `$23 $FF` answers the 16-byte record with byte 4 = 0, byte 3 = `07` and byte 5 = `03`; byte 6..8 are 0. +- `$21` checks its layout (81) and otherwise answers 90, including trust > 2. `$24` answers 81 for a handle it does + not own, else 90. `$22` answers 81 below 6 bytes, else 90 for every chunk, the clear included. `$25` answers one + byte, 0, `00,OK`. diff --git a/software/io/command_interface/command_intf.cc b/software/io/command_interface/command_intf.cc index 750b53f36..c8d958d68 100644 --- a/software/io/command_interface/command_intf.cc +++ b/software/io/command_interface/command_intf.cc @@ -205,6 +205,11 @@ void CommandInterface :: copy_result(Message *data, Message *status) } } +bool CommandInterface :: reset_pending(void) +{ + return c64_reset_pending; +} + bool CommandInterface :: is_dma_active(void) { return ((CMD_IF_HANDSHAKE_OUT & CMD_HS_DMA_ACTIVE) != 0); diff --git a/software/io/command_interface/command_intf.h b/software/io/command_interface/command_intf.h index b7dcd0997..9220df3ae 100644 --- a/software/io/command_interface/command_intf.h +++ b/software/io/command_interface/command_intf.h @@ -90,6 +90,10 @@ class CommandInterface : public SubSystem void dump_registers(void); const char *identify(void) { return "Command Interface"; } bool is_dma_active(void); + // Whether a C64 reset has come in that run_task has not yet handed to the + // targets. Only looks: a long command polls it to end early, and the reset + // is still delivered after the command returns. + bool reset_pending(void); void set_kernal_device_id(uint8_t id); }; diff --git a/software/io/network/network_target.cc b/software/io/network/network_target.cc index 1c71c6139..fd8ccd39d 100644 --- a/software/io/network/network_target.cc +++ b/software/io/network/network_target.cc @@ -15,6 +15,8 @@ #if U64 >= 1 #include "wifi_random.h" #endif +#include +#include NetworkTarget net(3); @@ -37,6 +39,9 @@ NetworkTarget::NetworkTarget(int id) status_message.message = new uint8_t[CMD_MAX_STATUS_LEN]; socket_count = 0; discard_read_reply(); +#if NET_TLS + tls_init(); +#endif } NetworkTarget::~NetworkTarget() @@ -57,6 +62,10 @@ void NetworkTarget :: parse_command(Message *command, Message **reply, Message * // client bytes left over from an earlier read. discard_read_reply(); +#if NET_TLS + tls_before_command(command); +#endif + switch(command->message[1]) { case NET_CMD_IDENTIFY: *reply = &c_net_message_identification; @@ -187,6 +196,21 @@ void NetworkTarget :: parse_command(Message *command, Message **reply, Message * break; } get_random(command, reply, status); + break; + case NET_CMD_OPEN_TLS: + open_tls(command, reply, status); + break; + case NET_CMD_TLS_TRUST_CA: + trust_ca(command, reply, status); + break; + case NET_CMD_TLS_INFO: + tls_info(command, reply, status); + break; + case NET_CMD_START_TLS: + start_tls(command, reply, status); + break; + case NET_CMD_TLS_RELEASE: + tls_release(command, reply, status); break; default: *reply = &c_message_empty; @@ -268,6 +292,14 @@ void NetworkTarget :: read_socket(Message *command, Message **reply, Message **s uint8_t socketnr = command->message[2]; uint32_t length = ((uint32_t)command->message[3]) | (((uint32_t)command->message[4]) << 8); +#if NET_TLS + TlsSocket *session = tls_find(socketnr); + if (session) { + tls_read(session, length, reply, status); + return; + } +#endif + // A complete unfragmented IPv4 UDP datagram is the most this command can // ever return, so that is what it accepts. Anything larger cannot arrive. if (length > NET_MAX_SOCKET_READ) { @@ -379,6 +411,13 @@ void NetworkTarget :: write_socket(Message *command, Message **reply, Message ** int length = command->length - 3; int ret; +#if NET_TLS + TlsSocket *session = (command->length >= 3) ? tls_find(socketnr) : NULL; + if (session) { + tls_write(session, src, length, reply, status); + return; + } +#endif if (owns_socket(socketnr)) { ret = lwip_send(socketnr, src, length, 0); } else { @@ -407,6 +446,16 @@ void NetworkTarget :: close_socket(Message *command, Message **reply, Message ** { uint8_t socketnr = command->message[2]; int result = -1; +#if NET_TLS + // Always OK: the session goes, whatever state it is in. + TlsSocket *session = tls_find(socketnr); + if (session) { + tls_close_entry(session, true); + *reply = &c_message_empty; + *status = &c_status_ok; + return; + } +#endif if (owns_socket(socketnr)) { untrack_socket(socketnr); result = lwip_close(socketnr); @@ -514,6 +563,9 @@ void NetworkTarget :: c64_reset(void) // what is left of the previous one's read over Data More. discard_read_reply(); close_all_sockets(); +#if NET_TLS + tls_reset(); +#endif } void NetworkTarget :: get_more_data(Message **reply, Message **status) diff --git a/software/io/network/network_target.h b/software/io/network/network_target.h index 1c4a99a60..5cc9391f5 100644 --- a/software/io/network/network_target.h +++ b/software/io/network/network_target.h @@ -22,6 +22,11 @@ #define NET_CMD_READ_SOCKET 0x10 #define NET_CMD_WRITE_SOCKET 0x11 #define NET_CMD_GET_RANDOM 0x20 +#define NET_CMD_OPEN_TLS 0x21 +#define NET_CMD_TLS_TRUST_CA 0x22 +#define NET_CMD_TLS_INFO 0x23 +#define NET_CMD_START_TLS 0x24 +#define NET_CMD_TLS_RELEASE 0x25 #define NET_CMD_BUFSIZE 2048 @@ -48,6 +53,21 @@ // module hands out per request (RANDOM_MAX_BYTES in software/wifi/common/rpc_shared.h; // network_target.cc and wifi_random.cc assert the three agree). #define NET_MAX_RANDOM 512 +// TLS sockets: the WiFi module runs the session, this target +// keeps the TCP socket and carries the ciphertext. U64 only; elsewhere the +// commands exist and answer that TLS is not available. The target with the WiFi +// module is the Nios II one (wifi_tls.cc is not built for the others). +#if (U64 == 1) && defined(NIOS) +#define NET_TLS 1 +#else +#define NET_TLS 0 +#endif + +#define NET_MAX_TLS 2 // the module's cap (TLS_MAX_SESSIONS), asserted in network_target_tls.cc +#define NET_TLS_CT_MAX 1536 // ciphertext into one step +#define NET_TLS_PT_MAX 1024 // one step's output +#define NET_TLS_CA_MAX 1472 // one DER certificate +#define NET_TLS_STICKY_MAX 48 // the longest status a failed session keeps #if NET_MAX_SOCKET_READ > NET_CMD_BUFSIZE #error "the socket read buffer cannot hold the largest accepted read" @@ -56,6 +76,33 @@ #if NET_MAX_RANDOM > NET_MAX_REPLY_BLOCK #error "random bytes must fit a single reply block" #endif +// One TLS socket: the TCP socket, which is also in sockets[], and the session +// on the module that runs over it. +struct TlsSocket { + bool used; + int socketnr; + uint8_t slot; // on the module; the index of this entry + uint16_t tag; // with slot, names the session on the module + bool failed; // sticky: every READ and WRITE answers `sticky` until CLOSE + char sticky[NET_TLS_STICKY_MAX]; + bool claimed; // any network command but $23 $FF and $25 claims every entry + bool module_live; // false once the module freed the session: CLOSE sends no RPC + int rx_err; // the first receive error, latched; 0 = none, no receive after it + bool write_saw_rx_err; // a WRITE reported rx_err: the stream ends in that 12 + bool rx_fin; // TCP said end of stream; no receive after it + bool module_more; // the last step handed something out: the next READ steps at once + uint8_t end; // how the stream ends once rx is empty (TLS_END_*) + uint8_t quiet; // ct_in_len-0 drain steps in a row that changed nothing, across READs + uint16_t rx_off, rx_len; // plaintext received, not yet read by the C64 + uint16_t held_len; // ciphertext received, not yet taken by the module + // What OPEN answered with, for TLS_INFO. + uint16_t version, suite, group; + uint8_t trust, bits; + uint8_t spki[32]; + uint32_t handshake_ms; + uint8_t rx[NET_TLS_PT_MAX]; + uint8_t held[NET_TLS_CT_MAX]; +}; class NetworkTarget : public CommandTarget { Message data_message; @@ -81,6 +128,64 @@ class NetworkTarget : public CommandTarget { int sockets[NET_MAX_SOCKETS]; int socket_count; +#if NET_TLS + TlsSocket tls[NET_MAX_TLS]; + uint16_t tls_last_tag; + bool tls_generation_known; + uint32_t tls_generation; + uint8_t ca_state; // CA_EMPTY, CA_UPLOADING or CA_LOADED + uint16_t ca_tag; // never 0; a new one whenever the CA changes + uint16_t ca_len; + uint16_t ca_total; + uint8_t ca_buf[NET_TLS_CA_MAX]; + // The last global STATS that answered, for TLS_INFO $FF: kept through a + // STATS that fails for a busy module, so that one slow RPC does not flip + // the ready bits; dropped when the module is gone, has no TLS, or restarts. + bool info_valid; + uint32_t info_generation; + uint8_t info_ready; // ready bits 0-2 as that STATS gave them + uint16_t info_block_max_ms; + uint8_t tls_ct_out[NET_TLS_CT_MAX]; + uint8_t tls_pt[NET_TLS_PT_MAX]; + + void tls_init(void); + void tls_before_command(Message *command); + void tls_reset(void); + TlsSocket *tls_find(int socketnr); + TlsSocket *tls_reserve(void); + int tls_in_use(bool unclaimed_only); + uint16_t tls_new_tag(void); + void tls_new_ca_tag(void); + void tls_check_generation(void); + void tls_fail(TlsSocket *e, const char *text); + void tls_fail_module(TlsSocket *e, bool cleanup); + void tls_fail_step(TlsSocket *e, int esp_err, uint8_t alert_in); + void tls_close_entry(TlsSocket *e, bool send_notify); + void tls_cleanup_close(TlsSocket *e); + void tls_abandon(TlsSocket *e); + int tls_run_step(TlsSocket *e, void *step, uint32_t deadline, bool use_deadline); + int tls_send_all(int sock, const uint8_t *data, int length, uint32_t deadline); + bool tls_wait(int sock, bool for_write, uint32_t until); + int tls_resolve(const char *host, uint32_t deadline, uint32_t *address); + int tls_connect(int sock, uint32_t address, uint16_t port, uint32_t deadline); + Message *tls_prepare(TlsSocket *e, uint8_t trust, uint8_t flags, const uint8_t *pin, const char *name, + int name_len, uint32_t total, bool *keep); + Message *tls_handshake(TlsSocket *e, uint32_t total); + Message *tls_classify(TlsSocket *e, void *step); + void tls_reply_open(TlsSocket *e, Message **reply); + void tls_read(TlsSocket *e, uint32_t length, Message **reply, Message **status); + void tls_write(TlsSocket *e, const uint8_t *data, int length, Message **reply, Message **status); + void tls_end(TlsSocket *e, Message **reply, Message **status); +#endif + Message *set_status(const char *text); + Message *tls_parse_open(Message *command, int fixed, bool start, uint8_t *trust, uint8_t *flags, + const uint8_t **pin, const char **host, int *host_len, const char **name, int *name_len); + void open_tls(Message *command, Message **reply, Message **status); + void start_tls(Message *command, Message **reply, Message **status); + void trust_ca(Message *command, Message **reply, Message **status); + void tls_info(Message *command, Message **reply, Message **status); + void tls_release(Message *command, Message **reply, Message **status); + bool track_socket(int socketnr); void untrack_socket(int socketnr); bool is_datagram_socket(int socketnr); diff --git a/software/io/network/network_target_tls.cc b/software/io/network/network_target_tls.cc new file mode 100644 index 000000000..04105a8e9 --- /dev/null +++ b/software/io/network/network_target_tls.cc @@ -0,0 +1,1661 @@ +/* + * network_target_tls.cc + * + * The TLS commands of the network target ($21-$25) and the TLS side of its socket commands. + * The protocol is described in doc/uci_tls.md. + */ + +#include "network_target.h" +#include "network_interface.h" +#include "socket.h" +#include "lwip/opt.h" +#include "netdb.h" +#include +#include +#include +#include +#if NET_TLS +#include "lwip/dns.h" +#include "lwip/tcpip.h" +#include "FreeRTOS.h" +#include "task.h" +#include "sntp_time.h" +#include "wifi_tls.h" +#endif + +extern Message c_status_invalid_params; +extern Message c_status_param_out_of_range; +extern Message c_status_host_not_resolvable; +extern Message c_status_no_socket; +extern Message c_status_internal_error; +extern Message c_status_socket_closed; + +// The status texts are part of the protocol (doc/uci_tls.md). +#define TLS_MESSAGE(text) { sizeof(text) - 1, true, (uint8_t *)text } +Message c_status_tls_not_available = TLS_MESSAGE("90,TLS NOT AVAILABLE"); +Message c_status_tls_in_use = TLS_MESSAGE("91,TLS SESSIONS IN USE"); +Message c_status_tls_no_time = TLS_MESSAGE("92,NO TRUSTED TIME"); +Message c_status_tls_no_custom_ca = TLS_MESSAGE("97,NO CUSTOM CA"); +Message c_status_tls_module = TLS_MESSAGE("17,TLS MODULE NOT RESPONDING"); +Message c_status_tls_hs_timeout = TLS_MESSAGE("15,TLS HANDSHAKE TIMEOUT"); +Message c_status_tls_downgrade = TLS_MESSAGE("19,TLS DOWNGRADE DETECTED"); +Message c_status_tls_pin_mismatch = TLS_MESSAGE("96,PINNED KEY MISMATCH"); +Message c_status_tls_no_notify = TLS_MESSAGE("05,TLS CLOSED WITHOUT NOTIFY"); +extern Message c_status_no_entropy; // network_target.cc: GET_RANDOM answers the same + +#if NET_TLS +// Deadlines and caps. +#define TLS_DNS_MS 10000 +#define TLS_CONNECT_MS 10000 +#define TLS_OPEN_TOTAL_MS 40000 +#define TLS_HANDSHAKE_MS 15000 +#define TLS_STEP_RPC_MS 5000 +#define TLS_OPEN_RPC_MS 5000 +#define TLS_CLOSE_RPC_MS 1000 +#define TLS_STATS_RPC_MS 1000 +#define TLS_CLOSE_ALL_RPC_MS 500 +#define TLS_READ_WAIT_MS 40 +#define TLS_READ_BUDGET_STEPS 8 +#define TLS_READ_BUDGET_MS 250 +#define TLS_READ_TOTAL_MS 10000 +#define TLS_WRITE_BUDGET 4 +#define TLS_WRITE_TOTAL_MS 10000 +#define TLS_SEND_MS 5000 +#define TLS_NOTIFY_SEND_MS 100 +#define TLS_UNSENT_RETRIES 10 +#define TLS_UNSENT_DELAY_MS 50 +#define TLS_SLICE_MS 100 // the longest any wait goes without looking at a reset +#define TLS_SNDTIMEO_MS 500 // caps lwIP's close when it cannot get memory for the FIN + // (api_msg.c:1034-1037, else 20 s); our sends are MSG_DONTWAIT +#define TLS_EARLIEST_TIME 1735689600u // 2025-01-01: an SNTP time before this is not one + +#define CA_EMPTY 0 +#define CA_UPLOADING 1 +#define CA_LOADED 2 + +// How a stream ends once the C64 has read everything before the end. +#define TLS_END_NONE 0 +#define TLS_END_CLOSED 1 // close_notify: 01, the handle is gone +#define TLS_END_NO_NOTIFY 2 // TCP end without close_notify: 05, the handle is gone +#define TLS_END_RX_ERR 3 // the latched receive error: sticky 12 + +static_assert(NET_MAX_TLS == WIFI_TLS_MAX_SESSIONS, "the TLS table must match the module's cap"); +static_assert(NET_TLS_CT_MAX == WIFI_TLS_STEP_MAX_IN, "a step takes at most this much ciphertext"); +static_assert(NET_TLS_PT_MAX == WIFI_TLS_STEP_MAX_OUT, "a step hands out at most this much"); +static_assert(NET_TLS_CA_MAX == WIFI_TLS_CA_MAX, "CA sizes differ"); +static_assert(NET_MAX_SOCKET_READ <= NET_CMD_BUFSIZE, "a TLS read goes through buffer"); +#endif + + +Message *NetworkTarget :: set_status(const char *text) +{ + // The status length register is 8 bits, so 255 is the longest status a reply can carry + int n = strlen(text); + if (n > CMD_MAX_STATUS_LEN - 1) { + n = CMD_MAX_STATUS_LEN - 1; + } + memcpy(status_message.message, text, n); + status_message.length = n; + status_message.last_part = true; + return &status_message; +} + +// Byte-exact parsing of OPEN_TLS ($21, fixed = 6) and START_TLS ($24, fixed = 5): the refusals that need only the +// command, 81 before 82. OPEN's tail is host [ $00 [ name [ $00 ] ] ], START's is [ name ] [ $00 ]; host and name +// point into the command, unterminated. NULL when the command is well formed. +Message *NetworkTarget :: tls_parse_open(Message *command, int fixed, bool start, uint8_t *trust, uint8_t *flags, + const uint8_t **pin, const char **host, int *host_len, const char **name, + int *name_len) +{ + const uint8_t *m = command->message; + int length = command->length; + if (length < fixed) { + return &c_status_invalid_params; + } + *trust = m[fixed - 2]; + *flags = m[fixed - 1]; + int pos = fixed; + *pin = NULL; + if (*trust == 2) { // PIN + if (length < fixed + 32) { + return &c_status_invalid_params; + } + *pin = &m[fixed]; + pos += 32; + } + *host = NULL; + *host_len = 0; + *name = NULL; + *name_len = 0; + + int end = pos; + if (!start) { + while ((end < length) && (m[end] != 0)) { + end++; + } + *host = (const char *)&m[pos]; + *host_len = end - pos; + if ((*host_len < 1) || (*host_len > 253)) { + return &c_status_invalid_params; + } + if (end == length) { + return NULL; // host + } + pos = end + 1; // past the $00 + if (pos == length) { + return NULL; // host $00 + } + } else if ((length - pos == 1) && (m[pos] == 0)) { + return NULL; // a lone $00: no name + } + if (pos == length) { + return NULL; // START_TLS without a name + } + end = pos; + while ((end < length) && (m[end] != 0)) { + end++; + } + *name = (const char *)&m[pos]; + *name_len = end - pos; + if ((*name_len < 1) || (*name_len > 253)) { + return &c_status_invalid_params; + } + // After the name, at most its $00, as the very last byte. + if ((end < length) && (end != length - 1)) { + return &c_status_invalid_params; + } + return NULL; +} + +#if NET_TLS + +// Status texts carry numbers; the firmware's printf is not relied on for hex. +static char *put_text(char *p, const char *text) +{ + while (*text) { + *p++ = *text++; + } + *p = 0; + return p; +} + +static char *put_dec(char *p, int value) +{ + char digits[12]; + int n = 0; + uint32_t v = (value < 0) ? (uint32_t)(-(int64_t)value) : (uint32_t)value; + if (value < 0) { + *p++ = '-'; + } + do { + digits[n++] = '0' + (v % 10); + v /= 10; + } while (v); + while (n) { + *p++ = digits[--n]; + } + *p = 0; + return p; +} + +static char *put_hex(char *p, uint32_t value, int digits) +{ + static const char hex[] = "0123456789ABCDEF"; + p = put_text(p, "0x"); + for (int i = digits - 1; i >= 0; i--) { + *p++ = hex[(value >> (4 * i)) & 0xF]; + } + *p = 0; + return p; +} + +// An mbedTLS code, as -0x%04X in a status text. +static char *put_error(char *p, int error) +{ + if (error < 0) { + *p++ = '-'; + return put_hex(p, (uint32_t)(-(int64_t)error), 4); + } + return put_hex(p, (uint32_t)error, 4); +} + +// lwIP's own predicate for an IPv4 literal, which also takes 127.1 and +// 0x7f.0.0.1. +static bool is_ipv4_literal(const char *text, int length) +{ + char name[254]; + memcpy(name, text, length); + name[length] = 0; + ip4_addr_t address; + return ip4addr_aton(name, &address) != 0; +} + +static bool reached(uint32_t deadline) +{ + return (int32_t)(xTaskGetTickCount() - deadline) >= 0; +} + +static uint32_t tick_after(uint32_t ms) +{ + return xTaskGetTickCount() + pdMS_TO_TICKS(ms); +} + +static uint32_t earlier(uint32_t a, uint32_t b) +{ + return ((int32_t)(a - b) <= 0) ? a : b; +} + +// The cancel predicate of the module calls: a C64 reset always, and a +// deadline for the waits that have one. Cleanup calls pass no deadline. +typedef struct { + bool use_deadline; + uint32_t deadline; +} tls_cancel_context_t; + +static bool tls_cancelled(void *context) +{ + tls_cancel_context_t *c = (tls_cancel_context_t *)context; + if (cmd_if.reset_pending()) { + return true; + } + return c->use_deadline && reached(c->deadline); +} + +static bool reset_now(void) +{ + return cmd_if.reset_pending(); +} + +TlsSocket *NetworkTarget :: tls_find(int socketnr) +{ + for (int i = 0; i < NET_MAX_TLS; i++) { + if (tls[i].used && (tls[i].socketnr == socketnr)) { + return &tls[i]; + } + } + return NULL; +} + +// A free entry, not yet in use; the slot on the module is its index. +TlsSocket *NetworkTarget :: tls_reserve(void) +{ + for (int i = 0; i < NET_MAX_TLS; i++) { + if (!tls[i].used) { + return &tls[i]; + } + } + return NULL; +} + +int NetworkTarget :: tls_in_use(bool unclaimed_only) +{ + int n = 0; + for (int i = 0; i < NET_MAX_TLS; i++) { + if (tls[i].used && (!unclaimed_only || !tls[i].claimed)) { + n++; + } + } + return n; +} + +uint16_t NetworkTarget :: tls_new_tag(void) +{ + if (++tls_last_tag == 0) { + tls_last_tag = 1; + } + return tls_last_tag; +} + +void NetworkTarget :: tls_new_ca_tag(void) +{ + if (++ca_tag == 0) { + ca_tag = 1; + } +} + +// A module restart ends every session it held, and its CA. +void NetworkTarget :: tls_check_generation(void) +{ + if (!wifi_tls_module_available()) { + return; + } + uint32_t now = wifi_tls_generation(); + if (!tls_generation_known) { + tls_generation_known = true; + tls_generation = now; + return; + } + if (now == tls_generation) { + return; + } + tls_generation = now; + for (int i = 0; i < NET_MAX_TLS; i++) { + TlsSocket *e = &tls[i]; + if (e->used) { + if (!e->failed) { + tls_fail(e, "17,TLS MODULE NOT RESPONDING"); + } + e->module_live = false; + } + } + ca_state = CA_EMPTY; + tls_new_ca_tag(); +} + +// Sticky: the entry answers text on every READ and WRITE until CLOSE, and +// plaintext not yet read is dropped. +void NetworkTarget :: tls_fail(TlsSocket *e, const char *text) +{ + e->failed = true; + strncpy(e->sticky, text, NET_TLS_STICKY_MAX - 1); + e->sticky[NET_TLS_STICKY_MAX - 1] = 0; + e->rx_len = 0; + e->rx_off = 0; + e->end = TLS_END_NONE; +} + +// 17. With cleanup, the session is closed on the module at once, since +// nothing says what it did with the last request. +void NetworkTarget :: tls_fail_module(TlsSocket *e, bool cleanup) +{ + tls_fail(e, "17,TLS MODULE NOT RESPONDING"); + if (!cleanup) { + e->module_live = false; + } else { + tls_cleanup_close(e); + } +} + +// A session that FAILED after its handshake: 14 for a fatal alert from the +// peer, 16 otherwise. The module has freed it. +void NetworkTarget :: tls_fail_step(TlsSocket *e, int esp_err, uint8_t alert_in) +{ + char text[NET_TLS_STICKY_MAX]; + if (alert_in != WIFI_TLS_ALERT_NONE) { + put_dec(put_text(text, "14,TLS ALERT RECEIVED: "), alert_in); + } else { + put_error(put_text(text, "16,TLS SESSION FAILED: "), esp_err); + } + e->module_live = false; + tls_fail(e, text); +} + +// CLOSE with the reset as its only cancel, bounded by CLOSE_RPC_MS; what the +// module answers is not sent. A module that no longer knows the session has +// freed it all the same. +void NetworkTarget :: tls_cleanup_close(TlsSocket *e) +{ + if (!e->module_live || reset_now()) { + return; + } + tls_cancel_context_t context = { false, 0 }; + wifi_tls_cancel_t cancel = { tls_cancelled, &context }; + uint16_t notify_len; + int esp_err; + int result = wifi_tls_close(e->slot, e->tag, tls_ct_out, sizeof(tls_ct_out), ¬ify_len, &esp_err, + TLS_CLOSE_RPC_MS, &cancel); + if ((result == 0) || ((result == WIFI_TLS_REFUSED) && (esp_err == WIFI_TLS_ESP_NOT_FOUND))) { + e->module_live = false; + } +} + +// CLOSE_SOCKET, $25, and the end of a stream: the session on the module, its +// close_notify best effort, the socket, the entry. +void NetworkTarget :: tls_close_entry(TlsSocket *e, bool send_notify) +{ + if (e->module_live && !reset_now()) { + tls_cancel_context_t context = { false, 0 }; + wifi_tls_cancel_t cancel = { tls_cancelled, &context }; + uint16_t notify_len = 0; + int esp_err; + int result = wifi_tls_close(e->slot, e->tag, tls_ct_out, sizeof(tls_ct_out), ¬ify_len, &esp_err, + TLS_CLOSE_RPC_MS, &cancel); + if ((result == 0) && send_notify && notify_len) { + tls_send_all(e->socketnr, tls_ct_out, notify_len, tick_after(TLS_NOTIFY_SEND_MS)); + } + } + untrack_socket(e->socketnr); + lwip_close(e->socketnr); + e->used = false; +} + +// One STEP, sent again while it could not be sent at all. +int NetworkTarget :: tls_run_step(TlsSocket *e, void *step, uint32_t deadline, bool use_deadline) +{ + tls_cancel_context_t context = { use_deadline, deadline }; + wifi_tls_cancel_t cancel = { tls_cancelled, &context }; + int result; + for (int i = 0; ; i++) { + result = wifi_tls_step(e->slot, e->tag, (wifi_tls_step_t *)step, TLS_STEP_RPC_MS, &cancel); + if ((result != WIFI_TLS_UNSENT) || (i == TLS_UNSENT_RETRIES) || tls_cancelled(&context)) { + break; + } + vTaskDelay(pdMS_TO_TICKS(TLS_UNSENT_DELAY_MS)); + } + return result; +} + +// Waits at most one slice, and never past until, for the socket to become +// readable (or writable). True when it did. +bool NetworkTarget :: tls_wait(int sock, bool for_write, uint32_t until) +{ + int32_t left = (int32_t)(until - xTaskGetTickCount()); + if (left <= 0) { + return false; + } + if (left > (int32_t)pdMS_TO_TICKS(TLS_SLICE_MS)) { + left = pdMS_TO_TICKS(TLS_SLICE_MS); + } + fd_set fds, errs; + FD_ZERO(&fds); + FD_ZERO(&errs); + FD_SET(sock, &fds); + FD_SET(sock, &errs); + struct timeval tv; + uint32_t us = (uint32_t)left * portTICK_PERIOD_MS * 1000; + tv.tv_sec = us / 1000000; + tv.tv_usec = us % 1000000; + int n = lwip_select(sock + 1, for_write ? NULL : &fds, for_write ? &fds : NULL, &errs, &tv); + return n > 0; +} + +// Sends all of it, polling a non-blocking socket, before SEND_MS and deadline. +// Returns 0, an errno (ETIMEDOUT at the deadline), or -1 on a reset. +int NetworkTarget :: tls_send_all(int sock, const uint8_t *data, int length, uint32_t deadline) +{ + uint32_t until = earlier(tick_after(TLS_SEND_MS), deadline); + while (length > 0) { + int sent = lwip_send(sock, data, length, MSG_DONTWAIT); + if (sent > 0) { + data += sent; + length -= sent; + continue; + } + if ((sent < 0) && (errno != EWOULDBLOCK) && (errno != EAGAIN)) { + return errno; + } + if (reset_now()) { + return -1; + } + if (reached(until)) { + return ETIMEDOUT; + } + tls_wait(sock, true, until); + } + return 0; +} + +// DNS inside OPEN_TLS: lwIP's callback resolver, polled. One slot, and a +// lookup is known by its sequence number, carried by value; a late answer to +// an abandoned lookup finds another number and writes nothing. +#define DNS_PENDING 0 +#define DNS_OK 1 +#define DNS_FAILED 2 +static struct { + uint32_t cur_seq; + ip_addr_t addr; + uint8_t state; +} tls_dns; + +static void tls_dns_found(const char *name, const ip_addr_t *ipaddr, void *arg) +{ + // On the tcpip thread, which holds the core lock. + if ((uint32_t)(uintptr_t)arg != tls_dns.cur_seq) { + return; + } + if (ipaddr) { + tls_dns.addr = *ipaddr; + tls_dns.state = DNS_OK; + } else { + tls_dns.state = DNS_FAILED; + } +} + +// 0 with the address, 84, or -1 on a reset. +int NetworkTarget :: tls_resolve(const char *host, uint32_t deadline, uint32_t *address) +{ + ip_addr_t found; + LOCK_TCPIP_CORE(); + uint32_t seq = ++tls_dns.cur_seq; + tls_dns.state = DNS_PENDING; + err_t err = dns_gethostbyname(host, &found, tls_dns_found, (void *)(uintptr_t)seq); + UNLOCK_TCPIP_CORE(); + if (err == ERR_OK) { + *address = ip4_addr_get_u32(ip_2_ip4(&found)); + return 0; + } + if (err != ERR_INPROGRESS) { + return 84; + } + while (true) { + LOCK_TCPIP_CORE(); + uint8_t state = tls_dns.state; + found = tls_dns.addr; + UNLOCK_TCPIP_CORE(); + if (state == DNS_OK) { + *address = ip4_addr_get_u32(ip_2_ip4(&found)); + return 0; + } + if (state == DNS_FAILED) { + return 84; + } + if (reset_now()) { + return -1; + } + int32_t left = (int32_t)(deadline - xTaskGetTickCount()); + if (left <= 0) { + return 84; + } + vTaskDelay((left > (int32_t)pdMS_TO_TICKS(TLS_SLICE_MS)) ? pdMS_TO_TICKS(TLS_SLICE_MS) : left); + } +} + +// A non-blocking connect, polled: lwIP answers EALREADY while it is under way +// and EISCONN once it is done. 0, an errno (ETIMEDOUT at the deadline), or -1 +// on a reset. +int NetworkTarget :: tls_connect(int sock, uint32_t address, uint16_t port, uint32_t deadline) +{ + struct sockaddr_in addr; + memset(&addr, 0, sizeof(addr)); + addr.sin_len = sizeof(addr); + addr.sin_family = AF_INET; + addr.sin_port = PP_HTONS(port); + addr.sin_addr.s_addr = address; + while (lwip_connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + int error = errno; + if (error == EISCONN) { + return 0; + } + if ((error != EINPROGRESS) && (error != EALREADY)) { + return error; + } + if (reset_now()) { + return -1; + } + int32_t left = (int32_t)(deadline - xTaskGetTickCount()); + if (left <= 0) { + return ETIMEDOUT; + } + tls_wait(sock, true, deadline); + } + return 0; +} + +// What every TLS socket gets: non-blocking, TCP_NODELAY, and a send timeout, which also bounds lwIP's close when it +// has no memory for the FIN. OPEN_TLS sets them on its new socket; START_TLS only once steps 1-5 have passed, so +// that a kept code leaves the socket as it was. +static void tls_socket_options(int sock) +{ + int on = 1; + lwip_ioctl(sock, FIONBIO, &on); + lwip_setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)); + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = TLS_SNDTIMEO_MS * 1000; + lwip_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); +} + +// Steps 2 to 5 of the refusal order: the module, the table, the CA, and the OPEN RPC, which starts a session on the +// module under (slot, tag). keep says whether START_TLS leaves the TCP socket as it was. NULL once the module holds +// the session. +Message *NetworkTarget :: tls_prepare(TlsSocket *e, uint8_t trust, uint8_t flags, const uint8_t *pin, + const char *name, int name_len, uint32_t total, bool *keep) +{ + *keep = true; + if (!wifi_tls_module_available()) { + return &c_status_tls_not_available; + } + if (!e) { + return &c_status_tls_in_use; + } + if ((trust == WIFI_TLS_TRUST_CUSTOM) && (ca_state != CA_LOADED)) { + return &c_status_tls_no_custom_ca; + } + memset(e, 0, offsetof(TlsSocket, rx)); // all but the buffers + e->slot = (uint8_t)(e - tls); + e->tag = tls_new_tag(); + e->trust = trust; + e->module_live = false; + + wifi_tls_open_t open; + open.trust = trust; + open.slot = e->slot; + open.tag = e->tag; + open.opts = flags & WIFI_TLS_OPT_REQUIRE_TLS13; + uint32_t now = sntp_utc_now(); + open.time_source = (now >= TLS_EARLIEST_TIME) ? WIFI_TLS_TIME_NIOS : WIFI_TLS_TIME_NONE; + open.unix_time = (now >= TLS_EARLIEST_TIME) ? now : 0; + open.ca_tag = (trust == WIFI_TLS_TRUST_CUSTOM) ? ca_tag : 0; + open.pin = (trust == WIFI_TLS_TRUST_PIN) ? pin : NULL; + open.sni = name; + open.sni_len = (uint8_t)name_len; + + tls_cancel_context_t context = { true, earlier(tick_after(TLS_OPEN_RPC_MS), total) }; + wifi_tls_cancel_t cancel = { tls_cancelled, &context }; + int esp_err; + uint8_t reason; + int result; + for (int i = 0; ; i++) { + result = wifi_tls_open(&open, TLS_OPEN_RPC_MS, &cancel, &esp_err, &reason); + if ((result != WIFI_TLS_UNSENT) || (i == TLS_UNSENT_RETRIES) || tls_cancelled(&context)) { + break; + } + vTaskDelay(pdMS_TO_TICKS(TLS_UNSENT_DELAY_MS)); + } + if (result == 0) { + e->module_live = true; + return NULL; + } + if (result == WIFI_TLS_NO_MODULE) { + return &c_status_tls_not_available; + } + if (result == WIFI_TLS_REFUSED) { + switch (reason) { + case WIFI_TLS_REASON_NO_ENTROPY: return &c_status_no_entropy; + case WIFI_TLS_REASON_NO_TIME: return &c_status_tls_no_time; + case WIFI_TLS_REASON_NO_CUSTOM_CA: return &c_status_tls_no_custom_ca; + default: break; + } + if (esp_err == WIFI_TLS_ESP_NOT_SUPPORTED) { + return &c_status_tls_not_available; // a module image without TLS + } + *keep = false; + return &c_status_tls_module; + } + // No answer, or not a well formed one: the module may hold the session + // all the same. The (slot, tag) takeover covers a CLOSE that is lost too. + *keep = false; + e->module_live = true; + tls_cleanup_close(e); + return &c_status_tls_module; +} + +// A handshake that FAILED, to its status code. +Message *NetworkTarget :: tls_classify(TlsSocket *e, void *step) +{ + wifi_tls_step_t *st = (wifi_tls_step_t *)step; + char text[64]; + uint32_t w = st->verify_flags; + bool pin = (e->trust == WIFI_TLS_TRUST_PIN); + switch (st->fail_reason) { + case WIFI_TLS_FAIL_NONE: + if (st->alert_in != WIFI_TLS_ALERT_NONE) { + put_dec(put_text(text, "14,TLS ALERT RECEIVED: "), st->alert_in); + } else { + put_error(put_text(text, "13,TLS HANDSHAKE FAILED: "), st->esp_err); + } + return set_status(text); + case WIFI_TLS_FAIL_VERSION_REFUSED: + put_hex(put_text(text, "18,TLS VERSION REFUSED: "), w & 0xFFFF, 4); + return set_status(text); + case WIFI_TLS_FAIL_DOWNGRADE: + return &c_status_tls_downgrade; + case WIFI_TLS_FAIL_NO_EMS: + return set_status("13,TLS HANDSHAKE FAILED: NO EMS"); + case WIFI_TLS_FAIL_CERT_VERIFY: + if ((w == 0xFFFFFFFF) || pin) { + put_hex(put_text(text, "93,CERTIFICATE NOT TRUSTED: "), w, 8); + } else if (w & 0x04) { // MBEDTLS_X509_BADCERT_CN_MISMATCH + put_hex(put_text(text, "94,CERTIFICATE NAME MISMATCH: "), w, 8); + } else if (w & (0x01 | 0x200)) { // BADCERT_EXPIRED, BADCERT_FUTURE + put_hex(put_text(text, "95,CERTIFICATE EXPIRED: "), w, 8); + } else { + put_hex(put_text(text, "93,CERTIFICATE NOT TRUSTED: "), w, 8); + } + return set_status(text); + case WIFI_TLS_FAIL_PIN_MISMATCH: + return pin ? &c_status_tls_pin_mismatch : &c_status_tls_module; + case WIFI_TLS_FAIL_PEER_CLOSED: + return set_status("13,TLS HANDSHAKE FAILED: PEER CLOSED"); + default: + return &c_status_tls_module; + } +} + +// Step 8: the handshake, through to the STATS that the OPEN reply is made of. +// NULL when the session is ESTABLISHED; otherwise the code, and e->module_live +// says whether the module still holds the session. +Message *NetworkTarget :: tls_handshake(TlsSocket *e, uint32_t total) +{ + uint32_t started = xTaskGetTickCount(); + uint32_t deadline = earlier(tick_after(TLS_HANDSHAKE_MS), total); + char text[64]; + bool more = true; // the first step, with no input, makes the ClientHello + e->held_len = 0; + while (true) { + if (reset_now()) { + return &c_status_tls_module; + } + if (reached(deadline)) { + return &c_status_tls_hs_timeout; + } + if ((e->held_len == 0) && !more) { + if (!tls_wait(e->socketnr, false, deadline)) { + continue; + } + int n = lwip_recv(e->socketnr, e->held, NET_TLS_CT_MAX, MSG_DONTWAIT); + if (n == 0) { + return set_status("13,TLS HANDSHAKE FAILED: PEER CLOSED"); + } + if (n < 0) { + if ((errno == EWOULDBLOCK) || (errno == EAGAIN)) { + continue; + } + put_dec(put_text(text, "13,TLS HANDSHAKE FAILED: PEER RESET: "), errno); + return set_status(text); + } + e->held_len = n; + } + wifi_tls_step_t st; + memset(&st, 0, sizeof(st)); + st.ct_in = e->held; + st.ct_in_len = e->held_len; + st.ct_out = tls_ct_out; + st.ct_out_room = sizeof(tls_ct_out); + st.pt_out = tls_pt; + st.pt_out_room = sizeof(tls_pt); + int result = tls_run_step(e, &st, deadline, true); + if (reset_now()) { + return &c_status_tls_module; + } + if ((result != 0) && (result != WIFI_TLS_AGAIN)) { + if ((result == WIFI_TLS_REFUSED) && (st.esp_err == WIFI_TLS_ESP_NOT_FOUND)) { + e->module_live = false; + } + if ((result == WIFI_TLS_BUSY) && reached(deadline)) { + return &c_status_tls_hs_timeout; + } + return &c_status_tls_module; + } + if (result == 0) { + e->held_len = 0; + } + if (st.state == WIFI_TLS_FAILED || st.state == WIFI_TLS_CLOSED) { + e->module_live = false; + } + // Every ciphertext goes out before the next step, a failure's alert too. + if (st.ct_out_len) { + int error = tls_send_all(e->socketnr, tls_ct_out, st.ct_out_len, deadline); + if ((error != 0) && (st.state != WIFI_TLS_FAILED)) { + if (error < 0) { + return &c_status_tls_module; + } + if ((error == ETIMEDOUT) && reached(deadline)) { + return &c_status_tls_hs_timeout; + } + // Status 12 is for READ/WRITE only; a send that fails + // mid-handshake, by a reset or by SEND_MS (116), is a + // handshake failure. + put_dec(put_text(text, "13,TLS HANDSHAKE FAILED: SEND ERROR: "), error); + return set_status(text); + } + } + if (st.state == WIFI_TLS_FAILED) { + return tls_classify(e, &st); + } + if (st.state == WIFI_TLS_CLOSED) { + return set_status("13,TLS HANDSHAKE FAILED: PEER CLOSED"); + } + if (st.state == WIFI_TLS_ESTABLISHED) { + if (st.pt_out_len) { + memcpy(e->rx, tls_pt, st.pt_out_len); + e->rx_len = st.pt_out_len; + } + e->module_more = true; + break; + } + more = (st.ct_out_len != 0) || (result == WIFI_TLS_AGAIN); + } + + // What the reply reports is the module's, never guessed here. + tls_cancel_context_t context = { true, deadline }; + wifi_tls_cancel_t cancel = { tls_cancelled, &context }; + wifi_tls_stats_t stats; + int esp_err; + int result = wifi_tls_stats(e->slot, e->tag, &stats, &esp_err, TLS_STATS_RPC_MS, &cancel); + if ((result != 0) || (stats.group == 0)) { + if (!reset_now() && reached(deadline)) { + return &c_status_tls_hs_timeout; + } + return &c_status_tls_module; + } + e->version = stats.tls_version; + e->suite = stats.ciphersuite; + e->group = stats.group; + e->bits = stats.ems ? 0x01 : 0x00; + memcpy(e->spki, stats.spki_sha256, sizeof(e->spki)); + e->handshake_ms = (xTaskGetTickCount() - started) * portTICK_PERIOD_MS; + return NULL; +} + +void NetworkTarget :: tls_reply_open(TlsSocket *e, Message **reply) +{ + uint8_t *m = data_message.message; + m[0] = (uint8_t)e->socketnr; + m[1] = (uint8_t)e->version; + m[2] = (uint8_t)(e->version >> 8); + m[3] = (uint8_t)e->suite; + m[4] = (uint8_t)(e->suite >> 8); + m[5] = (uint8_t)e->group; + m[6] = (uint8_t)(e->group >> 8); + m[7] = e->bits; + data_message.length = 8; + data_message.last_part = true; + *reply = &data_message; +} + +// A failed OPEN or START: the entry stays free, and the session goes on the +// module unless the module ended it itself. +void NetworkTarget :: tls_abandon(TlsSocket *e) +{ + e->used = false; + tls_cleanup_close(e); +} + +void NetworkTarget :: open_tls(Message *command, Message **reply, Message **status) +{ + *reply = &c_message_empty; + // No reply means nothing opened: an OPEN whose handle nobody reads + // could never be closed. + if (command->message[0] & CMD_IF_NO_REPLY) { + *status = &c_status_invalid_params; + return; + } + uint8_t trust, flags; + const uint8_t *pin; + const char *host, *name; + int host_len, name_len; + Message *refusal = tls_parse_open(command, 6, false, &trust, &flags, &pin, &host, &host_len, &name, + &name_len); + // The effective server name: the explicit one, else the host unless that + // is an IPv4 literal, else none. + bool host_literal = refusal ? false : is_ipv4_literal(host, host_len); + bool name_literal = (!refusal && name) ? is_ipv4_literal(name, name_len) : false; + if (!refusal && (trust <= WIFI_TLS_TRUST_CUSTOM)) { + if (name ? name_literal : host_literal) { + refusal = &c_status_invalid_params; // BUNDLE and CUSTOM check a name + } + } + if (!refusal) { + if (trust > WIFI_TLS_TRUST_PIN) { + refusal = &c_status_param_out_of_range; + } else if (flags & 0xFE) { + refusal = &c_status_param_out_of_range; + } else if (pin) { + int nonzero = 0; + for (int i = 0; i < 32; i++) { + nonzero |= pin[i]; + } + if (!nonzero) { + refusal = &c_status_param_out_of_range; + } + } + } + if (refusal) { + *status = refusal; + return; + } + const char *sni = name ? name : host; + int sni_len = name ? name_len : host_len; + if ((trust == WIFI_TLS_TRUST_PIN) && (name ? name_literal : host_literal)) { + sni = NULL; // an IPv4 literal never reaches SNI + sni_len = 0; + } + uint16_t port = uint16_t(command->message[2]) | (uint16_t(command->message[3]) << 8); + char hostname[254]; + memcpy(hostname, host, host_len); + hostname[host_len] = 0; + + uint32_t total = tick_after(TLS_OPEN_TOTAL_MS); + TlsSocket *e = tls_reserve(); + bool keep; + Message *failure = tls_prepare(e, trust, flags, pin, sni, sni_len, total, &keep); + if (failure) { + *status = failure; + return; + } + // From here on, every refusal closes the session just opened. + uint32_t address = 0; + int result = tls_resolve(hostname, earlier(tick_after(TLS_DNS_MS), total), &address); + if (result) { + *status = (result < 0) ? &c_status_tls_module : &c_status_host_not_resolvable; + tls_abandon(e); + return; + } + int sock = lwip_socket(AF_INET, SOCK_STREAM, 0); + if (sock < 0) { + *status = &c_status_no_socket; + tls_abandon(e); + return; + } + if (sock > 255) { + lwip_close(sock); + *status = &c_status_internal_error; + tls_abandon(e); + return; + } + tls_socket_options(sock); + result = tls_connect(sock, address, port, earlier(tick_after(TLS_CONNECT_MS), total)); + if (result) { + lwip_close(sock); + if (result < 0) { + *status = &c_status_tls_module; + } else { + char text[40]; + put_dec(put_text(text, "11,ERROR ON CONNECT: "), result); + *status = set_status(text); + } + tls_abandon(e); + return; + } + e->socketnr = sock; + failure = tls_handshake(e, total); + if (failure || !track_socket(sock)) { + *status = failure ? failure : &c_status_no_socket; + lwip_close(sock); + tls_abandon(e); + return; + } + e->used = true; + e->claimed = false; + tls_reply_open(e, reply); + *status = &c_status_ok; +} + +void NetworkTarget :: start_tls(Message *command, Message **reply, Message **status) +{ + *reply = &c_message_empty; + if (command->message[0] & CMD_IF_NO_REPLY) { + *status = &c_status_invalid_params; + return; + } + // The handle first, before any other check: a TCP socket this target + // owns that is not TLS already. Every 81 here leaves it alone. + if (command->length < 3) { + *status = &c_status_invalid_params; + return; + } + int sock = command->message[2]; + int type = -1; + socklen_t type_len = sizeof(type); + if (!owns_socket(sock) || (lwip_getsockopt(sock, SOL_SOCKET, SO_TYPE, &type, &type_len) < 0) || + (type != SOCK_STREAM) || tls_find(sock)) { + *status = &c_status_invalid_params; + return; + } + uint8_t trust, flags; + const uint8_t *pin; + const char *host, *name; + int host_len, name_len; + Message *refusal = tls_parse_open(command, 5, true, &trust, &flags, &pin, &host, &host_len, &name, + &name_len); + bool name_literal = (!refusal && name) ? is_ipv4_literal(name, name_len) : false; + if (!refusal && (trust <= WIFI_TLS_TRUST_CUSTOM) && (!name || name_literal)) { + refusal = &c_status_invalid_params; + } + if (!refusal) { + if ((trust > WIFI_TLS_TRUST_PIN) || (flags & 0xFE)) { + refusal = &c_status_param_out_of_range; + } else if (pin) { + int nonzero = 0; + for (int i = 0; i < 32; i++) { + nonzero |= pin[i]; + } + if (!nonzero) { + refusal = &c_status_param_out_of_range; + } + } + } + if (refusal) { + *status = refusal; + return; + } + if (name_literal) { + name = NULL; // PIN: an IPv4 literal never reaches SNI + name_len = 0; + } + uint32_t total = tick_after(TLS_OPEN_TOTAL_MS); + TlsSocket *e = tls_reserve(); + bool keep; + Message *failure = tls_prepare(e, trust, flags, pin, name, name_len, total, &keep); + if (failure && keep) { + *status = failure; // nothing was sent: the TCP handle is as it was + return; + } + if (!failure) { + // Only now, so that a kept code leaves the socket truly unchanged. + tls_socket_options(sock); + e->socketnr = sock; + failure = tls_handshake(e, total); + } + if (failure) { + // Every other code ends the handle. + *status = failure; + untrack_socket(sock); + lwip_close(sock); + tls_abandon(e); + return; + } + e->used = true; + e->claimed = false; + tls_reply_open(e, reply); + *status = &c_status_ok; +} + +// $22: the Nios owns the CA state; the module gets the certificate once +// it is complete. +void NetworkTarget :: trust_ca(Message *command, Message **reply, Message **status) +{ + *reply = &c_message_empty; + if (command->length < 6) { + *status = &c_status_invalid_params; + return; + } + const uint8_t *m = command->message; + uint16_t offset = uint16_t(m[2]) | (uint16_t(m[3]) << 8); + uint16_t total = uint16_t(m[4]) | (uint16_t(m[5]) << 8); + int chunk = command->length - 6; + if (offset == 0) { + if (total == 0) { + if (chunk) { + *status = &c_status_invalid_params; + return; + } + ca_state = CA_EMPTY; // cleared + tls_new_ca_tag(); + *status = &c_status_ok; + return; + } + // Any start drops the installed CA at once, under a new tag. + ca_state = CA_EMPTY; + tls_new_ca_tag(); + if (total > NET_TLS_CA_MAX) { + *status = &c_status_param_out_of_range; + return; + } + ca_state = CA_UPLOADING; + ca_len = 0; + ca_total = total; + } else { + // Only offset 0 touches an installed CA; a sequence error drops an upload. + if (ca_state != CA_UPLOADING) { + *status = &c_status_invalid_params; + return; + } + if ((offset != ca_len) || (total != ca_total)) { + ca_state = CA_EMPTY; + *status = &c_status_invalid_params; + return; + } + } + if (ca_len + chunk > ca_total) { + ca_state = CA_EMPTY; + *status = &c_status_invalid_params; + return; + } + memcpy(&ca_buf[ca_len], &m[6], chunk); + ca_len += chunk; + if (ca_len < ca_total) { + *status = &c_status_ok; + return; + } + + // The final chunk. + ca_state = CA_EMPTY; + if (!wifi_tls_module_available()) { + *status = &c_status_tls_not_available; + return; + } + tls_cancel_context_t context = { false, 0 }; + wifi_tls_cancel_t cancel = { tls_cancelled, &context }; + int esp_err; + uint8_t reject; + int result; + for (int i = 0; ; i++) { + result = wifi_tls_set_ca(ca_buf, ca_len, ca_tag, &esp_err, &reject, TLS_OPEN_RPC_MS, &cancel); + if ((result != WIFI_TLS_UNSENT) || (i == TLS_UNSENT_RETRIES) || reset_now()) { + break; + } + vTaskDelay(pdMS_TO_TICKS(TLS_UNSENT_DELAY_MS)); + } + char text[64]; + if (result == 0) { + ca_state = CA_LOADED; + *status = &c_status_ok; + } else if (result == WIFI_TLS_NO_MODULE) { + *status = &c_status_tls_not_available; + } else if ((result == WIFI_TLS_REFUSED) && (esp_err == WIFI_TLS_ESP_NOT_SUPPORTED) && (reject == 0)) { + *status = &c_status_tls_not_available; + } else if ((result == WIFI_TLS_REFUSED) && (reject == WIFI_TLS_REJECT_NONE) && (esp_err <= -2)) { + put_error(put_text(text, "97,CUSTOM CA INVALID: "), esp_err); + *status = set_status(text); + } else if ((result == WIFI_TLS_REFUSED) && (reject == WIFI_TLS_REJECT_RSA_KEY_SHORT)) { + *status = set_status("97,CUSTOM CA REJECTED: RSA KEY < 2048"); + } else if ((result == WIFI_TLS_REFUSED) && (reject == WIFI_TLS_REJECT_CURVE)) { + *status = set_status("97,CUSTOM CA REJECTED: CURVE"); + } else if ((result == WIFI_TLS_REFUSED) && (reject == WIFI_TLS_REJECT_NOT_CA)) { + *status = set_status("97,CUSTOM CA REJECTED: NOT A CA"); + } else { + *status = &c_status_tls_module; + } + if (ca_state != CA_LOADED) { + tls_new_ca_tag(); // whatever the module holds can no longer match + } +} + +void NetworkTarget :: tls_info(Message *command, Message **reply, Message **status) +{ + *reply = &c_message_empty; + if (command->length != 3) { + *status = &c_status_invalid_params; + return; + } + uint8_t *m = data_message.message; + uint8_t handle = command->message[2]; + if (handle == 0xFF) { + memset(m, 0, 16); + m[0] = 1; + m[1] = NET_MAX_TLS; + m[2] = (uint8_t)tls_in_use(false); + m[3] = 0x07; // BUNDLE, CUSTOM, PIN + m[5] = 0x03; // TLS 1.2 (hardened), TLS 1.3 + uint32_t now = sntp_utc_now(); + uint8_t ready = (ca_state == CA_LOADED) ? 0x08 : 0x00; + if (now >= TLS_EARLIEST_TIME) { + ready |= 0x04; + } + if (wifi_tls_module_available()) { + uint16_t major, minor; + wifi_tls_module_version(&major, &minor); + m[6] = (uint8_t)major; + m[7] = (uint8_t)minor; + m[8] = (uint8_t)(minor >> 8); + uint32_t generation = wifi_tls_generation(); + if (info_valid && (info_generation != generation)) { + info_valid = false; // the module restarted + } + tls_cancel_context_t context = { false, 0 }; + wifi_tls_cancel_t cancel = { tls_cancelled, &context }; + wifi_tls_stats_t stats; + int esp_err; + int result = wifi_tls_stats(WIFI_TLS_SLOT_GLOBAL, 0, &stats, &esp_err, TLS_STATS_RPC_MS, &cancel); + if (result == 0) { + info_valid = true; + info_generation = generation; + info_ready = 0x01 | (stats.entropy_source ? 0x02 : 0) | (stats.time_source ? 0x04 : 0); + info_block_max_ms = stats.block_max_ms; + } else if ((result == WIFI_TLS_NO_MODULE) || + ((result == WIFI_TLS_REFUSED) && (esp_err == WIFI_TLS_ESP_NOT_SUPPORTED))) { + // No module application, or no TLS in it. Anything else (no + // answer, a full TLS queue's ESP_ERR_TIMEOUT, a bad answer) + // says the module is busy, and the last good STATS stands. + info_valid = false; + } + } else { + info_valid = false; + } + if (info_valid) { + ready |= info_ready; + m[12] = (uint8_t)info_block_max_ms; + m[13] = (uint8_t)(info_block_max_ms >> 8); + // The CA store date: no reply carries it, so "a bundle, date + // unknown". + m[9] = 0xFF; + m[10] = 0xFF; + m[11] = 0xFF; + } + m[4] = ready; + m[14] = (uint8_t)tls_in_use(true); + data_message.length = 16; + data_message.last_part = true; + *reply = &data_message; + *status = &c_status_ok; + return; + } + TlsSocket *e = tls_find(handle); + if (!e) { + *status = &c_status_invalid_params; + return; + } + memset(m, 0, 48); + m[0] = (uint8_t)e->version; + m[1] = (uint8_t)(e->version >> 8); + m[2] = (uint8_t)e->suite; + m[3] = (uint8_t)(e->suite >> 8); + m[4] = (uint8_t)e->group; + m[5] = (uint8_t)(e->group >> 8); + m[6] = e->trust; + m[7] = e->bits; + memcpy(&m[8], e->spki, 32); + m[40] = (uint8_t)e->handshake_ms; + m[41] = (uint8_t)(e->handshake_ms >> 8); + m[42] = (uint8_t)(e->handshake_ms >> 16); + m[43] = (uint8_t)(e->handshake_ms >> 24); + data_message.length = 48; + data_message.last_part = true; + *reply = &data_message; + *status = &c_status_ok; +} + +void NetworkTarget :: tls_release(Message *command, Message **reply, Message **status) +{ + *reply = &c_message_empty; + if (command->length != 2) { + *status = &c_status_invalid_params; + return; + } + int closed = 0; + for (int i = 0; i < NET_MAX_TLS; i++) { + if (tls[i].used && !tls[i].claimed) { + tls_close_entry(&tls[i], true); + closed++; + } + } + data_message.message[0] = (uint8_t)closed; + data_message.length = 1; + data_message.last_part = true; + *reply = &data_message; + *status = &c_status_ok; +} + +static void read_header(Message *m, uint16_t value) +{ + m->message[0] = (uint8_t)value; + m->message[1] = (uint8_t)(value >> 8); + m->length = 2; + m->last_part = true; +} + +// The end of a stream whose plaintext has all been read: $0000 and the +// status; the handle is gone after 01 and 05, and owned until CLOSE after a +// sticky failure. +void NetworkTarget :: tls_end(TlsSocket *e, Message **reply, Message **status) +{ + read_header(&data_message, 0); + *reply = &data_message; + char text[NET_TLS_STICKY_MAX]; + // A WRITE that reported the latched 12 fixes the end to that 12, also + // when the drain had found close_notify before it: the + // client was told to CLOSE, so the handle must still be its own. + if (e->write_saw_rx_err && (e->end != TLS_END_NONE)) { + e->end = TLS_END_RX_ERR; + } + if (e->end == TLS_END_RX_ERR) { + put_dec(put_text(text, "12,RECEIVE ERROR: "), e->rx_err); + tls_fail(e, text); + } + if (e->failed) { + *status = set_status(e->sticky); + return; + } + if (e->end == TLS_END_CLOSED) { + tls_close_entry(e, false); + *status = &c_status_socket_closed; + } else { + tls_close_entry(e, true); + *status = &c_status_tls_no_notify; + } +} + +// READ on a TLS handle: plaintext already received first; else +// steps, within READ_BUDGET, until one hands out plaintext or the stream +// ends. +void NetworkTarget :: tls_read(TlsSocket *e, uint32_t length, Message **reply, Message **status) +{ + *reply = &c_message_empty; + if ((length == 0) || (length > NET_MAX_SOCKET_READ)) { + *status = &c_status_param_out_of_range; + return; + } + if (!e->failed && (e->rx_len == 0) && (e->end == TLS_END_NONE)) { + uint32_t deadline = tick_after(TLS_READ_TOTAL_MS); + uint32_t budget_end = tick_after(TLS_READ_BUDGET_MS); + int steps = 0; + while (!reset_now()) { + // Eager: top up the ciphertext before each step, unless the + // stream has ended or a receive error is latched. + if (!e->rx_err && !e->rx_fin && (e->held_len < NET_TLS_CT_MAX)) { + int n = lwip_recv(e->socketnr, e->held + e->held_len, NET_TLS_CT_MAX - e->held_len, MSG_DONTWAIT); + if (n > 0) { + e->held_len += n; + } else if (n == 0) { + e->rx_fin = true; + } else if ((errno != EWOULDBLOCK) && (errno != EAGAIN)) { + e->rx_err = errno; // the first one; no receive after it + } + } + bool draining = e->rx_err || e->rx_fin; + if ((e->held_len == 0) && !e->module_more && !draining) { + // Nothing to feed, and the module had nothing more to say. + uint32_t until = earlier(earlier(tick_after(TLS_READ_WAIT_MS), budget_end), deadline); + bool ready = false; + while (!ready && !reached(until) && !reset_now()) { + ready = tls_wait(e->socketnr, false, until); + } + if (!ready) { + break; + } + continue; + } + if ((steps >= TLS_READ_BUDGET_STEPS) || reached(budget_end) || reached(deadline)) { + break; + } + wifi_tls_step_t st; + memset(&st, 0, sizeof(st)); + st.ct_in = e->held; + st.ct_in_len = e->held_len; + st.ct_out = tls_ct_out; + st.ct_out_room = sizeof(tls_ct_out); + st.pt_out = tls_pt; + st.pt_out_room = sizeof(tls_pt); + uint16_t fed = e->held_len; + int result = tls_run_step(e, &st, deadline, true); + steps++; + if (reset_now()) { + break; + } + if ((result != 0) && (result != WIFI_TLS_AGAIN)) { + bool gone = (result == WIFI_TLS_REFUSED) && (st.esp_err == WIFI_TLS_ESP_NOT_FOUND); + tls_fail_module(e, !gone); + break; + } + if (result == 0) { + e->held_len = 0; + } + if (st.ct_out_len) { + int error = tls_send_all(e->socketnr, tls_ct_out, st.ct_out_len, deadline); + if (error < 0) { + break; + } + // After a receive error the peer is gone; its alert need not arrive. + if (error && !e->rx_err && (st.state != WIFI_TLS_FAILED)) { + char text[NET_TLS_STICKY_MAX]; + put_dec(put_text(text, "12,SEND ERROR: "), error); + tls_fail(e, text); + break; + } + } + e->module_more = (st.ct_out_len != 0) || (st.pt_out_len != 0) || (result == WIFI_TLS_AGAIN); + if (st.state == WIFI_TLS_FAILED) { + e->module_live = false; + if (e->write_saw_rx_err) { + e->end = TLS_END_RX_ERR; // a WRITE already said 12; plaintext read so far stays + } else { + tls_fail_step(e, st.esp_err, st.alert_in); + } + break; + } + if (st.pt_out_len) { + memcpy(e->rx, tls_pt, st.pt_out_len); + e->rx_off = 0; + e->rx_len = st.pt_out_len; + } + if (st.state == WIFI_TLS_CLOSED) { + // close_notify wins over a latched receive error, unless a + // WRITE has reported that error already. + e->module_live = false; + e->module_more = false; + e->end = e->write_saw_rx_err ? TLS_END_RX_ERR : TLS_END_CLOSED; + break; + } + if (st.state != WIFI_TLS_ESTABLISHED) { + tls_fail_module(e, true); + break; + } + if (e->rx_len) { + e->quiet = 0; // plaintext: not a quiet step + break; + } + if (draining && (fed == 0)) { + // Two quiet input-less steps: the module holds nothing more. + if (++e->quiet >= 2) { + e->end = e->rx_err ? TLS_END_RX_ERR : TLS_END_NO_NOTIFY; + break; + } + } else { + e->quiet = 0; + } + } + } + if (e->rx_len) { + int n = (e->rx_len < length) ? e->rx_len : length; + memcpy(buffer, e->rx + e->rx_off, n); + e->rx_off += n; + e->rx_len -= n; + if (!e->rx_len) { + e->rx_off = 0; + } + read_header(&data_message, n); + start_read_reply(n, &c_status_ok, reply, status); + return; + } + if (e->failed || (e->end != TLS_END_NONE)) { + tls_end(e, reply, status); + return; + } + // Nothing yet: the same answer as an idle TCP read. + read_header(&data_message, 0xFFFF); + *reply = &data_message; + char text[24]; + put_dec(put_text(text, "02,NO DATA: "), EWOULDBLOCK); + *status = set_status(text); +} + +static void write_header(Message *m, Message **reply, uint16_t value) +{ + read_header(m, value); + *reply = m; +} + +// WRITE on a TLS handle: all of it, or a sticky failure. The steps take +// no ciphertext in and hand no plaintext out (NO_READ). +void NetworkTarget :: tls_write(TlsSocket *e, const uint8_t *data, int length, Message **reply, Message **status) +{ + char text[NET_TLS_STICKY_MAX]; + if (e->failed) { + write_header(&data_message, reply, 0xFFFF); + *status = set_status(e->sticky); + return; + } + if (e->rx_err) { + // Nothing is sent; the READs go on draining, and end in this 12. + e->write_saw_rx_err = true; + write_header(&data_message, reply, 0xFFFF); + put_dec(put_text(text, "12,RECEIVE ERROR: "), e->rx_err); + *status = set_status(text); + return; + } + if (!e->module_live) { + // The peer's close_notify ended the session on the module. + put_dec(put_text(text, "12,SEND ERROR: "), EPIPE); + tls_fail(e, text); + write_header(&data_message, reply, 0xFFFF); + *status = set_status(e->sticky); + return; + } + if (length == 0) { + write_header(&data_message, reply, 0); + *status = &c_status_ok; + return; + } + uint32_t deadline = tick_after(TLS_WRITE_TOTAL_MS); + int pending = length; + int steps = 0; + while (true) { + if (reset_now()) { + tls_fail(e, "17,TLS MODULE NOT RESPONDING"); + break; + } + if (steps >= TLS_WRITE_BUDGET) { + tls_fail_module(e, true); + break; + } + wifi_tls_step_t st; + memset(&st, 0, sizeof(st)); + st.flags = WIFI_TLS_STEP_NO_READ; + st.pt_in = data; + st.pt_in_len = pending; + st.ct_out = tls_ct_out; + st.ct_out_room = sizeof(tls_ct_out); + st.pt_out = tls_pt; + st.pt_out_room = sizeof(tls_pt); + int result = tls_run_step(e, &st, deadline, true); + steps++; + if (reset_now()) { + tls_fail(e, "17,TLS MODULE NOT RESPONDING"); + break; + } + if ((result != 0) && (result != WIFI_TLS_AGAIN)) { + bool gone = (result == WIFI_TLS_REFUSED) && (st.esp_err == WIFI_TLS_ESP_NOT_FOUND); + tls_fail_module(e, !gone); + break; + } + if (result == 0) { + pending = 0; + } + if (st.ct_out_len) { + int error = tls_send_all(e->socketnr, tls_ct_out, st.ct_out_len, deadline); + if (error) { + if (error < 0) { + tls_fail(e, "17,TLS MODULE NOT RESPONDING"); + } else { + put_dec(put_text(text, "12,SEND ERROR: "), error); + tls_fail(e, text); // the ciphertext may be torn + } + break; + } + } + if (st.state == WIFI_TLS_FAILED) { + tls_fail_step(e, st.esp_err, st.alert_in); + break; + } + if (st.state != WIFI_TLS_ESTABLISHED) { + tls_fail_module(e, st.state != WIFI_TLS_CLOSED); + break; + } + if ((pending == 0) && (st.ct_out_len == 0)) { + write_header(&data_message, reply, (uint16_t)length); + *status = &c_status_ok; + return; + } + } + write_header(&data_message, reply, 0xFFFF); + *status = set_status(e->sticky); +} + +void NetworkTarget :: tls_init(void) +{ + memset(tls, 0, sizeof(tls)); + tls_last_tag = 0; + tls_generation_known = false; + tls_generation = 0; + ca_state = CA_EMPTY; + ca_tag = 0; + tls_new_ca_tag(); + ca_len = 0; + ca_total = 0; + info_valid = false; + info_generation = 0; + info_ready = 0; + info_block_max_ms = 0; +} + +void NetworkTarget :: tls_before_command(Message *command) +{ + // Every command claims every TLS session, so only the latest OPEN_TLS or START_TLS session can be unclaimed, + // and only until the next command. $25 (which frees an unclaimed session) and $23 $FF (which counts them) + // leave them as they are. + uint8_t code = (command->length >= 2) ? command->message[1] : 0; + bool keeps_claims = (code == NET_CMD_TLS_RELEASE) || + ((code == NET_CMD_TLS_INFO) && (command->length == 3) && (command->message[2] == 0xFF)); + tls_check_generation(); + if (!keeps_claims) { + for (int i = 0; i < NET_MAX_TLS; i++) { + tls[i].claimed = true; + } + } + // A CA upload takes no other network command in between. + if ((code != NET_CMD_TLS_TRUST_CA) && (ca_state == CA_UPLOADING)) { + ca_state = CA_EMPTY; + } +} + +void NetworkTarget :: tls_reset(void) +{ + // The sockets went with close_all_sockets. The sessions on the module go + // with CLOSE_ALL, and if that is lost, with the next OPEN of each slot; + // the CA with the new ca_tag, which the module's copy can never match. + for (int i = 0; i < NET_MAX_TLS; i++) { + tls[i].used = false; + } + ca_state = CA_EMPTY; + tls_new_ca_tag(); + if (wifi_tls_module_available()) { + int esp_err; + wifi_tls_close_all(&esp_err, TLS_CLOSE_ALL_RPC_MS); + } +} + +#else // !NET_TLS + +// Without the WiFi module the commands exist, and TLS is not available. +void NetworkTarget :: open_tls(Message *command, Message **reply, Message **status) +{ + uint8_t trust, flags; + const uint8_t *pin; + const char *host, *name; + int host_len, name_len; + *reply = &c_message_empty; + *status = tls_parse_open(command, 6, false, &trust, &flags, &pin, &host, &host_len, &name, &name_len); + if (!*status) { + *status = &c_status_tls_not_available; + } +} + +void NetworkTarget :: start_tls(Message *command, Message **reply, Message **status) +{ + *reply = &c_message_empty; + *status = (command->length < 3) || !owns_socket(command->message[2]) ? &c_status_invalid_params + : &c_status_tls_not_available; +} + +void NetworkTarget :: trust_ca(Message *command, Message **reply, Message **status) +{ + *reply = &c_message_empty; + *status = (command->length < 6) ? &c_status_invalid_params : &c_status_tls_not_available; +} + +void NetworkTarget :: tls_info(Message *command, Message **reply, Message **status) +{ + *reply = &c_message_empty; + if ((command->length != 3) || (command->message[2] != 0xFF)) { + *status = &c_status_invalid_params; + return; + } + uint8_t *m = data_message.message; + memset(m, 0, 16); + m[0] = 1; + m[1] = NET_MAX_TLS; + m[3] = 0x07; + m[5] = 0x03; + data_message.length = 16; + data_message.last_part = true; + *reply = &data_message; + *status = &c_status_ok; +} + +void NetworkTarget :: tls_release(Message *command, Message **reply, Message **status) +{ + *reply = &c_message_empty; + if (command->length != 2) { + *status = &c_status_invalid_params; + return; + } + data_message.message[0] = 0; + data_message.length = 1; + data_message.last_part = true; + *reply = &data_message; + *status = &c_status_ok; +} + +#endif // NET_TLS diff --git a/software/io/uart/dma_uart.cc b/software/io/uart/dma_uart.cc index bb56f3ba8..515a0e51e 100644 --- a/software/io/uart/dma_uart.cc +++ b/software/io/uart/dma_uart.cc @@ -113,8 +113,9 @@ void DmaUART::ModuleCtrl(uint8_t mode) void DmaUART::ClearRxBuffer(void) { - // No task may free a held buffer into the half refilled pool, which the - // reset would then fill with it a second time. Nothing below blocks. + // No other task may run until the pool is refilled and the generation counts the reset, or it could free a + // buffer it held into the half filled pool, which the reset then fills with that buffer a second time. + // Nothing below blocks: queue resets and zero tick sends only. vTaskSuspendAll(); // uart->ictrl = DMAUART_RxIRQ_DIS | DMAUART_TxIRQ_DIS |DMAUART_BufReq_DIS; // disable interrupts uart->flowctrl = uart->flowctrl | DMAUART_RESET; // reset pulse; will also disable interrupts diff --git a/software/io/wifi/tests/wifi_task_env.h b/software/io/wifi/tests/wifi_task_env.h index c521aee68..85f305db0 100644 --- a/software/io/wifi/tests/wifi_task_env.h +++ b/software/io/wifi/tests/wifi_task_env.h @@ -98,4 +98,7 @@ class U64Config { extern ultimate_ap_records_t wifi_aps; +// What wifi.cc keeps of the module's version, for the TLS calls +static __attribute__((unused)) uint16_t module_major, module_minor; + #endif /* WIFI_TASK_ENV_H_ */ diff --git a/software/io/wifi/wifi.cc b/software/io/wifi/wifi.cc index 4922307f5..0626fb4b8 100644 --- a/software/io/wifi/wifi.cc +++ b/software/io/wifi/wifi.cc @@ -20,6 +20,7 @@ #endif #include "init_function.h" #include "wifi_dedicated.h" +#include "wifi_tls.h" #define DEBUG_INPUT 0 #define EVENT_START 0xF1 @@ -27,6 +28,9 @@ WiFi wifi; ultimate_ap_records_t wifi_aps; +// What the module application said it is, for TLS_INFO; 0 before it answered. +static uint16_t module_major; +static uint16_t module_minor; InitFunction wifi_init("WiFi Application", WiFi::Init, NULL, NULL, 52); // after LWIP WiFi :: WiFi() @@ -288,6 +292,8 @@ void WiFi :: RunModeThread() case eWifi_ModuleDetected: uart->txDebug = false; if (wifi_detect(&major, &minor, moduleName, 32)) { + module_major = major; + module_minor = minor; state = eWifi_AppDetected; #if U64 == 2 @@ -643,6 +649,19 @@ bool wifi_module_ready(void) { return wifi.getState() >= eWifi_AppDetected; } + +// The application answers while its radio is off too; the module then refuses +// an OPEN itself, for want of entropy. +bool wifi_tls_module_available(void) +{ + return wifi_module_ready(); +} + +void wifi_tls_module_version(uint16_t *major, uint16_t *minor) +{ + *major = module_major; + *minor = module_minor; +} #endif extern "C" { diff --git a/software/io/wifi/wifi_dedicated.cc b/software/io/wifi/wifi_dedicated.cc index 4feb73749..2bed2b0e7 100644 --- a/software/io/wifi/wifi_dedicated.cc +++ b/software/io/wifi/wifi_dedicated.cc @@ -1,9 +1,10 @@ -// wifi_dedicated.cc: the one waiter for replies on WIFI_DEDICATED_THREAD, and -// GET_RANDOM, its first user. Not in wifi_cmd.cc, which the updater compiles. +// wifi_dedicated.cc: the one waiter for replies on WIFI_DEDICATED_THREAD, and GET_RANDOM, its +// first user. Not in wifi_cmd.cc, which the updater compiles without wifi.cc. #include #include "wifi_cmd.h" #include "wifi_dedicated.h" +#include "wifi_tls.h" #include "wifi_random.h" static_assert(WIFI_RANDOM_BUSY == DEDICATED_BUSY, "codes differ"); @@ -12,9 +13,9 @@ static_assert(WIFI_RANDOM_FOREIGN == DEDICATED_FOREIGN, "codes differ"); // The log reads esp_err where every reply that has one keeps it. static_assert(sizeof(rpc_espcmd_resp) == offsetof(rpc_get_random_resp, source), "rpc_espcmd_resp changed"); -// Hands a queued reply to take, then frees it. One queued before the last pool -// reset is dropped unread, as its buffer may be someone else's by now; the -// scheduler stays suspended so that no reset comes in between. check false: free only. +// Checks a queued reply against the request, lets take have it if it is the answer, and frees it. A reply queued +// before the last buffer pool reset is dropped unread: its buffer may since belong to someone else. The scheduler +// stays suspended from the check until the free, so no reset (only tasks do one) gets in between. check false: free. static int take_dedicated_reply(const dedicated_call_t *call, dedicated_reply_t *reply, bool check, uint16_t sequence) { int retval = DEDICATED_FOREIGN; @@ -43,11 +44,13 @@ static int take_dedicated_reply(const dedicated_call_t *call, dedicated_reply_t return retval; } -// Unlike wifi_cmd.cc, neither waits forever nor trusts the reply: take decides. -// Between calls dedicated_waiting is clear and dedicated_replies is empty. +// Unlike the calls in wifi_cmd.cc this neither waits for the module forever nor trusts what comes back: take decides +// what the answer is. Between calls dedicated_waiting is clear and dedicated_replies is empty, so no reply is left +// over for the next one. int wifi_dedicated_call(const dedicated_call_t *call) { - // Without the module application nothing can answer; fail now, not on a timeout. + // Without the module application nothing can answer, so fail at once + // rather than on a timeout. if (!wifi_module_ready() || !dedicated_replies) { return DEDICATED_NO_MODULE; } @@ -58,10 +61,12 @@ int wifi_dedicated_call(const dedicated_call_t *call) dedicated_waiting = true; LEAVE_SAFE_SECTION; if (busy) { - return DEDICATED_BUSY; + return DEDICATED_UNSENT; } int retval = DEDICATED_BUSY; + bool sent = false; + bool cancelled = false; uint16_t sequence = sequence_nr++; dedicated_reply_t reply; command_buf_t *packet; @@ -75,17 +80,35 @@ int wifi_dedicated_call(const dedicated_call_t *call) packet->size = call->fill(packet->data, call->context); if (esp32.uart->TransmitPacket(packet) == pdTRUE) { - // A late reply to an earlier request is skipped, within the same timeout. + // A late reply to an earlier request is skipped, within the same + // timeout. + sent = true; const TickType_t timeout = pdMS_TO_TICKS(call->timeout_ms); + const TickType_t slice = pdMS_TO_TICKS(DEDICATED_SLICE_MS); TickType_t start = xTaskGetTickCount(); retval = DEDICATED_FOREIGN; while (retval == DEDICATED_FOREIGN) { TickType_t spent = xTaskGetTickCount() - start; - if ((spent >= timeout) || - (xQueueReceive(dedicated_replies, &reply, timeout - spent) == pdFALSE)) { + if (spent >= timeout) { retval = DEDICATED_BUSY; break; } + TickType_t wait = timeout - spent; + if (call->cancel && (wait > slice)) { + wait = slice; + } + if (xQueueReceive(dedicated_replies, &reply, wait) == pdFALSE) { + if (call->cancel && call->cancel(call->cancel_context)) { + cancelled = true; + retval = DEDICATED_BUSY; + break; + } + if (!call->cancel) { + retval = DEDICATED_BUSY; + break; + } + continue; + } retval = take_dedicated_reply(call, &reply, true, sequence); } } @@ -95,7 +118,7 @@ int wifi_dedicated_call(const dedicated_call_t *call) // After a timeout that can still be our reply. dedicated_waiting = false; while (xQueueReceive(dedicated_replies, &reply, 0) == pdTRUE) { - if (retval == DEDICATED_BUSY) { + if ((retval == DEDICATED_BUSY) && !cancelled) { retval = take_dedicated_reply(call, &reply, true, sequence); if (retval == DEDICATED_FOREIGN) { retval = DEDICATED_BUSY; @@ -104,12 +127,22 @@ int wifi_dedicated_call(const dedicated_call_t *call) take_dedicated_reply(call, &reply, false, 0); } } - if (retval == DEDICATED_BUSY) { + if (cancelled) { + printf("%s: cancelled.\n", call->name); + } else if (retval == DEDICATED_BUSY) { printf("%s: no reply.\n", call->name); + if (!sent) { + retval = DEDICATED_UNSENT; + } } return retval; } +uint32_t wifi_tls_generation(void) +{ + return esp32.uart->generation; +} + typedef struct { uint8_t *buf; uint16_t len; @@ -136,5 +169,7 @@ int wifi_get_random(uint8_t *buf, uint16_t len) // About 1 ms on the wire; far longer only while the module's dispatcher is // blocked handing a scan or connect to its connector, which is worth a retry. const dedicated_call_t call = { "Get Random", CMD_GET_RANDOM, 200, fill_random, take_random, &args }; - return wifi_dedicated_call(&call); + int r = wifi_dedicated_call(&call); + // The channel was taken or there was no buffer: nothing was sent, which a caller of GET_RANDOM reads as busy + return (r == DEDICATED_UNSENT) ? WIFI_RANDOM_BUSY : r; } diff --git a/software/io/wifi/wifi_dedicated.h b/software/io/wifi/wifi_dedicated.h index 5f031b762..581b0766c 100644 --- a/software/io/wifi/wifi_dedicated.h +++ b/software/io/wifi/wifi_dedicated.h @@ -1,5 +1,6 @@ -// wifi_dedicated.h: requests whose replies bypass the reply slots and are -// awaited with a deadline, one at a time. Free of rpc_calls.h and FreeRTOS. +// wifi_dedicated.h: requests to the WiFi module that do not trust it to answer, or to answer only them (the TLS +// calls). Replies come through their own queue, not the reply slots; the caller waits with a deadline, +// and one request is outstanding at a time. Free of rpc_calls.h and FreeRTOS, so it can be tested on the host. #ifndef WIFI_DEDICATED_H_ #define WIFI_DEDICATED_H_ @@ -8,23 +9,33 @@ // What wifi_dedicated_call returns itself. Anything else comes from take. // Callers keep their own numbers for these, and assert that they match. -#define DEDICATED_BUSY 1 // no answer in time, or not sent (channel taken, no buffer); retry +#define DEDICATED_BUSY 1 // sent, but no answer in time; the module may still act on it #define DEDICATED_NO_MODULE 4 // the module application is not running; nothing was sent #define DEDICATED_FOREIGN 5 // from take only: not the answer to this request +#define DEDICATED_UNSENT 6 // another request was outstanding, or no buffer; nothing was sent typedef struct { const char *name; // for the log uint8_t command; // CMD_* uint32_t timeout_ms; // for the answer, from the moment the request is queued - // Writes the arguments after the header and returns the request's size. - // It may not fail, so the caller checks the arguments first. + // Writes the request's arguments after its header, which is filled in + // already, and returns the size of the whole request. It may not fail, + // so the caller checks the arguments first. int (*fill)(uint8_t *request, void *context); - // Takes what it needs from the answer to request sequence, or returns - // DEDICATED_FOREIGN. Runs with the scheduler suspended: no blocking, no printing. + // Checks the size bytes at reply as the answer to request sequence and takes what it needs; returns + // DEDICATED_FOREIGN for a reply that is not the answer, which is skipped. Runs with the scheduler suspended, + // so it may neither block nor print. int (*take)(const uint8_t *reply, int size, uint16_t sequence, void *context); void *context; + // Optional: the wait is cut into slices of at most DEDICATED_SLICE_MS and cancel is asked after each one that + // brought no answer; true ends the call with DEDICATED_BUSY, and a later answer is dropped by its sequence + // number. NULL waits the whole timeout in one go. + bool (*cancel)(void *cancel_context); + void *cancel_context; } dedicated_call_t; +#define DEDICATED_SLICE_MS 100 + // Sends one request and waits for its answer. U64 == 1 and U64 == 2 (the Ultimate 64 Elite II and the C64 Ultimate) only. int wifi_dedicated_call(const dedicated_call_t *call); diff --git a/software/io/wifi/wifi_tls.cc b/software/io/wifi/wifi_tls.cc new file mode 100644 index 000000000..9faf9b27d --- /dev/null +++ b/software/io/wifi/wifi_tls.cc @@ -0,0 +1,559 @@ +// wifi_tls.cc: the TLS calls to the WiFi module, what goes into each request and what is taken from each answer. +// The waiting is wifi_dedicated_call's. Free of FreeRTOS calls, so that the checks can be tested on the host. + +#include +#include +#include "rpc_calls.h" // the module's own definitions of the TLS requests and answers +extern "C" { + #include "cmd_buffer.h" +} +#include "wifi_dedicated.h" +#include "wifi_tls.h" + +// The wire layouts of rpc_calls.h, byte for byte. +static_assert(sizeof(rpc_header_t) == 4, "rpc_header_t"); +static_assert(sizeof(rpc_espcmd_resp) == 8, "rpc_espcmd_resp"); +static_assert(offsetof(rpc_tls_open_req, trust) == 4, "open.trust"); +static_assert(offsetof(rpc_tls_open_req, sni_len) == 5, "open.sni_len"); +static_assert(offsetof(rpc_tls_open_req, slot) == 6, "open.slot"); +static_assert(offsetof(rpc_tls_open_req, time_source) == 7, "open.time_source"); +static_assert(offsetof(rpc_tls_open_req, unix_time) == 8, "open.unix_time"); +static_assert(offsetof(rpc_tls_open_req, tag) == 12, "open.tag"); +static_assert(offsetof(rpc_tls_open_req, opts) == 14, "open.opts"); +static_assert(offsetof(rpc_tls_open_req, reserved) == 15, "open.reserved"); +static_assert(offsetof(rpc_tls_open_req, ca_tag) == 16, "open.ca_tag"); +static_assert(offsetof(rpc_tls_open_req, reserved2) == 18, "open.reserved2"); +static_assert(offsetof(rpc_tls_open_req, pin) == 20, "open.pin"); +static_assert(offsetof(rpc_tls_open_req, sni) == 52, "open.sni"); +static_assert(sizeof(rpc_tls_open_req) == 52, "open size"); +static_assert(offsetof(rpc_tls_open_resp, esp_err) == 4, "open resp.esp_err"); +static_assert(offsetof(rpc_tls_open_resp, slot) == 8, "open resp.slot"); +static_assert(offsetof(rpc_tls_open_resp, reason) == 9, "open resp.reason"); +static_assert(offsetof(rpc_tls_open_resp, reserved) == 10, "open resp.reserved"); +static_assert(sizeof(rpc_tls_open_resp) == 12, "open resp size"); +static_assert(offsetof(rpc_tls_step_req, slot) == 4, "step.slot"); +static_assert(offsetof(rpc_tls_step_req, flags) == 5, "step.flags"); +static_assert(offsetof(rpc_tls_step_req, tag) == 6, "step.tag"); +static_assert(offsetof(rpc_tls_step_req, ct_in_len) == 8, "step.ct_in_len"); +static_assert(offsetof(rpc_tls_step_req, pt_in_len) == 10, "step.pt_in_len"); +static_assert(offsetof(rpc_tls_step_req, data) == 12, "step.data"); +static_assert(sizeof(rpc_tls_step_req) == 12, "step size"); +static_assert(offsetof(rpc_tls_step_resp, esp_err) == 4, "step resp.esp_err"); +static_assert(offsetof(rpc_tls_step_resp, state) == 8, "step resp.state"); +static_assert(offsetof(rpc_tls_step_resp, alert_in) == 9, "step resp.alert_in"); +static_assert(offsetof(rpc_tls_step_resp, ct_out_len) == 10, "step resp.ct_out_len"); +static_assert(offsetof(rpc_tls_step_resp, pt_out_len) == 12, "step resp.pt_out_len"); +static_assert(offsetof(rpc_tls_step_resp, alert_out) == 14, "step resp.alert_out"); +static_assert(offsetof(rpc_tls_step_resp, fail_reason) == 15, "step resp.fail_reason"); +static_assert(offsetof(rpc_tls_step_resp, verify_flags) == 16, "step resp.verify_flags"); +static_assert(offsetof(rpc_tls_step_resp, data) == 20, "step resp.data"); +static_assert(sizeof(rpc_tls_step_resp) == 20, "step resp size"); +static_assert(offsetof(rpc_tls_session_req, slot) == 4, "session.slot"); +static_assert(offsetof(rpc_tls_session_req, reserved) == 5, "session.reserved"); +static_assert(offsetof(rpc_tls_session_req, tag) == 6, "session.tag"); +static_assert(sizeof(rpc_tls_session_req) == 8, "session size"); +static_assert(offsetof(rpc_tls_close_resp, esp_err) == 4, "close resp.esp_err"); +static_assert(offsetof(rpc_tls_close_resp, ct_out_len) == 8, "close resp.ct_out_len"); +static_assert(offsetof(rpc_tls_close_resp, reserved) == 10, "close resp.reserved"); +static_assert(offsetof(rpc_tls_close_resp, data) == 12, "close resp.data"); +static_assert(sizeof(rpc_tls_close_resp) == 12, "close resp size"); +static_assert(offsetof(rpc_tls_stats_resp, esp_err) == 4, "stats.esp_err"); +static_assert(offsetof(rpc_tls_stats_resp, handshake_us) == 36, "stats.handshake_us"); +static_assert(offsetof(rpc_tls_stats_resp, tls_version) == 40, "stats.tls_version"); +static_assert(offsetof(rpc_tls_stats_resp, ciphersuite) == 42, "stats.ciphersuite"); +static_assert(offsetof(rpc_tls_stats_resp, group) == 44, "stats.group"); +static_assert(offsetof(rpc_tls_stats_resp, state) == 46, "stats.state"); +static_assert(offsetof(rpc_tls_stats_resp, sessions_open) == 47, "stats.sessions_open"); +static_assert(offsetof(rpc_tls_stats_resp, stack_free) == 48, "stats.stack_free"); +static_assert(offsetof(rpc_tls_stats_resp, esp_time) == 52, "stats.esp_time"); +static_assert(offsetof(rpc_tls_stats_resp, time_source) == 56, "stats.time_source"); +static_assert(offsetof(rpc_tls_stats_resp, entropy_source) == 57, "stats.entropy_source"); +static_assert(offsetof(rpc_tls_stats_resp, ems) == 58, "stats.ems"); +static_assert(offsetof(rpc_tls_stats_resp, reserved) == 59, "stats.reserved"); +static_assert(offsetof(rpc_tls_stats_resp, block_max_ms) == 60, "stats.block_max_ms"); +static_assert(offsetof(rpc_tls_stats_resp, reserved2) == 62, "stats.reserved2"); +static_assert(offsetof(rpc_tls_stats_resp, spki_sha256) == 64, "stats.spki_sha256"); +static_assert(sizeof(rpc_tls_stats_resp) == 96, "stats size"); +static_assert(offsetof(rpc_tls_set_ca_req, der_len) == 4, "set_ca.der_len"); +static_assert(offsetof(rpc_tls_set_ca_req, ca_tag) == 6, "set_ca.ca_tag"); +static_assert(offsetof(rpc_tls_set_ca_req, der) == 8, "set_ca.der"); +static_assert(sizeof(rpc_tls_set_ca_req) == 8, "set_ca size"); +static_assert(offsetof(rpc_tls_set_ca_resp, esp_err) == 4, "set_ca resp.esp_err"); +static_assert(offsetof(rpc_tls_set_ca_resp, reject) == 8, "set_ca resp.reject"); +static_assert(sizeof(rpc_tls_set_ca_resp) == 12, "set_ca resp size"); + +// A full step, either way, fits one buffer, and so do the longest OPEN and SET_CA. +static_assert(sizeof(rpc_tls_open_req) + TLS_SNI_MAX_LEN <= CMD_BUF_SIZE, "largest CMD_TLS_OPEN request"); +static_assert(sizeof(rpc_tls_step_req) + TLS_STEP_IN_MAX <= CMD_BUF_SIZE, "largest CMD_TLS_STEP request"); +static_assert(sizeof(rpc_tls_step_resp) + TLS_STEP_OUT_MAX <= CMD_BUF_SIZE, "largest CMD_TLS_STEP reply"); +static_assert(sizeof(rpc_tls_set_ca_req) + TLS_CA_MAX_LEN <= CMD_BUF_SIZE, "largest CMD_TLS_SET_CA request"); + +// What wifi_tls.h repeats. +static_assert(WIFI_TLS_MAX_SESSIONS == TLS_MAX_SESSIONS, "session caps differ"); +static_assert(WIFI_TLS_MAX_SNI == TLS_SNI_MAX_LEN, "name lengths differ"); +static_assert(WIFI_TLS_STEP_MAX_IN == TLS_STEP_IN_MAX, "step sizes differ"); +static_assert(WIFI_TLS_STEP_MAX_OUT == TLS_STEP_OUT_MAX, "step sizes differ"); +static_assert(WIFI_TLS_CA_MAX == TLS_CA_MAX_LEN, "CA sizes differ"); +static_assert(WIFI_TLS_PIN_LEN == TLS_PIN_LEN, "pin lengths differ"); +static_assert(WIFI_TLS_SLOT_GLOBAL == TLS_SLOT_GLOBAL, "slots differ"); +static_assert(WIFI_TLS_TRUST_BUNDLE == TLS_TRUST_BUNDLE, "trust modes differ"); +static_assert(WIFI_TLS_TRUST_CUSTOM == TLS_TRUST_CUSTOM, "trust modes differ"); +static_assert(WIFI_TLS_TRUST_PIN == TLS_TRUST_PIN, "trust modes differ"); +static_assert(WIFI_TLS_OPT_REQUIRE_TLS13 == TLS_OPT_REQUIRE_TLS13, "options differ"); +static_assert(WIFI_TLS_STEP_NO_READ == TLS_STEP_NO_READ, "step flags differ"); +static_assert(WIFI_TLS_REASON_NO_ENTROPY == TLS_OPEN_REASON_NO_ENTROPY, "reasons differ"); +static_assert(WIFI_TLS_REASON_NO_TIME == TLS_OPEN_REASON_NO_TIME, "reasons differ"); +static_assert(WIFI_TLS_REASON_NO_CUSTOM_CA == TLS_OPEN_REASON_NO_CUSTOM_CA, "reasons differ"); +static_assert(WIFI_TLS_TIME_NONE == TLS_TIME_NONE, "time sources differ"); +static_assert(WIFI_TLS_TIME_NIOS == TLS_TIME_NIOS, "time sources differ"); +static_assert(WIFI_TLS_FAIL_VERSION_REFUSED == TLS_FAIL_VERSION_REFUSED, "fail reasons differ"); +static_assert(WIFI_TLS_FAIL_DOWNGRADE == TLS_FAIL_DOWNGRADE, "fail reasons differ"); +static_assert(WIFI_TLS_FAIL_NO_EMS == TLS_FAIL_NO_EMS, "fail reasons differ"); +static_assert(WIFI_TLS_FAIL_CERT_VERIFY == TLS_FAIL_CERT_VERIFY, "fail reasons differ"); +static_assert(WIFI_TLS_FAIL_PIN_MISMATCH == TLS_FAIL_PIN_MISMATCH, "fail reasons differ"); +static_assert(WIFI_TLS_FAIL_PEER_CLOSED == TLS_FAIL_PEER_CLOSED, "fail reasons differ"); +static_assert(WIFI_TLS_ALERT_NONE == TLS_ALERT_NONE, "alerts differ"); +static_assert(WIFI_TLS_REJECT_RSA_KEY_SHORT == TLS_CA_REJECT_RSA_KEY_SHORT, "rejects differ"); +static_assert(WIFI_TLS_REJECT_CURVE == TLS_CA_REJECT_CURVE, "rejects differ"); +static_assert(WIFI_TLS_REJECT_NOT_CA == TLS_CA_REJECT_NOT_CA, "rejects differ"); +static_assert(WIFI_TLS_HANDSHAKING == TLS_STATE_HANDSHAKING, "states differ"); +static_assert(WIFI_TLS_ESTABLISHED == TLS_STATE_ESTABLISHED, "states differ"); +static_assert(WIFI_TLS_CLOSED == TLS_STATE_CLOSED, "states differ"); +static_assert(WIFI_TLS_FAILED == TLS_STATE_FAILED, "states differ"); +static_assert(WIFI_TLS_BUSY == DEDICATED_BUSY, "codes differ"); +static_assert(WIFI_TLS_NO_MODULE == DEDICATED_NO_MODULE, "codes differ"); +static_assert(WIFI_TLS_FOREIGN == DEDICATED_FOREIGN, "codes differ"); +static_assert(WIFI_TLS_UNSENT == DEDICATED_UNSENT, "codes differ"); + +static bool is_answer(const uint8_t *reply, int size, uint8_t command, uint16_t sequence) +{ + const rpc_header_t *hdr = (const rpc_header_t *)reply; + return (size >= (int)sizeof(rpc_header_t)) && (hdr->command == command) && (hdr->sequence == sequence); +} + +// A bare rpc_espcmd_resp with an error: how the module refuses a command it +// does not know (ESP_ERR_NOT_SUPPORTED), or one it cannot start. +static bool bare_refusal(const uint8_t *reply, int size, int *esp_err) +{ + const rpc_espcmd_resp *result = (const rpc_espcmd_resp *)reply; + if ((size == (int)sizeof(rpc_espcmd_resp)) && (result->esp_err != 0)) { + *esp_err = result->esp_err; + return true; + } + return false; +} + +int wifi_tls_take_open(const uint8_t *reply, int size, uint16_t sequence, uint8_t slot, int *esp_err, + uint8_t *reason) +{ + const rpc_tls_open_resp *result = (const rpc_tls_open_resp *)reply; + if (!is_answer(reply, size, CMD_TLS_OPEN, sequence)) { + return WIFI_TLS_FOREIGN; + } + if (bare_refusal(reply, size, esp_err)) { + return WIFI_TLS_REFUSED; + } + if (size != (int)sizeof(rpc_tls_open_resp)) { + return WIFI_TLS_INVALID; + } + if (result->esp_err != 0) { + *esp_err = result->esp_err; + *reason = result->reason; + return WIFI_TLS_REFUSED; + } + // The module answers with the slot it opened (0xFF on a refusal). + if (result->slot != slot) { + return WIFI_TLS_INVALID; + } + return 0; +} + +int wifi_tls_take_step(const uint8_t *reply, int size, uint16_t sequence, wifi_tls_step_t *step) +{ + const rpc_tls_step_resp *result = (const rpc_tls_step_resp *)reply; + const int header = offsetof(rpc_tls_step_resp, data); + if (!is_answer(reply, size, CMD_TLS_STEP, sequence)) { + return WIFI_TLS_FOREIGN; + } + if (bare_refusal(reply, size, &step->esp_err)) { + return WIFI_TLS_REFUSED; + } + // Exactly the header and the bytes it counts, no more and no less. + if ((size < header) || (size != header + result->ct_out_len + result->pt_out_len)) { + return WIFI_TLS_INVALID; + } + bool has_state = result->state <= TLS_STATE_FAILED; + bool failed = has_state && (result->state == TLS_STATE_FAILED); + // Input refused for want of room, output all the same; in a live session the input goes again. Once the peer + // has closed the refusal no longer matters: the output, last plaintext included, is taken and CLOSED reported. + bool no_mem = has_state && (result->esp_err == WIFI_TLS_ESP_NO_MEM); + bool again = no_mem && ((result->state == TLS_STATE_HANDSHAKING) || (result->state == TLS_STATE_ESTABLISHED)); + bool closed = no_mem && (result->state == TLS_STATE_CLOSED); + if ((result->esp_err != 0) && !failed && !again && !closed) { + step->esp_err = result->esp_err; + if (has_state) { + step->state = result->state; + } + return WIFI_TLS_REFUSED; + } + if (!has_state) { + return WIFI_TLS_INVALID; + } + // The reasons come with FAILED only. + if (!failed && (result->fail_reason != TLS_FAIL_NONE)) { + return WIFI_TLS_INVALID; + } + uint16_t ct = result->ct_out_len; + uint16_t pt = result->pt_out_len; + if ((ct > step->ct_out_room) || (pt > step->pt_out_room)) { + return WIFI_TLS_INVALID; + } + // A step that was told not to read cannot have read anything. + if ((step->flags & WIFI_TLS_STEP_NO_READ) && (pt != 0)) { + return WIFI_TLS_INVALID; + } + // Plaintext only from a session that has finished its handshake. Records + // read before a failure were authentic, but they end a session that failed, + // and are withheld. + if (failed) { + pt = 0; + } else if ((pt != 0) && (result->state != TLS_STATE_ESTABLISHED) && (result->state != TLS_STATE_CLOSED)) { + return WIFI_TLS_INVALID; + } + memcpy(step->ct_out, result->data, ct); + memcpy(step->pt_out, result->data + ct, pt); + step->ct_out_len = ct; + step->pt_out_len = pt; + step->state = result->state; + step->esp_err = result->esp_err; + step->alert_in = result->alert_in; + step->alert_out = result->alert_out; + step->fail_reason = result->fail_reason; + step->verify_flags = result->verify_flags; + return again ? WIFI_TLS_AGAIN : 0; +} + +int wifi_tls_take_close(const uint8_t *reply, int size, uint16_t sequence, uint8_t *ct_out, uint16_t room, + uint16_t *ct_out_len, int *esp_err) +{ + const rpc_tls_close_resp *result = (const rpc_tls_close_resp *)reply; + const int header = offsetof(rpc_tls_close_resp, data); + if (!is_answer(reply, size, CMD_TLS_CLOSE, sequence)) { + return WIFI_TLS_FOREIGN; + } + if (bare_refusal(reply, size, esp_err)) { + return WIFI_TLS_REFUSED; + } + if ((size < header) || (size != header + result->ct_out_len)) { + return WIFI_TLS_INVALID; + } + if (result->esp_err != 0) { + *esp_err = result->esp_err; + return WIFI_TLS_REFUSED; + } + if (result->ct_out_len > room) { + return WIFI_TLS_INVALID; + } + memcpy(ct_out, result->data, result->ct_out_len); + *ct_out_len = result->ct_out_len; + return 0; +} + +int wifi_tls_take_stats(const uint8_t *reply, int size, uint16_t sequence, wifi_tls_stats_t *stats, int *esp_err) +{ + const rpc_tls_stats_resp *result = (const rpc_tls_stats_resp *)reply; + if (!is_answer(reply, size, CMD_TLS_STATS, sequence)) { + return WIFI_TLS_FOREIGN; + } + if (bare_refusal(reply, size, esp_err)) { + return WIFI_TLS_REFUSED; + } + if (size != (int)sizeof(rpc_tls_stats_resp)) { + return WIFI_TLS_INVALID; + } + if (result->esp_err != 0) { + *esp_err = result->esp_err; + return WIFI_TLS_REFUSED; + } + stats->heap_free = result->heap_free; + stats->heap_min_ever = result->heap_min; + stats->largest_block = result->largest_block; + stats->ct_in_bytes = result->ct_in_bytes; + stats->ct_out_bytes = result->ct_out_bytes; + stats->pt_in_bytes = result->pt_in_bytes; + stats->pt_out_bytes = result->pt_out_bytes; + stats->handshake_us = result->handshake_us; + stats->tls_version = result->tls_version; + stats->ciphersuite = result->ciphersuite; + stats->group = result->group; + stats->state = result->state; + stats->sessions_open = result->sessions_open; + stats->stack_free = result->stack_free; + stats->esp_time = result->esp_time; + stats->time_source = result->time_source; + stats->entropy_source = result->entropy_source; + stats->ems = result->ems; + stats->block_max_ms = result->block_max_ms; + memcpy(stats->spki_sha256, result->spki_sha256, sizeof(stats->spki_sha256)); + return 0; +} + +int wifi_tls_take_close_all(const uint8_t *reply, int size, uint16_t sequence, int *esp_err) +{ + const rpc_espcmd_resp *result = (const rpc_espcmd_resp *)reply; + if (!is_answer(reply, size, CMD_TLS_CLOSE_ALL, sequence)) { + return WIFI_TLS_FOREIGN; + } + if (size != (int)sizeof(rpc_espcmd_resp)) { + return WIFI_TLS_INVALID; + } + if (result->esp_err != 0) { + *esp_err = result->esp_err; + return WIFI_TLS_REFUSED; + } + return 0; +} + +// Three answers are well formed: loaded (0, no reject), a parse error (an mbedTLS or PSA code, never ESP_FAIL, no +// reject) and a refusal of a certificate that parsed (ESP_ERR_INVALID_ARG with reject 1, 3 or 4). Nothing else is. +int wifi_tls_take_set_ca(const uint8_t *reply, int size, uint16_t sequence, int *esp_err, uint8_t *reject) +{ + const rpc_tls_set_ca_resp *result = (const rpc_tls_set_ca_resp *)reply; + if (!is_answer(reply, size, CMD_TLS_SET_CA, sequence)) { + return WIFI_TLS_FOREIGN; + } + if (bare_refusal(reply, size, esp_err)) { + return WIFI_TLS_REFUSED; + } + if (size != (int)sizeof(rpc_tls_set_ca_resp)) { + return WIFI_TLS_INVALID; + } + int err = result->esp_err; + uint8_t why = result->reject; + if ((err == 0) && (why == TLS_CA_REJECT_NONE)) { + return 0; + } + bool parse_error = (err <= -2) && (why == TLS_CA_REJECT_NONE); + bool refused = (err == WIFI_TLS_ESP_INVALID_ARG) && + ((why == TLS_CA_REJECT_RSA_KEY_SHORT) || (why == TLS_CA_REJECT_CURVE) || + (why == TLS_CA_REJECT_NOT_CA)); + if (!parse_error && !refused) { + return WIFI_TLS_INVALID; + } + *esp_err = err; + *reject = why; + return WIFI_TLS_REFUSED; +} + +typedef struct { + const wifi_tls_open_t *open; + int *esp_err; + uint8_t *reason; +} open_call_t; + +static int fill_open(uint8_t *request, void *context) +{ + const wifi_tls_open_t *o = ((open_call_t *)context)->open; + rpc_tls_open_req *args = (rpc_tls_open_req *)request; + args->trust = o->trust; + args->sni_len = o->sni_len; + args->slot = o->slot; + args->time_source = o->time_source; + args->unix_time = o->unix_time; + args->tag = o->tag; + args->opts = o->opts; + args->reserved = 0; + args->ca_tag = o->ca_tag; + args->reserved2 = 0; + if (o->pin) { + memcpy(args->pin, o->pin, TLS_PIN_LEN); + } else { + memset(args->pin, 0, TLS_PIN_LEN); + } + if (o->sni_len) { + memcpy(args->sni, o->sni, o->sni_len); + } + return offsetof(rpc_tls_open_req, sni) + o->sni_len; +} + +static int take_open(const uint8_t *reply, int size, uint16_t sequence, void *context) +{ + open_call_t *c = (open_call_t *)context; + return wifi_tls_take_open(reply, size, sequence, c->open->slot, c->esp_err, c->reason); +} + +static void set_cancel(dedicated_call_t *call, const wifi_tls_cancel_t *cancel) +{ + call->cancel = cancel ? cancel->cancelled : NULL; + call->cancel_context = cancel ? cancel->context : NULL; +} + +int wifi_tls_open(const wifi_tls_open_t *open, uint32_t timeout_ms, const wifi_tls_cancel_t *cancel, int *esp_err, + uint8_t *reason) +{ + *esp_err = 0; + *reason = 0; + if ((open->sni_len > WIFI_TLS_MAX_SNI) || (open->sni_len && !open->sni)) { + return WIFI_TLS_TOO_LONG; + } + open_call_t args = { open, esp_err, reason }; + dedicated_call_t call = { "TLS Open", CMD_TLS_OPEN, timeout_ms, fill_open, take_open, &args, NULL, NULL }; + set_cancel(&call, cancel); + return wifi_dedicated_call(&call); +} + +typedef struct { + uint8_t slot; + uint16_t tag; + wifi_tls_step_t *step; +} step_call_t; + +static int fill_step(uint8_t *request, void *context) +{ + step_call_t *c = (step_call_t *)context; + wifi_tls_step_t *step = c->step; + rpc_tls_step_req *args = (rpc_tls_step_req *)request; + args->slot = c->slot; + args->flags = step->flags; + args->tag = c->tag; + args->ct_in_len = step->ct_in_len; + args->pt_in_len = step->pt_in_len; + memcpy(args->data, step->ct_in, step->ct_in_len); + memcpy(args->data + step->ct_in_len, step->pt_in, step->pt_in_len); + return offsetof(rpc_tls_step_req, data) + step->ct_in_len + step->pt_in_len; +} + +static int take_step(const uint8_t *reply, int size, uint16_t sequence, void *context) +{ + return wifi_tls_take_step(reply, size, sequence, ((step_call_t *)context)->step); +} + +int wifi_tls_step(uint8_t slot, uint16_t tag, wifi_tls_step_t *step, uint32_t timeout_ms, + const wifi_tls_cancel_t *cancel) +{ + step->ct_out_len = 0; + step->pt_out_len = 0; + step->state = WIFI_TLS_UNKNOWN; + step->esp_err = 0; + step->alert_in = WIFI_TLS_ALERT_NONE; + step->alert_out = WIFI_TLS_ALERT_NONE; + step->fail_reason = WIFI_TLS_FAIL_NONE; + step->verify_flags = 0; + if ((int)step->ct_in_len + step->pt_in_len > WIFI_TLS_STEP_MAX_IN) { + return WIFI_TLS_TOO_LONG; + } + step_call_t args = { slot, tag, step }; + dedicated_call_t call = { "TLS Step", CMD_TLS_STEP, timeout_ms, fill_step, take_step, &args, NULL, NULL }; + set_cancel(&call, cancel); + return wifi_dedicated_call(&call); +} + +typedef struct { + uint8_t slot; + uint16_t tag; + wifi_tls_stats_t *stats; + uint8_t *ct_out; + uint16_t room; + uint16_t *ct_out_len; + int *esp_err; +} session_call_t; + +// CLOSE and STATS carry the same argument. +static int fill_session(uint8_t *request, void *context) +{ + session_call_t *c = (session_call_t *)context; + rpc_tls_session_req *args = (rpc_tls_session_req *)request; + args->slot = c->slot; + args->reserved = 0; + args->tag = c->tag; + return sizeof(rpc_tls_session_req); +} + +static int take_close(const uint8_t *reply, int size, uint16_t sequence, void *context) +{ + session_call_t *c = (session_call_t *)context; + return wifi_tls_take_close(reply, size, sequence, c->ct_out, c->room, c->ct_out_len, c->esp_err); +} + +int wifi_tls_close(uint8_t slot, uint16_t tag, uint8_t *ct_out, uint16_t room, uint16_t *ct_out_len, int *esp_err, + uint32_t timeout_ms, const wifi_tls_cancel_t *cancel) +{ + *esp_err = 0; + *ct_out_len = 0; + session_call_t args = { slot, tag, NULL, ct_out, room, ct_out_len, esp_err }; + dedicated_call_t call = { "TLS Close", CMD_TLS_CLOSE, timeout_ms, fill_session, take_close, &args, NULL, NULL }; + set_cancel(&call, cancel); + return wifi_dedicated_call(&call); +} + +static int take_stats(const uint8_t *reply, int size, uint16_t sequence, void *context) +{ + session_call_t *c = (session_call_t *)context; + return wifi_tls_take_stats(reply, size, sequence, c->stats, c->esp_err); +} + +int wifi_tls_stats(uint8_t slot, uint16_t tag, wifi_tls_stats_t *stats, int *esp_err, uint32_t timeout_ms, + const wifi_tls_cancel_t *cancel) +{ + *esp_err = 0; + session_call_t args = { slot, tag, stats, NULL, 0, NULL, esp_err }; + dedicated_call_t call = { "TLS Stats", CMD_TLS_STATS, timeout_ms, fill_session, take_stats, &args, NULL, NULL }; + set_cancel(&call, cancel); + return wifi_dedicated_call(&call); +} + +static int fill_close_all(uint8_t *request, void *context) +{ + return sizeof(rpc_header_t); +} + +static int take_close_all(const uint8_t *reply, int size, uint16_t sequence, void *context) +{ + return wifi_tls_take_close_all(reply, size, sequence, (int *)context); +} + +int wifi_tls_close_all(int *esp_err, uint32_t timeout_ms) +{ + *esp_err = 0; + const dedicated_call_t call = { "TLS Close All", CMD_TLS_CLOSE_ALL, timeout_ms, fill_close_all, + take_close_all, esp_err, NULL, NULL }; + return wifi_dedicated_call(&call); +} + +typedef struct { + const uint8_t *der; + uint16_t der_len; + uint16_t ca_tag; + int *esp_err; + uint8_t *reject; +} set_ca_call_t; + +static int fill_set_ca(uint8_t *request, void *context) +{ + set_ca_call_t *c = (set_ca_call_t *)context; + rpc_tls_set_ca_req *args = (rpc_tls_set_ca_req *)request; + args->der_len = c->der_len; + args->ca_tag = c->ca_tag; + memcpy(args->der, c->der, c->der_len); + return offsetof(rpc_tls_set_ca_req, der) + c->der_len; +} + +static int take_set_ca(const uint8_t *reply, int size, uint16_t sequence, void *context) +{ + set_ca_call_t *c = (set_ca_call_t *)context; + return wifi_tls_take_set_ca(reply, size, sequence, c->esp_err, c->reject); +} + +int wifi_tls_set_ca(const uint8_t *der, uint16_t der_len, uint16_t ca_tag, int *esp_err, uint8_t *reject, + uint32_t timeout_ms, const wifi_tls_cancel_t *cancel) +{ + *esp_err = 0; + *reject = 0; + if (der_len > WIFI_TLS_CA_MAX) { + return WIFI_TLS_TOO_LONG; + } + set_ca_call_t args = { der, der_len, ca_tag, esp_err, reject }; + dedicated_call_t call = { "TLS Set CA", CMD_TLS_SET_CA, timeout_ms, fill_set_ca, take_set_ca, &args, NULL, NULL }; + set_cancel(&call, cancel); + return wifi_dedicated_call(&call); +} diff --git a/software/io/wifi/wifi_tls.h b/software/io/wifi/wifi_tls.h new file mode 100644 index 000000000..61e73da4b --- /dev/null +++ b/software/io/wifi/wifi_tls.h @@ -0,0 +1,179 @@ +// wifi_tls.h: TLS sessions run on the WiFi module (U64 only). It holds the keys and runs the protocol; this side moves +// the ciphertext between a socket and the module, one step at a time, and the module never speaks unasked. Apart +// from wifi_cmd.h; wifi_tls.cc asserts the values repeated here match rpc_calls.h's layout. + +#ifndef WIFI_TLS_H_ +#define WIFI_TLS_H_ + +#include + +#define WIFI_TLS_MAX_SESSIONS 2 // the module's cap +#define WIFI_TLS_MAX_SNI 253 +#define WIFI_TLS_STEP_MAX_IN 1536 // ct_in_len + pt_in_len in one step +#define WIFI_TLS_STEP_MAX_OUT 1024 // ct_out_len + pt_out_len in one step +#define WIFI_TLS_CA_MAX 1472 // one DER certificate for SET_CA +#define WIFI_TLS_PIN_LEN 32 +#define WIFI_TLS_SLOT_GLOBAL 0xFF // for wifi_tls_stats: the module as a whole, with tag 0 + +#define WIFI_TLS_TRUST_BUNDLE 0 +#define WIFI_TLS_TRUST_CUSTOM 1 +#define WIFI_TLS_TRUST_PIN 2 + +#define WIFI_TLS_OPT_REQUIRE_TLS13 0x01 // offer TLS 1.3 only +#define WIFI_TLS_STEP_NO_READ 0x01 // the module takes no plaintext out of the session in this step + +// Why an OPEN was refused. +#define WIFI_TLS_REASON_NO_ENTROPY 1 // the radio has not started, so there is no seed +#define WIFI_TLS_REASON_NO_TIME 2 // BUNDLE or CUSTOM, and neither side has a trustworthy clock +#define WIFI_TLS_REASON_NO_CUSTOM_CA 3 // CUSTOM, and the module holds no CA under the given ca_tag + +// Where the time in an OPEN came from. +#define WIFI_TLS_TIME_NONE 0 +#define WIFI_TLS_TIME_NIOS 1 // SNTP on this side + +#define WIFI_TLS_HANDSHAKING 0 +#define WIFI_TLS_ESTABLISHED 1 +#define WIFI_TLS_CLOSED 2 +#define WIFI_TLS_FAILED 3 // esp_err holds the mbedTLS error, fail_reason says more +#define WIFI_TLS_UNKNOWN 0xFF // the answer did not say + +// Why a step FAILED, besides esp_err. +#define WIFI_TLS_FAIL_NONE 0 // generic: esp_err has the mbedTLS code, alert_in any alert +#define WIFI_TLS_FAIL_VERSION_REFUSED 1 // the version chosen is in verify_flags' low 16 bits +#define WIFI_TLS_FAIL_DOWNGRADE 2 +#define WIFI_TLS_FAIL_NO_EMS 3 +#define WIFI_TLS_FAIL_CERT_VERIFY 4 // verify_flags is the final verify result +#define WIFI_TLS_FAIL_PIN_MISMATCH 5 +#define WIFI_TLS_FAIL_PEER_CLOSED 6 + +#define WIFI_TLS_ALERT_NONE 0xFF + +// Why SET_CA refused a certificate that parsed. +#define WIFI_TLS_REJECT_NONE 0 +#define WIFI_TLS_REJECT_RSA_KEY_SHORT 1 +#define WIFI_TLS_REJECT_CURVE 3 +#define WIFI_TLS_REJECT_NOT_CA 4 + +// esp_err values the callers tell apart (esp_err.h). +#define WIFI_TLS_ESP_FAIL (-1) +#define WIFI_TLS_ESP_NO_MEM 0x101 +#define WIFI_TLS_ESP_INVALID_ARG 0x102 +#define WIFI_TLS_ESP_INVALID_STATE 0x103 +#define WIFI_TLS_ESP_NOT_FOUND 0x105 +#define WIFI_TLS_ESP_NOT_SUPPORTED 0x106 + +// What the calls below return besides 0. +#define WIFI_TLS_BUSY 1 // sent, but no answer in time, or cancelled; the module may still act on it +#define WIFI_TLS_REFUSED 2 // the module answered with an error, which is in esp_err +#define WIFI_TLS_INVALID 3 // the answer is not a well formed reply +#define WIFI_TLS_NO_MODULE 4 // the module application is not running; nothing was sent +#define WIFI_TLS_FOREIGN 5 // (from the checks only) not the answer to this request +#define WIFI_TLS_UNSENT 6 // another request was outstanding, or no buffer; nothing was sent +#define WIFI_TLS_TOO_LONG 7 // the request does not fit; nothing was sent +#define WIFI_TLS_AGAIN 8 // STEP only: the module had no room and did not take the input, but its + // output is handed over as for 0; send the same input again + +// Polled between the slices of a wait; true ends the wait with BUSY. NULL +// for no cancelling. +typedef struct { + bool (*cancelled)(void *context); + void *context; +} wifi_tls_cancel_t; + +typedef struct { + uint8_t trust; // WIFI_TLS_TRUST_* + uint8_t slot; // 0 .. WIFI_TLS_MAX_SESSIONS - 1 + uint16_t tag; // never 0; names the session together with slot + uint8_t opts; // WIFI_TLS_OPT_* + uint8_t time_source; // WIFI_TLS_TIME_* + uint32_t unix_time; // UTC seconds, 0 without a time source + uint16_t ca_tag; // CUSTOM: the CA the module must hold; 0 otherwise + const uint8_t *pin; // PIN: WIFI_TLS_PIN_LEN bytes; NULL otherwise (sent as zeros) + const char *sni; // the server name, or NULL for none + uint8_t sni_len; +} wifi_tls_open_t; + +typedef struct { + uint32_t heap_free; + uint32_t heap_min_ever; + uint32_t largest_block; + uint32_t ct_in_bytes; // the session's counters; 0 for the module as a whole + uint32_t ct_out_bytes; + uint32_t pt_in_bytes; + uint32_t pt_out_bytes; + uint32_t handshake_us; + uint16_t tls_version; // as on the wire: 0x0304 is TLS 1.3 + uint16_t ciphersuite; // IANA number + uint16_t group; // IANA NamedGroup + uint8_t state; + uint8_t sessions_open; + uint32_t stack_free; + uint32_t esp_time; + uint8_t time_source; + uint8_t entropy_source; // 0: no live entropy source + uint8_t ems; // 1: extended master secret in use + uint16_t block_max_ms; // the longest the module's dispatcher was blocked since boot + uint8_t spki_sha256[32]; // of the leaf's SubjectPublicKeyInfo, digest order +} wifi_tls_stats_t; + +// One step; the module answers into the second block. Input is taken all or nothing: no room is AGAIN with the output +// handed over and the same input to resend (0 and CLOSED if the peer closed). FAILED is an answer (0, reasons set, +// session freed). Outputs only on 0/AGAIN; plaintext only from ESTABLISHED or just CLOSED; with NO_READ it is invalid. +typedef struct { + uint8_t flags; // WIFI_TLS_STEP_* + const uint8_t *ct_in; + uint16_t ct_in_len; + const uint8_t *pt_in; + uint16_t pt_in_len; + uint8_t *ct_out; + uint16_t ct_out_room; + uint8_t *pt_out; + uint16_t pt_out_room; + + uint16_t ct_out_len; + uint16_t pt_out_len; + uint8_t state; // WIFI_TLS_HANDSHAKING .. WIFI_TLS_FAILED, or WIFI_TLS_UNKNOWN + int esp_err; + uint8_t alert_in; // WIFI_TLS_ALERT_NONE when none + uint8_t alert_out; + uint8_t fail_reason; // WIFI_TLS_FAIL_* + uint32_t verify_flags; +} wifi_tls_step_t; + +// Each returns 0 or a code above after at most timeout_ms, or BUSY earlier when cancel says so. esp_err (where there +// is one), reason and reject are set to 0 first, then to what the module answered when it failed or refused. +int wifi_tls_open(const wifi_tls_open_t *open, uint32_t timeout_ms, const wifi_tls_cancel_t *cancel, int *esp_err, + uint8_t *reason); +int wifi_tls_step(uint8_t slot, uint16_t tag, wifi_tls_step_t *step, uint32_t timeout_ms, + const wifi_tls_cancel_t *cancel); +// ct_out receives the close_notify record, at most room bytes; *ct_out_len is 0 without one. +int wifi_tls_close(uint8_t slot, uint16_t tag, uint8_t *ct_out, uint16_t room, uint16_t *ct_out_len, int *esp_err, + uint32_t timeout_ms, const wifi_tls_cancel_t *cancel); +int wifi_tls_stats(uint8_t slot, uint16_t tag, wifi_tls_stats_t *stats, int *esp_err, uint32_t timeout_ms, + const wifi_tls_cancel_t *cancel); +int wifi_tls_close_all(int *esp_err, uint32_t timeout_ms); +int wifi_tls_set_ca(const uint8_t *der, uint16_t der_len, uint16_t ca_tag, int *esp_err, uint8_t *reject, + uint32_t timeout_ms, const wifi_tls_cancel_t *cancel); + +// The answer checks, apart for host tests. Exact sizes: OPEN 12, CLOSE 12 + record, STATS 96, CLOSE_ALL 8, SET_CA 12, +// STEP 20 + its bytes; a refusal may be a bare 8-byte rpc_espcmd_resp (no TLS: NOT_SUPPORTED). Each returns 0, +// WIFI_TLS_FOREIGN, REFUSED or INVALID (or AGAIN for a step). OPEN's answer must name the slot asked for. +int wifi_tls_take_open(const uint8_t *reply, int size, uint16_t sequence, uint8_t slot, int *esp_err, + uint8_t *reason); +int wifi_tls_take_step(const uint8_t *reply, int size, uint16_t sequence, wifi_tls_step_t *step); +int wifi_tls_take_close(const uint8_t *reply, int size, uint16_t sequence, uint8_t *ct_out, uint16_t room, + uint16_t *ct_out_len, int *esp_err); +int wifi_tls_take_stats(const uint8_t *reply, int size, uint16_t sequence, wifi_tls_stats_t *stats, int *esp_err); +int wifi_tls_take_close_all(const uint8_t *reply, int size, uint16_t sequence, int *esp_err); +int wifi_tls_take_set_ca(const uint8_t *reply, int size, uint16_t sequence, int *esp_err, uint8_t *reject); + +// The UART buffer generation, which changes when the module restarts: every +// session it held is then gone. In wifi_dedicated.cc. +uint32_t wifi_tls_generation(void); + +// Whether TLS calls can be sent at all (the module application runs and WiFi +// is not disabled), and the version the module reported. In wifi.cc. +bool wifi_tls_module_available(void); +void wifi_tls_module_version(uint16_t *major, uint16_t *minor); + +#endif /* WIFI_TLS_H_ */ diff --git a/software/network/sntp_time.cc b/software/network/sntp_time.cc index 51600aaa9..ebc84a1a7 100644 --- a/software/network/sntp_time.cc +++ b/software/network/sntp_time.cc @@ -4,6 +4,14 @@ #include #include "network_config.h" #include "rtc.h" +#include "FreeRTOS.h" +#include "task.h" +#include "itu.h" +#include "sntp_time.h" + +// The last time SNTP gave, UTC, and the tick it came at; 0 before the first. +static uint32_t sntp_seconds; +static TickType_t sntp_tick; extern "C" { #include "lwip/apps/sntp.h" @@ -11,10 +19,28 @@ extern "C" { void sntp_time_received(uint32_t sec) { printf("--> Time Received: %u (current TZ = %s)\n", sec, getenv("TZ")); + ENTER_SAFE_SECTION; + sntp_seconds = sec; + sntp_tick = xTaskGetTickCount(); + LEAVE_SAFE_SECTION; rtc.set_time_utc(sec); } } +uint32_t sntp_utc_now(void) +{ + uint32_t seconds; + TickType_t tick; + ENTER_SAFE_SECTION; + seconds = sntp_seconds; + tick = sntp_tick; + LEAVE_SAFE_SECTION; + if (!seconds) { + return 0; + } + return seconds + (xTaskGetTickCount() - tick) / configTICK_RATE_HZ; +} + void start_sntp(void) { sntp_stop(); diff --git a/software/network/sntp_time.h b/software/network/sntp_time.h index 8d4480dde..b517c2b88 100644 --- a/software/network/sntp_time.h +++ b/software/network/sntp_time.h @@ -1,6 +1,11 @@ #ifndef SNTP_TIME_H #define SNTP_TIME_H +#include + void start_sntp(); +// UTC seconds, counted on from the last time SNTP gave; 0 when it has not. +uint32_t sntp_utc_now(void); + #endif diff --git a/software/test/wifi_tls/check.h b/software/test/wifi_tls/check.h new file mode 100644 index 000000000..bca1b8d11 --- /dev/null +++ b/software/test/wifi_tls/check.h @@ -0,0 +1,8 @@ +#ifndef CHECK_H_ +#define CHECK_H_ +#include +extern int failures; +extern int checks; +// Counts one check and prints it: "ok" or "FAIL". +void check(bool condition, const char *what, ...); +#endif diff --git a/software/test/wifi_tls/ip4addr_aton.cc b/software/test/wifi_tls/ip4addr_aton.cc new file mode 100644 index 000000000..cd7f61cb3 --- /dev/null +++ b/software/test/wifi_tls/ip4addr_aton.cc @@ -0,0 +1,97 @@ +// lwIP's ip4addr_aton (software/lwip/src/core/ipv4/ip4_addr.c at 26a22151): network_target.cc decides what an IPv4 +// literal is with it, so the host tests need the same predicate (127.1, 0x7f.0.0.1 and "1.2.3.4 x" included). +// Copyright (c) 2001-2004 Swedish Institute of Computer Science. All rights reserved. (BSD; see software/lwip/COPYING.) +#include +#include +#include "lwip/dns.h" + +int ip4addr_aton(const char *cp, ip4_addr_t *addr) +{ + uint32_t val; + uint8_t base; + char c; + uint32_t parts[4]; + uint32_t *pp = parts; + + c = *cp; + for (;;) { + if (!isdigit((unsigned char)c)) { + return 0; + } + val = 0; + base = 10; + if (c == '0') { + c = *++cp; + if (c == 'x' || c == 'X') { + base = 16; + c = *++cp; + } else { + base = 8; + } + } + for (;;) { + if (isdigit((unsigned char)c)) { + if ((base == 8) && ((uint32_t)(c - '0') >= 8)) + break; + val = (val * base) + (uint32_t)(c - '0'); + c = *++cp; + } else if (base == 16 && isxdigit((unsigned char)c)) { + val = (val << 4) | (uint32_t)(c + 10 - (islower((unsigned char)c) ? 'a' : 'A')); + c = *++cp; + } else { + break; + } + } + if (c == '.') { + if (pp >= parts + 3) { + return 0; + } + *pp++ = val; + c = *++cp; + } else { + break; + } + } + if (c != '\0' && !isspace((unsigned char)c)) { + return 0; + } + switch (pp - parts + 1) { + case 0: + return 0; + case 1: + break; + case 2: + if (val > 0xffffffUL) { + return 0; + } + if (parts[0] > 0xff) { + return 0; + } + val |= parts[0] << 24; + break; + case 3: + if (val > 0xffff) { + return 0; + } + if ((parts[0] > 0xff) || (parts[1] > 0xff)) { + return 0; + } + val |= (parts[0] << 24) | (parts[1] << 16); + break; + case 4: + if (val > 0xff) { + return 0; + } + if ((parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff)) { + return 0; + } + val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); + break; + default: + break; + } + if (addr) { + addr->addr = htonl(val); + } + return 1; +} diff --git a/software/test/wifi_tls/net_tls_test.cc b/software/test/wifi_tls/net_tls_test.cc new file mode 100644 index 000000000..35ff1a7cf --- /dev/null +++ b/software/test/wifi_tls/net_tls_test.cc @@ -0,0 +1,1732 @@ +/* Host tests for the TLS commands ($21-$25, and READ/WRITE/CLOSE on a TLS handle) of the real + * network_target.cc in the world of net_world.cc. Run: make -C target/pc/linux/wifitls test + * Without the TLS commands every group is RED: the target answers 21,UNKNOWN COMMAND. */ +#include +#include +#include +#include +#include +#include +#include "net_world.h" +#include "network_target.h" +#include "check.h" + +int failures; +int checks; + +void check(bool condition, const char *what, ...) +{ + char line[400]; + va_list ap; + va_start(ap, what); + vsnprintf(line, sizeof(line), what, ap); + va_end(ap); + checks++; + if (!condition) { + failures++; + printf(" FAIL %s\n", line); + } else { + printf(" ok %s\n", line); + } +} + +extern NetworkTarget net; + +struct Res { + bytes data; + std::string status; +}; + +// One command as the C64 sends it, and every block of its reply as it reads them. +// The longest status any command of the run answered (the cap is 40 bytes). +static std::string longest_status; + +static Res run(const bytes &command) +{ + static uint8_t buf[1024]; + memcpy(buf, command.data(), command.size()); + Message m = { (int)command.size(), true, buf }; + Message *reply, *status; + net.parse_command(&m, &reply, &status); + Res r; + r.data.assign(reply->message, reply->message + reply->length); + r.status.assign((const char *)status->message, status->length); + if ((size_t)status->length > longest_status.size()) { + longest_status = r.status; + } + int guard = 0; + while (!reply->last_part && (guard++ < 10)) { + net.get_more_data(&reply, &status); + r.data.insert(r.data.end(), reply->message, reply->message + reply->length); + r.status.append((const char *)status->message, status->length); + } + return r; +} + +static bytes B(std::initializer_list v) +{ + bytes b; + for (int x : v) { + b.push_back((uint8_t)x); + } + return b; +} + +static bytes cat(bytes a, const bytes &b) +{ + a.insert(a.end(), b.begin(), b.end()); + return a; +} + +static bytes S(const std::string &s) +{ + return bytes(s.begin(), s.end()); +} + +static bytes PIN(uint8_t fill = 0x5A) +{ + return bytes(32, fill); +} + +static bytes open_cmd(uint8_t trust, uint8_t flags, const std::string &tail, const bytes &pin = bytes(), + uint16_t port = 443, uint8_t first = 0x03) +{ + bytes c = B({ first, 0x21, port & 0xFF, port >> 8, trust, flags }); + c = cat(c, pin); + return cat(c, S(tail)); +} + +static std::string num(int n) +{ + char t[16]; + snprintf(t, sizeof(t), "%d", n); + return t; +} + +// Byte i of a reply, or $EE past its end: a red run must not read beyond it. +static uint8_t at(const Res &r, size_t i) +{ + return (i < r.data.size()) ? r.data[i] : 0xEE; +} + +static uint8_t info_byte(size_t i); + +static uint16_t header(const Res &r) +{ + return (r.data.size() >= 2) ? (uint16_t)(r.data[0] | (r.data[1] << 8)) : 0xEEEE; +} + +static bytes body(const Res &r) +{ + return (r.data.size() >= 2) ? bytes(r.data.begin() + 2, r.data.end()) : bytes(); +} + +// Socket h of the world, or a spare one when h is no socket number: a red run must not crash. +static FakeSock &sock(int h) +{ + static FakeSock spare; + if ((h < 0) || (h >= 16)) { + spare = FakeSock(); + return spare; + } + return world_socks[h]; +} + +static Res read_cmd(int h, int maxlen) +{ + return run(B({ 0x03, 0x10, h, maxlen & 0xFF, maxlen >> 8 })); +} + +static Res write_cmd(int h, const bytes &data) +{ + return run(cat(B({ 0x03, 0x11, h }), data)); +} + +static Res close_cmd(int h) +{ + return run(B({ 0x03, 0x09, h })); +} + +static Res info(int h) +{ + return run(B({ 0x03, 0x23, h })); +} + +static Res release(void) +{ + return run(B({ 0x03, 0x25 })); +} + +static void fresh(void) +{ + world_reset(); + net.c64_reset(); + world_module.calls.clear(); + world_module.close_alls = 0; + for (int i = 0; i < 16; i++) { + world_socks[i] = FakeSock(); + world_socks[i].srv.saw_alert = -1; + world_socks[i].srv.flight = 2000; + world_socks[i].srv.delay_ms = 20; + world_socks[i].srv.chunk = 1460; + } +} + +// An OPEN that should succeed; the handle, or -1. +static int open_ok(uint8_t trust = 0, const std::string &tail = "example.com", const bytes &pin = bytes()) +{ + Res r = run(open_cmd(trust, 0, tail, pin)); + if ((r.status != "00,OK") || (r.data.size() != 8)) { + printf(" open: %s (%d bytes)\n", r.status.c_str(), (int)r.data.size()); + return -1; + } + return r.data[0]; +} + +// READs until the stream ends or nothing more comes: the data, and the last status. +static bytes read_all(int h, int maxlen, std::string *last, int *reads = NULL, int limit = 400) +{ + bytes all; + int n = 0; + for (; n < limit; n++) { + Res r = read_cmd(h, maxlen); + *last = r.status; + if (header(r) == 0xFFFF) { + if (r.status.compare(0, 3, "02,") != 0) { + break; + } + continue; + } + if (header(r) == 0) { + break; + } + bytes b = body(r); + all.insert(all.end(), b.begin(), b.end()); + } + if (reads) { + *reads = n; + } + return all; +} + +static bytes expected(uint32_t seed, size_t n) +{ + bytes b; + for (size_t i = 0; i < n; i++) { + b.push_back(payload_byte(seed, i)); + } + return b; +} + +// The i-th module call, or an empty one: a red run must not crash. +static RpcCall call_no(size_t i) +{ + return (i < world_module.calls.size()) ? world_module.calls[i] : RpcCall(); +} + +static RpcCall last_call(void) +{ + return world_module.calls.empty() ? RpcCall() : world_module.calls.back(); +} + +static uint8_t info_byte(size_t i) +{ + return at(info(0xFF), i); +} + +static int steps_logged(void) +{ + return world_count(0x31); +} + +// --- TLS_INFO ($23) ------------------------------------------------------------ + +static void test_info(void) +{ + printf("TLS_INFO $FF and on a handle\n"); + fresh(); + Res r = info(0xFF); + check(r.status == "00,OK" && r.data.size() == 16, "info: $FF answers 16 bytes, 00,OK (got %s, %d)", + r.status.c_str(), (int)r.data.size()); + if (r.data.size() == 16) { + const uint8_t want[16] = { 1, 2, 0, 7, 0x07, 3, 1, 0x32, 0x01, 0xFF, 0xFF, 0xFF, 12, 0, 0, 0 }; + check(memcmp(r.data.data(), want, 16) == 0, + "info: v1, 2 sessions, 0 in use, modes 7, ready 07 (image, entropy, time), versions 3, module 1.306, " + "CA date FF FF FF (unknown), block 12 ms, 0 unclaimed"); + } + check(world_count(0x33) == 1 && last_call().slot == 0xFF && last_call().tag == 0, + "info: one global STATS (slot $FF, tag 0)"); + world_module.available = false; + world_module.calls.clear(); + r = info(0xFF); + check(r.data.size() == 16 && !(r.data[4] & 0x01) && world_module.calls.empty(), + "info: no module -> ready bit0 clear, no RPC"); + world_module.available = true; + world_module.entropy = false; + world_module.module_time = false; + world_sntp = 0; + r = info(0xFF); + check(r.data.size() == 16 && r.data[4] == 0x01, "info: no entropy, no time anywhere -> ready 01 (got %02x)", + r.data.size() == 16 ? r.data[4] : 0xEE); + world_sntp = 1790000000u; + r = info(0xFF); + check(r.data.size() == 16 && r.data[4] == 0x05, "info: Nios SNTP alone gives the time bit"); + check(run(B({ 0x03, 0x23 })).status == "81,INVALID PARAMS", "info: 2 bytes -> 81"); + check(run(B({ 0x03, 0x23, 0xFF, 0x00 })).status == "81,INVALID PARAMS", "info: 4 bytes -> 81"); + check(info(5).status == "81,INVALID PARAMS" && info(5).data.empty(), "info: not a TLS handle -> empty, 81"); + + // The last good STATS stands through a STATS that gets no + // answer, within one module generation. + fresh(); + world_module.block_max_ms = 33; + r = info(0xFF); + world_module.block_max_ms = 44; + world_module.stats_result = WIFI_TLS_BUSY; + r = info(0xFF); + check(r.data.size() == 16 && (r.data[4] & 0x03) == 0x03 && r.data[12] == 33 && r.data[9] == 0xFF, + "info (cache): a STATS timeout keeps b0/b1, block_max 33 and the CA date from the last good STATS"); + world_module.stats_result = WIFI_TLS_UNSENT; + check((info_byte(4) & 0x01) == 0x01, "info (cache): an unsent STATS keeps b0 too"); + world_module.stats_result = WIFI_TLS_BUSY; + world_module.generation++; + r = info(0xFF); + check(r.data.size() == 16 && !(r.data[4] & 0x03) && r.data[12] == 0 && r.data[9] == 0, + "info (cache): after a module restart a STATS timeout clears b0/b1, block_max and the CA date"); + world_module.stats_result = -1; + check((info_byte(4) & 0x01) == 0x01 && info_byte(12) == 44, "info (cache): the next good STATS sets them again"); + world_module.stats_result = WIFI_TLS_INVALID; + check((info_byte(4) & 0x01) == 0x01, "info (cache): a malformed STATS answer keeps b0 (only NO_MODULE, " + "NOT_SUPPORTED or a new generation clear it)"); + world_module.stats_result = WIFI_TLS_REFUSED; // a module without TLS + world_module.stats_esp_err = WIFI_TLS_ESP_NOT_SUPPORTED; + check(!(info_byte(4) & 0x01), "info (cache): a STATS refused with NOT_SUPPORTED clears b0"); + world_module.stats_esp_err = 0; + world_module.stats_result = -1; + info(0xFF); + world_module.available = false; + r = info(0xFF); + world_module.available = true; + world_module.stats_result = WIFI_TLS_BUSY; + check(r.data.size() == 16 && !(r.data[4] & 0x01) && r.data[9] == 0 && r.data[10] == 0 && r.data[11] == 0 && + !(info_byte(4) & 0x01), "info (cache): no module clears b0 and the cache; the CA date is 0,0,0"); + world_module.stats_result = -1; +} + +// --- OPEN_TLS: the happy path -------------------------------------------------- + +static void test_open(void) +{ + printf("OPEN_TLS ($21): reply, RPC fields, socket\n"); + fresh(); + Res r = run(open_cmd(0, 0, "example.com")); + check(r.status == "00,OK", "open: BUNDLE example.com -> 00,OK (got %s)", r.status.c_str()); + int h = r.data.empty() ? -1 : r.data[0]; + const uint8_t want[8] = { (uint8_t)h, 0x04, 0x03, 0x01, 0x13, 0x1D, 0x00, 0x00 }; + check(r.data.size() == 8 && memcmp(r.data.data(), want, 8) == 0, + "open: reply is handle, 04 03, 01 13, 1D 00, 00 (8 bytes, LE)"); + RpcCall *o = NULL; + for (size_t i = 0; i < world_module.calls.size(); i++) { + if (world_module.calls[i].cmd == 0x30) { + o = &world_module.calls[i]; + } + } + check(o != NULL, "open: one OPEN RPC"); + if (o) { + check(o->open.trust == 0 && o->sni == "example.com" && o->open.slot == 0 && o->open.tag != 0, + "open: RPC trust 0, sni example.com, slot 0, tag %u != 0", o->open.tag); + check(o->open.time_source == WIFI_TLS_TIME_NIOS && o->open.unix_time == world_sntp, + "open: the Nios SNTP time goes along (time_source 1)"); + check(o->open.opts == 0 && o->open.ca_tag == 0 && o->pin.empty(), "open: opts 0, ca_tag 0, no pin"); + check(o->cancel_given, "open: the RPC wait has a cancel predicate"); + } + check(world_dns_calls == 1 && world_dns_unlocked_calls == 0, "open: dns_gethostbyname under the core lock"); + if (h >= 0 && h < 16) { + check(sock(h).nodelay, "open: TCP_NODELAY on the TLS socket"); + check(sock(h).sndtimeo_ms == 500, "open: SO_SNDTIMEO 500 ms caps lwIP's close (%d)", sock(h).sndtimeo_ms); + check(sock(h).nonblocking, "open: the TLS socket is non-blocking (SEND_MS)"); + check(sock(h).srv.hellos == 1, "open: the server saw one ClientHello"); + } + for (size_t i = 0; i < world_module.calls.size(); i++) { + const RpcCall &c = world_module.calls[i]; + if (c.cmd == 0x31) { + check(o && c.flags == 0 && c.slot == 0 && c.tag == o->open.tag, "open: handshake step %d: flags 0, slot and tag", + (int)i); + } + } + r = info(h); + check(r.status == "00,OK" && r.data.size() == 48, "info: a TLS handle answers 48 bytes"); + if (r.data.size() == 48) { + check(r.data[0] == 0x04 && r.data[1] == 0x03 && r.data[2] == 0x01 && r.data[3] == 0x13 && + r.data[4] == 0x1D && r.data[5] == 0 && r.data[6] == 0 && r.data[7] == 0, + "info: version, suite, group LE, trust 0, bits 0"); + check(memcmp(&r.data[8], world_module.spki, 32) == 0, "info: SPKI hash from the module, digest order"); + uint32_t ms = r.data[40] | (r.data[41] << 8) | (r.data[42] << 16) | (r.data[43] << 24); + check(ms > 0 && ms < 2000 && r.data[44] == 0 && r.data[47] == 0, "info: handshake %u ms, then 4 zero bytes", ms); + } + + fresh(); + world_module.version = 0x0303; + world_module.suite = 0xC02B; + world_module.group = 0x0017; + world_module.ems = 1; + r = run(open_cmd(0, 0x01, "example.com")); + check(r.data.size() == 8 && r.data[1] == 0x03 && r.data[2] == 0x03 && r.data[3] == 0x2B && r.data[4] == 0xC0 && + r.data[5] == 0x17 && r.data[7] == 0x01, "open: TLS 1.2 with EMS -> 03 03, 2B C0, 17 00, bit0 set"); + check(call_no(0).open.opts == WIFI_TLS_OPT_REQUIRE_TLS13, "open: flags bit0 -> opts REQUIRE_TLS13"); + + fresh(); + world_module.group = 0; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "17,TLS MODULE NOT RESPONDING" && r.data.empty() && world_open_sockets() == 0 && + world_count(0x32) == 1, "open: STATS with group 0 -> 17, socket and session closed (an established group is never 0)"); + + fresh(); + world_module.hello_size = 1400; + r = run(open_cmd(0, 0, "example.com")); + int first = -1, second = -1; + for (size_t i = 0; i < world_module.calls.size(); i++) { + if (world_module.calls[i].cmd == 0x31) { + if (first < 0) { + first = i; + } else if (second < 0) { + second = i; + } + } + } + check(r.status == "00,OK" && second > 0 && call_no(second).ct_in_len == 0, + "open: a 1403-B ClientHello goes in two steps, the second input-less (HANDSHAKE_MS)"); + h = r.data.empty() ? 0 : r.data[0]; + check(sock(h).srv.hellos == 1, "open: the server got the whole ClientHello"); + + fresh(); + for (int i = 0; i < 3; i++) { + uint16_t last = 0; + int a = open_ok(); + for (size_t k = 0; k < world_module.calls.size(); k++) { + if (world_module.calls[k].cmd == 0x30) { + last = world_module.calls[k].open.tag; + } + } + check(a >= 0 && last != 0, "open: open %d has a new non-zero tag %u", i, last); + close_cmd(a); + } + uint16_t t1 = 0, t2 = 0; + for (size_t k = 0; k < world_module.calls.size(); k++) { + if (world_module.calls[k].cmd == 0x30) { + t1 = t2; + t2 = world_module.calls[k].open.tag; + } + } + check(t1 != t2, "open: consecutive OPENs of one slot carry different tags"); +} + +// --- OPEN_TLS: the grammar, and 81 before 82 ------------------------------------ + +static void expect_open(const bytes &cmd, const char *want, const char *what) +{ + world_module.calls.clear(); + int dns = world_dns_calls; + Res r = run(cmd); + check(r.status == want && (strcmp(want, "00,OK") == 0 || (r.data.empty() && world_module.calls.empty() && + world_dns_calls == dns && world_open_sockets() == 0)), + "grammar: %s -> %s (got %s)", what, want, r.status.c_str()); + if (r.status == "00,OK" && !r.data.empty()) { + close_cmd(at(r, 0)); + } +} + +static std::string last_sni(void) +{ + for (size_t i = world_module.calls.size(); i-- > 0;) { + if (world_module.calls[i].cmd == 0x30) { + return world_module.calls[i].sni; + } + } + return ""; +} + +static void test_grammar(void) +{ + printf("OPEN_TLS: tail grammar, names and refusals (S19)\n"); + fresh(); + std::string h254(254, 'a'); + std::string h253(253, 'a'); + expect_open(B({ 0x03, 0x21, 0xBB, 0x01, 0 }), "81,INVALID PARAMS", "5 bytes"); + expect_open(open_cmd(0, 0, ""), "81,INVALID PARAMS", "empty host"); + expect_open(open_cmd(0, 0, std::string("\0", 1)), "81,INVALID PARAMS", "host is a lone $00"); + expect_open(open_cmd(0, 0, std::string("example.com\0\0", 13)), "81,INVALID PARAMS", "host $00 $00"); + expect_open(open_cmd(0, 0, std::string("example.com\0a\0b", 15)), "81,INVALID PARAMS", "a $00 inside the name"); + expect_open(open_cmd(0, 0, std::string("example.com\0name\0\0", 18)), "81,INVALID PARAMS", + "bytes after the name's $00"); + expect_open(open_cmd(0, 0, h254), "81,INVALID PARAMS", "a 254-byte host"); + expect_open(open_cmd(0, 0, std::string("x.com\0", 6) + h254), "81,INVALID PARAMS", "a 254-byte name"); + expect_open(open_cmd(2, 0, "example.com", bytes(20, 1)), "81,INVALID PARAMS", "a short pin"); + expect_open(open_cmd(3, 0, "example.com"), "82,PARAMETER(S) OUT OF RANGE", "trust 3"); + expect_open(open_cmd(0, 0x02, "example.com"), "82,PARAMETER(S) OUT OF RANGE", "flags $02 (reserved)"); + expect_open(open_cmd(0, 0x80, "example.com"), "82,PARAMETER(S) OUT OF RANGE", "flags $80"); + expect_open(open_cmd(2, 0, "example.com", PIN(0)), "82,PARAMETER(S) OUT OF RANGE", "an all-zero pin"); + expect_open(open_cmd(0, 0x02, ""), "81,INVALID PARAMS", "a reserved bit AND an empty host: 81 first"); + expect_open(open_cmd(3, 0x02, std::string("a\0\0", 3)), "81,INVALID PARAMS", "trust 3 AND a bad tail: 81 first"); + expect_open(open_cmd(0, 0, "1.2.3.4"), "81,INVALID PARAMS", "BUNDLE, IPv4 host, no name"); + expect_open(open_cmd(1, 0, "1.2.3.4"), "81,INVALID PARAMS", "CUSTOM, IPv4 host, no name"); + expect_open(open_cmd(0, 0, "127.1"), "81,INVALID PARAMS", "BUNDLE, host 127.1 (ip4addr_aton)"); + expect_open(open_cmd(0, 0, "0x7f.0.0.1"), "81,INVALID PARAMS", "BUNDLE, host 0x7f.0.0.1"); + expect_open(open_cmd(0, 0, "1.2.3.4 x"), "81,INVALID PARAMS", "BUNDLE, host '1.2.3.4 x'"); + expect_open(open_cmd(0, 0, std::string("example.com\0" "10.0.0.1", 20)), "81,INVALID PARAMS", + "BUNDLE, an explicit IPv4 name"); + expect_open(open_cmd(0, 0, std::string("1.2.3.4\0", 8)), "81,INVALID PARAMS", "BUNDLE, IPv4 host $00"); + + expect_open(open_cmd(0, 0x01, "example.com"), "00,OK", "flags $01 (REQUIRE_TLS13) is accepted"); + expect_open(open_cmd(0, 0, std::string("example.com\0", 12)), "00,OK", "host $00 (dos-lib habit)"); + check(last_sni() == "example.com", "name: host $00 -> the host is the name"); + expect_open(open_cmd(0, 0, std::string("1.2.3.4\0srv.example", 19)), "00,OK", "BUNDLE, IPv4 host with a name"); + check(last_sni() == "srv.example", "name: the explicit name goes to SNI"); + expect_open(open_cmd(0, 0, std::string("example.com\0srv\0", 16)), "00,OK", "host $00 name $00"); + check(last_sni() == "srv", "name: host $00 name $00 -> name"); + expect_open(open_cmd(0, 0, h253), "00,OK", "a 253-byte host"); + expect_open(open_cmd(2, 0, "10.1.2.3", PIN()), "00,OK", "PIN to an IPv4 host, no name"); + check(last_sni() == "", "name: PIN with an IPv4 host sends no SNI"); + expect_open(open_cmd(2, 0, std::string("host.lan\0" "10.1.2.3", 17), PIN()), "00,OK", "PIN, explicit IPv4 name"); + check(last_sni() == "", "name: PIN with an explicit IPv4 name sends no SNI"); + expect_open(open_cmd(2, 0, "host.lan", PIN()), "00,OK", "PIN to a DNS name"); + check(last_sni() == "host.lan", "name: PIN with a DNS name sends SNI"); + RpcCall o = call_no(0); + check(o.pin == PIN() && o.open.trust == 2, "pin: the 32 pin bytes go to the module unchanged"); + + // No reply, nothing opened. + world_module.calls.clear(); + int dns = world_dns_calls; + Res r = run(open_cmd(0, 0, "example.com", bytes(), 443, 0x83)); + check(r.status == "81,INVALID PARAMS" && world_module.calls.empty() && world_dns_calls == dns && + world_open_sockets() == 0, "no-reply: $83 $21 opens nothing"); +} + +// --- OPEN_TLS: the refusal order ------------------------------------------------ + +static void test_precedence(void) +{ + printf("OPEN_TLS: refusal precedence, nothing on the network before the checks pass\n"); + fresh(); + world_module.available = false; + expect_open(open_cmd(0, 0, "example.com"), "90,TLS NOT AVAILABLE", "no module"); + fresh(); + int a = open_ok(), b = open_ok(); + world_dns.push_back({ "nowhere.invalid", DNS_ASYNC_NO, 0, 10 }); + world_module.calls.clear(); + int dns = world_dns_calls; + int sockets = world_open_sockets(); + Res r = run(open_cmd(0, 0, "nowhere.invalid")); + check(r.status == "91,TLS SESSIONS IN USE" && world_module.calls.empty() && world_dns_calls == dns && + world_open_sockets() == sockets, "precedence: table full + unresolvable host -> 91, no DNS, no socket"); + close_cmd(a); + close_cmd(b); + fresh(); + sock(0).srv.connect_err = ECONNREFUSED; + expect_open(open_cmd(1, 0, "example.com"), "97,NO CUSTOM CA", "CUSTOM with nothing loaded + closed port"); + fresh(); + world_module.entropy = false; + world_module.calls.clear(); + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "87,NO ENTROPY SOURCE" && world_dns_calls == 0 && world_open_sockets() == 0, + "precedence: module reason 1 -> 87, before DNS"); + fresh(); + world_module.module_time = false; + world_sntp = 0; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "92,NO TRUSTED TIME" && world_dns_calls == 0, "precedence: module reason 2 -> 92"); + r = run(open_cmd(2, 0, "10.0.0.5", PIN())); + check(r.status == "00,OK", "precedence: PIN needs no time"); + fresh(); + world_module.open_result = WIFI_TLS_REFUSED; + world_module.open_esp_err = WIFI_TLS_ESP_INVALID_STATE; + world_module.open_reason = WIFI_TLS_REASON_NO_CUSTOM_CA; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "97,NO CUSTOM CA" && world_dns_calls == 0, "precedence: module reason 3 -> 97 NO CUSTOM CA"); + fresh(); + world_module.open_result = WIFI_TLS_REFUSED; + world_module.open_esp_err = WIFI_TLS_ESP_NOT_SUPPORTED; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "90,TLS NOT AVAILABLE" && world_dns_calls == 0, + "precedence: a module without TLS (NOT_SUPPORTED) -> 90"); + fresh(); + world_module.open_result = WIFI_TLS_REFUSED; + world_module.open_esp_err = WIFI_TLS_ESP_NO_MEM; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "17,TLS MODULE NOT RESPONDING" && world_dns_calls == 0, "precedence: another refusal -> 17"); + fresh(); + world_module.open_delay_ms = 6000; + uint32_t t0 = world_ms(); + r = run(open_cmd(0, 0, "example.com")); + uint32_t spent = world_ms() - t0; + check(r.status == "17,TLS MODULE NOT RESPONDING" && world_dns_calls == 0 && world_count(0x32) == 1, + "precedence: OPEN RPC timeout -> 17, best-effort CLOSE(slot, tag), no DNS"); + check(spent >= 5000 && spent <= 6200, "precedence: OPEN_RPC_MS 5 s + CLOSE (%u ms)", spent); + fresh(); + world_module.unsent_next = 3; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "00,OK", "precedence: an unsent OPEN is sent again (UNSENT_RETRIES)"); +} + +// --- the verify classification, and other handshake ends ------------- + +static void expect_fail(uint8_t trust, uint8_t reason, uint32_t flags, uint8_t alert, int err, const char *want, + const char *what) +{ + fresh(); + world_module.hs_fail = true; + world_module.hs_fail_reason = reason; + world_module.hs_verify_flags = flags; + world_module.hs_alert_in = alert; + world_module.hs_fail_err = err; + world_module.hs_alert_out = true; + Res r = (trust == 2) ? run(open_cmd(2, 0, "host.lan", PIN())) : run(open_cmd(trust, 0, "example.com")); + check(r.status == want && r.data.empty() && world_open_sockets() == 0 && world_count(0x32) == 0 && + sock(0).srv.saw_alert == 40, + "classify: %s -> %s (got %s); socket closed, no CLOSE RPC, our alert went out", what, want, r.status.c_str()); +} + +static void test_classify(void) +{ + printf("OPEN_TLS: handshake failures to codes\n"); + const uint8_t N = WIFI_TLS_ALERT_NONE; + expect_fail(0, 0, 0, 70, -0x7780, "14,TLS ALERT RECEIVED: 70", "reason 0 with alert 70"); + expect_fail(0, 0, 0, N, -0x7280, "13,TLS HANDSHAKE FAILED: -0x7280", "reason 0, no alert"); + expect_fail(0, 1, 0x0303, N, -0x7700, "18,TLS VERSION REFUSED: 0x0303", "reason 1 (TLS 1.2 under REQUIRE_TLS13)"); + expect_fail(0, 1, 0x0302, N, -0x7700, "18,TLS VERSION REFUSED: 0x0302", "reason 1 (below 1.2)"); + expect_fail(0, 2, 0, N, -0x7700, "19,TLS DOWNGRADE DETECTED", "reason 2"); + expect_fail(0, 3, 0, N, -0x7700, "13,TLS HANDSHAKE FAILED: NO EMS", "reason 3"); + expect_fail(0, 4, 0x08, N, -0x2700, "93,CERTIFICATE NOT TRUSTED: 0x00000008", "BUNDLE, unknown root (exact)"); + expect_fail(0, 4, 0xFFFFFFFF, N, -0x3000, "93,CERTIFICATE NOT TRUSTED: 0xFFFFFFFF", "w = 0xFFFFFFFF"); + expect_fail(0, 4, 0x0C, N, -0x2700, "94,CERTIFICATE NAME MISMATCH: 0x0000000C", "BUNDLE, w 0x0C (name mismatch first)"); + expect_fail(0, 4, 0x05, N, -0x2700, "94,CERTIFICATE NAME MISMATCH: 0x00000005", "BUNDLE, name and expiry"); + expect_fail(0, 4, 0x01, N, -0x2700, "95,CERTIFICATE EXPIRED: 0x00000001", "BUNDLE, expired"); + expect_fail(0, 4, 0x200, N, -0x2700, "95,CERTIFICATE EXPIRED: 0x00000200", "BUNDLE, not yet valid"); + expect_fail(0, 4, 0x4000, N, -0x7A00, "93,CERTIFICATE NOT TRUSTED: 0x00004000", "BUNDLE, BAD_MD"); + expect_fail(2, 4, 0x04, N, -0x7A00, "93,CERTIFICATE NOT TRUSTED: 0x00000004", "PIN, w 0x04 (no name check)"); + expect_fail(2, 4, 0x01, N, -0x7A00, "93,CERTIFICATE NOT TRUSTED: 0x00000001", "PIN, w 0x01"); + expect_fail(2, 4, 0x200, N, -0x7A00, "93,CERTIFICATE NOT TRUSTED: 0x00000200", "PIN, w 0x200"); + expect_fail(2, 5, 0x08, N, -0x2700, "96,PINNED KEY MISMATCH", "PIN, reason 5"); + expect_fail(0, 5, 0x08, N, -0x2700, "17,TLS MODULE NOT RESPONDING", "BUNDLE, reason 5 (PIN only: malformed)"); + expect_fail(0, 6, 0, N, -0x7280, "13,TLS HANDSHAKE FAILED: PEER CLOSED", "reason 6"); + expect_fail(0, 9, 0, N, -0x7280, "17,TLS MODULE NOT RESPONDING", "an unknown reason"); + + fresh(); + sock(0).srv.on_hello = SRV_RST; + Res r = run(open_cmd(0, 0, "example.com")); + check(r.status == "13,TLS HANDSHAKE FAILED: PEER RESET: " + num(ECONNRESET) && world_open_sockets() == 0 && + world_count(0x32) == 1, "handshake: RST after the ClientHello -> 13 PEER RESET: errno, CLOSE RPC (S7c)"); + fresh(); + sock(0).srv.on_hello = SRV_FIN; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "13,TLS HANDSHAKE FAILED: PEER CLOSED" && world_open_sockets() == 0 && world_count(0x32) == 1, + "handshake: FIN mid-handshake -> 13 PEER CLOSED"); + fresh(); + sock(0).srv.on_hello = SRV_STALL; + uint32_t t0 = world_ms(); + r = run(open_cmd(0, 0, "example.com")); + uint32_t spent = world_ms() - t0; + check(r.status == "15,TLS HANDSHAKE TIMEOUT" && world_open_sockets() == 0 && world_count(0x32) == 1, + "handshake: a stalled server -> 15, CLOSE RPC, socket closed (S10)"); + check(spent >= 15000 && spent <= 16300, "handshake: within HANDSHAKE_MS + CLOSE (%u ms)", spent); + fresh(); + world_module.forced.push_back(Forced()); + world_module.forced.back().result = WIFI_TLS_BUSY; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "17,TLS MODULE NOT RESPONDING" && world_count(0x32) == 1 && world_open_sockets() == 0, + "handshake: a STEP timeout -> 17 and CLOSE(slot, tag)"); +} + +// --- DNS and connect ------------------------------------------------------ + +static void test_dns_connect(void) +{ + printf("OPEN_TLS: DNS inside OPEN, connect\n"); + fresh(); + world_dns.push_back({ "slow.example", DNS_NEVER, 0, 0 }); + uint32_t t0 = world_ms(); + Res r = run(open_cmd(0, 0, "slow.example")); + uint32_t spent = world_ms() - t0; + check(r.status == "84,UNRESOLVED HOST" && world_count(0x32) == 1 && world_open_sockets() == 0, + "dns: no answer -> 84 and the module session CLOSEd"); + check(spent >= 10000 && spent <= 11200, "dns: after DNS_MS (%u ms)", spent); + fresh(); + world_dns.push_back({ "bad.example", DNS_ASYNC_NO, 0, 30 }); + r = run(open_cmd(0, 0, "bad.example")); + check(r.status == "84,UNRESOLVED HOST", "dns: a failed lookup -> 84"); + fresh(); + world_dns.push_back({ "val.example", DNS_ERR_VAL, 0, 0 }); + r = run(open_cmd(0, 0, "val.example")); + check(r.status == "84,UNRESOLVED HOST", "dns: ERR_VAL -> 84"); + // A late answer to an abandoned lookup is never taken for the next one. + fresh(); + world_dns.push_back({ "a.example", DNS_ASYNC_OK, 0x01010101, 12000 }); + world_dns.push_back({ "b.example", DNS_ASYNC_OK, 0x02020202, 3000 }); + r = run(open_cmd(0, 0, "a.example")); + check(r.status == "84,UNRESOLVED HOST", "dns: a.example answers after DNS_MS -> 84"); + r = run(open_cmd(0, 0, "b.example")); + int h = r.data.empty() ? 0 : r.data[0]; + check(r.status == "00,OK" && sock(h).connect_addr == 0x02020202, + "dns: the next OPEN connects to b's address, not a's late answer (the slot seq)"); + check(world_lock_bad == 0 && world_dns_unlocked_calls == 0, "dns: lookups start under the lock"); + fresh(); + r = run(open_cmd(2, 0, "10.9.8.7", PIN())); + h = r.data.empty() ? 0 : r.data[0]; + check(r.status == "00,OK" && sock(h).connect_addr == htonl(0x0A090807), + "dns: an IPv4 literal resolves at once"); + + fresh(); + sock(0).srv.connect_err = ECONNREFUSED; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "11,ERROR ON CONNECT: " + num(ECONNREFUSED) && world_count(0x32) == 1 && + world_open_sockets() == 0, "connect: refused -> 11 with errno, session CLOSEd, socket closed"); + fresh(); + sock(0).srv.connect_never = true; + t0 = world_ms(); + r = run(open_cmd(0, 0, "example.com")); + spent = world_ms() - t0; + check(r.status == "11,ERROR ON CONNECT: " + num(ETIMEDOUT) && spent >= 10000 && spent <= 11300, + "connect: no answer -> 11 ETIMEDOUT after CONNECT_MS (%u ms)", spent); + + // The whole OPEN is bounded (OPEN_TOTAL_MS + CLOSE_RPC_MS + a slice). + fresh(); + world_module.open_delay_ms = 4900; + world_dns.push_back({ "slow.example", DNS_ASYNC_OK, 0x03030303, 9900 }); + sock(0).srv.connect_delay_ms = 9900; + sock(0).srv.on_hello = SRV_STALL; + t0 = world_ms(); + r = run(open_cmd(0, 0, "slow.example")); + spent = world_ms() - t0; + check(r.status == "15,TLS HANDSHAKE TIMEOUT" && spent <= 41100, + "budget: slow OPEN RPC, DNS, connect and a stalled server end within 41.1 s (%u ms, %s)", spent, + r.status.c_str()); +} + +// --- a C64 reset during OPEN -------------------------------------------------- + +static void test_reset_during_open(void) +{ + printf("OPEN_TLS: a reset ends it at once\n"); + fresh(); + sock(0).srv.on_hello = SRV_STALL; + world_reset_at = world_tick + 600; // 3 s in + Res r = run(open_cmd(0, 0, "example.com")); + uint32_t late = (world_tick - world_reset_at) * 5; + check(late <= 110, "reset: the OPEN returns within a slice of the reset (%u ms late)", late); + check(world_open_sockets() == 0 && world_count(0x32) == 0, "reset: socket closed, no CLOSE RPC waited for"); + net.c64_reset(); + world_reset_at = 0xFFFFFFFF; + check(world_module.close_alls == 1, "reset: c64_reset sends CLOSE_ALL once"); + r = info(0xFF); + check(r.data.size() == 16 && r.data[2] == 0, "reset: no entries afterwards"); + fresh(); + world_dns.push_back({ "never.example", DNS_NEVER, 0, 0 }); + world_reset_at = world_tick + 200; + r = run(open_cmd(0, 0, "never.example")); + late = (world_tick - world_reset_at) * 5; + check(late <= 110 && world_open_sockets() == 0, "reset: during DNS too (%u ms late)", late); + world_reset_at = 0xFFFFFFFF; +} + +// --- START_TLS ($24) -------------------------------------------------------------------- + +static int open_tcp(void) +{ + Res r = run(B({ 0x03, 0x07, 0x19, 0x00, 'm', 'a', 'i', 'l' })); + return (r.status == "00,OK") ? at(r, 0) : -1; +} + +static bytes start_cmd(int h, uint8_t trust, uint8_t flags, const std::string &tail, const bytes &pin = bytes(), + uint8_t first = 0x03) +{ + return cat(cat(B({ first, 0x24, h, trust, flags }), pin), S(tail)); +} + +static void expect_kept(int h, const bytes &cmd, const char *want, const char *what) +{ + Res r = run(cmd); + bool untouched = sock(h).open && !sock(h).nodelay && !sock(h).nonblocking && !sock(h).sndtimeo_ms; + check(r.status == want && r.data.empty() && untouched, "start: %s -> %s, TCP handle unchanged (got %s)", what, + want, r.status.c_str()); +} + +static void test_start_tls(void) +{ + printf("START_TLS ($24): handle checks first, kept codes, success\n"); + fresh(); + int t = open_tcp(); + Res u = run(B({ 0x03, 0x08, 0x35, 0x00, 'n', 's' })); + int udp = u.data.empty() ? -1 : u.data[0]; + check(t >= 0 && udp >= 0, "start: a TCP and a UDP handle to work with"); + check(!sock(t).sndtimeo_ms && !sock(t).nodelay, "start: OPEN_TCP's socket gets neither (TLS sockets only)"); + Res r = run(start_cmd(udp, 2, 0, "", PIN())); + check(r.status == "81,INVALID PARAMS" && sock(udp).open, "start: on a UDP handle -> 81, UDP untouched"); + r = run(start_cmd(12, 2, 0, "", PIN())); + check(r.status == "81,INVALID PARAMS", "start: on an unowned number -> 81"); + r = run(start_cmd(udp, 3, 0x80, "")); + check(r.status == "81,INVALID PARAMS", "start: UDP handle AND trust 3: the handle check comes first -> 81"); + r = run(start_cmd(12, 3, 0, "x")); + check(r.status == "81,INVALID PARAMS", "start: unowned number AND trust 3 -> 81, not 82"); + r = run(B({ 0x03, 0x24 })); + check(r.status == "81,INVALID PARAMS", "start: no handle byte -> 81"); + expect_kept(t, start_cmd(t, 3, 0, "mail.example"), "82,PARAMETER(S) OUT OF RANGE", "trust 3"); + expect_kept(t, start_cmd(t, 0, 2, "mail.example"), "82,PARAMETER(S) OUT OF RANGE", "flags $02"); + expect_kept(t, start_cmd(t, 2, 0, "", PIN(0)), "82,PARAMETER(S) OUT OF RANGE", "zero pin"); + expect_kept(t, start_cmd(t, 0, 0, ""), "81,INVALID PARAMS", "BUNDLE without a name"); + expect_kept(t, start_cmd(t, 0, 0, std::string("\0", 1)), "81,INVALID PARAMS", "BUNDLE, a lone $00"); + expect_kept(t, start_cmd(t, 0, 0, "10.0.0.1"), "81,INVALID PARAMS", "BUNDLE, an IPv4 name"); + expect_kept(t, start_cmd(t, 0, 0, std::string("a\0b", 3)), "81,INVALID PARAMS", "bytes after the name's $00"); + expect_kept(t, start_cmd(t, 1, 0, "mail.example"), "97,NO CUSTOM CA", "CUSTOM, nothing loaded"); + world_module.available = false; + expect_kept(t, start_cmd(t, 0, 0, "mail.example"), "90,TLS NOT AVAILABLE", "no module"); + world_module.available = true; + world_module.entropy = false; + expect_kept(t, start_cmd(t, 0, 0, "mail.example"), "87,NO ENTROPY SOURCE", "module reason 1"); + world_module.entropy = true; + world_module.module_time = false; + world_sntp = 0; + expect_kept(t, start_cmd(t, 0, 0, "mail.example"), "92,NO TRUSTED TIME", "module reason 2"); + world_module.module_time = true; + world_sntp = 1790000000u; + // The TCP handle still carries plaintext after all of that. + server_push(t, EV_DATA, S("220 hello\r\n")); + r = read_cmd(t, 100); + check(r.status == "00,OK" && body(r) == S("220 hello\r\n"), "start: the TCP handle still reads plaintext"); + + world_module.calls.clear(); + r = run(start_cmd(t, 2, 0, std::string("\0", 1), PIN())); + check(r.status == "00,OK" && r.data.size() == 8 && r.data[0] == t, "start: PIN, a lone $00 -> OK, the same handle"); + check(last_sni() == "", "start: no name -> no SNI"); + check(sock(t).nodelay && sock(t).nonblocking && (sock(t).sndtimeo_ms == 500), + "start: TCP_NODELAY and SO_SNDTIMEO 500 ms once every refusal check passed"); + r = run(start_cmd(t, 2, 0, "", PIN())); + check(r.status == "81,INVALID PARAMS" && sock(t).open, "start: on a TLS handle -> 81, session untouched"); + check(info(t).data.size() == 48, "start: the handle is a TLS handle now"); + close_cmd(t); + + fresh(); + t = open_tcp(); + world_module.hs_fail = true; + world_module.hs_fail_reason = 4; + world_module.hs_verify_flags = 0x08; + r = run(start_cmd(t, 0, 0, "mail.example")); + check(r.status == "93,CERTIFICATE NOT TRUSTED: 0x00000008" && !sock(t).open, + "start: a 93 closes the handle (every code but the kept ones)"); + r = close_cmd(t); + check(r.status == "12,ERROR ON CLOSE: " + num(EBADF), "start: CLOSE after it -> 12,ERROR ON CLOSE: 9"); + fresh(); + t = open_tcp(); + world_module.open_delay_ms = 6000; + r = run(start_cmd(t, 0, 0, "mail.example")); + check(r.status == "17,TLS MODULE NOT RESPONDING" && !sock(t).open, + "start: a 17 from the OPEN RPC closes the handle"); + fresh(); + t = open_tcp(); + int a = open_ok(), b = open_ok(); + expect_kept(t, start_cmd(t, 0, 0, "mail.example"), "91,TLS SESSIONS IN USE", "table full"); + close_cmd(a); + close_cmd(b); + // No reply: nothing happens. + world_module.calls.clear(); + r = run(start_cmd(t, 2, 0, "", PIN(), 0x83)); + check(world_module.calls.empty() && sock(t).open && !sock(t).nodelay, + "start: $83 $24 does nothing"); +} + +// --- READ, WRITE and CLOSE on a TLS handle ----------------------------------------------- + +static void test_read(void) +{ + printf("READ on a TLS handle\n"); + fresh(); + int h = open_ok(); + uint32_t t0 = world_ms(); + Res r = read_cmd(h, 100); + check(header(r) == 0xFFFF && r.status == "02,NO DATA: " + num(EWOULDBLOCK), + "read: nothing yet -> $FFFF + 02,NO DATA: 11 (%s)", r.status.c_str()); + check(world_ms() - t0 <= 300, "read: an idle READ is short (%u ms)", world_ms() - t0); + check(read_cmd(h, 0).status == "82,PARAMETER(S) OUT OF RANGE", "read: maxlen 0 -> 82"); + check(read_cmd(h, 1473).status == "82,PARAMETER(S) OUT OF RANGE", "read: maxlen 1473 -> 82"); + + server_push(h, EV_DATA, record('D', 3000, 5)); + server_push(h, EV_DATA, record('C', 0)); + server_push(h, EV_FIN, bytes()); + std::string last; + bytes got = read_all(h, 1472, &last); + check(got == expected(5, 3000), "read: all 3000 B of one record, in order (%d)", (int)got.size()); + check(last == "01,CONNECTION CLOSED BY HOST" && !sock(h).open, "read: then $0000 + 01, handle GONE (S6)"); + check(!sock(h).srv.saw_notify, "read: no close_notify of ours after the peer's (module freed it)"); + check(close_cmd(h).status == "12,ERROR ON CLOSE: " + num(EBADF), "read: CLOSE afterwards -> 12,…: 9"); + r = read_cmd(h, 10); + check(header(r) == 0xFFFF && r.status == "02,NO DATA: " + num(EBADF), "read: READ afterwards -> 02,NO DATA: 9"); + + fresh(); + h = open_ok(); + server_push(h, EV_DATA, record('D', 3000, 6)); + server_push(h, EV_FIN, bytes()); + got = read_all(h, 1472, &last); + check(got == expected(6, 3000) && last == "05,TLS CLOSED WITHOUT NOTIFY" && !sock(h).open, + "read: 3000 B, then FIN -> all data, then 05, GONE (S7)"); + check(sock(h).srv.saw_notify, "read: 05 closes the live session with close_notify"); + + fresh(); + h = open_ok(); + server_push(h, EV_DATA, record('D', 100, 7)); + uint8_t alert = 80; + server_push(h, EV_DATA, bytes({ 'A', 1, 0, alert })); + got = read_all(h, 1472, &last); + check(got == expected(7, 100) && last == "14,TLS ALERT RECEIVED: 80", "read: data, then an alert -> 14"); + r = read_cmd(h, 10); + check(header(r) == 0 && r.status == "14,TLS ALERT RECEIVED: 80", "read: sticky: $0000 + 14 again"); + r = write_cmd(h, S("x")); + check(header(r) == 0xFFFF && r.status == "14,TLS ALERT RECEIVED: 80", "read: WRITE -> $FFFF + the same"); + check(info_byte(2) == 1, "read: INFO counts the sticky entry"); + world_module.calls.clear(); + check(close_cmd(h).status == "00,OK" && world_count(0x32) == 0 && !sock(h).open, + "read: CLOSE -> 00,OK, no RPC (module freed it)"); + check(info_byte(2) == 0, "read: entry freed"); + + fresh(); + h = open_ok(); + server_push(h, EV_DATA, record('B', 40)); + got = read_all(h, 1472, &last); + check(last == "16,TLS SESSION FAILED: -0x7180", "read: a bad record -> 16 with the mbedTLS code (%s)", + last.c_str()); + + fresh(); + h = open_ok(); + world_module.forced.push_back(Forced()); + world_module.forced.back().result = WIFI_TLS_BUSY; + server_push(h, EV_DATA, record('D', 10, 1)); + t0 = world_ms(); + r = read_cmd(h, 100); + check(header(r) == 0 && r.status == "17,TLS MODULE NOT RESPONDING" && world_count(0x32) == 1, + "read: a STEP timeout -> $0000 + 17, and CLOSE(slot, tag) at once"); + check(world_ms() - t0 <= 11100, "read: within READ_TOTAL_MS + CLOSE (%u ms)", world_ms() - t0); + check(read_cmd(h, 10).status == "17,TLS MODULE NOT RESPONDING", "read: 17 is sticky"); + world_module.calls.clear(); + check(close_cmd(h).status == "00,OK" && world_count(0x32) == 0, "read: CLOSE after a cleanup CLOSE sends no RPC"); + + fresh(); + h = open_ok(); + world_module.forced.push_back(Forced()); + world_module.forced.back().result = WIFI_TLS_REFUSED; + world_module.forced.back().esp_err = WIFI_TLS_ESP_NOT_FOUND; + server_push(h, EV_DATA, record('D', 10, 1)); + r = read_cmd(h, 100); + check(r.status == "17,TLS MODULE NOT RESPONDING" && world_count(0x32) == 0, + "read: NOT_FOUND -> 17, no CLOSE (the module has no session)"); + + // A big record over many READs, and the byte-exact slicing (S13). + int sizes[] = { 1, 100, 893, 894, 1472 }; + for (int i = 0; i < 5; i++) { + fresh(); + h = open_ok(); + server_push(h, EV_DATA, record('D', 16000, 9)); + server_push(h, EV_DATA, record('C', 0)); + got = read_all(h, sizes[i], &last, NULL, 20000); + check(got == expected(9, 16000) && last == "01,CONNECTION CLOSED BY HOST", + "read: a 16 KB record with maxlen %d is byte exact (%d)", sizes[i], (int)got.size()); + } + // A reply of more than one block carries the whole count in its header. + fresh(); + h = open_ok(); + server_push(h, EV_DATA, record('D', 960, 3)); + r = read_cmd(h, 1472); + check(header(r) == 960 && body(r) == expected(3, 960) && r.status == "00,OK", + "read: 960 B over two blocks, header 960, status once"); + + // Tickets ahead of data: the READs go on stepping until the data arrives. + fresh(); + h = open_ok(); + for (int i = 0; i < 10; i++) { + server_push(h, EV_DATA, record('T', 200, i)); + } + server_push(h, EV_DATA, record('D', 50, 4)); + got = read_all(h, 1472, &last, NULL, 60); + check(got == expected(4, 50), "read: 10 tickets, then the data arrives (S13)"); + + // READ never steps while rx is non-empty. + fresh(); + h = open_ok(); + server_push(h, EV_DATA, record('D', 900, 2)); + r = read_cmd(h, 100); + int before = steps_logged(); + r = read_cmd(h, 100); + bytes e900 = expected(2, 900); + check(steps_logged() == before && body(r) == bytes(e900.begin() + 100, e900.begin() + 200), + "read: the second READ comes from rx with no STEP"); + + // AGAIN: the same input goes again, and nothing is lost. + fresh(); + h = open_ok(); + world_module.again_next = 1; + server_push(h, EV_DATA, record('D', 500, 8)); + got = read_all(h, 1472, &last, NULL, 5); + check(got == expected(8, 500), "read: after AGAIN the same ciphertext is sent again (%d)", (int)got.size()); + + // READ_BUDGET: at most 8 steps per READ. + fresh(); + h = open_ok(); + for (int i = 0; i < 30; i++) { + server_push(h, EV_DATA, record('T', 20, i)); + } + before = steps_logged(); + r = read_cmd(h, 100); + check(steps_logged() - before <= 8 && header(r) == 0xFFFF, "read: 8 steps at most, then NO DATA (%d steps)", + steps_logged() - before); + for (size_t i = 0; i < world_module.calls.size(); i++) { + if ((world_module.calls[i].cmd == 0x31) && (world_module.calls[i].flags != 0)) { + check(false, "read: READ steps never carry NO_READ"); + break; + } + } +} + +static void test_write(void) +{ + printf("WRITE on a TLS handle\n"); + fresh(); + int h = open_ok(); + int before = steps_logged(); + Res r = write_cmd(h, bytes()); + check(header(r) == 0 && r.status == "00,OK" && steps_logged() == before, "write: 0 bytes -> 0000, OK, no step"); + bytes data = expected(11, 892); + world_module.calls.clear(); + r = write_cmd(h, data); + check(header(r) == 892 && r.status == "00,OK", "write: 892 B -> header 892, 00,OK"); + check(sock(h).srv.got == data, "write: the server got exactly those bytes"); + bool no_read = true; + int steps = 0; + for (size_t i = 0; i < world_module.calls.size(); i++) { + const RpcCall &c = world_module.calls[i]; + if (c.cmd == 0x31) { + steps++; + no_read = no_read && (c.flags == WIFI_TLS_STEP_NO_READ) && (c.ct_in_len == 0); + } + } + check(no_read && steps <= 4, "write: every step has NO_READ and ct_in_len 0 (%d steps)", steps); + + // WRITE between READs of one record. + for (int w = 0; w < 2; w++) { + fresh(); + h = open_ok(); + server_push(h, EV_DATA, record('D', 3000, 12)); + r = read_cmd(h, 100); + bytes got = body(r); + r = write_cmd(h, w ? expected(1, 892) : S("x")); + check(r.status == "00,OK", "write: a %d-B WRITE mid-record -> OK", w ? 892 : 1); + std::string last; + bytes rest = read_all(h, 1472, &last, NULL, 20); + got.insert(got.end(), rest.begin(), rest.end()); + check(got == expected(12, 3000), "write: the READs still give all 3000 B in order (%d)", (int)got.size()); + } + + // Budget, AGAIN, send failures, failures from the module. + fresh(); + h = open_ok(); + world_module.again_next = 10; + r = write_cmd(h, S("hello")); + check(header(r) == 0xFFFF && r.status == "17,TLS MODULE NOT RESPONDING" && world_count(0x32) == 1, + "write: AGAIN past WRITE_BUDGET -> $FFFF + 17, cleanup CLOSE"); + check(write_cmd(h, S("x")).status == "17,TLS MODULE NOT RESPONDING", "write: sticky"); + fresh(); + h = open_ok(); + world_module.again_next = 1; + r = write_cmd(h, S("hello")); + check(header(r) == 5 && sock(h).srv.got == S("hello"), "write: one AGAIN, sent again, once"); + fresh(); + h = open_ok(); + sock(h).send_err = EPIPE; + r = write_cmd(h, S("hello")); + check(header(r) == 0xFFFF && r.status == "12,SEND ERROR: " + num(EPIPE), "write: send error -> $FFFF + 12"); + r = read_cmd(h, 10); + check(header(r) == 0 && r.status == "12,SEND ERROR: " + num(EPIPE), "write: then READ -> $0000 + the same 12"); + fresh(); + h = open_ok(); + sock(h).send_blocked = true; + uint32_t t0 = world_ms(); + r = write_cmd(h, S("hello")); + uint32_t spent = world_ms() - t0; + check(header(r) == 0xFFFF && r.status == "12,SEND ERROR: " + num(ETIMEDOUT) && spent >= 5000 && spent <= 5300, + "write: a stalled send -> 12,SEND ERROR: ETIMEDOUT after SEND_MS (%u ms, S32)", spent); + fresh(); + h = open_ok(); + world_module.forced.push_back(Forced()); + world_module.forced.back().pt_on_no_read = true; + r = write_cmd(h, S("hello")); + check(r.status == "17,TLS MODULE NOT RESPONDING", "write: plaintext on a NO_READ step -> 17 (malformed)"); + fresh(); + h = open_ok(); + world_module.forced.push_back(Forced()); + world_module.forced.back().fail = true; + world_module.forced.back().alert_in = 21; + world_module.forced.back().fail_err = -0x7780; + r = write_cmd(h, S("hello")); + check(header(r) == 0xFFFF && r.status == "14,TLS ALERT RECEIVED: 21", "write: FAILED with an alert -> 14"); + fresh(); + h = open_ok(); + world_module.forced.push_back(Forced()); + world_module.forced.back().result = WIFI_TLS_BUSY; + world_module.forced.back().applied = true; + r = write_cmd(h, S("hello")); + check(header(r) == 0xFFFF && r.status == "17,TLS MODULE NOT RESPONDING" && world_count(0x32) == 1, + "write: a STEP timeout -> 17, cleanup CLOSE, never a partial count"); + // The peer's close_notify ended the session on the module (our reading of the protocol). + fresh(); + h = open_ok(); + server_push(h, EV_DATA, cat(record('D', 20, 1), record('C', 0))); + r = read_cmd(h, 5); + r = write_cmd(h, S("late")); + check(header(r) == 0xFFFF && r.status == "12,SEND ERROR: " + num(EPIPE), + "write: after the peer's close_notify -> $FFFF + 12,SEND ERROR: EPIPE (sticky)"); +} + +static void test_close(void) +{ + printf("CLOSE on a TLS handle\n"); + fresh(); + int h = open_ok(); + uint16_t tag = 0; + for (size_t i = 0; i < world_module.calls.size(); i++) { + if (world_module.calls[i].cmd == 0x30) { + tag = world_module.calls[i].open.tag; + } + } + world_module.calls.clear(); + Res r = close_cmd(h); + check(r.status == "00,OK" && r.data.empty(), "close: 00,OK"); + check(world_count(0x32) == 1 && call_no(0).slot == 0 && call_no(0).tag == tag, + "close: CLOSE(slot, tag) RPC"); + check(sock(h).srv.saw_notify && !sock(h).open, "close: close_notify sent, then the socket closed"); + check(info_byte(2) == 0, "close: the entry is free"); + world_module.close_result = WIFI_TLS_BUSY; + h = open_ok(); + r = close_cmd(h); + check(r.status == "00,OK" && !sock(h).open, "close: 00,OK even when the module does not answer"); +} + +// --- latch-and-drain after a receive error ------------------------------- + +// An established session whose module holds n bytes of plaintext and then +// `terminal`, and whose socket answers the first recv with ECONNRESET. +static int latch_setup(size_t n, char terminal, uint8_t alert = 80) +{ + fresh(); + int h = open_ok(); + FakeSession &s = world_module.sess[0]; + for (size_t i = 0; i < n; i++) { + s.pt.push_back(payload_byte(21, i)); + } + s.terminal = terminal; + s.alert = alert; + server_push(h, EV_ERR, bytes(), ECONNRESET); + return h; +} + +static void test_latch(void) +{ + printf("READ: latch-and-drain after a receive error\n"); + const std::string rst = "12,RECEIVE ERROR: " + num(ECONNRESET); + std::string last; + int reads; + int h = latch_setup(2500, 0); + bytes got = read_all(h, 1472, &last, &reads, 50); + check(got == expected(21, 2500), "latch: every held byte is delivered first (%d of 2500)", (int)got.size()); + check(last == rst, "latch: then $0000 + %s (got %s)", rst.c_str(), last.c_str()); + Res r = read_cmd(h, 10); + check(header(r) == 0 && r.status == rst, "latch: sticky on the next READ"); + check(sock(h).recv_after_err == 0, "latch: no lwip_recv after the latch; the FIRST errno is kept"); + check(close_cmd(h).status == "00,OK" && world_count(0x32) >= 1, "latch: CLOSE -> 00,OK (module session freed)"); + + h = latch_setup(2500, 'C'); + got = read_all(h, 1472, &last, NULL, 50); + check(got == expected(21, 2500) && last == "01,CONNECTION CLOSED BY HOST" && !sock(h).open, + "latch: close_notify held behind the data wins -> all bytes, then 01"); + + h = latch_setup(2500, 'A', 80); + got = read_all(h, 1472, &last, NULL, 50); + check(got == expected(21, 2500) && last == "14,TLS ALERT RECEIVED: 80", + "latch: a fatal alert held behind the data wins -> all bytes, then 14 (%s)", last.c_str()); + + // One quiet input-less step does not end the drain. + h = latch_setup(1500, 0); + world_module.quiet_next = 1; + got = read_all(h, 1472, &last, NULL, 50); + check(got == expected(21, 1500) && last == rst, + "latch: a quiet step while the module still holds plaintext does not end the drain (%d)", (int)got.size()); + + // Quiet and plaintext steps alternating: plaintext breaks the run of quiet steps, so the drain goes on. + h = latch_setup(3000, 0); + world_module.quiet_alternate = true; + got = read_all(h, 1472, &last, NULL, 50); + check(got == expected(21, 3000) && last == rst, + "latch: quiet steps between plaintext steps never add up to the end of the drain (%d)", (int)got.size()); + + h = latch_setup(0, 0); + r = read_cmd(h, 10); + check(header(r) == 0 && r.status == rst, "latch: nothing held -> 12 at once"); + + // (a) WRITE while latched: nothing sent; the end is fixed to that 12. + h = latch_setup(2500, 'C'); + r = read_cmd(h, 100); + bytes first = body(r); + int sends = sock(h).send_calls; + r = write_cmd(h, S("ping")); + check(header(r) == 0xFFFF && r.status == rst && sock(h).send_calls == sends, + "latch (a): WRITE while latched -> $FFFF + %s, no lwip_send", rst.c_str()); + got = read_all(h, 1472, &last, NULL, 50); + first.insert(first.end(), got.begin(), got.end()); + check(first == expected(21, 2500) && last == rst && sock(h).open, + "latch (a): READs deliver every byte and end in that 12, not 01, handle still owned"); + // (a2) the same with a fatal alert behind, READs of 1 byte. + h = latch_setup(1200, 'A', 80); + r = read_cmd(h, 1); + first = body(r); + write_cmd(h, S("ping")); + got = read_all(h, 1, &last, NULL, 3000); + first.insert(first.end(), got.begin(), got.end()); + check(first == expected(21, 1200) && last == rst, + "latch (a2): alert behind the data after a WRITE's 12 -> every byte (%d), then 12 not 14", + (int)first.size()); + // (a3) a record that fails its MAC. + h = latch_setup(1200, 'B'); + r = read_cmd(h, 1); + first = body(r); + write_cmd(h, S("ping")); + got = read_all(h, 1, &last, NULL, 3000); + first.insert(first.end(), got.begin(), got.end()); + check(first == expected(21, 1200) && last == rst, "latch (a3): bad MAC behind -> every byte, then 12 not 16"); + // (b) the RST found by a WRITE first: the held plaintext is discarded. + fresh(); + h = open_ok(); + server_push(h, EV_DATA, record('D', 1200, 21)); + r = read_cmd(h, 10); + sock(h).send_err = ECONNRESET; + server_push(h, EV_ERR, bytes(), ECONNRESET); + r = write_cmd(h, S("ping")); + const std::string sent = "12,SEND ERROR: " + num(ECONNRESET); + check(header(r) == 0xFFFF && r.status == sent, "latch (b): WRITE meets the RST -> $FFFF + %s", sent.c_str()); + r = read_cmd(h, 100); + check(header(r) == 0 && r.status == sent, "latch (b): READ -> $0000 + the same 12, held plaintext discarded"); +} + +// --- claims, $25 and ABORT --------------------------------------------- + +static void test_claims(void) +{ + printf("$25 TLS_RELEASE, claims and ABORT (S19e)\n"); + fresh(); + int a = open_ok(); + Res r = release(); + check(r.status == "00,OK" && r.data == B({ 1 }), "release: right after an OPEN -> 1"); + check(!sock(a).open && sock(a).srv.saw_notify && world_count(0x32) == 1, + "release: CLOSE RPC, close_notify, socket closed"); + check(release().data == B({ 0 }), "release: again -> 0 (idempotent)"); + r = read_cmd(a, 10); + check(header(r) == 0xFFFF && r.status == "02,NO DATA: " + num(EBADF), "release: READ on the number -> 02,NO DATA: 9"); + + fresh(); + a = open_ok(); + check(info_byte(14) == 1, "claims: INFO $FF [14] = 1 after an OPEN"); + check(info_byte(14) == 1, "claims: $23 $FF does not claim"); + check(release().data == B({ 1 }), "claims: $23 $FF, then $25 -> 1"); + + fresh(); + a = open_ok(); + read_cmd(a, 10); + check(release().data == B({ 0 }) && sock(a).open, "claims: any command claims (READ) -> $25 answers 0"); + fresh(); + a = open_ok(); + run(B({ 0x03, 0x01 })); + check(release().data == B({ 0 }), "claims: even IDENTIFY claims"); + fresh(); + a = open_ok(); + info(a); + check(release().data == B({ 0 }), "claims: INFO on a handle claims"); + fresh(); + a = open_ok(); + r = run(B({ 0x03, 0x25, 0x00 })); + check(r.status == "81,INVALID PARAMS" && info_byte(14) == 1, "claims: `03 25 00` -> 81, claims nothing"); + check(release().data == B({ 1 }), "claims: the corrected $25 still closes it"); + fresh(); + a = open_ok(); + run(B({ 0x03, 0x23, 0xFF, 0x00 })); + check(release().data == B({ 0 }), "claims: `03 23 FF 00` claims"); + fresh(); + a = open_ok(); + run(B({ 0x03, 0x23 })); + check(release().data == B({ 0 }), "claims: `03 23` claims"); + fresh(); + a = open_ok(); + r = run(B({ 0x83, 0x25 })); + check(!sock(a).open, "claims: $25 with the no-reply bit still closes"); + + // $25 spares claimed sessions (S19e2) and TCP sockets. + fresh(); + int t = open_tcp(); + a = open_ok(); + read_cmd(a, 10); + int b = open_ok(); + check(release().data == B({ 1 }) && sock(a).open && !sock(b).open && sock(t).open, + "claims: A claimed, B unclaimed -> $25 closes B only, TCP untouched"); + sock(a).srv.echo = true; + r = write_cmd(a, S("still")); + std::string last; + bytes got = read_all(a, 100, &last, NULL, 5); + check(got == S("still"), "claims: A still echoes"); + // START_TLS creates an unclaimed entry too. + fresh(); + t = open_tcp(); + run(start_cmd(t, 2, 0, "", PIN())); + check(release().data == B({ 1 }) && !sock(t).open, "claims: START_TLS's entry is unclaimed until the next command"); + + // ABORT never closes, frees or claims; does not touch a CA upload. + fresh(); + a = open_ok(); + net.abort(0); + check(sock(a).open && info_byte(14) == 1, "abort: the session stays, and stays unclaimed"); + check(release().data == B({ 1 }), "abort: $25 after an ABORTed OPEN closes it (S19e)"); + fresh(); + world_module.set_ca_result = 0; + run(cat(B({ 0x03, 0x22, 0, 0, 0x64, 0 }), bytes(50, 0x30))); + net.abort(0); + r = run(cat(B({ 0x03, 0x22, 50, 0, 0x64, 0 }), bytes(50, 0x31))); + check(r.status == "00,OK" && world_count(0x35) == 1, "abort: an ABORT between CA chunks does not end the upload"); +} + +// --- TRUST_CA ($22) --------------------------------------------------------------------------- + +static Res chunk(uint16_t offset, uint16_t total, const bytes &data) +{ + return run(cat(B({ 0x03, 0x22, offset & 0xFF, offset >> 8, total & 0xFF, total >> 8 }), data)); +} + +static bool loaded(void) +{ + Res r = info(0xFF); + return (r.data.size() == 16) && (r.data[4] & 0x08); +} + +static void test_ca(void) +{ + printf("TRUST_CA ($22): the Nios's CA state\n"); + fresh(); + world_module.set_ca_result = 0; + bytes der = expected(33, 1400); + Res r = chunk(0, 1400, bytes(der.begin(), der.begin() + 600)); + check(r.status == "00,OK" && r.data.empty(), "ca: first chunk -> 00,OK, empty"); + r = chunk(600, 1400, bytes(der.begin() + 600, der.begin() + 1200)); + check(r.status == "00,OK" && world_count(0x35) == 0, "ca: an intermediate chunk sends nothing"); + r = chunk(1200, 1400, bytes(der.begin() + 1200, der.end())); + check(r.status == "00,OK" && world_count(0x35) == 1 && world_module.ca_der == der, + "ca: final chunk -> SET_CA with all 1400 bytes -> LOADED"); + uint16_t tag = world_module.ca_tag; + check(tag != 0 && loaded(), "ca: INFO bit3 set, ca_tag %u != 0", tag); + world_module.calls.clear(); + int h = open_ok(1); + check(h >= 0 && call_no(0).open.ca_tag == tag, "ca: OPEN CUSTOM carries the ca_tag"); + close_cmd(h); + r = chunk(1200, 1400, bytes(der.begin() + 1200, der.end())); + check(r.status == "81,INVALID PARAMS" && loaded(), "ca: a duplicate final chunk -> 81, still LOADED"); + r = chunk(700, 1473, bytes(10, 1)); + check(r.status == "81,INVALID PARAMS" && loaded(), "ca: total > 1472 at a non-zero offset -> 81, CA untouched"); + r = chunk(0, 1473, bytes()); + check(r.status == "82,PARAMETER(S) OUT OF RANGE" && !loaded(), "ca: offset 0, total 1473 over a LOADED CA -> 82, EMPTY"); + chunk(0, 10, bytes(10, 1)); + uint16_t old_tag = world_module.ca_tag; + check(loaded(), "ca: loaded again"); + world_module.calls.clear(); + chunk(0, 10, bytes(10, 2)); + check(last_call().cmd == 0x35 && last_call().tag != old_tag, "ca: a new upload is sent under a new ca_tag (%u, was %u)", + last_call().tag, old_tag); + r = chunk(0, 1400, bytes(10, 1)); + check(!loaded(), "ca: offset 0 of a new upload drops the CA at once"); + r = run(cat(B({ 0x03, 0x22, 10, 0, 0x78, 0x05 }), bytes(10, 2))); + check(r.status == "81,INVALID PARAMS", "ca: (the INFO above ended that upload) a continuation -> 81"); + + fresh(); + world_module.set_ca_result = 0; + chunk(0, 100, bytes(50, 1)); + info(0xFF); + r = chunk(50, 100, bytes(50, 1)); + check(r.status == "81,INVALID PARAMS" && world_count(0x35) == 0, "ca: chunk, INFO, chunk -> 81, EMPTY (interleave)"); + chunk(0, 100, bytes(50, 1)); + release(); + check(chunk(50, 100, bytes(50, 1)).status == "81,INVALID PARAMS", "ca: $25 ends an upload too"); + chunk(0, 100, bytes(50, 1)); + check(chunk(40, 100, bytes(50, 1)).status == "81,INVALID PARAMS", "ca: a wrong offset -> 81"); + check(chunk(50, 100, bytes(50, 1)).status == "81,INVALID PARAMS", "ca: ... and the upload is gone"); + chunk(0, 100, bytes(50, 1)); + check(chunk(50, 100, bytes(51, 1)).status == "81,INVALID PARAMS", "ca: a chunk past total -> 81"); + check(chunk(0, 0, bytes(3, 1)).status == "81,INVALID PARAMS", "ca: total 0 with data -> 81"); + check(chunk(0, 1473, bytes()).status == "82,PARAMETER(S) OUT OF RANGE", "ca: offset 0, total 1473 -> 82"); + check(run(B({ 0x03, 0x22, 0, 0, 0 })).status == "81,INVALID PARAMS", "ca: 5 bytes -> 81"); + chunk(0, 10, bytes(10, 1)); + check(loaded(), "ca: a one-chunk upload loads"); + uint16_t before = world_module.ca_tag; + check(chunk(0, 0, bytes()).status == "00,OK" && !loaded(), "ca: offset 0 total 0 clears -> EMPTY"); + world_module.calls.clear(); + chunk(0, 10, bytes(10, 1)); + check(last_call().tag != before, "ca: every new upload has a new ca_tag"); + + struct { int result; int err; uint8_t reject; const char *want; } cases[] = { + { WIFI_TLS_REFUSED, -0x2180, 0, "97,CUSTOM CA INVALID: -0x2180" }, + { WIFI_TLS_REFUSED, WIFI_TLS_ESP_INVALID_ARG, 1, "97,CUSTOM CA REJECTED: RSA KEY < 2048" }, + { WIFI_TLS_REFUSED, WIFI_TLS_ESP_INVALID_ARG, 3, "97,CUSTOM CA REJECTED: CURVE" }, + { WIFI_TLS_REFUSED, WIFI_TLS_ESP_INVALID_ARG, 4, "97,CUSTOM CA REJECTED: NOT A CA" }, + { WIFI_TLS_REFUSED, WIFI_TLS_ESP_NOT_SUPPORTED, 0, "90,TLS NOT AVAILABLE" }, + { WIFI_TLS_INVALID, 0, 0, "17,TLS MODULE NOT RESPONDING" }, + { WIFI_TLS_BUSY, 0, 0, "17,TLS MODULE NOT RESPONDING" }, + { WIFI_TLS_NO_MODULE, 0, 0, "90,TLS NOT AVAILABLE" }, + }; + for (unsigned i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) { + fresh(); + world_module.set_ca_result = cases[i].result; + world_module.set_ca_esp_err = cases[i].err; + world_module.set_ca_reject = cases[i].reject; + r = chunk(0, 20, bytes(20, 7)); + check(r.status == cases[i].want && !loaded(), "ca: SET_CA answer %d/%d/%d -> %s, EMPTY (got %s)", + cases[i].result, cases[i].err, cases[i].reject, cases[i].want, r.status.c_str()); + } + fresh(); + world_module.available = false; + r = chunk(0, 20, bytes(20, 7)); + check(r.status == "90,TLS NOT AVAILABLE", "ca: no module at the final chunk -> 90"); +} + +// --- c64_reset, run_prg and module restarts --------------------------------------------- + +static void test_cleanup(void) +{ + printf("Cleanup: C64 reset and module restart (S14)\n"); + fresh(); + world_module.set_ca_result = 0; + chunk(0, 10, bytes(10, 1)); + int a = open_ok(1), b = open_ok(0); + world_module.calls.clear(); + net.c64_reset(); + check(!sock(a).open && !sock(b).open, "reset: both TLS sockets closed"); + check(world_module.close_alls == 1, "reset: CLOSE_ALL once"); + Res r = info(0xFF); + check(at(r, 2) == 0 && !(at(r, 4) & 0x08), "reset: no entries, CA bit clear"); + world_module.ca_loaded = true; // CLOSE_ALL lost: the module still has the old CA + world_module.calls.clear(); + r = run(open_cmd(1, 0, "example.com")); + check(r.status == "97,NO CUSTOM CA" && world_module.calls.empty(), "reset: OPEN CUSTOM -> 97, even if CLOSE_ALL was lost"); + a = open_ok(0); + check(a >= 0 && last_call().slot <= 1, "reset: the table is usable again"); + + fresh(); + world_module.set_ca_result = 0; + chunk(0, 10, bytes(10, 1)); + a = open_ok(); + world_module.generation++; + r = read_cmd(a, 10); + check(header(r) == 0 && r.status == "17,TLS MODULE NOT RESPONDING", "restart: a new generation -> $0000 + 17"); + check(!loaded(), "restart: the CA is EMPTY"); + world_module.calls.clear(); + check(close_cmd(a).status == "00,OK" && world_count(0x32) == 0 && !sock(a).open, + "restart: CLOSE sends no RPC and closes the socket"); +} + +// Every TLS status line is at most 40 bytes. The longest +// templates, with the widest values each field can take (a 3-digit newlib +// errno, 4 hex digits of mbedTLS code, 8 of flags). +static void test_status_lengths(void) +{ + printf("Status lines: at most 40 bytes\n"); + const int E = 999; + const uint8_t N = WIFI_TLS_ALERT_NONE; + fresh(); + world_socks[0].srv.on_hello = SRV_RST; + world_socks[0].srv.rst_err = E; + Res r = run(open_cmd(0, 0, "example.com")); + check(r.status == "13,TLS HANDSHAKE FAILED: PEER RESET: 999" && r.status.size() == 40, + "status cap: '%s' is %d bytes", r.status.c_str(), (int)r.status.size()); + fresh(); + world_socks[0].srv.send_err = E; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "13,TLS HANDSHAKE FAILED: SEND ERROR: 999" && r.status.size() == 40, + "status cap: '%s' is %d bytes (SEND ERROR wording, 3-digit errno)", r.status.c_str(), (int)r.status.size()); + expect_fail(0, 4, 0xFFFFFFFE, N, -0x2700, "94,CERTIFICATE NAME MISMATCH: 0xFFFFFFFE", "widest 94"); + expect_fail(0, 4, 0xFFFFFFFF, N, -0x2700, "93,CERTIFICATE NOT TRUSTED: 0xFFFFFFFF", "widest 93"); + expect_fail(0, 4, 0xFFFFFFFB, N, -0x2700, "95,CERTIFICATE EXPIRED: 0xFFFFFFFB", "widest 95"); + expect_fail(0, 0, 0, N, -0xFFFF, "13,TLS HANDSHAKE FAILED: -0xFFFF", "widest 13"); + expect_fail(0, 0, 0, 254, -0x7780, "14,TLS ALERT RECEIVED: 254", "widest 14 (255 means none)"); + expect_fail(0, 1, 0xFFFF, N, -0x7700, "18,TLS VERSION REFUSED: 0xFFFF", "widest 18"); + fresh(); + world_socks[0].srv.connect_err = E; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "11,ERROR ON CONNECT: 999", "status cap: %s", r.status.c_str()); + fresh(); + int h = open_ok(); + server_push(h, EV_ERR, bytes(), E); + r = read_cmd(h, 10); + check(r.status == "12,RECEIVE ERROR: 999", "status cap: %s", r.status.c_str()); + fresh(); + h = open_ok(); + sock(h).send_err = E; + r = write_cmd(h, S("x")); + check(r.status == "12,SEND ERROR: 999", "status cap: %s", r.status.c_str()); + fresh(); + world_module.set_ca_result = WIFI_TLS_REFUSED; + world_module.set_ca_esp_err = -0xFFFF; + r = chunk(0, 5, bytes(5, 1)); + check(r.status == "97,CUSTOM CA INVALID: -0xFFFF", "status cap: %s", r.status.c_str()); + world_module.set_ca_esp_err = WIFI_TLS_ESP_INVALID_ARG; + world_module.set_ca_reject = 1; + r = chunk(0, 5, bytes(5, 1)); + check(r.status == "97,CUSTOM CA REJECTED: RSA KEY < 2048", "status cap: %s", r.status.c_str()); + fresh(); + h = open_ok(); + server_push(h, EV_DATA, record('B', 10)); + r = read_cmd(h, 10); + check(r.status.compare(0, 23, "16,TLS SESSION FAILED: ") == 0, "status cap: %s", r.status.c_str()); +} + +// A READ on a TLS handle refused before any data (81 wrong +// length, 82 maxlen) has an EMPTY reply, which reads as $00 $00, and changes +// nothing. +static void test_empty_read_reply(void) +{ + printf("READ refusals on a TLS handle: an empty reply, the handle unchanged\n"); + fresh(); + int h = open_ok(); + server_push(h, EV_DATA, record('D', 30, 13)); + Res r = run(B({ 0x03, 0x10, h, 10 })); + check(r.status == "81,INVALID PARAMS" && r.data.empty(), "empty reply: a 4-byte READ -> 81, empty reply"); + r = run(B({ 0x03, 0x10, h, 10, 0, 0 })); + check(r.status == "81,INVALID PARAMS" && r.data.empty(), "empty reply: a 6-byte READ -> 81, empty reply"); + r = read_cmd(h, 0); + check(r.status == "82,PARAMETER(S) OUT OF RANGE" && r.data.empty(), "empty reply: maxlen 0 -> 82, empty reply"); + r = read_cmd(h, 1473); + check(r.status == "82,PARAMETER(S) OUT OF RANGE" && r.data.empty(), "empty reply: maxlen 1473 -> 82, empty reply"); + std::string last; + bytes got = read_all(h, 1472, &last, NULL, 5); + check(got == expected(13, 30) && sock(h).open, "empty reply: the handle is unchanged; its data still arrives"); +} + + +// --- edge cases: latch, STATS cache, drain, WRITE budget, send failures ------------------------- +static void test_edge_cases(void) +{ + printf("Edge cases: latch, STATS cache, drain, WRITE budget, send failures\n"); + const std::string rst = "12,RECEIVE ERROR: " + num(ECONNRESET); + std::string last; + + // A close_notify found by the drain BEFORE the WRITE, with plaintext + // still in rx. The WRITE reports the latched 12; the end must then be that 12, never 01/GONE. + fresh(); + int h = open_ok(); + FakeSession &s = world_module.sess[0]; + for (size_t i = 0; i < 500; i++) { + s.pt.push_back(payload_byte(21, i)); + } + s.terminal = 'C'; + server_push(h, EV_ERR, bytes(), ECONNRESET); + Res r = read_cmd(h, 100); // latches; the step hands out 500 B AND CLOSED + bytes all = body(r); + r = write_cmd(h, S("ping")); + check(header(r) == 0xFFFF && r.status == rst, "latch (c): WRITE while latched -> $FFFF + %s (got %s)", + rst.c_str(), r.status.c_str()); + bytes got = read_all(h, 100, &last, NULL, 50); + all.insert(all.end(), got.begin(), got.end()); + check(all == expected(21, 500), "latch (c): every byte delivered (%d of 500)", (int)all.size()); + check(last == rst && sock(h).open, + "latch (c): after a WRITE said 12, the end is that 12 and the handle is still owned (got '%s', socket %s)", + last.c_str(), sock(h).open ? "open" : "CLOSED"); + + // The STATS cache is cleared only on NO_MODULE, NOT_SUPPORTED or a new + // generation. The ESP32 answers a STATS that finds the TLS queue full with a full-size reply, + // esp_err ESP_ERR_TIMEOUT (rpc_dispatch.c cmd_tls_busy), which take_stats makes REFUSED. + fresh(); + info(0xFF); + world_module.stats_result = WIFI_TLS_REFUSED; // cmd_tls_busy's full-size reply + world_module.stats_esp_err = 0x107; // ESP_ERR_TIMEOUT + r = info(0xFF); + world_module.stats_result = -1; + world_module.stats_esp_err = 0; + check((at(r, 4) & 0x01) == 0x01, + "info (cache): a STATS refused with ESP_ERR_TIMEOUT (TLS queue full = a timeout) keeps b0 (b4=0x%02X)", at(r, 4)); + + // The drain ends after TWO CONSECUTIVE quiet steps, not two per READ. With + // every step taking 260 ms (> READ_BUDGET 250 ms), each READ gets one step in. + fresh(); + h = open_ok(); + server_push(h, EV_ERR, bytes(), ECONNRESET); + for (int i = 0; i < 60; i++) { + Forced f = Forced(); + f.result = 0; + f.delay_ms = 260; + world_module.forced.push_back(f); + } + int reads = 0; + std::string st; + for (reads = 1; reads <= 20; reads++) { + r = read_cmd(h, 100); + st = r.status; + if (header(r) != 0xFFFF) { + break; + } + } + world_module.forced.clear(); + check(st == rst, "latch: a peer RST with slow (260 ms) steps ends in %s within 20 READs (got '%s' after %d)", + rst.c_str(), st.c_str(), reads > 20 ? 20 : reads); + + // A WRITE ends with a step that returns no + // ciphertext, so 892 B is exactly 2 NO_READ steps; within WRITE_BUDGET 4 that leaves room for 2 + // AGAINs, and a third makes the WRITE a sticky 17, never a partial count. + fresh(); + h = open_ok(); + bytes data = expected(12, 892); + world_module.calls.clear(); + r = write_cmd(h, data); + check(header(r) == 892 && steps_logged() == 2 && last_call().pt_in_len == 0, + "write: 892 B is 2 steps, the last input-less (got %04X, %d steps)", header(r), steps_logged()); + fresh(); + h = open_ok(); + world_module.again_next = 2; + r = write_cmd(h, data); + check(header(r) == 892 && r.status == "00,OK" && sock(h).srv.got == data, + "write: 892 B after 2 AGAINs is 4 steps -> 892, 00,OK (got %04X %s)", header(r), r.status.c_str()); + fresh(); + h = open_ok(); + world_module.again_next = 3; + r = write_cmd(h, data); + check(header(r) == 0xFFFF && r.status == "17,TLS MODULE NOT RESPONDING", + "write: 892 B after 3 AGAINs runs out of WRITE_BUDGET -> $FFFF + sticky 17 (got %04X %s)", header(r), + r.status.c_str()); + + // A send failure during the handshake is a 13; 12 is for READ and WRITE only. + fresh(); + int t = open_tcp(); + sock(t).send_err = ECONNRESET; + r = run(start_cmd(t, 2, 0, "", PIN())); + check(r.status == "13,TLS HANDSHAKE FAILED: SEND ERROR: " + num(ECONNRESET) && !sock(t).open, + "start: START_TLS whose ClientHello send meets an RST -> 13 SEND ERROR: errno, handle closed " + "(got '%s', handle %s)", r.status.c_str(), sock(t).open ? "open" : "closed"); + fresh(); + world_socks[0].srv.send_err = EPIPE; // OPEN_TLS: the new socket's first send fails + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "13,TLS HANDSHAKE FAILED: SEND ERROR: " + num(EPIPE) && world_open_sockets() == 0 && + world_count(0x32) == 1, "open: OPEN_TLS whose ClientHello send fails -> 13 SEND ERROR: errno, CLOSE RPC (got '%s')", + r.status.c_str()); + + // 17 is not a kept code. The module's queue-full answer to OPEN (esp_err + // ESP_ERR_TIMEOUT, reason 0) is a REFUSED 17: START_TLS must close the TCP handle. + fresh(); + t = open_tcp(); + world_module.open_result = WIFI_TLS_REFUSED; + world_module.open_esp_err = 0x107; + world_module.open_reason = 0; + r = run(start_cmd(t, 2, 0, "", PIN())); + world_module.open_result = -1; + check(r.status == "17,TLS MODULE NOT RESPONDING" && !sock(t).open, + "start: START_TLS refused by a busy module -> 17 and the TCP handle is closed (got '%s', %s)", + r.status.c_str(), sock(t).open ? "open" : "closed"); +} + +// Send failures late in the handshake, NO_MODULE from STATS, and a module failure in the drain +// after a WRITE's 12. +static void test_late_send_failures(void) +{ + printf("Late handshake send failures, STATS NO_MODULE, a drain failure after a WRITE\n"); + Res r; + + // A STATS call that finds the module application gone (NO_MODULE, the race with + // wifi_tls_module_available()) clears the cache. + fresh(); + info(0xFF); + world_module.stats_result = WIFI_TLS_NO_MODULE; + r = info(0xFF); + world_module.stats_result = WIFI_TLS_BUSY; + Res r2 = info(0xFF); + world_module.stats_result = -1; + check(!(at(r, 4) & 1) && !(at(r2, 4) & 1), "info (cache): NO_MODULE from STATS clears b0, and it stays 0 (b4=0x%02X, 0x%02X)", + at(r, 4), at(r2, 4)); + + // The Finished's send fails (the 2nd send of the handshake) -> 13 SEND ERROR, never 12, + // never 00,OK. + fresh(); + world_socks[0].srv.send_err_from = 2; + world_socks[0].srv.send_err_late = ECONNRESET; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "13,TLS HANDSHAKE FAILED: SEND ERROR: " + num(ECONNRESET) && world_open_sockets() == 0, + "open: OPEN whose Finished send meets an RST -> 13 SEND ERROR (got '%s')", r.status.c_str()); + fresh(); + int t = open_tcp(); + sock(t).srv.send_err_from = sock(t).send_calls + 2; + sock(t).srv.send_err_late = EPIPE; + r = run(start_cmd(t, 2, 0, "", PIN())); + check(r.status == "13,TLS HANDSHAKE FAILED: SEND ERROR: " + num(EPIPE) && !sock(t).open, + "start: START whose Finished send fails -> 13 SEND ERROR, handle closed (got '%s')", r.status.c_str()); + + // A ClientHello send stalled for SEND_MS, well before the handshake deadline -> + // 13 SEND ERROR: ETIMEDOUT (116 on the Nios); a Finished send stalled into the deadline -> 15. + fresh(); + world_socks[0].srv.send_err_from = 1; + world_socks[0].srv.send_err_late = EWOULDBLOCK; + uint32_t t0 = world_ms(); + r = run(open_cmd(0, 0, "example.com")); + uint32_t spent = world_ms() - t0; + check(r.status == "13,TLS HANDSHAKE FAILED: SEND ERROR: " + num(ETIMEDOUT) && spent >= 5000 && spent < 6000, + "open: a stalled ClientHello send -> 13 SEND ERROR: ETIMEDOUT after SEND_MS (got '%s', %u ms)", + r.status.c_str(), spent); + fresh(); + world_socks[0].srv.delay_ms = 12000; + world_socks[0].srv.send_err_from = 2; + world_socks[0].srv.send_err_late = EWOULDBLOCK; + r = run(open_cmd(0, 0, "example.com")); + check(r.status == "15,TLS HANDSHAKE TIMEOUT", "open: a Finished send stalled into the handshake deadline -> 15 (got '%s')", + r.status.c_str()); + + // Pinned as the current behaviour: after a WRITE has reported the latched 12, a module + // failure in the drain (here a malformed step) ends in a sticky 17, not 12; the handle stays owned. + fresh(); + int h = open_ok(); + for (size_t i = 0; i < 1200; i++) { + world_module.sess[0].pt.push_back(payload_byte(21, i)); + } + server_push(h, EV_ERR, bytes(), ECONNRESET); + read_cmd(h, 1); + r = write_cmd(h, S("ping")); + check(r.status == "12,RECEIVE ERROR: " + num(ECONNRESET), "latch: setup: the WRITE reports the latched 12"); + Forced f = Forced(); + f.result = WIFI_TLS_INVALID; + world_module.forced.push_back(f); + std::string last; + read_all(h, 1472, &last, NULL, 50); + r = read_cmd(h, 10); + check(last == "17,TLS MODULE NOT RESPONDING" && header(r) == 0 && r.status == last && sock(h).open, + "latch: a module failure in the drain after the WRITE's 12 -> sticky 17, handle still owned (got '%s')", + last.c_str()); + check(close_cmd(h).status == "00,OK" && !sock(h).open, "latch: CLOSE -> 00,OK"); +} + +int main(int argc, char **argv) +{ + setvbuf(stdout, NULL, _IOLBF, 0); + test_info(); + test_open(); + test_grammar(); + test_precedence(); + test_classify(); + test_dns_connect(); + test_reset_during_open(); + test_start_tls(); + test_read(); + test_write(); + test_close(); + test_latch(); + test_claims(); + test_ca(); + test_cleanup(); + test_status_lengths(); + test_empty_read_reply(); + test_edge_cases(); + test_late_send_failures(); + check(longest_status.size() <= 40, "status cap: the longest status of the whole run is %d bytes: '%s'", + (int)longest_status.size(), longest_status.c_str()); + printf("\n%d checks, %d failures\n", checks, failures); + return failures ? 1 : 0; +} diff --git a/software/test/wifi_tls/net_world.cc b/software/test/wifi_tls/net_world.cc new file mode 100644 index 000000000..85482507f --- /dev/null +++ b/software/test/wifi_tls/net_world.cc @@ -0,0 +1,970 @@ +/* + * net_world.cc: see net_world.h. + */ +#include +#include +#include +#include "net_world.h" +#include "wifi_random.h" +#include "FreeRTOS.h" +#include "task.h" +#include "socket.h" +#include "netdb.h" +#include "lwip/dns.h" +#include "lwip/tcpip.h" +#include "command_intf.h" +#include "sntp_time.h" + +uint32_t world_tick; +uint32_t world_reset_at; +FakeSock world_socks[16]; +std::vector world_dns; +int world_dns_calls; +int world_dns_unlocked_calls; +int world_dns_late_writes; +int world_lock_depth; +int world_lock_bad; +FakeModule world_module; +uint32_t world_sntp; + +CommandInterface cmd_if; +CommandTarget *command_targets[CMD_IF_MAX_TARGET + 1]; +Message c_status_ok = { 5, true, (uint8_t *)"00,OK" }; +Message c_status_unknown_command = { 18, true, (uint8_t *)"21,UNKNOWN COMMAND" }; +Message c_message_empty = { 0, true, (uint8_t *)"" }; +Message c_message_no_target = { 9, true, (uint8_t *)"NO TARGET" }; + +#define MS_TICKS(ms) (((ms) + 4) / 5) + +struct PendingDns { + uint32_t at; + std::string name; + bool ok; + ip_addr_t addr; + dns_found_callback cb; + void *arg; +}; +static std::vector pending_dns; + +static void fire_dns(bool all) +{ + for (size_t i = 0; i < pending_dns.size();) { + if (all || ((int32_t)(world_tick - pending_dns[i].at) >= 0)) { + PendingDns p = pending_dns[i]; + pending_dns.erase(pending_dns.begin() + i); + if (world_lock_depth) { + world_lock_bad++; + } + p.cb(p.name.c_str(), p.ok ? &p.addr : NULL, p.arg); + } else { + i++; + } + } +} + +void world_dns_fire_all(void) +{ + fire_dns(true); +} + +void world_advance(uint32_t ticks) +{ + world_tick += ticks; + fire_dns(false); +} + +uint32_t world_ms(void) +{ + return world_tick * 5; +} + +uint8_t payload_byte(uint32_t seed, uint32_t i) +{ + return (uint8_t)(((seed + i) * 2654435761u) >> 24); +} + +bytes record(char type, size_t length, uint32_t seed) +{ + bytes r; + r.push_back((uint8_t)type); + r.push_back((uint8_t)length); + r.push_back((uint8_t)(length >> 8)); + for (size_t i = 0; i < length; i++) { + r.push_back(payload_byte(seed, i)); + } + return r; +} + +void server_push(int s, int kind, const bytes &data, int err, uint32_t after_ms) +{ + if ((s < 0) || (s >= 16)) { + return; // no such socket (a red run) + } + SockEvent e; + e.kind = kind; + e.data = data; + e.err = err; + e.at = world_tick + MS_TICKS(after_ms); + world_socks[s].rx.push_back(e); +} + +void world_reset(void) +{ + world_tick = 1000; + world_reset_at = 0xFFFFFFFF; + for (int i = 0; i < 16; i++) { + world_socks[i] = FakeSock(); + world_socks[i].srv.saw_alert = -1; + world_socks[i].srv.flight = 2000; + world_socks[i].srv.delay_ms = 20; + world_socks[i].srv.chunk = 1460; + } + world_dns.clear(); + pending_dns.clear(); + world_dns_calls = 0; + world_dns_unlocked_calls = 0; + world_dns_late_writes = 0; + world_lock_depth = 0; + world_lock_bad = 0; + world_module = FakeModule(); + FakeModule &m = world_module; + m.available = true; + m.major = 1; + m.minor = 306; + m.generation = 7; + m.entropy = true; + m.module_time = true; + m.open_result = -1; + m.hello_size = 300; + m.version = 0x0304; + m.suite = 0x1301; + m.group = 0x001D; + for (int i = 0; i < 32; i++) { + m.spki[i] = (uint8_t)(0xA0 + i); + } + m.block_max_ms = 12; + m.stats_result = -1; + m.close_result = -1; + m.in_cap = 18000; // mbedTLS reads a whole record, up to 16 KB + world_sntp = 1790000000u; // 2026 +} + +int world_count(int cmd) +{ + int n = 0; + for (size_t i = 0; i < world_module.calls.size(); i++) { + n += (world_module.calls[i].cmd == cmd); + } + return n; +} + +int world_open_sockets(void) +{ + int n = 0; + for (int i = 0; i < 16; i++) { + n += world_socks[i].open; + } + return n; +} + +// --- FreeRTOS, the command interface, SNTP --------------------------------- + +TickType_t xTaskGetTickCount(void) +{ + return world_tick; +} + +void vTaskDelay(TickType_t ticks) +{ + world_advance(ticks ? ticks : 1); +} + +bool CommandInterface :: reset_pending(void) +{ + return (world_reset_at != 0xFFFFFFFF) && ((int32_t)(world_tick - world_reset_at) >= 0); +} + +uint32_t sntp_utc_now(void) +{ + return world_sntp; +} + +// --- DNS and the core lock -------------------------------------------------- + +void fake_lock_tcpip_core(void) +{ + world_lock_depth++; +} + +void fake_unlock_tcpip_core(void) +{ + world_lock_depth--; +} + +err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr, dns_found_callback found, void *callback_arg) +{ + world_dns_calls++; + if (!world_lock_depth) { + world_dns_unlocked_calls++; + } + if (ip4addr_aton(hostname, addr)) { + return ERR_OK; + } + DnsRule rule = { hostname, DNS_ASYNC_OK, htonl(0x0A000002), 20 }; + for (size_t i = 0; i < world_dns.size(); i++) { + if (world_dns[i].host == hostname) { + rule = world_dns[i]; + } + } + switch (rule.mode) { + case DNS_IMMEDIATE: + addr->addr = rule.addr; + return ERR_OK; + case DNS_ERR_VAL: + return ERR_VAL; + case DNS_NEVER: + return ERR_INPROGRESS; + default: { + PendingDns p; + p.at = world_tick + MS_TICKS(rule.delay_ms); + p.name = hostname; + p.ok = (rule.mode == DNS_ASYNC_OK); + p.addr.addr = rule.addr; + p.cb = found; + p.arg = callback_arg; + pending_dns.push_back(p); + return ERR_INPROGRESS; + } + } +} + +// --- sockets ------------------------------------------------------------------ + +static bool valid(int s) +{ + return (s >= 0) && (s < 16) && world_socks[s].open; +} + +int lwip_socket(int domain, int type, int protocol) +{ + for (int s = 0; s < 16; s++) { + if (!world_socks[s].open) { + FakeServer srv = world_socks[s].srv; // what the test set up for this number + world_socks[s] = FakeSock(); + world_socks[s].srv = srv; + world_socks[s].open = true; + world_socks[s].type = type; + return s; + } + } + errno = ENFILE; + return -1; +} + +int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen) +{ + if (!valid(s)) { + errno = EBADF; + return -1; + } + FakeSock &k = world_socks[s]; + FakeServer &v = k.srv; + k.connect_addr = ((const struct sockaddr_in *)name)->sin_addr.s_addr; + if (k.connected) { + errno = EISCONN; + return -1; + } + if (!k.nonblocking) { + if (v.connect_err) { + errno = v.connect_err; + return -1; + } + k.connected = true; + return 0; + } + if (!k.connect_at) { + k.connect_at = world_tick + MS_TICKS(v.connect_delay_ms ? v.connect_delay_ms : 10); + errno = EINPROGRESS; + return -1; + } + if (v.connect_never || ((int32_t)(world_tick - k.connect_at) < 0)) { + errno = EALREADY; + return -1; + } + if (v.connect_err) { + errno = v.connect_err; + return -1; + } + k.connected = true; + errno = EISCONN; + return -1; +} + +int lwip_ioctl(int s, long cmd, void *argp) +{ + if (!valid(s)) { + errno = EBADF; + return -1; + } + if (cmd == (long)FIONBIO) { + world_socks[s].nonblocking = *(int *)argp != 0; + } + return 0; +} + +int lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) +{ + if (!valid(s)) { + errno = EBADF; + return -1; + } + if ((level == IPPROTO_TCP) && (optname == TCP_NODELAY)) { + world_socks[s].nodelay = *(const int *)optval != 0; + } + if ((level == SOL_SOCKET) && (optname == SO_RCVTIMEO)) { + world_socks[s].rcvtimeo_set = true; + } + if ((level == SOL_SOCKET) && (optname == SO_SNDTIMEO)) { + const struct timeval *tv = (const struct timeval *)optval; + world_socks[s].sndtimeo_ms = tv->tv_sec * 1000 + tv->tv_usec / 1000; + } + return 0; +} + +int lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) +{ + if (!valid(s)) { + errno = EBADF; + return -1; + } + if ((level == SOL_SOCKET) && (optname == SO_TYPE)) { + *(int *)optval = world_socks[s].type; + *optlen = sizeof(int); + return 0; + } + errno = ENOPROTOOPT; + return -1; +} + +static bool available(FakeSock &k) +{ + return !k.rx.empty() && ((int32_t)(world_tick - k.rx.front().at) >= 0); +} + +// The server's side: what the module sent, record by record. +static void server_hears(int s) +{ + FakeSock &k = world_socks[s]; + FakeServer &v = k.srv; + while (v.client_stream.size() >= 3) { + size_t len = v.client_stream[1] | (v.client_stream[2] << 8); + if (v.client_stream.size() < 3 + len) { + break; + } + char type = (char)v.client_stream[0]; + bytes body(v.client_stream.begin() + 3, v.client_stream.begin() + 3 + len); + v.client_stream.erase(v.client_stream.begin(), v.client_stream.begin() + 3 + len); + if (type == 'H') { + v.hellos++; + if (v.on_hello == SRV_RESPOND) { + bytes flight = record('H', v.flight, 77); + for (size_t off = 0; off < flight.size(); off += v.chunk) { + size_t n = flight.size() - off; + if (n > v.chunk) { + n = v.chunk; + } + server_push(s, EV_DATA, bytes(flight.begin() + off, flight.begin() + off + n), 0, v.delay_ms); + } + } else if (v.on_hello == SRV_RST) { + server_push(s, EV_ERR, bytes(), v.rst_err ? v.rst_err : ECONNRESET, v.delay_ms); + } else if (v.on_hello == SRV_FIN) { + server_push(s, EV_FIN, bytes(), 0, v.delay_ms); + } + } else if (type == 'F') { + for (size_t i = 0; i < v.after_finished.size(); i++) { + SockEvent e = v.after_finished[i]; + e.at += world_tick; + k.rx.push_back(e); + } + } else if (type == 'D') { + v.got.insert(v.got.end(), body.begin(), body.end()); + if (v.echo) { + bytes r = body; + r.insert(r.begin(), (uint8_t)(len >> 8)); + r.insert(r.begin(), (uint8_t)len); + r.insert(r.begin(), (uint8_t)'D'); + server_push(s, EV_DATA, r, 0, 5); + } + } else if (type == 'C') { + v.saw_notify = true; + } else if (type == 'A') { + v.saw_alert = body.empty() ? 0 : body[0]; + } + } +} + +ssize_t lwip_send(int s, const void *dataptr, size_t size, int flags) +{ + if (!valid(s)) { + errno = EBADF; + return -1; + } + FakeSock &k = world_socks[s]; + k.send_calls++; + if (k.srv.send_err_from && (k.send_calls >= k.srv.send_err_from)) { + if (k.srv.send_err_late == EWOULDBLOCK) { + k.send_blocked = true; // from here on, a stall (select advances the clock) + } + errno = k.srv.send_err_late; + return -1; + } + if (k.send_err || k.srv.send_err) { + errno = k.send_err ? k.send_err : k.srv.send_err; + return -1; + } + if (k.send_blocked) { + errno = EWOULDBLOCK; + return -1; + } + const uint8_t *p = (const uint8_t *)dataptr; + k.tx.insert(k.tx.end(), p, p + size); + if (k.type == SOCK_STREAM) { + k.srv.client_stream.insert(k.srv.client_stream.end(), p, p + size); + server_hears(s); + } + return size; +} + +ssize_t lwip_recv(int s, void *mem, size_t len, int flags) +{ + if (!valid(s)) { + errno = EBADF; + return -1; + } + FakeSock &k = world_socks[s]; + k.recv_calls++; + if (k.err_taken) { + k.recv_after_err++; + errno = ENOTCONN; // lwIP's errno changes on later calls + return -1; + } + if (!available(k)) { + if (!(flags & MSG_DONTWAIT) && !k.nonblocking) { + world_advance(8); // SO_RCVTIMEO 40 ms + if (available(k)) { + return lwip_recv(s, mem, len, flags); + } + } + errno = EWOULDBLOCK; + return -1; + } + SockEvent &e = k.rx.front(); + if (e.kind == EV_FIN) { + return 0; // and again on every later call + } + if (e.kind == EV_ERR) { + k.err_taken = true; + errno = e.err; + return -1; + } + size_t n = (e.data.size() < len) ? e.data.size() : len; + memcpy(mem, e.data.data(), n); + e.data.erase(e.data.begin(), e.data.begin() + n); + if (e.data.empty()) { + k.rx.pop_front(); + } + return n; +} + +ssize_t lwip_recvmsg(int s, struct msghdr *message, int flags) +{ + return lwip_recv(s, message->msg_iov[0].iov_base, message->msg_iov[0].iov_len, flags); +} + +int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout) +{ + int s = maxfdp1 - 1; + uint32_t wait = MS_TICKS(timeout->tv_sec * 1000 + timeout->tv_usec / 1000); + if (wait == 0) { + wait = 1; + } + if (!valid(s)) { + errno = EBADF; + return -1; + } + FakeSock &k = world_socks[s]; + if (writeset) { + if (k.send_blocked) { + world_advance(wait); + return 0; + } + if (k.nonblocking && !k.connected && k.connect_at) { + if (k.srv.connect_never) { + world_advance(wait); + return 0; + } + int32_t d = (int32_t)(k.connect_at - world_tick); + if (d > (int32_t)wait) { + world_advance(wait); + return 0; + } + if (d > 0) { + world_advance(d); + } + } + return 1; + } + if (available(k)) { + return 1; + } + if (!k.rx.empty()) { + uint32_t d = k.rx.front().at - world_tick; + if (d <= wait) { + world_advance(d); + return 1; + } + } + world_advance(wait); + return 0; +} + +int lwip_close(int s) +{ + if (!valid(s)) { + errno = EBADF; + return -1; + } + world_socks[s].open = false; + world_socks[s].closes++; + return 0; +} + +int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, + int *h_errnop) +{ + static struct in_addr address; + static char *list[2]; + address.s_addr = htonl(0x0A000009); + list[0] = (char *)&address; + list[1] = NULL; + ret->h_addr_list = list; + *result = ret; + return 0; +} + +// --- the WiFi module ------------------------------------------------------------ + +bool wifi_tls_module_available(void) +{ + return world_module.available; +} + +void wifi_tls_module_version(uint16_t *major, uint16_t *minor) +{ + *major = world_module.major; + *minor = world_module.minor; +} + +uint32_t wifi_tls_generation(void) +{ + return world_module.generation; +} + +// Waits as wifi_dedicated_call does: in slices when there is a cancel. The +// answer comes after answer_ms; true when it came before the timeout and +// before a cancel. +static bool module_wait(uint32_t timeout_ms, const wifi_tls_cancel_t *cancel, uint32_t answer_ms, bool *cancelled) +{ + *cancelled = false; + uint32_t spent = 0; + while (true) { + if (answer_ms <= spent) { + world_advance(1); + return true; + } + if (spent >= timeout_ms) { + return false; + } + uint32_t slice = timeout_ms - spent; + if (cancel && (slice > 100)) { + slice = 100; + } + if (answer_ms - spent < slice) { + world_advance(MS_TICKS(answer_ms - spent)); + return true; + } + world_advance(MS_TICKS(slice)); + spent += slice; + if (cancel && cancel->cancelled(cancel->context)) { + *cancelled = true; + return false; + } + } +} + +static RpcCall &log_call(int cmd, uint8_t slot, uint16_t tag, const wifi_tls_cancel_t *cancel) +{ + RpcCall c = RpcCall(); + c.cmd = cmd; + c.slot = slot; + c.tag = tag; + c.cancel_given = (cancel != NULL); + world_module.calls.push_back(c); + return world_module.calls.back(); +} + +static bool unsent(void) +{ + if (world_module.unsent_next > 0) { + world_module.unsent_next--; + return true; + } + return false; +} + +int wifi_tls_open(const wifi_tls_open_t *open, uint32_t timeout_ms, const wifi_tls_cancel_t *cancel, int *esp_err, + uint8_t *reason) +{ + FakeModule &m = world_module; + *esp_err = 0; + *reason = 0; + if (!m.available) { + return WIFI_TLS_NO_MODULE; + } + if (unsent()) { + return WIFI_TLS_UNSENT; + } + RpcCall &c = log_call(0x30, open->slot, open->tag, cancel); + c.open = *open; + c.sni.assign(open->sni ? open->sni : "", open->sni_len); + if (open->pin) { + c.pin.assign(open->pin, open->pin + 32); + } + bool cancelled; + if (!module_wait(timeout_ms, cancel, m.open_delay_ms, &cancelled)) { + return WIFI_TLS_BUSY; + } + if (m.open_result >= 0) { + *esp_err = m.open_esp_err; + *reason = m.open_reason; + return m.open_result; + } + if (!m.entropy) { + *esp_err = WIFI_TLS_ESP_INVALID_STATE; + *reason = WIFI_TLS_REASON_NO_ENTROPY; + return WIFI_TLS_REFUSED; + } + if ((open->trust != WIFI_TLS_TRUST_PIN) && !m.module_time && (open->time_source == WIFI_TLS_TIME_NONE)) { + *esp_err = WIFI_TLS_ESP_INVALID_STATE; + *reason = WIFI_TLS_REASON_NO_TIME; + return WIFI_TLS_REFUSED; + } + if ((open->trust == WIFI_TLS_TRUST_CUSTOM) && (!m.ca_loaded || (m.ca_tag != open->ca_tag))) { + *esp_err = WIFI_TLS_ESP_INVALID_STATE; + *reason = WIFI_TLS_REASON_NO_CUSTOM_CA; + return WIFI_TLS_REFUSED; + } + FakeSession &s = m.sess[open->slot]; + s = FakeSession(); // a slot held under another tag is freed first + s.live = true; + s.tag = open->tag; + s.trust = open->trust; + s.state = WIFI_TLS_HANDSHAKING; + return 0; +} + +static void emit(bytes &out, char type, const uint8_t *p, size_t n) +{ + out.push_back((uint8_t)type); + out.push_back((uint8_t)n); + out.push_back((uint8_t)(n >> 8)); + out.insert(out.end(), p, p + n); +} + +static void parse_in(FakeSession &s, wifi_tls_step_t *st) +{ + FakeModule &m = world_module; + while ((s.in.size() >= 3) && !s.terminal && (s.state != WIFI_TLS_FAILED)) { + size_t len = s.in[1] | (s.in[2] << 8); + if (s.in.size() < 3 + len) { + break; + } + char type = (char)s.in[0]; + bytes body(s.in.begin() + 3, s.in.begin() + 3 + len); + s.in.erase(s.in.begin(), s.in.begin() + 3 + len); + if (s.state == WIFI_TLS_HANDSHAKING) { + if (type != 'H') { + continue; + } + if (m.hs_fail) { + s.state = WIFI_TLS_FAILED; + st->fail_reason = m.hs_fail_reason; + st->verify_flags = m.hs_verify_flags; + st->alert_in = m.hs_alert_in; + st->esp_err = m.hs_fail_err; + if (m.hs_alert_out) { + uint8_t a = 40; + emit(s.out, 'A', &a, 1); + } + return; + } + s.state = WIFI_TLS_ESTABLISHED; + bytes fin = record('F', 32); + s.out.insert(s.out.end(), fin.begin(), fin.end()); + continue; + } + if (type == 'D') { + s.pt.insert(s.pt.end(), body.begin(), body.end()); + } else if ((type == 'C') || (type == 'B')) { + s.terminal = type; + } else if (type == 'A') { + s.terminal = 'A'; + s.alert = body.empty() ? 0 : body[0]; + } + } +} + +int wifi_tls_step(uint8_t slot, uint16_t tag, wifi_tls_step_t *st, uint32_t timeout_ms, + const wifi_tls_cancel_t *cancel) +{ + FakeModule &m = world_module; + st->ct_out_len = 0; + st->pt_out_len = 0; + st->state = WIFI_TLS_UNKNOWN; + st->esp_err = 0; + st->alert_in = WIFI_TLS_ALERT_NONE; + st->alert_out = WIFI_TLS_ALERT_NONE; + st->fail_reason = 0; + st->verify_flags = 0; + if (!m.available) { + return WIFI_TLS_NO_MODULE; + } + if (unsent()) { + return WIFI_TLS_UNSENT; + } + RpcCall &c = log_call(0x31, slot, tag, cancel); + c.flags = st->flags; + c.ct_in_len = st->ct_in_len; + c.pt_in_len = st->pt_in_len; + + Forced f = Forced(); + bool forced = !m.forced.empty(); + if (forced) { + f = m.forced.front(); + m.forced.pop_front(); + } + bool cancelled; + bool busy = forced && (f.result == WIFI_TLS_BUSY); + if (busy) { + module_wait(timeout_ms, cancel, 0xFFFFFFFF, &cancelled); + if (!f.applied) { + return WIFI_TLS_BUSY; + } + } else if (!module_wait(timeout_ms, cancel, f.delay_ms, &cancelled)) { + return WIFI_TLS_BUSY; + } + if (forced && (f.result == WIFI_TLS_INVALID || f.result == WIFI_TLS_REFUSED || f.result == WIFI_TLS_UNSENT)) { + st->esp_err = f.esp_err; + return f.result; + } + FakeSession &s = m.sess[slot]; + if (!s.live || (s.tag != tag)) { + st->esp_err = WIFI_TLS_ESP_NOT_FOUND; + return WIFI_TLS_REFUSED; // touches nothing (the tag rule) + } + if ((m.quiet_next > 0) && (st->ct_in_len == 0) && (s.state == WIFI_TLS_ESTABLISHED)) { + m.quiet_next--; + st->state = s.state; + return 0; + } + if (m.quiet_alternate && (st->ct_in_len == 0) && (s.state == WIFI_TLS_ESTABLISHED) && !s.pt.empty()) { + m.quiet_last = !m.quiet_last; + if (m.quiet_last) { + st->state = s.state; + return 0; + } + } + bool again = false; + if (m.again_next > 0) { + m.again_next--; + again = true; + } else if (s.in.size() + st->ct_in_len > m.in_cap) { + again = true; + } + if (!again) { + s.in.insert(s.in.end(), st->ct_in, st->ct_in + st->ct_in_len); + if ((s.state == WIFI_TLS_ESTABLISHED) && st->pt_in_len) { + emit(s.out, 'D', st->pt_in, st->pt_in_len); + } + } + if (s.state == WIFI_TLS_HANDSHAKING && !s.sent_hello) { + bytes hello = record('H', m.hello_size); + s.out.insert(s.out.end(), hello.begin(), hello.end()); + s.sent_hello = true; + } + if (!(st->flags & WIFI_TLS_STEP_NO_READ) || (s.state == WIFI_TLS_HANDSHAKING)) { + parse_in(s, st); + } + if (forced && f.fail && (s.state == WIFI_TLS_ESTABLISHED)) { + s.state = WIFI_TLS_FAILED; + st->fail_reason = f.fail_reason; + st->verify_flags = f.verify_flags; + st->alert_in = f.alert_in; + st->esp_err = f.fail_err; + } + size_t ct = s.out.size() < 1024 ? s.out.size() : 1024; + if (ct > st->ct_out_room) { + return WIFI_TLS_INVALID; + } + memcpy(st->ct_out, s.out.data(), ct); + s.out.erase(s.out.begin(), s.out.begin() + ct); + st->ct_out_len = ct; + size_t pt = 0; + if ((s.state == WIFI_TLS_ESTABLISHED) && !(st->flags & WIFI_TLS_STEP_NO_READ)) { + size_t room = 1024 - ct; + if (room > 960) { + room = 960; + } + pt = s.pt.size() < room ? s.pt.size() : room; + for (size_t i = 0; i < pt; i++) { + st->pt_out[i] = s.pt.front(); + s.pt.pop_front(); + } + if (s.terminal && s.pt.empty()) { + if (s.terminal == 'C') { + s.state = WIFI_TLS_CLOSED; + } else if (pt == 0) { + s.state = WIFI_TLS_FAILED; + if (s.terminal == 'A') { + st->alert_in = s.alert; + st->esp_err = -0x7780; // MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE + } else { + st->esp_err = -0x7180; // MBEDTLS_ERR_SSL_INVALID_MAC + } + } + } + } + if (forced && f.pt_on_no_read && (st->flags & WIFI_TLS_STEP_NO_READ)) { + return WIFI_TLS_INVALID; // what wifi_tls_take_step makes of it + } + st->pt_out_len = pt; + st->state = s.state; + if ((s.state == WIFI_TLS_FAILED) || (s.state == WIFI_TLS_CLOSED)) { + s.live = false; + } + if (busy) { + return WIFI_TLS_BUSY; // it ran, but its answer came too late + } + if (again) { + if (s.state == WIFI_TLS_CLOSED) { + return 0; + } + return WIFI_TLS_AGAIN; + } + return 0; +} + +int wifi_tls_close(uint8_t slot, uint16_t tag, uint8_t *ct_out, uint16_t room, uint16_t *ct_out_len, int *esp_err, + uint32_t timeout_ms, const wifi_tls_cancel_t *cancel) +{ + FakeModule &m = world_module; + *esp_err = 0; + *ct_out_len = 0; + if (!m.available) { + return WIFI_TLS_NO_MODULE; + } + log_call(0x32, slot, tag, cancel); + bool cancelled; + module_wait(timeout_ms, cancel, 0, &cancelled); + if (m.close_result >= 0) { + return m.close_result; + } + FakeSession &s = m.sess[slot]; + if (!s.live || (s.tag != tag)) { + *esp_err = WIFI_TLS_ESP_NOT_FOUND; + return WIFI_TLS_REFUSED; + } + s.live = false; + bytes notify = record('C', 0); + memcpy(ct_out, notify.data(), notify.size()); + *ct_out_len = notify.size(); + return 0; +} + +int wifi_tls_stats(uint8_t slot, uint16_t tag, wifi_tls_stats_t *stats, int *esp_err, uint32_t timeout_ms, + const wifi_tls_cancel_t *cancel) +{ + FakeModule &m = world_module; + *esp_err = 0; + if (!m.available) { + return WIFI_TLS_NO_MODULE; + } + log_call(0x33, slot, tag, cancel); + bool cancelled; + module_wait(timeout_ms, cancel, 0, &cancelled); + if (m.stats_result >= 0) { + *esp_err = m.stats_esp_err; + return m.stats_result; + } + memset(stats, 0, sizeof(*stats)); + if (slot == WIFI_TLS_SLOT_GLOBAL) { + stats->entropy_source = m.entropy ? 1 : 0; + stats->time_source = m.module_time ? 2 : 0; + stats->block_max_ms = m.block_max_ms; + return 0; + } + FakeSession &s = m.sess[slot]; + if (!s.live || (s.tag != tag)) { + *esp_err = WIFI_TLS_ESP_NOT_FOUND; + return WIFI_TLS_REFUSED; + } + stats->tls_version = m.version; + stats->ciphersuite = m.suite; + stats->group = m.group; + stats->ems = m.ems; + memcpy(stats->spki_sha256, m.spki, 32); + return 0; +} + +int wifi_tls_close_all(int *esp_err, uint32_t timeout_ms) +{ + FakeModule &m = world_module; + *esp_err = 0; + log_call(0x34, 0, 0, NULL); + m.close_alls++; + m.sess[0].live = false; + m.sess[1].live = false; + m.ca_loaded = false; + world_advance(1); + return 0; +} + +int wifi_tls_set_ca(const uint8_t *der, uint16_t der_len, uint16_t ca_tag, int *esp_err, uint8_t *reject, + uint32_t timeout_ms, const wifi_tls_cancel_t *cancel) +{ + FakeModule &m = world_module; + *esp_err = 0; + *reject = 0; + if (!m.available) { + return WIFI_TLS_NO_MODULE; + } + RpcCall &c = log_call(0x35, 0, ca_tag, cancel); + c.pt_in_len = der_len; + m.ca_der.assign(der, der + der_len); + world_advance(1); + m.ca_loaded = false; + if (m.set_ca_result == 0) { + m.ca_loaded = true; + m.ca_tag = ca_tag; + return 0; + } + *esp_err = m.set_ca_esp_err; + *reject = m.set_ca_reject; + return m.set_ca_result; +} + +// GET_RANDOM is not what these checks are about; the module is never asked for bytes +int wifi_get_random(uint8_t *buf, uint16_t len) +{ + return WIFI_RANDOM_NO_MODULE; +} diff --git a/software/test/wifi_tls/net_world.h b/software/test/wifi_tls/net_world.h new file mode 100644 index 000000000..af7ae05dd --- /dev/null +++ b/software/test/wifi_tls/net_world.h @@ -0,0 +1,202 @@ +// The world the host tests run network_target.cc in: a clock, lwIP's sockets and DNS, the C64 reset line, and a WiFi +// module with a pretend TLS of [type][length lo][length hi][payload] records; deterministic, time moves only on waits. +// Types: 'H' hello/flight, 'F' Finished, 'D' data, 'C' close_notify, 'A' alert, 'B' bad MAC, 'W' warning, 'T' ticket. +#ifndef NET_WORLD_H_ +#define NET_WORLD_H_ + +#include +#include +#include +#include +#include "wifi_tls.h" + +typedef std::vector bytes; + +// The clock: one tick is 5 ms, as on the U64. +extern uint32_t world_tick; +void world_advance(uint32_t ticks); +uint32_t world_ms(void); // world_tick in ms +extern uint32_t world_reset_at; // reset_pending() from this tick on; ~0 for never +extern uint32_t world_sntp; // what sntp_utc_now() answers + +// A record of the pretend TLS. +bytes record(char type, size_t length, uint32_t seed = 0); +uint8_t payload_byte(uint32_t seed, uint32_t i); + +// What a socket delivers: data, the peer's FIN, or an error; each from a tick on. +#define EV_DATA 0 +#define EV_FIN 1 +#define EV_ERR 2 +struct SockEvent { + int kind; + bytes data; + int err; + uint32_t at; +}; + +// What the server does when the module's ClientHello has arrived. +#define SRV_RESPOND 0 // its flight, flight bytes, from delay_ms on, in chunks of chunk bytes +#define SRV_STALL 1 +#define SRV_RST 2 +#define SRV_FIN 3 +struct FakeServer { + int on_hello; + size_t flight; + uint32_t delay_ms; + size_t chunk; + std::vector after_finished; // pushed once the module's Finished arrives (at is added to now) + bool echo; + bytes got; // plaintext the server received + bool saw_notify; // the module's close_notify + int saw_alert; // the module's alert, -1 for none + int hellos; + bytes client_stream; // every byte the module sent, unparsed rest + uint32_t connect_delay_ms; // a non-blocking connect takes this long + int connect_err; // ... and then fails with this errno + bool connect_never; + int rst_err; // the errno of SRV_RST; 0 for ECONNRESET + int send_err; // every send on this socket fails with it (set before the socket exists) + int send_err_from; // sends from this call number on (1-based) fail with send_err_late + int send_err_late; // EWOULDBLOCK makes it a stall +}; + +struct FakeSock { + bool open; + int type; + bool nonblocking; + bool nodelay; + bool rcvtimeo_set; + int sndtimeo_ms; // 0 when never set + bool connected; + uint32_t connect_at; // a non-blocking connect completes at this tick; 0 before it started + uint32_t connect_addr; // where to, network order + std::deque rx; + bool err_taken; // the error has been handed out once + bytes tx; + int send_err; // every send fails with this, when set + bool send_blocked; // every send would block + int recv_calls; + int recv_after_err; // recv calls after the first error + int send_calls; + int closes; + FakeServer srv; +}; +extern FakeSock world_socks[16]; +void server_push(int s, int kind, const bytes &data, int err = 0, uint32_t after_ms = 0); + +// DNS: how a name resolves. +#define DNS_IMMEDIATE 0 +#define DNS_ASYNC_OK 1 +#define DNS_ASYNC_NO 2 +#define DNS_ERR_VAL 3 +#define DNS_NEVER 4 +struct DnsRule { + std::string host; + int mode; + uint32_t addr; + uint32_t delay_ms; +}; +extern std::vector world_dns; +extern int world_dns_calls; +extern int world_dns_unlocked_calls; // dns_gethostbyname called without the core lock +extern int world_dns_late_writes; // callbacks that fired for an older lookup +extern int world_lock_depth; +extern int world_lock_bad; // a callback that ran while the core lock was held +void world_dns_fire_all(void); // every pending answer, now + +// A step answer forced on the module instead of the pretend TLS. +struct Forced { + int result; // WIFI_TLS_*: BUSY (no answer), INVALID, REFUSED, UNSENT + int esp_err; + bool applied; // the module still runs the step (for BUSY) + uint32_t delay_ms; // how long before the answer (0: at once) + // For an answer of 0 with FAILED + bool fail; + uint8_t fail_reason; + uint32_t verify_flags; + uint8_t alert_in; + int fail_err; + bool pt_on_no_read; // hand out plaintext on a NO_READ step (malformed) +}; + +struct FakeSession { + bool live; + uint16_t tag; + uint8_t trust; + int state; + bool sent_hello; + bytes in; + std::deque pt; + bytes out; + char terminal; // 'C', 'A' or 'B' waiting behind pt; 0 for none + uint8_t alert; +}; + +struct RpcCall { + int cmd; // 0x30.. as on the wire + uint8_t slot; + uint16_t tag; + uint8_t flags; + int ct_in_len; + int pt_in_len; + wifi_tls_open_t open; + std::string sni; + bytes pin; + bool cancel_given; +}; + +struct FakeModule { + bool available; + uint16_t major, minor; + uint32_t generation; + bool entropy; + bool module_time; // its own SNTP + // OPEN + int open_result; // forced; -1 for the normal checks + int open_esp_err; + uint8_t open_reason; + uint32_t open_delay_ms; + // the handshake + size_t hello_size; + bool hs_fail; + uint8_t hs_fail_reason; + uint32_t hs_verify_flags; + uint8_t hs_alert_in; + int hs_fail_err; + bool hs_alert_out; // send alert 40 with the failure + // STATS + uint16_t version, suite, group; + uint8_t ems; + uint8_t spki[32]; + uint16_t block_max_ms; + int stats_result; // forced; -1 for normal + int stats_esp_err; // with a forced REFUSED + // SET_CA + int set_ca_result; // WIFI_TLS_* to answer; 0 loads + int set_ca_esp_err; + uint8_t set_ca_reject; + bytes ca_der; + uint16_t ca_tag; + bool ca_loaded; + // CLOSE + int close_result; // forced; -1 for normal + int close_alls; + // steps + std::deque forced; + size_t in_cap; // what the module holds of unread ciphertext before AGAIN + int again_next; // answer AGAIN this many times first + FakeSession sess[2]; + std::vector calls; + int unsent_next; // answer UNSENT this many times first (any call) + bool quiet_alternate; // every other input-less step is quiet while plaintext is held + bool quiet_last; + int quiet_next; // input-less steps that hand out nothing although plaintext is held, first + // (the engine's skipped-warning WANT_READ case, tls_engine.c:503-505) +}; +extern FakeModule world_module; + +void world_reset(void); +int world_count(int cmd); +int world_open_sockets(void); + +#endif /* NET_WORLD_H_ */ diff --git a/software/test/wifi_tls/netstub/command_intf.h b/software/test/wifi_tls/netstub/command_intf.h new file mode 100644 index 000000000..1c5fa434c --- /dev/null +++ b/software/test/wifi_tls/netstub/command_intf.h @@ -0,0 +1,14 @@ +// Host stand-in for software/io/command_interface/command_intf.h: the real command_target.h, and of CommandInterface +// only what network_target.cc uses, faked in net_tls_test.cc. +#ifndef COMMAND_INTF_H +#define COMMAND_INTF_H +#include // the real header brings it, through its own includes +#include "command_target.h" + +class CommandInterface +{ +public: + bool reset_pending(void); +}; +extern CommandInterface cmd_if; +#endif diff --git a/software/test/wifi_tls/netstub/dump_hex.h b/software/test/wifi_tls/netstub/dump_hex.h new file mode 100644 index 000000000..c88a2fff8 --- /dev/null +++ b/software/test/wifi_tls/netstub/dump_hex.h @@ -0,0 +1 @@ +// Host stand-in: network_target.cc includes it and uses nothing from it. diff --git a/software/test/wifi_tls/netstub/lwip/dns.h b/software/test/wifi_tls/netstub/lwip/dns.h new file mode 100644 index 000000000..99b689389 --- /dev/null +++ b/software/test/wifi_tls/netstub/lwip/dns.h @@ -0,0 +1,19 @@ +// Host stand-in for lwip/dns.h and its address types (IPv4 only, as LWIP_IPV6 is 0 in lwipopts.h). +// net_tls_test.cc fakes dns_gethostbyname and carries a copy of lwIP's ip4addr_aton. +#ifndef LWIP_DNS_H_NETSTUB +#define LWIP_DNS_H_NETSTUB +#include +typedef int8_t err_t; +#define ERR_OK 0 +#define ERR_MEM -1 +#define ERR_INPROGRESS -5 +#define ERR_VAL -6 +#define ERR_ARG -16 +typedef struct { uint32_t addr; } ip4_addr_t; +typedef ip4_addr_t ip_addr_t; +#define ip_2_ip4(ipaddr) (ipaddr) +#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr) +int ip4addr_aton(const char *cp, ip4_addr_t *addr); +typedef void (*dns_found_callback)(const char *name, const ip_addr_t *ipaddr, void *callback_arg); +err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr, dns_found_callback found, void *callback_arg); +#endif diff --git a/software/test/wifi_tls/netstub/lwip/opt.h b/software/test/wifi_tls/netstub/lwip/opt.h new file mode 100644 index 000000000..78e5f9061 --- /dev/null +++ b/software/test/wifi_tls/netstub/lwip/opt.h @@ -0,0 +1,5 @@ +// Host stand-in for lwip/opt.h: MEMP_NUM_NETCONN as software/network/config/lwipopts.h sets it. +#ifndef LWIP_OPT_H_NETSTUB +#define LWIP_OPT_H_NETSTUB +#define MEMP_NUM_NETCONN 16 +#endif diff --git a/software/test/wifi_tls/netstub/lwip/tcpip.h b/software/test/wifi_tls/netstub/lwip/tcpip.h new file mode 100644 index 000000000..92cbcc376 --- /dev/null +++ b/software/test/wifi_tls/netstub/lwip/tcpip.h @@ -0,0 +1,8 @@ +// Host stand-in for lwip/tcpip.h: the core lock, faked in net_tls_test.cc. +#ifndef LWIP_TCPIP_H_NETSTUB +#define LWIP_TCPIP_H_NETSTUB +void fake_lock_tcpip_core(void); +void fake_unlock_tcpip_core(void); +#define LOCK_TCPIP_CORE() fake_lock_tcpip_core() +#define UNLOCK_TCPIP_CORE() fake_unlock_tcpip_core() +#endif diff --git a/software/test/wifi_tls/netstub/netdb.h b/software/test/wifi_tls/netstub/netdb.h new file mode 100644 index 000000000..dea531578 --- /dev/null +++ b/software/test/wifi_tls/netstub/netdb.h @@ -0,0 +1,8 @@ +// Host stand-in for lwIP's netdb.h: the host's struct hostent, and lwIP's +// gethostbyname_r, which net_tls_test.cc fakes. +#ifndef NETDB_H_NETSTUB +#define NETDB_H_NETSTUB +#include_next +int gethostbyname_r(const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, + int *h_errnop); +#endif diff --git a/software/test/wifi_tls/netstub/network_interface.h b/software/test/wifi_tls/netstub/network_interface.h new file mode 100644 index 000000000..fc5991f25 --- /dev/null +++ b/software/test/wifi_tls/netstub/network_interface.h @@ -0,0 +1,14 @@ +// Host stand-in for software/network/network_interface.h: what network_target.cc calls. +#ifndef NETWORK_INTERFACE_H_STUB +#define NETWORK_INTERFACE_H_STUB +#include +class NetworkInterface +{ +public: + static int getNumberOfInterfaces(void) { return 0; } + static NetworkInterface *getInterface(int i) { return 0; } + void getIpAddr(uint8_t *a) { } + void getMacAddr(uint8_t *a) { } + void setIpAddr(uint8_t *a) { } +}; +#endif diff --git a/software/test/wifi_tls/netstub/socket.h b/software/test/wifi_tls/netstub/socket.h new file mode 100644 index 000000000..6f7795a6a --- /dev/null +++ b/software/test/wifi_tls/netstub/socket.h @@ -0,0 +1,37 @@ +// Host stand-in for lwIP's socket API as network_target.cc and network_target_tls.cc see it (through compat/posix/sys/socket.h): the host's +// types and constants, and lwIP's calls, faked in net_tls_test.cc. The BSD names that the TCP and UDP commands use +// go to the same fakes. +#ifndef SOCKET_H_NETSTUB +#define SOCKET_H_NETSTUB +#include +#include +#include +#include +#include +#include +#include +#include + +// lwIP's sockaddr_in has sin_len, which BSD's has and Linux's does not. network_target.cc sets it right before sin_family, +// so there it lands on sin_family, which is then set; the fakes never read it. +#ifdef __linux__ +#define sin_len sin_family +#endif + +#define PP_HTONS(x) ((uint16_t)((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))) + +int lwip_socket(int domain, int type, int protocol); +int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen); +int lwip_ioctl(int s, long cmd, void *argp); +int lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen); +int lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen); +ssize_t lwip_send(int s, const void *dataptr, size_t size, int flags); +ssize_t lwip_recv(int s, void *mem, size_t len, int flags); +ssize_t lwip_recvmsg(int s, struct msghdr *message, int flags); +int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout); +int lwip_close(int s); + +#define socket(a, b, c) lwip_socket(a, b, c) +#define connect(a, b, c) lwip_connect(a, b, c) +#define setsockopt(a, b, c, d, e) lwip_setsockopt(a, b, c, d, e) +#endif diff --git a/software/test/wifi_tls/stub/FreeRTOS.h b/software/test/wifi_tls/stub/FreeRTOS.h new file mode 100644 index 000000000..44ddca460 --- /dev/null +++ b/software/test/wifi_tls/stub/FreeRTOS.h @@ -0,0 +1,17 @@ +// Host stand-in for FreeRTOS.h: the types and macros the code under test uses. +#ifndef FREERTOS_H_STUB +#define FREERTOS_H_STUB +#include +#include +typedef uint32_t TickType_t; +typedef long BaseType_t; +typedef unsigned long UBaseType_t; +typedef void *QueueHandle_t; +typedef void *TaskHandle_t; +#define pdTRUE 1 +#define pdFALSE 0 +#define configTICK_RATE_HZ 200 +#define portTICK_PERIOD_MS (1000 / configTICK_RATE_HZ) +// As in software/FreeRTOS/Source/include/projdefs.h. +#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) +#endif diff --git a/software/test/wifi_tls/stub/lwip/inet.h b/software/test/wifi_tls/stub/lwip/inet.h new file mode 100644 index 000000000..3711a25fa --- /dev/null +++ b/software/test/wifi_tls/stub/lwip/inet.h @@ -0,0 +1,6 @@ +#ifndef LWIP_INET_H_STUB +#define LWIP_INET_H_STUB +#include "lwip/sockets.h" +int fake_inet_aton(const char *cp, struct in_addr *addr); +#define inet_aton(cp, addr) fake_inet_aton(cp, (struct in_addr *)(addr)) +#endif diff --git a/software/test/wifi_tls/stub/lwip/netdb.h b/software/test/wifi_tls/stub/lwip/netdb.h new file mode 100644 index 000000000..8e53a6409 --- /dev/null +++ b/software/test/wifi_tls/stub/lwip/netdb.h @@ -0,0 +1 @@ +// Host stand-in: rpc_calls.h includes it and uses nothing from it. diff --git a/software/test/wifi_tls/stub/lwip/sockets.h b/software/test/wifi_tls/stub/lwip/sockets.h new file mode 100644 index 000000000..86ac73b79 --- /dev/null +++ b/software/test/wifi_tls/stub/lwip/sockets.h @@ -0,0 +1,36 @@ +// Host stand-in for lwIP's sockets.h: u16_t and the socket types that rpc_calls.h needs. +#ifndef LWIP_SOCKETS_H_STUB +#define LWIP_SOCKETS_H_STUB +#include +#include +#include +#include + +typedef uint16_t u16_t; +typedef uint32_t u32_t; +typedef u32_t socklen_t_stub; + +struct in_addr_stub { uint32_t s_addr; }; +struct sockaddr_stub { uint8_t sa_len; uint8_t sa_family; char sa_data[14]; }; +struct sockaddr_in_stub { uint8_t sin_len; uint8_t sin_family; uint16_t sin_port; struct in_addr_stub sin_addr; char sin_zero[8]; }; +#define sockaddr sockaddr_stub +#define sockaddr_in sockaddr_in_stub +#define in_addr in_addr_stub + +#define AF_INET 2 +#define SOCK_STREAM 1 +#define SOL_SOCKET 0xfff +#define SO_SNDTIMEO 0x1005 +#define SO_RCVTIMEO 0x1006 +#define MSG_DONTWAIT 0x08 +#define FIONBIO 0x8004667e +#define PP_HTONS(x) ((uint16_t)((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))) + +int lwip_socket(int domain, int type, int protocol); +int lwip_connect(int s, const struct sockaddr *name, socklen_t_stub namelen); +int lwip_ioctl(int s, long cmd, void *argp); +int lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t_stub optlen); +ssize_t lwip_send(int s, const void *dataptr, size_t size, int flags); +ssize_t lwip_recv(int s, void *mem, size_t len, int flags); +int lwip_close(int s); +#endif diff --git a/software/test/wifi_tls/stub/queue.h b/software/test/wifi_tls/stub/queue.h new file mode 100644 index 000000000..cb7604eb5 --- /dev/null +++ b/software/test/wifi_tls/stub/queue.h @@ -0,0 +1,5 @@ +#ifndef QUEUE_H_STUB +#define QUEUE_H_STUB +#include "FreeRTOS.h" +BaseType_t xQueueReceive(QueueHandle_t queue, void *item, TickType_t ticks); +#endif diff --git a/software/test/wifi_tls/stub/sntp_time.h b/software/test/wifi_tls/stub/sntp_time.h new file mode 100644 index 000000000..b3567dd51 --- /dev/null +++ b/software/test/wifi_tls/stub/sntp_time.h @@ -0,0 +1,6 @@ +// Host stand-in for software/network/sntp_time.h, faked in net_world.cc. +#ifndef SNTP_TIME_H_STUB +#define SNTP_TIME_H_STUB +#include +uint32_t sntp_utc_now(void); +#endif diff --git a/software/test/wifi_tls/stub/task.h b/software/test/wifi_tls/stub/task.h new file mode 100644 index 000000000..a6408e654 --- /dev/null +++ b/software/test/wifi_tls/stub/task.h @@ -0,0 +1,8 @@ +#ifndef TASK_H_STUB +#define TASK_H_STUB +#include "FreeRTOS.h" +TickType_t xTaskGetTickCount(void); +void vTaskSuspendAll(void); +BaseType_t xTaskResumeAll(void); +void vTaskDelay(TickType_t ticks); +#endif diff --git a/software/test/wifi_tls/stub/wifi_cmd.h b/software/test/wifi_tls/stub/wifi_cmd.h new file mode 100644 index 000000000..08f01bb99 --- /dev/null +++ b/software/test/wifi_tls/stub/wifi_cmd.h @@ -0,0 +1,51 @@ +// Host stand-in for software/io/wifi/wifi_cmd.h: only what wifi_dedicated.cc uses, backed by the scripted world in +// world.cc. The declarations mirror the real header; keep them in step with it. +#ifndef WIFI_CMD_H_ +#define WIFI_CMD_H_ + +#include +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "rpc_calls.h" +extern "C" { + #include "cmd_buffer.h" +} + +class DmaUART +{ +public: + volatile uint32_t generation; + BaseType_t GetBuffer(command_buf_t **buf, TickType_t ticks); + BaseType_t TransmitPacket(command_buf_t *buf, uint16_t *ms = NULL); + BaseType_t FreeBuffer(command_buf_t *buf); +}; + +class Esp32 +{ +public: + DmaUART *uart; +}; +extern Esp32 esp32; + +extern uint16_t sequence_nr; +extern const char *no_wifi_buf; + +#define WIFI_DEDICATED_THREAD 0xFC +typedef struct { + command_buf_t *buf; + uint32_t generation; +} dedicated_reply_t; +extern QueueHandle_t dedicated_replies; +extern volatile bool dedicated_waiting; + +void world_enter_safe(void); +void world_leave_safe(void); +#define ENTER_SAFE_SECTION world_enter_safe() +#define LEAVE_SAFE_SECTION world_leave_safe() + +// Everything the code under test prints goes into the trace. +int world_printf(const char *fmt, ...); +#define printf world_printf + +#endif /* WIFI_CMD_H_ */ diff --git a/software/test/wifi_tls/wifi_tls_test.cc b/software/test/wifi_tls/wifi_tls_test.cc new file mode 100644 index 000000000..25bd0b537 --- /dev/null +++ b/software/test/wifi_tls/wifi_tls_test.cc @@ -0,0 +1,705 @@ +// Host tests (make -C target/pc/linux/wifitls test) for the TLS calls to the WiFi module in wifi_tls.cc and for the +// channel they use (wifi_dedicated.cc), its cancel predicate included. The real wifi_tls.cc and +// wifi_dedicated.cc are compiled; only the UART, queue, tick and module are the world's. +#include +#include +#include +#include "world.h" +#include "wifi_dedicated.h" +#include "wifi_tls.h" +#include "rpc_calls.h" +#include "check.h" +#undef printf + +int failures; +int checks; + +void check(bool condition, const char *what, ...) +{ + char line[300]; + va_list ap; + va_start(ap, what); + vsnprintf(line, sizeof(line), what, ap); + va_end(ap); + checks++; + if (!condition) { + failures++; + printf(" FAIL %s\n", line); + } else { + printf(" ok %s\n", line); + } +} + + +#define SEQUENCE 0x1234 + +// Word aligned, as the data of a command_buf_t is. +static union { + uint32_t align; + uint8_t bytes[CMD_BUF_SIZE]; +} reply; + +static void header(uint8_t command) +{ + memset(reply.bytes, 0, sizeof(reply.bytes)); + rpc_header_t *hdr = (rpc_header_t *)reply.bytes; + hdr->command = command; + hdr->thread = WIFI_DEDICATED_THREAD; + hdr->sequence = SEQUENCE; +} + +// A step answer: state, esp_err, ct bytes of 0xC0+i and pt bytes of 0x50+i. +static int step_reply(uint8_t state, int esp_err, uint16_t ct, uint16_t pt) +{ + header(CMD_TLS_STEP); + rpc_tls_step_resp *r = (rpc_tls_step_resp *)reply.bytes; + r->esp_err = esp_err; + r->state = state; + r->alert_in = TLS_ALERT_NONE; + r->alert_out = TLS_ALERT_NONE; + r->ct_out_len = ct; + r->pt_out_len = pt; + for (int i = 0; i < ct; i++) { + r->data[i] = (uint8_t)(0xC0 + i); + } + for (int i = 0; i < pt; i++) { + r->data[ct + i] = (uint8_t)(0x50 + i); + } + return offsetof(rpc_tls_step_resp, data) + ct + pt; +} + +static uint8_t ct_out[CMD_BUF_SIZE]; +static uint8_t pt_out[CMD_BUF_SIZE]; + +static void fresh_step(wifi_tls_step_t *st, uint16_t room) +{ + memset(st, 0, sizeof(*st)); + memset(ct_out, 0xEE, sizeof(ct_out)); + memset(pt_out, 0xEE, sizeof(pt_out)); + st->ct_out = ct_out; + st->pt_out = pt_out; + st->ct_out_room = room; + st->pt_out_room = room; + st->ct_out_len = 0x7777; + st->pt_out_len = 0x7777; + st->state = WIFI_TLS_UNKNOWN; + st->esp_err = 0; +} + +static bool untouched(const uint8_t *buf) +{ + for (int i = 0; i < CMD_BUF_SIZE; i++) { + if (buf[i] != 0xEE) { + return false; + } + } + return true; +} + +static bool nothing_out(const wifi_tls_step_t *st) +{ + return untouched(ct_out) && untouched(pt_out) && (st->ct_out_len == 0x7777) && (st->pt_out_len == 0x7777); +} + +static void test_take_step(void) +{ + printf("The check on a STEP answer (20-byte header)\n"); + wifi_tls_step_t st; + const uint16_t sizes[][2] = { { 0, 0 }, { 1, 0 }, { 0, 1 }, { 255, 1 }, { 256, 0 }, { 300, 700 }, { 1024, 0 }, { 0, 1024 } }; + bool all = true; + for (unsigned k = 0; k < sizeof(sizes) / sizeof(sizes[0]); k++) { + uint16_t ct = sizes[k][0], pt = sizes[k][1]; + int size = step_reply(TLS_STATE_ESTABLISHED, 0, ct, pt); + fresh_step(&st, 1024); + int r = wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st); + bool ok = (r == 0) && (st.ct_out_len == ct) && (st.pt_out_len == pt) && (st.state == WIFI_TLS_ESTABLISHED) && + (memcmp(ct_out, ((rpc_tls_step_resp *)reply.bytes)->data, ct) == 0) && + (memcmp(pt_out, ((rpc_tls_step_resp *)reply.bytes)->data + ct, pt) == 0) && + (ct_out[ct] == 0xEE) && (pt_out[pt] == 0xEE); + all = all && ok; + } + check(all, "an ESTABLISHED answer hands over exactly its bytes, at lengths from 0 to 1024 and past 255"); + + int size = step_reply(TLS_STATE_ESTABLISHED, 0, 10, 10); + int foreign = 0; + for (int command = 0; command < 256; command++) { + if (command == CMD_TLS_STEP) { + continue; + } + ((rpc_header_t *)reply.bytes)->command = command; + fresh_step(&st, 1024); + foreign += (wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st) == WIFI_TLS_FOREIGN) && nothing_out(&st); + } + check(foreign == 255, "an answer to any other command is foreign and changes nothing (%d of 255)", foreign); + + int shorts = 0; + size = step_reply(TLS_STATE_ESTABLISHED, 0, 10, 10); + for (int s = 0; s < 4; s++) { + fresh_step(&st, 1024); + shorts += (wifi_tls_take_step(reply.bytes, s, SEQUENCE, &st) == WIFI_TLS_FOREIGN) && nothing_out(&st); + } + for (int s = 4; s < 40; s++) { + fresh_step(&st, 1024); + shorts += (wifi_tls_take_step(reply.bytes, s, SEQUENCE, &st) == WIFI_TLS_INVALID) && nothing_out(&st); + } + for (int s = 41; s < 64; s++) { + fresh_step(&st, 1024); + shorts += (wifi_tls_take_step(reply.bytes, s, SEQUENCE, &st) == WIFI_TLS_INVALID) && nothing_out(&st); + } + check(shorts == 63, "an answer of any size but its own (40) hands out nothing (%d of 63), the older 16-byte header too", + shorts); + size = step_reply(TLS_STATE_ESTABLISHED, 0, 20, 0); + fresh_step(&st, 19); + int r = wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st); + check((r == WIFI_TLS_INVALID) && nothing_out(&st), "more ciphertext than the caller has room for is invalid, not cut"); + + // FAILED carries the reasons, and only FAILED does. + size = step_reply(TLS_STATE_FAILED, -0x2700, 7, 3); + rpc_tls_step_resp *res = (rpc_tls_step_resp *)reply.bytes; + res->fail_reason = TLS_FAIL_CERT_VERIFY; + res->verify_flags = 0x0C; + res->alert_in = 70; + res->alert_out = 42; + fresh_step(&st, 1024); + r = wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st); + check((r == 0) && (st.state == WIFI_TLS_FAILED) && (st.esp_err == -0x2700) && (st.fail_reason == 4) && + (st.verify_flags == 0x0C) && (st.alert_in == 70) && (st.alert_out == 42) && (st.ct_out_len == 7) && + (st.pt_out_len == 0) && untouched(pt_out), + "FAILED: esp_err, fail_reason, verify_flags, alert_in and alert_out arrive; its plaintext is withheld"); + int reasons = 0; + for (int state = 0; state < 3; state++) { + size = step_reply((uint8_t)state, 0, 5, 0); + ((rpc_tls_step_resp *)reply.bytes)->fail_reason = 4; + fresh_step(&st, 1024); + reasons += (wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st) == WIFI_TLS_INVALID) && nothing_out(&st); + } + check(reasons == 3, "a fail_reason without FAILED is invalid (%d of 3)", reasons); + size = step_reply(TLS_STATE_ESTABLISHED, 0, 5, 0); + ((rpc_tls_step_resp *)reply.bytes)->alert_in = 0xFF; + ((rpc_tls_step_resp *)reply.bytes)->verify_flags = 0; + fresh_step(&st, 1024); + r = wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st); + check((r == 0) && (st.alert_in == WIFI_TLS_ALERT_NONE) && (st.fail_reason == 0), "no alert is 0xFF"); + + // NO_READ. + size = step_reply(TLS_STATE_ESTABLISHED, 0, 30, 1); + fresh_step(&st, 1024); + st.flags = WIFI_TLS_STEP_NO_READ; + r = wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st); + check((r == WIFI_TLS_INVALID) && nothing_out(&st), "plaintext on a NO_READ step is malformed (-> 17)"); + size = step_reply(TLS_STATE_ESTABLISHED, 0, 30, 0); + fresh_step(&st, 1024); + st.flags = WIFI_TLS_STEP_NO_READ; + r = wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st); + check((r == 0) && (st.ct_out_len == 30), "a NO_READ step with ciphertext only is fine"); + size = step_reply(TLS_STATE_ESTABLISHED, 0, 30, 1); + fresh_step(&st, 1024); + r = wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st); + check((r == 0) && (st.pt_out_len == 1), "without NO_READ the same answer is fine"); + + // The refusals, AGAIN, CLOSED. + size = step_reply(TLS_STATE_HANDSHAKING, 0x101, 9, 0); + fresh_step(&st, 1024); + r = wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st); + check((r == WIFI_TLS_AGAIN) && (st.ct_out_len == 9) && (st.state == WIFI_TLS_HANDSHAKING), + "ESP_ERR_NO_MEM: AGAIN, with the output"); + size = step_reply(TLS_STATE_CLOSED, 0x101, 4, 7); + fresh_step(&st, 1024); + r = wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st); + check((r == 0) && (st.state == WIFI_TLS_CLOSED) && (st.pt_out_len == 7), "CLOSED with NO_MEM: the last plaintext"); + size = step_reply(TLS_STATE_ESTABLISHED, 0x105, 0, 0); + fresh_step(&st, 1024); + r = wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st); + check((r == WIFI_TLS_REFUSED) && (st.esp_err == 0x105) && nothing_out(&st), + "ESP_ERR_NOT_FOUND (a stale tag) is refused, nothing taken"); + header(CMD_TLS_STEP); + ((rpc_espcmd_resp *)reply.bytes)->esp_err = 0x105; + fresh_step(&st, 1024); + r = wifi_tls_take_step(reply.bytes, 8, SEQUENCE, &st); + check((r == WIFI_TLS_REFUSED) && (st.esp_err == 0x105) && nothing_out(&st), + "a bare 8-byte refusal is refused with its error"); + fresh_step(&st, 1024); + ((rpc_espcmd_resp *)reply.bytes)->esp_err = 0; + r = wifi_tls_take_step(reply.bytes, 8, SEQUENCE, &st); + check((r == WIFI_TLS_INVALID) && nothing_out(&st), "... but a bare 8-byte answer with no error is invalid"); + int states = 0; + for (int state = 4; state < 256; state++) { + size = step_reply((uint8_t)state, 0, 5, 5); + fresh_step(&st, 1024); + states += (wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st) == WIFI_TLS_INVALID) && nothing_out(&st); + } + check(states == 252, "a state that does not exist is invalid (%d of 252)", states); + + // Random answers: bytes only whole, only from an answer that holds them, + // plaintext only once established and never on a NO_READ step. + world_reset(99, NULL, true); + int broken = 0; + for (int n = 0; n < 300000; n++) { + for (int i = 0; i < 64; i++) { + reply.bytes[i] = (uint8_t)world_rand(256); + } + res = (rpc_tls_step_resp *)reply.bytes; + if (world_rand(2)) { + res->hdr.command = CMD_TLS_STEP; + res->hdr.sequence = SEQUENCE; + } + if (world_rand(2)) { + res->esp_err = world_rand(2) ? 0 : (world_rand(2) ? -0x2700 : 0x101); + } + if (world_rand(2)) { + res->state = world_rand(5); + } + if (world_rand(2)) { + res->fail_reason = world_rand(2) ? 0 : world_rand(8); + } + if (world_rand(2)) { + res->ct_out_len = world_rand(1100); + res->pt_out_len = world_rand(4) ? world_rand(1100) : 0; + } + size = world_rand(2) ? (int)world_rand(CMD_BUF_SIZE + 1) + : (int)(offsetof(rpc_tls_step_resp, data) + res->ct_out_len + res->pt_out_len); + if (size > CMD_BUF_SIZE) { + size = CMD_BUF_SIZE; + } + uint16_t room = (uint16_t)world_rand(1100); + fresh_step(&st, room); + st.flags = world_rand(2) ? WIFI_TLS_STEP_NO_READ : 0; + r = wifi_tls_take_step(reply.bytes, size, SEQUENCE, &st); + if ((r == 0) || (r == WIFI_TLS_AGAIN)) { + uint16_t ct = res->ct_out_len, pt = res->pt_out_len; + bool failed = (res->state == TLS_STATE_FAILED); + bool good = (ct <= room) && (pt <= room) && (size == (int)offsetof(rpc_tls_step_resp, data) + ct + pt) && + (st.ct_out_len == ct) && (res->state <= TLS_STATE_FAILED) && + (failed || (res->fail_reason == 0)) && + !((st.flags & WIFI_TLS_STEP_NO_READ) && pt) && + ((pt == 0) || failed || (res->state != TLS_STATE_HANDSHAKING)) && + (memcmp(ct_out, res->data, ct) == 0) && + (failed ? ((st.pt_out_len == 0) && untouched(pt_out)) + : ((st.pt_out_len == pt) && (memcmp(pt_out, res->data + ct, pt) == 0))); + broken += !good; + } else { + broken += !nothing_out(&st); + } + } + check(broken == 0, "300000 random answers: bytes only whole, only from an answer that holds them (%d not)", broken); +} + +static void test_take_others(void) +{ + printf("The checks on OPEN, CLOSE, STATS, CLOSE_ALL and SET_CA answers\n"); + int esp_err = 0; + uint8_t reason = 0x77; + + header(CMD_TLS_OPEN); + ((rpc_tls_open_resp *)reply.bytes)->slot = 1; + int r = wifi_tls_take_open(reply.bytes, sizeof(rpc_tls_open_resp), SEQUENCE, 1, &esp_err, &reason); + check(r == 0, "OPEN: 12 bytes, no error, slot 1 as asked: the session is open"); + int other = 0; + const uint8_t slots[] = { 0, 2, 0xFF }; + for (unsigned k = 0; k < sizeof(slots); k++) { + ((rpc_tls_open_resp *)reply.bytes)->slot = slots[k]; + other += (wifi_tls_take_open(reply.bytes, 12, SEQUENCE, 1, &esp_err, &reason) == WIFI_TLS_INVALID); + } + ((rpc_tls_open_resp *)reply.bytes)->slot = 1; + check(other == 3, "OPEN: success naming another slot (0, 2, 0xFF) is malformed (%d of 3)", other); + int wrong = 0; + const int open_sizes[] = { 4, 9, 10, 11, 13, 16 }; + for (unsigned k = 0; k < sizeof(open_sizes) / sizeof(open_sizes[0]); k++) { + wrong += (wifi_tls_take_open(reply.bytes, open_sizes[k], SEQUENCE, 1, &esp_err, &reason) == WIFI_TLS_INVALID); + } + check(wrong == 6, "OPEN: any size but 12 without an error is invalid (%d of 6)", wrong); + check(wifi_tls_take_open(reply.bytes, 8, SEQUENCE, 1, &esp_err, &reason) == WIFI_TLS_INVALID, + "OPEN: 8 bytes and no error is invalid"); + ((rpc_tls_open_resp *)reply.bytes)->esp_err = 0x103; + ((rpc_tls_open_resp *)reply.bytes)->reason = TLS_OPEN_REASON_NO_CUSTOM_CA; + r = wifi_tls_take_open(reply.bytes, sizeof(rpc_tls_open_resp), SEQUENCE, 1, &esp_err, &reason); + check((r == WIFI_TLS_REFUSED) && (esp_err == 0x103) && (reason == WIFI_TLS_REASON_NO_CUSTOM_CA), + "OPEN: refused, with reason 3 NO_CUSTOM_CA"); + // The refusal as the ESP32 sends it, slot 0xFF (rpc_dispatch.c cmd_tls_open). + ((rpc_tls_open_resp *)reply.bytes)->slot = 0xFF; + ((rpc_tls_open_resp *)reply.bytes)->reason = TLS_OPEN_REASON_NO_TIME; + r = wifi_tls_take_open(reply.bytes, sizeof(rpc_tls_open_resp), SEQUENCE, 1, &esp_err, &reason); + check((r == WIFI_TLS_REFUSED) && (reason == WIFI_TLS_REASON_NO_TIME), + "OPEN refused as the ESP32 sends it (slot byte 0xFF) -> REFUSED with its reason, not malformed"); + ((rpc_tls_open_resp *)reply.bytes)->slot = 1; + header(CMD_TLS_OPEN); + ((rpc_espcmd_resp *)reply.bytes)->esp_err = 0x106; + reason = 0; + r = wifi_tls_take_open(reply.bytes, 8, SEQUENCE, 1, &esp_err, &reason); + check((r == WIFI_TLS_REFUSED) && (esp_err == 0x106) && (reason == 0), + "OPEN: a module without TLS answers a bare NOT_SUPPORTED: refused (-> 90)"); + ((rpc_header_t *)reply.bytes)->command = CMD_TLS_STEP; + check(wifi_tls_take_open(reply.bytes, 12, SEQUENCE, 1, &esp_err, &reason) == WIFI_TLS_FOREIGN, "OPEN: a STEP answer is foreign"); + + uint8_t notify[64]; + uint16_t notify_len = 0x7777; + header(CMD_TLS_CLOSE); + rpc_tls_close_resp *c = (rpc_tls_close_resp *)reply.bytes; + c->ct_out_len = 24; + for (int i = 0; i < 24; i++) { + c->data[i] = (uint8_t)(0x90 + i); + } + r = wifi_tls_take_close(reply.bytes, 36, SEQUENCE, notify, sizeof(notify), ¬ify_len, &esp_err); + check((r == 0) && (notify_len == 24) && (notify[0] == 0x90) && (notify[23] == 0xA7), + "CLOSE: 12 + 24 bytes: the close_notify record arrives"); + check(wifi_tls_take_close(reply.bytes, 35, SEQUENCE, notify, sizeof(notify), ¬ify_len, &esp_err) == + WIFI_TLS_INVALID, "CLOSE: a byte short is invalid"); + check(wifi_tls_take_close(reply.bytes, 37, SEQUENCE, notify, sizeof(notify), ¬ify_len, &esp_err) == + WIFI_TLS_INVALID, "CLOSE: a byte long is invalid"); + check(wifi_tls_take_close(reply.bytes, 36, SEQUENCE, notify, 23, ¬ify_len, &esp_err) == WIFI_TLS_INVALID, + "CLOSE: a record past the room is invalid"); + c->ct_out_len = 0; + c->esp_err = 0x105; + r = wifi_tls_take_close(reply.bytes, 12, SEQUENCE, notify, sizeof(notify), ¬ify_len, &esp_err); + check((r == WIFI_TLS_REFUSED) && (esp_err == 0x105), "CLOSE: NOT_FOUND in the full answer is refused, with its error"); + r = wifi_tls_take_close(reply.bytes, 8, SEQUENCE, notify, sizeof(notify), ¬ify_len, &esp_err); + check((r == WIFI_TLS_REFUSED) && (esp_err == 0x105), "CLOSE: ... and as a bare 8-byte answer"); + + header(CMD_TLS_STATS); + rpc_tls_stats_resp *s = (rpc_tls_stats_resp *)reply.bytes; + s->heap_free = 100001; + s->tls_version = 0x0303; + s->ciphersuite = 0xC02F; + s->group = 0x0017; + s->state = TLS_STATE_ESTABLISHED; + s->time_source = 2; + s->entropy_source = 1; + s->ems = 1; + s->block_max_ms = 0x1234; + for (int i = 0; i < 32; i++) { + s->spki_sha256[i] = (uint8_t)(i * 7); + } + wifi_tls_stats_t stats; + memset(&stats, 0, sizeof(stats)); + r = wifi_tls_take_stats(reply.bytes, sizeof(rpc_tls_stats_resp), SEQUENCE, &stats, &esp_err); + check((r == 0) && (stats.heap_free == 100001) && (stats.tls_version == 0x0303) && (stats.ciphersuite == 0xC02F) && + (stats.group == 0x0017) && (stats.time_source == 2) && (stats.entropy_source == 1) && (stats.ems == 1) && + (stats.block_max_ms == 0x1234) && (stats.spki_sha256[0] == 0) && (stats.spki_sha256[31] == 217), + "STATS: 96 bytes, entropy, ems, block_max_ms and the SPKI hash arrive"); + const int stat_sizes[] = { 8, 60, 64, 95, 97 }; + wrong = 0; + for (unsigned k = 0; k < sizeof(stat_sizes) / sizeof(stat_sizes[0]); k++) { + memset(&stats, 0, sizeof(stats)); + wrong += (wifi_tls_take_stats(reply.bytes, stat_sizes[k], SEQUENCE, &stats, &esp_err) == WIFI_TLS_INVALID) && + (stats.heap_free == 0); + } + check(wrong == 5, "STATS: any size but 96, the older 60 included, is invalid (%d of 5)", wrong); + + header(CMD_TLS_CLOSE_ALL); + check(wifi_tls_take_close_all(reply.bytes, 8, SEQUENCE, &esp_err) == 0, "CLOSE_ALL: 8 bytes, no error"); + check(wifi_tls_take_close_all(reply.bytes, 12, SEQUENCE, &esp_err) == WIFI_TLS_INVALID, "CLOSE_ALL: 12 is invalid"); + ((rpc_espcmd_resp *)reply.bytes)->esp_err = 0x106; + check(wifi_tls_take_close_all(reply.bytes, 8, SEQUENCE, &esp_err) == WIFI_TLS_REFUSED, "CLOSE_ALL: an error"); + + struct { int err; int reject; int want; } ca[] = { + { 0, 0, 0 }, + { -0x2180, 0, WIFI_TLS_REFUSED }, + { -2, 0, WIFI_TLS_REFUSED }, + { -1, 0, WIFI_TLS_INVALID }, // ESP_FAIL is not a parse code + { 0, 1, WIFI_TLS_INVALID }, + { 0x102, 1, WIFI_TLS_REFUSED }, + { 0x102, 3, WIFI_TLS_REFUSED }, + { 0x102, 4, WIFI_TLS_REFUSED }, + { 0x102, 0, WIFI_TLS_INVALID }, + { 0x102, 2, WIFI_TLS_INVALID }, // reserved (was WEAK_SIG_HASH) + { 0x102, 5, WIFI_TLS_INVALID }, + { 0x101, 0, WIFI_TLS_INVALID }, // NO_MEM + { -0x2180, 1, WIFI_TLS_INVALID }, + }; + int good = 0; + for (unsigned k = 0; k < sizeof(ca) / sizeof(ca[0]); k++) { + header(CMD_TLS_SET_CA); + ((rpc_tls_set_ca_resp *)reply.bytes)->esp_err = ca[k].err; + ((rpc_tls_set_ca_resp *)reply.bytes)->reject = ca[k].reject; + int e = 0x77; + uint8_t j = 0x77; + r = wifi_tls_take_set_ca(reply.bytes, 12, SEQUENCE, &e, &j); + bool ok = (r == ca[k].want) && ((r != WIFI_TLS_REFUSED) || ((e == ca[k].err) && (j == ca[k].reject))); + if (!ok) { + printf(" SET_CA %d/%d gave %d\n", ca[k].err, ca[k].reject, r); + } + good += ok; + } + check(good == (int)(sizeof(ca) / sizeof(ca[0])), "SET_CA: only the three well formed answers pass"); + header(CMD_TLS_SET_CA); + check(wifi_tls_take_set_ca(reply.bytes, 11, SEQUENCE, &esp_err, &reason) == WIFI_TLS_INVALID, "SET_CA: 11 bytes"); + ((rpc_espcmd_resp *)reply.bytes)->esp_err = 0x106; + check(wifi_tls_take_set_ca(reply.bytes, 8, SEQUENCE, &esp_err, &reason) == WIFI_TLS_REFUSED && esp_err == 0x106, + "SET_CA: a bare NOT_SUPPORTED is refused (-> 90)"); +} + +// Answers to the TLS calls, from what the request asked. +static void tls_maker(command_buf_t *rx, const uint8_t *req, int req_size, int kind) +{ + const rpc_header_t *request = (const rpc_header_t *)req; + memset(rx->data, 0, sizeof(rx->data)); + rpc_header_t *hdr = (rpc_header_t *)rx->data; + *hdr = *request; + switch (request->command) { + case CMD_TLS_OPEN: + ((rpc_tls_open_resp *)rx->data)->slot = ((const rpc_tls_open_req *)req)->slot; + rx->size = sizeof(rpc_tls_open_resp); + break; + case CMD_TLS_STEP: { + rpc_tls_step_resp *r = (rpc_tls_step_resp *)rx->data; + r->state = TLS_STATE_ESTABLISHED; + r->alert_in = 0xFF; + r->alert_out = 0xFF; + r->ct_out_len = 5; + r->pt_out_len = 4; + for (int i = 0; i < 9; i++) { + r->data[i] = (uint8_t)(i + 1); + } + rx->size = offsetof(rpc_tls_step_resp, data) + 9; + break; + } + case CMD_TLS_CLOSE: + rx->size = sizeof(rpc_tls_close_resp); + break; + case CMD_TLS_STATS: + ((rpc_tls_stats_resp *)rx->data)->heap_free = 123456; + rx->size = sizeof(rpc_tls_stats_resp); + break; + case CMD_TLS_SET_CA: + rx->size = sizeof(rpc_tls_set_ca_resp); + break; + default: + rx->size = sizeof(rpc_espcmd_resp); + break; + } +} + +static void late_maker(command_buf_t *rx, const uint8_t *req, int req_size, int kind) +{ + tls_maker(rx, req, req_size, kind); + ((rpc_header_t *)rx->data)->sequence++; +} + +// The request that went out, as the world recorded it: "transmit n: xx xx ...". +static std::string sent(void) +{ + size_t at = world_trace.find("transmit "); + if (at == std::string::npos) { + return ""; + } + size_t end = world_trace.find('\n', at); + return world_trace.substr(at, end - at); +} + +static std::string hex(const uint8_t *bytes, int n) +{ + std::string out; + char b[4]; + for (int i = 0; i < n; i++) { + snprintf(b, sizeof(b), " %02x", bytes[i]); + out += b; + } + return out; +} + +static int cancel_calls; +static int cancel_after; +static bool cancel_after_n(void *context) +{ + return ++cancel_calls >= cancel_after; +} + +static int count(const std::string &text, const std::string &what) +{ + int n = 0; + for (size_t at = text.find(what); at != std::string::npos; at = text.find(what, at + 1)) { + n++; + } + return n; +} + +static void test_calls(void) +{ + printf("The TLS calls through the channel (wire layouts, byte for byte)\n"); + int esp_err = 0x55; + uint8_t reason = 0x55; + + uint8_t pin[32]; + for (int i = 0; i < 32; i++) { + pin[i] = (uint8_t)(0xE0 + i); + } + wifi_tls_open_t o; + memset(&o, 0, sizeof(o)); + o.trust = WIFI_TLS_TRUST_PIN; + o.slot = 1; + o.tag = 0x0203; + o.opts = WIFI_TLS_OPT_REQUIRE_TLS13; + o.time_source = WIFI_TLS_TIME_NIOS; + o.unix_time = 0x6789ABCD; + o.ca_tag = 0x0405; + o.pin = pin; + o.sni = "a.b"; + o.sni_len = 3; + world_reset(1, tls_maker, true); + uint16_t seq = sequence_nr; + int r = wifi_tls_open(&o, 5000, NULL, &esp_err, &reason); + const uint8_t fixed[] = { CMD_TLS_OPEN, WIFI_DEDICATED_THREAD, (uint8_t)seq, (uint8_t)(seq >> 8), 2, 3, 1, 1, + 0xCD, 0xAB, 0x89, 0x67, 0x03, 0x02, 0x01, 0, 0x05, 0x04, 0, 0 }; + std::string want = "transmit 55:" + hex(fixed, 20) + hex(pin, 32) + hex((const uint8_t *)"a.b", 3); + check((r == 0) && (esp_err == 0) && (sent() == want), + "OPEN: hdr, trust, sni_len, slot, time_source, unix_time, tag, opts, 0, ca_tag, 0 0, pin[32], sni"); + o.pin = NULL; + o.sni = NULL; + o.sni_len = 0; + o.trust = 0; + world_reset(2, tls_maker, true); + r = wifi_tls_open(&o, 5000, NULL, &esp_err, &reason); + std::string s = sent(); + check((r == 0) && (s.compare(0, 12, "transmit 52:") == 0) && (count(s, " 00") >= 36), + "OPEN: no name, no pin: 52 bytes, the pin as zeros"); + o.sni_len = 254; + world_reset(3, tls_maker, true); + r = wifi_tls_open(&o, 5000, NULL, &esp_err, &reason); + check((r == WIFI_TLS_TOO_LONG) && (world_trace.find("getbuffer") == std::string::npos), "OPEN: 254 bytes of name send nothing"); + + wifi_tls_step_t st; + uint8_t ct_in[3] = { 0xA1, 0xA2, 0xA3 }; + uint8_t pt_in[2] = { 0xB1, 0xB2 }; + fresh_step(&st, 1024); + st.flags = WIFI_TLS_STEP_NO_READ; + st.ct_in = ct_in; + st.ct_in_len = 3; + st.pt_in = pt_in; + st.pt_in_len = 2; + world_reset(6, tls_maker, true); + seq = sequence_nr; + r = wifi_tls_step(1, 0x0A0B, &st, 5000, NULL); + uint8_t expect_step[] = { CMD_TLS_STEP, WIFI_DEDICATED_THREAD, (uint8_t)seq, (uint8_t)(seq >> 8), 1, 1, 0x0B, + 0x0A, 3, 0, 2, 0, 0xA1, 0xA2, 0xA3, 0xB1, 0xB2 }; + check((r == WIFI_TLS_INVALID) && (sent() == "transmit 17:" + hex(expect_step, sizeof(expect_step))), + "STEP: slot, flags, tag, ct_in_len, pt_in_len, ciphertext, plaintext (and the maker's plaintext on NO_READ is refused)"); + fresh_step(&st, 1024); + st.ct_in = ct_in; + st.ct_in_len = 3; + world_reset(7, tls_maker, true); + r = wifi_tls_step(0, 1, &st, 5000, NULL); + check((r == 0) && (st.ct_out_len == 5) && (st.pt_out_len == 4) && (ct_out[0] == 1) && (pt_out[0] == 6), + "STEP: the answer is split into ciphertext and plaintext"); + static uint8_t big[WIFI_TLS_STEP_MAX_IN + 1]; + fresh_step(&st, 1024); + st.ct_in = big; + st.ct_in_len = 1537; + world_reset(8, tls_maker, true); + r = wifi_tls_step(0, 1, &st, 5000, NULL); + check((r == WIFI_TLS_TOO_LONG) && (world_trace.find("getbuffer") == std::string::npos), "STEP: 1537 bytes in send nothing"); + st.ct_in_len = 1536; + world_reset(8, tls_maker, true); + r = wifi_tls_step(0, 1, &st, 5000, NULL); + check((r == 0) && (sent().compare(0, 15, "transmit 1548: ") == 0), "STEP: 1536 bytes in go in one request"); + + uint8_t notify[64]; + uint16_t notify_len; + world_reset(9, tls_maker, true); + seq = sequence_nr; + r = wifi_tls_close(1, 0xBEEF, notify, sizeof(notify), ¬ify_len, &esp_err, 1000, NULL); + uint8_t expect_close[] = { CMD_TLS_CLOSE, WIFI_DEDICATED_THREAD, (uint8_t)seq, (uint8_t)(seq >> 8), 1, 0, + 0xEF, 0xBE }; + check((r == 0) && (notify_len == 0) && (sent() == "transmit 8:" + hex(expect_close, sizeof(expect_close))), + "CLOSE: slot, 0, tag (8 bytes)"); + wifi_tls_stats_t stats; + world_reset(10, tls_maker, true); + seq = sequence_nr; + r = wifi_tls_stats(WIFI_TLS_SLOT_GLOBAL, 0, &stats, &esp_err, 1000, NULL); + uint8_t expect_stats[] = { CMD_TLS_STATS, WIFI_DEDICATED_THREAD, (uint8_t)seq, (uint8_t)(seq >> 8), 0xFF, 0, + 0, 0 }; + check((r == 0) && (stats.heap_free == 123456) && (sent() == "transmit 8:" + hex(expect_stats, 8)), + "STATS: the module as a whole is slot $FF, tag 0"); + world_reset(11, tls_maker, true); + seq = sequence_nr; + r = wifi_tls_close_all(&esp_err, 500); + uint8_t expect_all[] = { CMD_TLS_CLOSE_ALL, WIFI_DEDICATED_THREAD, (uint8_t)seq, (uint8_t)(seq >> 8) }; + check((r == 0) && (sent() == "transmit 4:" + hex(expect_all, 4)), "CLOSE_ALL: the header only"); + uint8_t der[5] = { 0x30, 0x82, 0x01, 0x02, 0x03 }; + uint8_t reject; + world_reset(12, tls_maker, true); + seq = sequence_nr; + r = wifi_tls_set_ca(der, 5, 0x1122, &esp_err, &reject, 5000, NULL); + uint8_t expect_ca[] = { CMD_TLS_SET_CA, WIFI_DEDICATED_THREAD, (uint8_t)seq, (uint8_t)(seq >> 8), 5, 0, + 0x22, 0x11, 0x30, 0x82, 0x01, 0x02, 0x03 }; + check((r == 0) && (sent() == "transmit 13:" + hex(expect_ca, sizeof(expect_ca))), "SET_CA: der_len, ca_tag, der"); + static uint8_t big_ca[WIFI_TLS_CA_MAX + 1]; + world_reset(12, tls_maker, true); + r = wifi_tls_set_ca(big_ca, WIFI_TLS_CA_MAX + 1, 1, &esp_err, &reject, 5000, NULL); + check((r == WIFI_TLS_TOO_LONG) && (world_trace.find("getbuffer") == std::string::npos), "SET_CA: 1473 bytes send nothing"); + world_reset(12, tls_maker, true); + r = wifi_tls_set_ca(big_ca, WIFI_TLS_CA_MAX, 1, &esp_err, &reject, 5000, NULL); + check((r == 0) && (sent().compare(0, 15, "transmit 1480: ") == 0), "SET_CA: 1472 bytes go in one request"); + + // The waits: each call its caller's timeout; with a cancel, in slices. + world_reset(13, late_maker, true); + fresh_step(&st, 1024); + r = wifi_tls_step(0, 1, &st, 5000, NULL); + check((r == WIFI_TLS_BUSY) && (world_trace.find("receive 1000") != std::string::npos) && !dedicated_waiting, + "no cancel: one wait of the whole timeout (5 s = 1000 ticks), then BUSY"); + world_reset(14, late_maker, true); + cancel_calls = 0; + cancel_after = 1000; + wifi_tls_cancel_t never = { cancel_after_n, NULL }; + fresh_step(&st, 1024); + r = wifi_tls_step(0, 1, &st, 1000, &never); + check((r == WIFI_TLS_BUSY) && (count(world_trace, "receive 20") == 10) && (cancel_calls == 10) && + (world_trace.find("print: TLS Step: no reply.") != std::string::npos), + "a cancel that never fires: ten 100-ms slices, asked after each (%d), then BUSY", cancel_calls); + world_reset(15, late_maker, true); + cancel_calls = 0; + cancel_after = 3; + wifi_tls_cancel_t soon = { cancel_after_n, NULL }; + fresh_step(&st, 1024); + r = wifi_tls_step(0, 1, &st, 5000, &soon); + // The first slice brings the late (foreign) answer and is skipped; three empty ones follow. + check((r == WIFI_TLS_BUSY) && (cancel_calls == 3) && (count(world_trace, "receive 20") == 4) && + (world_trace.find("print: TLS Step: cancelled.") != std::string::npos) && !dedicated_waiting && + (world_queued() == 0) && (st.ct_out_len == 0) && (st.pt_out_len == 0) && untouched(ct_out) && + untouched(pt_out), + "a cancel after 3 slices ends the call with BUSY at once, frees the channel, takes nothing"); + // The answer arrives just as the cancel fires: the call has given up, so + // it is dropped, not taken. + world_reset(20, late_maker, true); + fresh_step(&st, 1024); + struct arriving_right { + static void maker(command_buf_t *rx, const uint8_t *req, int req_size, int kind) + { + tls_maker(rx, req, req_size, kind); + } + static bool now(void *context) + { + world_reset_maker(maker); + world_deliver_now(); + return true; + } + }; + wifi_tls_cancel_t race = { arriving_right::now, NULL }; + r = wifi_tls_step(0, 1, &st, 5000, &race); + check((r == WIFI_TLS_BUSY) && (st.ct_out_len == 0) && untouched(ct_out) && (world_queued() == 0) && + !dedicated_waiting, + "an answer that arrives as the cancel fires is dropped: BUSY, nothing taken, the queue emptied (%d)", r); + + world_reset(16, tls_maker, true); + cancel_calls = 0; + cancel_after = 1; + fresh_step(&st, 1024); + r = wifi_tls_step(0, 1, &st, 5000, &soon); + check((r == 0) && (cancel_calls == 0), "an answer inside the first slice is taken; cancel is not even asked"); + world_reset(17, tls_maker, true); + world_ready = false; + r = wifi_tls_close_all(&esp_err, 500); + check((r == WIFI_TLS_NO_MODULE) && world_trace.empty(), "without the module application nothing is tried"); + world_reset(18, tls_maker, true); + dedicated_waiting = true; + r = wifi_tls_stats(0, 1, &stats, &esp_err, 1000, NULL); + check((r == WIFI_TLS_UNSENT) && dedicated_waiting, "another request outstanding: UNSENT at once"); +} + +int main(void) +{ + test_take_step(); + test_take_others(); + test_calls(); + printf("\n%d checks, %d failures\n", checks, failures); + return failures ? 1 : 0; +} diff --git a/software/test/wifi_tls/world.cc b/software/test/wifi_tls/world.cc new file mode 100644 index 000000000..e459fb125 --- /dev/null +++ b/software/test/wifi_tls/world.cc @@ -0,0 +1,269 @@ +/* + * world.cc: see world.h. + */ +#include +#include +#include +#include "world.h" + +Esp32 esp32; +uint16_t sequence_nr; +const char *no_wifi_buf = "No buffer for WiFi command.\n"; +QueueHandle_t dedicated_replies; +volatile bool dedicated_waiting; + +bool world_ready; +bool world_no_buffer; +bool world_no_transmit; +std::string world_trace; +int world_suspended; +int world_transmits; +int world_isr_calls; + +#define QUEUE_DEPTH 4 // as wifi_cmd.cc creates it +#define RX_BUFFERS 16 + +static DmaUART uart; +static std::deque queue; +static uint32_t rng; +static TickType_t now; +static command_buf_t tx_buf; +static command_buf_t rx_bufs[RX_BUFFERS]; +static int rx_next; +static uint8_t last_tx[CMD_BUF_SIZE]; +static int last_tx_size; +static world_maker_t make_reply; +static bool calm; +static bool calm_delivered; + +static void trace(const char *fmt, ...) +{ + char line[256]; + va_list ap; + va_start(ap, fmt); + vsnprintf(line, sizeof(line), fmt, ap); + va_end(ap); + world_trace += line; +} + +uint32_t world_rand(uint32_t n) +{ + rng ^= rng << 13; + rng ^= rng >> 17; + rng ^= rng << 5; + return n ? (rng % n) : 0; +} + +size_t world_queued(void) +{ + return queue.size(); +} + +void world_reset(uint32_t seed, world_maker_t maker, bool quiet) +{ + rng = (seed * 2654435761u) ^ 0x9E3779B9u; + if (!rng) { + rng = 1; + } + make_reply = maker; + calm = quiet; + calm_delivered = false; + world_trace.clear(); + queue.clear(); + world_suspended = 0; + world_transmits = 0; + world_isr_calls = 0; + rx_next = 0; + last_tx_size = -1; + // Now and then start just short of the tick counter wrapping. + now = (world_rand(4) == 0) ? (0xFFFFFFFFu - world_rand(400)) : world_rand(100000); + sequence_nr = (uint16_t)world_rand(65536); + uart.generation = world_rand(1000); + esp32.uart = &uart; + world_ready = calm || (world_rand(100) >= 3); + world_no_buffer = false; + world_no_transmit = false; + dedicated_replies = (!calm && (world_rand(100) < 2)) ? NULL : (QueueHandle_t)&queue; + dedicated_waiting = !calm && (world_rand(100) < 5); // another caller holds the channel + memset(tx_buf.data, 0xAB, sizeof(tx_buf.data)); + tx_buf.bufnr = 3; + for (int i = 0; i < RX_BUFFERS; i++) { + rx_bufs[i].bufnr = 0x40 | i; + } +} + +// The receive interrupt, as wifi_rx_isr handles a frame on the dedicated thread. +static void isr_deliver(void) +{ + command_buf_t *rx = &rx_bufs[rx_next++ % RX_BUFFERS]; + int kind = calm ? 0 : (int)world_rand(10); + make_reply(rx, last_tx, last_tx_size, kind); + uint32_t generation = uart.generation; + if (!calm && (world_rand(10) == 0)) { + generation--; // tagged before a reset that has since happened + } + world_isr_calls++; + if (!dedicated_waiting) { + trace("isr drop b%x (not waiting)\n", rx->bufnr); + } else if (queue.size() >= QUEUE_DEPTH) { + trace("isr drop b%x (full)\n", rx->bufnr); + } else { + dedicated_reply_t reply = { rx, generation }; + queue.push_back(reply); + trace("isr queue b%x g%u k%d\n", rx->bufnr, generation, kind); + } +} + +void world_reset_maker(world_maker_t maker) +{ + make_reply = maker; +} + +void world_deliver_now(void) +{ + isr_deliver(); +} + +TickType_t xTaskGetTickCount(void) +{ + if (!calm && (world_rand(5) == 0)) { + now += world_rand(11); // preempted for a while + } + trace("tick %u\n", now); + return now; +} + +void vTaskSuspendAll(void) +{ + world_suspended++; + trace("suspend\n"); +} + +BaseType_t xTaskResumeAll(void) +{ + world_suspended--; + trace("resume\n"); + return pdFALSE; +} + +void vTaskDelay(TickType_t ticks) +{ + now += ticks; + trace("delay %u\n", ticks); +} + +BaseType_t xQueueReceive(QueueHandle_t q, void *item, TickType_t ticks) +{ + trace("receive %u", ticks); + if (q != (QueueHandle_t)&queue) { + trace(" wrong queue\n"); + return pdFALSE; + } + if (queue.empty() && (ticks > 0)) { + if (calm) { + if (!calm_delivered) { + calm_delivered = true; + now += 1; + isr_deliver(); + } else { + now += ticks; + } + } else if (world_rand(10) < 6) { + TickType_t delay = world_rand(ticks); + now += delay; + if (world_rand(10) == 0) { + uart.generation++; + trace(" reset"); + } + int burst = 1 + world_rand((world_rand(4) == 0) ? 6 : 3); // more than the queue holds, now and then + for (int i = 0; i < burst; i++) { + isr_deliver(); + } + if (queue.empty()) { + now += ticks - delay; // nothing came through; wait it out + } + } else { + now += ticks; + } + } + if (queue.empty()) { + trace(" -> none\n"); + return pdFALSE; + } + *(dedicated_reply_t *)item = queue.front(); + queue.pop_front(); + trace(" -> b%x\n", ((dedicated_reply_t *)item)->buf->bufnr); + return pdTRUE; +} + +BaseType_t DmaUART::GetBuffer(command_buf_t **buf, TickType_t ticks) +{ + trace("getbuffer %u", ticks); + if (world_no_buffer || (!calm && (world_rand(100) < 5))) { + now += ticks; + trace(" -> none\n"); + return pdFALSE; + } + tx_buf.size = 0; + tx_buf.dropped = 0; + *buf = &tx_buf; + trace(" -> b%x\n", tx_buf.bufnr); + return pdTRUE; +} + +BaseType_t DmaUART::TransmitPacket(command_buf_t *buf, uint16_t *ms) +{ + trace("transmit %d:", buf->size); + for (int i = 0; (i < buf->size) && (i < CMD_BUF_SIZE); i++) { + trace(" %02x", buf->data[i]); + } + if (world_no_transmit || (!calm && (world_rand(100) < 5))) { + trace(" -> failed\n"); + return pdFALSE; // the real one frees the buffer itself + } + trace("\n"); + world_transmits++; + memcpy(last_tx, buf->data, CMD_BUF_SIZE); + last_tx_size = buf->size; + // Late replies to earlier requests, or even this one, before the wait. + if (!calm && (world_rand(100) < 15)) { + int burst = 1 + world_rand(2); + for (int i = 0; i < burst; i++) { + isr_deliver(); + } + } + return pdTRUE; +} + +BaseType_t DmaUART::FreeBuffer(command_buf_t *buf) +{ + trace("free b%x%s\n", buf->bufnr, world_suspended ? "" : " (not suspended)"); + return pdTRUE; +} + +void world_enter_safe(void) +{ + trace("enter\n"); +} + +void world_leave_safe(void) +{ + trace("leave\n"); +} + +int world_printf(const char *fmt, ...) +{ + char line[256]; + va_list ap; + va_start(ap, fmt); + int n = vsnprintf(line, sizeof(line), fmt, ap); + va_end(ap); + world_trace += "print: "; + world_trace += line; + return n; +} + +bool wifi_module_ready(void) +{ + return world_ready; +} diff --git a/software/test/wifi_tls/world.h b/software/test/wifi_tls/world.h new file mode 100644 index 000000000..25f58db64 --- /dev/null +++ b/software/test/wifi_tls/world.h @@ -0,0 +1,31 @@ +// The scripted world the host tests run wifi_dedicated.cc in: module replies, receive interrupt, tick, buffer pool and +// resets. Every decision comes from one generator, so two implementations that make the same calls in the same +// order see the same world; they are compared on the trace of those calls. +#ifndef WORLD_H_ +#define WORLD_H_ + +#include +#include "wifi_cmd.h" + +// Builds a reply of the given kind into rx, as an answer to the last request +// sent (req, req_size; req_size is -1 when nothing has been sent). kind 0 is +// the right answer; the others are up to the maker. +typedef void (*world_maker_t)(command_buf_t *rx, const uint8_t *req, int req_size, int kind); + +// Starts a new world from seed. With calm set nothing fails and the first +// wait delivers exactly one right answer. +void world_reset(uint32_t seed, world_maker_t maker, bool calm); +uint32_t world_rand(uint32_t n); + +extern bool world_ready; // what wifi_module_ready answers +extern bool world_no_buffer; // GetBuffer fails, even when calm +extern bool world_no_transmit; // TransmitPacket fails, even when calm +extern std::string world_trace; // every call, in order +extern int world_suspended; // vTaskSuspendAll minus xTaskResumeAll +extern int world_transmits; // requests that went out +extern int world_isr_calls; // replies the interrupt handled +size_t world_queued(void); // replies still in dedicated_replies +void world_deliver_now(void); // the receive interrupt hands over an answer now +void world_reset_maker(world_maker_t maker); // answers from now on come from maker + +#endif /* WORLD_H_ */ diff --git a/target/pc/linux/wifitls/Makefile b/target/pc/linux/wifitls/Makefile new file mode 100644 index 000000000..d47892263 --- /dev/null +++ b/target/pc/linux/wifitls/Makefile @@ -0,0 +1,66 @@ +# Host build of the checks on the TLS calls to the WiFi module, on the channel they use (wifi_dedicated.cc) +# and on the network target's TLS commands; FreeRTOS, the UART, lwIP and the module are stand-ins. +# make (build), make test (build and run) +RESULT = result +OUTPUT = output + +PATH_SW = ../../../../software +TEST = $(PATH_SW)/test/wifi_tls + +VPATH = $(TEST)/stub $(TEST) $(PATH_SW)/io/wifi $(PATH_SW)/io/uart $(PATH_SW)/wifi/raw_u64/main + +CXX = g++ +CPPOPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter -DNIOS=1 -DU64=1 \ + $(addprefix -I, $(VPATH)) + +TLS_SRCS = wifi_tls_test.cc world.cc wifi_tls.cc wifi_dedicated.cc +TLS_OBJS = $(addprefix $(OUTPUT)/tls/, $(TLS_SRCS:%.cc=%.o)) + +# The network target's sources, which a red run can point at another tree. +NET_DIR = $(PATH_SW)/io/network +NET_PATH = $(TEST)/netstub $(TEST)/stub $(NET_DIR) $(PATH_SW)/io/wifi $(PATH_SW)/io/command_interface +NET_OPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -DNIOS=1 -DU64=1 $(addprefix -I, $(NET_PATH)) +NET_SRCS = net_tls_test.cc net_world.cc ip4addr_aton.cc +NET_OBJS = $(addprefix $(OUTPUT)/net/, $(NET_SRCS:%.cc=%.o)) $(OUTPUT)/net/network_target.o $(OUTPUT)/net/network_target_tls.o + +.PHONY: all test clean + +all: $(RESULT)/wifitls $(RESULT)/nettls + +$(OUTPUT)/tls/%.o: %.cc + @mkdir -p $(OUTPUT)/tls + $(CXX) $(CPPOPTIONS) -c -o $@ $< + +# wifi_dedicated.cc includes "wifi_cmd.h", which the compiler looks for next to +# the source before anywhere else. A copy compiled from here finds the +# stand-in instead; it is the same file, byte for byte. +$(OUTPUT)/tls/wifi_dedicated.o: $(PATH_SW)/io/wifi/wifi_dedicated.cc + @mkdir -p $(OUTPUT)/tls + cp $< $(OUTPUT)/tls/wifi_dedicated.cc + $(CXX) $(CPPOPTIONS) -c -o $@ $(OUTPUT)/tls/wifi_dedicated.cc + +$(OUTPUT)/net/%.o: $(TEST)/%.cc + @mkdir -p $(OUTPUT)/net + $(CXX) $(NET_OPTIONS) -c -o $@ $< + +# Compiled from a copy, so that its includes find the stand-ins rather than +# the headers next to it (network_interface.h). +$(OUTPUT)/net/network_target.o $(OUTPUT)/net/network_target_tls.o: $(OUTPUT)/net/%.o: $(NET_DIR)/%.cc $(NET_DIR)/network_target.h + @mkdir -p $(OUTPUT)/net + cp $< $(OUTPUT)/net/$*.cc + $(CXX) $(NET_OPTIONS) -c -o $@ $(OUTPUT)/net/$*.cc + +$(RESULT)/wifitls: $(TLS_OBJS) + @mkdir -p $(RESULT) + $(CXX) -o $@ $(TLS_OBJS) + +$(RESULT)/nettls: $(NET_OBJS) + @mkdir -p $(RESULT) + $(CXX) -o $@ $(NET_OBJS) + +test: all + @$(RESULT)/wifitls + @$(RESULT)/nettls + +clean: + @rm -rf $(OUTPUT) $(RESULT) diff --git a/target/u2/microblaze/mb_ultimate/Makefile b/target/u2/microblaze/mb_ultimate/Makefile index 66960981b..7ca510212 100644 --- a/target/u2/microblaze/mb_ultimate/Makefile +++ b/target/u2/microblaze/mb_ultimate/Makefile @@ -117,6 +117,7 @@ SRCS_CC = small_printf.cc \ command_intf.cc \ dos.cc \ network_target.cc \ + network_target_tls.cc \ control_target.cc \ filetype_tap.cc \ socket_stream.cc \ diff --git a/target/u2/riscv/ultimate/Makefile b/target/u2/riscv/ultimate/Makefile index e46483b94..2b0472bdf 100755 --- a/target/u2/riscv/ultimate/Makefile +++ b/target/u2/riscv/ultimate/Makefile @@ -131,6 +131,7 @@ SRCS_CC = small_printf.cc \ command_intf.cc \ dos.cc \ network_target.cc \ + network_target_tls.cc \ control_target.cc \ filetype_tap.cc \ socket_stream.cc \ diff --git a/target/u2plus/nios/ultimate/Makefile b/target/u2plus/nios/ultimate/Makefile index eafc7669b..f1542ccf9 100755 --- a/target/u2plus/nios/ultimate/Makefile +++ b/target/u2plus/nios/ultimate/Makefile @@ -140,6 +140,7 @@ SRCS_CC = u2p_init.cc \ command_intf.cc \ dos.cc \ network_target.cc \ + network_target_tls.cc \ control_target.cc \ filetype_tap.cc \ socket_stream.cc \ diff --git a/target/u2plus_L/riscv/ultimate/Makefile b/target/u2plus_L/riscv/ultimate/Makefile index 4591f081b..cea6fa6a5 100755 --- a/target/u2plus_L/riscv/ultimate/Makefile +++ b/target/u2plus_L/riscv/ultimate/Makefile @@ -145,6 +145,7 @@ SRCS_CC = u2pl_init.cc \ command_intf.cc \ dos.cc \ network_target.cc \ + network_target_tls.cc \ control_target.cc \ filetype_tap.cc \ socket_stream.cc \ diff --git a/target/u64/nios2/ultimate/Makefile b/target/u64/nios2/ultimate/Makefile index 41e1626d6..457655369 100755 --- a/target/u64/nios2/ultimate/Makefile +++ b/target/u64/nios2/ultimate/Makefile @@ -149,6 +149,7 @@ SRCS_CC = u2p_init.cc \ command_intf.cc \ dos.cc \ network_target.cc \ + network_target_tls.cc \ control_target.cc \ filetype_tap.cc \ socket_stream.cc \ @@ -166,6 +167,7 @@ SRCS_CC = u2p_init.cc \ wifi_cmd.cc \ wifi_random.cc \ wifi_dedicated.cc \ + wifi_tls.cc \ acia.cc \ modem.cc \ listener_socket.cc \ diff --git a/target/u64/riscv/ultimate/Makefile b/target/u64/riscv/ultimate/Makefile index 8d962faa1..836932dfc 100755 --- a/target/u64/riscv/ultimate/Makefile +++ b/target/u64/riscv/ultimate/Makefile @@ -138,6 +138,7 @@ SRCS_CC = u2p_init.cc \ command_intf.cc \ dos.cc \ network_target.cc \ + network_target_tls.cc \ control_target.cc \ softiec_target.cc \ iec.cc \ diff --git a/target/u64ii/riscv/ultimate/Makefile b/target/u64ii/riscv/ultimate/Makefile index 337d413e1..2dedf04f8 100755 --- a/target/u64ii/riscv/ultimate/Makefile +++ b/target/u64ii/riscv/ultimate/Makefile @@ -154,6 +154,7 @@ SRCS_CC = u64ii_init.cc \ command_intf.cc \ dos.cc \ network_target.cc \ + network_target_tls.cc \ control_target.cc \ filetype_tap.cc \ socket_stream.cc \ From 08a82094997754e38f8e4c8397ea42e74b8ba344 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Wed, 14 Oct 2026 08:32:32 -0500 Subject: [PATCH 52/95] E2E: TLS sockets on the UCI network target (uci-net-tls) net_tls_test.py drives OPEN_TLS, TLS_TRUST_CA, TLS_INFO, START_TLS and TLS_RELEASE on a real device, against a TLS server on this host and the Internet. It is opt-in by name, never part of a profile: it can switch "WiFi Enabled" on (--set-wifi), needs this host as a TLS peer and the Internet, and fails on an image without the TLS commands. net_tls_selftest.py (registered as uci-net-tls-selftest, needs no device) runs it against a simulated device: green with the TLS commands, red on a stock one, and every mutant of the simulated device caught. uci_agent.asm gets OPT_WAIT, a per-transaction limit on how long the agent waits for a command (an OPEN_TLS can take 41 s); zero keeps the old default. uci_native.py passes it through. Co-Authored-By: Claude Opus 5.5 (1M context) --- run-tests | 5 + tests/e2e/io/command_interface/.gitignore | 2 + .../io/command_interface/internet_hosts.json | 17 + .../io/command_interface/net_tls_fixture.py | 494 +++++ .../e2e/io/command_interface/net_tls_mock.py | 487 +++++ .../e2e/io/command_interface/net_tls_proto.py | 569 ++++++ .../io/command_interface/net_tls_selftest.py | 696 +++++++ .../e2e/io/command_interface/net_tls_test.py | 1626 +++++++++++++++++ tests/e2e/io/command_interface/uci_agent.asm | 23 +- tests/e2e/lib/uci_native.py | 11 +- tests/lib/registry_test.py | 11 +- 11 files changed, 3929 insertions(+), 12 deletions(-) create mode 100644 tests/e2e/io/command_interface/.gitignore create mode 100644 tests/e2e/io/command_interface/internet_hosts.json create mode 100644 tests/e2e/io/command_interface/net_tls_fixture.py create mode 100644 tests/e2e/io/command_interface/net_tls_mock.py create mode 100644 tests/e2e/io/command_interface/net_tls_proto.py create mode 100644 tests/e2e/io/command_interface/net_tls_selftest.py create mode 100644 tests/e2e/io/command_interface/net_tls_test.py diff --git a/run-tests b/run-tests index 6d9a7e686..239cd6641 100755 --- a/run-tests +++ b/run-tests @@ -408,6 +408,11 @@ SUITES: Sequence[Suite] = ( # it skips when the device has no second address on this host's subnet. Suite("e2e", "uci-net-route", "tests/e2e/io/command_interface/net_route_test.py", "-H @HOST@ -p @PASS@ -t @TIMEOUT@", profile=profiles.DEEP), + # The UCI TLS suite against a simulated device; needs no device. The device + # suite itself, net_tls_test.py, is opt-in by name only and deliberately NOT + # registered: see tests/lib/registry_test.py NOT_SUITES. + Suite("e2e", "uci-net-tls-selftest", "tests/e2e/io/command_interface/net_tls_selftest.py", + "", profile=profiles.DEEP), # Two checks that are genuinely about the Telnet transport itself (a # concurrent poll-mode connection, per-keystroke output volume) only run # under --mode telnet. diff --git a/tests/e2e/io/command_interface/.gitignore b/tests/e2e/io/command_interface/.gitignore new file mode 100644 index 000000000..4cb6d85a4 --- /dev/null +++ b/tests/e2e/io/command_interface/.gitignore @@ -0,0 +1,2 @@ +# net_tls_test.py results (run.json, wire.jsonl) when --results is not given +.net_tls_results/ diff --git a/tests/e2e/io/command_interface/internet_hosts.json b/tests/e2e/io/command_interface/internet_hosts.json new file mode 100644 index 000000000..1e70b2501 --- /dev/null +++ b/tests/e2e/io/command_interface/internet_hosts.json @@ -0,0 +1,17 @@ +{ + "comment": "The default real hosts for the BUNDLE scenario that talks to the Internet; \"required\" hosts must answer. recorded_top is the topmost certificate each host sent when it was added, with its issuer and fingerprint. NET_TLS_INTERNET_HOSTS=h1,h2,... replaces this list for a run.", + "hosts": [ + {"id": "H1", "host": "www.google.com", "required": true, + "recorded_top": "CN=GTS Root R4,O=Google Trust Services LLC,C=US", + "recorded_top_issuer": "CN=GlobalSign Root CA,OU=Root CA,O=GlobalSign nv-sa,C=BE", + "recorded_top_fp": "76b27b80a58027dc3cf1da68dac17010ed93997d0b603e2fadbe85012493b5a7"}, + {"id": "H2", "host": "wikipedia.org", "required": true, + "recorded_top": "CN=ISRG Root X2,O=Internet Security Research Group,C=US", + "recorded_top_issuer": "CN=ISRG Root X1,O=Internet Security Research Group,C=US", + "recorded_top_fp": "ee5f7abd6981bb0255632cd8f49283451b4b18844d12040b44ee00f07b8fe2c6"}, + {"id": "H3", "host": "example.com", "required": false, + "recorded_top": "CN=SSL.com TLS ECC Root CA 2022,O=SSL Corporation,C=US", + "recorded_top_issuer": "CN=AAA Certificate Services,O=Comodo CA Limited,L=Salford,ST=Greater Manchester,C=GB", + "recorded_top_fp": "ba06d3d3e348fce7478cc84b422d0e638e9e221ef1a0b53adc14cc70e04b8ab8"} + ] +} diff --git a/tests/e2e/io/command_interface/net_tls_fixture.py b/tests/e2e/io/command_interface/net_tls_fixture.py new file mode 100644 index 000000000..5964c72b3 --- /dev/null +++ b/tests/e2e/io/command_interface/net_tls_fixture.py @@ -0,0 +1,494 @@ +#!/usr/bin/env python3 +"""The host side of the UCI TLS suite: a throwaway PKI and TLS servers that log what they saw. + +The servers run on this machine. Everything the device claims is +held against what the server logged for the same connection: the version and +suite the server negotiated, the SNI it received, the sha256 of the plaintext +it received, and whether the client ended with close_notify, a bare FIN or a +reset. The device's own claim is never the evidence for itself. + +The PKI is generated per run in a temporary directory, is never committed and +is never printed (only SPKI hashes are). It needs the `cryptography` package, +which the scenarios that need a local server report as a SKIP when it is +missing, rather than failing for a reason that is not the firmware's. + + root P-256, the CA a CUSTOM upload installs + intermediate P-256, served with every leaf + leaf ecdsa P-256, FIXTURE_NAME + leaf rsa RSA-2048, FIXTURE_NAME + leaf wrong P-256, WRONG_NAME only (94) + leaf expired P-256, FIXTURE_NAME, notAfter a year ago (95) + leaf future P-256, FIXTURE_NAME, notBefore a year ahead (95) + leaf unknown P-256, FIXTURE_NAME, under a root nobody trusts (93) + +A server is one listening socket and a thread per connection, with one +`Behaviour`. The device reaches it at this machine's address on the route to +the device, as net_target_test.py's Peer does. +""" + +import datetime +import hashlib +import socket +import ssl +import struct +import tempfile +import threading +import time +from dataclasses import dataclass, field +from pathlib import Path + +try: + from cryptography import x509 + from cryptography.hazmat.primitives import hashes, serialization + from cryptography.hazmat.primitives.asymmetric import ec, rsa + from cryptography.x509.oid import ExtendedKeyUsageOID, NameOID + HAVE_CRYPTOGRAPHY = True +except ImportError: # pragma: no cover - reported as a SKIP by the suite + HAVE_CRYPTOGRAPHY = False + +FIXTURE_NAME = "fixture.test" +WRONG_NAME = "wrong-host.test" +ACCEPT_TIMEOUT = 60.0 +# Idle limit per connection: it must outlast the slowest route (over REST a device +# took about 250 s to read S13's 16 KB record), yet still bound every wait; +# TlsServer.close() ends whatever is still open. +CONN_TIMEOUT = 600.0 + + +def payload(seed: int, length: int) -> bytes: + """A seeded payload neither side can produce by accident: SHA-256 in counter mode.""" + out = bytearray() + counter = 0 + while len(out) < length: + out += hashlib.sha256(struct.pack(" bytes: + """SHA-256 of a certificate's SubjectPublicKeyInfo, digest order.""" + cert = x509.load_der_x509_certificate(cert_der) + spki = cert.public_key().public_bytes(serialization.Encoding.DER, + serialization.PublicFormat.SubjectPublicKeyInfo) + return hashlib.sha256(spki).digest() + + +@dataclass +class Chain: + """One server identity: files for ssl.load_cert_chain, and what the device should see.""" + name: str + cert_file: Path # leaf then intermediate, PEM + key_file: Path + leaf_der: bytes + spki_sha256: bytes + + +class Pki: + """The per-run test PKI. Private keys live only in `directory`.""" + + def __init__(self, directory: Path | None = None) -> None: + if not HAVE_CRYPTOGRAPHY: + raise RuntimeError("the `cryptography` package is not installed " + "(pip install cryptography); the local TLS fixture needs it") + self._tmp = None + if directory is None: + self._tmp = tempfile.TemporaryDirectory(prefix="net-tls-pki-") + directory = Path(self._tmp.name) + self.dir = directory + now = datetime.datetime.now(datetime.UTC) + self.now = now + self.root_key = ec.generate_private_key(ec.SECP256R1()) + self.root = self._ca("E2E Test Root", self.root_key, None, None, now) + self.int_key = ec.generate_private_key(ec.SECP256R1()) + self.intermediate = self._ca("E2E Test Intermediate", self.int_key, + self.root, self.root_key, now) + self.unknown_key = ec.generate_private_key(ec.SECP256R1()) + self.unknown_root = self._ca("E2E Unknown Root", self.unknown_key, None, None, now) + self.chains: dict[str, Chain] = {} + day = datetime.timedelta(days=1) + self._leaf("ecdsa", FIXTURE_NAME, ec.generate_private_key(ec.SECP256R1()), + now - day, now + 30 * day) + self._leaf("rsa", FIXTURE_NAME, rsa.generate_private_key(65537, 2048), + now - day, now + 30 * day) + self._leaf("wrong", WRONG_NAME, ec.generate_private_key(ec.SECP256R1()), + now - day, now + 30 * day) + self._leaf("expired", FIXTURE_NAME, ec.generate_private_key(ec.SECP256R1()), + now - 400 * day, now - 365 * day) + self._leaf("future", FIXTURE_NAME, ec.generate_private_key(ec.SECP256R1()), + now + 365 * day, now + 400 * day) + self._leaf("unknown", FIXTURE_NAME, ec.generate_private_key(ec.SECP256R1()), + now - day, now + 30 * day, issuer=(self.unknown_root, self.unknown_key), + with_intermediate=False) + + def close(self) -> None: + if self._tmp is not None: + self._tmp.cleanup() + + @property + def root_der(self) -> bytes: + return self.root.public_bytes(serialization.Encoding.DER) + + def root_pem_file(self) -> Path: + path = self.dir / "root.pem" + path.write_bytes(self.root.public_bytes(serialization.Encoding.PEM)) + return path + + @staticmethod + def _name(cn: str) -> x509.Name: + return x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, cn)]) + + def _ca(self, cn, key, issuer, issuer_key, now) -> "x509.Certificate": + day = datetime.timedelta(days=1) + builder = (x509.CertificateBuilder() + .subject_name(self._name(cn)) + .issuer_name(issuer.subject if issuer is not None else self._name(cn)) + .public_key(key.public_key()) + .serial_number(x509.random_serial_number()) + .not_valid_before(now - 2 * day) + .not_valid_after(now + 60 * day) + .add_extension(x509.BasicConstraints(ca=True, path_length=None), critical=True) + .add_extension(x509.SubjectKeyIdentifier.from_public_key(key.public_key()), + critical=False) + .add_extension(x509.KeyUsage(digital_signature=False, content_commitment=False, + key_encipherment=False, data_encipherment=False, + key_agreement=False, key_cert_sign=True, + crl_sign=True, encipher_only=False, + decipher_only=False), critical=True)) + signer = issuer_key if issuer_key is not None else key + builder = builder.add_extension( + x509.AuthorityKeyIdentifier.from_issuer_public_key(signer.public_key()), critical=False) + return builder.sign(signer, hashes.SHA256()) + + def _leaf(self, label, cn, key, not_before, not_after, issuer=None, + with_intermediate=True) -> None: + ca, ca_key = issuer if issuer is not None else (self.intermediate, self.int_key) + cert = (x509.CertificateBuilder() + .subject_name(self._name(cn)) + .issuer_name(ca.subject) + .public_key(key.public_key()) + .serial_number(x509.random_serial_number()) + .not_valid_before(not_before) + .not_valid_after(not_after) + .add_extension(x509.SubjectAlternativeName([x509.DNSName(cn)]), critical=False) + .add_extension(x509.BasicConstraints(ca=False, path_length=None), critical=True) + .add_extension(x509.ExtendedKeyUsage([ExtendedKeyUsageOID.SERVER_AUTH]), + critical=False) + .add_extension(x509.SubjectKeyIdentifier.from_public_key(key.public_key()), + critical=False) + .add_extension(x509.AuthorityKeyIdentifier.from_issuer_public_key( + ca_key.public_key()), critical=False) + .sign(ca_key, hashes.SHA256())) + cert_file = self.dir / f"{label}.pem" + key_file = self.dir / f"{label}.key" + pem = cert.public_bytes(serialization.Encoding.PEM) + if with_intermediate: + pem += self.intermediate.public_bytes(serialization.Encoding.PEM) + cert_file.write_bytes(pem) + key_file.write_bytes(key.private_bytes(serialization.Encoding.PEM, + serialization.PrivateFormat.PKCS8, + serialization.NoEncryption())) + der = cert.public_bytes(serialization.Encoding.DER) + self.chains[label] = Chain(label, cert_file, key_file, der, spki_sha256(der)) + + def issue(self, label: str, cn: str) -> Chain: + """One more P-256 leaf under the test root, for a stand-in host (self-test).""" + day = datetime.timedelta(days=1) + self._leaf(label, cn, ec.generate_private_key(ec.SECP256R1()), + self.now - day, self.now + 30 * day) + return self.chains[label] + + +@dataclass +class Behaviour: + """What one server does with each connection.""" + min_version: "ssl.TLSVersion" = ssl.TLSVersion.TLSv1_3 + max_version: "ssl.TLSVersion" = ssl.TLSVersion.TLSv1_3 + # OpenSSL cipher string for TLS 1.2; TLS 1.3 suites are left at their default. + ciphers: str | None = None + # One curve name ("prime256v1"), to force an HRR or a P-256 group. + ecdh_curve: str | None = None + num_tickets: int | None = None + # Seconds to hold the ClientHello before answering it. + delay_handshake: float = 0.0 + # Accept the TCP connection and never answer (S10). + stall: bool = False + # Read the ClientHello, then reset the connection (S7c). + rst_after_client_hello: bool = False + # The listener's SO_RCVBUF, so a server that stops reading fills TCP soon. + rcvbuf: int | None = None + # Sent once, as one write, right after the handshake. + send: bytes = b"" + # After `send`: "echo" (until the client ends), "close_notify", "fin" (no + # close_notify), "hold" (read and discard), "http" (one 200, then + # close_notify), or "stall" (never read again, so writes fill TCP; S32). + then: str = "echo" + + +@dataclass +class ConnLog: + """What the server saw on one connection.""" + peer: str + sni: str | None = None + version: str | None = None + cipher: str | None = None + received: bytearray = field(default_factory=bytearray) + sent: int = 0 + # How the client ended it: "close_notify", "fin", "reset", "open" (still + # open when the server gave up), or "handshake" (it never completed). + peer_end: str = "open" + error: str | None = None + done: threading.Event = field(default_factory=threading.Event) + + def as_dict(self) -> dict: + return {"peer": self.peer, "sni": self.sni, "version": self.version, + "cipher": self.cipher, "received": len(self.received), + "received_sha256": hashlib.sha256(self.received).hexdigest(), + "sent": self.sent, "peer_end": self.peer_end, "error": self.error} + + +class TlsServer: + """One TLS server on this machine, with one Behaviour for every connection.""" + + def __init__(self, bind_ip: str, chain: Chain | None, behaviour: Behaviour, + port: int = 0) -> None: + self.behaviour = behaviour + self.chain = chain + self.logs: list[ConnLog] = [] + self._lock = threading.Lock() + self._stop = threading.Event() + self.listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + if behaviour.rcvbuf: + self.listener.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, behaviour.rcvbuf) + self.listener.bind((bind_ip, port)) + self.listener.listen(8) + self.listener.settimeout(0.2) + self.ip, self.port = self.listener.getsockname()[:2] + self.context = self._context() if chain is not None else None + self._threads: list[threading.Thread] = [] + # Every accepted socket, so close() can end the ones still waiting. + self._open: set = set() + self._acceptor = threading.Thread(target=self._accept_loop, daemon=True) + self._acceptor.start() + + def _context(self) -> ssl.SSLContext: + b = self.behaviour + ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + ctx.minimum_version = b.min_version + ctx.maximum_version = b.max_version + ctx.load_cert_chain(str(self.chain.cert_file), str(self.chain.key_file)) + if b.ciphers: + ctx.set_ciphers(b.ciphers) + if b.ecdh_curve: + ctx.set_ecdh_curve(b.ecdh_curve) + if b.num_tickets is not None: + ctx.num_tickets = b.num_tickets + + def sni(sslobj, name, _ctx) -> None: + log = getattr(sslobj, "_net_tls_log", None) + if log is not None: + log.sni = name + ctx.sni_callback = sni + return ctx + + def _accept_loop(self) -> None: + while not self._stop.is_set(): + try: + raw, addr = self.listener.accept() + except TimeoutError: + continue + except OSError: + return + log = ConnLog(f"{addr[0]}:{addr[1]}") + with self._lock: + self.logs.append(log) + thread = threading.Thread(target=self._serve, args=(raw, log), daemon=True) + self._threads.append(thread) + thread.start() + + def _serve(self, raw: socket.socket, log: ConnLog) -> None: + b = self.behaviour + # wrap_socket detaches `raw`, so whichever object owns the descriptor + # is the one to read from and to close. + conn = raw + with self._lock: + self._open.add(raw) + try: + raw.settimeout(CONN_TIMEOUT) + if b.stall: + log.peer_end = self._hold_raw(raw) + return + if b.rst_after_client_hello: + raw.recv(4096) + raw.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)) + log.peer_end = "handshake" + log.error = "reset after the ClientHello (by design)" + return + if b.delay_handshake: + time.sleep(b.delay_handshake) + tls = self.context.wrap_socket(raw, server_side=True, + do_handshake_on_connect=False, + suppress_ragged_eofs=False) + conn = tls + with self._lock: + self._open.discard(raw) + self._open.add(tls) + tls._net_tls_log = log # read by the SNI callback + try: + tls.do_handshake() + except (ssl.SSLError, OSError) as exc: + log.peer_end = "handshake" + log.error = f"handshake: {exc}" + return + log.version = tls.version() + log.cipher = tls.cipher()[0] if tls.cipher() else None + if b.send: + tls.sendall(b.send) + log.sent += len(b.send) + if b.then in ("close_notify", "fin"): + # Let the device's reads be what ends the stream. + time.sleep(0.5) + if b.then == "close_notify": + try: + tls.unwrap() # close_notify, then the peer's, on the same socket + except (ssl.SSLError, OSError): + pass + # SSLSocket.shutdown drops the TLS layer first, so after + # "fin" this is a bare FIN with no close_notify ahead of it. + tls.shutdown(socket.SHUT_WR) + log.peer_end = self._drain_after_close(tls) + return + if b.then == "stall": + while not self._stop.wait(0.2): + pass + return + if b.then == "http": + self._http(tls, log) + return + self._echo(tls, log, echo=(b.then == "echo")) + except Exception as exc: # the log is the report; the thread must not die silently + log.error = f"{type(exc).__name__}: {exc}" + finally: + with self._lock: + self._open.discard(conn) + self._open.discard(raw) + try: + conn.close() + except OSError: + pass + log.done.set() + + def _echo(self, tls: ssl.SSLSocket, log: ConnLog, echo: bool) -> None: + while not self._stop.is_set(): + try: + data = tls.recv(4096) + except ssl.SSLEOFError: + log.peer_end = "fin" + return + except ssl.SSLZeroReturnError: + log.peer_end = "close_notify" + return + except (ConnectionResetError, BrokenPipeError): + log.peer_end = "reset" + return + except TimeoutError: + log.peer_end = "open" + return + except ssl.SSLError as exc: + log.peer_end = "error" + log.error = f"recv: {exc}" + return + if not data: + log.peer_end = "close_notify" + return + log.received += data + if echo: + tls.sendall(data) + log.sent += len(data) + + def _http(self, tls: ssl.SSLSocket, log: ConnLog) -> None: + while b"\r\n\r\n" not in log.received: + data = tls.recv(4096) + if not data: + log.peer_end = "close_notify" + return + log.received += data + body = b"ok\n" + response = (b"HTTP/1.1 200 OK\r\nContent-Length: %d\r\nConnection: close\r\n\r\n" + % len(body)) + body + tls.sendall(response) + log.sent += len(response) + try: + tls.unwrap() + except (ssl.SSLError, OSError): + pass + log.peer_end = "close_notify" + + @staticmethod + def _hold_raw(raw: socket.socket) -> str: + try: + while raw.recv(4096): + pass + return "fin" + except (ConnectionResetError, BrokenPipeError): + return "reset" + except TimeoutError: + return "open" + + @staticmethod + def _drain_after_close(raw: socket.socket) -> str: + """How the client ended a connection the server has already closed for writing.""" + # The same idle bound: after the server's own close, a REST-route client + # can take minutes to read what is left (S6/S7: about 45 s for 3000 B). + raw.settimeout(CONN_TIMEOUT) + try: + while raw.recv(4096): + pass + return "fin" + except (ConnectionResetError, BrokenPipeError): + return "reset" + except TimeoutError: + return "open" + except OSError: + return "closed" + + def wait_connections(self, count: int, timeout: float = 15.0) -> list[ConnLog]: + """The first `count` connections, once each has finished (or `timeout`).""" + deadline = time.monotonic() + timeout + while True: + with self._lock: + logs = list(self.logs) + if len(logs) >= count and all(log.done.is_set() for log in logs[:count]): + return logs[:count] + if time.monotonic() > deadline: + return logs[:count] + time.sleep(0.05) + + def close(self) -> None: + self._stop.set() + try: + self.listener.close() + except OSError: + pass + with self._lock: + still_open = list(self._open) + for sock in still_open: + # Wakes a thread blocked in recv or unwrap, so it ends now rather + # than at CONN_TIMEOUT. + try: + # The plain socket's shutdown, under any TLS wrapper the other + # thread is still reading through. + socket.socket.shutdown(sock, socket.SHUT_RDWR) + except OSError: + pass + self._acceptor.join(timeout=2) + + +def local_address_towards(device_host: str) -> str: + """This machine's address on the route to the device (as net_target_test.py).""" + probe = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + try: + probe.connect((device_host, 9)) + return probe.getsockname()[0] + finally: + probe.close() diff --git a/tests/e2e/io/command_interface/net_tls_mock.py b/tests/e2e/io/command_interface/net_tls_mock.py new file mode 100644 index 000000000..6e4188428 --- /dev/null +++ b/tests/e2e/io/command_interface/net_tls_mock.py @@ -0,0 +1,487 @@ +#!/usr/bin/env python3 +"""A simulated network target, for checking the UCI TLS suite without hardware. + +Two flavours, each a `net_tls_proto.Link`: + + "tls" answers $21-$25 the way doc/uci_tls.md says, doing + real TLS from this machine with Python's ssl module, so a scenario + that passes against it has exercised its own oracle end to end; + "stock" the firmware without the TLS commands: $21-$25 answer `21,UNKNOWN COMMAND`, and + the plain commands ($01, $07, $09, $10, $11) work. + +And mutants of "tls", each breaking one rule a scenario claims to guard, so +the self-test can show that scenario turning red: + + "bundle-accepts-all" BUNDLE verifies nothing (S5 / S4 must catch it) + "release-noop" $25 never closes anything (S19e must catch it) + "group-zero" the OPEN reply's group is 0 (S2 must catch it) + "info-ff-claims" `03 23 FF` claims every session (S19e2b must catch it) + "abort-shortens" an ABORT ends PROCESSING early: bit 2 clears at the ABORT, + while the open still completes behind it (S19e must catch it) + +It is a model of the contract, not of the firmware: timings are not +simulated, a READ takes what the socket has, and the group is reported as +x25519 because Python's ssl does not expose the negotiated one. Nothing here +is evidence about a device. +""" + +import hashlib +import ipaddress +import socket +import ssl +import time +from dataclasses import dataclass + +from net_tls_proto import ( + CA_MAX, HANDLE_RANGE, NET_CMD_CLOSE_SOCKET, NET_CMD_IDENTIFY, NET_CMD_OPEN_TCP, + NET_CMD_OPEN_TLS, NET_CMD_READ_SOCKET, NET_CMD_START_TLS, NET_CMD_TLS_INFO, + NET_CMD_TLS_RELEASE, NET_CMD_TLS_TRUST_CA, NET_CMD_WRITE_SOCKET, READ_MAX, + STATUS_INVALID_PARAMS, STATUS_OK, STATUS_OUT_OF_RANGE, STATUS_UNKNOWN_COMMAND, + TLS_COMMANDS, TRUST_BUNDLE, TRUST_CUSTOM, TRUST_PIN, AbortedCommand, Link, Result) + +try: + from cryptography import x509 + from cryptography.hazmat.primitives import serialization +except ImportError: # pragma: no cover + x509 = None + +MUTANTS = ("bundle-accepts-all", "release-noop", "group-zero", "info-ff-claims", + "abort-shortens") +FLAVOURS = ("tls", "stock", *MUTANTS) +MAX_TLS = 2 + +SUITES = { + "TLS_AES_128_GCM_SHA256": 0x1301, "TLS_AES_256_GCM_SHA384": 0x1302, + "TLS_CHACHA20_POLY1305_SHA256": 0x1303, + "ECDHE-ECDSA-AES128-GCM-SHA256": 0xC02B, "ECDHE-ECDSA-AES256-GCM-SHA384": 0xC02C, + "ECDHE-RSA-AES128-GCM-SHA256": 0xC02F, "ECDHE-RSA-AES256-GCM-SHA384": 0xC030, + "ECDHE-ECDSA-CHACHA20-POLY1305": 0xCCA9, "ECDHE-RSA-CHACHA20-POLY1305": 0xCCA8, +} +# The six hardened 1.2 suites of 1.7, as OpenSSL names them. +TLS12_CIPHERS = ":".join(name for name, code in SUITES.items() if code >= 0xC000) +ALERTS = {"PROTOCOL_VERSION": 70, "HANDSHAKE_FAILURE": 40, "INTERNAL_ERROR": 80, + "DECODE_ERROR": 50, "ILLEGAL_PARAMETER": 47, "UNEXPECTED_MESSAGE": 10} + + +def is_ipv4_literal(text: bytes) -> bool: + """lwIP's ip4addr_aton is laxer than this (127.1, 0x7f.0.0.1); the mock uses + inet_aton, which accepts the same short and hex forms.""" + try: + socket.inet_aton(text.decode("ascii")) + return True + except (OSError, UnicodeDecodeError): + return False + + +def status(text: str) -> bytes: + return text.encode("ascii") + + +@dataclass +class Entry: + kind: str # "tcp" or "tls" + sock: object + claimed: bool = True + open_reply: bytes = b"" + trust: int = 0 + spki: bytes = b"" + handshake_ms: int = 0 + sticky: bytes | None = None + + +class MockDevice(Link): + """A network target in Python. See the module docstring.""" + + def __init__(self, flavour: str = "tls", bundle_cafile: str | None = None, + resolver: dict[str, str] | None = None, system_bundle: bool = True) -> None: + super().__init__() + if flavour not in FLAVOURS: + raise ValueError(f"unknown flavour {flavour!r}") + self.flavour = flavour + self.name = f"mock-{flavour}" + self.can_abort_in_flight = True + self.bundle_cafile = bundle_cafile + self.system_bundle = system_bundle + self.resolver = resolver or {} + self.handles: dict[int, Entry] = {} + self.ca_state = "EMPTY" + self.ca_buf = bytearray() + self.ca_total = 0 + self.ca_der: bytes | None = None + self.ready = 0x07 # module, entropy, time + + # -- Link ---------------------------------------------------------------- + + def _command(self, command: bytes, bound: float) -> Result: + started = time.monotonic() + data, text = self._dispatch(command) + return Result(command, data, text, time.monotonic() - started) + + def abort_in_flight(self, command: bytes, abort_after: float, + bound: float | None = None) -> AbortedCommand: + # ABORT never shortens a command: it runs to its end, and only + # its reply is dropped. + started = time.monotonic() + self._dispatch(command) + elapsed = time.monotonic() - started + if self.flavour == "abort-shortens": + elapsed = abort_after + self.log.append({"t": round(time.time(), 3), "link": self.name, + "command": command.hex(" "), "abort_after": abort_after, + "busy_at_abort": True, "bit2_cleared_after": round(elapsed, 3)}) + return AbortedCommand(command, abort_after, True, elapsed, 0x00) + + def startup_abort(self) -> float: + return 0.0 + + def reset(self) -> None: + """A C64 reset: every socket closed, CA EMPTY.""" + for entry in self.handles.values(): + try: + entry.sock.close() + except OSError: + pass + self.handles.clear() + self.ca_state, self.ca_der = "EMPTY", None + + # -- dispatch ------------------------------------------------------------ + + def _dispatch(self, command: bytes) -> tuple[bytes, bytes]: + if len(command) < 2: + return b"", STATUS_INVALID_PARAMS + code = command[1] + if self.flavour == "stock" and code in TLS_COMMANDS: + return b"", STATUS_UNKNOWN_COMMAND + if command[0] & 0x80: + # The no-reply bit: the reply is thrown away (command_intf.cc:166-171), + # and $21/$24 open nothing (r6 L-i). + if code in (NET_CMD_OPEN_TLS, NET_CMD_START_TLS): + return b"", STATUS_INVALID_PARAMS + exempt = code == NET_CMD_TLS_RELEASE or ( + code == NET_CMD_TLS_INFO and len(command) == 3 and command[2] == 0xFF + and self.flavour != "info-ff-claims") + if self.flavour != "stock" and not exempt: + for entry in self.handles.values(): + entry.claimed = True + if code != NET_CMD_TLS_TRUST_CA and self.ca_state == "UPLOADING": + self.ca_state = "EMPTY" + handler = { + NET_CMD_IDENTIFY: self._identify, NET_CMD_OPEN_TCP: self._open_tcp, + NET_CMD_CLOSE_SOCKET: self._close, NET_CMD_READ_SOCKET: self._read, + NET_CMD_WRITE_SOCKET: self._write, NET_CMD_OPEN_TLS: self._open_tls, + NET_CMD_TLS_TRUST_CA: self._trust_ca, NET_CMD_TLS_INFO: self._info, + NET_CMD_TLS_RELEASE: self._release, + }.get(code) + if handler is None: + return b"", STATUS_UNKNOWN_COMMAND + return handler(command) + + def _free_handle(self) -> int | None: + return next((h for h in HANDLE_RANGE if h not in self.handles), None) + + def _identify(self, command: bytes): + return b"MOCK NETWORK TARGET", STATUS_OK + + def _resolve(self, host: str) -> str | None: + if host in self.resolver: + return self.resolver[host] + try: + ipaddress.IPv4Address(host) + return host + except ValueError: + pass + try: + return socket.gethostbyname(host) + except OSError: + return None + + def _open_tcp(self, command: bytes): + if len(command) < 5: + return b"", STATUS_INVALID_PARAMS + port = command[2] | command[3] << 8 + host = command[4:].split(b"\x00")[0].decode("latin-1") + address = self._resolve(host) + if address is None: + return b"", status("84,UNRESOLVED HOST") + handle = self._free_handle() + if handle is None: + return b"", status("85,ERROR OPENING SOCKET") + try: + sock = socket.create_connection((address, port), timeout=10) + except OSError as exc: + return b"", status(f"11,ERROR ON CONNECT: {exc.errno or 116}") + self.handles[handle] = Entry("tcp", sock) + return bytes([handle]), STATUS_OK + + def _close(self, command: bytes): + if len(command) != 3: + return b"", STATUS_INVALID_PARAMS + entry = self.handles.pop(command[2], None) + if entry is None: + return b"", status("12,ERROR ON CLOSE: 9") + if entry.kind == "tls": + try: + entry.sock.settimeout(0.1) + entry.sock.unwrap() + except (OSError, ValueError, ssl.SSLError): + pass + try: + entry.sock.close() + except OSError: + pass + return b"", STATUS_OK + + def _read(self, command: bytes): + if len(command) != 5: + return b"", STATUS_INVALID_PARAMS + handle, maxlen = command[2], command[3] | command[4] << 8 + entry = self.handles.get(handle) + if entry is None: + return b"\xff\xff", status("02,NO DATA: 9") + if maxlen == 0 or maxlen > READ_MAX: + return b"", STATUS_OUT_OF_RANGE + if entry.sticky is not None: + return b"\x00\x00", entry.sticky + entry.sock.settimeout(0.25) + try: + data = entry.sock.recv(maxlen) + except (TimeoutError, ssl.SSLWantReadError): + return b"\xff\xff", status("02,NO DATA: 11") + except ssl.SSLEOFError: + self.handles.pop(handle, None) + entry.sock.close() + return b"\x00\x00", status("05,TLS CLOSED WITHOUT NOTIFY") + except ConnectionResetError: + entry.sticky = status("12,RECEIVE ERROR: 104") + return b"\x00\x00", entry.sticky + except ssl.SSLError as exc: + alert = self._alert(exc) + entry.sticky = status(f"14,TLS ALERT RECEIVED: {alert}" if alert + else "16,TLS SESSION FAILED: -0x7100") + return b"\x00\x00", entry.sticky + if not data: + self.handles.pop(handle, None) + entry.sock.close() + return b"\x00\x00", status("01,CONNECTION CLOSED BY HOST") + return len(data).to_bytes(2, "little") + data, STATUS_OK + + def _write(self, command: bytes): + if len(command) < 3: + return b"", STATUS_INVALID_PARAMS + entry = self.handles.get(command[2]) + if entry is None: + return b"\xff\xff", status("12,SEND ERROR: 9") + if entry.sticky is not None: + return b"\xff\xff", entry.sticky + data = command[3:] + try: + entry.sock.settimeout(5) + entry.sock.sendall(data) + except OSError as exc: + entry.sticky = status(f"12,SEND ERROR: {exc.errno or 32}") + return b"\xff\xff", entry.sticky + return len(data).to_bytes(2, "little"), STATUS_OK + + @staticmethod + def _alert(exc: Exception) -> int | None: + text = str(exc).upper() + for name, number in ALERTS.items(): + if f"ALERT_{name}" in text: + return number + return None + + # -- TLS ----------------------------------------------------------------- + + def _open_tls(self, command: bytes): + if len(command) < 7: + return b"", STATUS_INVALID_PARAMS + port, trust, flags = command[2] | command[3] << 8, command[4], command[5] + pin = None + if trust == TRUST_PIN: + if len(command) < 39: + return b"", STATUS_INVALID_PARAMS + pin, tail = command[6:38], command[38:] + else: + tail = command[6:] + parts = tail.split(b"\x00") + host, name = parts[0], None + if len(parts) == 2: + name = parts[1] or None + elif len(parts) == 3: + if not parts[1] or parts[2]: + return b"", STATUS_INVALID_PARAMS + name = parts[1] + elif len(parts) > 3: + return b"", STATUS_INVALID_PARAMS + if not host or len(host) > 253 or (name is not None and len(name) > 253): + return b"", STATUS_INVALID_PARAMS + effective = name if name is not None else (None if is_ipv4_literal(host) else host) + if trust in (TRUST_BUNDLE, TRUST_CUSTOM) and (effective is None or is_ipv4_literal(effective)): + return b"", STATUS_INVALID_PARAMS + if trust > TRUST_PIN or flags & 0xFE or (pin is not None and not any(pin)): + return b"", STATUS_OUT_OF_RANGE + if not self.ready & 1: + return b"", status("90,TLS NOT AVAILABLE") + if sum(1 for e in self.handles.values() if e.kind == "tls") >= MAX_TLS: + return b"", status("91,TLS SESSIONS IN USE") + if trust == TRUST_CUSTOM and self.ca_state != "LOADED": + return b"", status("97,NO CUSTOM CA") + if trust == TRUST_PIN and effective is not None and is_ipv4_literal(effective): + effective = None + address = self._resolve(host.decode("latin-1")) + if address is None: + return b"", status("84,UNRESOLVED HOST") + handle = self._free_handle() + if handle is None: + return b"", status("85,ERROR OPENING SOCKET") + try: + raw = socket.create_connection((address, port), timeout=10) + except OSError as exc: + return b"", status(f"11,ERROR ON CONNECT: {exc.errno or 116}") + ctx = self._context(trust, flags) + started = time.monotonic() + try: + raw.settimeout(15) + sock = ctx.wrap_socket(raw, server_hostname=effective.decode("ascii") if effective else None, + suppress_ragged_eofs=False) + except ssl.SSLCertVerificationError as exc: + raw.close() + return b"", self._verify_status(exc) + except TimeoutError: + raw.close() + return b"", status("15,TLS HANDSHAKE TIMEOUT") + except ConnectionResetError: + raw.close() + return b"", status("13,TLS HANDSHAKE FAILED: PEER RESET: 104") + except ssl.SSLError as exc: + raw.close() + alert = self._alert(exc) + return b"", status(f"14,TLS ALERT RECEIVED: {alert}" if alert + else "13,TLS HANDSHAKE FAILED: -0x7780") + except OSError as exc: + raw.close() + return b"", status(f"13,TLS HANDSHAKE FAILED: SEND ERROR: {exc.errno or 32}") + handshake_ms = int((time.monotonic() - started) * 1000) + der = sock.getpeercert(binary_form=True) + spki = self._spki(der) + if trust == TRUST_PIN and spki != pin: + sock.close() + return b"", status("96,PINNED KEY MISMATCH") + version = 0x0304 if sock.version() == "TLSv1.3" else 0x0303 + suite = SUITES.get(sock.cipher()[0], 0) + group = 0 if self.flavour == "group-zero" else 0x001D + bits = 1 if version == 0x0303 else 0 + reply = (bytes([handle]) + version.to_bytes(2, "little") + suite.to_bytes(2, "little") + + group.to_bytes(2, "little") + bytes([bits])) + self.handles[handle] = Entry("tls", sock, claimed=False, open_reply=reply, trust=trust, + spki=spki, handshake_ms=handshake_ms) + return reply, STATUS_OK + + def _context(self, trust: int, flags: int) -> ssl.SSLContext: + ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) + ctx.minimum_version = ssl.TLSVersion.TLSv1_3 if flags & 1 else ssl.TLSVersion.TLSv1_2 + ctx.set_ciphers(TLS12_CIPHERS) + if trust == TRUST_PIN or (trust == TRUST_BUNDLE and self.flavour == "bundle-accepts-all"): + ctx.check_hostname = False + ctx.verify_mode = ssl.CERT_NONE + elif trust == TRUST_BUNDLE: + if self.system_bundle: + ctx.load_default_certs() + if self.bundle_cafile: + ctx.load_verify_locations(cafile=self.bundle_cafile) + else: + ctx.load_verify_locations(cadata=self.ca_der) + return ctx + + @staticmethod + def _spki(der: bytes) -> bytes: + if x509 is None or not der: + return b"\x00" * 32 + cert = x509.load_der_x509_certificate(der) + return hashlib.sha256(cert.public_key().public_bytes( + serialization.Encoding.DER, serialization.PublicFormat.SubjectPublicKeyInfo)).digest() + + @staticmethod + def _verify_status(exc: ssl.SSLCertVerificationError) -> bytes: + code = exc.verify_code + if code == 62: + return status("94,CERTIFICATE NAME MISMATCH: 0x00000004") + if code == 10: + return status("95,CERTIFICATE EXPIRED: 0x00000001") + if code == 9: + return status("95,CERTIFICATE EXPIRED: 0x00000200") + if code in (2, 19, 20, 21): + return status("93,CERTIFICATE NOT TRUSTED: 0x00000008") + return status("93,CERTIFICATE NOT TRUSTED: 0xFFFFFFFF") + + def _trust_ca(self, command: bytes): + if len(command) < 6: + return b"", STATUS_INVALID_PARAMS + offset, total = command[2] | command[3] << 8, command[4] | command[5] << 8 + chunk = command[6:] + if offset == 0: + if total == 0: + if chunk: + return b"", STATUS_INVALID_PARAMS + self.ca_state, self.ca_der = "EMPTY", None + return b"", STATUS_OK + if total > CA_MAX: + self.ca_state, self.ca_der = "EMPTY", None + return b"", STATUS_OUT_OF_RANGE + self.ca_state, self.ca_der = "UPLOADING", None + self.ca_buf, self.ca_total = bytearray(), total + elif self.ca_state != "UPLOADING" or offset != len(self.ca_buf) or total != self.ca_total: + if self.ca_state == "UPLOADING": + self.ca_state = "EMPTY" + return b"", STATUS_INVALID_PARAMS + if len(self.ca_buf) + len(chunk) > self.ca_total: + self.ca_state = "EMPTY" + return b"", STATUS_INVALID_PARAMS + self.ca_buf += chunk + if len(self.ca_buf) < self.ca_total: + return b"", STATUS_OK + der = bytes(self.ca_buf) + try: + cert = x509.load_der_x509_certificate(der) + constraints = cert.extensions.get_extension_for_class(x509.BasicConstraints).value + if not constraints.ca: + self.ca_state = "EMPTY" + return b"", status("97,CUSTOM CA REJECTED: NOT A CA") + except Exception: + self.ca_state = "EMPTY" + return b"", status("97,CUSTOM CA INVALID: -0x2180") + self.ca_state, self.ca_der = "LOADED", der + return b"", STATUS_OK + + def _info(self, command: bytes): + if len(command) != 3: + return b"", STATUS_INVALID_PARAMS + handle = command[2] + tls = [e for e in self.handles.values() if e.kind == "tls"] + if handle == 0xFF: + ready = self.ready | (0x08 if self.ca_state == "LOADED" else 0) + record = bytearray(16) + record[0:6] = bytes([1, MAX_TLS, len(tls), 0x07, ready, 0x03]) + record[6:9] = bytes([1]) + (8).to_bytes(2, "little") + record[9:12] = b"\xff\xff\xff" if ready & 1 else b"\x00\x00\x00" + record[12:14] = (3).to_bytes(2, "little") + record[14] = sum(1 for e in tls if not e.claimed) + return bytes(record), STATUS_OK + entry = self.handles.get(handle) + if entry is None or entry.kind != "tls": + return b"", STATUS_INVALID_PARAMS + r = entry.open_reply + record = (r[1:7] + bytes([entry.trust, r[7]]) + entry.spki + + entry.handshake_ms.to_bytes(4, "little") + bytes(4)) + return record, STATUS_OK + + def _release(self, command: bytes): + if len(command) != 2: + return b"", STATUS_INVALID_PARAMS + closed = 0 + if self.flavour != "release-noop": + for handle, entry in list(self.handles.items()): + if entry.kind == "tls" and not entry.claimed: + self._close(bytes([3, NET_CMD_CLOSE_SOCKET, handle])) + closed += 1 + return bytes([closed]), STATUS_OK diff --git a/tests/e2e/io/command_interface/net_tls_proto.py b/tests/e2e/io/command_interface/net_tls_proto.py new file mode 100644 index 000000000..c5d56804e --- /dev/null +++ b/tests/e2e/io/command_interface/net_tls_proto.py @@ -0,0 +1,569 @@ +#!/usr/bin/env python3 +"""The TLS commands of the UCI network target, as bytes, and two ways to send them. + +doc/uci_tls.md is the contract. This module knows the byte layouts of +$21-$25 and of the existing commands a TLS handle uses ($07, $09, $10, $11), +parses the replies, and carries every command over a `Link` with the client +deadlines: + + - B = 45 s from the PUSH for OPEN_TLS / START_TLS, 12 s for every other TLS + command, and 45 s (advice) for OPEN_TCP; + - at PUSH + B with no reply, write ABORT ($04 alone) and wait for $DF1C bit 2 + to read 0, up to the later of PUSH + B and ABORT + 12 s; + - bit 2 still 1 then: the interface is wedged, and the caller resets the C64. + +So no command here can hang a run: the longest any one of them can take is +PUSH + 57 s, after which it has either answered, been ABORTed, or been +reported as a wedge. + +Two links reach the registers, as in net_target_test.py: + RestLink machine:readmem / writemem DMA cycles, one per register access. + It can write ABORT while a command is still in PROCESSING, so it + is the route for the ABORT scenarios (S19e family). + NativeLink the 6502 agent (uci_agent.asm). The real program's timing, but + the agent cannot ABORT a command in flight. +net_tls_mock.py offers a third, a simulated device, for the offline self-test. +""" + +import time +from dataclasses import dataclass, field + +from report import Failure, detail +from uci import (CTRL_ABORT, CTRL_CLR_ERR, CTRL_DATA_ACC, CTRL_PUSH_CMD, MAX_REPLY_BLOCKS, + REG_COMMAND, ST_ABORT_P, ST_ERROR, ST_STATE_BUSY, ST_STATE_DATA_LAST, ST_STATE_DATA_MORE, + ST_STATE_IDLE, ST_STATE_MASK, TARGET_NETWORK, Uci, describe_status) + +# -- command codes (network_target.h) ---------------------------------------- +NET_CMD_IDENTIFY = 0x01 +NET_CMD_OPEN_TCP = 0x07 +NET_CMD_OPEN_UDP = 0x08 +NET_CMD_CLOSE_SOCKET = 0x09 +NET_CMD_READ_SOCKET = 0x10 +NET_CMD_WRITE_SOCKET = 0x11 +NET_CMD_OPEN_TLS = 0x21 +NET_CMD_TLS_TRUST_CA = 0x22 +NET_CMD_TLS_INFO = 0x23 +NET_CMD_START_TLS = 0x24 +NET_CMD_TLS_RELEASE = 0x25 +TLS_COMMANDS = (NET_CMD_OPEN_TLS, NET_CMD_TLS_TRUST_CA, NET_CMD_TLS_INFO, + NET_CMD_START_TLS, NET_CMD_TLS_RELEASE) +# The no-reply bit of byte 0 (command_target.h:9). +NO_REPLY = 0x80 + +TRUST_BUNDLE = 0 +TRUST_CUSTOM = 1 +TRUST_PIN = 2 +FLAG_REQUIRE_TLS13 = 0x01 + +INFO_CAPABILITY = 0xFF +INFO_CAPABILITY_BYTES = 16 +INFO_HANDLE_BYTES = 48 +OPEN_REPLY_BYTES = 8 + +# -- the client deadlines (and the advice for OPEN_TCP) ---------------------- +BOUND_OPEN = 45.0 +BOUND_OTHER = 12.0 +BOUND_OPEN_TCP = 45.0 +POST_ABORT_MIN = 12.0 +# A non-TLS command (IDENTIFY, CLOSE of a plain socket) is immediate. +BOUND_PLAIN = 12.0 + +# -- what the firmware answers, verbatim where the text is fixed ------------ +STATUS_OK = b"00,OK" +STATUS_UNKNOWN_COMMAND = b"21,UNKNOWN COMMAND" +STATUS_INVALID_PARAMS = b"81,INVALID PARAMS" +STATUS_OUT_OF_RANGE = b"82,PARAMETER(S) OUT OF RANGE" +STATUS_CLOSE_UNOWNED = b"12,ERROR ON CLOSE: 9" +STATUS_NO_DATA_IDLE = b"02,NO DATA: 11" +STATUS_NO_DATA_GONE = b"02,NO DATA: 9" +STATUS_PEER_CLOSED = b"01,CONNECTION CLOSED BY HOST" +STATUS_NO_NOTIFY = b"05,TLS CLOSED WITHOUT NOTIFY" +STATUS_HS_TIMEOUT = b"15,TLS HANDSHAKE TIMEOUT" +STATUS_TLS_IN_USE = b"91,TLS SESSIONS IN USE" +STATUS_NO_CUSTOM_CA = b"97,NO CUSTOM CA" +STATUS_PIN_MISMATCH = b"96,PINNED KEY MISMATCH" +# S5: the full text, because the code alone cannot tell an installation-order +# bug (which prints 0xFFFFFFFF) from the right answer. +STATUS_UNKNOWN_ROOT = b"93,CERTIFICATE NOT TRUSTED: 0x00000008" + +READ_MAX = 1472 +WRITE_MAX = 892 +CA_MAX = 1472 +CA_CHUNK = 889 +HANDLE_RANGE = range(16) # this firmware's handles + +# The IANA numbers the OPEN reply and INFO carry. +TLS13 = 0x0304 +TLS12 = 0x0303 +TLS13_SUITES = {0x1301, 0x1302, 0x1303} +TLS12_SUITES = {0xC02B, 0xC02C, 0xC02F, 0xC030, 0xCCA9, 0xCCA8} +GROUPS = {0x001D: "x25519", 0x0017: "secp256r1", 0x0018: "secp384r1", 0x0019: "secp521r1"} + + +def status_code(status: bytes) -> int | None: + """The two-digit code a status line starts with, or None.""" + if len(status) >= 2 and status[:2].isdigit(): + return int(status[:2]) + return None + + +@dataclass +class Result: + """Everything one command showed a client.""" + command: bytes + data: bytes + status: bytes + elapsed: float + # ABORTed at PUSH + B because no reply came in time. The reply, if + # it came later, was dropped by the ABORT. + aborted: bool = False + + @property + def code(self) -> int | None: + return status_code(self.status) + + @property + def ok(self) -> bool: + return self.status == STATUS_OK + + def describe(self) -> str: + shown = self.data[:24].hex(" ") + (" ..." if len(self.data) > 24 else "") + if self.aborted: + return f"no reply within its bound; ABORTed after {self.elapsed:.1f}s" + return f"[{len(self.data)} B: {shown}] {self.status.decode('latin-1')!r} in {self.elapsed:.2f}s" + + +class LinkLost(Failure): + """The route can no longer carry commands: wedged, or the agent stopped. + + The caller resets the C64, which is the recovery (doc/uci_tls.md) for a + wedge, and which also closes every TLS session the network target holds. + """ + + +@dataclass +class AbortedCommand: + """What an ABORT written during a command's PROCESSING left behind.""" + command: bytes + abort_after: float # seconds from the PUSH to the ABORT + busy_at_abort: bool # the command was still in PROCESSING then + bit2_cleared_after: float # seconds from the PUSH until $DF1C bit 2 read 0 + final_status: int # $DF1C once bit 2 was 0 + + +def bound_for(command: bytes) -> float: + """The client deadline B for this command.""" + code = command[1] if len(command) >= 2 else 0 + if code in (NET_CMD_OPEN_TLS, NET_CMD_START_TLS): + return BOUND_OPEN + if code in (NET_CMD_OPEN_TCP, NET_CMD_OPEN_UDP): + return BOUND_OPEN_TCP + if code in TLS_COMMANDS or code in (NET_CMD_READ_SOCKET, NET_CMD_WRITE_SOCKET, + NET_CMD_CLOSE_SOCKET): + return BOUND_OTHER + return BOUND_PLAIN + + +class Link: + """One way of handing commands to the network target.""" + + name = "link" + # Whether this link can write ABORT while a command is in PROCESSING. + can_abort_in_flight = False + + def __init__(self) -> None: + # Every command and its result, in order: the run's wire evidence. + self.log: list[dict] = [] + + def command(self, command: bytes, bound: float | None = None) -> Result: + bound = bound_for(command) if bound is None else bound + result = self._command(command, bound) + self.log.append({"t": round(time.time(), 3), "link": self.name, + "command": command.hex(" "), "data": result.data.hex(" "), + "status": result.status.decode("latin-1"), + "elapsed": round(result.elapsed, 3), "aborted": result.aborted}) + detail(f"{command[:40].hex(' ')}{' ...' if len(command) > 40 else ''} -> {result.describe()}") + return result + + def _command(self, command: bytes, bound: float) -> Result: + raise NotImplementedError + + def abort_in_flight(self, command: bytes, abort_after: float, + bound: float | None = None) -> AbortedCommand: + raise Failure(f"the {self.name} route cannot ABORT a command in flight") + + def startup_abort(self) -> float: + """Startup: presence check, $0C, then wait for bit 2 up to 45 s. Seconds taken.""" + raise NotImplementedError + + +class RestLink(Link): + """The registers over REST DMA, with the client deadlines and ABORT.""" + + name = "rest" + can_abort_in_flight = True + poll = 0.05 + + def __init__(self, uci: Uci) -> None: + super().__init__() + self.uci = uci + + def _wait_bit2(self, deadline: float) -> int: + """Wait for $DF1C bit 2 (ABORT pending) to read 0; the status, or LinkLost.""" + while True: + status = self.uci.status() + if not status & ST_ABORT_P: + return status + if time.monotonic() > deadline: + raise LinkLost(f"$DF1C bit 2 still set at the client deadline: " + f"{describe_status(status)}. The interface is wedged") + time.sleep(self.poll) + + def _abort(self, pushed: float, bound: float) -> int: + aborted = time.monotonic() + self.uci.control(CTRL_ABORT) + status = self._wait_bit2(max(pushed + bound, aborted + POST_ABORT_MIN)) + if status & ST_ERROR: + self.uci.control(CTRL_CLR_ERR) + return status + + def _push(self, command: bytes) -> float: + if not self.uci.release(): + raise LinkLost(f"the interface did not return to Idle before {command.hex(' ')}: " + f"{describe_status(self.uci.status())}") + self.uci.require_idle("before pushing a command") + for byte in command: + self.uci.poke(REG_COMMAND, byte) + pushed = time.monotonic() + self.uci.control(CTRL_PUSH_CMD) + return pushed + + def _command(self, command: bytes, bound: float) -> Result: + pushed = self._push(command) + blocks: list[bytes] = [] + status_text = b"" + wait_from = pushed + wait_bound = bound + while True: + # B bounds the first block; each later block gets 12 s from + # the data-accept of the block before it. + while True: + status = self.uci.status() + state = status & ST_STATE_MASK + if state in (ST_STATE_DATA_LAST, ST_STATE_DATA_MORE): + break + if time.monotonic() - wait_from > wait_bound: + self._abort(pushed, bound) + return Result(command, b"".join(blocks), b"", + time.monotonic() - pushed, aborted=True) + time.sleep(self.poll) + data, text = self.uci.drain() + blocks.append(data) + status_text = text or status_text + if state != ST_STATE_DATA_MORE: + break + if len(blocks) >= MAX_REPLY_BLOCKS: + raise Failure(f"reply to {command.hex(' ')} still said Data More after " + f"{MAX_REPLY_BLOCKS} blocks") + self.uci.control(CTRL_DATA_ACC) + wait_from, wait_bound = time.monotonic(), BOUND_OTHER + elapsed = time.monotonic() - pushed + self.uci.control(CTRL_DATA_ACC) + final = self.uci.status() + if (final & ST_STATE_MASK) != ST_STATE_IDLE or final & ST_ERROR: + raise LinkLost(f"the interface was {describe_status(final)} after the reply to " + f"{command.hex(' ')} was accepted, expected Idle") + return Result(command, b"".join(blocks), status_text, elapsed) + + def abort_in_flight(self, command: bytes, abort_after: float, + bound: float | None = None) -> AbortedCommand: + """PUSH, write ABORT ($04 alone) `abort_after` s later, wait out bit 2. + + This is the client of 1.1 "What a client does": after the ABORT it + writes nothing to $DF1C/$DF1D until bit 2 reads 0, up to the later of + PUSH + B and ABORT + 12 s. The reply, if any, is dropped by the ABORT. + """ + bound = bound_for(command) if bound is None else bound + pushed = self._push(command) + time.sleep(abort_after) + busy = (self.uci.status() & ST_STATE_MASK) == ST_STATE_BUSY + self.uci.control(CTRL_ABORT) + aborted = time.monotonic() + final = self._wait_bit2(max(pushed + bound, aborted + POST_ABORT_MIN)) + cleared = time.monotonic() - pushed + if final & ST_ERROR: + self.uci.control(CTRL_CLR_ERR) + if (final & ST_STATE_MASK) != ST_STATE_IDLE: + # A reply that arrived after bit 2 cleared cannot be: the ABORT is + # serviced right after the command returns. Accept anything left. + self.uci.release() + self.log.append({"t": round(time.time(), 3), "link": self.name, + "command": command.hex(" "), "abort_after": abort_after, + "busy_at_abort": busy, "bit2_cleared_after": round(cleared, 3), + "final": describe_status(final)}) + detail(f"{command[:40].hex(' ')} ABORTed {abort_after:.1f}s after its PUSH " + f"({'in PROCESSING' if busy else 'already answered'}); bit 2 cleared " + f"{cleared:.2f}s after the PUSH, then {describe_status(final)}") + return AbortedCommand(command, abort_after, busy, cleared, final) + + def startup_abort(self) -> float: + ident = self.uci.peek(REG_COMMAND) + if ident not in (0xC9, 0x49): + raise Failure(f"$DF1D reads ${ident:02X}, not $C9/$49: no command interface") + started = time.monotonic() + self.uci.control(CTRL_ABORT | CTRL_CLR_ERR) + self._wait_bit2(started + BOUND_OPEN) + self.uci.release() + return time.monotonic() - started + + +class NativeLink(Link): + """The registers from 6502 code on the C64 (uci_native.NativeUci).""" + + name = "native" + # One wrap of the agent's 16-bit wait counter is about 1.7 s at 1 MHz (by + # cycle count, not measured), so 40 wraps (about 67 s) outlast the host's + # own deadline (57 s for an open), which therefore fires first. + WAIT_WRAPS = 40 + + def __init__(self, agent) -> None: + super().__init__() + self.agent = agent + self.agent.wait_wraps = self.WAIT_WRAPS + + def _command(self, command: bytes, bound: float) -> Result: + # The agent cannot ABORT a command in flight, so its wait is the + # bound plus margin, and a command that outlives it loses the route. + self.agent.busy_timeout = bound + POST_ABORT_MIN + started = time.monotonic() + try: + transaction = self.agent.transact(command, single_part=False) + except Failure as exc: + raise LinkLost(f"the 6502 agent lost {command.hex(' ')}: {exc}") from exc + return Result(command, transaction.data, transaction.status_text, + time.monotonic() - started) + + def startup_abort(self) -> float: + # The agent's own transaction starts by handing back anything pending, + # and the run_prg that started it reset the C64 a moment ago. + return 0.0 + + +# -- command builders -------------------------------------------------------- + +def open_tls_command(port: int, host: str | bytes, trust: int = TRUST_BUNDLE, flags: int = 0, + name: str | bytes | None = None, pin: bytes | None = None, + tail: bytes | None = None, no_reply: bool = False) -> bytes: + """`03 21 port trust flags [pin] tail`, the tail being host [00 name].""" + head = bytes([TARGET_NETWORK | (NO_REPLY if no_reply else 0), NET_CMD_OPEN_TLS, + port & 0xFF, (port >> 8) & 0xFF, trust & 0xFF, flags & 0xFF]) + if pin is not None: + head += pin + if tail is None: + host_b = host.encode("ascii") if isinstance(host, str) else host + tail = host_b + if name is not None: + tail += b"\x00" + (name.encode("ascii") if isinstance(name, str) else name) + return head + tail + + +def open_tcp_command(host: str, port: int) -> bytes: + return (bytes([TARGET_NETWORK, NET_CMD_OPEN_TCP, port & 0xFF, (port >> 8) & 0xFF]) + + host.encode("ascii") + b"\x00") + + +def read_command(handle: int, maxlen: int) -> bytes: + return bytes([TARGET_NETWORK, NET_CMD_READ_SOCKET, handle, maxlen & 0xFF, (maxlen >> 8) & 0xFF]) + + +def write_command(handle: int, data: bytes) -> bytes: + return bytes([TARGET_NETWORK, NET_CMD_WRITE_SOCKET, handle]) + data + + +def close_command(handle: int) -> bytes: + return bytes([TARGET_NETWORK, NET_CMD_CLOSE_SOCKET, handle]) + + +def info_command(handle: int) -> bytes: + return bytes([TARGET_NETWORK, NET_CMD_TLS_INFO, handle]) + + +def release_command() -> bytes: + return bytes([TARGET_NETWORK, NET_CMD_TLS_RELEASE]) + + +def trust_ca_command(offset: int, total: int, chunk: bytes) -> bytes: + return bytes([TARGET_NETWORK, NET_CMD_TLS_TRUST_CA, offset & 0xFF, (offset >> 8) & 0xFF, + total & 0xFF, (total >> 8) & 0xFF]) + chunk + + +def start_tls_command(handle: int, trust: int, flags: int = 0, name: str | None = None, + pin: bytes | None = None) -> bytes: + command = bytes([TARGET_NETWORK, NET_CMD_START_TLS, handle, trust, flags]) + if pin is not None: + command += pin + if name is not None: + command += name.encode("ascii") + return command + + +# -- replies ----------------------------------------------------------------- + +@dataclass +class Capability: + """TLS_INFO $FF: the capability record.""" + raw: bytes + + @property + def version(self) -> int: + return self.raw[0] + + @property + def max_sessions(self) -> int: + return self.raw[1] + + @property + def entries(self) -> int: + return self.raw[2] + + @property + def trust_modes(self) -> int: + return self.raw[3] + + @property + def ready(self) -> int: + return self.raw[4] + + @property + def versions(self) -> int: + return self.raw[5] + + @property + def module_version(self) -> tuple[int, int]: + return self.raw[6], int.from_bytes(self.raw[7:9], "little") + + @property + def store_date(self) -> bytes: + return self.raw[9:12] + + @property + def block_max_ms(self) -> int: + return int.from_bytes(self.raw[12:14], "little") + + @property + def unclaimed(self) -> int: + return self.raw[14] + + def as_dict(self) -> dict: + major, minor = self.module_version + return {"raw": self.raw.hex(" "), "interface": self.version, + "max_sessions": self.max_sessions, "entries": self.entries, + "trust_modes": self.trust_modes, "ready": self.ready, + "ready_bits": {"module": bool(self.ready & 1), "entropy": bool(self.ready & 2), + "time": bool(self.ready & 4), "custom_ca": bool(self.ready & 8)}, + "versions": self.versions, "module_version": f"{major}.{minor}", + "store_date": self.store_date.hex(" "), "block_max_ms": self.block_max_ms, + "unclaimed": self.unclaimed} + + +@dataclass +class OpenReply: + """The 8 bytes of a successful OPEN_TLS / START_TLS.""" + raw: bytes + + @property + def handle(self) -> int: + return self.raw[0] + + @property + def version(self) -> int: + return int.from_bytes(self.raw[1:3], "little") + + @property + def suite(self) -> int: + return int.from_bytes(self.raw[3:5], "little") + + @property + def group(self) -> int: + return int.from_bytes(self.raw[5:7], "little") + + @property + def bits(self) -> int: + return self.raw[7] + + def as_dict(self) -> dict: + return {"handle": self.handle, "version": f"0x{self.version:04X}", + "suite": f"0x{self.suite:04X}", "group": f"0x{self.group:04X}", + "bits": self.bits} + + +@dataclass +class HandleInfo: + """TLS_INFO for a handle: 48 bytes.""" + raw: bytes + + @property + def version(self) -> int: + return int.from_bytes(self.raw[0:2], "little") + + @property + def suite(self) -> int: + return int.from_bytes(self.raw[2:4], "little") + + @property + def group(self) -> int: + return int.from_bytes(self.raw[4:6], "little") + + @property + def trust(self) -> int: + return self.raw[6] + + @property + def bits(self) -> int: + return self.raw[7] + + @property + def spki_sha256(self) -> bytes: + return self.raw[8:40] + + @property + def handshake_ms(self) -> int: + return int.from_bytes(self.raw[40:44], "little") + + def as_dict(self) -> dict: + return {"version": f"0x{self.version:04X}", "suite": f"0x{self.suite:04X}", + "group": f"0x{self.group:04X}", "trust": self.trust, "bits": self.bits, + "spki_sha256": self.spki_sha256.hex(), "handshake_ms": self.handshake_ms} + + +@dataclass +class ReadReply: + """One READ_SOCKET: the 2-byte header, the payload, the status.""" + result: Result + + @property + def header(self) -> int | None: + data = self.result.data + return int.from_bytes(data[:2], "little") if len(data) >= 2 else None + + @property + def payload(self) -> bytes: + return self.result.data[2:] + + @property + def status(self) -> bytes: + return self.result.status + + @property + def gone(self) -> bool: + """01/05: the handle is closed and untracked; never CLOSE it.""" + return self.header == 0 and status_code(self.status) in (1, 5) + + +@dataclass +class TlsSession: + """What the suite knows about one handle it holds.""" + handle: int + reply: OpenReply + gone: bool = False + notes: list[str] = field(default_factory=list) diff --git a/tests/e2e/io/command_interface/net_tls_selftest.py b/tests/e2e/io/command_interface/net_tls_selftest.py new file mode 100644 index 000000000..d8986bcb5 --- /dev/null +++ b/tests/e2e/io/command_interface/net_tls_selftest.py @@ -0,0 +1,696 @@ +#!/usr/bin/env python3 +# Self-test: the UCI TLS suite against a simulated device; needs no hardware. + +"""Check net_tls_test.py without a device: it must go GREEN, RED, and red for the right reason. + +Seven parts, none of which touches any Ultimate: + +1. The client deadlines on the REST route, against fake registers: a late + reply is ABORTed, and a bit 2 that never clears is a LinkLost, never a hang. +2. The scenarios against net_tls_mock.MockDevice and the real local fixture: + the tls flavour GREEN (except S22, a mock limit), stock RED. +3. Mutants of the mock: the scenario guarding each broken rule must go red. +4. main() over real HTTP (tests/lib/device_double.py) for Tier 1 without S30: + --expect green on tls and red on stock exit 0, and swapped, 1. +5. No verdict without evidence, and setup failures are errors. +6. Setup refusals change no setting; READs and routes are bounded. +7. The fixture outlasts a slow reader (S13 over REST). + +Usage: net_tls_selftest.py [--quick] (--quick skips the tls flavour's 15 s +handshake-timeout scenario and the 16 KB record) +""" + +import argparse +import json +import os +import sys +import tempfile +import threading +import time +from pathlib import Path +from types import SimpleNamespace + +# The one stanza that puts the shared library on sys.path; see tests/lib/bootstrap.py. +sys.path.insert(0, str(next(p for p in Path(__file__).resolve().parents + if (p / "tests" / "lib").is_dir()) / "tests" / "lib")) +import bootstrap # noqa: E402,F401 +from report import Failure, check, check_skip, check_start, detail, section, suite_fail, suite_ok, suite_skip # noqa: E402 +from device_double import DeviceDouble # noqa: E402 +from uci import MAX_BLOCK_BYTES, Uci # noqa: E402 + +sys.path.insert(0, bootstrap.directory("e2e", "io", "command_interface")) +import net_tls_fixture as fx # noqa: E402 +import net_tls_proto as proto # noqa: E402 +import net_tls_test as suite # noqa: E402 +from net_tls_mock import MockDevice # noqa: E402 + +SUITE = "net_tls_selftest" +STANDINS = (("H1", "h1.standin.test"), ("H2", "h2.standin.test")) + + +# -- part 1: fake registers -------------------------------------------------- + +class FakeRegisters: + """$DF1B-$DF1F as a MachineApi: readmem / writemem, one command at a time.""" + + def __init__(self, busy: float, reply: bytes = b"\x05", text: bytes = b"00,OK", + stuck_abort: bool = False) -> None: + self.busy, self.reply, self.text, self.stuck = busy, reply, text, stuck_abort + self.state = "idle" + self.done_at = 0.0 + self.abort = False + self.resp = bytearray() + self.stat = bytearray() + + def _tick(self) -> None: + if self.state == "busy" and time.monotonic() >= self.done_at: + if self.abort: + # The ABORT is serviced right after the command returns: the + # reply is dropped and the state goes back to Idle. + self.state = "idle" + self.abort = self.stuck + else: + self.state = "reply" + self.resp, self.stat = bytearray(self.reply), bytearray(self.text) + + def _status(self) -> int: + self._tick() + value = {"idle": 0x00, "busy": 0x11, "reply": 0x20}[self.state] + if self.abort: + value |= 0x04 + if self.state == "reply": + value |= (0x80 if self.resp else 0) | (0x40 if self.stat else 0) + return value + + def _read(self, address: int) -> int: + if address == 0xDF1C: + return self._status() + if address == 0xDF1D: + return 0xC9 + if address == 0xDF1E: + return self.resp.pop(0) if self.resp else 0 + if address == 0xDF1F: + return self.stat.pop(0) if self.stat else 0 + return 0x02 + + def readmem(self, address: int, length: int = 1) -> bytes: + return bytes(self._read(address + i) for i in range(length)) + + def writemem(self, address: int, data: bytes, idempotent: bool = False) -> None: + if address != 0xDF1C: + return + for bits in data: + self._tick() + if bits & 0x01: + self.state, self.done_at = "busy", time.monotonic() + self.busy + if bits & 0x02 and self.state == "reply": + self.state = "idle" + if bits & 0x04: + # On an idle interface the ABORT is serviced at once. + self.abort = self.state == "busy" or self.stuck + + +def part1() -> bool: + section("part 1: client deadlines over fake registers") + ok = True + saved = proto.POST_ABORT_MIN + proto.POST_ABORT_MIN = 1.5 + try: + cases = [ + ("a reply inside its bound is collected", FakeRegisters(0.2), 2.0, "reply"), + ("a reply past its bound is ABORTed; bit 2 clears when the command ends", + FakeRegisters(1.0), 0.4, "aborted"), + ("bit 2 that never clears is LinkLost at the deadline, not a hang", + FakeRegisters(5.0, stuck_abort=True), 0.4, "lost"), + ] + for label, regs, bound, wanted in cases: + try: + with check(label): + link = proto.RestLink(Uci(regs, 30.0)) + started = time.monotonic() + try: + result = link.command(proto.info_command(0xFF), bound) + got = "aborted" if result.aborted else "reply" + if got == "reply" and (result.data, result.status) != (b"\x05", b"00,OK"): + raise Failure(f"collected {result.describe()}") + except proto.LinkLost: + got = "lost" + took = time.monotonic() - started + detail(f"{got} after {took:.2f}s") + if got != wanted: + raise Failure(f"{got}, expected {wanted}") + if took > bound + proto.POST_ABORT_MIN + 1.0: + raise Failure(f"took {took:.2f}s, past the client deadline") + except Failure: + ok = False + try: + with check("abort_in_flight: ABORT lands in PROCESSING; bit 2 clears at the command's end"): + regs = FakeRegisters(1.0) + outcome = proto.RestLink(Uci(regs, 30.0)).abort_in_flight( + proto.info_command(0xFF), 0.3, bound=5.0) + if not outcome.busy_at_abort or not 0.9 <= outcome.bit2_cleared_after <= 2.0: + raise Failure(str(outcome)) + except Failure: + ok = False + finally: + proto.POST_ABORT_MIN = saved + return ok + + +# -- parts 2 and 3: the mock ----------------------------------------------- + +class World: + """The fixture PKI, a stand-in public PKI and its HTTP servers.""" + + def __init__(self) -> None: + self.pki = fx.Pki() + self.public = fx.Pki() + self.public_root = str(self.public.root_pem_file()) + self.servers = [] + self.hosts = [] + self.resolver = {} + for hid, name in STANDINS: + chain = self.public.issue(hid, name) + server = fx.TlsServer("127.0.0.1", chain, fx.Behaviour(then="http")) + self.servers.append(server) + self.hosts.append(suite.Host(name, hid, ip="127.0.0.1", port=server.port)) + self.resolver[name] = "127.0.0.1" + + def device(self, flavour: str) -> MockDevice: + return MockDevice(flavour, bundle_cafile=self.public_root, resolver=self.resolver, + system_bundle=False) + + def args(self) -> SimpleNamespace: + return SimpleNamespace(module_minor=8, mac_cafile=self.public_root, strict_sni=True, + hosts=self.hosts) + + def run(self, flavour: str, sids: list[str]) -> dict[str, suite.Outcome]: + device = self.device(flavour) + + def reset(): + device.reset() + return device + scenarios = [s for s in suite.SCENARIOS if s.sid in sids] + outcomes, _ = suite.run_routes([(f"mock-{flavour}", lambda: device, reset)], scenarios, + self.args(), self.pki, "127.0.0.1", + {"peer", "fixture", "crypto", "internet"}) + device.reset() + return {o.scenario.sid: o for o in outcomes} + + def close(self) -> None: + for server in self.servers: + server.close() + self.pki.close() + self.public.close() + + +# -- part 4: main() over HTTP --------------------------------------------------- + +class UciDouble(DeviceDouble): + """The repository's REST double, with a command interface run by a MockDevice.""" + + def __init__(self, device: MockDevice) -> None: + super().__init__() + self.mock = device + self.configs.update({ + "C64 and Cartridge Settings": {"Command Interface": "Disabled"}, + "WiFi settings": {"WiFi Enabled": "Enabled"}, + "Network Settings": {"SNTP Enable": "Disabled"}, + "U64 Specific Settings": {"Turbo Control": "Manual"}, + }) + self.cmd = bytearray() + self.state = "idle" + self.abort = False + self.blocks: list[tuple[bytes, bytes]] = [] + self.resp = bytearray() + self.stat = bytearray() + self.uci_lock = threading.Lock() + + def route(self, method, path): + if path == "/v1/machine:readmem" and method == "GET": + return self._uci_read + if path == "/v1/machine:writemem" and method == "PUT": + return self._uci_write + if path == "/v1/machine:reset" and method == "PUT": + return self._reset + return super().route(method, path) + + def _reset(self, params): + self.mock.reset() + return self._ok_json(params) + + def _run(self, command: bytes) -> None: + data, text = self.mock._dispatch(command) + with self.uci_lock: + if self.abort: + # The ABORT is serviced once the command returns: reply dropped. + self.state, self.abort, self.blocks = "idle", False, [] + return + chunks = [data[i:i + MAX_BLOCK_BYTES] for i in range(0, len(data), MAX_BLOCK_BYTES)] + chunks = chunks or [b""] + self.blocks = [(chunk, text if i == len(chunks) - 1 else b"") + for i, chunk in enumerate(chunks)] + self._next_block() + + def _next_block(self) -> None: + chunk, text = self.blocks.pop(0) + self.resp, self.stat = bytearray(chunk), bytearray(text) + self.state = "more" if self.blocks else "last" + + def _status(self) -> int: + value = {"idle": 0x00, "busy": 0x11, "last": 0x20, "more": 0x30}[self.state] + if self.abort: + value |= 0x04 + if self.state in ("last", "more"): + value |= (0x80 if self.resp else 0) | (0x40 if self.stat else 0) + return value + + def _byte(self, address: int) -> int: + if address == 0xDF1C: + return self._status() + if address == 0xDF1D: + return 0xC9 + if address == 0xDF1E: + return self.resp.pop(0) if self.resp else 0 + if address == 0xDF1F: + return self.stat.pop(0) if self.stat else 0 + return 0x02 + + def _uci_read(self, params): + address = int(params.get("address", "0"), 16) + if not 0xDF1B <= address <= 0xDF1F: + return super()._readmem(params) + length = int(params.get("length", "1")) + with self.uci_lock: + body = bytes(self._byte(address + i) for i in range(length)) + return 200, body, "application/octet-stream" + + def _uci_write(self, params): + address = int(params.get("address", "0"), 16) + data = bytes.fromhex(params.get("data", "")) + with self.uci_lock: + for value in data: + if address == 0xDF1D: + self.cmd.append(value) + elif address == 0xDF1C: + self._control(value) + return self._ok_json(params) + + def _control(self, bits: int) -> None: + if bits & 0x01 and self.state == "idle": + command, self.cmd = bytes(self.cmd), bytearray() + self.state = "busy" + threading.Thread(target=self._run, args=(command,), daemon=True).start() + if bits & 0x02: + if self.state == "more": + self._next_block() + elif self.state == "last": + self.state = "idle" + if bits & 0x04: + if self.state == "busy": + self.abort = True + else: + self.state, self.blocks, self.cmd = "idle", [], bytearray() + + +def part4(world: "World") -> bool: + section("part 4: main() over HTTP, against a REST double with a mocked network target") + ok = True + tier1 = ["S1", "S20", "S2", "S23", "S5", "S19e"] + for flavour, expect, code in (("tls", "green", 0), ("stock", "red", 0), + ("tls", "red", 1), ("stock", "green", 1)): + double = UciDouble(world.device(flavour)) + saved = {k: os.environ.get(k) for k in double.environment()} + os.environ.update(double.environment()) + try: + with tempfile.TemporaryDirectory() as results: + argv = ["-H", "127.0.0.1", "-t", "10", "--route", "rest", "--expect", expect, + "--results", results, "--module-minor", "8"] + for sid in tier1: + argv += ["--test", sid] + exit_code = suite.main(argv) + run = json.loads((Path(results) / "run.json").read_text()) + try: + with check(f"{flavour} with --expect {expect} exits {code}; run.json and settings"): + if exit_code != code: + raise Failure(f"exit {exit_code}") + settings = run.get("settings", {}) + wanted = {"Command Interface": "Enabled", "WiFi Enabled": "Enabled", + "SNTP Enable": "Enabled", "Turbo Control": "Off"} + if settings != wanted: + raise Failure(f"settings read back {settings}") + restored = double.configs["C64 and Cartridge Settings"]["Command Interface"] + if restored != "Disabled": + raise Failure(f"Command Interface left {restored!r}, not restored") + if double.configs["WiFi settings"]["WiFi Enabled"] != "Enabled": + raise Failure("WiFi Enabled was written back (it is one-way)") + sigs = {o["sid"]: o["signature"] for o in run["scenarios"]} + detail(str(sigs)) + if len(run["scenarios"]) != len(tier1) + 1: + raise Failure(f"{len(run['scenarios'])} scenario records") + resets = double.calls(path="/v1/machine:reset") + if not resets: + raise Failure("the C64 was never reset") + except Failure: + ok = False + finally: + for key, value in saved.items(): + if value is None: + os.environ.pop(key, None) + else: + os.environ[key] = value + double.close() + return ok + + +def run_main(world: "World", flavour: str, argv: list[str], fixture: bool = True, + native_fails: bool = False, wifi: str = "Enabled") -> tuple[int, dict, UciDouble]: + """suite.main() against a double; (exit code, run.json, the double).""" + double = UciDouble(world.device(flavour)) + double.configs["WiFi settings"]["WiFi Enabled"] = wifi + saved_env = {k: os.environ.get(k) for k in double.environment()} + os.environ.update(double.environment()) + saved_address, saved_start = fx.local_address_towards, suite.NativeUci.start + + def no_route(*_args, **_kw): + raise OSError("self-test: no route to the device") + + def no_agent(_self): + raise Failure("self-test: the agent did not start (64tass Exec format error)") + if not fixture: + fx.local_address_towards = no_route + if native_fails: + suite.NativeUci.start = no_agent + try: + with tempfile.TemporaryDirectory() as results: + try: + code = suite.main(["-H", "127.0.0.1", "-t", "10", "--results", results, *argv]) + except SystemExit as exc: # argparse refusing an option + code = exc.code + path = Path(results) / "run.json" + run = json.loads(path.read_text()) if path.exists() else {"scenarios": []} + finally: + fx.local_address_towards, suite.NativeUci.start = saved_address, saved_start + for key, value in saved_env.items(): + if value is None: + os.environ.pop(key, None) + else: + os.environ[key] = value + double.close() + return code, run, double + + +class SlowReads(proto.Link): + """READs that each take 50 ms and alternate data with `02,NO DATA: 11`.""" + name = "slow" + + def __init__(self) -> None: + super().__init__() + self.turn = 0 + + def _command(self, command: bytes, bound: float) -> proto.Result: + time.sleep(0.05) + self.turn += 1 + if self.turn % 2: + return proto.Result(command, (100).to_bytes(2, "little") + bytes(100), b"00,OK", 0.05) + return proto.Result(command, b"\xff\xff", proto.STATUS_NO_DATA_IDLE, 0.05) + + +def part5(world: "World") -> bool: + section("part 5: no verdict without evidence; setup failures are errors") + ok = True + t1 = ["--test", "tier1", "--module-minor", "8", "--route", "rest"] + cases = [ + ("tls, --expect green, the fixture cannot start -> exit 1", + "tls", ["--expect", "green", *t1], {"fixture": False}, 1), + ("stock, --expect red, the fixture cannot start -> exit 1", + "stock", ["--expect", "red", *t1], {"fixture": False}, 1), + ("mutant bundle-accepts-all, --expect green, no fixture -> exit 1", + "bundle-accepts-all", ["--expect", "green", *t1], {"fixture": False}, 1), + ("stock, --expect green, only S32 on REST (route n/a) -> exit 1", + "stock", ["--expect", "green", "--test", "S32", "--route", "rest"], {}, 1), + ("stock, --expect red, only the S33 measurement -> exit 1", + "stock", ["--expect", "red", "--test", "S33", "--route", "rest"], {}, 1), + ("WiFi Disabled and no --set-wifi: setup refuses, WiFi untouched -> exit 1", + "tls", ["--expect", "green", "--test", "S1", "--route", "rest", "--module-minor", "8"], + {"wifi": "Disabled"}, 1), + ("WiFi Disabled with --set-wifi: set and kept -> exit 0", + "tls", ["--expect", "green", "--test", "S1", "--route", "rest", "--module-minor", "8", + "--set-wifi"], {"wifi": "Disabled"}, 0), + ] + for label, flavour, argv, options, wanted in cases: + try: + with check(label): + code, run, double = run_main(world, flavour, argv, **options) + detail(str([(o["sid"], o["verdict"], o["signature"]) for o in run["scenarios"]])) + if code != wanted: + raise Failure(f"exit {code}") + wifi = double.configs["WiFi settings"]["WiFi Enabled"] + if options.get("wifi") == "Disabled" and "--set-wifi" not in argv and wifi != "Disabled": + raise Failure(f"WiFi Enabled was written ({wifi!r}) without --set-wifi") + if "--set-wifi" in argv and wifi != "Enabled": + raise Failure(f"--set-wifi left WiFi {wifi!r}") + except Failure: + ok = False + try: + with check("the native agent fails to start: REST records kept, native ERROR, exit 1"): + code, run, _ = run_main(world, "tls", ["--expect", "green", "--test", "S1", + "--module-minor", "8"], native_fails=True) + records = [(o["route"], o["sid"], o["verdict"]) for o in run["scenarios"]] + detail(str(records)) + rest = [r for r in records if r[0] == "rest"] + native = [r for r in records if r[0] == "native"] + if code != 1 or not rest or any(v != "PASS" for _, _, v in rest): + raise Failure(f"exit {code}, REST records {rest}") + if not native or any(v != "ERROR" for _, _, v in native): + raise Failure(f"native records {native}") + except Failure: + ok = False + try: + with check("read_until's budget is idle time: 2000 B over 50 ms READs, budget 0.5 s"): + ctx = suite.Ctx(SlowReads(), SimpleNamespace(), None, None, None, []) + got, end = ctx.read_until(0, 2000, budget=0.5) + if len(got) != 2000 or end is not None: + raise Failure(f"{len(got)} bytes, end {end}") + except Failure: + ok = False + return ok + + +class EmptyOk(proto.Link): + """READs that answer 00,OK with header $0000: not a 1.6 answer.""" + name = "empty-ok" + + def __init__(self) -> None: + super().__init__() + self.calls = 0 + + def _command(self, command: bytes, bound: float) -> proto.Result: + self.calls += 1 + if self.calls > 5000: + raise Failure("read_until was still reading after 5000 empty 00,OK READs: unbounded") + return proto.Result(command, b"\x00\x00", b"00,OK", 0.0) + + +def part6(world: "World") -> bool: + section("part 6: setup refusals and bounded reads") + ok = True + try: + with check("WiFi off, no --set-wifi: refused before ANY setting is written"): + code, run, double = run_main(world, "tls", ["--expect", "green", "--test", "S1", "--route", + "rest", "--module-minor", "8"], + wifi="Disabled") + ci = double.configs["C64 and Cartridge Settings"]["Command Interface"] + sntp = double.configs["Network Settings"]["SNTP Enable"] + if code != 1 or ci != "Disabled" or sntp != "Disabled": + raise Failure(f"exit {code}, Command Interface {ci!r}, SNTP {sntp!r}") + if not run.get("settings_before"): + raise Failure("run.json does not record the settings as found") + if double.calls(path="/v1/machine:reset"): + raise Failure("the C64 was reset although nothing was run") + except Failure: + ok = False + try: + with check("--route native with S19e selected: S19e ran on no route -> exit 1"): + outcomes = [suite.Outcome(suite.BY_NAME["S0"], "native", "PASS"), + suite.Outcome(suite.BY_NAME["S1"], "native", "PASS"), + suite.Outcome(suite.BY_NAME["S19e"], "native", "N/A")] + for o in outcomes: + suite.judge(o) + met, problems = suite.expectation_met(outcomes, "green") + detail(str(problems)) + if met: + raise Failure("met") + except Failure: + ok = False + try: + with check("READ answering 00,OK with no data: read_until fails, bounded"): + link = EmptyOk() + ctx = suite.Ctx(link, SimpleNamespace(), None, None, None, []) + try: + ctx.read_until(0, 100, budget=0.5) + raise Failure("read_until returned") + except Failure as exc: + if "unbounded" in str(exc): + raise + detail(f"failed as it should: {exc}") + except Failure: + ok = False + try: + from c64_test_harness.backends.device_lock import DeviceLock # noqa: PLC0415 + except ImportError: + DeviceLock = None + # Without the harness every run with --require-lock is refused for want of a DeviceLock, so this check + # would pass without looking at any lock. + if DeviceLock is None: + check_start("--require-lock with no session lock: refused, nothing changed") + check_skip("c64_test_harness is not installed, so there is no session lock to be missing") + else: + try: + with check("--require-lock with no session lock: refused, nothing changed"): + code, run, double = run_main(world, "tls", ["--expect", "green", "--test", "S1", "--route", + "rest", "--module-minor", "8", + "--require-lock"]) + ci = double.configs["C64 and Cartridge Settings"]["Command Interface"] + if code != 1 or ci != "Disabled": + raise Failure(f"exit {code}, Command Interface {ci!r}") + except Failure: + ok = False + if DeviceLock is None: + check_start("--require-lock inside this process's own lock (NET_TLS_LOCK_PID) runs -> exit 0") + check_skip("c64_test_harness is not installed, so there is no DeviceLock to take") + return ok + try: + with check("--require-lock inside this process's own lock (NET_TLS_LOCK_PID) runs -> exit 0"): + lock = DeviceLock("127.0.0.1") + if not lock.acquire(timeout=10): + raise Failure("could not take the 127.0.0.1 test lock") + os.environ["NET_TLS_LOCK_PID"] = str(os.getpid()) + try: + code, run, _ = run_main(world, "tls", ["--expect", "green", "--test", "S1", "--route", + "rest", "--module-minor", "8", + "--require-lock"]) + finally: + os.environ.pop("NET_TLS_LOCK_PID", None) + lock.release() + if code != 0: + raise Failure(f"exit {code}: {run.get('setup_error')}") + except Failure: + ok = False + return ok + + +SLOW_READER_SECONDS = 65.0 + + +def part7(world: "World") -> bool: + """A device run's S13-over-REST failure, modelled: a client that reads after more than 60 s. + + On the REST route the device needed about 250 s to read a 16 KB record before + it wrote (one REST call per byte). A fixture whose per-connection idle + timeout is shorter than the slowest route gives up and closes, and the + device's WRITE meets a reset: a fixture failure reported against the + firmware. + """ + section("part 7: the fixture outlasts a slow reader (S13 over REST)") + ok = True + try: + with check(f"a client that waits {SLOW_READER_SECONDS:.0f}s before reading 16 KB and " + f"writing 100 B still gets its echo"): + data = fx.payload(13, 16384) + server = fx.TlsServer("127.0.0.1", world.pki.chains["ecdsa"], + fx.Behaviour(send=data, then="echo")) + device = world.device("tls") + ctx = suite.Ctx(device, SimpleNamespace(), world.pki, "127.0.0.1", None, []) + try: + reply = ctx.expect_open(server.port, "127.0.0.1", + pin=world.pki.chains["ecdsa"].spki_sha256) + time.sleep(SLOW_READER_SECONDS) + got, end = ctx.read_until(reply.handle, len(data)) + if got != data: + raise Failure(f"{len(got)} of {len(data)} bytes ({end})") + suite.echo_round_trip(ctx, reply.handle, 100, seed=7) + ctx.close(reply.handle) + finally: + server.close() + device.reset() + detail(str([c.as_dict() for c in server.logs])) + except Failure: + ok = False + return ok + + +def judge_flavour(label: str, outcomes: dict, wanted: dict[str, str]) -> bool: + """`wanted` maps a sid to the signature it must show.""" + ok = True + for sid, signature in wanted.items(): + o = outcomes.get(sid) + try: + with check(f"{label}: {sid} shows {signature}"): + if o is None: + raise Failure("not run") + if o.signature != signature: + raise Failure(f"{o.signature}: {o.reason[:200]}") + except Failure: + ok = False + return ok + + +def main() -> int: + parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + parser.add_argument("--quick", action="store_true") + args = parser.parse_args() + if not fx.HAVE_CRYPTOGRAPHY: + suite_skip(SUITE, "the `cryptography` package is not installed") + return 0 + ok = part1() + world = World() + try: + everything = [s.sid for s in suite.SCENARIOS if s.default] + if args.quick: + everything = [sid for sid in everything if sid not in ("S10", "S13")] + section("part 2: the tls flavour goes GREEN") + tls = world.run("tls", everything) + wanted = {sid: ("CONTROL-PASS" if suite.BY_NAME[sid].kind == "control" else "GREEN") + for sid in everything} + wanted["S22"] = "FAIL" # the mock cannot report the negotiated group + ok &= judge_flavour("tls", tls, wanted) + section("part 2: the stock flavour goes RED") + stock = world.run("stock", everything) + wanted = {sid: ("CONTROL-PASS" if suite.BY_NAME[sid].kind == "control" else "RED") + for sid in everything} + ok &= judge_flavour("stock", stock, wanted) + try: + with check("--expect red is met by the stock run, and --expect green is not"): + red, problems = suite.expectation_met(list(stock.values()), "red") + green, _ = suite.expectation_met(list(stock.values()), "green") + if not red or green: + raise Failure(f"red met {red}, green met {green}: {problems[:3]}") + except Failure: + ok = False + section("part 3: each mutant turns its guard red") + for flavour, sids in (("bundle-accepts-all", ["S0", "S5"]), + ("release-noop", ["S0", "S19e", "S19e2"]), + ("group-zero", ["S0", "S2"]), + ("info-ff-claims", ["S0", "S19e", "S19e2b"])): + outcomes = world.run(flavour, sids) + ok &= judge_flavour(flavour, outcomes, {sid: "FAIL" for sid in sids[1:]}) + outcomes = world.run("abort-shortens", ["S0", "S19e"]) + ok &= judge_flavour("abort-shortens", outcomes, {"S19e": "FAIL"}) + if not args.quick: + ok &= part4(world) + ok &= part5(world) + ok &= part6(world) + if not args.quick: + ok &= part7(world) + finally: + world.close() + if ok: + suite_ok(SUITE, "GREEN with TLS, RED on stock, every mutant caught") + return 0 + suite_fail(SUITE, "see the checks above") + return 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tests/e2e/io/command_interface/net_tls_test.py b/tests/e2e/io/command_interface/net_tls_test.py new file mode 100644 index 000000000..052edabad --- /dev/null +++ b/tests/e2e/io/command_interface/net_tls_test.py @@ -0,0 +1,1626 @@ +#!/usr/bin/env python3 +# E2E: TLS sockets on the UCI network target ($21-$25): RED on stock firmware, GREEN with TLS. + +"""End-to-end check of the UCI network target's TLS commands ($21-$25). + +The contract is doc/uci_tls.md; this suite checks it. Every +scenario is RED on firmware without the TLS commands, with the one signature +`21,UNKNOWN COMMAND` to its first TLS command, and GREEN on firmware with +them. The exceptions are marked `control` (they pass on both, and say the +test setup itself works) and `measurement` (they only record a number). + +Tier 1 is the RED signature and the smoke test to run first: + S0 startup sweep (CLOSE 0..15) control + S1 capability: `03 23 FF`, 16 bytes RED 21 / GREEN v1 record + S20 plain TCP round trip control + S2 PIN echo to this machine, TLS 1.3, INFO for the handle + S23 hardened TLS 1.2 fallback (EMS bit, one of the six suites) + S5 a refused certificate: exactly `93,CERTIFICATE NOT TRUSTED: 0x00000008`, + and `96` for a wrong pin + S19e an ABORTed OPEN, then $25 (client deadlines; REST route only) + S30 BUNDLE to real hosts (internet_hosts.json) with an HTTP GET +Tier 2 is the other scenarios this machine can drive (see --list). +Oracles come from the server side (net_tls_fixture.py logs), never from the device's claim. + +The suite first SETS and reads back Command Interface, WiFi Enabled (one-way on the U64: +never written back), SNTP Enable and Turbo Control Off, resets the C64 and sweeps the route. +Every command has a client deadline (45 s for an open, 12 s otherwise), then ABORT and, +if $DF1C bit 2 stays set, a C64 reset: nothing waits forever. +Results: --results (default .net_tls_results/-/): run.json and wire.jsonl. +--expect red exits 0 exactly when every TLS scenario is RED and every control passed. +""" + +import argparse +import datetime +import hashlib +import json +import os +import socket +import ssl +import subprocess +import sys +import time +import traceback +from dataclasses import dataclass, field +from pathlib import Path +from collections.abc import Callable + +# The one stanza that puts the shared library on sys.path; see tests/lib/bootstrap.py. +sys.path.insert(0, str(next(p for p in Path(__file__).resolve().parents + if (p / "tests" / "lib").is_dir()) / "tests" / "lib")) +import bootstrap # noqa: E402,F401 +import cli # noqa: E402 +import targets # noqa: E402 +from api import UltimateApi # noqa: E402 +from report import ( # noqa: E402 + FAIL, OK, SKIP, Failure, check, check_fail, check_ok, check_skip, check_start, check_warn, detail, + format_exception, section, suite_fail, suite_ok, warn) +from uci import Uci, interface_present # noqa: E402 +from uci_native import NativeUci # noqa: E402 + +sys.path.insert(0, bootstrap.directory("e2e", "io", "command_interface")) +import net_tls_fixture as fx # noqa: E402 +from net_tls_proto import ( # noqa: E402 + BOUND_OPEN, CA_CHUNK, GROUPS, HANDLE_RANGE, INFO_CAPABILITY, + INFO_CAPABILITY_BYTES, INFO_HANDLE_BYTES, NET_CMD_TLS_INFO, NET_CMD_TLS_RELEASE, + OPEN_REPLY_BYTES, STATUS_CLOSE_UNOWNED, STATUS_HS_TIMEOUT, STATUS_INVALID_PARAMS, + STATUS_NO_CUSTOM_CA, STATUS_NO_DATA_GONE, STATUS_NO_DATA_IDLE, STATUS_NO_NOTIFY, STATUS_OK, + STATUS_OUT_OF_RANGE, STATUS_PEER_CLOSED, STATUS_PIN_MISMATCH, STATUS_TLS_IN_USE, + STATUS_UNKNOWN_COMMAND, STATUS_UNKNOWN_ROOT, TLS12, TLS12_SUITES, TLS13, TLS13_SUITES, + TLS_COMMANDS, TRUST_BUNDLE, TRUST_CUSTOM, TRUST_PIN, WRITE_MAX, Capability, HandleInfo, + Link, LinkLost, NativeLink, OpenReply, ReadReply, RestLink, Result, close_command, + info_command, open_tcp_command, open_tls_command, read_command, release_command, + status_code, trust_ca_command, write_command) + +SUITE = "net_tls_test" +HERE = Path(__file__).resolve().parent +DEFAULT_RESULTS = HERE / ".net_tls_results" +HOSTS_FILE = HERE / "internet_hosts.json" +HOSTS_ENV = "NET_TLS_INTERNET_HOSTS" + +# What the runner sets, and whether it puts it back afterwards. WiFi Enabled is +# one-way on the U64 (network_esp32.cc:134-136: the disable branch is commented +# out), so writing it back would record a restore that did not happen. +SETTINGS = ( + ("C64 and Cartridge Settings", "Command Interface", "Enabled", True), + ("WiFi settings", "WiFi Enabled", "Enabled", False), + ("Network Settings", "SNTP Enable", "Enabled", True), + ("U64 Specific Settings", "Turbo Control", "Off", True), +) +REQUIRED_SETTING = "Command Interface" +WIFI_SETTING = "WiFi Enabled" +# INFO $FF [4]: module, entropy, trusted time. How long the module and SNTP may +# take to come up after the settings above. +READY_BITS = 0x07 +READY_WAIT_SECONDS = 90.0 + +ECHO_BYTES = 4096 +PEER_STREAM_BYTES = 3000 +BIG_RECORD_BYTES = 16384 +READ_CHUNK = 892 +READ_BUDGET_SECONDS = 20.0 +SLOW_HANDSHAKE_SECONDS = 4.0 +ABORT_AFTER_SECONDS = 1.5 +HANDSHAKE_MS = 15.0 +HTTP_READ_BUDGET_SECONDS = 15.0 +RESAMPLE_AFTER_SECONDS = 30.0 +MAC_SAMPLES = 3 +# A name no resolver answers (RFC 6761), and an address nothing answers SYNs on +# (RFC 5737 TEST-NET-1, dropped rather than refused on most networks). +UNRESOLVABLE = "e2e-unresolvable.invalid" +# S32 stops here: with a 4 KB receive buffer the stall comes within tens of +# WRITEs, and each native WRITE is a body-carrying writemem. +S32_MAX_WRITES = 100 +BLACKHOLE = "192.0.2.1" + + +# -- the record -------------------------------------------------------------- + +@dataclass +class Scenario: + sid: str + name: str + tier: int + kind: str # "tls" (RED on stock), "control", "measurement" + oracle: str + fn: Callable + needs: tuple = () # "fixture", "internet", "abort" + default: bool = True + + +@dataclass +class Outcome: + scenario: Scenario + route: str + verdict: str = "not run" # PASS, FAIL, SKIP, N/A (not on this route), ERROR + signature: str = "" # GREEN, RED, FAIL, CONTROL-PASS, ... + reason: str = "" + first_tls_status: str | None = None + elapsed: float = 0.0 + evidence: dict = field(default_factory=dict) + + def as_dict(self) -> dict: + s = self.scenario + return {"sid": s.sid, "name": s.name, "tier": s.tier, "kind": s.kind, + "route": self.route, "oracle": s.oracle, "verdict": self.verdict, + "signature": self.signature, "reason": self.reason, + "first_tls_status": self.first_tls_status, + "elapsed": round(self.elapsed, 2), "evidence": self.evidence} + + +class Ctx: + """One route's view of the device, the fixture and the open scenario.""" + + def __init__(self, link: Link, args, pki, bind_ip: str | None, + reset_c64: Callable[[], Link] | None, wire: list[dict]) -> None: + self.wire = wire + self.link = link + link.log = wire + self.args = args + self.pki = pki + self.bind_ip = bind_ip + self._reset_c64 = reset_c64 + self.servers: list[fx.TlsServer] = [] + self.outcome: Outcome | None = None + + # -- commands ------------------------------------------------------------ + + def cmd(self, command: bytes, bound: float | None = None) -> Result: + result = self.link.command(command, bound) + o = self.outcome + if o is not None and len(command) >= 2 and command[1] in TLS_COMMANDS: + if o.first_tls_status is None: + o.first_tls_status = result.status.decode("latin-1") + if result.status == STATUS_UNKNOWN_COMMAND: + o.evidence.setdefault("unknown_command", []).append(command[:3].hex(" ")) + if result.aborted: + raise Failure(f"{command[:6].hex(' ')} gave no reply within its client deadline " + f"and was ABORTed after {result.elapsed:.1f}s") + return result + + def expect(self, result: Result, status: bytes, what: str) -> Result: + if result.status != status: + raise Failure(f"{what}: expected {status.decode()!r}, got {result.describe()}") + return result + + def info_ff(self) -> Capability: + r = self.cmd(info_command(INFO_CAPABILITY)) + self.expect(r, STATUS_OK, "TLS_INFO $FF") + if len(r.data) != INFO_CAPABILITY_BYTES: + raise Failure(f"TLS_INFO $FF answered {len(r.data)} bytes, not 16") + return Capability(r.data) + + def info(self, handle: int) -> HandleInfo: + r = self.cmd(info_command(handle)) + self.expect(r, STATUS_OK, f"TLS_INFO {handle}") + if len(r.data) != INFO_HANDLE_BYTES: + raise Failure(f"TLS_INFO {handle} answered {len(r.data)} bytes, not 48") + return HandleInfo(r.data) + + def open_tls(self, port: int, host: str, trust: int = TRUST_PIN, flags: int = 0, + name: str | None = None, pin: bytes | None = None) -> Result: + return self.cmd(open_tls_command(port, host, trust, flags, name, pin)) + + def expect_open(self, port: int, host: str, trust: int = TRUST_PIN, flags: int = 0, + name: str | None = None, pin: bytes | None = None) -> OpenReply: + r = self.open_tls(port, host, trust, flags, name, pin) + self.expect(r, STATUS_OK, "OPEN_TLS") + if len(r.data) != OPEN_REPLY_BYTES: + raise Failure(f"OPEN_TLS answered {len(r.data)} bytes, not 8: {r.data.hex(' ')}") + reply = OpenReply(r.data) + self.note("open", reply.as_dict()) + return reply + + def read(self, handle: int, maxlen: int = READ_CHUNK) -> ReadReply: + return ReadReply(self.cmd(read_command(handle, maxlen))) + + def read_until(self, handle: int, count: int, maxlens=(READ_CHUNK,), + budget: float = READ_BUDGET_SECONDS) -> tuple[bytes, ReadReply | None]: + """READ until `count` bytes or the stream ends; (bytes, the ending reply or None). + + `budget` is IDLE time: the clock restarts on every READ that brings at + least one byte. On the REST route every byte costs one REST call, so a + total-time budget would fail a healthy but slow transfer for the wrong + reason. A READ answering 00,OK with no bytes is not a valid READ answer + and fails at once, so the loop is always bounded. + """ + got = bytearray() + deadline = time.monotonic() + budget + index = 0 + while len(got) < count: + reply = self.read(handle, maxlens[index % len(maxlens)]) + index += 1 + if reply.result.ok: + if reply.header != len(reply.payload): + raise Failure(f"READ header {reply.header} but {len(reply.payload)} bytes") + if not reply.payload: + raise Failure("READ answered 00,OK with header $0000: the protocol has no " + "such answer (data is 1..maxlen; nothing yet is $FFFF + 02)") + got += reply.payload + deadline = time.monotonic() + budget + continue + if reply.header == 0xFFFF and reply.status == STATUS_NO_DATA_IDLE: + if time.monotonic() > deadline: + raise Failure(f"only {len(got)} of {count} bytes: no data for {budget:.0f}s") + time.sleep(0.05) + continue + return bytes(got), reply + return bytes(got), None + + def write(self, handle: int, data: bytes) -> None: + r = self.cmd(write_command(handle, data)) + self.expect(r, STATUS_OK, f"WRITE of {len(data)} bytes") + if r.data[:2] != len(data).to_bytes(2, "little"): + raise Failure(f"WRITE header {r.data[:2].hex(' ')}, expected {len(data)}") + + def close(self, handle: int) -> Result: + return self.cmd(close_command(handle)) + + def release(self) -> int: + r = self.cmd(release_command()) + self.expect(r, STATUS_OK, "TLS_RELEASE") + if len(r.data) != 1: + raise Failure(f"TLS_RELEASE answered {len(r.data)} bytes, not 1") + return r.data[0] + + def entries(self, wanted: int, what: str) -> Capability: + cap = self.info_ff() + if cap.entries != wanted: + raise Failure(f"{what}: INFO $FF [2] = {cap.entries}, expected {wanted}") + return cap + + def upload_ca(self, der: bytes) -> Result: + last = None + for offset in range(0, len(der), CA_CHUNK): + last = self.cmd(trust_ca_command(offset, len(der), der[offset:offset + CA_CHUNK])) + if not last.ok: + return last + return last + + def sweep(self) -> list[int]: + """The startup CLOSE sweep of 0..15; the numbers that were held.""" + held = [] + for handle in HANDLE_RANGE: + r = self.link.command(close_command(handle)) + if r.status == STATUS_OK: + held.append(handle) + elif r.status != STATUS_CLOSE_UNOWNED: + raise Failure(f"CLOSE {handle} in the sweep answered {r.describe()}") + return held + + def reset_c64(self) -> None: + if self._reset_c64 is None: + raise Failure("this route cannot reset the C64") + self.link = self._reset_c64() + self.link.log = self.wire + + # -- fixture ------------------------------------------------------------- + + def server(self, chain: str | None, behaviour: fx.Behaviour) -> fx.TlsServer: + if self.pki is None or self.bind_ip is None: + raise Skipped("no local TLS fixture on this run (see the fixture check)") + server = fx.TlsServer(self.bind_ip, self.pki.chains[chain] if chain else None, behaviour) + self.servers.append(server) + return server + + def note(self, key: str, value) -> None: + if self.outcome is not None: + self.outcome.evidence.setdefault(key, []) + self.outcome.evidence[key].append(value) + + def close_servers(self) -> None: + for server in self.servers: + if self.outcome is not None: + self.outcome.evidence.setdefault("server", []).append( + {"port": server.port, "connections": [c.as_dict() for c in server.logs]}) + server.close() + self.servers.clear() + + +class Skipped(Failure): + """The scenario could not run here. Counts AGAINST every verdict.""" + + +class NotOnRoute(Skipped): + """By design the scenario does not apply to this route (S19e/S19e2b native, S32 REST). + + The only skip a verdict may ignore; the run still needs TLS evidence elsewhere. + """ + + +def tls13_server() -> fx.Behaviour: + return fx.Behaviour() + + +def tls12_server(**kw) -> fx.Behaviour: + return fx.Behaviour(min_version=ssl.TLSVersion.TLSv1_2, max_version=ssl.TLSVersion.TLSv1_2, + ciphers="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:" + "ECDHE-ECDSA-CHACHA20-POLY1305", **kw) + + +def one_connection(server: fx.TlsServer, timeout: float = 15.0) -> fx.ConnLog: + logs = server.wait_connections(1, timeout) + if not logs: + raise Failure("the server saw no connection") + return logs[0] + + +def pin_of(ctx: Ctx, chain: str = "ecdsa") -> bytes: + return ctx.pki.chains[chain].spki_sha256 + + +def echo_round_trip(ctx: Ctx, handle: int, total: int, seed: int) -> bytes: + data = fx.payload(seed, total) + with check(f"{total} B echoed back byte exact, written in {WRITE_MAX} B WRITEs"): + got = bytearray() + for offset in range(0, total, WRITE_MAX): + ctx.write(handle, data[offset:offset + WRITE_MAX]) + part, end = ctx.read_until(handle, min(offset + WRITE_MAX, total) - len(got)) + got += part + if end is not None: + raise Failure(f"the stream ended early: {end.result.describe()}") + if bytes(got) != data: + raise Failure(f"echo differs (sha256 {hashlib.sha256(got).hexdigest()[:16]} vs " + f"{hashlib.sha256(data).hexdigest()[:16]})") + return data + + +def check_reply_bits(reply: OpenReply, version: int) -> None: + with check(f"OPEN reply: version 0x{version:04X}, a policy suite, a policy group, EMS bit"): + if reply.version != version: + raise Failure(f"version 0x{reply.version:04X}") + suites = TLS13_SUITES if version == TLS13 else TLS12_SUITES + if reply.suite not in suites: + raise Failure(f"suite 0x{reply.suite:04X} is not one of the policy suites") + if reply.group not in GROUPS: + raise Failure(f"group 0x{reply.group:04X} (0 is a FAIL in a GREEN run)") + ems = 1 if version == TLS12 else 0 + if reply.bits != ems: + raise Failure(f"byte 7 = 0x{reply.bits:02X}, expected 0x{ems:02X} (bit0 EMS)") + + +# -- Tier 1 ------------------------------------------------------------------ + +def s0_startup_sweep(ctx: Ctx) -> None: + if ctx.link.can_abort_in_flight: + with check("startup: $DF1D reads $C9/$49, $0C written, bit 2 back to 0 within 45 s"): + seconds = ctx.link.startup_abort() + detail(f"bit 2 cleared {seconds:.2f}s after the $0C") + else: + check_start("startup: $0C and the wait for bit 2") + check_skip("the 6502 agent starts from run_prg's reset, and writes no $0C itself") + with check("startup: CLOSE 0..15 each answers 00,OK or 12,ERROR ON CLOSE: 9"): + held = ctx.sweep() + ctx.note("swept", held) + detail(f"leftover handles closed: {held or 'none'}") + + +def s1_capability(ctx: Ctx) -> None: + with check("`03 23 FF` answers 00,OK with the 16-byte v1 record"): + cap = ctx.info_ff() + ctx.note("info_ff", cap.as_dict()) + detail(json.dumps(cap.as_dict())) + problems = [] + if cap.version != 1: + problems.append(f"[0] interface {cap.version}, not 1") + if cap.max_sessions != 2: + problems.append(f"[1] max sessions {cap.max_sessions}, not 2") + if cap.trust_modes != 0x07: + problems.append(f"[3] trust modes 0x{cap.trust_modes:02X}, not 07") + if cap.versions != 0x03: + problems.append(f"[5] versions 0x{cap.versions:02X}, not 03") + if cap.raw[15] != 0: + problems.append(f"[15] = {cap.raw[15]}, not 0") + if problems: + raise Failure("; ".join(problems)) + with check("the startup sweep left no entries: [2] = 0 and [14] = 0"): + if cap.entries or cap.unclaimed: + raise Failure(f"[2] = {cap.entries}, [14] = {cap.unclaimed}") + with check("ready bits match the configured state: module, entropy, time (0x07)"): + if cap.ready & READY_BITS != READY_BITS: + raise Failure(f"[4] = 0x{cap.ready:02X}: Wi-Fi and SNTP are set on, so b0-b2 are owed") + if cap.ready & 0x08: + raise Failure("[4] b3 (custom CA LOADED) is set after the startup reset") + with check("module version set and [9..11] = FF FF FF while b0 is set"): + major, minor = cap.module_version + if (major, minor) == (0, 0): + raise Failure("[6..8] = 0 with b0 set") + if cap.store_date != b"\xff\xff\xff": + raise Failure(f"[9..11] = {cap.store_date.hex(' ')}") + detail(f"module {major}.{minor}, block_max {cap.block_max_ms} ms") + if ctx.args.module_minor is not None and minor != ctx.args.module_minor: + raise Failure(f"module minor {minor}, expected {ctx.args.module_minor} (--module-minor)") + with check("`03 23 FF 00` (4 bytes) answers 81"): + ctx.expect(ctx.cmd(bytes([3, NET_CMD_TLS_INFO, 0xFF, 0])), STATUS_INVALID_PARAMS, "03 23 FF 00") + with check("`03 25` answers 1 byte, 0, 00,OK; `03 25 00` answers 81"): + if ctx.release() != 0: + raise Failure("$25 closed something with no OPEN before it") + ctx.expect(ctx.cmd(bytes([3, NET_CMD_TLS_RELEASE, 0])), STATUS_INVALID_PARAMS, "03 25 00") + with check("INFO on a handle that is not TLS answers 81 with no data"): + r = ctx.cmd(info_command(0x7F)) + ctx.expect(r, STATUS_INVALID_PARAMS, "03 23 7F") + + +def s20_plain_tcp(ctx: Ctx) -> None: + """Control: OPEN_TCP / WRITE / READ / CLOSE to this machine, on any firmware.""" + if ctx.bind_ip is None: + raise Skipped("this machine is not reachable from the device") + listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + listener.bind((ctx.bind_ip, 0)) + listener.listen(1) + listener.settimeout(10) + try: + with check("OPEN_TCP to this machine answers a handle"): + r = ctx.cmd(open_tcp_command(ctx.bind_ip, listener.getsockname()[1])) + ctx.expect(r, STATUS_OK, "OPEN_TCP") + handle = r.data[0] + conn, _ = listener.accept() + try: + with check("a 100-byte WRITE arrives, and 100 bytes sent back are READ"): + data = fx.payload(20, 100) + ctx.write(handle, data) + conn.settimeout(5) + got = b"" + while len(got) < 100: + got += conn.recv(100) + if got != data: + raise Failure("the bytes that arrived differ") + conn.sendall(data) + back, end = ctx.read_until(handle, 100) + if back != data: + raise Failure(f"READ gave {len(back)} bytes, not the 100 sent ({end})") + with check("CLOSE answers 00,OK"): + ctx.expect(ctx.close(handle), STATUS_OK, "CLOSE") + finally: + conn.close() + finally: + listener.close() + + +def s2_pin_echo(ctx: Ctx) -> None: + server = ctx.server("ecdsa", tls13_server()) + with check("OPEN_TLS PIN to this machine's IP (no name) answers 8 bytes, 00,OK"): + reply = ctx.expect_open(server.port, ctx.bind_ip, TRUST_PIN, pin=pin_of(ctx)) + check_reply_bits(reply, TLS13) + with check("INFO $FF: [2] = 1, [14] = 1 (the new entry is unclaimed until the next command)"): + cap = ctx.info_ff() + if (cap.entries, cap.unclaimed) != (1, 1): + raise Failure(f"[2] = {cap.entries}, [14] = {cap.unclaimed}") + with check("INFO for the handle: 48 bytes, the same version/suite/group, trust 2, SPKI = pin"): + info = ctx.info(reply.handle) + ctx.note("info", info.as_dict()) + if (info.version, info.suite, info.group) != (reply.version, reply.suite, reply.group): + raise Failure(f"INFO {info.as_dict()} differs from the OPEN reply {reply.as_dict()}") + if info.trust != TRUST_PIN or info.spki_sha256 != pin_of(ctx): + raise Failure(f"trust {info.trust}, SPKI {info.spki_sha256.hex()[:16]}") + if info.group == 0: + raise Failure("INFO group 0") + sent = echo_round_trip(ctx, reply.handle, ECHO_BYTES, seed=2) + with check("CLOSE answers 00,OK; INFO $FF [2] = 0 afterwards"): + ctx.expect(ctx.close(reply.handle), STATUS_OK, "CLOSE") + ctx.entries(0, "after CLOSE") + with check("server: TLS 1.3, no SNI (an IPv4 host, no name), sha256 of what it got, close_notify"): + log = one_connection(server) + ctx.note("conn", log.as_dict()) + if log.version != "TLSv1.3": + raise Failure(f"server negotiated {log.version}") + if log.sni is not None: + raise Failure(f"SNI {log.sni!r} was sent for an IP literal") + if hashlib.sha256(log.received).digest() != hashlib.sha256(sent).digest(): + raise Failure(f"server received {len(log.received)} bytes that differ from the payload") + if log.peer_end != "close_notify": + raise Failure(f"the client ended with {log.peer_end}, not close_notify") + + +def s23_tls12(ctx: Ctx) -> None: + server = ctx.server("ecdsa", tls12_server()) + with check("OPEN_TLS PIN, default flags, to a TLS 1.2-only server answers 00,OK"): + reply = ctx.expect_open(server.port, ctx.bind_ip, TRUST_PIN, pin=pin_of(ctx)) + check_reply_bits(reply, TLS12) + sent = echo_round_trip(ctx, reply.handle, WRITE_MAX, seed=23) + with check("CLOSE 00,OK; server log: TLSv1.2, a hardened suite, the bytes, close_notify"): + ctx.expect(ctx.close(reply.handle), STATUS_OK, "CLOSE") + log = one_connection(server) + ctx.note("conn", log.as_dict()) + if log.version != "TLSv1.2" or not (log.cipher or "").startswith("ECDHE-"): + raise Failure(f"server: {log.version} {log.cipher}") + if bytes(log.received) != sent or log.peer_end != "close_notify": + raise Failure(f"server got {len(log.received)} B, ended by {log.peer_end}") + + +def s5_refused_cert(ctx: Ctx) -> None: + server = ctx.server("ecdsa", tls13_server()) + with check("BUNDLE to a local-PKI server answers exactly " + f"{STATUS_UNKNOWN_ROOT.decode()!r} with no data"): + r = ctx.open_tls(server.port, ctx.bind_ip, TRUST_BUNDLE, name=fx.FIXTURE_NAME) + ctx.expect(r, STATUS_UNKNOWN_ROOT, "OPEN_TLS BUNDLE") + if r.data: + raise Failure(f"a refused OPEN answered {len(r.data)} data bytes") + with check("PIN with a key that is not the server's answers 96 with no data"): + r = ctx.open_tls(server.port, ctx.bind_ip, TRUST_PIN, pin=hashlib.sha256(b"x").digest()) + ctx.expect(r, STATUS_PIN_MISMATCH, "OPEN_TLS PIN") + with check("nothing leaked: INFO $FF [2] = 0; the server received 0 application bytes"): + ctx.entries(0, "after two refusals") + logs = server.wait_connections(2) + for log in logs: + ctx.note("conn", log.as_dict()) + if any(log.received for log in logs): + raise Failure("the server received application data on a refused connection") + if ctx.args.strict_sni and logs and logs[0].sni != fx.FIXTURE_NAME: + raise Failure(f"BUNDLE sent SNI {logs[0].sni!r}, expected {fx.FIXTURE_NAME!r}") + + +def s19e_abort_release(ctx: Ctx) -> None: + if not ctx.link.can_abort_in_flight: + raise NotOnRoute(f"the {ctx.link.name} route cannot ABORT a command in flight (REST only)") + with check("TLS_INFO $FF answers before the OPEN (and claims no session)"): + ctx.entries(0, "before the OPEN") + server = ctx.server("ecdsa", fx.Behaviour(delay_handshake=SLOW_HANDSHAKE_SECONDS)) + command = open_tls_command(server.port, ctx.bind_ip, TRUST_PIN, pin=pin_of(ctx)) + with check(f"ABORT {ABORT_AFTER_SECONDS}s into an OPEN_TLS: bit 2 clears only when the " + "command ends (ABORT never shortens it), within the client deadline"): + aborted = ctx.link.abort_in_flight(command, ABORT_AFTER_SECONDS) + ctx.note("abort", {"busy_at_abort": aborted.busy_at_abort, + "bit2_cleared_after": round(aborted.bit2_cleared_after, 2)}) + if not aborted.busy_at_abort: + raise Failure("the OPEN had already answered when the ABORT was written, so this " + "run did not test an ABORT in PROCESSING") + if aborted.bit2_cleared_after > BOUND_OPEN + 12: + raise Failure(f"bit 2 cleared {aborted.bit2_cleared_after:.1f}s after the PUSH") + # The server holds its answer SLOW_HANDSHAKE_SECONDS, so an OPEN that + # ran to its end cannot clear bit 2 sooner. + if aborted.bit2_cleared_after < SLOW_HANDSHAKE_SECONDS - 0.5: + raise Failure(f"bit 2 cleared {aborted.bit2_cleared_after:.1f}s after the PUSH, before " + f"the server's {SLOW_HANDSHAKE_SECONDS:.0f}s delay: the ABORT shortened it") + with check("`03 23 FF` (allowed in between): [2] = 1 and [14] = 1, the session is unclaimed"): + cap = ctx.info_ff() + if (cap.entries, cap.unclaimed) != (1, 1): + raise Failure(f"[2] = {cap.entries}, [14] = {cap.unclaimed}") + with check("`03 25` as the next command closes it: 1 byte, 01, 00,OK"): + if (closed := ctx.release()) != 1: + raise Failure(f"$25 closed {closed}") + with check("a second `03 25` answers 0 (idempotent); INFO $FF [2] = 0, [14] = 0"): + if (closed := ctx.release()) != 0: + raise Failure(f"$25 closed {closed} the second time") + cap = ctx.info_ff() + if cap.entries or cap.unclaimed: + raise Failure(f"[2] = {cap.entries}, [14] = {cap.unclaimed}") + with check("the server saw the handshake complete, then close_notify + FIN from the device"): + log = one_connection(server, timeout=20) + ctx.note("conn", log.as_dict()) + if log.version != "TLSv1.3" or log.peer_end != "close_notify": + raise Failure(f"server: {log.version}, ended by {log.peer_end}") + + +# -- S30: real hosts ----------------------------------------------------------- + +@dataclass +class Host: + host: str + hid: str = "" + ip: str | None = None # pinned, for the self-test's stand-ins + port: int = 443 + record: dict = field(default_factory=dict) + + +def load_hosts() -> list[Host]: + override = os.environ.get(HOSTS_ENV) + if override: + warn(f"{HOSTS_ENV} replaces the built-in hosts for this run: {override}") + return [Host(h.strip(), f"X{i + 1}") for i, h in enumerate(override.split(",")) if h.strip()] + entries = json.loads(HOSTS_FILE.read_text())["hosts"] + return [Host(e["host"], e["id"], record=e) for e in entries] + + +def mac_context(cafile: str | None) -> tuple[ssl.SSLContext, str]: + ctx = ssl.create_default_context(cafile=cafile) + if cafile: + return ctx, f"cafile {cafile}" + if ctx.cert_store_stats().get("x509_ca", 0) == 0: + try: + import certifi # noqa: PLC0415 - only when the default store is empty + return ssl.create_default_context(cafile=certifi.where()), "certifi" + except ImportError: + pass + return ctx, "the system default store" + + +def mac_view(host: Host, address: str, cafile: str | None) -> dict: + """One verified handshake from this machine to address:port with SNI = host.""" + ctx, store = mac_context(cafile) + with socket.create_connection((address, host.port), timeout=10) as raw: + with ctx.wrap_socket(raw, server_hostname=host.host) as tls: + der = tls.getpeercert(binary_form=True) + chain = [] + getter = getattr(tls, "get_verified_chain", None) + if getter is not None: + for cert in getter(): + chain.append(cert if isinstance(cert, bytes) else cert.public_bytes(1)) + return {"version": tls.version(), "spki": fx.spki_sha256(der).hex(), + "store": store, "chain": [describe_cert(c) for c in chain]} + + +def describe_cert(der: bytes) -> dict: + cert = fx.x509.load_der_x509_certificate(der) + return {"subject": cert.subject.rfc4514_string(), "issuer": cert.issuer.rfc4514_string(), + "sha256": hashlib.sha256(der).hexdigest()} + + +def s30_real_hosts(ctx: Ctx) -> None: + hosts = ctx.args.hosts if ctx.args.hosts is not None else load_hosts() + failures = [] + for host in hosts: + line = f"{host.hid} {host.host}" + try: + verdict = one_real_host(ctx, host) + detail(f"PASS {line}: {verdict}") + ctx.note("hosts", {"host": host.host, "verdict": "PASS", "detail": verdict}) + except Skipped as exc: + failures.append(f"{line}: {exc}") + ctx.note("hosts", {"host": host.host, "verdict": "UNREACHABLE", "detail": str(exc)}) + except Failure as exc: + failures.append(f"{line}: {exc}") + ctx.note("hosts", {"host": host.host, "verdict": "FAIL", "detail": str(exc)}) + with check("S30: INFO $FF [2] = 0 after the hosts"): + ctx.entries(0, "after S30") + if failures: + raise Failure(" | ".join(failures)) + + +def one_real_host(ctx: Ctx, host: Host) -> str: + with check(f"{host.host}: step 1, this machine resolves it and verifies a TLS handshake"): + try: + address = host.ip or socket.getaddrinfo(host.host, host.port, socket.AF_INET)[0][4][0] + except OSError as exc: + raise Skipped(f"FAIL internet unreachable: host: dns {host.host}: {exc}") from exc + try: + first = mac_view(host, address, ctx.args.mac_cafile) + except ssl.SSLError as exc: + raise Skipped(f"FAIL internet path failed TLS verification (this machine): " + f"{host.host} at {address}: {exc}; possible causes: a captive portal, TLS " + f"interception, or a broken or misconfigured host; step 1 cannot " + f"tell which") from exc + except OSError as exc: + raise Skipped(f"FAIL internet unreachable: host: connect {host.host}: {exc}") from exc + detail(f"{address}, {first['version']}, leaf SPKI {first['spki'][:16]}, via {first['store']}") + with check(f"{host.host}: step 2, the device's OPEN_TCP to the name and to {address}"): + for target in (host.host, address): + r = ctx.cmd(open_tcp_command(target, host.port)) + if not r.ok: + raise Skipped(f"FAIL internet unreachable: device: OPEN_TCP {target} " + f"{r.status.decode('latin-1')}") + ctx.expect(ctx.close(r.data[0]), STATUS_OK, "CLOSE") + with check(f"{host.host}: step 3, OPEN_TLS BUNDLE to {address} with name {host.host}"): + r = ctx.open_tls(host.port, address, TRUST_BUNDLE, name=host.host) + if not r.ok: + chain = "; ".join(f"{c['subject']} <- {c['issuer']}" for c in first["chain"]) + raise Failure(f"FAIL {host.host}: {r.status.decode('latin-1')} (this machine's chain: " + f"{chain or 'not available'})") + reply = OpenReply(r.data) + handle = reply.handle + info = ctx.info(handle) + gone = False + try: + with check(f"{host.host}: step 4, version/group policy, " + f"leaf SPKI among this machine's view"): + samples = {first["spki"]} + for _ in range(MAC_SAMPLES - 1): + samples.add(mac_view(host, address, ctx.args.mac_cafile)["spki"]) + if info.version == TLS12 and (info.suite not in TLS12_SUITES or not info.bits & 1): + raise Failure(f"1.2 without the hardened rules: {info.as_dict()}") + if info.version not in (TLS13, TLS12): + raise Failure(f"INFO version 0x{info.version:04X}") + if info.group not in GROUPS: + raise Failure(f"INFO group 0x{info.group:04X}") + if info.spki_sha256.hex() not in samples: + time.sleep(RESAMPLE_AFTER_SECONDS if ctx.args.hosts is None else 0) + samples.add(mac_view(host, address, ctx.args.mac_cafile)["spki"]) + if info.spki_sha256.hex() not in samples: + raise Failure(f"leaf key differs from this machine's view (same IP, same " + f"offer): device {info.spki_sha256.hex()[:16]}, this machine " + f"{sorted(s[:16] for s in samples)}") + with check(f"{host.host}: step 5, an HTTP GET over the session starts with HTTP/1."): + request = (f"GET / HTTP/1.1\r\nHost: {host.host}\r\nUser-Agent: u64-e2e\r\n" + f"Connection: close\r\n\r\n").encode("ascii") + ctx.write(handle, request) + got = bytearray() + deadline = time.monotonic() + HTTP_READ_BUDGET_SECONDS + while b"\r\n" not in got: + reply_r = ctx.read(handle, 512) + if reply_r.result.ok: + got += reply_r.payload + continue + if reply_r.gone: + gone = True + break + if reply_r.status != STATUS_NO_DATA_IDLE: + raise Failure(f"READ answered {reply_r.result.describe()}") + if time.monotonic() > deadline: + raise Failure("no status line within 15 s") + time.sleep(0.05) + status_line = bytes(got).split(b"\r\n")[0] + if not status_line.startswith(b"HTTP/1."): + raise Failure(f"the response starts {bytes(got[:40])!r}") + detail(f"{status_line.decode('latin-1')}, TLS 0x{info.version:04X}, " + f"group {GROUPS[info.group]}, handshake {info.handshake_ms} ms") + finally: + if not gone: + ctx.close(handle) + return (f"0x{info.version:04X} suite 0x{info.suite:04X} group {GROUPS.get(info.group)} " + f"handshake {info.handshake_ms} ms, {status_line.decode('latin-1')}") + + +# -- Tier 2 ------------------------------------------------------------------ + +def s6_peer_close(ctx: Ctx, then: str = "close_notify") -> None: + data = fx.payload(6, PEER_STREAM_BYTES) + server = ctx.server("ecdsa", fx.Behaviour(send=data, then=then)) + end_status = STATUS_PEER_CLOSED if then == "close_notify" else STATUS_NO_NOTIFY + with check(f"all {PEER_STREAM_BYTES} B delivered BEFORE $0000 + {end_status.decode()!r}"): + reply = ctx.expect_open(server.port, ctx.bind_ip, TRUST_PIN, pin=pin_of(ctx)) + got, end = ctx.read_until(reply.handle, PEER_STREAM_BYTES + 1) + if got != data: + raise Failure(f"{len(got)} of {PEER_STREAM_BYTES} bytes, or different bytes") + if end is None or end.header != 0 or end.status != end_status: + raise Failure(f"the stream ended with {end.result.describe() if end else 'nothing'}") + with check("the handle is GONE: a CLOSE answers 12,ERROR ON CLOSE: 9; INFO [2] = 0"): + ctx.expect(ctx.close(reply.handle), STATUS_CLOSE_UNOWNED, "CLOSE after the end") + ctx.entries(0, "after the end") + + +def s7_truncation(ctx: Ctx) -> None: + s6_peer_close(ctx, then="fin") + + +def s7c_rst_handshake(ctx: Ctx) -> None: + server = ctx.server(None, fx.Behaviour(rst_after_client_hello=True)) + with check("an RST after the ClientHello: `13,TLS HANDSHAKE FAILED: PEER RESET: 104`"): + r = ctx.open_tls(server.port, ctx.bind_ip, TRUST_PIN, pin=pin_of(ctx)) + ctx.expect(r, b"13,TLS HANDSHAKE FAILED: PEER RESET: 104", "OPEN_TLS") + ctx.entries(0, "after the reset") + + +def s10_handshake_timeout(ctx: Ctx) -> None: + server = ctx.server(None, fx.Behaviour(stall=True)) + with check("a server that never answers: 15 within HANDSHAKE_MS + 2 s; nothing leaked"): + r = ctx.open_tls(server.port, ctx.bind_ip, TRUST_PIN, pin=pin_of(ctx)) + ctx.expect(r, STATUS_HS_TIMEOUT, "OPEN_TLS") + if r.elapsed > HANDSHAKE_MS + 2 + 1: + raise Failure(f"15 after {r.elapsed:.1f}s") + ctx.entries(0, "after the timeout") + + +def s11_cap(ctx: Ctx) -> None: + server = ctx.server("ecdsa", tls13_server()) + handles = [] + try: + with check("two OPENs succeed, the third answers 91; after one CLOSE an OPEN works"): + handles.append(ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)).handle) + handles.append(ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)).handle) + ctx.expect(ctx.open_tls(server.port, ctx.bind_ip, pin=pin_of(ctx)), + STATUS_TLS_IN_USE, "third OPEN") + ctx.expect(ctx.close(handles.pop()), STATUS_OK, "CLOSE") + handles.append(ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)).handle) + finally: + for handle in handles: + ctx.close(handle) + ctx.entries(0, "after the cap") + + +def s12_open_close(ctx: Ctx) -> None: + server = ctx.server("ecdsa", tls13_server()) + with check("20 x (OPEN PIN, CLOSE): every one 00,OK, INFO [2] = 0 after"): + for _ in range(20): + handle = ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)).handle + ctx.expect(ctx.close(handle), STATUS_OK, "CLOSE") + cap = ctx.entries(0, "after 20 cycles") + detail(f"module block_max {cap.block_max_ms} ms (heap is not exported over UCI)") + + +def s13_tickets_big_record(ctx: Ctx) -> None: + data = fx.payload(13, BIG_RECORD_BYTES) + server = ctx.server("ecdsa", fx.Behaviour(num_tickets=10, send=data, then="echo")) + reply = ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)) + try: + with check("10 tickets, then one 16 KB record read with maxlen 1, 100, 893, 894, 1472"): + got, end = ctx.read_until(reply.handle, BIG_RECORD_BYTES, + maxlens=(1, 100, 893, 894, 1472), budget=120) + if got != data: + raise Failure(f"{len(got)} bytes, or different bytes ({end})") + echo_round_trip(ctx, reply.handle, 100, seed=131) + finally: + ctx.close(reply.handle) + + +def s3_custom_ca(ctx: Ctx) -> None: + with check("clear the CA (`03 22 00 00 00 00`) answers 00,OK, b3 clear"): + ctx.expect(ctx.cmd(trust_ca_command(0, 0, b"")), STATUS_OK, "clear") + if ctx.info_ff().ready & 0x08: + raise Failure("b3 still set after the clear") + with check("CUSTOM with nothing loaded answers 97,NO CUSTOM CA"): + ctx.expect(ctx.open_tls(1, ctx.bind_ip, TRUST_CUSTOM, name=fx.FIXTURE_NAME), + STATUS_NO_CUSTOM_CA, "OPEN CUSTOM") + with check(f"the test root ({len(ctx.pki.root_der)} B DER) uploads in chunks: 00,OK, b3 set"): + ctx.expect(ctx.upload_ca(ctx.pki.root_der), STATUS_OK, "final chunk") + if not ctx.info_ff().ready & 0x08: + raise Failure("b3 clear after the upload") + for chain in ("ecdsa", "rsa"): + server = ctx.server(chain, tls13_server()) + with check(f"CUSTOM {chain}: OPEN 00,OK; INFO SPKI = the server leaf's; echo"): + reply = ctx.expect_open(server.port, ctx.bind_ip, TRUST_CUSTOM, name=fx.FIXTURE_NAME) + info = ctx.info(reply.handle) + if info.spki_sha256 != pin_of(ctx, chain): + raise Failure("INFO SPKI is not the leaf this machine served") + echo_round_trip(ctx, reply.handle, 500, seed=3) + ctx.expect(ctx.close(reply.handle), STATUS_OK, "CLOSE") + for chain, prefix in (("wrong", b"94,"), ("expired", b"95,"), ("future", b"95,"), + ("unknown", b"93,")): + server = ctx.server(chain, tls13_server()) + with check(f"CUSTOM must-fail {chain}: {prefix.decode()} with no data, nothing leaked"): + r = ctx.open_tls(server.port, ctx.bind_ip, TRUST_CUSTOM, name=fx.FIXTURE_NAME) + if not r.status.startswith(prefix) or r.data: + raise Failure(r.describe()) + ctx.entries(0, "after the must-fails") + ctx.cmd(trust_ca_command(0, 0, b"")) + + +def s14_reset_cleanup(ctx: Ctx) -> None: + server = ctx.server("ecdsa", fx.Behaviour(then="hold")) + with check("two sessions and a LOADED CA, then a C64 reset"): + ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)) + ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)) + ctx.expect(ctx.upload_ca(ctx.pki.root_der), STATUS_OK, "upload") + ctx.reset_c64() + with check("the server sees both TCP connections end; INFO [2] = 0, b3 clear"): + logs = server.wait_connections(2, timeout=10) + ends = [log.peer_end for log in logs] + if len(logs) != 2 or "open" in ends: + raise Failure(f"connection ends seen by the server: {ends}") + cap = ctx.info_ff() + if cap.entries or cap.ready & 0x08: + raise Failure(f"[2] = {cap.entries}, [4] = 0x{cap.ready:02X}") + with check("OPEN CUSTOM after the reset answers 97,NO CUSTOM CA"): + ctx.expect(ctx.open_tls(server.port, ctx.bind_ip, TRUST_CUSTOM, name=fx.FIXTURE_NAME), + STATUS_NO_CUSTOM_CA, "OPEN CUSTOM") + + +def s19_params(ctx: Ctx) -> None: + server = ctx.server("ecdsa", tls13_server()) + port, ip, pin = server.port, ctx.bind_ip, pin_of(ctx) + head = bytes([3, 0x21, port & 0xFF, port >> 8]) + cases = [ + ("trust 3", head + bytes([3, 0]) + ip.encode(), STATUS_OUT_OF_RANGE), + ("flags $02", head + bytes([2, 2]) + pin + ip.encode(), STATUS_OUT_OF_RANGE), + ("flags $80", head + bytes([2, 0x80]) + pin + ip.encode(), STATUS_OUT_OF_RANGE), + ("all-zero pin", head + bytes([2, 0]) + bytes(32) + ip.encode(), STATUS_OUT_OF_RANGE), + ("empty host", head + bytes([2, 0]) + pin, STATUS_INVALID_PARAMS), + ("host 00 00", head + bytes([2, 0]) + pin + ip.encode() + b"\0\0", STATUS_INVALID_PARAMS), + ("254-byte host", head + bytes([2, 0]) + pin + b"a" * 254, STATUS_INVALID_PARAMS), + ("short pin", head + bytes([2, 0]) + pin[:20], STATUS_INVALID_PARAMS), + ("BUNDLE, IPv4 host, no name", head + bytes([0, 0]) + ip.encode(), STATUS_INVALID_PARAMS), + ("BUNDLE, explicit IPv4 name", head + bytes([0, 0]) + b"x.test\x00" + ip.encode(), + STATUS_INVALID_PARAMS), + ("BUNDLE, host 127.1", head + bytes([0, 0]) + b"127.1", STATUS_INVALID_PARAMS), + ("INFO, 2 bytes", bytes([3, 0x23]), STATUS_INVALID_PARAMS), + ("INFO, 4 bytes", bytes([3, 0x23, 0xFF, 0x00]), STATUS_INVALID_PARAMS), + ] + for label, command, expected in cases: + with check(f"{label} -> {expected.decode()}"): + r = ctx.cmd(command) + ctx.expect(r, expected, label) + if r.data: + raise Failure(f"{len(r.data)} data bytes with a refusal") + with check("flags $01 (REQUIRE_TLS13) is accepted, and `host 00` is a host with no name"): + r = ctx.cmd(head + bytes([2, 1]) + pin + ip.encode() + b"\0") + ctx.expect(r, STATUS_OK, "flags $01") + handle = r.data[0] + try: + with check("READ maxlen 0 and 1473 on a TLS handle -> 82"): + ctx.expect(ctx.cmd(read_command(handle, 0)), STATUS_OUT_OF_RANGE, "maxlen 0") + ctx.expect(ctx.cmd(read_command(handle, 1473)), STATUS_OUT_OF_RANGE, "maxlen 1473") + finally: + ctx.close(handle) + with check("a closed port -> 11, an unresolvable host -> 84"): + probe = socket.socket() + probe.bind((ip, 0)) + closed_port = probe.getsockname()[1] + probe.close() + r = ctx.open_tls(closed_port, ip, TRUST_PIN, pin=pin) + if status_code(r.status) != 11: + raise Failure(f"closed port: {r.describe()}") + r = ctx.open_tls(443, UNRESOLVABLE, TRUST_PIN, pin=pin) + if status_code(r.status) != 84: + raise Failure(f"unresolvable: {r.describe()}") + ctx.entries(0, "after the parameter cases") + + +def s19e2_release_spares_claimed(ctx: Ctx) -> None: + server = ctx.server("ecdsa", tls13_server()) + a = ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)).handle + try: + with check("READ on A (claims it), OPEN B (unclaimed), `03 25` -> 1"): + ctx.read(a, 16) + b = ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)).handle + if (closed := ctx.release()) != 1: + raise Failure(f"$25 closed {closed}") + with check("A still echoes; a READ on B's number -> $FFFF + 02,NO DATA: 9 (S19e2c)"): + echo_round_trip(ctx, a, 64, seed=192) + r = ctx.read(b, 16) + if r.header != 0xFFFF or r.status != STATUS_NO_DATA_GONE: + raise Failure(f"READ {b}: {r.result.describe()}") + finally: + ctx.close(a) + ctx.entries(0, "after S19e2") + + +def s19e2b_info_does_not_claim(ctx: Ctx) -> None: + if not ctx.link.can_abort_in_flight: + raise NotOnRoute(f"the {ctx.link.name} route cannot ABORT a command in flight (REST only)") + ctx.entries(0, "before the OPENs") + fast = ctx.server("ecdsa", tls13_server()) + slow = ctx.server("ecdsa", fx.Behaviour(delay_handshake=SLOW_HANDSHAKE_SECONDS)) + a = ctx.expect_open(fast.port, ctx.bind_ip, pin=pin_of(ctx)).handle + try: + with check("OPEN A, accept it, unused; ABORTed OPEN B; `03 23 FF` [14] = 1; $25 -> 1"): + ctx.link.abort_in_flight(open_tls_command(slow.port, ctx.bind_ip, TRUST_PIN, + pin=pin_of(ctx)), ABORT_AFTER_SECONDS) + cap = ctx.info_ff() + if (cap.entries, cap.unclaimed) != (2, 1): + raise Failure(f"[2] = {cap.entries}, [14] = {cap.unclaimed}") + if (closed := ctx.release()) != 1: + raise Failure(f"$25 closed {closed}") + with check("A still echoes"): + echo_round_trip(ctx, a, 64, seed=193) + finally: + ctx.close(a) + + +def s22_groups(ctx: Ctx) -> None: + for curve, group in ((None, 0x001D), ("prime256v1", 0x0017)): + server = ctx.server("ecdsa", fx.Behaviour(ecdh_curve=curve)) + label = "a default 1.3 server" if curve is None else "a P-256-only server (HRR)" + with check(f"{label}: OPEN reply version 0x0304, group 0x{group:04X}"): + reply = ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)) + ctx.close(reply.handle) + if (reply.version, reply.group) != (TLS13, group): + raise Failure(json.dumps(reply.as_dict())) + + +def s24_require13(ctx: Ctx) -> None: + server = ctx.server("ecdsa", tls12_server()) + with check("REQUIRE_TLS13 to a 1.2-only server: 14 with 70, or 18 with 0x0303 (recorded)"): + r = ctx.open_tls(server.port, ctx.bind_ip, TRUST_PIN, flags=1, pin=pin_of(ctx)) + if r.status not in (b"14,TLS ALERT RECEIVED: 70", b"18,TLS VERSION REFUSED: 0x0303"): + raise Failure(r.describe()) + ctx.note("variant", r.status.decode()) + ctx.entries(0, "after the refusal") + + +def s18_block_max(ctx: Ctx) -> None: + server = ctx.server("ecdsa", tls13_server()) + with check("after a handshake, INFO module_block_max_ms < 50 " + "(it is the longest the module's dispatcher blocked since boot)"): + handle = ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)).handle + ctx.close(handle) + cap = ctx.info_ff() + ctx.note("block_max_ms", cap.block_max_ms) + if cap.block_max_ms >= 50: + raise Failure(f"block_max {cap.block_max_ms} ms") + + +def s32_write_stall(ctx: Ctx) -> None: + """S32: a WRITE stall, and the CLOSE time measured on the stalled socket.""" + if ctx.link.name == "rest": + raise NotOnRoute("hundreds of 892-B WRITEs cost a REST call per byte; run it native") + server = ctx.server("ecdsa", fx.Behaviour(then="stall", rcvbuf=4096)) + reply = ctx.expect_open(server.port, ctx.bind_ip, pin=pin_of(ctx)) + chunk = fx.payload(32, WRITE_MAX) + with check("WRITE until TCP is full: FFFF + 12 or 17, sticky; never a partial count"): + for count in range(1, S32_MAX_WRITES + 1): + r = ctx.cmd(write_command(reply.handle, chunk)) + if r.ok: + if r.data[:2] != WRITE_MAX.to_bytes(2, "little"): + raise Failure(f"WRITE {count}: partial count {r.data[:2].hex(' ')}") + continue + ctx.note("stall", {"writes_ok": count - 1, "status": r.status.decode("latin-1"), + "elapsed": round(r.elapsed, 2)}) + if r.data[:2] != b"\xff\xff" or status_code(r.status) not in (12, 17): + raise Failure(f"WRITE {count}: {r.describe()}") + again = ctx.cmd(write_command(reply.handle, b"x")) + if again.status != r.status: + raise Failure(f"not sticky: then {again.describe()}") + break + else: + raise Failure(f"{S32_MAX_WRITES} WRITEs never stalled") + with check("CLOSE on the stalled TLS socket answers 00,OK within 12 s (measured)"): + r = ctx.close(reply.handle) + ctx.note("close_elapsed", round(r.elapsed, 3)) + ctx.expect(r, STATUS_OK, "CLOSE") + detail(f"CLOSE took {r.elapsed:.2f}s (expected: about 1 s at most, then RST)") + + +def s34_big_curves(ctx: Ctx) -> None: + """Measurement: P-384 / P-521 under 1.3 and 1.2, CUSTOM (the TLS-task stack case).""" + ctx.expect(ctx.cmd(trust_ca_command(0, 0, b"")), STATUS_OK, "clear") + ctx.expect(ctx.upload_ca(ctx.pki.root_der), STATUS_OK, "upload") + for curve, group in (("secp384r1", 0x0018), ("secp521r1", 0x0019)): + for label, behaviour in (("1.3", fx.Behaviour(ecdh_curve=curve)), + ("1.2", tls12_server(ecdh_curve=curve))): + server = ctx.server("ecdsa", behaviour) + with check(f"CUSTOM, TLS {label}, {curve}: OPEN 00,OK, group 0x{group:04X}"): + reply = ctx.expect_open(server.port, ctx.bind_ip, TRUST_CUSTOM, + name=fx.FIXTURE_NAME) + info = ctx.info(reply.handle) + ctx.close(reply.handle) + cap = ctx.info_ff() + ctx.note("timing", {"curve": curve, "tls": label, "handshake_ms": info.handshake_ms, + "block_max_ms": cap.block_max_ms}) + detail(f"handshake {info.handshake_ms} ms, block_max {cap.block_max_ms} ms") + if reply.group != group: + raise Failure(f"group 0x{reply.group:04X}") + ctx.cmd(trust_ca_command(0, 0, b"")) + + +def s33_open_tcp_duration(ctx: Ctx) -> None: + """Measurement: how long a plain OPEN_TCP takes to give up.""" + for label, host in (("an address that drops SYNs", BLACKHOLE), + ("an unresolvable name", UNRESOLVABLE)): + check_start(f"OPEN_TCP to {label}: time to 11 / 84") + r = ctx.link.command(open_tcp_command(host, 80)) + ctx.note("open_tcp", {"target": label, "status": r.status.decode("latin-1"), + "elapsed": round(r.elapsed, 2), "aborted": r.aborted}) + if r.ok: + ctx.close(r.data[0]) + check_ok(f"{r.status.decode('latin-1') or 'ABORTed'} after {r.elapsed:.1f}s") + + +SCENARIOS = [ + Scenario("S0", "startup-sweep", 1, "control", "every CLOSE 0..15 answers 00 or 12,…: 9", + s0_startup_sweep), + Scenario("S1", "capability", 1, "tls", "16-byte v1 record, ready 0x07, length checks", + s1_capability), + Scenario("S20", "plain-tcp", 1, "control", "OPEN_TCP/WRITE/READ/CLOSE round trip", + s20_plain_tcp, ("peer",)), + Scenario("S2", "pin-echo", 1, "tls", "PIN, TLS 1.3, 4096 B echo, INFO SPKI = pin", + s2_pin_echo, ("fixture",)), + Scenario("S23", "tls12-fallback", 1, "tls", "0x0303, a hardened suite, EMS bit, echo", + s23_tls12, ("fixture",)), + Scenario("S5", "refused-cert", 1, "tls", "exactly 93 0x00000008; 96 for a wrong pin", + s5_refused_cert, ("fixture",)), + Scenario("S19e", "abort-then-release", 1, "tls", "ABORTed OPEN: [14] = 1, $25 -> 1, then 0", + s19e_abort_release, ("fixture",)), + Scenario("S30", "bundle-real-hosts", 1, "tls", "BUNDLE to H1-H3, SPKI as seen here, HTTP/1.", + s30_real_hosts, ("internet", "crypto")), + Scenario("S6", "peer-close-notify", 2, "tls", "3000 B then $0000 + 01; CLOSE -> 12,…: 9", + s6_peer_close, ("fixture",)), + Scenario("S7", "peer-fin-truncation", 2, "tls", "3000 B then $0000 + 05", s7_truncation, + ("fixture",)), + Scenario("S7c", "rst-mid-handshake", 2, "tls", "13 PEER RESET: 104", s7c_rst_handshake, + ("fixture",)), + Scenario("S10", "handshake-timeout", 2, "tls", "15 within 17 s", s10_handshake_timeout, + ("fixture",)), + Scenario("S11", "session-cap", 2, "tls", "2 OK, 3rd 91, CLOSE one, OPEN OK", s11_cap, + ("fixture",)), + Scenario("S12", "open-close-x20", 2, "tls", "20 cycles, INFO [2] = 0", s12_open_close, + ("fixture",)), + Scenario("S13", "tickets-big-record", 2, "tls", "10 tickets; 16 KB record byte exact", + s13_tickets_big_record, ("fixture",)), + Scenario("S3", "custom-ca", 2, "tls", "CUSTOM echo ECDSA+RSA, SPKI; 94/95/95/93; 97", + s3_custom_ca, ("fixture",)), + Scenario("S19", "params", 2, "tls", "81/82 table, flags $01 OK, maxlen 82, 11, 84", + s19_params, ("fixture",)), + Scenario("S19e2", "release-spares-claimed", 2, "tls", "$25 -> 1; A echoes; B -> 02: 9", + s19e2_release_spares_claimed, ("fixture",)), + Scenario("S19e2b", "info-ff-does-not-claim", 2, "tls", "[14] = 1 after 03 23 FF; $25 -> 1", + s19e2b_info_does_not_claim, ("fixture",)), + Scenario("S22", "group-negotiation", 2, "tls", "0x001D default; 0x0017 via HRR", + s22_groups, ("fixture",)), + Scenario("S24", "require-tls13-vs-1.2", 2, "tls", "14 with 70, or 18 with 0x0303", + s24_require13, ("fixture",)), + Scenario("S18", "dispatcher-not-blocked", 2, "tls", "block_max_ms < 50 after a handshake", + s18_block_max, ("fixture",)), + Scenario("S14", "reset-cleanup", 2, "tls", "reset closes both, b3 clear, then 97", + s14_reset_cleanup, ("fixture",)), + Scenario("S32", "write-stall-close-cap", 2, "tls", "FFFF + 12/17 sticky; CLOSE time", + s32_write_stall, ("fixture",), default=False), + Scenario("S34", "p384-p521-custom", 2, "measurement", "handshake ms for P-384/P-521, 1.3/1.2", + s34_big_curves, ("fixture",), default=False), + Scenario("S33", "open-tcp-duration", 2, "measurement", "seconds to 11 / 84", + s33_open_tcp_duration, (), default=False), +] +BY_NAME = {s.name: s for s in SCENARIOS} | {s.sid: s for s in SCENARIOS} + + +# -- the run ----------------------------------------------------------------- + +def judge(outcome: Outcome) -> None: + """The signature: GREEN, RED (21 to a TLS command), or a plain FAIL.""" + s = outcome.scenario + unknown = outcome.evidence.get("unknown_command") + if outcome.verdict == "PASS": + outcome.signature = {"tls": "GREEN", "control": "CONTROL-PASS", + "measurement": "MEASURED"}[s.kind] + elif outcome.verdict in ("SKIP", "N/A", "ERROR"): + outcome.signature = outcome.verdict + elif unknown and outcome.first_tls_status == STATUS_UNKNOWN_COMMAND.decode(): + outcome.signature = "RED" + else: + outcome.signature = "FAIL" + + +def run_scenario(ctx: Ctx, scenario: Scenario, route: str) -> Outcome: + outcome = Outcome(scenario, route) + ctx.outcome = outcome + section(f"{scenario.sid} {scenario.name} [tier {scenario.tier}, {scenario.kind}, {route}]") + started = time.monotonic() + try: + scenario.fn(ctx) + outcome.verdict = "PASS" + except NotOnRoute as exc: + outcome.verdict, outcome.reason = "N/A", str(exc) + check_start(f"{scenario.sid} applies to this route") + check_skip(str(exc)) + except Skipped as exc: + outcome.verdict, outcome.reason = "SKIP", str(exc) + check_start(f"{scenario.sid} can run here") + check_skip(str(exc)) + except LinkLost: + ctx.outcome = None + ctx.close_servers() + raise + except Failure as exc: + outcome.verdict, outcome.reason = "FAIL", format_exception(exc) + except Exception as exc: # a bug in the suite must not pass for the firmware's + outcome.verdict = "FAIL" + outcome.reason = f"suite error: {type(exc).__name__}: {exc}" + detail(traceback.format_exc()) + finally: + outcome.elapsed = time.monotonic() - started + if ctx.outcome is not None: + ctx.close_servers() + judge(outcome) + detail(f"{scenario.sid}: {outcome.verdict} ({outcome.signature})" + + (f": {outcome.reason}" if outcome.reason else "")) + ctx.outcome = None + if outcome.verdict == "FAIL": + # Leave nothing behind for the next scenario (the startup sweep). + try: + ctx.sweep() + except Failure as exc: + warn(f"the sweep after {scenario.sid} failed: {exc}") + return outcome + + +def expectation_met(outcomes: list[Outcome], expect: str) -> tuple[bool, list[str]]: + """Whether the run shows what --expect asks, from evidence only. + + A SKIP or ERROR of any selected scenario is a problem; only N/A (by design + not on this route) is set aside. green: every control passes, every TLS + scenario is GREEN, no measurement failed. red: every control passes and + every TLS scenario is RED. Either way each route must have produced at least + one TLS outcome of the expected signature, so zero evidence never passes. + """ + problems = [] + evidence: dict[str, int] = {} + routes = [] + for o in outcomes: + label = f"{o.scenario.sid} {o.scenario.name} [{o.route}]" + if o.route not in routes: + routes.append(o.route) + evidence[o.route] = 0 + if o.verdict == "N/A": + continue + if o.verdict in ("SKIP", "ERROR"): + problems.append(f"{label}: {o.verdict}, so it says nothing: {o.reason}") + continue + kind = o.scenario.kind + if kind == "control": + if o.verdict != "PASS": + problems.append(f"{label}: the control failed, so the setup is not sound: {o.reason}") + elif kind == "measurement": + if expect == "green" and o.verdict != "PASS": + problems.append(f"{label}: the measurement failed: {o.reason}") + elif expect == "green": + if o.signature == "GREEN": + evidence[o.route] += 1 + else: + problems.append(f"{label}: {o.signature}: {o.reason}") + elif o.signature == "RED": + evidence[o.route] += 1 + else: + problems.append(f"{label}: {o.signature} where RED (21 to its first TLS command) " + f"was expected: {o.reason or 'it passed'}") + if not outcomes: + problems.append("no scenario ran") + # A scenario selected for this run but N/A on every route of it ran nowhere + # (e.g. --route native with S19e): never evidence. + for sid in dict.fromkeys(o.scenario.sid for o in outcomes): + if all(o.verdict == "N/A" for o in outcomes if o.scenario.sid == sid): + problems.append(f"{sid}: selected, but N/A on every route of this run, so it ran nowhere") + for route in routes: + if not evidence[route]: + problems.append(f"route {route}: no TLS scenario showed {expect.upper()}, so this run " + f"is no evidence either way") + return not problems, problems + + +def ancestor_pids() -> set[int]: + pids, pid = set(), os.getpid() + for _ in range(16): + try: + parent = int(subprocess.run(["ps", "-o", "ppid=", "-p", str(pid)], + capture_output=True, text=True, timeout=5, + check=False).stdout.strip() or 0) + except (OSError, ValueError, subprocess.SubprocessError): + break + if parent <= 1: + break + pids.add(parent) + pid = parent + return pids + + +LOCK_PID_ENV = "NET_TLS_LOCK_PID" + + +def lock_check(host: str, require: bool = False) -> dict: + """The DeviceLock of the optional c64-test-harness package (https://github.com/JC-000/c64-test-harness): + refuse if another live process holds this device. + + With `require` (or when a locking wrapper exported NET_TLS_LOCK_PID), + the lock must be HELD, by that very process, and that process must be this + one or an ancestor of it. A free lock is then a refusal: the user has left + the locked shell, or never entered it. + """ + try: + from c64_test_harness.backends.device_lock import DeviceLock # noqa: PLC0415 + except ImportError as exc: + # The DeviceLock comes from the optional c64-test-harness package, which this tree does not + # require; without it there is nothing to check, unless the run was told to require a lock. + if require or os.environ.get(LOCK_PID_ENV): + raise Failure(f"--require-lock, but the harness DeviceLock is not importable ({exc}); " + f"refusing to run against {host}") from exc + print(f"warning: c64_test_harness (https://github.com/JC-000/c64-test-harness) is not installed: " + f"not checking whether another run holds {host} ({exc})", file=sys.stderr) + return {"lock": "not checked (c64_test_harness not installed)"} + marker = os.environ.get(LOCK_PID_ENV, "") + require = require or bool(marker) + if require: + if not marker.isdigit(): + raise Failure(f"--require-lock, but {LOCK_PID_ENV} is not set: this shell is not the " + f"shell of a locking wrapper. Nothing was run or changed") + if int(marker) == os.getpid() and DeviceLock.held_by_this_process(host): + return {"lock": f"held by this process ({marker})"} + holder = DeviceLock.foreign_holder(host) + if (not holder or holder.get("pid") != int(marker) + or int(marker) not in ancestor_pids()): + raise Failure(f"--require-lock: the session lock on {host} is not held by our " + f"locking wrapper (pid {marker}); holder {holder or 'none'}. Nothing " + f"was run or changed") + return {"lock": f"held by our locking wrapper, pid {marker}"} + holder = DeviceLock.foreign_holder(host) + if not holder: + return {"lock": "free"} + if holder.get("pid") in ancestor_pids(): + return {"lock": f"held by our ancestor pid {holder.get('pid')} (a locking wrapper)"} + raise Failure(f"{host} is held by pid {holder.get('pid')} ({holder}); another run is using " + f"the device. Run under its lock, or wait") + + +def apply_settings(device, set_wifi: bool, original: dict, header: dict) -> dict: + """Read every setting first; refuse before writing anything; then set and read back. + + `original` is the caller's, filled as each setting is written, so whatever + happens after a write the caller can restore it. + """ + before: dict[str, str] = {} + header["settings_before"] = before + with check("read the settings this suite depends on, before changing any"): + for category, item, _value, _restore in SETTINGS: + try: + before[item] = str(device.configs.current(category, item)) + except Failure: + if item == REQUIRED_SETTING: + raise + before[item] = "absent" + detail(json.dumps(before)) + wifi = before.get(WIFI_SETTING, "absent") + if wifi != "absent" and wifi.strip() != "Enabled" and not set_wifi: + # One-way on the U64: switching it on cannot be undone by this suite, so + # only an explicit --set-wifi may do it. + raise SetupRefused(f"{WIFI_SETTING} is {wifi!r}; this suite needs it 'Enabled' and does " + f"not switch it on without --set-wifi (one-way on the U64). Nothing " + f"was changed") + applied = {} + for category, item, value, restore in SETTINGS: + with check(f"set {category} / {item} = {value}"): + current = before[item] + if current == "absent": + check_warn("not on this device; recorded as absent") + applied[item] = "absent" + continue + if current.strip() != value: + if restore: + original[(category, item)] = current + device.configs.set(category, item, value) + applied[item] = str(device.configs.current(category, item)) + if applied[item].strip() != value: + raise Failure(f"read back {applied[item]!r}") + detail(f"{current!r} -> {applied[item]!r}" + ("" if restore else " (one-way: kept)")) + return applied + + +class SetupRefused(Failure): + """Setup refused before changing anything on the device.""" + + +def wait_ready(link: Link) -> dict: + """With TLS, wait for INFO [4] b0-b2; on stock, the 21 says there is nothing to wait for.""" + deadline = time.monotonic() + READY_WAIT_SECONDS + while True: + r = link.command(info_command(INFO_CAPABILITY)) + if r.status == STATUS_UNKNOWN_COMMAND: + return {"tls_info": "21,UNKNOWN COMMAND"} + if r.ok and len(r.data) == INFO_CAPABILITY_BYTES: + cap = Capability(r.data) + if cap.ready & READY_BITS == READY_BITS or time.monotonic() > deadline: + return cap.as_dict() + elif time.monotonic() > deadline: + return {"tls_info": r.status.decode("latin-1")} + time.sleep(2) + + +def git_head() -> str: + try: + return subprocess.run(["git", "-C", str(HERE), "rev-parse", "--short", "HEAD"], + capture_output=True, text=True, timeout=5, + check=False).stdout.strip() + except (OSError, subprocess.SubprocessError): + return "" + + +def parse_args(argv=None): + parser = argparse.ArgumentParser(description="TLS sockets on the UCI network target: " + "RED on stock firmware, GREEN with TLS.") + cli.add_device_arguments(parser, password=None, timeout=30.0, colour=False) + parser.add_argument("--test", action="append", + help="A scenario id or name (repeatable), 'all', or 'tier1'. Default: " + "every default scenario.") + parser.add_argument("--route", action="append", choices=["all", "rest", "native"], + help="How to reach $DF1C-$DF1F. Default: both.") + parser.add_argument("--expect", choices=["green", "red"], default="green", + help="green: every TLS scenario must pass. red: every TLS scenario " + "must show the stock signature (21) and every control pass.") + parser.add_argument("--results", type=Path, help="Where run.json and wire.jsonl go.") + parser.add_argument("--label", default="", help="Free text recorded in run.json.") + parser.add_argument("--module-minor", type=int, + help="S1 also requires INFO [7..8] to equal this (e.g. 8).") + parser.add_argument("--mac-cafile", help="S30 step 1/4: verify with this CA file instead " + "of this machine's default store.") + parser.add_argument("--strict-sni", action="store_true", + help="S5 also requires the BUNDLE ClientHello to carry the SNI.") + parser.add_argument("--require-lock", action="store_true", + help="Refuse unless the device's DeviceLock is held by the process in " + "NET_TLS_LOCK_PID, this process or an ancestor of it.") + parser.add_argument("--set-wifi", action="store_true", + help="Switch 'WiFi Enabled' on if it is off. One-way on the U64 (a " + "reboot is the only way back), so without it the suite refuses.") + parser.add_argument("--keep-config", action="store_true", + help="Don't restore the settings this suite changed.") + parser.add_argument("--list", action="store_true", help="List the scenarios and exit.") + args = parser.parse_args(argv) + args.hosts = None + return args + + +def select(args) -> list[Scenario]: + """The scenarios asked for, always led by S0: every route starts with the startup sweep.""" + wanted = args.test or [] + if not wanted: + return [s for s in SCENARIOS if s.default] + if "all" in wanted: + return list(SCENARIOS) + chosen = [SCENARIOS[0]] + for s in SCENARIOS: + if s is SCENARIOS[0]: + continue + if ("tier1" in wanted and s.tier == 1) or s.sid in wanted or s.name in wanted: + chosen.append(s) + unknown = [w for w in wanted if w not in BY_NAME and w not in ("all", "tier1")] + if unknown: + raise SystemExit(f"unknown scenario(s): {unknown}; see --list") + return chosen + + +def write_results(directory: Path, header: dict, outcomes: list[Outcome], wire: list[dict]) -> None: + directory.mkdir(parents=True, exist_ok=True) + body = dict(header, scenarios=[o.as_dict() for o in outcomes]) + (directory / "run.json").write_text(json.dumps(body, indent=2, default=repr)) + with open(directory / "wire.jsonl", "w", encoding="utf-8") as handle: + for entry in wire: + handle.write(json.dumps(entry) + "\n") + + +def run_routes(links: list[tuple[str, Callable[[], Link], Callable[[], Link] | None]], + scenarios: list[Scenario], args, pki, bind_ip, + available: set[str]) -> tuple[list[Outcome], list[dict]]: + """Every selected scenario on every route; (outcomes, wire log). + + `available` names what this run has: "peer" (the device can reach this + machine), "fixture" (and the local PKI), "crypto", "internet". + """ + outcomes: list[Outcome] = [] + wire: list[dict] = [] + for route, make_link, reset in links: + section(f"route: {route}") + try: + link = make_link() + except Failure as exc: + # The other routes' records stay; this one is an ERROR. + warn(f"the {route} route could not start: {exc}") + for scenario in scenarios: + failed = Outcome(scenario, route, "ERROR", reason=f"the {route} route could not " + f"start: {exc}") + judge(failed) + outcomes.append(failed) + continue + ctx = Ctx(link, args, pki, bind_ip, reset, wire) + pending = list(scenarios) + try: + while pending: + scenario = pending.pop(0) + missing = [need for need in scenario.needs if need not in available] + if missing: + # The run was meant to have it (the fixture could not start, + # say): an ERROR, never a quiet SKIP. + outcome = Outcome(scenario, route, "ERROR", + reason=f"this run has no {', '.join(missing)}") + judge(outcome) + else: + outcome = run_scenario(ctx, scenario, route) + outcomes.append(outcome) + except LinkLost as exc: + outcomes.append(ctx_lost := Outcome(scenario, route, "FAIL", reason=str(exc))) + judge(ctx_lost) + for rest in pending: + lost = Outcome(rest, route, "ERROR", reason=f"the {route} route was lost") + judge(lost) + outcomes.append(lost) + warn(f"the {route} route is lost: {exc}; resetting the C64") + if reset is not None: + try: + reset() + except Failure as again: + warn(f"the reset failed too: {again}") + return outcomes, wire + + +def summarise(outcomes: list[Outcome], expect: str) -> bool: + section("summary") + for o in outcomes: + state = {"PASS": OK, "FAIL": FAIL, "ERROR": FAIL}.get(o.verdict, SKIP) + detail(f"{o.scenario.sid:7} {o.scenario.name:24} tier {o.scenario.tier} " + f"{o.scenario.kind:11} {o.route:7} {state:4} {o.signature}" + + (f" ({o.reason[:110]})" if o.reason and o.verdict != "PASS" else "")) + met, problems = expectation_met(outcomes, expect) + for problem in problems: + detail(f"not {expect.upper()}: {problem}") + return met + + +def main(argv=None) -> int: + args = parse_args(argv) + if args.list: + for s in SCENARIOS: + print(f"{s.sid:7} {s.name:24} tier {s.tier} {s.kind:11} " + f"{'' if s.default else '(opt-in) '}{s.oracle}") + return 0 + scenarios = select(args) + routes = ["rest", "native"] if not args.route or "all" in args.route else args.route + stamp = datetime.datetime.now(datetime.UTC).strftime("%Y%m%dT%H%M%SZ") + results = args.results or DEFAULT_RESULTS / f"{stamp}-{args.expect}" + target = targets.parse(args.host) + device = UltimateApi(target.device, args.password, args.timeout) + computer = UltimateApi(target.computer, args.password, args.timeout) + header = {"suite": SUITE, "suite_commit": git_head(), "started": stamp, "expect": args.expect, + "label": args.label, "host": args.host, "routes": routes, + "scenarios_selected": [s.sid for s in scenarios]} + # Before anything touches the device: a run holding the lock is mid-run, + # and even the reset below would land in the middle of its work. + try: + with check("no other run holds this device (harness DeviceLock)"): + header["lock"] = lock_check(target.device, args.require_lock) + detail(header["lock"]["lock"]) + except Failure as exc: + suite_fail(SUITE, f"nothing was run or changed: {format_exception(exc)}") + return 1 + original: dict = {} + outcomes: list[Outcome] = [] + wire: list[dict] = [] + pki = None + rest_uci = Uci(computer.machine, BOUND_OPEN) + ok = False + setup_error = None + touched = False # whether anything on the device was changed + try: + with check("read /v1/info: product, firmware, core, fpga, git hash"): + info = device.info() + header["device"] = {"product": info.product, "firmware_version": info.firmware_version, + "fpga_version": info.fpga_version, **info.extra} + detail(json.dumps(header["device"])) + header["settings"] = apply_settings(device, args.set_wifi, original, header) + touched = True + with check("reset the C64 so nothing another program left is still driving the UCI"): + computer.machine.reset(force=True) + rest_uci.release() + if not interface_present(rest_uci): + raise Failure("$DF1B-$DF1F all read $FF: no command interface on this machine") + with check("wait for INFO $FF ready bits (module, entropy, time), up to 90 s with TLS"): + header["ready"] = wait_ready(RestLink(rest_uci)) + detail(json.dumps(header["ready"])) + available = {"internet"} + bind_ip = None + check_start("this machine can serve the local TLS fixture to the device") + try: + bind_ip = fx.local_address_towards(target.device) + available.add("peer") + pki = fx.Pki() + available |= {"fixture", "crypto"} + check_ok(bind_ip) + except (RuntimeError, OSError) as exc: + # Every scenario that needs it then records ERROR. + check_fail(f"{exc}; the scenarios that need it will be ERROR") + header["fixture"] = {"bind_ip": bind_ip, "cryptography": fx.HAVE_CRYPTOGRAPHY} + + def reset_rest() -> Link: + computer.machine.reset(force=True) + rest_uci.release() + return RestLink(rest_uci) + + def make_native() -> Link: + computer.machine.reset(force=True) + agent = NativeUci(computer.machine, computer.runners, BOUND_OPEN) + agent.start() + return NativeLink(agent) + + links = [] + for route in routes: + if route == "rest": + links.append(("rest", lambda: RestLink(rest_uci), reset_rest)) + elif target.split: + warn("the native route cannot reach a cartridge's interface; skipped") + else: + links.append(("native", make_native, make_native)) + outcomes, wire = run_routes(links, scenarios, args, pki, bind_ip, available) + ok = summarise(outcomes, args.expect) + except Failure as exc: + setup_error = format_exception(exc) + ok = False + finally: + if pki is not None: + pki.close() + if touched or original: + try: + rest_uci.release() + computer.machine.reset(force=True) + except Failure as exc: + warn(f"final reset: {exc}") + if not args.keep_config: + for (category, item), value in original.items(): + with check(f"restore {category} / {item} to {value!r}"): + device.configs.set(category, item, value) + header["finished"] = datetime.datetime.now(datetime.UTC).strftime("%Y%m%dT%H%M%SZ") + header["expectation_met"] = ok + header["setup_error"] = setup_error + write_results(results, header, outcomes, wire) + print(f"results: {results}") + if ok: + suite_ok(SUITE, f"{args.expect.upper()} as expected over {len(outcomes)} scenario runs") + return 0 + suite_fail(SUITE, setup_error or f"not {args.expect.upper()}; see the summary and " + f"{results}/run.json") + return 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tests/e2e/io/command_interface/uci_agent.asm b/tests/e2e/io/command_interface/uci_agent.asm index f00fa03dc..534362f38 100644 --- a/tests/e2e/io/command_interface/uci_agent.asm +++ b/tests/e2e/io/command_interface/uci_agent.asm @@ -23,7 +23,9 @@ ; OPT_ABRT abandon the reply after the first block, which is what a ; client does when it gives up part way through a Data More ; reply -; $C00A-$C00F and $C440-$C4FF are reserved for further options and results. +; OPT_WAIT how long a wait may last, for a command that legitimately +; runs longer than the default (an OPEN_TLS can take 41 s) +; $C00B-$C00F and $C440-$C4FF are reserved for further options and results. ; New behaviour, as opposed to a new value, belongs in a reserved option byte, ; where zero has to keep meaning what the agent does today: the host writes the ; whole option block at once, so an older host leaves zeroes there. @@ -67,7 +69,8 @@ OPT_CAP = $C006 ; 16 bit cap on the data drain READY = $C008 ; agent writes $A5 here once it is running OPT_ABRT = $C009 ; non-zero: abandon the reply after the first ; block by writing the abort bit -; $C00A-$C00F ; reserved for further options +OPT_WAIT = $C00A ; wraps a wait may take; zero means WAIT_WRAPS +; $C00B-$C00F ; reserved for further options CMDBUF = $C010 ; command bytes, up to 896 ; ------------------------------------------------------------- result block -- @@ -92,10 +95,12 @@ zcap = $05 ; 16 bit remaining drain allowance ztmo = $07 ; 24 bit wait counter zblk = $0A ; block index zstat = $0B ; CTRL as the current block arrived +zwrap = $0C ; wraps this transaction's waits may take ; The wait gives up after this many wraps of a 16 bit counter. Each pass is -; about a dozen cycles, so $08 is roughly six seconds on a 1 MHz 6510: longer -; than any command takes, shorter than the host's own timeout. +; 25 cycles, so a wrap is about 1.7 s and $08 about 14 s on a 1 MHz 6510 +; (counted, not measured): longer than any plain command takes. A host that +; sends a longer command (a TLS open) raises it through OPT_WAIT. WAIT_WRAPS = $08 * = $0801 @@ -115,6 +120,7 @@ start sta GO sta SEQ sta OPT_ABRT ; so a host that never sets it gets the default + sta OPT_WAIT lda #$A5 sta READY main_wait @@ -129,6 +135,11 @@ main_wait ; ---------------------------------------------------------------- transact --- ; Runs one command end to end and fills the result block. transact + lda OPT_WAIT + bne transact_wrap + lda #WAIT_WRAPS +transact_wrap + sta zwrap lda #$00 sta R_FLAGS sta R_BLOCKS @@ -303,7 +314,7 @@ idle_loop bne idle_loop inc ztmo+2 lda ztmo+2 - cmp #WAIT_WRAPS + cmp zwrap bne idle_loop lda R_FLAGS ora #$01 @@ -334,7 +345,7 @@ wait_loop bne wait_loop inc ztmo+2 lda ztmo+2 - cmp #WAIT_WRAPS + cmp zwrap bne wait_loop lda R_FLAGS ora #$01 diff --git a/tests/e2e/lib/uci_native.py b/tests/e2e/lib/uci_native.py index fe00dd2ac..d98c4949f 100644 --- a/tests/e2e/lib/uci_native.py +++ b/tests/e2e/lib/uci_native.py @@ -36,6 +36,7 @@ OPT_CAP = 0xC006 READY = 0xC008 OPT_ABRT = 0xC009 +OPT_WAIT = 0xC00A CMDBUF = 0xC010 RESULT_BASE = 0xC400 @@ -83,6 +84,10 @@ def __init__(self, machine, runners, self.machine = machine self.runners = runners self.busy_timeout = busy_timeout + # Wraps of the agent's 16-bit wait counter (about 1.7 s each at 1 MHz). + # Zero keeps the agent's default of 8, about 14 s; a caller with a + # longer command raises it together with busy_timeout. + self.wait_wraps = 0 self._sequence = 0 # -- lifecycle ---------------------------------------------------------- @@ -121,8 +126,10 @@ def _run(self, command: bytes, overrun_reads: int, cap: int, min(overrun_reads, MAX_OVERRUN_READS), max_blocks, cap & 0xFF, (cap >> 8) & 0xFF])) # Outside the option block above, so it is written every time rather - # than left over from the previous transaction. - self.machine.writemem(OPT_ABRT, bytes([0x01 if abort_first else 0x00])) + # than left over from the previous transaction. OPT_WAIT follows + # OPT_ABRT, so one write carries both. + self.machine.writemem(OPT_ABRT, bytes([0x01 if abort_first else 0x00, + self.wait_wraps & 0xFF])) self.machine.writemem(GO, bytes([0x01])) deadline = time.monotonic() + self.busy_timeout diff --git a/tests/lib/registry_test.py b/tests/lib/registry_test.py index 225a4f836..8063c1e34 100755 --- a/tests/lib/registry_test.py +++ b/tests/lib/registry_test.py @@ -56,10 +56,9 @@ # it. A token outside this set would reach the suite as a literal. TOKENS = {"@HOST@", "@PASS@", "@TIMEOUT@", "@MODE@", "@SOAKPROFILE@", "@KERNAL@"} -# Files ending in _test.py that no profile should select, each with its reason. -# A file that is not a suite belongs here rather than in the registry, so that -# "not registered" always means "nobody can run it". Everything else under -# SEARCHED has to be in the registry. +# Files ending in _test.py that no profile should select, each with its reason: +# not a suite, or a suite that is opt-in by name (run directly). Everything +# else under SEARCHED has to be in the registry. NOT_SUITES: dict[str, str] = { # The four tiers of the observability suite. Importing one registers its # cases in support.CASES; tests/lib/observability_test.py imports all four @@ -70,6 +69,10 @@ "tests/lib/observability/component_test.py": "tier 2 of the observability suite", "tests/lib/observability/pipeline_test.py": "tier 3 of the observability suite", "tests/lib/observability/golden_test.py": "tier 4 of the observability suite", + # Never by a profile: it can switch "WiFi Enabled" on (--set-wifi; one-way + # on the U64), needs this host as a TLS peer and the Internet, and is RED on + # any image without the TLS commands. net_tls_selftest.py checks it offline. + "tests/e2e/io/command_interface/net_tls_test.py": "opt-in TLS suite on a device, run directly", } # tests/lib/bootstrap.py is the one place that may compute a path into the From 7c5bcb364d74ddbe38ea9e39d4cbdd0e8bd1b75a Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 15 Oct 2026 12:41:46 -0500 Subject: [PATCH 53/95] E2E: fix the stale cite in net_tls_test.py The commented-out WiFi disable branch is network_esp32.cc:143-146; :134-136 is inside the U64 == 2 RadioOn/RadioOff block. Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/e2e/io/command_interface/net_tls_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/io/command_interface/net_tls_test.py b/tests/e2e/io/command_interface/net_tls_test.py index 052edabad..0cd42c957 100644 --- a/tests/e2e/io/command_interface/net_tls_test.py +++ b/tests/e2e/io/command_interface/net_tls_test.py @@ -79,7 +79,7 @@ HOSTS_ENV = "NET_TLS_INTERNET_HOSTS" # What the runner sets, and whether it puts it back afterwards. WiFi Enabled is -# one-way on the U64 (network_esp32.cc:134-136: the disable branch is commented +# one-way on the U64 (network_esp32.cc:143-146: the disable branch is commented # out), so writing it back would record a restore that did not happen. SETTINGS = ( ("C64 and Cartridge Settings", "Command Interface", "Enabled", True), From b1ff7b02ae157ea8d420fb5c56977fd8fecb19e5 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 09:11:25 -0500 Subject: [PATCH 54/95] Move the ESP-side TLS code to a shared directory, software/wifi/tls The TLS engine and its RPC commands are not specific to the U64's module, and a second module firmware will build them. This step moves them and changes no behaviour. - tls_engine.c/.h and tls_engine_stub.c move from raw_u64/main to wifi/tls. - The cmd_tls_* handlers and the TLS task move from rpc_dispatch.c to wifi/tls/tls_rpc.c. The dispatcher calls tls_rpc_start(), tls_rpc_dispatch() and tls_rpc_note_block(). tls_rpc.h lists what the host firmware provides. - The CMD_TLS_* opcodes and the TLS RPC layout, with its layout asserts, move from rpc_calls.h and rpc_dispatch.c to wifi/tls/rpc_tls.h, which rpc_calls.h includes. The asserts are C only (#ifndef __cplusplus): GCC's C++ front end has no _Static_assert, and the Ultimate side asserts the same layouts itself in wifi_tls.cc. - The CA-store block of raw_u64/CMakeLists.txt moves to ca_store/ca_store.cmake. It finds the store from its own directory and checks CMAKE_SOURCE_DIR, so any project can include it. - ca_store.py attaching() reads the shared directory too (SHARED_SOURCES), so a CA refresh still bumps raw_u64's IDENT_MINOR. refresh.py takes a minor per project (--ident-minor PROJECT=N) when more than one project carries the bundle. - The Ultimate-side Makefiles and the host wifitls build find rpc_tls.h; the CI ESP32 cache key hashes wifi/tls and *.cmake. - Comments that named rpc_dispatch.c or rpc_calls.h for the TLS code now name tls_rpc.c and rpc_tls.h. The module's behaviour is unchanged, so its version is too. Co-Authored-By: Claude Opus 5.5 (1M context) --- doc/uci_tls.md | 2 +- software/esp_depends.py | 2 +- software/io/wifi/tests/Makefile | 2 +- software/io/wifi/wifi_tls.cc | 2 +- software/io/wifi/wifi_tls.h | 2 +- software/test/wifi_tls/net_tls_test.cc | 2 +- software/test/wifi_tls/wifi_tls_test.cc | 2 +- software/wifi/ca_store/ca_store.cmake | 21 ++ software/wifi/raw_u64/CMakeLists.txt | 19 +- software/wifi/raw_u64/README.md | 9 +- software/wifi/raw_u64/main/CMakeLists.txt | 10 +- software/wifi/raw_u64/main/rpc_calls.h | 167 +-------- software/wifi/raw_u64/main/rpc_dispatch.c | 330 +----------------- software/wifi/raw_u64/main/rpc_dispatch.h | 3 - software/wifi/tests/Makefile | 4 +- software/wifi/tls/rpc_tls.h | 274 +++++++++++++++ .../wifi/{raw_u64/main => tls}/tls_engine.c | 0 .../wifi/{raw_u64/main => tls}/tls_engine.h | 0 .../{raw_u64/main => tls}/tls_engine_stub.c | 0 software/wifi/tls/tls_rpc.c | 267 ++++++++++++++ software/wifi/tls/tls_rpc.h | 24 ++ target/pc/linux/getrandompaths/Makefile | 4 +- target/pc/linux/radioentropy/Makefile | 2 +- target/pc/linux/wifidedicated/Makefile | 2 +- target/pc/linux/wifirandom/Makefile | 2 +- target/pc/linux/wifitls/Makefile | 10 +- target/u64/nios2/ultimate/Makefile | 1 + target/u64/nios2/updater/Makefile | 1 + tools/ca_store/ca_store.py | 22 +- tools/ca_store/refresh.py | 38 +- tools/ca_store/test_ca_store.py | 27 +- tools/ca_store/test_refresh.py | 22 +- 32 files changed, 720 insertions(+), 553 deletions(-) create mode 100644 software/wifi/ca_store/ca_store.cmake create mode 100644 software/wifi/tls/rpc_tls.h rename software/wifi/{raw_u64/main => tls}/tls_engine.c (100%) rename software/wifi/{raw_u64/main => tls}/tls_engine.h (100%) rename software/wifi/{raw_u64/main => tls}/tls_engine_stub.c (100%) create mode 100644 software/wifi/tls/tls_rpc.c create mode 100644 software/wifi/tls/tls_rpc.h diff --git a/doc/uci_tls.md b/doc/uci_tls.md index 91f85f123..f1f8085ac 100644 --- a/doc/uci_tls.md +++ b/doc/uci_tls.md @@ -3,7 +3,7 @@ Commands `$21`-`$25` of network target 3 open TLS client connections. The WiFi module (ESP32) runs the TLS sessions. The Ultimate keeps the TCP socket and carries the ciphertext between it and the module, so the C64 only ever sees plaintext. Implementation: `software/io/network/network_target_tls.cc` (Ultimate side), -`software/wifi/raw_u64/main/tls_engine.c` (module side). +`software/wifi/tls/tls_engine.c` and `tls_rpc.c` (module side; the directory is shared by module firmware). ## Conventions diff --git a/software/esp_depends.py b/software/esp_depends.py index 7d3fcd73c..689d9e3b0 100644 --- a/software/esp_depends.py +++ b/software/esp_depends.py @@ -11,7 +11,7 @@ def get_hash(path="", hash_type='md5'): return func.hexdigest() # Find dependencies -dirs = [ 'wifi/raw_c3/main', 'wifi/raw_c3', 'wifi/raw_u64/main', 'wifi/raw_u64', 'u64ctrl', 'u64ctrl/main', 'u64ctrl/ca', 'wifi/common' ] +dirs = [ 'wifi/raw_c3/main', 'wifi/raw_c3', 'wifi/raw_u64/main', 'wifi/raw_u64', 'wifi/tls', 'u64ctrl', 'u64ctrl/main', 'u64ctrl/ca', 'wifi/common' ] ptrns = [ '*.c', '*.h', '*.mk', '*.txt', '*.pem', 'sdkconfig'] fns = [ ] for d in dirs: diff --git a/software/io/wifi/tests/Makefile b/software/io/wifi/tests/Makefile index 140086f60..3b50e70ec 100644 --- a/software/io/wifi/tests/Makefile +++ b/software/io/wifi/tests/Makefile @@ -45,7 +45,7 @@ LEGACY := $(sort $(wildcard legacy/*.sed)) CXXFLAGS := -std=c++14 -g -O0 -Wall -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-switch \ -Wno-format -Wno-unknown-warning-option -Wno-mismatched-tags -Wno-deprecated-declarations \ -fno-access-control -DRISCV=1 $(if $(filter 0,$(U64)),,-DU64=$(U64)) \ - -I$(OUT) -Istubs -I. -I$(WIFI_DIR) -I$(UART) -I$(SW)/wifi/raw_u64/main -I$(SW)/wifi/common + -I$(OUT) -Istubs -I. -I$(WIFI_DIR) -I$(UART) -I$(SW)/wifi/raw_u64/main -I$(SW)/wifi/common -I$(SW)/wifi/tls # Prints the function $(1) of file $(2), and stops when it is not there extract = out=$$(awk -v f="$(subst ~, ,$(1))" -f $(EXTRACT) $(2)); \ diff --git a/software/io/wifi/wifi_tls.cc b/software/io/wifi/wifi_tls.cc index 9faf9b27d..e4fb3e670 100644 --- a/software/io/wifi/wifi_tls.cc +++ b/software/io/wifi/wifi_tls.cc @@ -10,7 +10,7 @@ extern "C" { #include "wifi_dedicated.h" #include "wifi_tls.h" -// The wire layouts of rpc_calls.h, byte for byte. +// The wire layouts of rpc_tls.h, byte for byte. static_assert(sizeof(rpc_header_t) == 4, "rpc_header_t"); static_assert(sizeof(rpc_espcmd_resp) == 8, "rpc_espcmd_resp"); static_assert(offsetof(rpc_tls_open_req, trust) == 4, "open.trust"); diff --git a/software/io/wifi/wifi_tls.h b/software/io/wifi/wifi_tls.h index 61e73da4b..abf615efa 100644 --- a/software/io/wifi/wifi_tls.h +++ b/software/io/wifi/wifi_tls.h @@ -1,6 +1,6 @@ // wifi_tls.h: TLS sessions run on the WiFi module (U64 only). It holds the keys and runs the protocol; this side moves // the ciphertext between a socket and the module, one step at a time, and the module never speaks unasked. Apart -// from wifi_cmd.h; wifi_tls.cc asserts the values repeated here match rpc_calls.h's layout. +// from wifi_cmd.h; wifi_tls.cc asserts the values repeated here match rpc_tls.h's layout. #ifndef WIFI_TLS_H_ #define WIFI_TLS_H_ diff --git a/software/test/wifi_tls/net_tls_test.cc b/software/test/wifi_tls/net_tls_test.cc index 35ff1a7cf..de7ecd85c 100644 --- a/software/test/wifi_tls/net_tls_test.cc +++ b/software/test/wifi_tls/net_tls_test.cc @@ -1538,7 +1538,7 @@ static void test_edge_cases(void) // The STATS cache is cleared only on NO_MODULE, NOT_SUPPORTED or a new // generation. The ESP32 answers a STATS that finds the TLS queue full with a full-size reply, - // esp_err ESP_ERR_TIMEOUT (rpc_dispatch.c cmd_tls_busy), which take_stats makes REFUSED. + // esp_err ESP_ERR_TIMEOUT (tls_rpc.c cmd_tls_busy), which take_stats makes REFUSED. fresh(); info(0xFF); world_module.stats_result = WIFI_TLS_REFUSED; // cmd_tls_busy's full-size reply diff --git a/software/test/wifi_tls/wifi_tls_test.cc b/software/test/wifi_tls/wifi_tls_test.cc index 25bd0b537..e1c8a8501 100644 --- a/software/test/wifi_tls/wifi_tls_test.cc +++ b/software/test/wifi_tls/wifi_tls_test.cc @@ -315,7 +315,7 @@ static void test_take_others(void) r = wifi_tls_take_open(reply.bytes, sizeof(rpc_tls_open_resp), SEQUENCE, 1, &esp_err, &reason); check((r == WIFI_TLS_REFUSED) && (esp_err == 0x103) && (reason == WIFI_TLS_REASON_NO_CUSTOM_CA), "OPEN: refused, with reason 3 NO_CUSTOM_CA"); - // The refusal as the ESP32 sends it, slot 0xFF (rpc_dispatch.c cmd_tls_open). + // The refusal as the ESP32 sends it, slot 0xFF (tls_rpc.c cmd_tls_open). ((rpc_tls_open_resp *)reply.bytes)->slot = 0xFF; ((rpc_tls_open_resp *)reply.bytes)->reason = TLS_OPEN_REASON_NO_TIME; r = wifi_tls_take_open(reply.bytes, sizeof(rpc_tls_open_resp), SEQUENCE, 1, &esp_err, &reason); diff --git a/software/wifi/ca_store/ca_store.cmake b/software/wifi/ca_store/ca_store.cmake new file mode 100644 index 000000000..6e9c5e653 --- /dev/null +++ b/software/wifi/ca_store/ca_store.cmake @@ -0,0 +1,21 @@ +# The certificate bundle is the vendored Mozilla root store, software/wifi/ca_store/cacert.pem. ca_store.py checks it against +# CA_PINS and the configuration this build really uses (sdkconfig.json) at every configure and again at every build, +# before the bundle is made, so an earlier configure cannot skip it. RELEASE=1 also fails a stale store. See README.md. +# Include this from a project's own CMakeLists.txt, after project(), wherever the project is. The store and the check +# are found from this file (CMAKE_CURRENT_LIST_DIR here is the store's own directory); the project being checked is +# CMAKE_SOURCE_DIR. +set(CA_STORE ${CMAKE_CURRENT_LIST_DIR}) +set(CA_STORE_CHECK ${CMAKE_CURRENT_LIST_DIR}/../../../tools/ca_store/ca_store.py) +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CA_STORE}/cacert.pem ${CA_STORE}/CA_PINS ${CA_STORE_CHECK}) +idf_build_get_property(_python PYTHON) +idf_build_get_property(_sdkconfig_json SDKCONFIG_JSON) +set(_ca_check ${_python} ${CA_STORE_CHECK} check --project ${CMAKE_SOURCE_DIR} --sdkconfig-json ${_sdkconfig_json}) +execute_process(COMMAND ${_ca_check} RESULT_VARIABLE _ca_rc) +if(NOT _ca_rc EQUAL 0) + message(FATAL_ERROR "The Mozilla root store (software/wifi/ca_store) failed its check; see README.md") +endif() +add_custom_target(ca_store_check ALL COMMAND ${_ca_check} COMMENT "Checking the Mozilla root store" VERBATIM) +# The bundle (and so the mbedtls library and the image) waits for it +if(TARGET custom_bundle) + add_dependencies(custom_bundle ca_store_check) +endif() diff --git a/software/wifi/raw_u64/CMakeLists.txt b/software/wifi/raw_u64/CMakeLists.txt index 5fa75d887..07d822cb7 100644 --- a/software/wifi/raw_u64/CMakeLists.txt +++ b/software/wifi/raw_u64/CMakeLists.txt @@ -8,21 +8,4 @@ if(IDF_VERSION_MAJOR LESS 6) endif() project(bridge) -# The certificate bundle is the vendored Mozilla root store, ../ca_store/cacert.pem. ca_store.py checks it against -# CA_PINS and the configuration this build really uses (sdkconfig.json) at every configure and again at every build, -# before the bundle is made, so an earlier configure cannot skip it. RELEASE=1 also fails a stale store. See README.md. -set(CA_STORE ${CMAKE_CURRENT_LIST_DIR}/../ca_store) -set(CA_STORE_CHECK ${CMAKE_CURRENT_LIST_DIR}/../../../tools/ca_store/ca_store.py) -set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CA_STORE}/cacert.pem ${CA_STORE}/CA_PINS ${CA_STORE_CHECK}) -idf_build_get_property(_python PYTHON) -idf_build_get_property(_sdkconfig_json SDKCONFIG_JSON) -set(_ca_check ${_python} ${CA_STORE_CHECK} check --project ${CMAKE_CURRENT_LIST_DIR} --sdkconfig-json ${_sdkconfig_json}) -execute_process(COMMAND ${_ca_check} RESULT_VARIABLE _ca_rc) -if(NOT _ca_rc EQUAL 0) - message(FATAL_ERROR "The Mozilla root store (software/wifi/ca_store) failed its check; see README.md") -endif() -add_custom_target(ca_store_check ALL COMMAND ${_ca_check} COMMENT "Checking the Mozilla root store" VERBATIM) -# The bundle (and so the mbedtls library and the image) waits for it -if(TARGET custom_bundle) - add_dependencies(custom_bundle ca_store_check) -endif() +include(${CMAKE_SOURCE_DIR}/../ca_store/ca_store.cmake) diff --git a/software/wifi/raw_u64/README.md b/software/wifi/raw_u64/README.md index 87b57e98f..1cbfa5f95 100644 --- a/software/wifi/raw_u64/README.md +++ b/software/wifi/raw_u64/README.md @@ -25,7 +25,7 @@ server that sends one, as OpenJDK's JSSE does, fails the handshake. ## Testing the TLS engine -The engine (`main/tls_engine.c`, `main/rpc_dispatch.c`) is checked from the C64's side by the E2E +The engine (`../tls/tls_engine.c`, `../tls/tls_rpc.c`; `software/wifi/tls` is shared by module firmware, and holds the RPC layout, `rpc_tls.h`) is checked from the C64's side by the E2E suite `tests/e2e/io/command_interface/net_tls_test.py` (against a device) and `net_tls_selftest.py` (against a simulated one), and the Ultimate's side of the module calls by `make -C target/pc/linux/wifitls test`. The engine can also be run on its own, on QEMU or an @@ -46,7 +46,7 @@ and then: v6.0.3 ships Mozilla's data of 2025-12-02, with roots Mozilla has sinc so none of ESP-IDF's roots are merged in, and points `CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH` at `../ca_store/cacert.pem`; ESP-IDF's `gen_crt_bundle.py` builds the bundle from that file and builds it again whenever the file changes. -- **How the build verifies it.** `CMakeLists.txt` runs `python3 tools/ca_store/ca_store.py check` +- **How the build verifies it.** `CMakeLists.txt` (through `../ca_store/ca_store.cmake`) runs `python3 tools/ca_store/ca_store.py check` at every configure (an edit to `cacert.pem`, `CA_PINS` or the checker configures again) and again at every build, before the bundle is made, so an already-configured tree cannot skip it. It checks the configuration the build really uses (its `config/sdkconfig.json`, which @@ -63,7 +63,8 @@ and then: v6.0.3 ships Mozilla's data of 2025-12-02, with roots Mozilla has sinc pinned by commit and sha256, gives the same file from the newest `certdata.txt` on Firefox's release branch, which must descend from `CA_CERTDATA_REF`. It writes `cacert.pem` and `CA_PINS`. When the certificates changed it also sets `IDENT_MINOR` (and `IDENT_STRING`) in - `main/rpc_dispatch.h` to N, since the updater reflashes a module only for a new version. N must + `main/rpc_dispatch.h` to N (of every project whose own sources or `ca_store.SHARED_SOURCES` attach the + bundle; with more than one, `--ident-minor PROJECT=N` for each), since the updater reflashes a module only for a new version. N must be allocated for this image and above the current minor: the tool refuses a certificate change without `--ident-minor`, because on a development line the next number may already belong to another image. `--summary FILE` lists what changed by fingerprint, for review. Commit the @@ -77,7 +78,7 @@ and then: v6.0.3 ships Mozilla's data of 2025-12-02, with roots Mozilla has sinc stops (it fails closed, as it would with ESP-IDF's own bundle, which holds the same roots). - **No anchors.** ESP-IDF 6 verifies cross-signed chains itself (`CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY`), so the store needs no hand-kept - roots: `sdkconfig` sets it explicitly, `main/tls_engine.c` refuses to build without it, and the + roots: `sdkconfig` sets it explicitly, `../tls/tls_engine.c` refuses to build without it, and the check refuses an anchor file. Only raw_u64 uses the store; raw_c3 and u64ctrl keep ESP-IDF's bundle. diff --git a/software/wifi/raw_u64/main/CMakeLists.txt b/software/wifi/raw_u64/main/CMakeLists.txt index 4bab394b1..13be65c48 100644 --- a/software/wifi/raw_u64/main/CMakeLists.txt +++ b/software/wifi/raw_u64/main/CMakeLists.txt @@ -1,11 +1,13 @@ set(EXTERNAL "../../../io/uart") +# The TLS engine and its RPC commands are shared with other module firmware: software/wifi/tls +set(TLS_DIR "../../tls") # BRIDGE_TLS_STUB (idf.py -D BRIDGE_TLS_STUB=1) builds a size-measurement image without the TLS engine if(BRIDGE_TLS_STUB) - set(TLS_SRCS "tls_engine_stub.c") + set(TLS_SRCS "${TLS_DIR}/tls_engine_stub.c") else() - set(TLS_SRCS "tls_engine.c") + set(TLS_SRCS "${TLS_DIR}/tls_engine.c") endif() set(COMMON "../../common") -idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" ${TLS_SRCS} ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_boot.c ${COMMON}/radio_entropy.c ${COMMON}/radio_entropy_esp.c - INCLUDE_DIRS "." ${EXTERNAL} ${COMMON} +idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" "${TLS_DIR}/tls_rpc.c" ${TLS_SRCS} ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_boot.c ${COMMON}/radio_entropy.c ${COMMON}/radio_entropy_esp.c + INCLUDE_DIRS "." ${TLS_DIR} ${EXTERNAL} ${COMMON} LDFRAGMENTS "linker.lf") diff --git a/software/wifi/raw_u64/main/rpc_calls.h b/software/wifi/raw_u64/main/rpc_calls.h index bf854b3d5..a3d1aa954 100644 --- a/software/wifi/raw_u64/main/rpc_calls.h +++ b/software/wifi/raw_u64/main/rpc_calls.h @@ -131,165 +131,7 @@ typedef struct { //---------------------------------- //---------------------------------- -// TLS sessions, named by (slot, tag): the ESP32 runs the engine, the Ultimate moves the ciphertext. Fixed fields first, -// variable data last; rpc_dispatch.c and wifi_tls.cc assert these layouts at fixed offsets. -#define TLS_MAX_SESSIONS 2 -#define TLS_SNI_MAX_LEN 253 // longest DNS name -#define TLS_STEP_IN_MAX 1536 // ct_in_len + pt_in_len per step -#define TLS_STEP_OUT_MAX 1024 // ct_out_len + pt_out_len per step -#define TLS_SLOT_GLOBAL 0xFF // CMD_TLS_STATS without a session (tag 0) -#define TLS_PIN_LEN 32 // SHA-256 of the server's SubjectPublicKeyInfo, digest order -#define TLS_CA_MAX_LEN 1472 // one DER certificate for trust mode CUSTOM -#define TLS_ALERT_NONE 0xFF - -typedef enum { - TLS_TRUST_BUNDLE = 0, // the ESP-IDF certificate bundle - TLS_TRUST_CUSTOM = 1, // the one CA loaded with CMD_TLS_SET_CA, matched by ca_tag - TLS_TRUST_PIN = 2, // the leaf key's SHA-256 only -} tls_trust_t; - -#define TLS_OPT_REQUIRE_TLS13 0x01 // rpc_tls_open_req.opts: offer TLS 1.3 only -#define TLS_STEP_NO_READ 0x01 // rpc_tls_step_req.flags: no plaintext out of this step - -// rpc_tls_open_resp.reason, telling the ESP_ERR_INVALID_STATE refusals apart -#define TLS_OPEN_REASON_NONE 0 -#define TLS_OPEN_REASON_NO_ENTROPY 1 // the radio has not started: no RNG seed -#define TLS_OPEN_REASON_NO_TIME 2 // BUNDLE or CUSTOM, but no trustworthy clock -#define TLS_OPEN_REASON_NO_CUSTOM_CA 3 // CUSTOM, but no CA held under the request's ca_tag - -typedef enum { - TLS_TIME_NONE = 0, // clock not later than the build date - TLS_TIME_NIOS = 1, // set from unix_time in a CMD_TLS_OPEN (the Ultimate's SNTP time) - TLS_TIME_SNTP = 2, // already valid without the Ultimate: SNTP over the ESP32's own Wi-Fi (STATS only) -} tls_time_source_t; - -typedef enum { - TLS_STATE_HANDSHAKING = 0, - TLS_STATE_ESTABLISHED = 1, - TLS_STATE_CLOSED = 2, - TLS_STATE_FAILED = 3, // esp_err holds the mbedTLS error code, fail_reason says more -} tls_state_t; - -// rpc_tls_step_resp.fail_reason, set with FAILED -typedef enum { - TLS_FAIL_NONE = 0, // generic: esp_err has the mbedTLS code (alert_in the alert, if any) - TLS_FAIL_VERSION_REFUSED = 1, // the ServerHello chose a version not offered; it is in verify_flags' low 16 bits - TLS_FAIL_DOWNGRADE = 2, // TLS 1.2 chosen by a ServerHello carrying the RFC 8446 downgrade sentinel - TLS_FAIL_NO_EMS = 3, // a TLS 1.2 server without the extended master secret - TLS_FAIL_CERT_VERIFY = 4, // verify_flags = mbedtls_ssl_get_verify_result(), 0xFFFFFFFF if it never completed - TLS_FAIL_PIN_MISMATCH = 5, // PIN: the leaf key is not the pinned one - TLS_FAIL_PEER_CLOSED = 6, // close_notify during the handshake -} tls_fail_reason_t; - -// rpc_tls_set_ca_resp.reject, with ESP_ERR_INVALID_ARG -#define TLS_CA_REJECT_NONE 0 -#define TLS_CA_REJECT_RSA_KEY_SHORT 1 // RSA key below 2048 bits -#define TLS_CA_REJECT_RESERVED 2 // never sent -#define TLS_CA_REJECT_CURVE 3 // EC key on a curve the X.509 profile does not accept -#define TLS_CA_REJECT_NOT_CA 4 // v3 without basicConstraints cA, or a keyUsage without keyCertSign - -typedef struct { - rpc_header_t hdr; - uint8_t trust; // tls_trust_t - uint8_t sni_len; // 0..TLS_SNI_MAX_LEN, no terminator; 0 = no name (PIN only) - uint8_t slot; // 0..TLS_MAX_SESSIONS-1, chosen by the Ultimate - uint8_t time_source; // TLS_TIME_NONE, or TLS_TIME_NIOS when unix_time is the Ultimate's SNTP time - uint32_t unix_time; // UTC seconds - uint16_t tag; // names the session with slot; never 0 - uint8_t opts; // TLS_OPT_* - uint8_t reserved; - uint16_t ca_tag; // CUSTOM: the Ultimate's current ca_tag; 0 otherwise - uint16_t reserved2; - uint8_t pin[TLS_PIN_LEN]; // read only when trust is PIN - char sni[]; -} rpc_tls_open_req; - -typedef struct { - rpc_header_t hdr; - int esp_err; // ESP_OK, an esp_err_t, or a negative mbedTLS code - uint8_t slot; // TLS_SLOT_GLOBAL when esp_err != ESP_OK - uint8_t reason; // TLS_OPEN_REASON_* - uint16_t reserved; // 0 -} rpc_tls_open_resp; - -typedef struct { - rpc_header_t hdr; - uint8_t slot; - uint8_t flags; // TLS_STEP_NO_READ - uint16_t tag; - uint16_t ct_in_len; - uint16_t pt_in_len; - uint8_t data[]; // ct_in, then pt_in -} rpc_tls_step_req; - -typedef struct { - rpc_header_t hdr; - int esp_err; - uint8_t state; // tls_state_t - uint8_t alert_in; // fatal alert received, TLS_ALERT_NONE if none - uint16_t ct_out_len; - uint16_t pt_out_len; - uint8_t alert_out; // alert this engine sent unencrypted, TLS_ALERT_NONE if none (or encrypted) - uint8_t fail_reason; // tls_fail_reason_t, with FAILED - uint32_t verify_flags; // see tls_fail_reason_t - uint8_t data[]; // ct_out, then pt_out -} rpc_tls_step_resp; - -typedef struct { - rpc_header_t hdr; - uint8_t slot; - uint8_t reserved; - uint16_t tag; -} rpc_tls_session_req; // CMD_TLS_CLOSE and CMD_TLS_STATS - -typedef struct { - rpc_header_t hdr; - int esp_err; - uint16_t ct_out_len; - uint16_t reserved; - uint8_t data[]; // the close_notify record -} rpc_tls_close_resp; - -typedef struct { - rpc_header_t hdr; - int esp_err; - uint32_t heap_free; // internal 8-bit capable heap - uint32_t heap_min; // low-water mark since the OPEN that found no session open - uint32_t largest_block; - uint32_t ct_in_bytes; // session counters, 0 for TLS_SLOT_GLOBAL - uint32_t ct_out_bytes; - uint32_t pt_in_bytes; - uint32_t pt_out_bytes; - uint32_t handshake_us; // ESP32 time spent in handshake steps - uint16_t tls_version; // 0x0304 for TLS 1.3 - uint16_t ciphersuite; // IANA id - uint16_t group; // IANA NamedGroup, never 0 once ESTABLISHED - uint8_t state; // tls_state_t - uint8_t sessions_open; - uint32_t stack_free; // TLS task stack high-water mark, bytes - uint32_t esp_time; // ESP32 clock at the session's OPEN (now, for TLS_SLOT_GLOBAL), 0 = no time - uint8_t time_source; // tls_time_source_t of that clock - uint8_t entropy_source; // entropy_source_t, now - uint8_t ems; // 1: TLS 1.2 with the extended master secret - uint8_t reserved; - uint16_t block_max_ms; // longest dispatcher iteration since boot - uint16_t reserved2; - uint8_t spki_sha256[32]; // SHA-256 of the leaf's SubjectPublicKeyInfo, digest order -} rpc_tls_stats_resp; - -typedef struct { - rpc_header_t hdr; - uint16_t der_len; // 1..TLS_CA_MAX_LEN - uint16_t ca_tag; // never 0 - uint8_t der[]; -} rpc_tls_set_ca_req; - -typedef struct { - rpc_header_t hdr; - int esp_err; // ESP_OK, a negative mbedTLS parse code, or ESP_ERR_INVALID_ARG with a reject reason - uint8_t reject; // TLS_CA_REJECT_* - uint8_t reserved[3]; -} rpc_tls_set_ca_resp; +#include "rpc_tls.h" // CMD_TLS_* opcodes and the TLS session layouts, software/wifi/tls //---------------------------------- // send raw packet @@ -343,12 +185,7 @@ typedef struct { #define CMD_CLEAR_APS 0x11 #define CMD_WIFI_AUTOCONNECT 0x12 // 0x13-0x1F are u64ctrl's; 0x20 is CMD_GET_RANDOM, in rpc_shared.h -#define CMD_TLS_OPEN 0x30 -#define CMD_TLS_STEP 0x31 -#define CMD_TLS_CLOSE 0x32 -#define CMD_TLS_STATS 0x33 -#define CMD_TLS_CLOSE_ALL 0x34 -#define CMD_TLS_SET_CA 0x35 +// CMD_TLS_OPEN .. CMD_TLS_SET_CA (0x30-0x35): rpc_tls.h /* #define CMD_SOCKET 0x11 diff --git a/software/wifi/raw_u64/main/rpc_dispatch.c b/software/wifi/raw_u64/main/rpc_dispatch.c index 3fb200b8d..017982201 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.c +++ b/software/wifi/raw_u64/main/rpc_dispatch.c @@ -22,7 +22,7 @@ #include "pinout.h" #include "wifi_modem.h" #include "sntp.h" -#include "tls_engine.h" +#include "tls_rpc.h" // not officially supported #include "../lwip/esp_netif_lwip_internal.h" @@ -264,322 +264,6 @@ void cmd_get_random(command_buf_t *buf) } -// TLS. The layout is part of the wire, the header is echoed, and the fixed part of every reply is zeroed -// before it is filled. The Ultimate decodes these by offset and asserts the same ones: a layout change must -// break the build, not the wire. -_Static_assert(sizeof(rpc_tls_open_req) == 52, "rpc_tls_open_req size"); -_Static_assert(offsetof(rpc_tls_open_req, trust) == 4, "rpc_tls_open_req.trust"); -_Static_assert(offsetof(rpc_tls_open_req, sni_len) == 5, "rpc_tls_open_req.sni_len"); -_Static_assert(offsetof(rpc_tls_open_req, slot) == 6, "rpc_tls_open_req.slot"); -_Static_assert(offsetof(rpc_tls_open_req, time_source) == 7, "rpc_tls_open_req.time_source"); -_Static_assert(offsetof(rpc_tls_open_req, unix_time) == 8, "rpc_tls_open_req.unix_time"); -_Static_assert(offsetof(rpc_tls_open_req, tag) == 12, "rpc_tls_open_req.tag"); -_Static_assert(offsetof(rpc_tls_open_req, opts) == 14, "rpc_tls_open_req.opts"); -_Static_assert(offsetof(rpc_tls_open_req, reserved) == 15, "rpc_tls_open_req.reserved"); -_Static_assert(offsetof(rpc_tls_open_req, ca_tag) == 16, "rpc_tls_open_req.ca_tag"); -_Static_assert(offsetof(rpc_tls_open_req, reserved2) == 18, "rpc_tls_open_req.reserved2"); -_Static_assert(offsetof(rpc_tls_open_req, pin) == 20, "rpc_tls_open_req.pin"); -_Static_assert(offsetof(rpc_tls_open_req, sni) == 52, "rpc_tls_open_req.sni"); -_Static_assert(sizeof(rpc_tls_open_resp) == 12, "rpc_tls_open_resp size"); -_Static_assert(offsetof(rpc_tls_open_resp, esp_err) == 4, "rpc_tls_open_resp.esp_err"); -_Static_assert(offsetof(rpc_tls_open_resp, slot) == 8, "rpc_tls_open_resp.slot"); -_Static_assert(offsetof(rpc_tls_open_resp, reason) == 9, "rpc_tls_open_resp.reason"); -_Static_assert(offsetof(rpc_tls_open_resp, reserved) == 10, "rpc_tls_open_resp.reserved"); -_Static_assert(sizeof(rpc_tls_step_req) == 12, "rpc_tls_step_req size"); -_Static_assert(offsetof(rpc_tls_step_req, slot) == 4, "rpc_tls_step_req.slot"); -_Static_assert(offsetof(rpc_tls_step_req, flags) == 5, "rpc_tls_step_req.flags"); -_Static_assert(offsetof(rpc_tls_step_req, tag) == 6, "rpc_tls_step_req.tag"); -_Static_assert(offsetof(rpc_tls_step_req, ct_in_len) == 8, "rpc_tls_step_req.ct_in_len"); -_Static_assert(offsetof(rpc_tls_step_req, pt_in_len) == 10, "rpc_tls_step_req.pt_in_len"); -_Static_assert(offsetof(rpc_tls_step_req, data) == 12, "rpc_tls_step_req.data"); -_Static_assert(sizeof(rpc_tls_step_resp) == 20, "rpc_tls_step_resp size"); -_Static_assert(offsetof(rpc_tls_step_resp, esp_err) == 4, "rpc_tls_step_resp.esp_err"); -_Static_assert(offsetof(rpc_tls_step_resp, state) == 8, "rpc_tls_step_resp.state"); -_Static_assert(offsetof(rpc_tls_step_resp, alert_in) == 9, "rpc_tls_step_resp.alert_in"); -_Static_assert(offsetof(rpc_tls_step_resp, ct_out_len) == 10, "rpc_tls_step_resp.ct_out_len"); -_Static_assert(offsetof(rpc_tls_step_resp, pt_out_len) == 12, "rpc_tls_step_resp.pt_out_len"); -_Static_assert(offsetof(rpc_tls_step_resp, alert_out) == 14, "rpc_tls_step_resp.alert_out"); -_Static_assert(offsetof(rpc_tls_step_resp, fail_reason) == 15, "rpc_tls_step_resp.fail_reason"); -_Static_assert(offsetof(rpc_tls_step_resp, verify_flags) == 16, "rpc_tls_step_resp.verify_flags"); -_Static_assert(offsetof(rpc_tls_step_resp, data) == 20, "rpc_tls_step_resp.data"); -_Static_assert(sizeof(rpc_tls_session_req) == 8, "rpc_tls_session_req size"); -_Static_assert(offsetof(rpc_tls_session_req, slot) == 4, "rpc_tls_session_req.slot"); -_Static_assert(offsetof(rpc_tls_session_req, reserved) == 5, "rpc_tls_session_req.reserved"); -_Static_assert(offsetof(rpc_tls_session_req, tag) == 6, "rpc_tls_session_req.tag"); -_Static_assert(sizeof(rpc_tls_close_resp) == 12, "rpc_tls_close_resp size"); -_Static_assert(offsetof(rpc_tls_close_resp, esp_err) == 4, "rpc_tls_close_resp.esp_err"); -_Static_assert(offsetof(rpc_tls_close_resp, ct_out_len) == 8, "rpc_tls_close_resp.ct_out_len"); -_Static_assert(offsetof(rpc_tls_close_resp, reserved) == 10, "rpc_tls_close_resp.reserved"); -_Static_assert(offsetof(rpc_tls_close_resp, data) == 12, "rpc_tls_close_resp.data"); -_Static_assert(sizeof(rpc_espcmd_resp) == 8, "rpc_espcmd_resp size"); -_Static_assert(offsetof(rpc_espcmd_resp, esp_err) == 4, "rpc_espcmd_resp.esp_err"); -_Static_assert(sizeof(rpc_tls_stats_resp) == 96, "rpc_tls_stats_resp size"); -_Static_assert(offsetof(rpc_tls_stats_resp, esp_err) == 4, "rpc_tls_stats_resp.esp_err"); -_Static_assert(offsetof(rpc_tls_stats_resp, heap_free) == 8, "rpc_tls_stats_resp.heap_free"); -_Static_assert(offsetof(rpc_tls_stats_resp, heap_min) == 12, "rpc_tls_stats_resp.heap_min"); -_Static_assert(offsetof(rpc_tls_stats_resp, largest_block) == 16, "rpc_tls_stats_resp.largest_block"); -_Static_assert(offsetof(rpc_tls_stats_resp, ct_in_bytes) == 20, "rpc_tls_stats_resp.ct_in_bytes"); -_Static_assert(offsetof(rpc_tls_stats_resp, ct_out_bytes) == 24, "rpc_tls_stats_resp.ct_out_bytes"); -_Static_assert(offsetof(rpc_tls_stats_resp, pt_in_bytes) == 28, "rpc_tls_stats_resp.pt_in_bytes"); -_Static_assert(offsetof(rpc_tls_stats_resp, pt_out_bytes) == 32, "rpc_tls_stats_resp.pt_out_bytes"); -_Static_assert(offsetof(rpc_tls_stats_resp, handshake_us) == 36, "rpc_tls_stats_resp.handshake_us"); -_Static_assert(offsetof(rpc_tls_stats_resp, tls_version) == 40, "rpc_tls_stats_resp.tls_version"); -_Static_assert(offsetof(rpc_tls_stats_resp, ciphersuite) == 42, "rpc_tls_stats_resp.ciphersuite"); -_Static_assert(offsetof(rpc_tls_stats_resp, group) == 44, "rpc_tls_stats_resp.group"); -_Static_assert(offsetof(rpc_tls_stats_resp, state) == 46, "rpc_tls_stats_resp.state"); -_Static_assert(offsetof(rpc_tls_stats_resp, sessions_open) == 47, "rpc_tls_stats_resp.sessions_open"); -_Static_assert(offsetof(rpc_tls_stats_resp, stack_free) == 48, "rpc_tls_stats_resp.stack_free"); -_Static_assert(offsetof(rpc_tls_stats_resp, esp_time) == 52, "rpc_tls_stats_resp.esp_time"); -_Static_assert(offsetof(rpc_tls_stats_resp, time_source) == 56, "rpc_tls_stats_resp.time_source"); -_Static_assert(offsetof(rpc_tls_stats_resp, entropy_source) == 57, "rpc_tls_stats_resp.entropy_source"); -_Static_assert(offsetof(rpc_tls_stats_resp, ems) == 58, "rpc_tls_stats_resp.ems"); -_Static_assert(offsetof(rpc_tls_stats_resp, reserved) == 59, "rpc_tls_stats_resp.reserved"); -_Static_assert(offsetof(rpc_tls_stats_resp, block_max_ms) == 60, "rpc_tls_stats_resp.block_max_ms"); -_Static_assert(offsetof(rpc_tls_stats_resp, reserved2) == 62, "rpc_tls_stats_resp.reserved2"); -_Static_assert(offsetof(rpc_tls_stats_resp, spki_sha256) == 64, "rpc_tls_stats_resp.spki_sha256"); -_Static_assert(sizeof(rpc_tls_set_ca_req) == 8, "rpc_tls_set_ca_req size"); -_Static_assert(offsetof(rpc_tls_set_ca_req, der_len) == 4, "rpc_tls_set_ca_req.der_len"); -_Static_assert(offsetof(rpc_tls_set_ca_req, ca_tag) == 6, "rpc_tls_set_ca_req.ca_tag"); -_Static_assert(offsetof(rpc_tls_set_ca_req, der) == 8, "rpc_tls_set_ca_req.der"); -_Static_assert(sizeof(rpc_tls_set_ca_resp) == 12, "rpc_tls_set_ca_resp size"); -_Static_assert(offsetof(rpc_tls_set_ca_resp, esp_err) == 4, "rpc_tls_set_ca_resp.esp_err"); -_Static_assert(offsetof(rpc_tls_set_ca_resp, reject) == 8, "rpc_tls_set_ca_resp.reject"); -_Static_assert((TLS_TIME_NONE == 0) && (TLS_TIME_NIOS == 1) && (TLS_TIME_SNTP == 2), "tls_time_source_t"); -_Static_assert((TLS_STATE_HANDSHAKING == 0) && (TLS_STATE_ESTABLISHED == 1) && - (TLS_STATE_CLOSED == 2) && (TLS_STATE_FAILED == 3), "tls_state_t"); -_Static_assert((TLS_TRUST_BUNDLE == 0) && (TLS_TRUST_CUSTOM == 1) && (TLS_TRUST_PIN == 2), "tls_trust_t"); -_Static_assert((TLS_FAIL_VERSION_REFUSED == 1) && (TLS_FAIL_DOWNGRADE == 2) && (TLS_FAIL_NO_EMS == 3) && - (TLS_FAIL_CERT_VERIFY == 4) && (TLS_FAIL_PIN_MISMATCH == 5) && (TLS_FAIL_PEER_CLOSED == 6), "tls_fail_reason_t"); -_Static_assert((TLS_OPEN_REASON_NO_ENTROPY == 1) && (TLS_OPEN_REASON_NO_TIME == 2) && (TLS_OPEN_REASON_NO_CUSTOM_CA == 3), - "rpc_tls_open_resp.reason"); -_Static_assert((TLS_CA_REJECT_RSA_KEY_SHORT == 1) && (TLS_CA_REJECT_CURVE == 3) && (TLS_CA_REJECT_NOT_CA == 4), - "rpc_tls_set_ca_resp.reject"); -// Every request and reply must fit one command buffer -_Static_assert(sizeof(rpc_tls_open_req) + TLS_SNI_MAX_LEN <= CMD_BUF_SIZE, "largest CMD_TLS_OPEN request"); -_Static_assert(sizeof(rpc_tls_step_req) + TLS_STEP_IN_MAX <= CMD_BUF_SIZE, "largest CMD_TLS_STEP request"); -_Static_assert(sizeof(rpc_tls_step_resp) + TLS_STEP_OUT_MAX <= CMD_BUF_SIZE, "largest CMD_TLS_STEP reply"); -_Static_assert(sizeof(rpc_tls_close_resp) + TLS_STEP_OUT_MAX <= CMD_BUF_SIZE, "largest CMD_TLS_CLOSE reply"); -_Static_assert(sizeof(rpc_tls_set_ca_req) + TLS_CA_MAX_LEN <= CMD_BUF_SIZE, "largest CMD_TLS_SET_CA request"); -_Static_assert(sizeof(rpc_tls_stats_resp) <= CMD_BUF_SIZE, "CMD_TLS_STATS reply"); -_Static_assert(TLS_SNI_MAX_LEN <= 255, "sni_len is a byte"); - -void cmd_not_implemented(command_buf_t *buf); - -static QueueHandle_t tls_queue; -static volatile uint16_t block_max_ms; // the longest dispatcher iteration since boot, read by the TLS task - -void cmd_tls_open(command_buf_t *buf) -{ - rpc_tls_open_req *req = (rpc_tls_open_req *)buf->data; - rpc_tls_open_resp *resp = (rpc_tls_open_resp *)buf->data; - - // tls_open() copies the pin and the host name before the response overwrites them - uint8_t slot = TLS_SLOT_GLOBAL; - uint8_t reason = TLS_OPEN_REASON_NONE; - int err = ESP_ERR_INVALID_ARG; - if ((buf->size >= (int)sizeof(rpc_tls_open_req)) && (buf->size == (int)sizeof(rpc_tls_open_req) + req->sni_len)) { - tls_open_params_t p = { - .trust = req->trust, .opts = req->opts, .time_source = req->time_source, .ca_tag = req->ca_tag, - .unix_time = req->unix_time, .pin = req->pin, .sni = req->sni, .sni_len = req->sni_len, - }; - err = tls_open(req->slot, req->tag, &p, &reason); - if (err == ESP_OK) { - slot = req->slot; - } - } - memset(&resp->esp_err, 0, sizeof(rpc_tls_open_resp) - sizeof(rpc_header_t)); - resp->esp_err = err; - resp->slot = slot; - resp->reason = reason; - buf->size = sizeof(rpc_tls_open_resp); - my_uart_transmit_packet(UART_CHAN, buf); -} - -void cmd_tls_step(command_buf_t *buf) -{ - rpc_tls_step_req *req = (rpc_tls_step_req *)buf->data; - rpc_tls_step_resp *resp = (rpc_tls_step_resp *)buf->data; - - // The response overlays the request: tls_step() consumes ct_in and pt_in before it writes resp->data - uint16_t ct_out_len = 0; - uint16_t pt_out_len = 0; - tls_step_result_t result = { .state = TLS_STATE_CLOSED, .alert_in = TLS_ALERT_NONE, .alert_out = TLS_ALERT_NONE }; - int err = ESP_ERR_INVALID_ARG; - if (buf->size >= (int)sizeof(rpc_tls_step_req)) { - int ct_in_len = req->ct_in_len; - int pt_in_len = req->pt_in_len; - if (buf->size == (int)sizeof(rpc_tls_step_req) + ct_in_len + pt_in_len) { - err = tls_step(req->slot, req->tag, req->flags, req->data, ct_in_len, req->data + ct_in_len, pt_in_len, - resp->data, &ct_out_len, &pt_out_len, &result); - } else { - tls_session_stats_t stats; - tls_get_stats(req->slot, req->tag, &stats); - result.state = stats.state; - } - } - memset(&resp->esp_err, 0, sizeof(rpc_tls_step_resp) - sizeof(rpc_header_t)); - resp->esp_err = err; - resp->state = result.state; - resp->alert_in = result.alert_in; - resp->ct_out_len = ct_out_len; - resp->pt_out_len = pt_out_len; - resp->alert_out = result.alert_out; - resp->fail_reason = result.fail_reason; - resp->verify_flags = result.verify_flags; - buf->size = sizeof(rpc_tls_step_resp) + ct_out_len + pt_out_len; - my_uart_transmit_packet(UART_CHAN, buf); -} - -void cmd_tls_close(command_buf_t *buf) -{ - rpc_tls_session_req *req = (rpc_tls_session_req *)buf->data; - rpc_tls_close_resp *resp = (rpc_tls_close_resp *)buf->data; - - // The close_notify goes to resp->data, which starts past the request - uint16_t ct_out_len = 0; - int err = ESP_ERR_INVALID_ARG; - if (buf->size >= (int)sizeof(rpc_tls_session_req)) { - err = tls_close(req->slot, req->tag, resp->data, &ct_out_len); - } - memset(&resp->esp_err, 0, sizeof(rpc_tls_close_resp) - sizeof(rpc_header_t)); - resp->esp_err = err; - resp->ct_out_len = ct_out_len; - buf->size = sizeof(rpc_tls_close_resp) + ct_out_len; - my_uart_transmit_packet(UART_CHAN, buf); -} - -void cmd_tls_stats(command_buf_t *buf) -{ - rpc_tls_session_req *req = (rpc_tls_session_req *)buf->data; - rpc_tls_stats_resp *resp = (rpc_tls_stats_resp *)buf->data; - - // Heap figures come with every reply, also when the session is gone - tls_session_stats_t stats; - int err = ESP_ERR_INVALID_ARG; - if (buf->size >= (int)sizeof(rpc_tls_session_req)) { - err = tls_get_stats(req->slot, req->tag, &stats); - } else { - tls_get_stats(TLS_SLOT_GLOBAL, 0, &stats); - } - memset(&resp->esp_err, 0, sizeof(rpc_tls_stats_resp) - sizeof(rpc_header_t)); - resp->esp_err = err; - resp->heap_free = heap_caps_get_free_size(TLS_HEAP_CAPS); - resp->heap_min = heap_caps_get_minimum_free_size(TLS_HEAP_CAPS); - resp->largest_block = heap_caps_get_largest_free_block(TLS_HEAP_CAPS); - resp->ct_in_bytes = stats.ct_in_bytes; - resp->ct_out_bytes = stats.ct_out_bytes; - resp->pt_in_bytes = stats.pt_in_bytes; - resp->pt_out_bytes = stats.pt_out_bytes; - resp->handshake_us = stats.handshake_us; - resp->tls_version = stats.tls_version; - resp->ciphersuite = stats.ciphersuite; - resp->group = stats.group; - resp->state = stats.state; - resp->sessions_open = tls_sessions_open(); - resp->stack_free = uxTaskGetStackHighWaterMark(NULL); // this runs on the TLS task - resp->esp_time = stats.esp_time; - resp->time_source = stats.time_source; - resp->entropy_source = entropy_source(); - resp->ems = stats.ems; - resp->block_max_ms = block_max_ms; - memcpy(resp->spki_sha256, stats.spki_sha256, sizeof(resp->spki_sha256)); - buf->size = sizeof(rpc_tls_stats_resp); - my_uart_transmit_packet(UART_CHAN, buf); -} - -void cmd_tls_close_all(command_buf_t *buf) -{ - rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; - tls_close_all(); - resp->esp_err = ESP_OK; - buf->size = sizeof(rpc_espcmd_resp); - my_uart_transmit_packet(UART_CHAN, buf); -} - -void cmd_tls_set_ca(command_buf_t *buf) -{ - rpc_tls_set_ca_req *req = (rpc_tls_set_ca_req *)buf->data; - rpc_tls_set_ca_resp *resp = (rpc_tls_set_ca_resp *)buf->data; - - // tls_set_ca() parses the certificate before the response overwrites it - uint8_t reject = TLS_CA_REJECT_NONE; - int err = ESP_ERR_INVALID_ARG; - if ((buf->size >= (int)sizeof(rpc_tls_set_ca_req)) && (buf->size == (int)sizeof(rpc_tls_set_ca_req) + req->der_len)) { - err = tls_set_ca(req->der, req->der_len, req->ca_tag, &reject); - } else { - tls_set_ca(NULL, 0, 0, &reject); // a malformed upload still leaves no CA held - } - memset(&resp->esp_err, 0, sizeof(rpc_tls_set_ca_resp) - sizeof(rpc_header_t)); - resp->esp_err = err; - resp->reject = reject; - buf->size = sizeof(rpc_tls_set_ca_resp); - my_uart_transmit_packet(UART_CHAN, buf); -} - -// The TLS task's side: runs one TLS command and transmits its reply -void tls_serve(command_buf_t *buf) -{ - rpc_header_t *hdr = (rpc_header_t *)buf->data; - switch (hdr->command) { - case CMD_TLS_OPEN: - cmd_tls_open(buf); - break; - case CMD_TLS_STEP: - cmd_tls_step(buf); - break; - case CMD_TLS_CLOSE: - cmd_tls_close(buf); - break; - case CMD_TLS_STATS: - cmd_tls_stats(buf); - break; - case CMD_TLS_CLOSE_ALL: - cmd_tls_close_all(buf); - break; - case CMD_TLS_SET_CA: - cmd_tls_set_ca(buf); - break; - default: - cmd_not_implemented(buf); - break; - } -} - -static void tls_task(void *arg) -{ - command_buf_t *buf; - while (1) { - if (xQueueReceive(tls_queue, &buf, portMAX_DELAY) == pdTRUE) { - tls_serve(buf); - } - } -} - -// The TLS queue is full: the command's own reply shape, all zero but for ESP_ERR_TIMEOUT -static void cmd_tls_busy(command_buf_t *buf) -{ - rpc_header_t *hdr = (rpc_header_t *)buf->data; - int size; - switch (hdr->command) { - case CMD_TLS_OPEN: size = sizeof(rpc_tls_open_resp); break; - case CMD_TLS_STEP: size = sizeof(rpc_tls_step_resp); break; - case CMD_TLS_CLOSE: size = sizeof(rpc_tls_close_resp); break; - case CMD_TLS_STATS: size = sizeof(rpc_tls_stats_resp); break; - case CMD_TLS_SET_CA: size = sizeof(rpc_tls_set_ca_resp); break; - default: size = sizeof(rpc_espcmd_resp); break; - } - memset(buf->data + sizeof(rpc_header_t), 0, size - sizeof(rpc_header_t)); - ((rpc_espcmd_resp *)buf->data)->esp_err = ESP_ERR_TIMEOUT; - if (hdr->command == CMD_TLS_OPEN) { - ((rpc_tls_open_resp *)buf->data)->slot = TLS_SLOT_GLOBAL; - } else if (hdr->command == CMD_TLS_STEP) { - ((rpc_tls_step_resp *)buf->data)->alert_in = TLS_ALERT_NONE; - ((rpc_tls_step_resp *)buf->data)->alert_out = TLS_ALERT_NONE; - } - buf->size = size; - my_uart_transmit_packet(UART_CHAN, buf); -} - void cmd_not_implemented(command_buf_t *buf) { rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; @@ -668,18 +352,14 @@ void dispatch_command(command_buf_t *pbuffer) case CMD_TLS_STATS: case CMD_TLS_CLOSE_ALL: case CMD_TLS_SET_CA: - if (xQueueSend(tls_queue, &pbuffer, 0) != pdTRUE) { - cmd_tls_busy(pbuffer); - } + tls_rpc_dispatch(pbuffer); break; default: cmd_not_implemented(pbuffer); break; } int64_t ms = (esp_timer_get_time() - start) / 1000; - if (ms > block_max_ms) { - block_max_ms = (ms > 0xFFFF) ? 0xFFFF : (uint16_t)ms; - } + tls_rpc_note_block(ms); } void dispatch(void *ct) @@ -706,9 +386,7 @@ void dispatch(void *ct) void start_dispatch(QueueHandle_t queue) { - // TLS on core 1, as Wi-Fi is pinned to core 0 (CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0), at the dispatcher's priority - tls_queue = xQueueCreate(TLS_QUEUE_DEPTH, sizeof(command_buf_t *)); - xTaskCreatePinnedToCore(tls_task, "TLS", TLS_TASK_STACK, NULL, tskIDLE_PRIORITY + 1, NULL, 1); + tls_rpc_start(); // Core 1, above the system tasks: the UART ISR that feeds this queue runs on core 1 too xTaskCreatePinnedToCore( dispatch, "Dispatch Task", DISPATCHER_STACK, queue, 19, NULL, 1 ); } diff --git a/software/wifi/raw_u64/main/rpc_dispatch.h b/software/wifi/raw_u64/main/rpc_dispatch.h index 3c6541e01..832910f42 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.h +++ b/software/wifi/raw_u64/main/rpc_dispatch.h @@ -23,7 +23,6 @@ typedef struct { void create_dispatchers(int stacksize, command_buf_context_t *bufs); void dispatch(void *ct); void dispatch_command(command_buf_t *buf); -void tls_serve(command_buf_t *buf); void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); @@ -49,7 +48,5 @@ void send_keepalive(); #define IDENT_MINOR 11 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 // TLS runs on its own task, so this stays small -#define TLS_TASK_STACK 8192 // twice the stack handshakes were measured to use on the dispatcher -#define TLS_QUEUE_DEPTH 2 // one request outstanding, and a CLOSE behind a step that timed out #endif /* SOFTWARE_WIFI_SCAN_MAIN_RPC_DISPATCH_H_ */ diff --git a/software/wifi/tests/Makefile b/software/wifi/tests/Makefile index f9f476f7e..dcc4f0282 100644 --- a/software/wifi/tests/Makefile +++ b/software/wifi/tests/Makefile @@ -28,7 +28,7 @@ DIR_raw_u64 := $(PATH_SW)/wifi/raw_u64/main DIR_raw_c3 := $(PATH_SW)/wifi/raw_c3/main DIR_u64ctrl := $(PATH_SW)/u64ctrl/main # The U64 and U2+L modules have the radio switch (radio_boot.h): only they see wifi/common -INC_raw_u64 := -I$(PATH_SW)/wifi/common +INC_raw_u64 := -I$(PATH_SW)/wifi/common -I$(PATH_SW)/wifi/tls INC_raw_c3 := -I$(PATH_SW)/wifi/common # u64ctrl's rpc_calls.h and wifi_modem.h include rpc_shared.h and radio_entropy.h from there. It has no radio # switch: module_env.h does not count it as one, although radio_boot.h is on its path now @@ -38,7 +38,7 @@ HOSTTEST := $(PATH_SW)/io/usb/tests CASES := $(wildcard module_*_test.cpp) RADIO := $(wildcard radio_*test.cpp) # radio_entropy.h includes rpc_calls.h of raw_u64, which needs lwIP's headers; the wifi_random test stubs them out -RADIO_INC := -I$(PATH_SW)/wifi/common -I$(PATH_SW)/wifi/raw_u64/main -I$(PATH_SW)/test/wifi_random +RADIO_INC := -I$(PATH_SW)/wifi/common -I$(PATH_SW)/wifi/tls -I$(PATH_SW)/wifi/raw_u64/main -I$(PATH_SW)/test/wifi_random COMMON := -g -O0 -Wall -Wno-unused-parameter -D_FORTIFY_SOURCE=0 CFLAGS := -std=gnu11 $(COMMON) -Wno-unused-variable -Wno-unused-function CXXFLAGS := -std=c++14 $(COMMON) -I$(HOSTTEST) -I. -Istub diff --git a/software/wifi/tls/rpc_tls.h b/software/wifi/tls/rpc_tls.h new file mode 100644 index 000000000..8913743e6 --- /dev/null +++ b/software/wifi/tls/rpc_tls.h @@ -0,0 +1,274 @@ +/* rpc_tls.h: the wire contract of the CMD_TLS_* commands: their opcodes and the layout of their requests and answers. + * One definition for every module firmware that runs the TLS engine (software/wifi/tls) and for the Ultimate side + * that decodes them. Include rpc_calls.h, which includes this after the types it builds on. */ + +#ifndef RPC_TLS_H_ +#define RPC_TLS_H_ + +#include +#include +#include "rpc_calls.h" + +// TLS sessions, named by (slot, tag): the ESP32 runs the engine, the Ultimate moves the ciphertext. Fixed fields first, +// variable data last; the asserts at the end of this file and wifi_tls.cc check these layouts at fixed offsets. +#define TLS_MAX_SESSIONS 2 +#define TLS_SNI_MAX_LEN 253 // longest DNS name +#define TLS_STEP_IN_MAX 1536 // ct_in_len + pt_in_len per step +#define TLS_STEP_OUT_MAX 1024 // ct_out_len + pt_out_len per step +#define TLS_SLOT_GLOBAL 0xFF // CMD_TLS_STATS without a session (tag 0) +#define TLS_PIN_LEN 32 // SHA-256 of the server's SubjectPublicKeyInfo, digest order +#define TLS_CA_MAX_LEN 1472 // one DER certificate for trust mode CUSTOM +#define TLS_ALERT_NONE 0xFF + +typedef enum { + TLS_TRUST_BUNDLE = 0, // the ESP-IDF certificate bundle + TLS_TRUST_CUSTOM = 1, // the one CA loaded with CMD_TLS_SET_CA, matched by ca_tag + TLS_TRUST_PIN = 2, // the leaf key's SHA-256 only +} tls_trust_t; + +#define TLS_OPT_REQUIRE_TLS13 0x01 // rpc_tls_open_req.opts: offer TLS 1.3 only +#define TLS_STEP_NO_READ 0x01 // rpc_tls_step_req.flags: no plaintext out of this step + +// rpc_tls_open_resp.reason, telling the ESP_ERR_INVALID_STATE refusals apart +#define TLS_OPEN_REASON_NONE 0 +#define TLS_OPEN_REASON_NO_ENTROPY 1 // the radio has not started: no RNG seed +#define TLS_OPEN_REASON_NO_TIME 2 // BUNDLE or CUSTOM, but no trustworthy clock +#define TLS_OPEN_REASON_NO_CUSTOM_CA 3 // CUSTOM, but no CA held under the request's ca_tag + +typedef enum { + TLS_TIME_NONE = 0, // clock not later than the build date + TLS_TIME_NIOS = 1, // set from unix_time in a CMD_TLS_OPEN (the Ultimate's SNTP time) + TLS_TIME_SNTP = 2, // already valid without the Ultimate: SNTP over the ESP32's own Wi-Fi (STATS only) +} tls_time_source_t; + +typedef enum { + TLS_STATE_HANDSHAKING = 0, + TLS_STATE_ESTABLISHED = 1, + TLS_STATE_CLOSED = 2, + TLS_STATE_FAILED = 3, // esp_err holds the mbedTLS error code, fail_reason says more +} tls_state_t; + +// rpc_tls_step_resp.fail_reason, set with FAILED +typedef enum { + TLS_FAIL_NONE = 0, // generic: esp_err has the mbedTLS code (alert_in the alert, if any) + TLS_FAIL_VERSION_REFUSED = 1, // the ServerHello chose a version not offered; it is in verify_flags' low 16 bits + TLS_FAIL_DOWNGRADE = 2, // TLS 1.2 chosen by a ServerHello carrying the RFC 8446 downgrade sentinel + TLS_FAIL_NO_EMS = 3, // a TLS 1.2 server without the extended master secret + TLS_FAIL_CERT_VERIFY = 4, // verify_flags = mbedtls_ssl_get_verify_result(), 0xFFFFFFFF if it never completed + TLS_FAIL_PIN_MISMATCH = 5, // PIN: the leaf key is not the pinned one + TLS_FAIL_PEER_CLOSED = 6, // close_notify during the handshake +} tls_fail_reason_t; + +// rpc_tls_set_ca_resp.reject, with ESP_ERR_INVALID_ARG +#define TLS_CA_REJECT_NONE 0 +#define TLS_CA_REJECT_RSA_KEY_SHORT 1 // RSA key below 2048 bits +#define TLS_CA_REJECT_RESERVED 2 // never sent +#define TLS_CA_REJECT_CURVE 3 // EC key on a curve the X.509 profile does not accept +#define TLS_CA_REJECT_NOT_CA 4 // v3 without basicConstraints cA, or a keyUsage without keyCertSign + +typedef struct { + rpc_header_t hdr; + uint8_t trust; // tls_trust_t + uint8_t sni_len; // 0..TLS_SNI_MAX_LEN, no terminator; 0 = no name (PIN only) + uint8_t slot; // 0..TLS_MAX_SESSIONS-1, chosen by the Ultimate + uint8_t time_source; // TLS_TIME_NONE, or TLS_TIME_NIOS when unix_time is the Ultimate's SNTP time + uint32_t unix_time; // UTC seconds + uint16_t tag; // names the session with slot; never 0 + uint8_t opts; // TLS_OPT_* + uint8_t reserved; + uint16_t ca_tag; // CUSTOM: the Ultimate's current ca_tag; 0 otherwise + uint16_t reserved2; + uint8_t pin[TLS_PIN_LEN]; // read only when trust is PIN + char sni[]; +} rpc_tls_open_req; + +typedef struct { + rpc_header_t hdr; + int esp_err; // ESP_OK, an esp_err_t, or a negative mbedTLS code + uint8_t slot; // TLS_SLOT_GLOBAL when esp_err != ESP_OK + uint8_t reason; // TLS_OPEN_REASON_* + uint16_t reserved; // 0 +} rpc_tls_open_resp; + +typedef struct { + rpc_header_t hdr; + uint8_t slot; + uint8_t flags; // TLS_STEP_NO_READ + uint16_t tag; + uint16_t ct_in_len; + uint16_t pt_in_len; + uint8_t data[]; // ct_in, then pt_in +} rpc_tls_step_req; + +typedef struct { + rpc_header_t hdr; + int esp_err; + uint8_t state; // tls_state_t + uint8_t alert_in; // fatal alert received, TLS_ALERT_NONE if none + uint16_t ct_out_len; + uint16_t pt_out_len; + uint8_t alert_out; // alert this engine sent unencrypted, TLS_ALERT_NONE if none (or encrypted) + uint8_t fail_reason; // tls_fail_reason_t, with FAILED + uint32_t verify_flags; // see tls_fail_reason_t + uint8_t data[]; // ct_out, then pt_out +} rpc_tls_step_resp; + +typedef struct { + rpc_header_t hdr; + uint8_t slot; + uint8_t reserved; + uint16_t tag; +} rpc_tls_session_req; // CMD_TLS_CLOSE and CMD_TLS_STATS + +typedef struct { + rpc_header_t hdr; + int esp_err; + uint16_t ct_out_len; + uint16_t reserved; + uint8_t data[]; // the close_notify record +} rpc_tls_close_resp; + +typedef struct { + rpc_header_t hdr; + int esp_err; + uint32_t heap_free; // internal 8-bit capable heap + uint32_t heap_min; // low-water mark since the OPEN that found no session open + uint32_t largest_block; + uint32_t ct_in_bytes; // session counters, 0 for TLS_SLOT_GLOBAL + uint32_t ct_out_bytes; + uint32_t pt_in_bytes; + uint32_t pt_out_bytes; + uint32_t handshake_us; // ESP32 time spent in handshake steps + uint16_t tls_version; // 0x0304 for TLS 1.3 + uint16_t ciphersuite; // IANA id + uint16_t group; // IANA NamedGroup, never 0 once ESTABLISHED + uint8_t state; // tls_state_t + uint8_t sessions_open; + uint32_t stack_free; // TLS task stack high-water mark, bytes + uint32_t esp_time; // ESP32 clock at the session's OPEN (now, for TLS_SLOT_GLOBAL), 0 = no time + uint8_t time_source; // tls_time_source_t of that clock + uint8_t entropy_source; // entropy_source_t, now + uint8_t ems; // 1: TLS 1.2 with the extended master secret + uint8_t reserved; + uint16_t block_max_ms; // longest dispatcher iteration since boot + uint16_t reserved2; + uint8_t spki_sha256[32]; // SHA-256 of the leaf's SubjectPublicKeyInfo, digest order +} rpc_tls_stats_resp; + +typedef struct { + rpc_header_t hdr; + uint16_t der_len; // 1..TLS_CA_MAX_LEN + uint16_t ca_tag; // never 0 + uint8_t der[]; +} rpc_tls_set_ca_req; + +typedef struct { + rpc_header_t hdr; + int esp_err; // ESP_OK, a negative mbedTLS parse code, or ESP_ERR_INVALID_ARG with a reject reason + uint8_t reject; // TLS_CA_REJECT_* + uint8_t reserved[3]; +} rpc_tls_set_ca_resp; + +#define CMD_TLS_OPEN 0x30 +#define CMD_TLS_STEP 0x31 +#define CMD_TLS_CLOSE 0x32 +#define CMD_TLS_STATS 0x33 +#define CMD_TLS_CLOSE_ALL 0x34 +#define CMD_TLS_SET_CA 0x35 + +// TLS. The layout is part of the wire, the header is echoed, and the fixed part of every reply is zeroed +// before it is filled. The Ultimate decodes these by offset and asserts the same ones (wifi_tls.cc): a layout +// change must break the build, not the wire. The asserts here are C only: GCC's C++ front end has no +// _Static_assert, and glibc, unlike newlib, does not supply a macro for it. +#ifndef __cplusplus +_Static_assert(sizeof(rpc_tls_open_req) == 52, "rpc_tls_open_req size"); +_Static_assert(offsetof(rpc_tls_open_req, trust) == 4, "rpc_tls_open_req.trust"); +_Static_assert(offsetof(rpc_tls_open_req, sni_len) == 5, "rpc_tls_open_req.sni_len"); +_Static_assert(offsetof(rpc_tls_open_req, slot) == 6, "rpc_tls_open_req.slot"); +_Static_assert(offsetof(rpc_tls_open_req, time_source) == 7, "rpc_tls_open_req.time_source"); +_Static_assert(offsetof(rpc_tls_open_req, unix_time) == 8, "rpc_tls_open_req.unix_time"); +_Static_assert(offsetof(rpc_tls_open_req, tag) == 12, "rpc_tls_open_req.tag"); +_Static_assert(offsetof(rpc_tls_open_req, opts) == 14, "rpc_tls_open_req.opts"); +_Static_assert(offsetof(rpc_tls_open_req, reserved) == 15, "rpc_tls_open_req.reserved"); +_Static_assert(offsetof(rpc_tls_open_req, ca_tag) == 16, "rpc_tls_open_req.ca_tag"); +_Static_assert(offsetof(rpc_tls_open_req, reserved2) == 18, "rpc_tls_open_req.reserved2"); +_Static_assert(offsetof(rpc_tls_open_req, pin) == 20, "rpc_tls_open_req.pin"); +_Static_assert(offsetof(rpc_tls_open_req, sni) == 52, "rpc_tls_open_req.sni"); +_Static_assert(sizeof(rpc_tls_open_resp) == 12, "rpc_tls_open_resp size"); +_Static_assert(offsetof(rpc_tls_open_resp, esp_err) == 4, "rpc_tls_open_resp.esp_err"); +_Static_assert(offsetof(rpc_tls_open_resp, slot) == 8, "rpc_tls_open_resp.slot"); +_Static_assert(offsetof(rpc_tls_open_resp, reason) == 9, "rpc_tls_open_resp.reason"); +_Static_assert(offsetof(rpc_tls_open_resp, reserved) == 10, "rpc_tls_open_resp.reserved"); +_Static_assert(sizeof(rpc_tls_step_req) == 12, "rpc_tls_step_req size"); +_Static_assert(offsetof(rpc_tls_step_req, slot) == 4, "rpc_tls_step_req.slot"); +_Static_assert(offsetof(rpc_tls_step_req, flags) == 5, "rpc_tls_step_req.flags"); +_Static_assert(offsetof(rpc_tls_step_req, tag) == 6, "rpc_tls_step_req.tag"); +_Static_assert(offsetof(rpc_tls_step_req, ct_in_len) == 8, "rpc_tls_step_req.ct_in_len"); +_Static_assert(offsetof(rpc_tls_step_req, pt_in_len) == 10, "rpc_tls_step_req.pt_in_len"); +_Static_assert(offsetof(rpc_tls_step_req, data) == 12, "rpc_tls_step_req.data"); +_Static_assert(sizeof(rpc_tls_step_resp) == 20, "rpc_tls_step_resp size"); +_Static_assert(offsetof(rpc_tls_step_resp, esp_err) == 4, "rpc_tls_step_resp.esp_err"); +_Static_assert(offsetof(rpc_tls_step_resp, state) == 8, "rpc_tls_step_resp.state"); +_Static_assert(offsetof(rpc_tls_step_resp, alert_in) == 9, "rpc_tls_step_resp.alert_in"); +_Static_assert(offsetof(rpc_tls_step_resp, ct_out_len) == 10, "rpc_tls_step_resp.ct_out_len"); +_Static_assert(offsetof(rpc_tls_step_resp, pt_out_len) == 12, "rpc_tls_step_resp.pt_out_len"); +_Static_assert(offsetof(rpc_tls_step_resp, alert_out) == 14, "rpc_tls_step_resp.alert_out"); +_Static_assert(offsetof(rpc_tls_step_resp, fail_reason) == 15, "rpc_tls_step_resp.fail_reason"); +_Static_assert(offsetof(rpc_tls_step_resp, verify_flags) == 16, "rpc_tls_step_resp.verify_flags"); +_Static_assert(offsetof(rpc_tls_step_resp, data) == 20, "rpc_tls_step_resp.data"); +_Static_assert(sizeof(rpc_tls_session_req) == 8, "rpc_tls_session_req size"); +_Static_assert(offsetof(rpc_tls_session_req, slot) == 4, "rpc_tls_session_req.slot"); +_Static_assert(offsetof(rpc_tls_session_req, reserved) == 5, "rpc_tls_session_req.reserved"); +_Static_assert(offsetof(rpc_tls_session_req, tag) == 6, "rpc_tls_session_req.tag"); +_Static_assert(sizeof(rpc_tls_close_resp) == 12, "rpc_tls_close_resp size"); +_Static_assert(offsetof(rpc_tls_close_resp, esp_err) == 4, "rpc_tls_close_resp.esp_err"); +_Static_assert(offsetof(rpc_tls_close_resp, ct_out_len) == 8, "rpc_tls_close_resp.ct_out_len"); +_Static_assert(offsetof(rpc_tls_close_resp, reserved) == 10, "rpc_tls_close_resp.reserved"); +_Static_assert(offsetof(rpc_tls_close_resp, data) == 12, "rpc_tls_close_resp.data"); +_Static_assert(sizeof(rpc_espcmd_resp) == 8, "rpc_espcmd_resp size"); +_Static_assert(offsetof(rpc_espcmd_resp, esp_err) == 4, "rpc_espcmd_resp.esp_err"); +_Static_assert(sizeof(rpc_tls_stats_resp) == 96, "rpc_tls_stats_resp size"); +_Static_assert(offsetof(rpc_tls_stats_resp, esp_err) == 4, "rpc_tls_stats_resp.esp_err"); +_Static_assert(offsetof(rpc_tls_stats_resp, heap_free) == 8, "rpc_tls_stats_resp.heap_free"); +_Static_assert(offsetof(rpc_tls_stats_resp, heap_min) == 12, "rpc_tls_stats_resp.heap_min"); +_Static_assert(offsetof(rpc_tls_stats_resp, largest_block) == 16, "rpc_tls_stats_resp.largest_block"); +_Static_assert(offsetof(rpc_tls_stats_resp, ct_in_bytes) == 20, "rpc_tls_stats_resp.ct_in_bytes"); +_Static_assert(offsetof(rpc_tls_stats_resp, ct_out_bytes) == 24, "rpc_tls_stats_resp.ct_out_bytes"); +_Static_assert(offsetof(rpc_tls_stats_resp, pt_in_bytes) == 28, "rpc_tls_stats_resp.pt_in_bytes"); +_Static_assert(offsetof(rpc_tls_stats_resp, pt_out_bytes) == 32, "rpc_tls_stats_resp.pt_out_bytes"); +_Static_assert(offsetof(rpc_tls_stats_resp, handshake_us) == 36, "rpc_tls_stats_resp.handshake_us"); +_Static_assert(offsetof(rpc_tls_stats_resp, tls_version) == 40, "rpc_tls_stats_resp.tls_version"); +_Static_assert(offsetof(rpc_tls_stats_resp, ciphersuite) == 42, "rpc_tls_stats_resp.ciphersuite"); +_Static_assert(offsetof(rpc_tls_stats_resp, group) == 44, "rpc_tls_stats_resp.group"); +_Static_assert(offsetof(rpc_tls_stats_resp, state) == 46, "rpc_tls_stats_resp.state"); +_Static_assert(offsetof(rpc_tls_stats_resp, sessions_open) == 47, "rpc_tls_stats_resp.sessions_open"); +_Static_assert(offsetof(rpc_tls_stats_resp, stack_free) == 48, "rpc_tls_stats_resp.stack_free"); +_Static_assert(offsetof(rpc_tls_stats_resp, esp_time) == 52, "rpc_tls_stats_resp.esp_time"); +_Static_assert(offsetof(rpc_tls_stats_resp, time_source) == 56, "rpc_tls_stats_resp.time_source"); +_Static_assert(offsetof(rpc_tls_stats_resp, entropy_source) == 57, "rpc_tls_stats_resp.entropy_source"); +_Static_assert(offsetof(rpc_tls_stats_resp, ems) == 58, "rpc_tls_stats_resp.ems"); +_Static_assert(offsetof(rpc_tls_stats_resp, reserved) == 59, "rpc_tls_stats_resp.reserved"); +_Static_assert(offsetof(rpc_tls_stats_resp, block_max_ms) == 60, "rpc_tls_stats_resp.block_max_ms"); +_Static_assert(offsetof(rpc_tls_stats_resp, reserved2) == 62, "rpc_tls_stats_resp.reserved2"); +_Static_assert(offsetof(rpc_tls_stats_resp, spki_sha256) == 64, "rpc_tls_stats_resp.spki_sha256"); +_Static_assert(sizeof(rpc_tls_set_ca_req) == 8, "rpc_tls_set_ca_req size"); +_Static_assert(offsetof(rpc_tls_set_ca_req, der_len) == 4, "rpc_tls_set_ca_req.der_len"); +_Static_assert(offsetof(rpc_tls_set_ca_req, ca_tag) == 6, "rpc_tls_set_ca_req.ca_tag"); +_Static_assert(offsetof(rpc_tls_set_ca_req, der) == 8, "rpc_tls_set_ca_req.der"); +_Static_assert(sizeof(rpc_tls_set_ca_resp) == 12, "rpc_tls_set_ca_resp size"); +_Static_assert(offsetof(rpc_tls_set_ca_resp, esp_err) == 4, "rpc_tls_set_ca_resp.esp_err"); +_Static_assert(offsetof(rpc_tls_set_ca_resp, reject) == 8, "rpc_tls_set_ca_resp.reject"); +_Static_assert((TLS_TIME_NONE == 0) && (TLS_TIME_NIOS == 1) && (TLS_TIME_SNTP == 2), "tls_time_source_t"); +_Static_assert((TLS_STATE_HANDSHAKING == 0) && (TLS_STATE_ESTABLISHED == 1) && + (TLS_STATE_CLOSED == 2) && (TLS_STATE_FAILED == 3), "tls_state_t"); +_Static_assert((TLS_TRUST_BUNDLE == 0) && (TLS_TRUST_CUSTOM == 1) && (TLS_TRUST_PIN == 2), "tls_trust_t"); +_Static_assert((TLS_FAIL_VERSION_REFUSED == 1) && (TLS_FAIL_DOWNGRADE == 2) && (TLS_FAIL_NO_EMS == 3) && + (TLS_FAIL_CERT_VERIFY == 4) && (TLS_FAIL_PIN_MISMATCH == 5) && (TLS_FAIL_PEER_CLOSED == 6), "tls_fail_reason_t"); +_Static_assert((TLS_OPEN_REASON_NO_ENTROPY == 1) && (TLS_OPEN_REASON_NO_TIME == 2) && (TLS_OPEN_REASON_NO_CUSTOM_CA == 3), + "rpc_tls_open_resp.reason"); +_Static_assert((TLS_CA_REJECT_RSA_KEY_SHORT == 1) && (TLS_CA_REJECT_CURVE == 3) && (TLS_CA_REJECT_NOT_CA == 4), + "rpc_tls_set_ca_resp.reject"); +_Static_assert(TLS_SNI_MAX_LEN <= 255, "sni_len is a byte"); +#endif /* __cplusplus */ + +#endif /* RPC_TLS_H_ */ diff --git a/software/wifi/raw_u64/main/tls_engine.c b/software/wifi/tls/tls_engine.c similarity index 100% rename from software/wifi/raw_u64/main/tls_engine.c rename to software/wifi/tls/tls_engine.c diff --git a/software/wifi/raw_u64/main/tls_engine.h b/software/wifi/tls/tls_engine.h similarity index 100% rename from software/wifi/raw_u64/main/tls_engine.h rename to software/wifi/tls/tls_engine.h diff --git a/software/wifi/raw_u64/main/tls_engine_stub.c b/software/wifi/tls/tls_engine_stub.c similarity index 100% rename from software/wifi/raw_u64/main/tls_engine_stub.c rename to software/wifi/tls/tls_engine_stub.c diff --git a/software/wifi/tls/tls_rpc.c b/software/wifi/tls/tls_rpc.c new file mode 100644 index 000000000..da080bd82 --- /dev/null +++ b/software/wifi/tls/tls_rpc.c @@ -0,0 +1,267 @@ +/* tls_rpc.c: the CMD_TLS_* commands on the module side. They run on their own task, so a handshake never blocks + * the dispatcher (Wi-Fi TX); the dispatcher hands them over with tls_rpc_dispatch(). */ + +#include +#include "freertos/FreeRTOS.h" +#include "freertos/queue.h" +#include "freertos/task.h" +#include "esp_err.h" +#include "esp_heap_caps.h" +#include "driver/uart.h" +#include "rpc_calls.h" +#include "cmd_buffer.h" // CMD_BUF_SIZE +#include "my_uart.h" +#include "wifi_modem.h" +#include "tls_engine.h" +#include "tls_rpc.h" + +// Every request and reply must fit one command buffer +_Static_assert(sizeof(rpc_tls_open_req) + TLS_SNI_MAX_LEN <= CMD_BUF_SIZE, "largest CMD_TLS_OPEN request"); +_Static_assert(sizeof(rpc_tls_step_req) + TLS_STEP_IN_MAX <= CMD_BUF_SIZE, "largest CMD_TLS_STEP request"); +_Static_assert(sizeof(rpc_tls_step_resp) + TLS_STEP_OUT_MAX <= CMD_BUF_SIZE, "largest CMD_TLS_STEP reply"); +_Static_assert(sizeof(rpc_tls_close_resp) + TLS_STEP_OUT_MAX <= CMD_BUF_SIZE, "largest CMD_TLS_CLOSE reply"); +_Static_assert(sizeof(rpc_tls_set_ca_req) + TLS_CA_MAX_LEN <= CMD_BUF_SIZE, "largest CMD_TLS_SET_CA request"); +_Static_assert(sizeof(rpc_tls_stats_resp) <= CMD_BUF_SIZE, "CMD_TLS_STATS reply"); + +#define UART_CHAN UART_NUM_1 + +void cmd_not_implemented(command_buf_t *buf); + +static QueueHandle_t tls_queue; +static volatile uint16_t block_max_ms; // the longest dispatcher iteration since boot, read by the TLS task + +void cmd_tls_open(command_buf_t *buf) +{ + rpc_tls_open_req *req = (rpc_tls_open_req *)buf->data; + rpc_tls_open_resp *resp = (rpc_tls_open_resp *)buf->data; + + // tls_open() copies the pin and the host name before the response overwrites them + uint8_t slot = TLS_SLOT_GLOBAL; + uint8_t reason = TLS_OPEN_REASON_NONE; + int err = ESP_ERR_INVALID_ARG; + if ((buf->size >= (int)sizeof(rpc_tls_open_req)) && (buf->size == (int)sizeof(rpc_tls_open_req) + req->sni_len)) { + tls_open_params_t p = { + .trust = req->trust, .opts = req->opts, .time_source = req->time_source, .ca_tag = req->ca_tag, + .unix_time = req->unix_time, .pin = req->pin, .sni = req->sni, .sni_len = req->sni_len, + }; + err = tls_open(req->slot, req->tag, &p, &reason); + if (err == ESP_OK) { + slot = req->slot; + } + } + memset(&resp->esp_err, 0, sizeof(rpc_tls_open_resp) - sizeof(rpc_header_t)); + resp->esp_err = err; + resp->slot = slot; + resp->reason = reason; + buf->size = sizeof(rpc_tls_open_resp); + my_uart_transmit_packet(UART_CHAN, buf); +} + +void cmd_tls_step(command_buf_t *buf) +{ + rpc_tls_step_req *req = (rpc_tls_step_req *)buf->data; + rpc_tls_step_resp *resp = (rpc_tls_step_resp *)buf->data; + + // The response overlays the request: tls_step() consumes ct_in and pt_in before it writes resp->data + uint16_t ct_out_len = 0; + uint16_t pt_out_len = 0; + tls_step_result_t result = { .state = TLS_STATE_CLOSED, .alert_in = TLS_ALERT_NONE, .alert_out = TLS_ALERT_NONE }; + int err = ESP_ERR_INVALID_ARG; + if (buf->size >= (int)sizeof(rpc_tls_step_req)) { + int ct_in_len = req->ct_in_len; + int pt_in_len = req->pt_in_len; + if (buf->size == (int)sizeof(rpc_tls_step_req) + ct_in_len + pt_in_len) { + err = tls_step(req->slot, req->tag, req->flags, req->data, ct_in_len, req->data + ct_in_len, pt_in_len, + resp->data, &ct_out_len, &pt_out_len, &result); + } else { + tls_session_stats_t stats; + tls_get_stats(req->slot, req->tag, &stats); + result.state = stats.state; + } + } + memset(&resp->esp_err, 0, sizeof(rpc_tls_step_resp) - sizeof(rpc_header_t)); + resp->esp_err = err; + resp->state = result.state; + resp->alert_in = result.alert_in; + resp->ct_out_len = ct_out_len; + resp->pt_out_len = pt_out_len; + resp->alert_out = result.alert_out; + resp->fail_reason = result.fail_reason; + resp->verify_flags = result.verify_flags; + buf->size = sizeof(rpc_tls_step_resp) + ct_out_len + pt_out_len; + my_uart_transmit_packet(UART_CHAN, buf); +} + +void cmd_tls_close(command_buf_t *buf) +{ + rpc_tls_session_req *req = (rpc_tls_session_req *)buf->data; + rpc_tls_close_resp *resp = (rpc_tls_close_resp *)buf->data; + + // The close_notify goes to resp->data, which starts past the request + uint16_t ct_out_len = 0; + int err = ESP_ERR_INVALID_ARG; + if (buf->size >= (int)sizeof(rpc_tls_session_req)) { + err = tls_close(req->slot, req->tag, resp->data, &ct_out_len); + } + memset(&resp->esp_err, 0, sizeof(rpc_tls_close_resp) - sizeof(rpc_header_t)); + resp->esp_err = err; + resp->ct_out_len = ct_out_len; + buf->size = sizeof(rpc_tls_close_resp) + ct_out_len; + my_uart_transmit_packet(UART_CHAN, buf); +} + +void cmd_tls_stats(command_buf_t *buf) +{ + rpc_tls_session_req *req = (rpc_tls_session_req *)buf->data; + rpc_tls_stats_resp *resp = (rpc_tls_stats_resp *)buf->data; + + // Heap figures come with every reply, also when the session is gone + tls_session_stats_t stats; + int err = ESP_ERR_INVALID_ARG; + if (buf->size >= (int)sizeof(rpc_tls_session_req)) { + err = tls_get_stats(req->slot, req->tag, &stats); + } else { + tls_get_stats(TLS_SLOT_GLOBAL, 0, &stats); + } + memset(&resp->esp_err, 0, sizeof(rpc_tls_stats_resp) - sizeof(rpc_header_t)); + resp->esp_err = err; + resp->heap_free = heap_caps_get_free_size(TLS_HEAP_CAPS); + resp->heap_min = heap_caps_get_minimum_free_size(TLS_HEAP_CAPS); + resp->largest_block = heap_caps_get_largest_free_block(TLS_HEAP_CAPS); + resp->ct_in_bytes = stats.ct_in_bytes; + resp->ct_out_bytes = stats.ct_out_bytes; + resp->pt_in_bytes = stats.pt_in_bytes; + resp->pt_out_bytes = stats.pt_out_bytes; + resp->handshake_us = stats.handshake_us; + resp->tls_version = stats.tls_version; + resp->ciphersuite = stats.ciphersuite; + resp->group = stats.group; + resp->state = stats.state; + resp->sessions_open = tls_sessions_open(); + resp->stack_free = uxTaskGetStackHighWaterMark(NULL); // this runs on the TLS task + resp->esp_time = stats.esp_time; + resp->time_source = stats.time_source; + resp->entropy_source = entropy_source(); + resp->ems = stats.ems; + resp->block_max_ms = block_max_ms; + memcpy(resp->spki_sha256, stats.spki_sha256, sizeof(resp->spki_sha256)); + buf->size = sizeof(rpc_tls_stats_resp); + my_uart_transmit_packet(UART_CHAN, buf); +} + +void cmd_tls_close_all(command_buf_t *buf) +{ + rpc_espcmd_resp *resp = (rpc_espcmd_resp *)buf->data; + tls_close_all(); + resp->esp_err = ESP_OK; + buf->size = sizeof(rpc_espcmd_resp); + my_uart_transmit_packet(UART_CHAN, buf); +} + +void cmd_tls_set_ca(command_buf_t *buf) +{ + rpc_tls_set_ca_req *req = (rpc_tls_set_ca_req *)buf->data; + rpc_tls_set_ca_resp *resp = (rpc_tls_set_ca_resp *)buf->data; + + // tls_set_ca() parses the certificate before the response overwrites it + uint8_t reject = TLS_CA_REJECT_NONE; + int err = ESP_ERR_INVALID_ARG; + if ((buf->size >= (int)sizeof(rpc_tls_set_ca_req)) && (buf->size == (int)sizeof(rpc_tls_set_ca_req) + req->der_len)) { + err = tls_set_ca(req->der, req->der_len, req->ca_tag, &reject); + } else { + tls_set_ca(NULL, 0, 0, &reject); // a malformed upload still leaves no CA held + } + memset(&resp->esp_err, 0, sizeof(rpc_tls_set_ca_resp) - sizeof(rpc_header_t)); + resp->esp_err = err; + resp->reject = reject; + buf->size = sizeof(rpc_tls_set_ca_resp); + my_uart_transmit_packet(UART_CHAN, buf); +} + +// The TLS task's side: runs one TLS command and transmits its reply +void tls_serve(command_buf_t *buf) +{ + rpc_header_t *hdr = (rpc_header_t *)buf->data; + switch (hdr->command) { + case CMD_TLS_OPEN: + cmd_tls_open(buf); + break; + case CMD_TLS_STEP: + cmd_tls_step(buf); + break; + case CMD_TLS_CLOSE: + cmd_tls_close(buf); + break; + case CMD_TLS_STATS: + cmd_tls_stats(buf); + break; + case CMD_TLS_CLOSE_ALL: + cmd_tls_close_all(buf); + break; + case CMD_TLS_SET_CA: + cmd_tls_set_ca(buf); + break; + default: + cmd_not_implemented(buf); + break; + } +} + +static void tls_task(void *arg) +{ + command_buf_t *buf; + while (1) { + if (xQueueReceive(tls_queue, &buf, portMAX_DELAY) == pdTRUE) { + tls_serve(buf); + } + } +} + +// The TLS queue is full: the command's own reply shape, all zero but for ESP_ERR_TIMEOUT +static void cmd_tls_busy(command_buf_t *buf) +{ + rpc_header_t *hdr = (rpc_header_t *)buf->data; + int size; + switch (hdr->command) { + case CMD_TLS_OPEN: size = sizeof(rpc_tls_open_resp); break; + case CMD_TLS_STEP: size = sizeof(rpc_tls_step_resp); break; + case CMD_TLS_CLOSE: size = sizeof(rpc_tls_close_resp); break; + case CMD_TLS_STATS: size = sizeof(rpc_tls_stats_resp); break; + case CMD_TLS_SET_CA: size = sizeof(rpc_tls_set_ca_resp); break; + default: size = sizeof(rpc_espcmd_resp); break; + } + memset(buf->data + sizeof(rpc_header_t), 0, size - sizeof(rpc_header_t)); + ((rpc_espcmd_resp *)buf->data)->esp_err = ESP_ERR_TIMEOUT; + if (hdr->command == CMD_TLS_OPEN) { + ((rpc_tls_open_resp *)buf->data)->slot = TLS_SLOT_GLOBAL; + } else if (hdr->command == CMD_TLS_STEP) { + ((rpc_tls_step_resp *)buf->data)->alert_in = TLS_ALERT_NONE; + ((rpc_tls_step_resp *)buf->data)->alert_out = TLS_ALERT_NONE; + } + buf->size = size; + my_uart_transmit_packet(UART_CHAN, buf); +} + +// The dispatcher's side: queues the command for the TLS task, or answers it at once when the queue is full +void tls_rpc_dispatch(command_buf_t *buf) +{ + if (xQueueSend(tls_queue, &buf, 0) != pdTRUE) { + cmd_tls_busy(buf); + } +} + +// The dispatcher reports how long one command held it, in ms; TLS_STATS returns the longest +void tls_rpc_note_block(int64_t ms) +{ + if (ms > block_max_ms) { + block_max_ms = (ms > 0xFFFF) ? 0xFFFF : (uint16_t)ms; + } +} + +// TLS task on core 1, as Wi-Fi is pinned to core 0 (CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0). It runs at +// tskIDLE_PRIORITY + 1, below the dispatch task (priority 19, also core 1), so a handshake yields to command traffic. +void tls_rpc_start(void) +{ + tls_queue = xQueueCreate(TLS_QUEUE_DEPTH, sizeof(command_buf_t *)); + xTaskCreatePinnedToCore(tls_task, "TLS", TLS_TASK_STACK, NULL, tskIDLE_PRIORITY + 1, NULL, 1); +} diff --git a/software/wifi/tls/tls_rpc.h b/software/wifi/tls/tls_rpc.h new file mode 100644 index 000000000..a6005829f --- /dev/null +++ b/software/wifi/tls/tls_rpc.h @@ -0,0 +1,24 @@ +/* tls_rpc.h: what a module firmware's dispatcher needs of the TLS commands (tls_rpc.c). + * + * The firmware that builds tls_rpc.c and tls_engine.c provides, on the include path and at link time: + * rpc_calls.h rpc_header_t and rpc_espcmd_resp, and (through it) rpc_tls.h + * my_uart.h my_uart_transmit_packet(), on UART_NUM_1 + * wifi_modem.h, sntp.h entropy_source() and entropy_source_t, and the clock the engine reads + * cmd_not_implemented() answers a command the TLS task does not know (the dispatcher's own) + * and an sdkconfig with the mbedTLS 4 / PSA configuration the engine needs. */ + +#ifndef TLS_RPC_H_ +#define TLS_RPC_H_ + +#include +#include "cmd_buffer.h" + +#define TLS_TASK_STACK 8192 // twice the stack handshakes were measured to use on the dispatcher +#define TLS_QUEUE_DEPTH 2 // one request outstanding, and a CLOSE behind a step that timed out + +void tls_rpc_start(void); // create the TLS queue and task, before the dispatcher runs +void tls_rpc_dispatch(command_buf_t *buf); // CMD_TLS_*: queue for the TLS task, or answer ESP_ERR_TIMEOUT +void tls_rpc_note_block(int64_t ms); // how long the dispatcher was held by one command +void tls_serve(command_buf_t *buf); // the TLS task's side: run one command and transmit its reply + +#endif /* TLS_RPC_H_ */ diff --git a/target/pc/linux/getrandompaths/Makefile b/target/pc/linux/getrandompaths/Makefile index f4f2001db..6a4818e00 100644 --- a/target/pc/linux/getrandompaths/Makefile +++ b/target/pc/linux/getrandompaths/Makefile @@ -43,7 +43,7 @@ $(OUTPUT)/net.cc: $(SRC)/io/network/network_target.cc $(SRC)/io/command_interfac $(RESULT)/net_target: $(OUTPUT)/net.cc $(TESTDIR)/net_target_test.cc @mkdir -p $(RESULT) $(CXX) -std=gnu++11 -g -O0 $(WARN) -DU64=1 -I$(TESTDIR)/stub -I$(TESTDIR) -I$(SRC)/io/network -I$(SRC)/io/wifi \ - -I$(PATH_SW)/test/wifi_random -I$(SRC)/wifi/raw_u64/main -I$(SRC)/wifi/common \ + -I$(PATH_SW)/test/wifi_random -I$(SRC)/wifi/raw_u64/main -I$(SRC)/wifi/common -I$(SRC)/wifi/tls -I$(SRC)/io/uart \ -o $@ $(OUTPUT)/net.cc $(TESTDIR)/net_target_test.cc $(SRC)/io/wifi/wifi_random.cc $(OUTPUT)/isr.cc: $(SRC)/io/wifi/wifi_cmd.cc $(SRC)/io/uart/dma_uart.cc @@ -55,7 +55,7 @@ $(OUTPUT)/isr.cc: $(SRC)/io/wifi/wifi_cmd.cc $(SRC)/io/uart/dma_uart.cc $(RESULT)/isr: $(OUTPUT)/isr.cc $(TESTDIR)/isr_test.cc @mkdir -p $(RESULT) - $(CXX) -std=gnu++11 -g -O0 $(WARN) -DU64=1 -I$(TESTDIR)/stub -I$(TESTDIR) -I$(SRC)/io/wifi -I$(SRC)/wifi/raw_u64/main -I$(SRC)/wifi/common \ + $(CXX) -std=gnu++11 -g -O0 $(WARN) -DU64=1 -I$(TESTDIR)/stub -I$(TESTDIR) -I$(SRC)/io/wifi -I$(SRC)/wifi/raw_u64/main -I$(SRC)/wifi/common -I$(SRC)/wifi/tls -I$(SRC)/io/uart \ -o $@ $(OUTPUT)/isr.cc $(TESTDIR)/isr_test.cc $(OUTPUT)/voltages_extract.c: $(SRC)/u64ctrl/main/rpc_dispatch.c diff --git a/target/pc/linux/radioentropy/Makefile b/target/pc/linux/radioentropy/Makefile index 24fb44f34..1036bf3f9 100644 --- a/target/pc/linux/radioentropy/Makefile +++ b/target/pc/linux/radioentropy/Makefile @@ -7,7 +7,7 @@ PATH_SW = ../../../../software # rpc_calls.h of raw_u64 needs lwIP's headers, which the wifi_random test stubs out VPATH = $(PATH_SW)/wifi/common $(PATH_SW)/test/radio_entropy $(PATH_SW)/test/wifi_random \ - $(PATH_SW)/wifi/raw_u64/main + $(PATH_SW)/wifi/raw_u64/main $(PATH_SW)/wifi/tls $(PATH_SW)/io/uart CC = gcc CFLAGS = -std=gnu11 -g -O0 -Wall -Wextra -Wno-unused-parameter -pthread \ diff --git a/target/pc/linux/wifidedicated/Makefile b/target/pc/linux/wifidedicated/Makefile index 388c1a4f2..b915358f3 100644 --- a/target/pc/linux/wifidedicated/Makefile +++ b/target/pc/linux/wifidedicated/Makefile @@ -18,7 +18,7 @@ OUTPUT = output endif VPATH = $(TEST)/stub $(TEST) $(PATH_SW)/test/wifi_random $(PATH_SW)/io/wifi $(PATH_SW)/io/uart \ - $(MODULE) $(PATH_SW)/wifi/common + $(MODULE) $(PATH_SW)/wifi/common $(PATH_SW)/wifi/tls CXX = g++ CPPOPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter -DNIOS=1 -DU64=$(U64) \ diff --git a/target/pc/linux/wifirandom/Makefile b/target/pc/linux/wifirandom/Makefile index 4de32805b..168520bd8 100644 --- a/target/pc/linux/wifirandom/Makefile +++ b/target/pc/linux/wifirandom/Makefile @@ -16,7 +16,7 @@ RESULT = result OUTPUT = output endif -VPATH = $(PATH_SW)/io/wifi $(MODULE) $(PATH_SW)/wifi/common $(PATH_SW)/test/wifi_random +VPATH = $(PATH_SW)/io/wifi $(MODULE) $(PATH_SW)/wifi/common $(PATH_SW)/wifi/tls $(PATH_SW)/io/uart $(PATH_SW)/test/wifi_random CXX = g++ CPPOPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter -DU64=$(U64) \ diff --git a/target/pc/linux/wifitls/Makefile b/target/pc/linux/wifitls/Makefile index d47892263..77e02de37 100644 --- a/target/pc/linux/wifitls/Makefile +++ b/target/pc/linux/wifitls/Makefile @@ -7,13 +7,13 @@ OUTPUT = output PATH_SW = ../../../../software TEST = $(PATH_SW)/test/wifi_tls -VPATH = $(TEST)/stub $(TEST) $(PATH_SW)/io/wifi $(PATH_SW)/io/uart $(PATH_SW)/wifi/raw_u64/main +VPATH = $(TEST)/stub $(TEST) $(PATH_SW)/io/wifi $(PATH_SW)/io/uart $(PATH_SW)/wifi/raw_u64/main $(PATH_SW)/wifi/common $(PATH_SW)/wifi/tls CXX = g++ CPPOPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter -DNIOS=1 -DU64=1 \ $(addprefix -I, $(VPATH)) -TLS_SRCS = wifi_tls_test.cc world.cc wifi_tls.cc wifi_dedicated.cc +TLS_SRCS = wifi_tls_test.cc world.cc wifi_tls.cc wifi_dedicated.cc wifi_random.cc TLS_OBJS = $(addprefix $(OUTPUT)/tls/, $(TLS_SRCS:%.cc=%.o)) # The network target's sources, which a red run can point at another tree. @@ -21,7 +21,7 @@ NET_DIR = $(PATH_SW)/io/network NET_PATH = $(TEST)/netstub $(TEST)/stub $(NET_DIR) $(PATH_SW)/io/wifi $(PATH_SW)/io/command_interface NET_OPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -DNIOS=1 -DU64=1 $(addprefix -I, $(NET_PATH)) NET_SRCS = net_tls_test.cc net_world.cc ip4addr_aton.cc -NET_OBJS = $(addprefix $(OUTPUT)/net/, $(NET_SRCS:%.cc=%.o)) $(OUTPUT)/net/network_target.o $(OUTPUT)/net/network_target_tls.o +NET_OBJS = $(addprefix $(OUTPUT)/net/, $(NET_SRCS:%.cc=%.o)) $(OUTPUT)/net/network_target.o $(OUTPUT)/net/network_target_tls.o $(OUTPUT)/net/wifi_random.o .PHONY: all test clean @@ -39,6 +39,10 @@ $(OUTPUT)/tls/wifi_dedicated.o: $(PATH_SW)/io/wifi/wifi_dedicated.cc cp $< $(OUTPUT)/tls/wifi_dedicated.cc $(CXX) $(CPPOPTIONS) -c -o $@ $(OUTPUT)/tls/wifi_dedicated.cc +$(OUTPUT)/net/wifi_random.o: $(PATH_SW)/io/wifi/wifi_random.cc + @mkdir -p $(OUTPUT)/net + $(CXX) $(NET_OPTIONS) $(addprefix -I, $(PATH_SW)/wifi/raw_u64/main $(PATH_SW)/wifi/common $(PATH_SW)/wifi/tls $(PATH_SW)/io/uart) -c -o $@ $< + $(OUTPUT)/net/%.o: $(TEST)/%.cc @mkdir -p $(OUTPUT)/net $(CXX) $(NET_OPTIONS) -c -o $@ $< diff --git a/target/u64/nios2/ultimate/Makefile b/target/u64/nios2/ultimate/Makefile index 457655369..117b512a3 100755 --- a/target/u64/nios2/ultimate/Makefile +++ b/target/u64/nios2/ultimate/Makefile @@ -234,6 +234,7 @@ VPATH += $(BSP)/drivers/inc VPATH += $(PATH_SW)/6502/sidcrt/target VPATH += $(PATH_SW)/wifi/raw_u64/main VPATH += $(PATH_SW)/wifi/common +VPATH += $(PATH_SW)/wifi/tls # sock_echo.c \ # sys_calls.cc \ diff --git a/target/u64/nios2/updater/Makefile b/target/u64/nios2/updater/Makefile index 914a90b6e..71caaffed 100755 --- a/target/u64/nios2/updater/Makefile +++ b/target/u64/nios2/updater/Makefile @@ -102,6 +102,7 @@ VPATH += $(PATH_SW)/../html VPATH += $(PATH_SW)/../doc/api VPATH += $(PATH_SW)/wifi/raw_u64/main VPATH += $(PATH_SW)/wifi/common +VPATH += $(PATH_SW)/wifi/tls VPATH += $(PATH_SW)/wifi/raw_u64/build/bootloader VPATH += $(PATH_SW)/wifi/raw_u64/build/partition_table VPATH += $(PATH_SW)/wifi/raw_u64/build diff --git a/tools/ca_store/ca_store.py b/tools/ca_store/ca_store.py index 5b75c69d4..b59d3406e 100644 --- a/tools/ca_store/ca_store.py +++ b/tools/ca_store/ca_store.py @@ -52,6 +52,9 @@ # ESP-IDF 5.3's bundle, which looks up only the issuer of the topmost certificate a server # sends, so they would need hand-kept anchor roots; they keep ESP-IDF's own bundle. PROJECTS = ("software/wifi/raw_u64",) +# Source directories a project builds that are not under its own main/, relative to the project. The TLS +# engine, which attaches the bundle, is shared by the module firmware that carry it (software/wifi/tls). +SHARED_SOURCES = {"software/wifi/raw_u64": ("../tls",)} DATE_PREFIX = "## Certificate data from Mozilla as of: " BEGIN = "-----BEGIN CERTIFICATE-----" @@ -289,11 +292,20 @@ def projects(repo_root, effective=None): def attaching(project): - """Whether a project's own sources (under main/, not ESP-IDF's) attach the bundle.""" - for path in sorted((pathlib.Path(project) / "main").rglob("*")): - if (path.suffix in (".c", ".cc", ".cpp", ".h") - and ATTACH in path.read_text(errors="replace")): - return True + """Whether a project's own sources (under main/, and its SHARED_SOURCES, not ESP-IDF's) attach + the bundle.""" + project = pathlib.Path(project) + roots = [project / "main"] + for name, shared in SHARED_SOURCES.items(): + if project.resolve().as_posix().endswith("/" + name): + roots += [project / directory for directory in shared] + for root in roots: + if not root.is_dir(): + raise StoreError("%s: no %s, but it is one of the project's sources" % (project, root)) + for path in sorted(root.rglob("*")): + if (path.suffix in (".c", ".cc", ".cpp", ".h") + and ATTACH in path.read_text(errors="replace")): + return True return False diff --git a/tools/ca_store/refresh.py b/tools/ca_store/refresh.py index 7cb011fea..e0cfa379a 100644 --- a/tools/ca_store/refresh.py +++ b/tools/ca_store/refresh.py @@ -284,11 +284,18 @@ def refresh(repo_root, source=None, summary=None, now=None, regenerate=regenerat day = when.date().isoformat() carrying = ([project for project, _ in using if attaching(project)] if new_set != pins["CA_BUNDLE_SET_SHA256"] else []) - if carrying and ident_minor is None: + # One number serves one project; with several carrying the bundle, each has its own IDENT series + names = [pathlib.Path(os.path.relpath(p, repo_root)).as_posix() for p in carrying] + minors = (ident_minor if isinstance(ident_minor, dict) + else {names[0]: ident_minor} if ident_minor is not None and len(names) == 1 else {}) + missing = [name for name in names if minors.get(name) is None] + if missing: raise StoreError("the bundle's certificates changed, so %s needs a new IDENT_MINOR: pass " - "--ident-minor N with a number allocated for this image" - % ", ".join(os.path.relpath(p, repo_root) for p in carrying)) - bumps = [bump_ident(project, day, ident_minor) for project in carrying] + "--ident-minor N with a number allocated for this image%s" + % (", ".join(missing), + " (--ident-minor PROJECT=N for each, as they have separate versions)" + if len(names) > 1 else "")) + bumps = [bump_ident(project, day, minors[name]) for project, name in zip(carrying, names)] write_atomically(pem_path, data) write_pins(pins_path, {"CA_MOZILLA_DATE": iso(date), @@ -349,20 +356,37 @@ def describe(old_text, text, url, ref, ref_date, date, old_date, count, set_chan return "\n".join(lines) + "\n" +def parse_ident_minors(values): + """--ident-minor values as refresh() takes them: None, one number, or {project: number}.""" + if not values: + return None + try: + if all("=" not in value for value in values) and len(values) == 1: + return int(values[0]) + pairs = [value.partition("=") for value in values] + if any(not sep for _, sep, _ in pairs): + raise ValueError + return {name: int(number) for name, _, number in pairs} + except ValueError: + raise StoreError("--ident-minor takes N, or PROJECT=N once for each project: %s" + % " ".join(values)) + + def main(argv=None): parser = argparse.ArgumentParser(description=__doc__.split("\n")[0]) parser.add_argument("--repo-root", default=str(REPO_ROOT)) parser.add_argument("--source", help="fetch from this URL instead of CA_SOURCE_URL " "(its sum from the same URL + .sha256)") parser.add_argument("--summary", help="write what changed to this file") - parser.add_argument("--ident-minor", type=int, + parser.add_argument("--ident-minor", action="append", metavar="[PROJECT=]N", help="the IDENT_MINOR allocated for the image, needed when the " - "certificates change") + "certificates change. With more than one project carrying the " + "bundle, once for each as PROJECT=N (PROJECT as in ca_store.PROJECTS)") arguments = parser.parse_args(argv) repo_root = pathlib.Path(arguments.repo_root) try: written = refresh(repo_root, arguments.source, arguments.summary, - ident_minor=arguments.ident_minor) + ident_minor=parse_ident_minors(arguments.ident_minor)) except (StoreError, OSError) as error: print("refresh: %s" % error, file=sys.stderr) return 1 diff --git a/tools/ca_store/test_ca_store.py b/tools/ca_store/test_ca_store.py index 66df3e9fc..55eb67996 100644 --- a/tools/ca_store/test_ca_store.py +++ b/tools/ca_store/test_ca_store.py @@ -120,7 +120,10 @@ def __init__(self, root, date=OLD_DATE, max_certs=200): % (ca_store.iso(date), hashlib.sha256(text.encode()).hexdigest(), OLD_REF, ca_store.bundle_set_sha256(ca_store.certificates(text)))) self.bridge = self.project(BRIDGE, "../ca_store/cacert.pem", 6, max_certs) - (self.bridge / "main/tls.c").write_text( + # The engine that attaches the bundle is in the directory the module firmware share + self.shared = self.root / "software/wifi/tls" + self.shared.mkdir(parents=True) + (self.shared / "tls_engine.c").write_text( "void setup(void) { esp_crt_bundle_attach(&conf); }\n") self.sdkconfig = self.bridge / "sdkconfig" other = self.root / "software/u64ctrl" @@ -436,6 +439,17 @@ def test_attaching_reads_only_the_projects_own_sources(self): self.assertTrue(ca_store.attaching(self.tree.bridge)) self.assertFalse(ca_store.attaching(self.tree.root / "software/u64ctrl")) + def test_attaching_finds_the_engine_in_the_shared_directory_only_for_its_users(self): + (self.tree.shared / "tls_engine.c").write_text("void setup(void) {}\n") + self.assertFalse(ca_store.attaching(self.tree.bridge)) + (self.tree.bridge / "main/own.c").write_text("esp_crt_bundle_attach(&conf);\n") + self.assertTrue(ca_store.attaching(self.tree.bridge)) + + def test_attaching_fails_when_a_shared_directory_is_missing(self): + shutil.rmtree(self.tree.shared) + with self.assertRaisesRegex(ca_store.StoreError, "no .*tls"): + ca_store.attaching(self.tree.bridge) + def test_two_roots_with_one_subject_fail(self): store = ca_store.certificates(self.tree.pem.read_text()) double = with_key(store[0], ca_store.subject_and_key(store[1])[1]) @@ -485,7 +499,16 @@ def test_every_project_that_uses_the_store_has_a_version_to_bump(self): self.assertIn('%s"' % version, text) def test_the_bridge_cmake_runs_the_check_at_configure_and_at_every_build(self): - cmake = (REPO_ROOT / BRIDGE / "CMakeLists.txt").read_text() + project = (REPO_ROOT / BRIDGE / "CMakeLists.txt").read_text() + self.assertIn("ca_store/ca_store.cmake", project) + self.assertLess(project.index("project(bridge)"), project.index("ca_store.cmake")) + cmake = (REPO_ROOT / ca_store.STORE_DIR / "ca_store.cmake").read_text() + # Included from any project, at any depth: the store is found from this file's own directory, + # and the project being checked is the one that includes it + self.assertIn("set(CA_STORE ${CMAKE_CURRENT_LIST_DIR})", cmake) + self.assertIn("--project ${CMAKE_SOURCE_DIR}", cmake) + self.assertNotIn("--project ${CMAKE_CURRENT_LIST_DIR}", cmake) + self.assertNotIn("${CMAKE_SOURCE_DIR}/..", cmake) self.assertIn("tools/ca_store/ca_store.py", cmake) self.assertIn("FATAL_ERROR", cmake) self.assertIn("--sdkconfig-json", cmake) diff --git a/tools/ca_store/test_refresh.py b/tools/ca_store/test_refresh.py index 555b4a0cf..66038f01c 100644 --- a/tools/ca_store/test_refresh.py +++ b/tools/ca_store/test_refresh.py @@ -20,7 +20,7 @@ import ca_store import refresh -from test_ca_store import (COMMITTED, HEADER, NEW_DATE, NEW_ISO, NEW_REF, NOW, OLD_DATE, +from test_ca_store import (BRIDGE, COMMITTED, HEADER, NEW_DATE, NEW_ISO, NEW_REF, NOW, OLD_DATE, OLD_ISO, OLD_REF, REPO_ROOT, Tree, der_length, pem, pem_block, rekeyed) REF_DATE = "2026-09-08T20:22:24Z" @@ -207,6 +207,24 @@ def test_the_command_line_reports_a_failure_with_a_nonzero_status(self): self.assertIn("sha256 mismatch", stderr.getvalue()) + def test_a_version_given_for_the_project_by_name_bumps_it(self): + self.refresh(pem(NEW_DATE, first=5, count=30), ident_minor={BRIDGE: 9}) + self.assertIn("#define IDENT_MINOR 9", (self.tree.bridge / "main/rpc_dispatch.h").read_text()) + + def test_a_version_for_another_project_is_not_one_for_the_bridge(self): + before = self.tree.snapshot() + with self.assertRaisesRegex(ca_store.StoreError, "software/wifi/raw_u64 needs a new IDENT_MINOR"): + self.refresh(pem(NEW_DATE, first=5, count=30), ident_minor={"software/u64ctrl": 9}) + self.assertEqual(self.tree.snapshot(), before) + + def test_the_command_line_takes_one_number_or_one_per_project(self): + self.assertIsNone(refresh.parse_ident_minors(None)) + self.assertEqual(refresh.parse_ident_minors(["7"]), 7) + self.assertEqual(refresh.parse_ident_minors(["a/b=7", "c=8"]), {"a/b": 7, "c": 8}) + for bad in (["7", "8"], ["a=x"], ["7", "c=8"]): + with self.assertRaises(ca_store.StoreError): + refresh.parse_ident_minors(bad) + def test_changed_certificates_without_an_allocated_version_write_nothing(self): # The next minor is not necessarily free on a development line. before = self.tree.snapshot() @@ -338,7 +356,7 @@ def older(old, new): self.assertEqual(self.tree.snapshot(), before) def test_no_module_attaching_the_bundle_means_no_bump(self): - (self.tree.bridge / "main/tls.c").unlink() + (self.tree.shared / "tls_engine.c").unlink() summary = pathlib.Path(self.tmp) / "summary.md" written = self.refresh(pem(NEW_DATE, first=5, count=30), summary=summary) self.assertEqual(written, [self.tree.pem, self.tree.pins]) From 6b838d7fff25d6c5180140a7bd7844d99cada75b Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 19:18:51 -0500 Subject: [PATCH 55/95] Answer the peer's close_notify with our own on TLS client sockets The ESP32 engine ended the session on the peer's close_notify without sending one back, so the peer saw a bare FIN. RFC 8446 6.1 and RFC 5246 7.2.1 want the reply (tls_close() already sends one for our own CLOSE). The engine now calls mbedtls_ssl_close_notify() on MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY, so it goes out with the step that reports CLOSED. The Ultimate no longer turns a failed send of that reply (the peer may have closed TCP behind its own) into 12,SEND ERROR. Tests: the host fake module answers as the engine does and a new check covers the refused send; the E2E fixture records whether the client answered the server's close_notify (S6), and the mock gains the no-notify-reply mutant. No IDENT change: the module is still the unreleased 1.8. Co-Authored-By: Claude Sonnet 5.5 --- software/io/network/network_target_tls.cc | 5 +++-- software/test/wifi_tls/net_tls_test.cc | 12 +++++++++++- software/test/wifi_tls/net_world.cc | 7 +++++++ software/wifi/tls/tls_engine.c | 3 +++ tests/e2e/io/command_interface/net_tls_fixture.py | 15 +++++++++++++-- tests/e2e/io/command_interface/net_tls_mock.py | 9 ++++++++- .../e2e/io/command_interface/net_tls_selftest.py | 2 ++ tests/e2e/io/command_interface/net_tls_test.py | 7 +++++++ 8 files changed, 54 insertions(+), 6 deletions(-) diff --git a/software/io/network/network_target_tls.cc b/software/io/network/network_target_tls.cc index 04105a8e9..c9eb088dd 100644 --- a/software/io/network/network_target_tls.cc +++ b/software/io/network/network_target_tls.cc @@ -1367,8 +1367,9 @@ void NetworkTarget :: tls_read(TlsSocket *e, uint32_t length, Message **reply, M if (error < 0) { break; } - // After a receive error the peer is gone; its alert need not arrive. - if (error && !e->rx_err && (st.state != WIFI_TLS_FAILED)) { + // After a receive error the peer is gone; its alert need not arrive. Nor need our close_notify + // after the peer's: it may have closed the TCP connection behind it. + if (error && !e->rx_err && (st.state != WIFI_TLS_FAILED) && (st.state != WIFI_TLS_CLOSED)) { char text[NET_TLS_STICKY_MAX]; put_dec(put_text(text, "12,SEND ERROR: "), error); tls_fail(e, text); diff --git a/software/test/wifi_tls/net_tls_test.cc b/software/test/wifi_tls/net_tls_test.cc index de7ecd85c..b0fe5f82c 100644 --- a/software/test/wifi_tls/net_tls_test.cc +++ b/software/test/wifi_tls/net_tls_test.cc @@ -854,11 +854,21 @@ static void test_read(void) bytes got = read_all(h, 1472, &last); check(got == expected(5, 3000), "read: all 3000 B of one record, in order (%d)", (int)got.size()); check(last == "01,CONNECTION CLOSED BY HOST" && !sock(h).open, "read: then $0000 + 01, handle GONE (S6)"); - check(!sock(h).srv.saw_notify, "read: no close_notify of ours after the peer's (module freed it)"); + check(sock(h).srv.saw_notify, "read: the peer's close_notify is answered with ours (RFC 8446 6.1)"); check(close_cmd(h).status == "12,ERROR ON CLOSE: " + num(EBADF), "read: CLOSE afterwards -> 12,…: 9"); r = read_cmd(h, 10); check(header(r) == 0xFFFF && r.status == "02,NO DATA: " + num(EBADF), "read: READ afterwards -> 02,NO DATA: 9"); + // The peer closed TCP behind its close_notify: our answer finds a dead socket, which is not an error. + fresh(); + h = open_ok(); + server_push(h, EV_DATA, cat(record('D', 100, 7), record('C', 0))); + sock(h).srv.send_err_from = sock(h).send_calls + 1; + sock(h).srv.send_err_late = EPIPE; + got = read_all(h, 1472, &last); + check(got == expected(7, 100) && last == "01,CONNECTION CLOSED BY HOST", + "read: our close_notify refused by a closed peer -> all bytes, then 01 (%s)", last.c_str()); + fresh(); h = open_ok(); server_push(h, EV_DATA, record('D', 3000, 6)); diff --git a/software/test/wifi_tls/net_world.cc b/software/test/wifi_tls/net_world.cc index 85482507f..f88556b9e 100644 --- a/software/test/wifi_tls/net_world.cc +++ b/software/test/wifi_tls/net_world.cc @@ -833,6 +833,13 @@ int wifi_tls_step(uint8_t slot, uint16_t tag, wifi_tls_step_t *st, uint32_t time if (s.terminal && s.pt.empty()) { if (s.terminal == 'C') { s.state = WIFI_TLS_CLOSED; + // The engine answers the peer's close_notify with ours, in the same step + bytes notify = record('C', 0); + if (ct + notify.size() <= st->ct_out_room) { + memcpy(st->ct_out + ct, notify.data(), notify.size()); + ct += notify.size(); + st->ct_out_len = ct; + } } else if (pt == 0) { s.state = WIFI_TLS_FAILED; if (s.terminal == 'A') { diff --git a/software/wifi/tls/tls_engine.c b/software/wifi/tls/tls_engine.c index a3d8dc3d9..85990ec26 100644 --- a/software/wifi/tls/tls_engine.c +++ b/software/wifi/tls/tls_engine.c @@ -692,6 +692,9 @@ int tls_step(uint8_t slot, uint16_t tag, uint8_t flags, const uint8_t *ct_in, in // connection closed, because tls_bio_recv() never reports end of input. continue; } else if (n == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { + // RFC 8446 6.1 / RFC 5246 7.2.1: answer the peer's close_notify with our own. Best effort, as in + // tls_close(); it lands in out_buf and goes out with this step (TLS_ALERT_ROOM is kept free for it). + mbedtls_ssl_close_notify(&s->ssl); s->stats.state = TLS_STATE_CLOSED; } else { ret = n; diff --git a/tests/e2e/io/command_interface/net_tls_fixture.py b/tests/e2e/io/command_interface/net_tls_fixture.py index 5964c72b3..da0f62f3b 100644 --- a/tests/e2e/io/command_interface/net_tls_fixture.py +++ b/tests/e2e/io/command_interface/net_tls_fixture.py @@ -53,6 +53,8 @@ # took about 250 s to read S13's 16 KB record), yet still bound every wait; # TlsServer.close() ends whatever is still open. CONN_TIMEOUT = 600.0 +# How long the server waits for the client's answer to its close_notify. +NOTIFY_REPLY_WAIT = 120.0 def payload(seed: int, length: int) -> bytes: @@ -236,12 +238,17 @@ class ConnLog: # How the client ended it: "close_notify", "fin", "reset", "open" (still # open when the server gave up), or "handshake" (it never completed). peer_end: str = "open" + # After the server's own close_notify ("close_notify" mode): whether the + # client answered with one before it closed (True), or ended without it + # (False). None when the server did not close that way. + notify_reply: bool | None = None error: str | None = None done: threading.Event = field(default_factory=threading.Event) def as_dict(self) -> dict: return {"peer": self.peer, "sni": self.sni, "version": self.version, "cipher": self.cipher, "received": len(self.received), + "notify_reply": self.notify_reply, "received_sha256": hashlib.sha256(self.received).hexdigest(), "sent": self.sent, "peer_end": self.peer_end, "error": self.error} @@ -349,10 +356,14 @@ def _serve(self, raw: socket.socket, log: ConnLog) -> None: # Let the device's reads be what ends the stream. time.sleep(0.5) if b.then == "close_notify": + # SSL_shutdown sends ours and waits for the peer's. It returns only when the client's + # close_notify arrived; a bare FIN or reset raises instead. + tls.settimeout(NOTIFY_REPLY_WAIT) try: - tls.unwrap() # close_notify, then the peer's, on the same socket + tls.unwrap() + log.notify_reply = True except (ssl.SSLError, OSError): - pass + log.notify_reply = False # SSLSocket.shutdown drops the TLS layer first, so after # "fin" this is a bare FIN with no close_notify ahead of it. tls.shutdown(socket.SHUT_WR) diff --git a/tests/e2e/io/command_interface/net_tls_mock.py b/tests/e2e/io/command_interface/net_tls_mock.py index 6e4188428..63498a59f 100644 --- a/tests/e2e/io/command_interface/net_tls_mock.py +++ b/tests/e2e/io/command_interface/net_tls_mock.py @@ -16,6 +16,7 @@ "release-noop" $25 never closes anything (S19e must catch it) "group-zero" the OPEN reply's group is 0 (S2 must catch it) "info-ff-claims" `03 23 FF` claims every session (S19e2b must catch it) + "no-notify-reply" the peer's close_notify is not answered with ours (S6 must catch it) "abort-shortens" an ABORT ends PROCESSING early: bit 2 clears at the ABORT, while the open still completes behind it (S19e must catch it) @@ -46,7 +47,7 @@ x509 = None MUTANTS = ("bundle-accepts-all", "release-noop", "group-zero", "info-ff-claims", - "abort-shortens") + "abort-shortens", "no-notify-reply") FLAVOURS = ("tls", "stock", *MUTANTS) MAX_TLS = 2 @@ -261,6 +262,12 @@ def _read(self, command: bytes): return b"\x00\x00", entry.sticky if not data: self.handles.pop(handle, None) + if entry.kind == "tls" and self.flavour != "no-notify-reply": + try: + entry.sock.settimeout(0.5) + entry.sock.unwrap() # the answer to the peer's close_notify + except (OSError, ValueError, ssl.SSLError): + pass entry.sock.close() return b"\x00\x00", status("01,CONNECTION CLOSED BY HOST") return len(data).to_bytes(2, "little") + data, STATUS_OK diff --git a/tests/e2e/io/command_interface/net_tls_selftest.py b/tests/e2e/io/command_interface/net_tls_selftest.py index d8986bcb5..c1fe1a017 100644 --- a/tests/e2e/io/command_interface/net_tls_selftest.py +++ b/tests/e2e/io/command_interface/net_tls_selftest.py @@ -675,6 +675,8 @@ def main() -> int: ("info-ff-claims", ["S0", "S19e", "S19e2b"])): outcomes = world.run(flavour, sids) ok &= judge_flavour(flavour, outcomes, {sid: "FAIL" for sid in sids[1:]}) + outcomes = world.run("no-notify-reply", ["S0", "S6"]) + ok &= judge_flavour("no-notify-reply", outcomes, {"S6": "FAIL"}) outcomes = world.run("abort-shortens", ["S0", "S19e"]) ok &= judge_flavour("abort-shortens", outcomes, {"S19e": "FAIL"}) if not args.quick: diff --git a/tests/e2e/io/command_interface/net_tls_test.py b/tests/e2e/io/command_interface/net_tls_test.py index 0cd42c957..c1bc18bc3 100644 --- a/tests/e2e/io/command_interface/net_tls_test.py +++ b/tests/e2e/io/command_interface/net_tls_test.py @@ -766,6 +766,13 @@ def s6_peer_close(ctx: Ctx, then: str = "close_notify") -> None: with check("the handle is GONE: a CLOSE answers 12,ERROR ON CLOSE: 9; INFO [2] = 0"): ctx.expect(ctx.close(reply.handle), STATUS_CLOSE_UNOWNED, "CLOSE after the end") ctx.entries(0, "after the end") + if then == "close_notify": + with check("the server saw OUR close_notify in answer to its own (RFC 8446 6.1, RFC 5246 7.2.1)"): + log = one_connection(server) + ctx.note("conn", log.as_dict()) + if log.notify_reply is not True: + raise Failure(f"the client ended without answering close_notify (notify_reply {log.notify_reply}, " + f"peer_end {log.peer_end})") def s7_truncation(ctx: Ctx) -> None: From 0c95b64bdbd770849456ba81fbf1cecedea2496d Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 26 Oct 2026 09:11:37 -0500 Subject: [PATCH 56/95] Keep the U64 WiFi bridge command dispatch and TLS block timing in IRAM Splitting dispatch_command() out of dispatch() left the per-frame command path (cmd_send_eth_packet is inlined into it) in flash, since the linker fragment only named dispatch(). Name dispatch_command() and tls_rpc_note_block(), which dispatch_command() calls for every command, so the whole receive-to-transmit path stays out of flash. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/main/linker.lf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/software/wifi/raw_u64/main/linker.lf b/software/wifi/raw_u64/main/linker.lf index cb9337427..8b37f736a 100644 --- a/software/wifi/raw_u64/main/linker.lf +++ b/software/wifi/raw_u64/main/linker.lf @@ -5,6 +5,8 @@ entries: cmd_buffer (noflash) wifi_modem:hacked_recv (noflash) rpc_dispatch:dispatch (noflash) + rpc_dispatch:dispatch_command (noflash) + tls_rpc:tls_rpc_note_block (noflash) [mapping:raw_u64_netif] archive: libesp_netif.a From 405e234cad32d77d39c3b83dad572a1c27e48c20 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 30 Oct 2026 14:04:52 -0500 Subject: [PATCH 57/95] Build the raw_u64 certificate bundle from the control module's root list raw_u64 vendored a second copy of Mozilla's root store, software/wifi/ca_store, with its own pins and refresh tooling (tools/ca_store). Point its custom bundle at the one list the tree has, software/u64ctrl/ca/cacert.pem, and drop the second store, its CMake check, its unit tests (Makefile target and CI step) and the documentation of both. The list is curl's of 2026-10-20 (118 roots), without the emSign roots G3, C1 and C3 that the 2026-09-25 copy held. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build.yml | 9 - Makefile | 8 +- doc/uci_tls.md | 2 +- software/u64ctrl/ca/README.md | 5 +- software/wifi/ca_store/CA_PINS | 18 - software/wifi/ca_store/ca_store.cmake | 21 - software/wifi/ca_store/cacert.pem | 2950 ------------------------- software/wifi/raw_u64/CMakeLists.txt | 2 - software/wifi/raw_u64/README.md | 59 +- software/wifi/raw_u64/sdkconfig | 2 +- tools/ca_store/ca_store.py | 492 ----- tools/ca_store/refresh.py | 401 ---- tools/ca_store/test_ca_store.py | 520 ----- tools/ca_store/test_refresh.py | 464 ---- 14 files changed, 15 insertions(+), 4938 deletions(-) delete mode 100644 software/wifi/ca_store/CA_PINS delete mode 100644 software/wifi/ca_store/ca_store.cmake delete mode 100644 software/wifi/ca_store/cacert.pem delete mode 100644 tools/ca_store/ca_store.py delete mode 100644 tools/ca_store/refresh.py delete mode 100644 tools/ca_store/test_ca_store.py delete mode 100644 tools/ca_store/test_refresh.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6e68f0b1a..8f239a53c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -193,15 +193,6 @@ jobs: -v /opt/build-tools:/mnt/build-tools:ro \ -v $GITHUB_WORKSPACE:/mnt/project:rw my_docker_image /bin/bash -c "cd /mnt/project && make -C target/pc/linux/wifitls test" - # The checks on the vendored root store the ESP32 bridge builds its certificate - # bundle from, and on the tool that refreshes it. Standard library only; in a - # stock Python image for the same reason as the lint step above. - - name: Test CA Store - run: | - docker run --rm -v $GITHUB_WORKSPACE:/mnt/project:rw --workdir /mnt/project \ - --user $(id -u):$(id -g) -e HOME=/tmp python:3.12-slim \ - python3 -m unittest discover -s tools/ca_store -p "test_*.py" - - name: Cache U2 FPGA id: cache-u2 uses: actions/cache@v6 diff --git a/Makefile b/Makefile index 5788068b4..6fcfc993b 100755 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ OPENAPI = python3 tools/openapi/generate.py # make openapi_validate PYTHON=/path/to/venv/bin/python PYTHON ?= python3 -.PHONY: all app_space app_space_test d81_tracks_test observability_test lint_test host_tests host_tests_idf6 openapi openapi_check openapi_test openapi_validate ca_store_test +.PHONY: all app_space app_space_test d81_tracks_test observability_test lint_test host_tests host_tests_idf6 openapi openapi_check openapi_test openapi_validate all: esp32 u2_rv u2plus u2pl u64 u64ii @$(APP_SPACE) report @@ -92,12 +92,6 @@ host_tests: @$(MAKE) -C target/pc/linux/getrandompaths test @$(MAKE) -C target/pc/linux/wifitls test -# The Mozilla root store the ESP32 bridge (raw_u64) builds its certificate bundle from -# (software/wifi/ca_store). Its build checks the store at every configure; these are the -# tests of that check and of tools/ca_store/refresh.py. See software/wifi/raw_u64/README.md. -ca_store_test: - @python3 -m unittest discover -s tools/ca_store -p "test_*.py" - esp32: esp32_raw_u64 esp32_raw_c3 esp32_u64ctrl esp32_clean: esp32_raw_u64_clean esp32_raw_c3_clean esp32_u64ctrl_clean diff --git a/doc/uci_tls.md b/doc/uci_tls.md index f1f8085ac..338344ad0 100644 --- a/doc/uci_tls.md +++ b/doc/uci_tls.md @@ -245,7 +245,7 @@ client matches on those. | Trust | Verifies against | |---|---| -| 0 BUNDLE | the Mozilla root store built into the module (`software/wifi/ca_store`) | +| 0 BUNDLE | the Mozilla root store built into the module (`software/u64ctrl/ca/cacert.pem`, the list the control module trusts too) | | 1 CUSTOM | the one CA uploaded with `$22`, and nothing else | | 2 PIN | the SHA-256 of the server leaf's SubjectPublicKeyInfo. The certificate chain and name are not checked; key usage and extended key usage still are | diff --git a/software/u64ctrl/ca/README.md b/software/u64ctrl/ca/README.md index a27dbe75a..35dd59550 100644 --- a/software/u64ctrl/ca/README.md +++ b/software/u64ctrl/ca/README.md @@ -1,4 +1,4 @@ -# Root list for u64ctrl's network recovery +# Root list for u64ctrl's network recovery and the raw_u64 module's TLS `cacert.pem` is curl's copy of Mozilla's root list of 2026-10-20 (118 roots), unmodified; its sha256 is pinned in `tests/lib/u64ctrl_ca_test.py` (`CACERT_SHA256`, the value curl publishes next to the file). u64ctrl's recovery trusts it @@ -22,7 +22,8 @@ unless the hash matches, the file is not older than the committed one, the file including ISRG Root X1 and X2 and none in `REMOVED`, and both recovery servers verify against it. Then it replaces `cacert.pem`, updates `CACERT_SHA256` and the date above, and prints the roots added and removed. Review that output, add the removed roots to `REMOVED` in `tests/lib/u64ctrl_ca_test.py`, run that test (again after a firmware build), -and bump `IDENT_MINOR` in `main/rpc_dispatch.h`. The test also fails when the list is more than a year old +and bump `IDENT_MINOR` in `main/rpc_dispatch.h` and in `software/wifi/raw_u64/main/rpc_dispatch.h`, which builds +its bundle from the same file. The test also fails when the list is more than a year old (`MAX_AGE_DAYS`), without needing the network. If the test fails only because the list is older than `MAX_AGE_DAYS` and `refresh.py` says "no change", Mozilla's data diff --git a/software/wifi/ca_store/CA_PINS b/software/wifi/ca_store/CA_PINS deleted file mode 100644 index fb0ee3233..000000000 --- a/software/wifi/ca_store/CA_PINS +++ /dev/null @@ -1,18 +0,0 @@ -# The ESP32 bridge's TLS root store: cacert.pem beside this file (curl's extract of Mozilla's certdata.txt), the -# only input of the bundle (sdkconfig CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH). Every configure runs -# `tools/ca_store/ca_store.py check`, which fails the build on a mismatch; only refresh.py changes the two. -CA_SOURCE_URL=https://curl.se/ca/cacert.pem -# The "Certificate data from Mozilla as of:" line of cacert.pem, in UTC as ISO 8601. -CA_MOZILLA_DATE=2026-09-25T03:12:01Z -CA_SHA256=a41b5d356aea97a529fe27e0f7316d2f9d946d75927476cf9cf1b90637d00505 -# The certdata.txt, on GitHub, that cacert.pem was regenerated from with curl's mk-ca-bundle.pl -# to check it byte for byte: a second origin besides curl.se. -CA_CERTDATA_REF=mozilla-firefox/firefox@f6dd0159931e536991eaaa02d839bdffb92c3f22 -# sha256 over the sorted DER of every certificate in cacert.pem (the bundle's set): `check` fails when the set -# changes and this does not. refresh.py, which moves it, bumps IDENT_MINOR of every project attaching the -# bundle, since the updater reflashes a module only for a new version. -CA_BUNDLE_SET_SHA256=4e8015669428e25eef4dc88b4c7240a2466f9c9d84227fa7a7691d3904cf1aeb -# The ESP32 build warns when CA_MOZILLA_DATE is older than this, and a release build -# (RELEASE=1 in the environment of the configure step) fails. -# Mozilla's data changed at most 107 days apart in the ten updates to 2026-09-25. -CA_MAX_AGE_DAYS=180 diff --git a/software/wifi/ca_store/ca_store.cmake b/software/wifi/ca_store/ca_store.cmake deleted file mode 100644 index 6e9c5e653..000000000 --- a/software/wifi/ca_store/ca_store.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# The certificate bundle is the vendored Mozilla root store, software/wifi/ca_store/cacert.pem. ca_store.py checks it against -# CA_PINS and the configuration this build really uses (sdkconfig.json) at every configure and again at every build, -# before the bundle is made, so an earlier configure cannot skip it. RELEASE=1 also fails a stale store. See README.md. -# Include this from a project's own CMakeLists.txt, after project(), wherever the project is. The store and the check -# are found from this file (CMAKE_CURRENT_LIST_DIR here is the store's own directory); the project being checked is -# CMAKE_SOURCE_DIR. -set(CA_STORE ${CMAKE_CURRENT_LIST_DIR}) -set(CA_STORE_CHECK ${CMAKE_CURRENT_LIST_DIR}/../../../tools/ca_store/ca_store.py) -set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CA_STORE}/cacert.pem ${CA_STORE}/CA_PINS ${CA_STORE_CHECK}) -idf_build_get_property(_python PYTHON) -idf_build_get_property(_sdkconfig_json SDKCONFIG_JSON) -set(_ca_check ${_python} ${CA_STORE_CHECK} check --project ${CMAKE_SOURCE_DIR} --sdkconfig-json ${_sdkconfig_json}) -execute_process(COMMAND ${_ca_check} RESULT_VARIABLE _ca_rc) -if(NOT _ca_rc EQUAL 0) - message(FATAL_ERROR "The Mozilla root store (software/wifi/ca_store) failed its check; see README.md") -endif() -add_custom_target(ca_store_check ALL COMMAND ${_ca_check} COMMENT "Checking the Mozilla root store" VERBATIM) -# The bundle (and so the mbedtls library and the image) waits for it -if(TARGET custom_bundle) - add_dependencies(custom_bundle ca_store_check) -endif() diff --git a/software/wifi/ca_store/cacert.pem b/software/wifi/ca_store/cacert.pem deleted file mode 100644 index 4b694a502..000000000 --- a/software/wifi/ca_store/cacert.pem +++ /dev/null @@ -1,2950 +0,0 @@ -## -## Bundle of CA Root Certificates -## -## Certificate data from Mozilla as of: Fri Sep 25 03:12:01 2026 GMT -## -## Find updated versions here: https://curl.se/docs/caextract.html -## -## This is a bundle of X.509 certificates of public Certificate Authorities -## (CA). These were automatically extracted from Mozilla's root certificates -## file (certdata.txt). This file can be found in the mozilla source tree: -## https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/release/security/nss/lib/ckfw/builtins/certdata.txt -## -## It contains the certificates in PEM format and therefore -## can be directly used with curl / libcurl / php_curl, or with -## an Apache+mod_ssl webserver for SSL client authentication. -## Configure this file as the SSLCACertificateFile. -## -## Conversion done with mk-ca-bundle.pl version 1.33. -## SHA256: beb7e6dfe6499926e52c075c27bcfbe4c957f8609c575b3860273ae2806f63eb -## - - -COMODO ECC Certification Authority -================================== ------BEGIN CERTIFICATE----- -MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC -R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE -ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB -dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix -GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR -Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo -b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X -4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni -wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E -BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG -FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA -U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY= ------END CERTIFICATE----- - -NetLock Arany (Class Gold) FÅ‘tanúsítvány -======================================== ------BEG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2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW -qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta -YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC -bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna -NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu -dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E= ------END CERTIFICATE----- - -Microsec e-Szigno Root CA 2009 -============================== ------BEGIN CERTIFICATE----- -MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER -MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv -c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o -dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE -BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt -U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw -DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA -fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG -0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA -pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm -1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC -AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf -QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE -FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o -lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX -I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775 -tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02 -yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi -LXpUq3DDfSJlgnCW ------END CERTIFICATE----- - -GlobalSign Root CA - R3 -======================= ------BEGIN CERTIFICATE----- -MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv -YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh -bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT -aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln -bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt -iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ -0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3 -rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl -OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2 -xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE -FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7 -lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8 -EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E -bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18 -YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r -kpeDMdmztcpHWD9f ------END CERTIFICATE----- - -Izenpe.com -========== ------BEGIN CERTIFICATE----- -MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG -EwJFUzEU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zBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx -MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O -BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l -Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga -kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q -hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs -g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5 -aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5 -nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC -ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo -Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z -WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw== ------END CERTIFICATE----- - -Go Daddy Root Certificate Authority - G2 -======================================== ------BEGIN CERTIFICATE----- -MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT -B0FyaXpvbmExEzARBgNVBAcTClNjb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ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO -LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1 ------END CERTIFICATE----- - -Starfield Root Certificate Authority - G2 -========================================= ------BEGIN CERTIFICATE----- -MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT -B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s -b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0 -eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw -DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg -VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB -dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv -W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs -bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk -N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf -ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU -JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC -AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol -TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx -4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw -F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K -pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ -c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0 ------END CERTIFICATE----- - -Starfield Services Root Certificate Authority - G2 -================================================== ------BEGIN CERTIFICATE----- -MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT -B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s -b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl -IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV -BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT -dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg -Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC -AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2 -h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa -hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP -LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB -rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw -AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG -SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP -E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy -xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd -iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza -YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6 ------END CERTIFICATE----- - -Certum Trusted Network CA -========================= ------BEGIN CERTIFICATE----- -MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK -ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0E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zT1fs45mtk48VH3Tyw= ------END CERTIFICATE----- - -TWCA Root Certification Authority -================================= ------BEGIN CERTIFICATE----- -MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ -VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh -dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG -EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB -IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK -AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx -QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC -oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP -4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r -y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB -BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG -9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC -mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW -QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY -T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny -Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw== ------END CERTIFICATE----- - -Security Communication RootCA2 -============================== ------BEGIN CERTIFICATE----- -MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc -U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh -dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC -SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy -aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB -ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++ -+T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R -3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV -spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K -EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8 -QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB -CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj -u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk -3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q -tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29 -mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03 ------END CERTIFICATE----- - -Actalis Authentication Root CA -============================== ------BEGIN CERTIFICATE----- -MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM -BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE -AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky -MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz -IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290 -IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ -wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa -by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6 -zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gC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CJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz -lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem -OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9 -vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg== ------END CERTIFICATE----- - -Buypass Class 2 Root CA -======================= ------BEGIN CERTIFICATE----- -MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU -QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X -DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1 -eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw -DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1 -g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn -9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b -/+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU -CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff -awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DB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WOIv4x3kqdbQCtCev9eBCfHJxyYN -rJgWVqA= ------END CERTIFICATE----- - -Buypass Class 3 Root CA -======================= ------BEGIN CERTIFICATE----- -MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU -QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X -DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1 -eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw -DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH -sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR -5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh -7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ -ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH -2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV -/afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ -RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA -Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq -j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD -VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF -AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV -cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G -uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG -Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8 -ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2 -KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz -6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug -UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe -eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi -Cp/HuZc= ------END CERTIFICATE----- - -T-TeleSec GlobalRoot Class 3 -============================ ------BEGIN CERTIFICATE----- -MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM -IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQ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LZGOMivgkeGj5asuRrDFR6fUNOuIml -e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw== ------END CERTIFICATE----- - -D-TRUST Root Class 3 CA 2 2009 -============================== ------BEGIN CERTIFICATE----- -MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK -DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe -Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE -LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw -DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD -ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA -BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv -KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z -p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC -AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ -4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y -eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw -MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G -PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw -OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm -2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0 -o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV -dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph -X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I= ------END CERTIFICATE----- - -D-TRUST Root Class 3 CA 2 EV 2009 -================================= ------BEGIN CERTIFICATE----- -MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK -DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw -OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK -DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw -OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS -egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1Y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JUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3 -zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0= ------END CERTIFICATE----- - -T-TeleSec GlobalRoot Class 2 -============================ ------BEGIN CERTIFICATE----- -MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM -IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU -cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx -MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz -dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD -ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3 -DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ -SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F -vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970 -2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV -WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA -MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy -YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4 -r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf -vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR -3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN -9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg== ------END CERTIFICATE----- - -QuoVadis Root CA 1 G3 -===================== ------BEGIN CERTIFICATE----- -MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG -A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv -b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN -MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg -RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE -PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm -PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6 -Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0F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RTDvdbJWqNjZgKAvQU6 -O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0 -FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV -hMJKzRwuJIczYOXD ------END CERTIFICATE----- - -QuoVadis Root CA 2 G3 -===================== ------BEGIN CERTIFICATE----- -MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG -A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv -b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN -MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg -RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh -ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY -NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t -oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o -MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l -V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo -L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DT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QIDAQABo0IwQDAPBgNVHRMBAf8EBTAD -AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI -hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px -KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS -t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ -TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du -DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib -Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD -hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX -0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW -dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2 -PpxxVJkES/1Y+Zj0 ------END CERTIFICATE----- - -DigiCert Assured ID Root G2 -=========================== ------BEGIN CERTIFICATE----- -MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG -EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw -IgYDVQQDExtEaWdpQ2VydCBBc3N1cm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ATE----- - -DigiCert Assured ID Root G3 -=========================== ------BEGIN CERTIFICATE----- -MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV -UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD -VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1 -MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 -d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ -BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb -RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs -KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF -UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy -YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy -1vUhZscv6pZjamVFkpUBtA== ------END CERTIFICATE----- - -DigiCert Global Root G2 -======================= ------BEGIN CERTIFICATE----- -MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG -EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw -HgYDVQQDExdEaWdpQ2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------END CERTIFICATE----- - -DigiCert Global Root G3 -======================= ------BEGIN CERTIFICATE----- -MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV -UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD -VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw -MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k -aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C -AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O -YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP -BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp -Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y -3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34 -VOKa5Vt8sycX ------END CERTIFICATE----- - -DigiCert Trusted Root G4 -======================== ------BEGIN CERTIFICATE----- -MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG -EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw -HwYDVQQDExhEaWdpQ2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IBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY -ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr -yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy -7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah -ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN -5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb -/UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa -5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK -G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP -82Z+ ------END CERTIFICATE----- - -COMODO RSA Certification Authority -================================== ------BEGIN CERTIFICATE----- -MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE -BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG -A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEB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vlwFTPoCWOAvn9sKIN9SCYPBMt -rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+ -nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg -tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW -sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp -pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA -zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq -ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52 -7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I -LaZRfyHBNVOFBkpdn627G190 ------END CERTIFICATE----- - -USERTrust RSA Certification Authority -===================================== ------BEGIN CERTIFICATE----- -MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE -BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK -ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh -dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE -BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBg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xmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ -7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ -Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM -8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi -FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi -yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c -J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw -sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx -Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9 ------END CERTIFICATE----- - -USERTrust ECC Certification Authority -===================================== ------BEGIN CERTIFICATE----- -MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC -VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU -aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC -VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU -a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DAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd -BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx -uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7 -yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3 ------END CERTIFICATE----- - -IdenTrust Commercial Root CA 1 -============================== ------BEGIN CERTIFICATE----- -MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG -EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS -b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES -MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB -IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld -hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/ -mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi -1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C -XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl -3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGM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Tzcqx+QGtVKnO7R -cGzM7vRX+Bi6hG6H ------END CERTIFICATE----- - -IdenTrust Public Sector Root CA 1 -================================= ------BEGIN CERTIFICATE----- -MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG -EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv -ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV -UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS -b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy -P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6 -Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI -rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf -qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS -mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn -ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh -LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v -iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3I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cNAQELBQADggIB -ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q -ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua -4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG -E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX -BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn -aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy -PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX -kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C -ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su ------END CERTIFICATE----- - -OISTE WISeKey Global Root GB CA -=============================== ------BEGIN CERTIFICATE----- -MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG -EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl -ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw -MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD -VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds -b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX -scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP -rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk -9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o -Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg -GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB -/zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI -hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD -dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0 -VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui -HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic -Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM= ------END CERTIFICATE----- - -SZAFIR ROOT CA2 -=============== ------BEGIN CERTIFICATE----- -MIIDcjCCAlqgAwIBAgIUPopdB+xV0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lIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6 -+/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw== ------END CERTIFICATE----- - -Certum Trusted Network CA 2 -=========================== ------BEGIN CERTIFICATE----- -MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE -BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1 -bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y -ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ -TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl -cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB -IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9 -7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o -CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b -Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p -uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130 -GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8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agCyzxxN5DaAhqXzvwdmP7 -zAYspsbiDrW5viSP ------END CERTIFICATE----- - -Hellenic Academic and Research Institutions RootCA 2015 -======================================================= ------BEGIN CERTIFICATE----- -MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT -BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0 -aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl -YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx -MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg -QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV -BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw -MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv -bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh -iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+ -6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd -FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr -i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLd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mT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q -p/UsQu0yrbYhnr68 ------END CERTIFICATE----- - -Hellenic Academic and Research Institutions ECC RootCA 2015 -=========================================================== ------BEGIN CERTIFICATE----- -MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0 -aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u -cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj -aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw -MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj -IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD -VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290 -Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP -dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK -Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O -BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA -GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofT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IwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC -ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH -FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ -gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t -dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce -VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB -/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3 -DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM -CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy -8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa -2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2 -xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5 ------END CERTIFICATE----- - -Amazon Root CA 2 -================ ------BEGIN CERTIFICATE----- -MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD -VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1 -MDUyNjAwMDAwMFoXDT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-+gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE -YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW -xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ -gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW -aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV -Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3 -KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi -JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw= ------END CERTIFICATE----- - -Amazon Root CA 3 -================ ------BEGIN CERTIFICATE----- -MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG -EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy -NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ -MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB -f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr -Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43 -rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc -eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw== ------END CERTIFICATE----- - -Amazon Root CA 4 -================ ------BEGIN CERTIFICATE----- -MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG -EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy -NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ -MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN -/sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri -83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV -HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA -MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1 -AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA== ------END CERTIFICATE----- - -TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1 -============================================= ------BEGIN CERTIFICATE----- -MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT -D0dlYnplIC0gS29jYWVsaTFCM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ggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh -AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc -lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R -e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j -q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM= ------END CERTIFICATE----- - -GDCA TrustAUTH R5 ROOT -====================== ------BEGIN CERTIFICATE----- -MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw -BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD -DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow -YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ -IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B -AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs -AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p -OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr -pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM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5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv -/EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT -aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g== ------END CERTIFICATE----- - -SSL.com Root Certification Authority RSA -======================================== ------BEGIN CERTIFICATE----- -MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM -BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x -MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw -MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx -EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM -LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD -ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C -Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8 -P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge -oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp -k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZ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04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y -wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI -WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k= ------END CERTIFICATE----- - -SSL.com Root Certification Authority ECC -======================================== ------BEGIN CERTIFICATE----- -MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV -BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv -BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy -MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO -BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv -bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA -BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+ -8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR -hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT -jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW -e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z -5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl ------END CERTIFICATE----- - -SSL.com EV Root Certification Authority RSA R2 -============================================== ------BEGIN CERTIFICATE----- -MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w -DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u -MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy -MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI -DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD -VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN -BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh -hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w -cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO -Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+ -B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh -CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim -9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3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jbSsV7FFY6GsdqnC+w== ------END CERTIFICATE----- - -SSL.com EV Root Certification Authority ECC -=========================================== ------BEGIN CERTIFICATE----- -MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV -BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy -BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw -MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx -EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM -LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB -BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy -3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O -BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe -5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ -N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm -m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg== ------END CERTIFICATE----- - -GlobalSign Root CA - R6 -======================= ------BEGIN CERTIFICATE----- -MIIFgzCCA2ugAwIBAgIORea7A4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WBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV -HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN -nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0 -lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY -BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym -Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr -3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1 -0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T -uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK -oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t -JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA= ------END CERTIFICATE----- - -OISTE WISeKey Global Root GC CA -=============================== ------BEGIN CERTIFICATE----- -MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD -SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo -MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4Mz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AAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo -jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk -bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x -ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn -RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A== ------END CERTIFICATE----- - -UCA Extended Validation Root -============================ ------BEGIN CERTIFICATE----- -MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG -EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u -IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G -A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi -MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs -iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF -Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu -eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dksHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR -59mzLC52LqGj3n5qiAno8geK+LLNEOfic0CTuwj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shqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi -djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr -dhh2n1ax ------END CERTIFICATE----- - -Certigna Root CA -================ ------BEGIN CERTIFICATE----- -MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE -BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ -MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda -MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz -MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC -DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX -stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz -KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8 -JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16 -XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq -4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3YzIoej -wpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBY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pjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY -tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS -aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde -E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0= ------END CERTIFICATE----- - -emSign Root CA - G1 -=================== ------BEGIN CERTIFICATE----- -MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET -MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl -ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx -ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVk -aHJhIFRlY2hub2xvZ2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIB -IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQzf2N4aLTN -LnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO8oG0x5ZOrRkVUkr+PHB1 -cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aqd7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHW -DV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhMtTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ -6DqS0hdW5TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH -hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG -MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2 -vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q -NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q -+Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih -U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx -iN66zB+Afko= ------END CERTIFICATE----- - -emSign ECC Root CA - G3 -======================= ------BEGIN CERTIFICATE----- -MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG -A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg -MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4 -MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11 -ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g -RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc -58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr -MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC -AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D -CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7 -jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj ------END CERTIFICATE----- - -emSign Root CA - C1 -=================== ------BEGIN CERTIFICATE----- -MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx -EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp -Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE -BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD -ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up -ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/ -Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX -OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V -I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms -lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+ -XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD -ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp -/6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1 -NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9 -wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ -BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI= ------END CERTIFICATE----- - -emSign ECC Root CA - C3 -======================= ------BEGIN CERTIFICATE----- -MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG -A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF -Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE -BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD -ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd -6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9 -SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA -B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA -MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU -ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ== ------END CERTIFICATE----- - -Hongkong Post Root CA 3 -======================= ------BEGIN CERTIFICATE----- -MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG -A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK -Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2 -MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv -bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX -SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz -iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf -jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim -5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe -sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj -0mRiikKYvLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+TtbNe/ -JgERohYpSms0B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5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq -dBb9HxEGmpv0 ------END CERTIFICATE----- - -Microsoft ECC Root Certificate Authority 2017 -============================================= ------BEGIN CERTIFICATE----- -MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV -UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND -IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4 -MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw -NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ -BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6 -thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB -eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM -+Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf -Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR -eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M= ------END CERTIFICATE----- - -Microsoft RSA Root Certificate Authority 2017 -============================================= ------BEGIN CERTIFICATE----- -MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9Fsz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VgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw -DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC -NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og -6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80 -dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk -+ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex -/2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy -AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW -ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE -7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT -c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D -5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E ------END CERTIFICATE----- - -e-Szigno Root CA 2017 -===================== ------BEGIN CERTIFICATE----- -MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw -DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt -MjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJvb3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZa -Fw00MjA4MjIxMjA3MDZaMHExCzAJBgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UE -CgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3pp -Z25vIFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtvxie+RJCx -s1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+HWyx7xf58etqjYzBhMA8G -A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSHERUI0arBeAyxr87GyZDv -vzAEwDAfBgNVHSMEGDAWgBSHERUI0arBeAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEA -tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO -svxyqltZ+efcMQ== ------END CERTIFICATE----- - -certSIGN Root CA G2 -=================== ------BEGIN CERTIFICATE----- -MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw -EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy -MDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJBgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lH -TiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP -ADCCAgoCggIBAMDFdRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69Mh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vRCjj5 -BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW -atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU -Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M -NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N -0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc= ------END CERTIFICATE----- - -NAVER Global Root Certification Authority -========================================= ------BEGIN CERTIFICATE----- -MIIFojCCA4qgAwIBAgIUAZQwHqIL3fXFMyqxQ0Rx+NZQTQ0wDQYJKoZIhvcNAQEMBQAwaTELMAkG -A1UEBhMCS1IxJjAkBgNVBAoMHU5BVkVSIEJVU0lORVNTIFBMQVRGT1JNIENvcnAuMTIwMAYDVQQD -DClOQVZFUiBHbG9iYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MTgwODU4 -NDJaFw0zNzA4MTgyMzU5NTlaMGkxCzAJBgNVBAYTAktSMSYwJAYDVQQKDB1OQVZFUiBCVVNJTkVT -UyBQTEFURk9STSBDb3JwLjEyMDAGA1UEAwwpTkFWRVIgR2xvYmFsIFJvb3QgQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC21PGTXLVAiQqrDZBb -UGOukJR0F0Vy1ntlWilLp1agS7gvQnXp2XskWjFlqxcX0TM62RHcQDaH38dq6SZeWYp34+hInDEW -+j6RscrJo+KfziFTowI2MMtSAuXaMl3Dxeb57hHHi8lEHoSTGEq0n+USZGnQJoViAbbJAh2+g1G7 -XNr4rRVqmfeSVP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Ai428diDRgxuYKuQl1C/AH6GmWNcf7I4GOODm4RStDeKLRLBT/DShycpWbXgnbiUSY -qqFJu3FS8r/2/yehNq+4tneI3TqkbZs0kNwUXTC/t+sX5Ie3cdCh13cV1ELX8vMxmV2b3RZtP+oG -I/hGoiLtk/bdmuYqh7GYVPEi92tF4+KOdh2ajcQGjTa3FPOdVGm3jjzVpG2Tgbet9r1ke8LJaDmg -kpzNNIaRkPpkUZ3+/uul9XXeifdy ------END CERTIFICATE----- - -AC RAIZ FNMT-RCM SERVIDORES SEGUROS -=================================== ------BEGIN CERTIFICATE----- -MIICbjCCAfOgAwIBAgIQYvYybOXE42hcG2LdnC6dlTAKBggqhkjOPQQDAzB4MQswCQYDVQQGEwJF -UzERMA8GA1UECgwIRk5NVC1SQ00xDjAMBgNVBAsMBUNlcmVzMRgwFgYDVQRhDA9WQVRFUy1RMjgy -NjAwNEoxLDAqBgNVBAMMI0FDIFJBSVogRk5NVC1SQ00gU0VSVklET1JFUyBTRUdVUk9TMB4XDTE4 -MTIyMDA5MzczM1oXDTQzMTIyMDA5MzczM1oweDELMAkGA1UEBhMCRVMxETAPBgNVBAoMCEZOTVQt -UkNNMQ4wDAYDVQQLDAVDZXJlczEYMBYGA1UEYQwPVkFURVMtUTI4MjYwMDRKMSwwKgYDVQQDDCNB -QyBSQUlaIEZOTVQtUkNNIFNFUlZJRE9SRVMgU0VHVVJPUzB2MBAGByqGSM49AgEGBSuBBAAiA2IA -BPa6V1PIyqvfNkpSIeSX0oNnnvBlUdBeh8dHsVnyV0ebAAKTRBdp20LHsbI6GA60XYyzZl2hNPk2 -LEnb80b8s0RpRBNm/dfF/a82Tc4DTQdxz69qBdKiQ1oKUm8BA06Oi6NCMEAwDwYDVR0TAQH/BAUw -AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFAG5L++/EYZg8k/QQW6rcx/n0m5JMAoGCCqG -SM49BAMDA2kAMGYCMQCuSuMrQMN0EfKVrRYj3k4MGuZdpSR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49BAMDMEYxCzAJBgNVBAYT -AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJvb3Qg -RTQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAXBgNV -BAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBFNDYwdjAQBgcq -hkjOPQIBBgUrgQQAIgNiAAScDrHPt+ieUnd1NPqlRqetMhkytAepJ8qUuwzSChDH2omwlwxwEwkB -jtjqR+q+soArzfwoDdusvKSGN+1wCAB16pMLey5SnCNoIwZD7JIvU4Tb+0cUB+hflGddyXqBPCCj -QjBAMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQxCpCPtsad0kRL -gLWi5h+xEk8blTAKBggqhkjOPQQDAwNoADBlAjEA31SQ7Zvvi5QCkxeCmb6zniz2C5GMn0oUsfZk -vLtoURMMA/cVi4RguYv/Uo7njLwcAjA8+RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+ -CAezNIm8BZ/3Hobui3A= ------END CERTIFICATE----- - -ANF Secure Server Root CA -========================= ------BEGIN CERTIFICATE----- -MIIF7zCCA9egAwIBAgIIDdPjvGz5a7EwDQYJKoZIhvcNAQELBQAwgYQxEjAQBgNVBAUTCUc2MzI4 -NzUxMDELMAkGA1UEBhMCRVMxJzAlBgNVBAoTHkFORiBBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lv -bjEUMBIGA1UECxMLQU5GIENBIFJhaXoxIjAgBgNVBAMTGUFORiBTZWN1cmUgU2VydmVyIFJvb3Qg -Q0EwHhcNMTkwOTA0MTAwMDM4WhcNMzkwODMwMTAwMDM4WjCBhDESMBAGA1UEBRMJRzYzMjg3NTEw -MQswCQYDVQQGEwJFUzEnMCUGA1UEChMeQU5GIEF1dG9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VVISfk/CHGT0sZonrDUL8zPB1hT+L9IBdeeUXZ701guLyPI59WzbLWoAAKfLOKyzx -j6ptBZNscsdW699QIyjlRRA96Gejrw5VD5AJYu9LWaL2U/HANeQvwSS9eS9OICI7/RogsKQOLHDt -dD+4E5UGUcjohybKpFtqFiGS3XNgnhAY3jyB6ugYw3yJ8otQPr0R4hUDqDZ9MwFsSBXXiJCZBMXM -5gf0vPSQ7RPi6ovDj6MzD8EpTBNO2hVWcXNyglD2mjN8orGoGjR0ZVzO0eurU+AagNjqOknkJjCb -5RyKqKkVMoaZkgoQI1YS4PbOTOK7vtuNknMBZi9iPrJyJ0U27U1W45eZ/zo1PqVUSlJZS2Db7v54 -EX9K3BR5YLZrZAPbFYPhor72I5dQ8AkzNqdxliXzuUJ92zg/LFis6ELhDtjTO0wugumDLmsx2d1H -hk9tl5EuT+IocTUW0fJz/iUrB0ckYyfI+PbZa/wSMVYIwFNCr5zQM378BvAxRAMU8Vjq8moNqRGy -g77FGr8H6lnco4g175x2MjxNBiLOFeXdntiP2t7SxDnlF4HPOEfrf4htWRvfn0IUrn7PqLBmZdo3 -r5+qPeoott7VMVgWglvquxl1AnMaykgaIZOQCo6ThKd9OyMYkomgjaw= ------END CERTIFICATE----- - -Certum EC-384 CA -================ ------BEGIN CERTIFICATE----- -MIICZTCCAeugAwIBAgIQeI8nXIESUiClBNAt3bpz9DAKBggqhkjOPQQDAzB0MQswCQYDVQQGEwJQ -TDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2Vy -dGlmaWNhdGlvbiBBdXRob3JpdHkxGTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwHhcNMTgwMzI2 -MDcyNDU0WhcNNDMwMzI2MDcyNDU0WjB0MQswCQYDVQQGEwJQTDEhMB8GA1UEChMYQXNzZWNvIERh -dGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx -GTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATEKI6rGFtq -vm5kN2PkzeyrOvfMobgOgknXhimfoZTy42B4mIF4Bk3y7JoOV2CDn7TmFy8as10CW4kjPMIRBSqn -iBMY81CE1700LCeJVf/OTOffph8oxPBUw7l8t1Ot68KjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD -VR0OBBYEFI0GZnQkdjrzife81r1HfS+8EF9LMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNo -ADBlAjADVS2m5hjEfO/JUG7BJw+ch69u1RsIGL2SKcHvlJF40jocVYli5RsJHrpka/F2tNQCMQC0 -QoSZ/6vnnvuRlydd3LBbMHHOXjgaatkl5+r3YZJW+OraNsKHZZYuciUvf9/DE8k= ------END CERTIFICATE----- - -Certum Trusted Root CA -====================== ------BEGIN CERTIFICATE----- -MIIFwDCCA6igAwIBAgIQHr9ZULjJgDdMBvfrVU+17TANBgkqhkiG9w0BAQ0FADB6MQswCQYDVQQG -EwJQTDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0g -Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0Ew -HhcNMTgwMzE2MTIxMDEzWhcNNDMwMzE2MTIxMDEzWjB6MQswCQYDVQQGEwJQTDEhMB8GA1UEChMY -QXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBB -dXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEB -AQUAA4ICDwAwggIKAoICAQDRLY67tzbqbTeRn06TpwXkKQMlzhyC93yZn0EGze2jusDbCSzBfN8p -fktlL5On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VXF/sHyz03FJuc9SpAQ/3D2gu68zngowYI7bnV2UqL1g52KAdoGDDIzM -MEZJ4gzSqK/rYXHv5yJiqfdcZGyfFoxnNidF9Ql7v/YQCvGwjVRDjAS6oz/v4jXH+XTgbzRB0L9z -ZVcg+ZtnemZoJE6AZb0QmQZZ8mWvuMZHu/2QeItBcy6vVR/cO5JyboTT0GFMDcx2V+IthSIVNg3r -AZ3r2OvEhJn7wAzMMujjd9qDRIueVSjAi1jTkD5OGwDxFa2DK5o= ------END CERTIFICATE----- - -HARICA TLS RSA Root CA 2021 -=========================== ------BEGIN CERTIFICATE----- -MIIFpDCCA4ygAwIBAgIQOcqTHO9D88aOk8f0ZIk4fjANBgkqhkiG9w0BAQsFADBsMQswCQYDVQQG -EwJHUjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u -cyBDQTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBSU0EgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTEwNTUz -OFoXDTQ1MDIxMzEwNTUzN1owbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRl -bWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgUlNB -IFJvb3QgQ0EgMjAyMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAIvC569lmwVnlskN -JLnQDmT8zuIkGCyEf3dRywQRNrhe7Wlxp57kJQmXZ8FHws+RFjZiPTgE4VGC/6zStGndLuwRo0Xu -a2s7TL+MjaQenRG56Tj5eg4MmOIjHdFOY9TnuEFE+2uva9of08WRiFukiZLRgeaMOVig1mlDqa2Y -Ulhu2wr7a89o+uOkXjpFc5gH6l8Cct4MpbOfrqkdtx2z/IpZ525yZa31MJQjB/OCFks1mJxTuy/K -5FrZx40d/JiZ+yykgmvwKh+OC19xXFyuQnspiYHLA6OZ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JGWg/6w/zgH7IS79aPib8qXPMThcFarmlwDB31qlpzmq6YR/ -PFGoOtmUW4y/Twhx5duoXNTSpv4Ao8YWxw/ogM4cKGR0GQjTQuPOAF1/sdwTsOEFy9EgqoZ0njnn -kf3/W9b3raYvAwtt41dU63ZTGI0RmLo= ------END CERTIFICATE----- - -HARICA TLS ECC Root CA 2021 -=========================== ------BEGIN CERTIFICATE----- -MIICVDCCAdugAwIBAgIQZ3SdjXfYO2rbIvT/WeK/zjAKBggqhkjOPQQDAzBsMQswCQYDVQQGEwJH -UjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBD -QTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBFQ0MgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTExMDExMFoX -DTQ1MDIxMzExMDEwOVowbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRlbWlj -IGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgRUNDIFJv -b3QgQ0EgMjAyMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABDgI/rGgltJ6rK9JOtDA4MM7KKrxcm1l -AEeIhPyaJmuqS7psBAqIXhfyVYf8MLA04jRYVxqEU+kw2anylnTDUR9YSTHMmE5gEYd103KUkE+b -ECUqqHgtvpBBWJAVcqeht6NCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUyRtTgRL+BNUW -0aq8mm+3oJUZbsowDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2cAMGQCMBHervjcToiwqfAi -rcJRQO9gcS3ujwLEXQNwSaSS6sUUiHCm0w2wqsosQJz76YJumgIwK0eaB8bRwoF8yguWGEEbo/Qw -CZ61IygNnxS2PFOiTAZpffpskcYqSUXm7LcT4Tps ------END CERTIFICATE----- - -Autoridad de Certificacion Firmaprofesional CIF A62634068 -========================================================= ------BEGIN CERTIFICATE----- -MIIGFDCCA/ygAwIBAgIIG3Dp0v+ubHEwDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCRVMxQjBA -BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2 -MjYzNDA2ODAeFw0xNDA5MjMxNTIyMDdaFw0zNjA1MDUxNTIyMDdaMFExCzAJBgNVBAYTAkVTMUIw -QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB -NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD -Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P -B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY -7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH -ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI -plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX -MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX -LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK -bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU -vzlN1J5Bto+WHWOWk9mVBngxaJ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cAZfpLz6IHxV ------END CERTIFICATE----- - -vTrus ECC Root CA -================= ------BEGIN CERTIFICATE----- -MIICDzCCAZWgAwIBAgIUbmq8WapTvpg5Z6LSa6Q75m0c1towCgYIKoZIzj0EAwMwRzELMAkGA1UE -BhMCQ04xHDAaBgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xGjAYBgNVBAMTEXZUcnVzIEVDQyBS -b290IENBMB4XDTE4MDczMTA3MjY0NFoXDTQzMDczMTA3MjY0NFowRzELMAkGA1UEBhMCQ04xHDAa -BgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xGjAYBgNVBAMTEXZUcnVzIEVDQyBSb290IENBMHYw -EAYHKoZIzj0CAQYFK4EEACIDYgAEZVBKrox5lkqqHAjDo6LN/llWQXf9JpRCux3NCNtzslt188+c -ToL0v/hhJoVs1oVbcnDS/dtitN9Ti72xRFhiQgnH+n9bEOf+QP3A2MMrMudwpremIFUde4BdS49n -TPEQo0IwQDAdBgNVHQ4EFgQUmDnNvtiyjPeyq+GtJK97fKHbH88wDwYDVR0TAQH/BAUwAwEB/zAO -BgNVHQ8BAf8EBAMCAQYwCgYIKoZIzj0EAwMDaAAwZQIwV53dVvHH4+m4SVBrm2nDb+zDfSXkV5UT -QJtS0zvzQBm8JsctBp61ezaf9SXUY2sAAjEA6dPGnlaaKsyh2j/IZivTWJwghfqrkYpwcBE4YGQL -YgmRWAD5Tfs0aNoJrSEGGJTO ------END CERTIFICATE----- - -vTrus Root CA -============= ------BEGIN CERTIFICATE----- -MIIFVjCCAz6gAwIBAgIUQ+NxE9izWRRdt86M/TX9b7wFjUUwDQYJKoZIhvcNAQELBQAwQzELMAkG -A1UEBhMCQ04xHDAaBgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xFjAUBgNVBAMTDXZUcnVzIFJv -b3QgQ0EwHhcNMTgwNzMxMDcyNDA1WhcNNDMwNzMxMDcyNDA1WjBDMQswCQYDVQQGEwJDTjEcMBoG -A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C/+sOxL9kLX1jbhd47F18iMjr -jld22VkE+rxSH0Ws8HqA7Oxvdq6R2xCOBNyS36D25q5J08FsEhvMKar5CKXiNxTKsbhm7xqC5PD4 -8acWabfbqWE8n/Uxy+QARsIvdLGx14HuqCaVvIivTDUHKgLKeBRtRytAVunLKmChZwOgzoy8sHJn -xDHO2zTlJQNgJXtxmOTAGytfdELSS8VZCAeHvsXDf+eW2eHcKJfWjwXj9ZtOyh1QRwVTsMo554Wg -icEFOwE30z9J4nfrI8iIZjs9OXYhRvHsXyO466JmdXTBQPfYaJqT4i2pLr0cox7IdMakLXogqzu4 -sEb9b91fUlV1YvCXoHzXOP0l382gmxDPi7g4Xl7FtKYCNqEeXxzP4padKar9mK5S4fNBUvupLnKW -nyfjqnN9+BojZns7q2WwMgFLFT49ok8MKzWixtlnEjUwzXYuFrOZnk1PTi07NEPhmg4NpGaXutIc -SkwsKouLgU9xGqndXHt7CMUADTdA43x7VF8vhV929vensBxXVsFy6K2ir40zSbofitzmdHxghm+H -l3s= ------END CERTIFICATE----- - -ISRG Root X2 -============ ------BEGIN CERTIFICATE----- -MIICGzCCAaGgAwIBAgIQQdKd0XLq7qeAwSxs6S+HUjAKBggqhkjOPQQDAzBPMQswCQYDVQQGEwJV -UzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElT -UkcgUm9vdCBYMjAeFw0yMDA5MDQwMDAwMDBaFw00MDA5MTcxNjAwMDBaME8xCzAJBgNVBAYTAlVT -MSkwJwYDVQQKEyBJbnRlcm5ldCBTZWN1cml0eSBSZXNlYXJjaCBHcm91cDEVMBMGA1UEAxMMSVNS -RyBSb290IFgyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEzZvVn4CDCuwJSvMWSj5cz3es3mcFDR0H -ttwW+1qLFNvicWDEukWVEYmO6gbf9yoWHKS5xcUy4APgHoIYOIvXRdgKam7mAHf7AlF9ItgKbppb -d9/w+kHsOdx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swBVLuT1sw5XxJFBAJw/6KXf6vb/ -yPCtbVKoF6ubYfwSUTXkJf2vqmqGOQ== ------END CERTIFICATE----- - -GlobalSign ECC Root CA - R4 -=========================== ------BEGIN CERTIFICATE----- -MIIB3DCCAYOgAwIBAgINAgPlfvU/k/2lCSGypjAKBggqhkjOPQQDAjBQMSQwIgYDVQQLExtHbG9i -YWxTaWduIEVDQyBSb290IENBIC0gUjQxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds -b2JhbFNpZ24wHhcNMTIxMTEzMDAwMDAwWhcNMzgwMTE5MDMxNDA3WjBQMSQwIgYDVQQLExtHbG9i -YWxTaWduIEVDQyBSb290IENBIC0gUjQxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds -b2JhbFNpZ24wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAS4xnnTj2wlDp8uORkcA6SumuU5BwkW -ymOxuYb4ilfBV85C+nOh92VC/x7BALJucw7/xyHlGKSq2XE/qNS5zowdo0IwQDAOBgNVHQ8BAf8E -BAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVLB7rUW44kB/+wpu+74zyTyjhNUwCgYI -KoZIzj0EAwIDRwAwRAIgIk90crlgr/HmnKAWBVBfw147bmF0774BxL4YSFlhgjICICadVGNA3jdg -UM/I2O2dgq43mLyjj0xMqTQrbO/7lZsm ------END CERTIFICATE----- - -GTS Root R1 -=========== ------BEGIN CERTIFICATE----- -MIIFVzCCAz+gAwIBAgINAgPlk28xsBNJiGuiFzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQGEwJV -UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg -UjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE -ChMZR29vZ2xlIFRydXN0IFNlcnZpY2V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G+gnoot7TiYaelpkttGsN/H9oPM47HLwEXWdyzRSjeZ2axfG34ar -J45JK3VmgRAhpuo+9K4l/3wV3s6MJT/KYnAK9y8JZgfIPxz88NtFMN9iiMG1D53Dn0reWVlHxYci -NuaCp+0KueIHoI17eko8cdLiA6EfMgfdG+RCzgwARWGAtQsgWSl4vflVy2PFPEz0tv/bal8xa5me -LMFrUKTX5hgUvYU/Z6tGn6D/Qqc6f1zLXbBwHSs09dR2CQzreExZBfMzQsNhFRAbd03OIozUhfJF -fbdT6u9AWpQKXCBfTkBdYiJ23//OYb2MI3jSNwLgjt7RETeJ9r/tSQdirpLsQBqvFAnZ0E6yove+ -7u7Y/9waLd64NnHi/Hm3lCXRSHNboTXns5lndcEZOitHTtNCjv0xyBZm2tIMPNuzjsmhDYAPexZ3 -FL//2wmUspO8IFgV6dtxQ/PeEMMA3KgqlbbC1j+Qa3bbbP6MvPJwNQzcmRk13NfIRmPVNnGuV/u3 -gm3c ------END CERTIFICATE----- - -GTS Root R3 -=========== ------BEGIN CERTIFICATE----- -MIICCTCCAY6gAwIBAgINAgPluILrIPglJ209ZjAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJVUzEi -MCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMw -HhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZ -R29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcqhkjO -PQIBBgUrgQQAIgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUURout -736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL24CejQjBA -MA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTB8Sa6oC2uhYHP0/Eq -Er24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEA9uEglRR7VKOQFhG/hMjqb2sXnh5GmCCbn9MN2azT -L818+FsuVbu/3ZL3pAzcMeGiAjEA/JdmZuVDFhOD3cffL74UOO0BzrEXGhF16b0DjyZ+hOXJYKaV -11RZt+cRLInUue4X ------END CERTIFICATE----- - -GTS Root R4 -=========== ------BEGIN CERTIFICATE----- -MIICCTCCAY6gAwIBAgINAgPlwGjvYxqccpBQUjAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJVUzEi -MCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQw -HhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZ -R29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcqhkjO -PQIBBgUrgQQAIgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa6zzu -hXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvRHYqjQjBA -MA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSATNbrdP9JNqPV2Py1 -PsVq8JQdjDAKBggqhkjOPQQDAwNpADBmAjEA6ED/g94D9J+uHXqnLrmvT/aDHQ4thQEd0dlq7A/C -r8deVl5c1RxYIigL9zC2L7F8AjEA8GE8p/SgguMh1YQdc4acLa/KNJvxn7kjNuK8YAOdgLOaVsjh -4rsUecrNIdSUtUlD ------END CERTIFICATE----- - -Telia Root CA v2 -================ ------BEGIN CERTIFICATE----- -MIIFdDCCA1ygAwIBAgIPAWdfJ9b+euPkrL4JWwWeMA0GCSqGSIb3DQEBCwUAMEQ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gNVHQ8BAf8EBAMCAQYwDwYD -VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAoDtZpwmUPjaE0n4vOaWWl/oRrfxn83EJ -8rKJhGdEr7nv7ZbsnGTbMjBvZ5qsfl+yqwE2foH65IRe0qw24GtixX1LDoJt0nZi0f6X+J8wfBj5 -tFJ3gh1229MdqfDBmgC9bXXYfef6xzijnHDoRnkDry5023X4blMMA8iZGok1GTzTyVR8qPAs5m4H -eW9q4ebqkYJpCh3DflminmtGFZhb069GHWLIzoBSSRE/yQQSwxN8PzuKlts8oB4KtItUsiRnDe+C -y748fdHif64W1lZYudogsYMVoe+KTTJvQS8TUoKU1xrBeKJR3Stwbbca+few4GeXVtt8YVMJAygC -QMez2P2ccGrGKMOF6eLtGpOg3kuYooQ+BXcBlj37tCAPnHICehIv1aO6UXivKitEZU61/Qrowc15 -h2Er3oBXRb9n8ZuRXqWk7FlIEA04x7D6w0RtBPV4UBySllva9bguulvP5fBqnUsvWHMtTy3EHD70 -sz+rFQ47GUGKpMFXEmZxTPpT41frYpUJnlTd0cI8Vzy9OK2YZLe4A5pTVmBds9hCG1xLEooc6+t9 -xnppxyd/pPiL8uSUZodL6ZQHCRJ5irLrdATczvREWeAWysUsWNc8e89ihmpQfTU2Zqf7N+cox9jQ -raVplI/owd8k+BsHMYeB2F326CjYSlKArBPuUBQemMc= ------END CERTIFICATE----- - -D-TRUST BR Root CA 1 2020 -========================= ------BEGIN CERTIFICATE----- -MIIC2zCCAmCgAwIBAgIQfMmPK4TX3+oPyWWa00tNljAKBggqhkjOPQQDAzBIMQswCQYDVQQGEwJE -RTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEJSIFJvb3QgQ0EgMSAy -MDIwMB4XDTIwMDIxMTA5NDUwMFoXDTM1MDIxMTA5NDQ1OVowSDELMAkGA1UEBhMCREUxFTATBgNV -BAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBCUiBSb290IENBIDEgMjAyMDB2MBAG -ByqGSM49AgEGBSuBBAAiA2IABMbLxyjR+4T1mu9CFCDhQ2tuda38KwOE1HaTJddZO0Flax7mNCq7 -dPYSzuht56vkPE4/RAiLzRZxy7+SmfSk1zxQVFKQhYN4lGdnoxwJGT11NIXe7WB9xwy0QVK5buXu -QqOCAQ0wggEJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFHOREKv/VbNafAkl1bK6CKBrqx9t -MA4GA1UdDwEB/wQEAwIBBjCBxgYDVR0fBIG+MIG7MD6gPKA6hjhodHRwOi8vY3JsLmQtdHJ1c3Qu -bmV0L2NybC9kLXRydXN0X2JyX3Jvb3RfY2FfMV8yMDIwLmNybDB5oHegdYZzbGRhcDovL2RpcmVj -dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwQlIlMjBSb290JTIwQ0ElMjAxJTIwMjAyMCxP -PUQtVHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdDAKBggqhkjOPQQD -AwNpADBmAjEAlJAtE/rhY/hhY+ithXhUkZy4kzg+GkHaQBZTQgjKL47xPoFWwKrY7RjEsK70Pvom -AjEA8yjixtsrmfu3Ubgko6SUeho/5jbiA1czijDLgsfWFBHVdWNbFJWcHwHP2NVypw87 ------END CERTIFICATE----- - -D-TRUST EV Root CA 1 2020 -========================= ------BEGIN CERTIFICATE----- -MIIC2zCCAmCgAwIBAgIQXwJB13qHfEwDo6yWjfv/0DAKBggqhkjOPQQDAzBIMQswCQYDVQQGEwJE -RTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEVWIFJvb3QgQ0EgMSAy -MDIwMB4XDTIwMDIxMTEwMDAwMFoXDTM1MDIxMTA5NTk1OVowSDELMAkGA1UEBhMCREUxFTATBgNV -BAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBFViBSb290IENBIDEgMjAyMDB2MBAG -ByqGSM49AgEGBSuBBAAiA2IABPEL3YZDIBnfl4XoIkqbz52Yv7QFJsnL46bSj8WeeHsxiamJrSc8 -ZRCC/N/DnU7wMyPE0jL1HLDfMxddxfCxivnvubcUyilKwg+pf3VlSSowZ/Rk99Yad9rDwpdhQntJ -raOCAQ0wggEJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFH8QARY3OqQo5FD4pPfsazK2/umL -MA4GA1UdDwEB/wQEAwIBBjCBxgYDVR0fBIG+MIG7MD6gPKA6hjhodHRwOi8vY3JsLmQtdHJ1c3Qu -bmV0L2NybC9kLXRydXN0X2V2X3Jvb3RfY2FfMV8yMDIwLmNybDB5oHegdYZzbGRhcDovL2RpcmVj -dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwRVYlMjBSb290JTIwQ0ElMjAxJTIwMjAyMCxP -PUQtVHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdDAKBggqhkjOPQQD -AwNpADBmAjEAyjzGKnXCXnViOTYAYFqLwZOZzNnbQTs7h5kXO9XMT8oi96CAy/m0sRtW9XLS/BnR -AjEAkfcwkz8QRitxpNA7RJvAKQIFskF3UfN5Wp6OFKBOQtJbgfM0agPnIjhQW+0ZT0MW ------END CERTIFICATE----- - -DigiCert TLS ECC P384 Root G5 -============================= ------BEGIN CERTIFICATE----- -MIICGTCCAZ+gAwIBAgIQCeCTZaz32ci5PhwLBCou8zAKBggqhkjOPQQDAzBOMQswCQYDVQQGEwJV -UzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJjAkBgNVBAMTHURpZ2lDZXJ0IFRMUyBFQ0MgUDM4 -NCBSb290IEc1MB4XDTIxMDExNTAwMDAwMFoXDTQ2MDExNDIzNTk1OVowTjELMAkGA1UEBhMCVVMx -FzAVBgNVBAoTDkRpZ2lDZXJ0LCBJbmMuMSYwJAYDVQQDEx1EaWdpQ2VydCBUTFMgRUNDIFAzODQg -Um9vdCBHNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABMFEoc8Rl1Ca3iOCNQfN0MsYndLxf3c1Tzvd -lHJS7cI7+Oz6e2tYIOyZrsn8aLN1udsJ7MgT9U7GCh1mMEy7H0cKPGEQQil8pQgO4CLp0zVozptj -n4S1mU1YoI71VOeVyaNCMEAwHQYDVR0OBBYEFMFRRVBZqz7nLFr6ICISB4CIfBFqMA4GA1UdDwEB -/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gAMGUCMQCJao1H5+z8blUD2Wds -Jk6Dxv3J+ysTvLd6jLRl0mlpYxNjOyZQLgGheQaRnUi/wr4CMEfDFXuxoJGZSZOoPHzoRgaLLPIx -AJSdYsiJvRmEFOml+wG4DXZDjC5Ty3zfDBeWUA== ------END CERTIFICATE----- - -DigiCert TLS RSA4096 Root G5 -============================ ------BEGIN CERTIFICATE----- -MIIFZjCCA06gAwIBAgIQCPm0eKj6ftpqMzeJ3nzPijANBgkqhkiG9w0BAQwFADBNMQswCQYDVQQG -EwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJTAjBgNVBAMTHERpZ2lDZXJ0IFRMUyBSU0E0 -MDk2IFJvb3QgRzUwHhcNMjEwMTE1MDAwMDAwWhcNNDYwMTE0MjM1OTU5WjBNMQswCQYDVQQGEwJV -UzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJTAjBgNVBAMTHERpZ2lDZXJ0IFRMUyBSU0E0MDk2 -IFJvb3QgRzUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz0PTJeRGd/fxmgefM1eS8 -7IE+ajWOLrfn3q/5B03PMJ3qCQuZvWxX2hhKuHisOjmopkisLnLlvevxGs3npAOpPxG02C+JFvuU -AT27L/gTBaF4HI4o4EXgg/RZG5Wzrn4DReW+wkL+7vI8toUTmDKdFqgpwgscONyfMXdcvyej/Ces -tyu9dJsXLfKB2l2w4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JqIz3nCU2AG3swpMPdB380vqQmsvZB6Akd4yCYqjdP//fx4ilwMUc/dNAU -FvohigLVigmUdy7yWSiLfFCSCmZ4OIN1xLVaqBHG5cGdZlXPU8Sv13WFqUITVuwhd4GTWgzqltlJ -yqEI8pc7bZsEGCREjnwB8twl2F6GmrE52/WRMmrRpnCKovfepEWFJqgejF0pW8hL2JpqA15w8oVP -bEtoL8pU9ozaMv7Da4M/OMZ+ ------END CERTIFICATE----- - -Certainly Root R1 -================= ------BEGIN CERTIFICATE----- -MIIFRzCCAy+gAwIBAgIRAI4P+UuQcWhlM1T01EQ5t+AwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UE -BhMCVVMxEjAQBgNVBAoTCUNlcnRhaW5seTEaMBgGA1UEAxMRQ2VydGFpbmx5IFJvb3QgUjEwHhcN -MjEwNDAxMDAwMDAwWhcNNDYwNDAxMDAwMDAwWjA9MQswCQYDVQQGEwJVUzESMBAGA1UEChMJQ2Vy -dGFpbmx5MRowGAYDVQQDExFDZXJ0YWlubHkgUm9vdCBSMTCCAiIwDQYJKoZIhvcNAQEBBQADggIP -ADCCAgoCggIBANA21B/q3avk0bbm+yLA3RMNansiExyXPGhjZjKcA7WNpIGD2ngwEc/csiu+kr+O -5MQTvqRoTNoCaBZ0vrLdBORrKt03H2As2/X3oXyVtwxwhi7xOu9S98zTm/mLvg7fMbedaFySpvXl -8wo0tf97ouSHocavFwDvA5HtqRxOcT3Si2yJ9HiG5mpJoM610rCrm/b01C7jcvk2xusVtyWMOvwl -DbMicyF0yEqWYZL1LwsYpfSt4u5BvQF5+paMjRcCMLT5r3gajLQ2EBAHBXDQ9DGQilHFhiZ5shGI -XsXwClTNSaa/ApzSRKft43jvRl5tcdF5cBxGX1HpyTfcX35pe0HfNEXgO4T0oYoKNp43zGJS4YkN -KPl6I7ENPT2a/Z2B7yyQwHtETrtJ4A5KVpK8y7XdeReJkd5hiXSSqOMyhb5OhaRLWcsrxXiOcVTQ -AjeZjOVJ6uBUcqQR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root E1 -================= ------BEGIN CERTIFICATE----- -MIIB9zCCAX2gAwIBAgIQBiUzsUcDMydc+Y2aub/M+DAKBggqhkjOPQQDAzA9MQswCQYDVQQGEwJV -UzESMBAGA1UEChMJQ2VydGFpbmx5MRowGAYDVQQDExFDZXJ0YWlubHkgUm9vdCBFMTAeFw0yMTA0 -MDEwMDAwMDBaFw00NjA0MDEwMDAwMDBaMD0xCzAJBgNVBAYTAlVTMRIwEAYDVQQKEwlDZXJ0YWlu -bHkxGjAYBgNVBAMTEUNlcnRhaW5seSBSb290IEUxMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE3m/4 -fxzf7flHh4axpMCK+IKXgOqPyEpeKn2IaKcBYhSRJHpcnqMXfYqGITQYUBsQ3tA3SybHGWCA6TS9 -YBk2QNYphwk8kXr2vBMj3VlOBF7PyAIcGFPBMdjaIOlEjeR2o0IwQDAOBgNVHQ8BAf8EBAMCAQYw -DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU8ygYy2R17ikq6+2uI1g4hevIIgcwCgYIKoZIzj0E -AwMDaAAwZQIxALGOWiDDshliTd6wT99u0nCK8Z9+aozmut6Dacpps6kFtZaSF4fC0urQe87YQVt8 -rgIwRt7qy12a7DLCZRawTDBcMPPaTnOGBtjOiQRINzf43TNRnXCve1XYAS59BWQOhriR ------END CERTIFICATE----- - -Security Communication ECC RootCA1 -================================== ------BEGIN CERTIFICATE----- -MIICODCCAb6gAwIBAgIJANZdm7N4gS7rMAoGCCqGSM49BAMDMGExCzAJBgNVBAYTAkpQMSUwIwYD -VQQKExxTRUNPTSBUcnVzdCBTeXN0ZW1zIENPLixMVEQuMSswKQYDVQQDEyJTZWN1cml0eSBDb21t -dW5pY2F0aW9uIEVDQyBSb290Q0ExMB4XDTE2MDYxNjA1MTUyOFoXDTM4MDExODA1MTUyOFowYTEL -MAkGA1UEBhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xKzApBgNV -BAMTIlNlY3VyaXR5IENvbW11bmljYXRpb24gRUNDIFJvb3RDQTEwdjAQBgcqhkjOPQIBBgUrgQQA -IgNiAASkpW9gAwPDvTH00xecK4R1rOX9PVdu12O/5gSJko6BnOPpR27KkBLIE+CnnfdldB9sELLo -5OnvbYUymUSxXv3MdhDYW72ixvnWQuRXdtyQwjWpS4g8EkdtXP9JTxpKULGjQjBAMB0GA1UdDgQW -BBSGHOf+LaVKiwj+KBH6vqNm+GBZLzAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAK -BggqhkjOPQQDAwNoADBlAjAVXUI9/Lbu9zuxNuie9sRGKEkz0FhDKmMpzE2xtHqiuQ04pV1IKv3L -snNdo4gIxwwCMQDAqy0Obe0YottT6SXbVQjgUMzfRGEWgqtJsLKB7HOHeLRMsmIbEvoWTSVLY70e -N9k= ------END CERTIFICATE----- - -BJCA Global Root CA1 -==================== ------BEGIN CERTIFICATE----- -MIIFdDCCA1ygAwIBAgIQVW9l47TZkGobCdFsPsBsIDANBgkqhkiG9w0BAQsFADBUMQswCQYDVQQG -EwJDTjEmMCQGA1UECgwdQkVJSklORyBDRVJUSUZJQ0FURSBBVVRIT1JJVFkxHTAbBgNVBAMMFEJK -Q0EgR2xvYmFsIFJvb3QgQ0ExMB4XDTE5MTIxOTAzMTYxN1oXDTQ0MTIxMjAzMTYxN1owVDELMAkG -A1UEBhMCQ04xJjAkBgNVBAoMHUJFSUpJTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZMR0wGwYDVQQD -DBRCSkNBIEdsb2JhbCBSb290IENBMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAPFm -CL3ZxRVhy4QEQaVpN3cdwbB7+sN3SJATcmTRuHyQNZ0YeYjjlwE8R4HyDqKYDZ4/N+AZspDyRhyS -sTphzvq3Rp4Dhtczbu33RYx2N95ulpH3134rhxfVizXuhJFyV9xgw8O558dnJCNPYwpj9mZ9S1Wn -P3hkSWkS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l1lOWqzzIQNph91Oj9w== ------END CERTIFICATE----- - -Sectigo Public Server Authentication Root E46 -============================================= ------BEGIN CERTIFICATE----- -MIICOjCCAcGgAwIBAgIQQvLM2htpN0RfFf51KBC49DAKBggqhkjOPQQDAzBfMQswCQYDVQQGEwJH -QjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0aWdvIFB1YmxpYyBTZXJ2 -ZXIgQXV0aGVudGljYXRpb24gUm9vdCBFNDYwHhcNMjEwMzIyMDAwMDAwWhcNNDYwMzIxMjM1OTU5 -WjBfMQswCQYDVQQGEwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0 -aWdvIFB1YmxpYyBTZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBFNDYwdjAQBgcqhkjOPQIBBgUr -gQQAIgNiAAR2+pmpbiDt+dd34wc7qNs9Xzjoq1WmVk/WSOrsfy2qw7LFeeyZYX8QeccCWvkEN/U0 -NSt3zn8gj1KjAIns1aeibVvjS5KToID1AZTc8GgHHs3u/iVStSBDHBv+6xnOQ6OjQjBAMB0GA1Ud -DgQWBBTRItpMWfFLXyY4qp3W7usNw/upYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB -/zAKBggqhkjOPQQDAwNnADBkAjAn7qRaqCG76UeXlImldCBteU/IvZNeWBj7LRoAasm4PdCkT0RH -lAFWovgzJQxC36oCMB3q4S6ILuH5px0CMk7yn2xVdOOurvulGu7t0vzCAxHrRVxgED1cf5kDW21U -SAGKcw== ------END CERTIFICATE----- - -Sectigo Public Server Authentication Root R46 -============================================= ------BEGIN CERTIFICATE----- -MIIFijCCA3KgAwIBAgIQdY39i658BwD6qSWn4cetFDANBgkqhkiG9w0BAQwFADBfMQswCQYDVQQG -EwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0aWdvIFB1YmxpYyB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AQEMBQADggIBAC9c -mTz8Bl6MlC5w6tIyMY208FHVvArzZJ8HXtXBc2hkeqK5Duj5XYUtqDdFqij0lgVQYKlJfp/imTYp -E0RHap1VIDzYm/EDMrraQKFz6oOht0SmDpkBm+S8f74TlH7Kph52gDY9hAaLMyZlbcp+nv4fjFg4 -exqDsQ+8FxG75gbMY/qB8oFM2gsQa6H61SilzwZAFv97fRheORKkU55+MkIQpiGRqRxOF3yEvJ+M -0ejf5lG5Nkc/kLnHvALcWxxPDkjBJYOcCj+esQMzEhonrPcibCTRAUH4WAP+JWgiH5paPHxsnnVI -84HxZmduTILA7rpXDhjvLpr3Etiga+kFpaHpaPi8TD8SHkXoUsCjvxInebnMMTzD9joiFgOgyY9m -pFuiTdaBJQbpdqQACj7LzTWb4OE4y2BThihCQRxEV+ioratF4yUQvNs+ZUH7G6aXD+u5dHn5Hrwd -Vw1Hr8Mvn4dGp+smWg9WY7ViYG4A++MnESLn/pmPNPW56MORcr3Ywx65LvKRRFHQV80MNNVIIb/b -E/FmJUNS0nAiNs2fxBx1IK1jcmMGDw4nztJqDby1ORrp0XZ60Vzk50lJLVU3aPAaOpg+VBeHVOmm -J1CJeyAvP/+/oYtKR5j/K3tJPsMpRmAYQqszKbrAKbkTidOIijlBO8n9pu0f9GBj39ItVQGL ------END CERTIFICATE----- - -SSL.com TLS RSA Root CA 2022 -============================ ------BEGIN CERTIFICATE----- -MIIFiTCCA3GgAwIBAgIQb77arXO9CEDii02+1PdbkTANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQG -EwJVUzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQDDBxTU0wuY29tIFRMUyBSU0Eg -Um9vdCBDQSAyMDIyMB4XDTIyMDgyNTE2MzQyMloXDTQ2MDgxOTE2MzQyMVowTjELMAkGA1UEBhMC -VVMxGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjElMCMGA1UEAwwcU1NMLmNvbSBUTFMgUlNBIFJv -b3Qg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rrPRpgqU+tvT5TgKa3kSM/tKWTcWQA673vWJDPFs0/dRa1419dvAJuoSc06pkZCmF8NsLzjU -o3KUQyxi4U5cMj29TH0ZR6LDSeeWP4+a0zvkEdiLA9z2tmBVGKaBUfPhqBVq6+AL8BQx1rmMRTqo -ENjwuSfr98t67wVylrXEj5ZzxOhWc5y8aVFjvO9nHEMaX3cZHxj4HCUp+UmZKbaSPaKDN7Egkaib -MOlqbLQjk2UEqxHzDh1TJElTHaE/nUiSEeJ9DU/1172iWD54nR4fK/4huxoTtrEoZP2wAgDHbICi -vRZQIA9ygV/MlP+7mea6kMvq+cYMwq7FGc4zoWtcu358NFcXrfA/rs3qr5nsLFR+jM4uElZI7xc7 -P0peYNLcdDa8pUNjyw9bowJWCZ4kLOGGgYz+qxcs+sjiMho6/4UIyYOf8kpIEFR3N+2ivEC+5BB0 -9+Rbu7nzifmPQdjH5FCQNYA+HLhNkNPU98OwoX6EyneSMSy4kLGCenROmxMmtNVQZlR4rmA= ------END CERTIFICATE----- - -SSL.com TLS ECC Root CA 2022 -============================ ------BEGIN CERTIFICATE----- -MIICOjCCAcCgAwIBAgIQFAP1q/s3ixdAW+JDsqXRxDAKBggqhkjOPQQDAzBOMQswCQYDVQQGEwJV -UzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQDDBxTU0wuY29tIFRMUyBFQ0MgUm9v -dCBDQSAyMDIyMB4XDTIyMDgyNTE2MzM0OFoXDTQ2MDgxOTE2MzM0N1owTjELMAkGA1UEBhMCVVMx -GDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjElMCMGA1UEAwwcU1NMLmNvbSBUTFMgRUNDIFJvb3Qg -Q0EgMjAyMjB2MBAGByqGSM49AgEGBSuBBAAiA2IABEUpNXP6wrgjzhR9qLFNoFs27iosU8NgCTWy -JGYmacCzldZdkkAZDsalE3D07xJRKF3nzL35PIXBz5SQySvOkkJYWWf9lCcQZIxPBLFNSeR7T5v1 -5wj4A4j3p8OSSxlUgaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBSJjy+j6CugFFR7 -81a4Jl9nOAuc0DAdBgNVHQ4EFgQUiY8vo+groBRUe/NWuCZfZzgLnNAwDgYDVR0PAQH/BAQDAgGG -MAoGCCqGSM49BAMDA2gAMGUCMFXjIlbp15IkWE8elDIPDAI2wv2sdDJO4fscgIijzPvX6yv/N33w -7deedWo1dlJF4AIxAMeNb0Igj762TVntd00pxCAgRWSGOlDGxK0tk/UYfXLtqc/ErFc2KAhl3zx5 -Zn6g6g== ------END CERTIFICATE----- - -Atos TrustedRoot Root CA ECC TLS 2021 -===================================== ------BEGIN CERTIFICATE----- -MIICFTCCAZugAwIBAgIQPZg7pmY9kGP3fiZXOATvADAKBggqhkjOPQQDAzBMMS4wLAYDVQQDDCVB -dG9zIFRydXN0ZWRSb290IFJvb3QgQ0EgRUNDIFRMUyAyMDIxMQ0wCwYDVQQKDARBdG9zMQswCQYD -VQQGEwJERTAeFw0yMTA0MjIwOTI2MjNaFw00MTA0MTcwOTI2MjJaMEwxLjAsBgNVBAMMJUF0b3Mg -VHJ1c3RlZFJvb3QgUm9vdCBDQSBFQ0MgVExTIDIwMjExDTALBgNVBAoMBEF0b3MxCzAJBgNVBAYT -AkRFMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEloZYKDcKZ9Cg3iQZGeHkBQcfl+3oZIK59sRxUM6K -DP/XtXa7oWyTbIOiaG6l2b4siJVBzV3dscqDY4PMwL502eCdpO5KTlbgmClBk1IQ1SQ4AjJn8ZQS -b+/Xxd4u/RmAo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR2KCXWfeBmmnoJsmo7jjPX -NtNPojAOBgNVHQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwMDaAAwZQIwW5kp85wxtolrbNa9d+F851F+ -uDrNozZffPc8dz7kUK2o59JZDCaOMDtuCCrCp1rIAjEAmeMM56PDr9NJLkaCI2ZdyQAUEv049OGY -a3cpetskz2VAv9LcjBHo9H1/IISpQuQo ------END CERTIFICATE----- - -Atos TrustedRoot Root CA RSA TLS 2021 -===================================== ------BEGIN CERTIFICATE----- -MIIFZDCCA0ygAwIBAgIQU9XP5hmTC/srBRLYwiqipDANBgkqhkiG9w0BAQwFADBMMS4wLAYDVQQD -DCVBdG9zIFRydXN0ZWRSb290IFJvb3QgQ0EgUlNBIFRMUyAyMDIxMQ0wCwYDVQQKDARBdG9zMQsw -CQYDVQQGEwJERTAeFw0yMTA0MjIwOTIxMTBaFw00MTA0MTcwOTIxMDlaMEwxLjAsBgNVBAMMJUF0 -b3MgVHJ1c3RlZFJvb3QgUm9vdCBDQSBSU0EgVExTIDIwMjExDTALBgNVBAoMBEF0b3MxCzAJBgNV -BAYTAkRFMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtoAOxHm9BYx9sKOdTSJNy/BB -l01Z4NH+VoyX8te9j2y3I49f1cTYQcvyAh5x5en2XssIKl4w8i1mx4QbZFc4nXUtVsYvYe+W/CBG -vevUez8/fEc4BKkbqlLfEzfTFRVOvV98r61jx3ncCHvVoOX3W3WsgFWZkmGbzSoXfduP9LVq6hdK -ZChmFSlsAvFr1bqjM9xaZ6cF4r9lthawEO3NUDPJcFDsGY6wx/J0W2tExn2WuZgIWWbeKQGb9Cpt -0xU6kGpn8bRrZtkh68rZYnxGEFzedUlnnkL5/nWpo63/dgpnQOPF943HhZpZnmKaau1Fh5hnstVK -PNe0OwANwI8f4UDErmwh3El+fsqyjW22v5MvoVw+j8rtgI5Y4dtXz4U2OLJxpAmMkokIiEjxQGMY -sluMWuPD0xeqqxmjLBvk1cbiZnrXghmmOxYsL3GHX0WelXOTwkKBIROW1527k2gV+p2kHYzygeBY -Br3JtuP2iV2J+axEoctr+hbxx1A9JNr3w+SH1VbxT5Aw+kUJWdo0zuATHAR8ANSbhqRAvNncTFd+ -rrcztl524WWLZt+NyteYr842mIycg5kDcPOvdO3GDjbnvezBc6eUWsuSZIKmAMFwoW4sKeFYV+xa -fJlrJaSQOoD0IJ2azsct+bJLKZWD6TWNp0lIpw9MGZHQ9b8Q4HECAwEAAaNCMEAwDwYDVR0TAQH/ -BAUwAwEB/zAdBgNVHQ4EFgQUdEmZ0f+0emhFdcN+tNzMzjkz2ggwDgYDVR0PAQH/BAQDAgGGMA0G -CSqGSIb3DQEBDAUAA4ICAQAjQ1MkYlxt/T7Cz1UAbMVWiLkO3TriJQ2VSpfKgInuKs1l+NsW4AmS -4BjHeJi78+xCUvuppILXTdiK/ORO/auQxDh1MoSf/7OwKwIzNsAQkG8dnK/haZPso0UvFJ/1TCpl -Q3IM98P4lYsU84UgYt1UU90s3BiVaU+DR3BAM1h3Egyi61IxHkzJqM7F78PRreBrAwA0JrRUITWX -AdxfG/F851X6LWh3e9NpzNMOa7pNdkTWwhWaJuywxfW70Xp0wmzNxbVe9kzmWy2B27O3Opee7c9G -slA9hGCZcbUztVdF5kJHdWoOsAgMrr3e97sPWD2PAzHoPYJQyi9eDF20l74gNAf0xBLh7tew2Vkt -afcxBPTy+av5EzH4AXcOPUIjJsyacmdRIXrMPIWo6iFqO9taPKU0nprALN+AnCng33eU0aKAQv9q -TFsR0PXNor6uzFFcw9VUewyu1rkGd4Di7wcaaMxZUa1+XGdrudviB0JbuAEFWDlN5LuYo7Ey7Nmj -1m+UI/87tyll5gfp77YZ6ufCOB0yiJA8EytuzO+rdwY0d4RPcuSBhPm5dDTedk+SKlOxJTnbPP/l -PqYO5Wue/9vsL3SD3460s6neFE3/MaNFcyT6lSnMEpcEoji2jbDwN/zIIX8/syQbPYtuzE2wFg2W -HYMfRsCbvUOZ58SWLs5fyQ== ------END CERTIFICATE----- - -TrustAsia Global Root CA G3 -=========================== ------BEGIN CERTIFICATE----- -MIIFpTCCA42gAwIBAgIUZPYOZXdhaqs7tOqFhLuxibhxkw8wDQYJKoZIhvcNAQEMBQAwWjELMAkG -A1UEBhMCQ04xJTAjBgNVBAoMHFRydXN0QXNpYSBU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0GA1UdDgQWBBRA5OTyI+84yrCuV3/yITAWNNu8kjAOBgNVHQ8BAf8E -BAMCAQYwDQYJKoZIhvcNAQEMBQADggIBACY7UeFNOPMyGLS0XuFlXsSUT9SnYaP4wM8zAQLpw6o1 -D/GUE3d3NZ4tVlFEbuHGLige/9rsR82XRBf34EzC4Xx8MnpmyFq2XFNFV1pF1AWZLy4jVe5jaN/T -G3inEpQGAHUNcoTpLrxaatXeL1nHo+zSh2bbt1S1JKv0Q3jbSwTEb93mPmY+KfJLaHEih6D4sTNj -duMNhXJEIlU/HHzp/LgV6FL6qj6jITk1dImmasI5+njPtqzn59ZW/yOSLlALqbUHM/Q4X6RJpstl -cHboCoWASzY9M/eVVHUl2qzEc4Jl6VL1XP04lQJqaTDFHApXB64ipCz5xUG3uOyfT0gA+QEEVcys -+TIxxHWVBqB/0Y0n3bOppHKH/lmLmnp0Ft0WpWIp6zqW3IunaFnT63eROfjXy9mPX1onAX1daBli -2MjN9LdyR75bl87yraKZk62Uy5P2EgmVtqvXO9A/EcswFi55gORngS1d7XB4tmBZrOFdRWOPyN9y -aFvqHbgB8X7754qz41SgOAngPN5C8sLtLpvzHzW2NtjjgKGLzZlkD8Kqq7HK9W+eQ42EVJmzbsAS -ZthwEPEGNTNDqJwuuhQxzhB/HIbjj9LV+Hfsm6vxL2PZQl/gZ4FkkfGXL/xuJvYz+NO1+MRiqzFR -JQJ6+N1rZdVtTTDIZbpoFGWsJwt0ivKH ------END CERTIFICATE----- - -TrustAsia Global Root CA G4 -=========================== ------BEGIN CERTIFICATE----- -MIICVTCCAdygAwIBAgIUTyNkuI6XY57GU4HBdk7LKnQV1tcwCgYIKoZIzj0EAwMwWjELMAkGA1UE -BhMCQ04xJTAjBgNVBAoMHFRydXN0QXNpYSBUZWNobm9sb2dpZXMsIEluYy4xJDAiBgNVBAMMG1Ry -dXN0QXNpYSBHbG9iYWwgUm9vdCBDQSBHNDAeFw0yMTA1MjAwMjEwMjJaFw00NjA1MTkwMjEwMjJa -MFoxCzAJBgNVBAYTAkNOMSUwIwYDVQQKDBxUcnVzdEFzaWEgVGVjaG5vbG9naWVzLCBJbmMuMSQw -IgYDVQQDDBtUcnVzdEFzaWEgR2xvYmFsIFJvb3QgQ0EgRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNi -AATxs8045CVD5d4ZCbuBeaIVXxVjAd7Cq92zphtnS4CDr5nLrBfbK5bKfFJV4hrhPVbwLxYI+hW8 -m7tH5j/uqOFMjPXTNvk4XatwmkcN4oFBButJ+bAp3TPsUKV/eSm4IJijYzBhMA8GA1UdEwEB/wQF -MAMBAf8wHwYDVR0jBBgwFoAUpbtKl86zK3+kMd6Xg1mDpm9xy94wHQYDVR0OBBYEFKW7SpfOsyt/ -pDHel4NZg6ZvccveMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjBe8usGzEkxn0AA -bbd+NvBNEU/zy4k6LHiRUKNbwMp1JvK/kF0LgoxgKJ/GcJpo5PECMFxYDlZ2z1jD1xCMuo6u47xk -dUfFVZDj/bpV6wfEU6s3qe4hsiFbYI89MvHVI5TWWA== ------END CERTIFICATE----- - -Telekom Security TLS ECC Root 2020 -================================== ------BEGIN CERTIFICATE----- -MIICQjCCAcmgAwIBAgIQNjqWjMlcsljN0AFdxeVXADAKBggqhkjOPQQDAzBjMQswCQYDVQQGEwJE -RTEnMCUGA1UECgweRGV1dHNjaGUgVGVsZWtvbSBTZWN1cml0eSBHbWJIMSswKQYDVQQDDCJUZWxl -a29tIFNlY3VyaXR5IFRMUyBFQ0MgUm9vdCAyMDIwMB4XDTIwMDgyNTA3NDgyMFoXDTQ1MDgyNTIz -NTk1OVowYzELMAkGA1UEBhMCREUxJzAlBgNVBAoMHkRldXRzY2hlIFRlbGVrb20gU2VjdXJpdHkg -R21iSDErMCkGA1UEAwwiVGVsZWtvbSBTZWN1cml0eSBUTFMgRUNDIFJvb3QgMjAyMDB2MBAGByqG -SM49AgEGBSuBBAAiA2IABM6//leov9Wq9xCazbzREaK9Z0LMkOsVGJDZos0MKiXrPk/OtdKPD/M1 -2kOLAoC+b1EkHQ9rK8qfwm9QMuU3ILYg/4gND21Ju9sGpIeQkpT0CdDPf8iAC8GXs7s1J8nCG6NC -MEAwHQYDVR0OBBYEFONyzG6VmUex5rNhTNHLq+O6zd6fMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P -AQH/BAQDAgEGMAoGCCqGSM49BAMDA2cAMGQCMHVSi7ekEE+uShCLsoRbQuHmKjYC2qBuGT8lv9pZ -Mo7k+5Dck2TOrbRBR2Diz6fLHgIwN0GMZt9Ba9aDAEH9L1r3ULRn0SyocddDypwnJJGDSA3PzfdU -ga/sf+Rn27iQ7t0l ------END CERTIFICATE----- - -Telekom Security TLS RSA Root 2023 -================================== ------BEGIN CERTIFICATE----- -MIIFszCCA5ugAwIBAgIQIZxULej27HF3+k7ow3BXlzANBgkqhkiG9w0BAQwFADBjMQswCQYDVQQG -EwJERTEnMCUGA1UECgweRGV1dHNjaGUgVGVsZWtvbSBTZWN1cml0eSBHbWJIMSswKQYDVQQDDCJU -ZWxla29tIFNlY3VyaXR5IFRMUyBSU0EgUm9vdCAyMDIzMB4XDTIzMDMyODEyMTY0NVoXDTQ4MDMy -NzIzNTk1OVowYzELMAkGA1UEBhMCREUxJzAlBgNVBAoMHkRldXRzY2hlIFRlbGVrb20gU2VjdXJp -dHkgR21iSDErMCkGA1UEAwwiVGVsZWtvbSBTZWN1cml0eSBUTFMgUlNBIFJvb3QgMjAyMzCCAiIw -DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAO01oYGA88tKaVvC+1GDrib94W7zgRJ9cUD/h3VC -KSHtgVIs3xLBGYSJwb3FKNXVS2xE1kzbB5ZKVXrKNoIENqil/Cf2SfHVcp6R+SPWcHu79ZvB7JPP -GeplfohwoHP89v+1VmLhc2o0mD6CuKyVU/QBoCcHcqMAU6DksquDOFczJZSfvkgdmOGjup5czQRx -UX11eKvzWarE4GC+j4NSuHUaQT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bzsQCzndILIyy7MMAo+wsVRjBfhnu4S/yrYObnqsZ38aKL4x35bcF7DvB7L6Gs4a8 -wPfc5+pbrrLMtTWGS9DiP7bY+A4A7l3j941Y/8+LN+ljX273CXE2whJdV/LItM3z7gLfEdxquVeE -HVlNjM7IDiPCtyaaEBRx/pOyiriA8A4QntOoUAw3gi/q4Iqd4Sw5/7W0cwDk90imc6y/st53BIe0 -o82bNSQ3+pCTE4FCxpgmdTdmQRCsu/WU48IxK63nI1bMNSWSs1A= ------END CERTIFICATE----- - -TWCA CYBER Root CA -================== ------BEGIN CERTIFICATE----- -MIIFjTCCA3WgAwIBAgIQQAE0jMIAAAAAAAAAATzyxjANBgkqhkiG9w0BAQwFADBQMQswCQYDVQQG -EwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJUV0NB -IENZQkVSIFJvb3QgQ0EwHhcNMjIxMTIyMDY1NDI5WhcNNDcxMTIyMTU1OTU5WjBQMQswCQYDVQQG -EwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJUV0NB -IENZQkVSIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDG+Moe2Qkgfh1s -Ts6P40czRJzHyWmqOlt47nDSkvgEs1JSHWdyKKHfi12VCv7qze33Kc7wb3+szT3vsxxFavcokPFh -V8UMxKNQXd7UtcsZyoC5dc4pztKFIuwCY8xEMCDa6pFbVuYdHNWdZsc/34bKS1PE2Y2yHer43CdT -o0fhYcx9tbD47nORxc5zb87uEB8aBs/pJ2DFTxnk684iJkXXYJndzk834H/nY62wuFm40AZoNWDT -Nq5xQwTxaWV4fPMf88oon1oglWa0zbfuj3ikRRjpJi+NmykosaS3Om251Bw4ckVYsV7r8Cibt4LK -/c/WMw+f+5eesRycnupfXtuq3VTpMCEobY5583WSjCb+3MX2w7DfRFlDo7YDKPYIMKoNM+HvnKk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yOWHh8qgnaHl -IhInD0Q9HWzq1MKLL295q39QpsQZp6F6t5b5wR9iWqJDB0BeJsas7a5wFsWqynKKTbDPAYsDP27X ------END CERTIFICATE----- - -SecureSign Root CA14 -==================== ------BEGIN CERTIFICATE----- -MIIFcjCCA1qgAwIBAgIUZNtaDCBO6Ncpd8hQJ6JaJ90t8sswDQYJKoZIhvcNAQEMBQAwUTELMAkG -A1UEBhMCSlAxIzAhBgNVBAoTGkN5YmVydHJ1c3QgSmFwYW4gQ28uLCBMdGQuMR0wGwYDVQQDExRT -ZWN1cmVTaWduIFJvb3QgQ0ExNDAeFw0yMDA0MDgwNzA2MTlaFw00NTA0MDgwNzA2MTlaMFExCzAJ -BgNVBAYTAkpQMSMwIQYDVQQKExpDeWJlcnRydXN0IEphcGFuIENvLiwgTHRkLjEdMBsGA1UEAxMU -U2VjdXJlU2lnbiBSb290IENBMTQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDF0nqh -1oq/FjHQmNE6lPxauG4iwWL3pwon71D2LrGeaBLwbCRjOfHw3xDG3rdSINVSW0KZnvOgvlIfX8xn -bacuUKLBl422+JX1sLrcneC+y9/3OPJH9aaakpUqYllQC6KxNedlsmGy6pJxaeQp8E+BgQQ8sqVb -1MWoWWd7VRxJq3qdwudzTe/NCcLEVxLbAQ4jeQkHO6Lo/IrPj8BGJJw4J+CDnRugv3gVEOuGTgpa -/d/aLIJ+7sr2KeH6caH3iGicnPCNvg9JkdjqOvn90Ghx2+m1K06Ckm9mH+Dw3EzsytHqunQG+bOE -kJTRX45zGRBdAuVwpcAQ0BB8b8VYSbSwbprafZX1zNoCr7gsfXmPvkPx+SgojQlD+Ajda8iLLCSx -jVIHvXiby8posqTdDEx5YMaZ0ZPxMBoH064iwurO8YQJzOAUbn8/ftKChazcqRZOhaBgy/ac18iz -ju3Gm5h1DVXoX+WViwKkrkMpKBGk5hIwAUt1ax5mnXkvpXYvHUC0bcl9eQjs0Wq2XSqypWa9a4X0 -dFbD9ed1Uigspf9mR6XU/v6eVL9lfgHWMI+lNpyiUBzuOIABSMbHdPTGrMNASRZhdCyvjG817XsY -AFs2PJxQDcqSMxDxJklt33UkN4Ii1+iW/RVLApY+B3KVfqs9TC7XyvDf4Fg/LS8EmjijAQIDAQAB -o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUBpOjCl4oaTeq -YR3r6/wtbyPk86AwDQYJKoZIhvcNAQEMBQADggIBAJaAcgkGfpzMkwQWu6A6jZJOtxEaCnFxEM0E -rX+lRVAQZk5KQaID2RFPeje5S+LGjzJmdSX7684/AykmjbgWHfYfM25I5uj4V7Ibed87hwriZLoA -ymzvftAj63iP/2SbNDefNWWipAA9EiOWWF3KY4fGoweITedpdopTzfFP7ELyk+OZpDc8h7hi2/Ds -Hzc/N19DzFGdtfCXwreFamgLRB7lUe6TzktuhsHSDCRZNhqfLJGP4xjblJUK7ZGqDpncllPjYYPG -FrojutzdfhrGe0K22VoF3Jpf1d+42kd92jjbrDnVHmtsKheMYc2xbXIBw8MgAGJoFjHVdqqGuw6q -nsb58Nn4DSEC5MUoFlkRudlpcyqSeLiSV5sI8jrlL5WwWLdrIBRtFO8KvH7YVdiI2i/6GaX7i+B/ -OfVyK4XELKzvGUWSTLNhB9xNH27SgRNcmvMSZ4PPmz+Ln52kuaiWA3rF7iDeM9ovnhp6dB7h7sxa -OgTdsxoEqBRjrLdHEoOabPXm6RUVkRqEGQ6UROcSjiVbgGcZ3GOTEAtlLor6CZpO2oYofaphNdgO -pygau1LgePhsumywbrmHXumZNTfxPWQrqaA0k89jL9WB365jJ6UeTo3cKXhZ+PmhIIynJkBugnLN -eLLIjzwec+fBH7/PzqUqm9tEZDKgu39cJRNItX+S ------END CERTIFICATE----- - -SecureSign Root CA15 -==================== ------BEGIN CERTIFICATE----- -MIICIzCCAamgAwIBAgIUFhXHw9hJp75pDIqI7fBw+d23PocwCgYIKoZIzj0EAwMwUTELMAkGA1UE -BhMCSlAxIzAhBgNVBAoTGkN5YmVydHJ1c3QgSmFwYW4gQ28uLCBMdGQuMR0wGwYDVQQDExRTZWN1 -cmVTaWduIFJvb3QgQ0ExNTAeFw0yMDA0MDgwODMyNTZaFw00NTA0MDgwODMyNTZaMFExCzAJBgNV -BAYTAkpQMSMwIQYDVQQKExpDeWJlcnRydXN0IEphcGFuIENvLiwgTHRkLjEdMBsGA1UEAxMUU2Vj -dXJlU2lnbiBSb290IENBMTUwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQLUHSNZDKZmbPSYAi4Io5G -dCx4wCtELW1fHcmuS1Iggz24FG1Th2CeX2yF2wYUleDHKP+dX+Sq8bOLbe1PL0vJSpSRZHX+AezB -2Ot6lHhWGENfa4HL9rzatAy2KZMIaY+jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD -AgEGMB0GA1UdDgQWBBTrQciu/NWeUUj1vYv0hyCTQSvT9DAKBggqhkjOPQQDAwNoADBlAjEA2S6J -fl5OpBEHvVnCB96rMjhTKkZEBhd6zlHp4P9mLQlO4E/0BdGF9jVg3PVys0Z9AjBEmEYagoUeYWmJ -SwdLZrWeqrqgHkHZAXQ6bkU6iYAZezKYVWOr62Nuk22rGwlgMU4= ------END CERTIFICATE----- - -D-TRUST BR Root CA 2 2023 -========================= ------BEGIN CERTIFICATE----- -MIIFqTCCA5GgAwIBAgIQczswBEhb2U14LnNLyaHcZjANBgkqhkiG9w0BAQ0FADBIMQswCQYDVQQG -EwJERTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEJSIFJvb3QgQ0Eg -MiAyMDIzMB4XDTIzMDUwOTA4NTYzMVoXDTM4MDUwOTA4NTYzMFowSDELMAkGA1UEBhMCREUxFTAT -BgNVBAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBCUiBSb290IENBIDIgMjAyMzCC -AiIwDQYJKoZIhvcNAQ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w9QAgLABMjDu0ox+2v5Eyq6+SmNMW5tTRVFxDWy6u71cqqLRvpO8NVhTaIasgdp4D/Ca4 -nj8+AybmTNudX0KEPUUDAxxZiMrcLmEkWqTqJwtzEr5SswrPMhfiHocaFpVIbVrg0M8JkiZmkdij -YQ6qgYF/6FKC0ULn4B0Y+qSFNueG4A3rvNTJ1jxD8V1Jbn6Bm2m1iWKPiFLY1/4nwSPFyysCu7Ff -/vtDhQNGvl3GyiEm/9cCnnRK3PgTFbGBVzbLZVzRHTF36SXDw7IyN9XxmAnkbWOACKsGkoHU6XCP -pz+y7YaMgmo1yEJagtFSGkUPFaUA8JR7ZSdXOUPPfH/mvTWze/EZTN46ls/pdu4D58JDUjxqgejB -WoC9EV2Ta/vH5mQ/u2kc6d0li690yVRAysuTEwrt+2aSEcr1wPrYg1UDfNPFIkZ1cGt5SAYqgpq/ -5usWDiJFAbzdNpQ0qTUmiteXue4Icr80knCDgKs4qllo3UCkGJCy89UDyibK79XH4I9TjvAA46jt -n/mtd+ArY0+ew+43u3gJhJ65bvspmZDogNOfJA== ------END CERTIFICATE----- - -TrustAsia TLS ECC Root CA -========================= ------BEGIN CERTIFICATE----- -MIICMTCCAbegAwIBAgIUNnThTXxlE8msg1UloD5Sfi9QaMcwCgYIKoZIzj0EAwMwWDELMAkGA1UE -BhMCQ04xJTAjBgNVBAoTHFRydXN0QXNpYSBUZWNobm9sb2dpZXMsIEluYy4xIjAgBgNVBAMTGVRy -dXN0QXNpYSBUTFMgRUNDIFJvb3QgQ0EwHhcNMjQwNTE1MDU0MTU2WhcNNDQwNTE1MDU0MTU1WjBY -MQswCQYDVQQGEwJDTjElMCMGA1UEChMcVHJ1c3RBc2lhIFRlY2hub2xvZ2llcywgSW5jLjEiMCAG -A1UEAxMZVHJ1c3RBc2lhIFRMUyBFQ0MgUm9vdCBDQTB2MBAGByqGSM49AgEGBSuBBAAiA2IABLh/ -pVs/AT598IhtrimY4ZtcU5nb9wj/1WrgjstEpvDBjL1P1M7UiFPoXlfXTr4sP/MSpwDpguMqWzJ8 -S5sUKZ74LYO1644xST0mYekdcouJtgq7nDM1D9rs3qlKH8kzsaNCMEAwDwYDVR0TAQH/BAUwAwEB -/zAdBgNVHQ4EFgQULIVTu7FDzTLqnqOH/qKYqKaT6RAwDgYDVR0PAQH/BAQDAgEGMAoGCCqGSM49 -BAMDA2gAMGUCMFRH18MtYYZI9HlaVQ01L18N9mdsd0AaRuf4aFtOJx24mH1/k78ITcTaRTChD15K -eAIxAKORh/IRM4PDwYqROkwrULG9IpRdNYlzg8WbGf60oenUoWa2AaU2+dhoYSi3dOGiMQ== ------END CERTIFICATE----- - -TrustAsia TLS RSA Root CA -========================= ------BEGIN CERTIFICATE----- -MIIFgDCCA2igAwIBAgIUHBjYz+VTPyI1RlNUJDxsR9FcSpwwDQYJKoZIhvcNAQEMBQAwWDELMAkG -A1UEBhMCQ04xJTAjBgNVBAoTHFRydXN0QXNpYSBUZWNobm9sb2dpZXMsIEluYy4xIjAgBgNVBAMT -GVRydXN0QXNpYSBUTFMgUlNBIFJvb3QgQ0EwHhcNMjQwNTE1MDU0MTU3WhcNNDQwNTE1MDU0MTU2 -WjBYMQswCQYDVQQGEwJDTjElMCMGA1UEChMcVHJ1c3RBc2lhIFRlY2hub2xvZ2llcywgSW5jLjEi -MCAGA1UEAxMZVHJ1c3RBc2lhIFRMUyBSU0EgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIP -ADCCAgoCggIBAMMWuBtqpERz5dZO9LnPWwvB0ZqB9WOwj0PBuwhaGnrhB3YmH49pVr7+NmDQDIPN -lOrnxS1cLwUWAp4KqC/lYCZUlviYQB2srp10Zy9U+5RjmOMmSoPGlbYJQ1DNDX3eRA5gEk9bNb2/ -mThtfWza4mhzH/kxpRkQcwUqwzIZheo0qt1CHjCNP561HmHVb70AcnKtEj+qpklz8oYVlQwQX1Fk -zv93uMltrOXVmPGZLmzjyUT5tUMnCE32ft5EebuyjBza00tsLtbDeLdM1aTk2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IweSsCI3zWQzj8C9GRh3sfI -B5XeMhg6j6JCQCTl1jNdfK7vsU1P1FeQNWrcrgSXSYk0ly4wBOeY99sLAZDBHwo/+ML+TvrbmnNz -FrwFuHnYWa8G5z9nODmxfKuU4CkUpijy323imttUQ/hHWKNddBWcwauwxzQ= ------END CERTIFICATE----- - -D-TRUST EV Root CA 2 2023 -========================= ------BEGIN CERTIFICATE----- -MIIFqTCCA5GgAwIBAgIQaSYJfoBLTKCnjHhiU19abzANBgkqhkiG9w0BAQ0FADBIMQswCQYDVQQG -EwJERTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEVWIFJvb3QgQ0Eg -MiAyMDIzMB4XDTIzMDUwOTA5MTAzM1oXDTM4MDUwOTA5MTAzMlowSDELMAkGA1UEBhMCREUxFTAT -BgNVBAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBFViBSb290IENBIDIgMjAyMzCC -AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANiOo4mAC7JXUtypU0w3uX9jFxPvp1sjW2l1 -sJkKF8GLxNuo4MwxusLyzV3pt/gdr2rElYfXR8mV2IIEUD2BCP/kPbOx1sWy/YgJ25yE7CUXFId/ -MHibaljJtnMoPDT3mfd/06b4HEV8rSyMlD/YZxBTfiLNTiVR8CUkNRFeEMbsh2aJgWi6zCudR3Mf -vc2RpHJqnKIbGKBv7FD0fUDCqDDPvXPIEysQEx6Lmqg6lHPTGGkKSv/BAQP/eX+1SH977ugpbzZM -lWGG2Pmic4ruri+W7mjNPU0oQvlFKzIbRlUWaqZLKfm7lVa/Rh3sHZMdwGWyH6FDrlaeoLGPaxK3 -YG14C8qKXO0elg6DpkiVjTujIcSuWMYAsoS0I6SWhjW42J7YrDRJmGOVxcttSEfi8i4YHtAxq910 -7PncjLgcjmgjutDzUNzPZY9zOjLHfP7KgiJPvo5iR2blzYfi6NUPGJ/lBHJLRjwQ8kTCZFZxTnXo -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4ko1Di1L -+KIkBI3Y4WNeApI02phhXBxvWHZks/wCuPWdCg== ------END CERTIFICATE----- - -SwissSign RSA TLS Root CA 2022 - 1 -================================== ------BEGIN CERTIFICATE----- -MIIFkzCCA3ugAwIBAgIUQ/oMX04bgBhE79G0TzUfRPSA7cswDQYJKoZIhvcNAQELBQAwUTELMAkG -A1UEBhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzErMCkGA1UEAxMiU3dpc3NTaWduIFJTQSBU -TFMgUm9vdCBDQSAyMDIyIC0gMTAeFw0yMjA2MDgxMTA4MjJaFw00NzA2MDgxMTA4MjJaMFExCzAJ -BgNVBAYTAkNIMRUwEwYDVQQKEwxTd2lzc1NpZ24gQUcxKzApBgNVBAMTIlN3aXNzU2lnbiBSU0Eg -VExTIFJvb3QgQ0EgMjAyMiAtIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDLKmji -C8NXvDVjvHClO/OMPE5Xlm7DTjak9gLKHqquuN6orx122ro10JFwB9+zBvKK8i5VUXu7LCTLf5Im -gKO0lPaCoaTo+nUdWfMHamFk4saMla+ju45vVs9xzF6BYQ1t8qsCLqSX5XH8irCRIFucdFJtrhUn -WXjyCcplDn/L9Ovn3KlMd/YrFgSVrpxxpT8q2kFC5zyEEPThPYxr4iuRR1VPuFa+Rd4iUU1OKNlf -GUEGjw5NBuBwQCMBauTLE5tzrE0USJIt/m2n+IdreXXhvhCxqohAWVTXz8TQm0SzOGlkjIHRI36q -OTw7D59Ke4LKa2/KIj4x0LDQKhySio/YGZxH5D4MucLNvkEM+KRHBdvBFzA4OmnczcNpI/2aDwLO -EGrOyvi5KaM2iYauC8BPY7kGWUleDsFpswrzd34unYyzJ5jSmY0lpx+Gs6ZUcDj8fV3oT4MM0ZPl -EuRU2j7yrTrePjxF8CgPBrnh25d7mUWe3f6VWQQvdT/TromZhqwUtKiE+shdOxtYk8EXlFXIC+OC -eYSf8wCENO7cMdWP8vpPlkwGqnj73mSiI80fPsWMvDdUDrtaclXvyFu1cvh43zcgTFeRc5JzrBh3 -Q4IgaezprClG5QtO+DdziZaKHG29777YtvTKwP1H8K4LWCDFyB02rpeNUIMmJCn3nTsPBQIDAQAB -o2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBRvjmKLk0Ow -4UD2p8P98Q+4DxU4pTAdBgNVHQ4EFgQUb45ii5NDsOFA9qfD/fEPuA8VOKUwDQYJKoZIhvcNAQEL -BQADggIBAKwsKUF9+lz1GpUYvyypiqkkVHX1uECry6gkUSsYP2OprphWKwVDIqO310aewCoSPY6W -lkDfDDOLazeROpW7OSltwAJsipQLBwJNGD77+3v1dj2b9l4wBlgzHqp41eZUBDqyggmNzhYzWUUo -8aWjlw5DI/0LIICQ/+Mmz7hkkeUFjxOgdg3XNwwQiJb0Pr6VvfHDffCjw3lHC1ySFWPtUnWK50Zp -y1FVCypM9fJkT6lc/2cyjlUtMoIcgC9qkfjLvH4YoiaoLqNTKIftV+Vlek4ASltOU8liNr3Cjlvr -zG4ngRhZi0Rjn9UMZfQpZX+RLOV/fuiJz48gy20HQhFRJjKKLjpHE7iNvUcNCfAWpO2Whi4Z2L6M -OuhFLhG6rlrnub+xzI/goP+4s9GFe3lmozm1O2bYQL7Pt2eLSMkZJVX8vY3PXtpOpvJpzv1/THfQ -wUY1mFwjmwJFQ5Ra3bxHrSL+ul4vkSkphnsh3m5kt8sNjzdbowhq6/TdAo9QAwKxuDdollDruF/U -KIqlIgyKhPBZLtU30WHlQnNYKoH3dtvi4k0NX/a3vgW0rk4N3hY9A4GzJl5LuEsAz/+MF7psYC0n -hzck5npgL7XTgwSqT0N1osGDsieYK7EOgLrAhV5Cud+xYJHT6xh+cHiudoO+cVrQkOPKwRYlZ0rw -tnu64ZzZ ------END CERTIFICATE----- - -OISTE Server Root ECC G1 -======================== ------BEGIN CERTIFICATE----- -MIICNTCCAbqgAwIBAgIQI/nD1jWvjyhLH/BU6n6XnTAKBggqhkjOPQQDAzBLMQswCQYDVQQGEwJD -SDEZMBcGA1UECgwQT0lTVEUgRm91bmRhdGlvbjEhMB8GA1UEAwwYT0lTVEUgU2VydmVyIFJvb3Qg -RUNDIEcxMB4XDTIzMDUzMTE0NDIyOFoXDTQ4MDUyNDE0NDIyN1owSzELMAkGA1UEBhMCQ0gxGTAX -BgNVBAoMEE9JU1RFIEZvdW5kYXRpb24xITAfBgNVBAMMGE9JU1RFIFNlcnZlciBSb290IEVDQyBH -MTB2MBAGByqGSM49AgEGBSuBBAAiA2IABBcv+hK8rBjzCvRE1nZCnrPoH7d5qVi2+GXROiFPqOuj -vqQycvO2Ackr/XeFblPdreqqLiWStukhEaivtUwL85Zgmjvn6hp4LrQ95SjeHIC6XG4N2xml4z+c -KrhAS93mT6NjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBQ3TYhlz/w9itWj8UnATgwQ -b0K0nDAdBgNVHQ4EFgQUN02IZc/8PYrVo/FJwE4MEG9CtJwwDgYDVR0PAQH/BAQDAgGGMAoGCCqG -SM49BAMDA2kAMGYCMQCpKjAd0MKfkFFRQD6VVCHNFmb3U2wIFjnQEnx/Yxvf4zgAOdktUyBFCxxg -ZzFDJe0CMQCSia7pXGKDYmH5LVerVrkR3SW+ak5KGoJr3M/TvEqzPNcum9v4KGm8ay3sMaE641c= ------END CERTIFICATE----- - -OISTE Server Root RSA G1 -======================== ------BEGIN CERTIFICATE----- -MIIFgzCCA2ugAwIBAgIQVaXZZ5Qoxu0M+ifdWwFNGDANBgkqhkiG9w0BAQwFADBLMQswCQYDVQQG -EwJDSDEZMBcGA1UECgwQT0lTVEUgRm91bmRhdGlvbjEhMB8GA1UEAwwYT0lTVEUgU2VydmVyIFJv -b3QgUlNBIEcxMB4XDTIzMDUzMTE0MzcxNloXDTQ4MDUyNDE0MzcxNVowSzELMAkGA1UEBhMCQ0gx -GTAXBgNVBAoMEE9JU1RFIEZvdW5kYXRpb24xITAfBgN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sjkLWd9kYccnbz8qyiWXmFcuCIzGEgWUOrKL+ml -Sdx/PKQZvDatkuK59EvV6wit53j+F8Bdh3foZ3dPAGav9LEDOr4SfEE15fSmG0eLy3n31r8Xbk5l -8PjaV8GUgeV6Vg27Rn9vkf195hfkgSe7BYhW3SCl95gtkRlpMV+bMPKZrXJAlszYd2abtNUOshD+ -FKrDgHGdPY3ofRRsYWSGRqbXVMW215AWRqWFyp464+YTFrYVI8ypKVL9AMb2kI5Wj4kI3Zaq5tNq -qYY19tVFeEJKRvwDyF7YZvZFZSS0vod7VSCd9521Kvy5YhnLbDuv0204bKt7ph6N/Ome/msVuduC -msuY33OhkKCgxeDoAaijFJzIwZqsFVAzje18KotzlUBDJvyBpCpfOZC3J8tRd/iWkx7P8nd9H0aT -olkelUTFLXVksNb54Dxp6gS1HAviRkRNQzuXSXERvSS2wq1yVAb+axj5d9spLFKebXd7Yv0PTY6Y -MjAwcRLWJTXjn/hvnLXrahut6hDTlhZyBiElxky8j3C7DOReIoMt0r7+hVu05L0= ------END CERTIFICATE----- - -e-Szigno TLS Root CA 2023 -========================= ------BEGIN CERTIFICATE----- -MIICzzCCAjGgAwIBAgINAOhvGHvWOWuYSkmYCjAKBggqhkjOPQQDBDB1MQswCQYDVQQGEwJIVTER -MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xFzAVBgNVBGEMDlZBVEhV -LTIzNTg0NDk3MSIwIAYDVQQDDBllLVN6aWdubyBUTFMgUm9vdCBDQSAyMDIzMB4XDTIzMDcxNzE0 -MDAwMFoXDTM4MDcxNzE0MDAwMFowdTELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRYw -FAYDVQQKDA1NaWNyb3NlYyBMdGQuMRcwFQYDVQRhDA5WQVRIVS0yMzU4NDQ5NzEiMCAGA1UEAwwZ -ZS1Temlnbm8gVExTIFJvb3QgQ0EgMjAyMzCBmzAQBgcqhkjOPQIBBgUrgQ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Uf0C -5CEP6dbQlfgxWfzYr69yVT6dPQB+GFEaY03IMY+AcBCs+om1fNxrQXt9zoofMBNFbLhvpNH/JsXW -dGUzfNbO12uswTa5wah8LB18FTQN2/zPHYmvBEoLuyUgZ09VNLJo5YA0kXItVYkLjMe2SixzK4sc -UHv81IK99I91DWx7FwMVKw2xgFp+ZLYB2dnpQQrqwlW64glHUcK2N9BDsnjLSxeZ+UPECh9RxH4W -AcKiZW+cqaKMmhP2WBfR4IcR7NOL32ml11ds87hhV1CZWWFCJAcCidYZz6CZa8exzHojP9SB5RH0 -/v1KdHAisqhSjtJl/UIAHIQ48elOn8wrTdFap4Yb5aHglmMeNx+fAIhDluWVfxTO7H4dTPU+SFVR -MLAh+wwKZfqb94nMeQ== ------END CERTIFICATE----- - -SECOM TLS ECC Root CA 2024 -========================== ------BEGIN CERTIFICATE----- -MIICTDCCAdGgAwIBAgIJAIF6LO+PI3pEMAoGCCqGSM49BAMDMFoxCzAJBgNVBAYTAkpQMSYwJAYD -VQQKEx1TRUNPTSBUcnVzdCBTeXN0ZW1zIENvLiwgTHRkLjEjMCEGA1UEAxMaU0VDT00gVExTIEVD -QyBSb290IENBIDIwMjQwHhcNMjQwMTMxMDU1MjM0WhcNNDkwMTE0MDU1MjM0WjBaMQswCQYDVQQG -EwJKUDEmMCQGA1UEChMdU0VDT00gVHJ1c3QgU3lzdGVtcyBDby4sIEx0ZC4xIzAhBgNVBAMTGlNF -Q09NIFRMUyBFQ0MgUm9vdCBDQSAyMDI0MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE7NzFMtu9dzQX -SNC12fabk0+GlC5finB3R7XaZonRUd20aFiWObtuNBCLUZSfk6QXAE55BjEXsXQ/NG8yUqicXjsu -9ksDK3JZBgCwLOVh6+nwJXTvso/dEj/GUYH5mBdoo2MwYTAdBgNVHQ4EFgQUO3YReyl04k4GTFaC -QNAhL3qzydUwHwYDVR0jBBgwFoAUO3YReyl04k4GTFaCQNAhL3qzydUwDgYDVR0PAQH/BAQDAgEG -MA8GA1UdEwEB/wQFMAMBAf8wCgYIKoZIzj0EAwMDaQAwZgIxAN3ib8fi1pMYtAPjMilB5e5/H+t5 -CL0xPL+cZ5oTTZuSCjpAn1v7F/VAr8bFxQXAowIxAKsBVO1ACFp7skwzPvdv1EUY5a897WGLT4lb -+bjxFAWyl8wDcZJdwGZ/pAHxt1AJ1g== ------END CERTIFICATE----- - -Telia EC TLS Root CA v3 -======================= ------BEGIN CERTIFICATE----- -MIICMjCCAbegAwIBAgIPAYvSIlRjTQSLbOVHH9K1MAoGCCqGSM49BAMDMEoxCzAJBgNVBAYTAlNF -MRkwFwYDVQQKDBBUZWxpYSBDb21wYW55IEFCMSAwHgYDVQQDDBdUZWxpYSBFQyBUTFMgUm9vdCBD -QSB2MzAeFw0yMzExMTUwODU1MjZaFw00ODA1MjMxMTAwMDBaMEoxCzAJBgNVBAYTAlNFMRkwFwYD -VQQKDBBUZWxpYSBDb21wYW55IEFCMSAwHgYDVQQDDBdUZWxpYSBFQyBUTFMgUm9vdCBDQSB2MzB2 -MBAGByqGSM49AgEGBSuBBAAiA2IABMHIlhVDLbmFKUpW0iK4dpryT6emYOeS31JPwWnWPmkWRrAk -TbPX40sQfHI9mpR7Rbktu3ngg6W+BBSXSechtMCnBmWXj/EaVlmV5cY1jD2HoTfhBQ3AacpCNMLJ -K4NpZaNjMGEwHwYDVR0jBBgwFoAU1GToQ4g6cy/QGnGCNgtehd7H3kMwHQYDVR0OBBYEFNRk6EOI -OnMv0BpxgjYLXoXex95DMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49 -BAMDA2kAMGYCMQCXAUdS/9bbJ8A1JYaGf/bWt/s7Ta0ot5Ulno8OjSNYRWQIlS4tVWldvTAVA7he -OFgCMQCvKr8+Z2Rn+OBr5UHzlgBObpad1LuwNTRcdNgUJxIWadcki+UBLEi1/AURKV5md2M= ------END CERTIFICATE----- - -Telia RSA TLS Root CA v3 -======================== ------B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wHwYDVR0jBBgwFoAU -sMep0t2yKFZzBJSMFFxIbzdSkqgwHQYDVR0OBBYEFLDHqdLdsihWcwSUjBRcSG83UpKoMA4GA1Ud -DwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBDAUAA4ICAQBdYzFsNGDRk7bR -/AgRKq+5637YuOW+w6uhpoS0VnKMUpyHCwku86hEvqivakPtfmlm4bFwt++sb/8OXsWBqtfbXMaB -NDTZl8XRMJuLWOW2JrbKkRzgG0eBUcvsadG1rrhbmZqYvFXaAZO7o4TdOZzxhBB5GOAWWXB3Iera -NP4J63zyo9n8Gqw3sJBG44em5hoYjBffP+npibyslnslRi4L6xHsCYj/Pab+OlqbMCB6v+sTCLeE -IukRVzoR9aQ45pEK7Z1QBnSsbAKQtss0JKD9d/mX143H1xePjPhTXlv5JCkhrcj+SShz0P9+EHoW -e6m9lyUEOIVn0rp+yVJWNbmyDv3VkwFxHC1ApSQsgSimjGQ4wtr6cSmordYxkV+Ro8lOIIhRksXP -yDk27gW6IjUXCkZKpxFjkL3jiBSc8SkxnwCWtXg8xwNwdFVNBGLCCuJnsneYXjJNqzRqUcoGwzsv -F3Qi/ZnHUNvISdevlgIAXL4Wvrxaqvoa01wB+GCfs57RTGE4TvAGhKNKus8K3hRT1BSpigzMIRzS -xtAOrqPN6j//QSmW9f8Jcncri4j2ihSpVrFU0NdNkMhZeAKidTFPsxCVFuW4Aniz7jqiw5sWtjbQ -rlW035izIEU4sYwQoC1Nx0Svy+mMTRai50LqFQ+A1/Hq6xHHDNx7CI83d23Erw== ------END CERTIFICATE----- diff --git a/software/wifi/raw_u64/CMakeLists.txt b/software/wifi/raw_u64/CMakeLists.txt index 07d822cb7..ecffda6a1 100644 --- a/software/wifi/raw_u64/CMakeLists.txt +++ b/software/wifi/raw_u64/CMakeLists.txt @@ -7,5 +7,3 @@ if(IDF_VERSION_MAJOR LESS 6) message(FATAL_ERROR "raw_u64 needs ESP-IDF 6, not ${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR} (see software/wifi/raw_u64/README.md)") endif() project(bridge) - -include(${CMAKE_SOURCE_DIR}/../ca_store/ca_store.cmake) diff --git a/software/wifi/raw_u64/README.md b/software/wifi/raw_u64/README.md index 1cbfa5f95..9ab636d0d 100644 --- a/software/wifi/raw_u64/README.md +++ b/software/wifi/raw_u64/README.md @@ -31,56 +31,15 @@ suite `tests/e2e/io/command_interface/net_tls_test.py` (against a device) and `n `make -C target/pc/linux/wifitls test`. The engine can also be run on its own, on QEMU or an ESP32 dev board, with a red/green gate: . -## The certificate bundle: the Mozilla root store, vendored - -The roots the bridge trusts in BUNDLE mode come from `software/wifi/ca_store/cacert.pem`, not -from ESP-IDF's copy. ESP-IDF refreshes its own `cacrt_all.pem` on its release branches only now -and then: v6.0.3 ships Mozilla's data of 2025-12-02, with roots Mozilla has since dropped. - -- **Where it comes from.** `cacert.pem` is curl's extract of Mozilla's `certdata.txt` - (), byte for byte. `CA_PINS` beside it records the source URL, - the Mozilla date, the file's sha256 (`CA_SHA256`), the `certdata.txt` commit on GitHub it was - regenerated from as a cross-check (`CA_CERTDATA_REF`), the sha256 of its set of certificates - (`CA_BUNDLE_SET_SHA256`) and the age limit (`CA_MAX_AGE_DAYS`). -- **How the build uses it.** `sdkconfig` selects `CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE`, - so none of ESP-IDF's roots are merged in, and points `CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH` - at `../ca_store/cacert.pem`; ESP-IDF's `gen_crt_bundle.py` builds the bundle from that file and - builds it again whenever the file changes. -- **How the build verifies it.** `CMakeLists.txt` (through `../ca_store/ca_store.cmake`) runs `python3 tools/ca_store/ca_store.py check` - at every configure (an edit to `cacert.pem`, `CA_PINS` or the checker configures again) and - again at every build, before the bundle is made, so an already-configured tree cannot skip it. - It checks the configuration the build really uses (its `config/sdkconfig.json`, which - `idf.py -D SDKCONFIG=...` can point away from this directory's `sdkconfig`). The build fails - when `cacert.pem` does not match `CA_SHA256`, when its date disagrees with the pins, when its - certificates changed without `CA_BUNDLE_SET_SHA256`, when another certificate file (such as an - `anchors.pem`) is in the store, or when the configuration no longer builds the bundle from the - store alone with `CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y`. A store older than - `CA_MAX_AGE_DAYS` is a warning, and an error when the build runs with `RELEASE=1` in its - environment (`RELEASE=1 idf.py build`, `make RELEASE=1 esp32_raw_u64`). Run the check by hand - with `python3 tools/ca_store/ca_store.py check`, and its tests with `make ca_store_test`. -- **How to refresh it.** `python3 tools/ca_store/refresh.py --ident-minor N` (needs the network - and Perl) fetches curl's file and its sum, and takes it only when curl's own `mk-ca-bundle.pl`, - pinned by commit and sha256, gives the same file from the newest `certdata.txt` on Firefox's - release branch, which must descend from `CA_CERTDATA_REF`. It writes `cacert.pem` and `CA_PINS`. - When the certificates changed it also sets `IDENT_MINOR` (and `IDENT_STRING`) in - `main/rpc_dispatch.h` to N (of every project whose own sources or `ca_store.SHARED_SOURCES` attach the - bundle; with more than one, `--ident-minor PROJECT=N` for each), since the updater reflashes a module only for a new version. N must - be allocated for this image and above the current minor: the tool refuses a certificate change - without `--ident-minor`, because on a development line the next number may already belong to - another image. `--summary FILE` lists what changed by fingerprint, for review. Commit the - result. Never edit `cacert.pem` by hand: the build refuses it. Moving the pins by hand without - a new `IDENT_MINOR` is not caught by the check, so review that the two move together. -- **Roots with serial number zero.** Six roots in Mozilla's set as of 2026-09-25 (Go Daddy Root - CA - G2, Starfield Root CA - G2, Starfield Services Root CA - G2, Security Communication - RootCA2 and the two HARICA 2015 roots) have serial number 0, which the `cryptography` package - (48.0) warns is not positive. ESP-IDF's `gen_crt_bundle.py` silences that warning - today; if a future `cryptography` refuses such certificates, the bundle step fails and the build - stops (it fails closed, as it would with ESP-IDF's own bundle, which holds the same roots). -- **No anchors.** ESP-IDF 6 verifies cross-signed chains itself - (`CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY`), so the store needs no hand-kept - roots: `sdkconfig` sets it explicitly, `../tls/tls_engine.c` refuses to build without it, and the - check refuses an anchor file. Only raw_u64 uses the store; raw_c3 and u64ctrl keep ESP-IDF's - bundle. +## The certificate bundle + +The roots the bridge trusts in BUNDLE mode are the ones `software/u64ctrl/ca/cacert.pem` holds, the +Mozilla root list the control module's recovery trusts, not ESP-IDF's copy (v6.0.3 ships Mozilla's +data of 2025-12-02, with roots Mozilla has since dropped). There is one file for both modules: +`sdkconfig` selects `CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE`, so none of ESP-IDF's roots are +merged in, and points `CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH` at `../../u64ctrl/ca/cacert.pem`. +`CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y` is set explicitly, and `../tls/tls_engine.c` +refuses to build without it. How the list is checked and refreshed is in `software/u64ctrl/ca/README.md`. ## The Wi-Fi scan (from the ESP-IDF example this project started as) diff --git a/software/wifi/raw_u64/sdkconfig b/software/wifi/raw_u64/sdkconfig index c8c754e8e..47ebaf77d 100644 --- a/software/wifi/raw_u64/sdkconfig +++ b/software/wifi/raw_u64/sdkconfig @@ -2101,7 +2101,7 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y -CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="../ca_store/cacert.pem" +CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="../../u64ctrl/ca/cacert.pem" CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 # end of Certificate Bundle Configuration diff --git a/tools/ca_store/ca_store.py b/tools/ca_store/ca_store.py deleted file mode 100644 index b59d3406e..000000000 --- a/tools/ca_store/ca_store.py +++ /dev/null @@ -1,492 +0,0 @@ -#!/usr/bin/env python3 -"""Checks the Mozilla root store the ESP32 bridge trusts for TLS, before every ESP32 build. - - ca_store.py check fail if the store, its pins and the sdkconfigs disagree; warn when - the store is older than CA_MAX_AGE_DAYS, and fail instead with - --release or RELEASE (not 0) in the environment - -The bridge's build runs the check at its configure step and again at every build, with ---project and --sdkconfig-json naming the configuration that build actually uses (which -`idf.py -D SDKCONFIG=...` can point away from the project's own sdkconfig). - -The store is the directory software/wifi/ca_store: cacert.pem, the bundle curl extracts from -Mozilla's certdata.txt (the same source ESP-IDF's own cacrt_all.pem comes from), and CA_PINS. -Each project in PROJECTS selects CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE and points -CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH at cacert.pem, so ESP-IDF's gen_crt_bundle.py builds -the device's bundle from it alone, and again whenever it changes. ESP-IDF refreshes its own copy -only on its release branches, and not always then: v6.0.3 ships Mozilla's data of 2025-12-02. - -There are no hand-kept anchors. ESP-IDF 6 verifies cross-signed chains -(CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY, which the bridge pins to y and its engine -refuses to build without), so a chain a server sends through a cross-sign verifies against the -newer root Mozilla still trusts. `check` refuses anchors.pem, or any other certificate file, in -the store. - -The Ultimate's updater reflashes a module only when the version the module reports differs from -the one it carries. CA_BUNDLE_SET_SHA256 pins the set of certificates the bundle is built from, -so `check` fails when that set changes without the pin, and refresh.py moves the pin together -with IDENT_MINOR of every project whose own sources attach the bundle. - -Only the standard library, so it runs in the build image and on a stock runner alike. -""" - -import argparse -import base64 -import datetime -import hashlib -import json -import os -import pathlib -import re -import sys - -REPO_ROOT = pathlib.Path(__file__).resolve().parents[2] -STORE_DIR = "software/wifi/ca_store" -PEM_NAME = "cacert.pem" -PINS_NAME = "CA_PINS" -# A file that must not be in the store: ESP-IDF 6 verifies cross-signed chains itself, so no hand-kept roots are needed. -ANCHORS_NAME = "anchors.pem" -PIN_KEYS = ("CA_SOURCE_URL", "CA_MOZILLA_DATE", "CA_SHA256", "CA_MAX_AGE_DAYS", "CA_CERTDATA_REF", - "CA_BUNDLE_SET_SHA256") -# The ESP-IDF 6 projects whose bundle comes from the store. raw_c3 and u64ctrl are built with -# ESP-IDF 5.3's bundle, which looks up only the issuer of the topmost certificate a server -# sends, so they would need hand-kept anchor roots; they keep ESP-IDF's own bundle. -PROJECTS = ("software/wifi/raw_u64",) -# Source directories a project builds that are not under its own main/, relative to the project. The TLS -# engine, which attaches the bundle, is shared by the module firmware that carry it (software/wifi/tls). -SHARED_SOURCES = {"software/wifi/raw_u64": ("../tls",)} - -DATE_PREFIX = "## Certificate data from Mozilla as of: " -BEGIN = "-----BEGIN CERTIFICATE-----" -END = "-----END CERTIFICATE-----" -ISO_FORMAT = "%Y-%m-%dT%H:%M:%SZ" -MONTHS = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") -# How far ahead of this host's clock a Mozilla date may be. A later one would make every real -# update look like a rollback, and the age gate would never fire again. -CLOCK_SLACK = datetime.timedelta(days=1) -# What a project's sources call when they verify servers against the bundle. A project that -# never calls it has no bundle in its image. -ATTACH = "esp_crt_bundle_attach" - - -class StoreError(Exception): - pass - - -def store_paths(repo_root): - store = pathlib.Path(repo_root) / STORE_DIR - return store / PEM_NAME, store / PINS_NAME - - -def write_atomically(path, data): - """Writes through a new file renamed into place, so a build never reads half a file.""" - path = pathlib.Path(path) - temporary = path.with_name(path.name + ".new") - temporary.write_bytes(data) - os.replace(str(temporary), str(path)) - - -# CA_PINS: KEY=VALUE lines and # comments, parsed like tests/crypto/PINS and shell-sourceable, -# so no value has quotes or spaces. - - -def read_pins(path): - pins = {} - for line in pathlib.Path(path).read_text().split("\n"): - line = line.split("#", 1)[0].strip() - if line: - if "=" not in line: - raise StoreError("%s: %r is not KEY=VALUE" % (path, line)) - key, value = line.split("=", 1) - pins[key] = value - missing = [key for key in PIN_KEYS if key not in pins] - if missing: - raise StoreError("%s: missing %s" % (path, ", ".join(missing))) - if not pins["CA_MAX_AGE_DAYS"].isdigit(): - raise StoreError("%s: CA_MAX_AGE_DAYS=%s is not a number of days" - % (path, pins["CA_MAX_AGE_DAYS"])) - return pins - - -def utc_now(): - return datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None) - - -def write_pins(path, updates): - """Rewrites the given keys in place, keeping the order and the comments.""" - out = [] - for line in pathlib.Path(path).read_text().split("\n"): - key = line.split("=", 1)[0] - if "=" in line and not line.startswith("#") and key in updates: - line = "%s=%s" % (key, updates[key]) - out.append(line) - write_atomically(path, "\n".join(out).encode()) - - -# The PEM. - - -def mozilla_date(text): - for line in text.split("\n"): - if line.startswith(DATE_PREFIX): - return line[len(DATE_PREFIX):].strip() - raise StoreError("no '%s' line" % DATE_PREFIX.strip("# ")) - - -def parse_date(stamp): - # "Fri Sep 25 03:12:01 2026 GMT", parsed by hand so the host's locale cannot change it. - match = re.fullmatch(r"\w{3} (\w{3}) +(\d{1,2}) (\d\d):(\d\d):(\d\d) (\d{4}) GMT", stamp) - if not match or match.group(1) not in MONTHS: - raise StoreError("unrecognised Mozilla date %r" % stamp) - month, day, hour, minute, second, year = match.groups() - return datetime.datetime(int(year), MONTHS.index(month) + 1, int(day), - int(hour), int(minute), int(second)) - - -def iso(stamp): - """The header's date as CA_PINS holds it: 2026-09-25T03:12:01Z.""" - return parse_date(stamp).strftime(ISO_FORMAT) - - -def parse_iso(value): - try: - return datetime.datetime.strptime(value, ISO_FORMAT) - except ValueError: - raise StoreError("CA_MOZILLA_DATE=%s is not of the form 2026-09-25T03:12:01Z" % value) - - -def certificates(text): - """The DER of each certificate, after checking the file is whole.""" - ders = [] - inside = None - for line in text.split("\n"): - if line == BEGIN: - if inside is not None: - raise StoreError("certificate %d is not closed" % (len(ders) + 1)) - inside = [] - elif line == END: - if inside is None: - raise StoreError("END without BEGIN after certificate %d" % len(ders)) - try: - der = base64.b64decode("".join(inside), validate=True) - except ValueError: - raise StoreError("certificate %d is not valid base64" % (len(ders) + 1)) - if len(der) < 4 or der[0] != 0x30: - raise StoreError("certificate %d is not DER" % (len(ders) + 1)) - ders.append(der) - inside = None - elif inside is not None: - inside.append(line) - if inside is not None: - raise StoreError("the file ends inside certificate %d (truncated?)" % (len(ders) + 1)) - if not ders: - raise StoreError("no certificates") - if not text.endswith(END + "\n"): - raise StoreError("the file does not end with a whole certificate (truncated?)") - return ders - - -def names(text): - """The label curl writes above each certificate, in file order.""" - lines = text.split("\n") - return [lines[i - 2] for i, line in enumerate(lines) - if line == BEGIN and i >= 2 and lines[i - 1].startswith("=")] - - -def _tlv(der, pos): - """(tag, start of the value, end of the element) of the DER element at pos.""" - if pos + 2 > len(der): - raise StoreError("DER ends early") - tag, length = der[pos], der[pos + 1] - pos += 2 - if length & 0x80: - count = length & 0x7F - if count == 0 or count > 4 or pos + count > len(der): - raise StoreError("bad DER length") - length = int.from_bytes(der[pos:pos + count], "big") - pos += count - if pos + length > len(der): - raise StoreError("DER element runs past its end") - return tag, pos, pos + length - - -def subject_and_key(der): - """The subject name and the SubjectPublicKeyInfo of a certificate, each as DER. These are - the two things ESP-IDF's bundle keeps of a root.""" - _, start, _ = _tlv(der, 0) # Certificate - _, pos, _ = _tlv(der, start) # tbsCertificate - fields = [] - while len(fields) < 7: - tag, _, end = _tlv(der, pos) - if not (tag == 0xA0 and not fields): # skip the optional [0] version - fields.append(der[pos:end]) - pos = end - # serial, signature, issuer, validity, subject, subjectPublicKeyInfo - return fields[4], fields[5] - - -def roots(text): - """{sha256 fingerprint: (label, subject DER, key DER)} of every certificate in a store.""" - if not text: - return {} - ders = certificates(text) - labels = names(text) - if len(labels) != len(ders): - labels = ["(no label)"] * len(ders) - return {hashlib.sha256(der).hexdigest(): (label, *subject_and_key(der)) - for label, der in zip(labels, ders)} - - -def bundle_set_sha256(ders): - """CA_BUNDLE_SET_SHA256: the sha256 over the DER encodings, sorted and concatenated. DER is - self-delimiting, so the concatenation is unambiguous, and the order of the certificates does - not matter, as it does not to gen_crt_bundle.py.""" - return hashlib.sha256(b"".join(sorted(set(ders)))).hexdigest() - - -# The ESP32 projects that build their bundle from the store. - - -def has_line(text, line): - return line in text.split("\n") - - -def sdkconfig_from_json(path): - """A build's config/sdkconfig.json (what it really uses) in sdkconfig's own syntax.""" - try: - config = json.loads(pathlib.Path(path).read_text()) - except (OSError, ValueError) as error: - raise StoreError("cannot read the build's configuration %s: %s" % (path, error)) - lines = [] - for key, value in config.items(): - if value is True: - lines.append("CONFIG_%s=y" % key) - elif value is False: - lines.append("# CONFIG_%s is not set" % key) - elif isinstance(value, str): - lines.append('CONFIG_%s="%s"' % (key, value)) - else: - lines.append("CONFIG_%s=%s" % (key, value)) - return "\n".join(lines) + "\n" - - -def projects(repo_root, effective=None): - """(project dir, sdkconfig text) of every project in PROJECTS. effective maps a project dir - to the sdkconfig.json of the build at hand, which then stands for its sdkconfig.""" - repo_root = pathlib.Path(repo_root) - effective = {pathlib.Path(p).resolve(): j for p, j in (effective or {}).items()} - for project in effective: - if project not in [(repo_root / path).resolve() for path in PROJECTS]: - raise StoreError("%s is not one of the projects that use the store" % project) - found = [] - for path in PROJECTS: - project = repo_root / path - if project.resolve() in effective: - found.append((project, sdkconfig_from_json(effective[project.resolve()]))) - continue - sdkconfig = project / "sdkconfig" - if not sdkconfig.exists(): - raise StoreError("%s: no sdkconfig, but PROJECTS names it" % path) - found.append((project, sdkconfig.read_text())) - return found - - -def attaching(project): - """Whether a project's own sources (under main/, and its SHARED_SOURCES, not ESP-IDF's) attach - the bundle.""" - project = pathlib.Path(project) - roots = [project / "main"] - for name, shared in SHARED_SOURCES.items(): - if project.resolve().as_posix().endswith("/" + name): - roots += [project / directory for directory in shared] - for root in roots: - if not root.is_dir(): - raise StoreError("%s: no %s, but it is one of the project's sources" % (project, root)) - for path in sorted(root.rglob("*")): - if (path.suffix in (".c", ".cc", ".cpp", ".h") - and ATTACH in path.read_text(errors="replace")): - return True - return False - - -def bundle_misconfigured(repo_root, effective=None): - """Each project builds its bundle from cacert.pem and nothing else, and verifies cross-signed - chains, which is what lets the store go without anchors.""" - repo_root = pathlib.Path(repo_root) - pem = (repo_root / STORE_DIR / PEM_NAME).resolve() - problems = [] - for project, text in projects(repo_root, effective): - relative = (project / "sdkconfig").relative_to(repo_root) - if not has_line(text, "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y"): - problems.append("%s: CONFIG_MBEDTLS_CERTIFICATE_BUNDLE is off, so the store is not " - "used" % relative) - continue - match = re.search(r'^CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="(.*)"$', text, re.M) - if not match or (project / match.group(1)).resolve() != pem: - problems.append("%s: CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH does not name " - "%s/%s" % (relative, STORE_DIR, PEM_NAME)) - elif not has_line(text, "CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y"): - problems.append("%s: names the store but does not set " - "CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y, so the path is ignored" - % relative) - if not has_line(text, "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y"): - problems.append("%s: also takes ESP-IDF's default bundle; select " - "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE" % relative) - if not has_line(text, "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y"): - problems.append("%s: the store holds no anchors, so it needs " - "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y" % relative) - return problems - - -def max_certs(text): - match = re.search(r"^CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=(\d+)$", text, re.M) - return int(match.group(1)) if match else None - - -def bump_ident(project, date, new): - """IDENT_MINOR and IDENT_STRING moved to `new`, which must be above the current minor, with a - line saying why, as the header keeps them. The caller names the number: on a development line - the next one may already belong to another image. - - Returns (header, new text, new version) and writes nothing, so a caller can check every - project before it changes any file.""" - header = project / "main" / "rpc_dispatch.h" - if not header.exists(): - raise StoreError("%s uses the store but has no %s" % (project, header)) - text = header.read_text() - major = re.search(r"^#define IDENT_MAJOR\s+(\d+)$", text, re.M) - minor = re.search(r"^#define IDENT_MINOR\s+(\d+)$", text, re.M) - string = re.search(r'^#define IDENT_STRING "(.* V)(\d+)\.(\d+)"$', text, re.M) - if not (major and minor and string): - raise StoreError("%s: IDENT_MAJOR, IDENT_MINOR or IDENT_STRING not found" % header) - if (string.group(2), string.group(3)) != (major.group(1), minor.group(1)): - raise StoreError("%s: IDENT_STRING says %s.%s, IDENT_MAJOR/MINOR say %s.%s" % ( - header, string.group(2), string.group(3), major.group(1), minor.group(1))) - if new <= int(minor.group(1)): - raise StoreError("%s: IDENT_MINOR %d is not above %s" % (header, new, minor.group(1))) - version = "%s.%d" % (major.group(1), new) - text = (text[:minor.start()] + minor.group(0).replace(minor.group(1), str(new)) - + text[minor.end():]) - text = (text[:string.start()] + '#define IDENT_STRING "%s%s"' % (string.group(1), version) - + text[string.end():]) - major = re.search(r"^#define IDENT_MAJOR\s+\d+\n", text, re.M) - note = "// %s: the Mozilla root store as of %s.\n" % (version, date) - return header, text[:major.end()] + note + text[major.end():], version - - -# The check. - - -def check_store_dir(store_dir): - """Nothing but cacert.pem may hold certificates in the store: the anchors are retired, and a - directory bundle path would take every .pem and .der in it.""" - errors = [] - for path in sorted(pathlib.Path(store_dir).iterdir()): - if path.name == ANCHORS_NAME: - errors.append("%s: the anchors are retired on ESP-IDF 6, which verifies cross-signed " - "chains (CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY); remove " - "it" % ANCHORS_NAME) - elif path.suffix in (".pem", ".der", ".crt") and path.name != PEM_NAME: - errors.append("%s: only %s holds certificates in %s" % (path.name, PEM_NAME, STORE_DIR)) - return errors - - -def check(repo_root, release=False, today=None, now=None, effective=None): - """Returns (errors, warnings). effective: see projects().""" - pem_path, pins_path = store_paths(repo_root) - pins = read_pins(pins_path) - now = now or utc_now() - errors = [] - if not re.fullmatch(r"[\w.-]+/[\w.-]+@[0-9a-f]{40}", pins["CA_CERTDATA_REF"]): - errors.append("CA_CERTDATA_REF=%s is not owner/repo@" - % pins["CA_CERTDATA_REF"]) - if parse_iso(pins["CA_MOZILLA_DATE"]) > now + CLOCK_SLACK: - errors.append("CA_MOZILLA_DATE=%s is in the future" % pins["CA_MOZILLA_DATE"]) - data = pem_path.read_bytes() - if hashlib.sha256(data).hexdigest() != pins["CA_SHA256"]: - errors.append("%s does not match CA_SHA256 in %s: the vendored store changed without " - "tools/ca_store/refresh.py" % (pem_path.name, PINS_NAME)) - text = data.decode("utf-8", "replace") - try: - if iso(mozilla_date(text)) != pins["CA_MOZILLA_DATE"]: - errors.append("%s is from %s, CA_MOZILLA_DATE says %s" - % (pem_path.name, iso(mozilla_date(text)), pins["CA_MOZILLA_DATE"])) - store = certificates(text) - subjects = {} - for der in store: - subject = subject_and_key(der)[0] - if subject in subjects and subjects[subject] != der: - # ESP-IDF's lookup is a binary search that tries one root per subject, so which - # of two would be used depends on where they sort. - errors.append("two roots in the bundle have the same subject: %s and %s" - % (hashlib.sha256(subjects[subject]).hexdigest()[:16], - hashlib.sha256(der).hexdigest()[:16])) - subjects[subject] = der - except StoreError as error: - errors.append("%s: %s" % (pem_path.name, error)) - store = [] - errors += check_store_dir(pem_path.parent) - if store and bundle_set_sha256(store) != pins["CA_BUNDLE_SET_SHA256"]: - modules = [os.path.relpath(p, repo_root) for p, _ in projects(repo_root) if attaching(p)] - errors.append("the bundle's certificates changed but CA_BUNDLE_SET_SHA256 did not: " - "update the store with tools/ca_store/refresh.py, which bumps IDENT_MINOR " - "of %s" % (", ".join(modules) or "no project (none attaches the bundle)")) - errors += bundle_misconfigured(repo_root, effective) - for project, sdkconfig in projects(repo_root, effective): - limit = max_certs(sdkconfig) - if limit is not None and len(store) > limit: - errors.append("%s/sdkconfig: CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=%d, " - "the store has %d" % (os.path.relpath(project, repo_root), limit, - len(store))) - - warnings = [] - today = today or now.date() - age = (today - parse_iso(pins["CA_MOZILLA_DATE"]).date()).days - limit = int(pins["CA_MAX_AGE_DAYS"]) - if age > limit: - message = ("the Mozilla root store is %d days old (as of %s), over CA_MAX_AGE_DAYS=%d: " - "run tools/ca_store/refresh.py" - % (age, pins["CA_MOZILLA_DATE"], limit)) - (errors if release else warnings).append(message) - return errors, warnings - - -def main(argv=None): - parser = argparse.ArgumentParser(description=__doc__.split("\n")[0]) - parser.add_argument("command", choices=("check",)) - parser.add_argument("--repo-root", default=str(REPO_ROOT)) - parser.add_argument("--release", action="store_true", - help="a stale store is an error, not a warning (also RELEASE=1 in the " - "environment)") - parser.add_argument("--project", help="with --sdkconfig-json: the project being built") - parser.add_argument("--sdkconfig-json", - help="the build's config/sdkconfig.json, checked instead of the project's " - "sdkconfig") - parser.add_argument("--today", type=datetime.date.fromisoformat, help=argparse.SUPPRESS) - arguments = parser.parse_args(argv) - repo_root = pathlib.Path(arguments.repo_root) - if bool(arguments.project) != bool(arguments.sdkconfig_json): - parser.error("--project and --sdkconfig-json go together") - effective = {arguments.project: arguments.sdkconfig_json} if arguments.project else None - release = arguments.release or os.environ.get("RELEASE", "") not in ("", "0") - - try: - errors, warnings = check(repo_root, release, arguments.today, effective=effective) - except (StoreError, OSError) as error: - print("ca_store: %s" % error, file=sys.stderr) - return 1 - - for message in warnings: - print("ca_store: warning: %s" % message, file=sys.stderr) - for message in errors: - print("ca_store: %s" % message, file=sys.stderr) - if errors: - return 1 - pins = read_pins(store_paths(repo_root)[1]) - print("ca_store: the Mozilla root store as of %s, sha256 %s" - % (pins["CA_MOZILLA_DATE"], pins["CA_SHA256"])) - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/ca_store/refresh.py b/tools/ca_store/refresh.py deleted file mode 100644 index e0cfa379a..000000000 --- a/tools/ca_store/refresh.py +++ /dev/null @@ -1,401 +0,0 @@ -#!/usr/bin/env python3 -"""Refreshes the Mozilla root store the ESP32 bridge trusts (software/wifi/ca_store). - - refresh.py [--source URL] [--summary FILE] [--ident-minor N] - -Fetches curl's cacert.pem and its published sum, and checks the file against a copy made again -from Mozilla's own certdata.txt on GitHub. If Mozilla's data changed, it writes cacert.pem and -CA_PINS and, when the bundle's certificates changed, moves IDENT_MINOR of every project that -attaches the bundle (ca_store.PROJECTS) to --ident-minor N. Without it such a change is refused: -the updater reflashes a module only for a new version, and on a development line the next number -may already belong to another image, so the number is allocated by a person, not taken. - -curl.se publishes the file and its sum from the same server, so the sum proves only that the -download is whole. The second copy is made from certdata.txt on Firefox's release branch (the -revision whose sha256 curl's header names) with curl's own mk-ca-bundle.pl, pinned by commit and -sha256, and curl's file is taken only if the two are the same byte for byte. That revision must -also be the newest certdata.txt on the branch (see GRACE), and a descendant of the committed CA_CERTDATA_REF, so a server serving an older conversion under -a new date is refused too. Changing the store then takes both curl.se and GitHub. - -Needs Perl for mk-ca-bundle.pl, and the network; nothing else beyond the standard library. -""" - -import argparse -import calendar -import datetime -import hashlib -import json -import os -import pathlib -import re -import subprocess -import sys -import tempfile -import urllib.error -import urllib.request - -sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) - -import ca_store -from ca_store import (CLOCK_SLACK, REPO_ROOT, StoreError, attaching, bump_ident, - bundle_set_sha256, certificates, iso, max_certs, mozilla_date, - parse_date, parse_iso, projects, read_pins, roots, - store_paths, utc_now, write_atomically, write_pins) - -# The second origin: Mozilla's certdata.txt as Firefox's release branch carries it, and the -# script curl converts it with. -CERTDATA_REPO = "mozilla-firefox/firefox" -CERTDATA_BRANCH = "release" -CERTDATA_PATH = "security/nss/lib/ckfw/builtins/certdata.txt" -CERTDATA_COMMITS = 10 -# How old (by commit date) the newest certdata.txt on `release` may be for curl's file to match an older one. -# Newer revisions arrive older than this, so only the newest is ever taken: no rollback, at the cost of a -# red run, healed the next week, when `release` moves between curl's daily run and ours. -GRACE = datetime.timedelta(days=14) -MK_CA_BUNDLE_COMMIT = "d48f2f4ec867783e611beeb2ad53fbabcb94aa6f" -MK_CA_BUNDLE_SHA256 = "8e278f4982210b37e4f9a048bd6ed23df41e4a054085bd73f8242628f03d09ca" -MK_CA_BUNDLE_URL = "https://raw.githubusercontent.com/curl/curl/%s/scripts/mk-ca-bundle.pl" -RAW_URL = "https://raw.githubusercontent.com/%s/%s/%s" -API_URL = "https://api.github.com/repos/%s/commits?sha=%s&path=%s&per_page=%d" -COMPARE_URL = "https://api.github.com/repos/%s/compare/%s...%s" -CERTDATA_PREFIX = "## SHA256: " -FETCH_TIMEOUT = 60 - - -def changes(old_text, new_text): - """(added, removed, rekeyed) as sorted lists: fingerprints for the first two, and - (label, old fingerprint, new fingerprint) for a subject that stays with a different key or - certificate, which is the case to look at by hand because ESP-IDF looks roots up by - subject.""" - old, new = roots(old_text), roots(new_text) - by_subject = {subject: fp for fp, (_, subject, _) in old.items()} - added = sorted(set(new) - set(old)) - removed = sorted(set(old) - set(new)) - rekeyed = [] - for fp in list(added): - old_fp = by_subject.get(new[fp][1]) - if old_fp in removed: - rekeyed.append((new[fp][0], old_fp, fp)) - added.remove(fp) - removed.remove(old_fp) - return added, removed, sorted(rekeyed) - - -def plain(label): - """A label safe to paste into a pull request description.""" - return re.sub(r"[^A-Za-z0-9 .,()&'/:_+-]", "?", label)[:100] - - -def name_key(subject): - """A subject name with its string types and case set aside, to catch a look-alike: the same - name spelled with UTF8String where the real one uses PrintableString is a different subject - to ESP-IDF, and to the SAME SUBJECT section, but not to a reader.""" - tlv = ca_store._tlv - _, start, end = tlv(subject, 0) - parts = [] - while start < end: # SET OF AttributeTypeAndValue - _, set_start, set_end = tlv(subject, start) - while set_start < set_end: - _, seq_start, seq_end = tlv(subject, set_start) - _, oid_start, oid_end = tlv(subject, seq_start) - _, value_start, value_end = tlv(subject, oid_end) - value = subject[value_start:value_end].decode("utf-8", "replace").strip().lower() - parts.append((subject[oid_start:oid_end], value)) - set_start = seq_end - start = set_end - return tuple(sorted(parts)) - - -def certdata_sha256(text): - for line in text.split("\n"): - if line.startswith(CERTDATA_PREFIX) and re.fullmatch(r"[0-9a-f]{64}", - line[len(CERTDATA_PREFIX):]): - return line[len(CERTDATA_PREFIX):] - raise StoreError("no '%s' line naming the certdata.txt it came from" - % CERTDATA_PREFIX.strip("# :")) - - -def validate(data, expected_sha256): - actual = hashlib.sha256(data).hexdigest() - if actual != expected_sha256: - raise StoreError("sha256 mismatch: the file is %s, the published sum is %s" - % (actual, expected_sha256)) - try: - text = data.decode("utf-8") - except UnicodeDecodeError: - raise StoreError("not UTF-8") - date = mozilla_date(text) - parse_date(date) - return text, date, certificates(text) - - -# The second origin. - - -def fetch(url, token=False): - request = urllib.request.Request(url) - # A token only raises the API's rate limit; nothing here needs its permissions. - if token and os.environ.get("GITHUB_TOKEN"): - request.add_header("Authorization", "Bearer " + os.environ["GITHUB_TOKEN"]) - try: - with urllib.request.urlopen(request, timeout=FETCH_TIMEOUT) as response: - return response.read() - except (urllib.error.URLError, OSError) as error: - raise StoreError("cannot fetch %s: %s" % (url, error)) - - -def fetch_json(url): - try: - return json.loads(fetch(url, token=True)) - except ValueError: - raise StoreError("%s did not return JSON" % url) - - -def find_certdata(wanted, now): - """(CA_CERTDATA_REF, contents, commit date) of the certdata.txt revision on Firefox's - release branch whose sha256 is the one curl's file names. It must be the newest revision, - or the newest must have been committed less than GRACE ago.""" - url = API_URL % (CERTDATA_REPO, CERTDATA_BRANCH, CERTDATA_PATH, CERTDATA_COMMITS) - try: - commits = [(c["sha"], c["commit"]["committer"]["date"]) for c in fetch_json(url)] - except (KeyError, TypeError): - raise StoreError("%s did not return a list of commits" % url) - for index, (commit, date) in enumerate(commits): - data = fetch(RAW_URL % (CERTDATA_REPO, commit, CERTDATA_PATH)) - if hashlib.sha256(data).hexdigest() != wanted: - continue - if index: - newest, newest_date = commits[0] - since = now - datetime.datetime.strptime(newest_date, ca_store.ISO_FORMAT) - if since > GRACE: - raise StoreError( - "curl's file is certdata.txt from %s (committed %s), but the release branch " - "now carries a newer one, %s@%s, committed %s (%d days ago). Either the " - "branch moved after curl's last daily run, which the next run heals once " - "curl publishes it, or this is an old file served as new" - % (commit[:12], date, CERTDATA_REPO, newest[:12], newest_date, since.days)) - return "%s@%s" % (CERTDATA_REPO, commit), data, date - raise StoreError("none of the last %d revisions of %s in %s is the certdata.txt curl's file " - "names (sha256 %s)" % (len(commits), CERTDATA_PATH, CERTDATA_REPO, wanted)) - - -def descends(old_ref, new_ref): - """Whether new_ref is old_ref or a later commit on top of it.""" - if old_ref == new_ref: - return True - old_repo, old = old_ref.split("@", 1) - new_repo, new = new_ref.split("@", 1) - if old_repo != new_repo: - return False - result = fetch_json(COMPARE_URL % (new_repo, old, new)) - if not isinstance(result, dict): - raise StoreError("GitHub's compare of %s...%s did not return an object" % (old, new)) - return result.get("status") == "ahead" and result.get("behind_by") == 0 - - -def regenerate(text, now): - """(CA_CERTDATA_REF, bytes, commit date): curl's file made again from Mozilla's - certdata.txt on GitHub with curl's own pinned mk-ca-bundle.pl. Its "as of" line comes from - the input's modification time, which is set to curl's date, so an honest file comes out - identical.""" - ref, certdata, date = find_certdata(certdata_sha256(text), now) - script = fetch(MK_CA_BUNDLE_URL % MK_CA_BUNDLE_COMMIT) - if hashlib.sha256(script).hexdigest() != MK_CA_BUNDLE_SHA256: - raise StoreError("mk-ca-bundle.pl at %s is not the pinned file" % MK_CA_BUNDLE_COMMIT) - stamp = calendar.timegm(parse_date(mozilla_date(text)).timetuple()) - with tempfile.TemporaryDirectory() as work: - work = pathlib.Path(work) - (work / "mk-ca-bundle.pl").write_bytes(script) - (work / "certdata.txt").write_bytes(certdata) - os.utime(work / "certdata.txt", (stamp, stamp)) - try: - run = subprocess.run(["perl", "mk-ca-bundle.pl", "-n", "-q", "cacert.pem"], cwd=work, - capture_output=True, check=False) - except OSError as error: - raise StoreError("cannot run perl: %s" % error) - if run.returncode != 0: - raise StoreError("mk-ca-bundle.pl failed: %s" - % run.stderr.decode("utf-8", "replace").strip()) - return ref, (work / "cacert.pem").read_bytes(), date - - -def published_sha256(data, url): - match = re.match(r"([0-9a-f]{64})\s", data.decode("ascii", "replace") + "\n") - if not match: - raise StoreError("%s is not a sha256 sum" % url) - return match.group(1) - - -# The refresh. - - -def refresh(repo_root, source=None, summary=None, now=None, regenerate=regenerate, - descends=descends, ident_minor=None): - """Returns the paths written, empty when Mozilla's data has not changed.""" - pem_path, pins_path = store_paths(repo_root) - pins = read_pins(pins_path) - now = now or utc_now() - url = source or pins["CA_SOURCE_URL"] - data = fetch(url) - text, date, ders = validate(data, published_sha256(fetch(url + ".sha256"), url + ".sha256")) - - when, old_date = parse_date(date), pins["CA_MOZILLA_DATE"] - if when > now + CLOCK_SLACK: - raise StoreError("%s is dated %s, in the future" % (url, iso(date))) - if when < parse_iso(old_date): - raise StoreError("%s is older than the committed store (%s, committed %s)" - % (url, iso(date), old_date)) - - # Every run, changed or not, so a weekly job keeps checking curl.se against Mozilla. - ref, again, ref_date = regenerate(text, now) - if again != data: - try: - added, removed, rekeyed = changes(again.decode("utf-8"), text) - detail = ("; in curl's file only: %s; in Mozilla's only: %s" - % (", ".join(added + [new for _, _, new in rekeyed]) or "none", - ", ".join(removed + [old for _, old, _ in rekeyed]) or "none")) - except (StoreError, UnicodeDecodeError): - detail = "" - raise StoreError("%s is not what %s gives when converted with mk-ca-bundle.pl %s%s" - % (url, ref, MK_CA_BUNDLE_COMMIT, detail)) - if not descends(pins["CA_CERTDATA_REF"], ref): - raise StoreError("%s comes from %s, which is not the committed %s or a later commit on " - "top of it: an older certdata.txt under a newer date, or the branch's " - "history was rewritten (then move CA_CERTDATA_REF by hand after a look)" - % (url, ref, pins["CA_CERTDATA_REF"])) - - old_text = pem_path.read_text() if pem_path.exists() else "" - if iso(date) == old_date: - if old_text and set(ders) != set(certificates(old_text)): - raise StoreError("the certificates changed but the Mozilla date did not (%s)" % date) - return [] - - using = projects(repo_root) - for project, sdkconfig in using: - limit = max_certs(sdkconfig) - if limit is not None and len(ders) > limit: - raise StoreError("%d certificates, but %s/sdkconfig allows %d " - "(CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS)" - % (len(ders), project, limit)) - - # The bundle is built from the certificates alone, so only a change to them needs the - # modules that carry it reflashed. Every header is checked before anything is written. - new_set = bundle_set_sha256(ders) - day = when.date().isoformat() - carrying = ([project for project, _ in using if attaching(project)] - if new_set != pins["CA_BUNDLE_SET_SHA256"] else []) - # One number serves one project; with several carrying the bundle, each has its own IDENT series - names = [pathlib.Path(os.path.relpath(p, repo_root)).as_posix() for p in carrying] - minors = (ident_minor if isinstance(ident_minor, dict) - else {names[0]: ident_minor} if ident_minor is not None and len(names) == 1 else {}) - missing = [name for name in names if minors.get(name) is None] - if missing: - raise StoreError("the bundle's certificates changed, so %s needs a new IDENT_MINOR: pass " - "--ident-minor N with a number allocated for this image%s" - % (", ".join(missing), - " (--ident-minor PROJECT=N for each, as they have separate versions)" - if len(names) > 1 else "")) - bumps = [bump_ident(project, day, minors[name]) for project, name in zip(carrying, names)] - - write_atomically(pem_path, data) - write_pins(pins_path, {"CA_MOZILLA_DATE": iso(date), - "CA_SHA256": hashlib.sha256(data).hexdigest(), - "CA_CERTDATA_REF": ref, - "CA_BUNDLE_SET_SHA256": new_set}) - written = [pem_path, pins_path] - bumped = [] - for header, text_after, version in bumps: - write_atomically(header, text_after.encode()) - written.append(header) - bumped.append((header.parent.parent, version)) - - if summary: - pathlib.Path(summary).write_text(describe( - old_text, text, url, ref, ref_date, iso(date), old_date, len(ders), - new_set != pins["CA_BUNDLE_SET_SHA256"], bumped, repo_root)) - return written - - -def describe(old_text, text, url, ref, ref_date, date, old_date, count, set_changed, bumped, - repo_root): - """The pull request description: what changed, by SHA-256 fingerprint.""" - added, removed, rekeyed = changes(old_text, text) - new, old = roots(text), roots(old_text) - lines = ["Mozilla root store as of %s (was %s), %d certificates." % (date, old_date, count), - "", - "Fetched from %s. Regenerated from `%s` (committed %s) with curl's mk-ca-bundle.pl " - "at %s, byte for byte the same." % (url, ref, ref_date, MK_CA_BUNDLE_COMMIT), ""] - if rekeyed: - lines += ["## SAME SUBJECT, DIFFERENT CERTIFICATE: check each of these by hand", "", - "ESP-IDF finds a root by its subject name, so a changed key under the same " - "subject changes what the modules trust for every server that names it.", ""] - lines += ["- %s: `%s` became `%s`" % (plain(label), old_fp, new_fp) - for label, old_fp, new_fp in rekeyed] - lines += [""] - kept = {name_key(subject): label for fp, (label, subject, _) in old.items() - if fp not in removed} - kept_labels = {label for label in kept.values()} - lookalikes = [fp for fp in added - if name_key(new[fp][1]) in kept or new[fp][0] in kept_labels] - if lookalikes: - lines += ["## ADDED UNDER THE NAME OF A ROOT ALREADY HERE: check each of these by hand", - "", "A new root whose name reads like one the store already has.", ""] - lines += ["- `%s` %s" % (fp, plain(new[fp][0])) for fp in lookalikes] + [""] - lines += ["## Added", ""] + (["- `%s` %s" % (fp, plain(new[fp][0])) for fp in added] - or ["None."]) + [""] - lines += ["## Removed", ""] + (["- `%s` %s" % (fp, plain(old[fp][0])) for fp in removed] - or ["None."]) + [""] - if bumped: - lines += ["## Module versions", ""] - lines += ["- %s now reports %s." % (os.path.relpath(p, repo_root), v) for p, v in bumped] - elif set_changed: - lines += ["No project attaches the bundle, so no module version changes."] - else: - lines += ["The certificates did not change, so the bundle and the module versions do " - "not either."] - return "\n".join(lines) + "\n" - - -def parse_ident_minors(values): - """--ident-minor values as refresh() takes them: None, one number, or {project: number}.""" - if not values: - return None - try: - if all("=" not in value for value in values) and len(values) == 1: - return int(values[0]) - pairs = [value.partition("=") for value in values] - if any(not sep for _, sep, _ in pairs): - raise ValueError - return {name: int(number) for name, _, number in pairs} - except ValueError: - raise StoreError("--ident-minor takes N, or PROJECT=N once for each project: %s" - % " ".join(values)) - - -def main(argv=None): - parser = argparse.ArgumentParser(description=__doc__.split("\n")[0]) - parser.add_argument("--repo-root", default=str(REPO_ROOT)) - parser.add_argument("--source", help="fetch from this URL instead of CA_SOURCE_URL " - "(its sum from the same URL + .sha256)") - parser.add_argument("--summary", help="write what changed to this file") - parser.add_argument("--ident-minor", action="append", metavar="[PROJECT=]N", - help="the IDENT_MINOR allocated for the image, needed when the " - "certificates change. With more than one project carrying the " - "bundle, once for each as PROJECT=N (PROJECT as in ca_store.PROJECTS)") - arguments = parser.parse_args(argv) - repo_root = pathlib.Path(arguments.repo_root) - try: - written = refresh(repo_root, arguments.source, arguments.summary, - ident_minor=parse_ident_minors(arguments.ident_minor)) - except (StoreError, OSError) as error: - print("refresh: %s" % error, file=sys.stderr) - return 1 - if not written: - print("refresh: the Mozilla root store is current, nothing to do") - for path in written: - print("refresh: wrote %s" % os.path.relpath(path, repo_root)) - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/ca_store/test_ca_store.py b/tools/ca_store/test_ca_store.py deleted file mode 100644 index 55eb67996..000000000 --- a/tools/ca_store/test_ca_store.py +++ /dev/null @@ -1,520 +0,0 @@ -#!/usr/bin/env python3 -"""Tests for the Mozilla root store's build gate (ca_store.py). Need no network.""" - -import base64 -import contextlib -import datetime -import hashlib -import io -import os -import pathlib -import shutil -import subprocess -import sys -import tempfile -import unittest -from unittest import mock - -sys.path.insert(0, str(pathlib.Path(__file__).parent)) - -import ca_store - - -REPO_ROOT = pathlib.Path(__file__).resolve().parents[2] -COMMITTED = (REPO_ROOT / ca_store.STORE_DIR / ca_store.PEM_NAME).read_text() -OLD_DATE = "Tue Jul 14 03:12:01 2026 GMT" -NEW_DATE = "Fri Sep 25 03:12:01 2026 GMT" -OLD_ISO = "2026-07-14T03:12:01Z" -NEW_ISO = "2026-09-25T03:12:01Z" -NOW = datetime.datetime(2026, 9, 29, 12, 0, 0) -OLD_REF = "mozilla-firefox/firefox@" + "1" * 40 -NEW_REF = "mozilla-firefox/firefox@" + "2" * 40 -BRIDGE = "software/wifi/raw_u64" - -SDKCONFIG = """\ -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL is not set -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y -CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y -CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="%s" -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=%d -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y -""" - -HEADER = """\ -#define IDENT_STRING "ESP32 WiFi Bridge V1.%d" -#define IDENT_MAJOR 1 -// 1.%d: something earlier. -#define IDENT_MINOR %d -""" - - -def pem(date, first=0, count=20): - """A store in curl's layout: its header with the given date, then some real roots.""" - header, _, body = COMMITTED.partition("\n\n") - header = "\n".join(ca_store.DATE_PREFIX + date if line.startswith(ca_store.DATE_PREFIX) - else line for line in header.split("\n")) - blocks = body.strip("\n").split("\n\n") - return header + "\n\n\n" + "\n\n".join(blocks[first:first + count]) + "\n" - - -def der_length(n): - if n < 0x80: - return bytes([n]) - body = n.to_bytes((n.bit_length() + 7) // 8, "big") - return bytes([0x80 | len(body)]) + body - - -def with_key(der, key): - """der with its SubjectPublicKeyInfo replaced (the signature no longer matches).""" - _, start, _ = ca_store._tlv(der, 0) - _, tbs_start, tbs_end = ca_store._tlv(der, start) - fields, pos = [], tbs_start - while pos < tbs_end: - _, _, end = ca_store._tlv(der, pos) - fields.append(der[pos:end]) - pos = end - fields[6 if fields[0][0] == 0xA0 else 5] = key - tbs = b"".join(fields) - tbs = bytes([0x30]) + der_length(len(tbs)) + tbs - body = tbs + der[tbs_end:] - return bytes([0x30]) + der_length(len(body)) + body - - -def rekeyed(text, victim, donor): - """text with certificate number `victim` given the public key of number `donor`, keeping its - subject and label: the swap a compromised mirror would make.""" - ders = ca_store.certificates(text) - swapped = with_key(ders[victim], ca_store.subject_and_key(ders[donor])[1]) - old_b64 = base64.encodebytes(ders[victim]).decode().replace("\n", "") - new_b64 = base64.b64encode(swapped).decode() - old_block = "\n".join(old_b64[i:i + 76] for i in range(0, len(old_b64), 76)) - new_block = "\n".join(new_b64[i:i + 76] for i in range(0, len(new_b64), 76)) - assert old_block in text - return text.replace(old_block, new_block) - - -def pem_block(der): - text = base64.b64encode(der).decode() - return (ca_store.BEGIN + "\n" + "\n".join(text[i:i + 76] for i in range(0, len(text), 76)) - + "\n" + ca_store.END + "\n") - - -class Tree: - """A repository with the store, the bridge that builds its bundle from it (and attaches it), - and a project still on ESP-IDF's own bundle, which the store leaves alone.""" - - def __init__(self, root, date=OLD_DATE, max_certs=200): - self.root = pathlib.Path(root) - store = self.root / ca_store.STORE_DIR - store.mkdir(parents=True) - self.pem = store / ca_store.PEM_NAME - self.pins = store / ca_store.PINS_NAME - text = pem(date) - self.pem.write_text(text) - self.pins.write_text( - "# comment kept\nCA_SOURCE_URL=https://curl.se/ca/cacert.pem\n" - "CA_MOZILLA_DATE=%s\nCA_SHA256=%s\nCA_MAX_AGE_DAYS=180\nCA_CERTDATA_REF=%s\n" - "CA_BUNDLE_SET_SHA256=%s\n" - % (ca_store.iso(date), hashlib.sha256(text.encode()).hexdigest(), OLD_REF, - ca_store.bundle_set_sha256(ca_store.certificates(text)))) - self.bridge = self.project(BRIDGE, "../ca_store/cacert.pem", 6, max_certs) - # The engine that attaches the bundle is in the directory the module firmware share - self.shared = self.root / "software/wifi/tls" - self.shared.mkdir(parents=True) - (self.shared / "tls_engine.c").write_text( - "void setup(void) { esp_crt_bundle_attach(&conf); }\n") - self.sdkconfig = self.bridge / "sdkconfig" - other = self.root / "software/u64ctrl" - (other / "main").mkdir(parents=True) - (other / "sdkconfig").write_text("CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y\n" - "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y\n") - (other / "main/rpc_dispatch.h").write_text(HEADER % (14, 14, 14)) - - def project(self, path, relative, minor, max_certs): - project = self.root / path - (project / "main").mkdir(parents=True) - (project / "sdkconfig").write_text(SDKCONFIG % (relative, max_certs)) - (project / "main/rpc_dispatch.h").write_text(HEADER % (minor, minor, minor)) - return project - - def repin(self): - """A pins file that agrees with cacert.pem's bytes again, but not its set pin.""" - self.pins.write_text(self.pins.read_text().replace( - ca_store.read_pins(self.pins)["CA_SHA256"], - hashlib.sha256(self.pem.read_bytes()).hexdigest())) - - def snapshot(self): - return {p: p.read_bytes() for p in self.root.rglob("*") if p.is_file()} - - -class CheckTest(unittest.TestCase): - def setUp(self): - self.tmp = tempfile.mkdtemp() - self.addCleanup(shutil.rmtree, self.tmp) - self.tree = Tree(self.tmp) # as of 2026-07-14, limit 180 days - - def errors(self): - return ca_store.check(self.tree.root, today=datetime.date(2026, 9, 29), now=NOW)[0] - - def test_a_fresh_store_passes(self): - self.assertEqual(ca_store.check(self.tree.root, today=datetime.date(2027, 1, 10), now=NOW), ([], [])) - - def test_a_stale_store_warns(self): - errors, warnings = ca_store.check(self.tree.root, today=datetime.date(2027, 1, 11), now=NOW) - self.assertEqual(errors, []) - self.assertIn("181 days old", warnings[0]) - - def test_a_stale_store_fails_a_release(self): - errors, warnings = ca_store.check(self.tree.root, release=True, - today=datetime.date(2027, 1, 11), now=NOW) - self.assertEqual(warnings, []) - self.assertIn("181 days old", errors[0]) - - def test_a_fresh_store_passes_a_release(self): - self.assertEqual(ca_store.check(self.tree.root, release=True, - today=datetime.date(2026, 9, 29), now=NOW), ([], [])) - - def test_the_release_flag_sets_the_exit_status(self): - arguments = ["check", "--repo-root", str(self.tree.root), "--today", "2027-06-01"] - with contextlib.redirect_stderr(io.StringIO()), contextlib.redirect_stdout(io.StringIO()): - self.assertEqual(ca_store.main(arguments), 0) - self.assertEqual(ca_store.main([*arguments, "--release"]), 1) - - def test_a_pins_date_that_disagrees_with_the_store_fails(self): - self.tree.pins.write_text(self.tree.pins.read_text().replace(OLD_ISO, NEW_ISO)) - self.assertIn("is from %s, CA_MOZILLA_DATE says %s" % (OLD_ISO, NEW_ISO), self.errors()[0]) - - def test_a_pins_date_that_is_not_iso_fails(self): - self.tree.pins.write_text(self.tree.pins.read_text().replace(OLD_ISO, "2026-07-14")) - with self.assertRaisesRegex(ca_store.StoreError, "not of the form"): - self.errors() - - def test_more_certificates_than_the_bundle_allows_fails(self): - shutil.rmtree(self.tree.root) - self.tree = Tree(self.tree.root, max_certs=19) - errors = self.errors() - self.assertEqual(len(errors), 1) - self.assertIn("MAX_CERTS=19, the store has 20", errors[0]) - shutil.rmtree(self.tree.root) - self.tree = Tree(self.tree.root, max_certs=20) - self.assertEqual(self.errors(), []) - - def test_a_date_in_the_future_fails(self): - errors, _ = ca_store.check(self.tree.root, now=datetime.datetime(2026, 7, 13, 3, 12, 0)) - self.assertIn("in the future", errors[0]) - - def test_a_certdata_ref_that_is_not_a_commit_fails(self): - self.tree.pins.write_text(self.tree.pins.read_text().replace(OLD_REF, "firefox@release")) - self.assertIn("CA_CERTDATA_REF=firefox@release", self.errors()[0]) - - def test_a_malformed_pins_file_is_an_error_not_a_crash(self): - text = self.tree.pins.read_text() - for broken in (text + "garbage\n", - text.replace("CA_MAX_AGE_DAYS=180", "CA_MAX_AGE_DAYS=x"), - text.replace("CA_BUNDLE_SET_SHA256", "# CA_BUNDLE_SET_SHA256")): - self.tree.pins.write_text(broken) - with self.assertRaises(ca_store.StoreError): - ca_store.check(self.tree.root) - - @unittest.skipUnless(hasattr(__import__("time"), "tzset"), "needs time.tzset") - def test_the_age_is_counted_in_utc_not_local_time(self): - import time - now = datetime.datetime.now(datetime.timezone.utc) - # A zone whose date differs from UTC's at this moment. - zone = "Etc/GMT-14" if now.hour >= 10 else "Etc/GMT+12" - shutil.rmtree(self.tree.root) - # Exactly CA_MAX_AGE_DAYS old by UTC's date, so any other date makes it stale or not. - date = (now - datetime.timedelta(days=180)).strftime("%a %b %d 00:00:00 %Y GMT") - self.tree = Tree(self.tree.root, date=date) - saved = os.environ.get("TZ") - os.environ["TZ"] = zone - time.tzset() - try: - errors, warnings = ca_store.check(self.tree.root, release=True) - finally: - if saved is None: - del os.environ["TZ"] - else: - os.environ["TZ"] = saved - time.tzset() - self.assertEqual((errors, warnings), ([], [])) - - def test_a_store_edited_by_hand_fails(self): - self.tree.pem.write_text(self.tree.pem.read_text() + "\n") - self.assertIn("does not match CA_SHA256", self.errors()[0]) - - def test_one_flipped_byte_in_a_certificate_fails(self): - text = self.tree.pem.read_text() - at = text.index(ca_store.BEGIN) + len(ca_store.BEGIN) + 40 - self.tree.pem.write_text(text[:at] + ("A" if text[at] != "A" else "B") + text[at + 1:]) - self.assertIn("does not match CA_SHA256", self.errors()[0]) - - def test_a_flipped_byte_that_breaks_a_certificate_is_an_error_not_a_crash(self): - # The flip the ESP32 build's tamper case made: the base64 still decodes, the DER does not. - text = self.tree.pem.read_text() - at = text.index(ca_store.BEGIN) + 40 - self.tree.pem.write_text(text[:at] + ("A" if text[at] != "A" else "B") + text[at + 1:]) - errors = self.errors() - self.assertIn("does not match CA_SHA256", errors[0]) - self.assertIn("cacert.pem: bad DER length", errors[1]) - - def test_a_truncated_store_fails(self): - text = self.tree.pem.read_text() - self.tree.pem.write_text(text[:text.rindex(ca_store.END)]) - self.tree.repin() - self.assertTrue(any("truncated" in e for e in self.errors()), self.errors()) - - def test_the_bridge_back_on_the_default_bundle_fails(self): - self.tree.sdkconfig.write_text("CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y\n" - "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y\n" - "# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set\n" - "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y\n") - errors = self.errors() - self.assertEqual(len(errors), 2) - self.assertIn("does not name software/wifi/ca_store/cacert.pem", errors[0]) - self.assertIn("DEFAULT_NONE", errors[1]) - - def test_the_bridge_adding_the_default_bundle_to_the_store_fails(self): - self.tree.sdkconfig.write_text(self.tree.sdkconfig.read_text().replace( - "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y", - "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y")) - self.assertIn("DEFAULT_NONE", self.errors()[0]) - - def test_a_store_path_without_the_custom_bundle_switch_fails(self): - self.tree.sdkconfig.write_text(self.tree.sdkconfig.read_text().replace( - "CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y\n", - "# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set\n")) - self.assertIn("does not set CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y", self.errors()[0]) - - def test_a_path_to_another_file_or_to_the_directory_fails(self): - for path in ("../ca_store", "../ca_store/other.pem", "cacert.pem"): - self.tree.sdkconfig.write_text(SDKCONFIG % (path, 200)) - self.assertIn("does not name software/wifi/ca_store/cacert.pem", self.errors()[0], path) - - def test_the_bundle_off_fails(self): - self.tree.sdkconfig.write_text("# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE is not set\n") - self.assertIn("CONFIG_MBEDTLS_CERTIFICATE_BUNDLE is off", self.errors()[0]) - - def test_without_cross_signed_verification_fails(self): - self.tree.sdkconfig.write_text(self.tree.sdkconfig.read_text().replace( - "CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y", - "# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY is not set")) - self.assertIn("needs CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y", - self.errors()[0]) - - def test_a_project_outside_projects_is_left_alone(self): - # u64ctrl takes ESP-IDF's own bundle; that is no error, and nothing reads it. - self.assertEqual(self.errors(), []) - self.assertEqual([p for p, _ in ca_store.projects(self.tree.root)], [self.tree.bridge]) - - def test_a_project_named_but_missing_is_an_error_not_a_crash(self): - self.tree.sdkconfig.unlink() - with self.assertRaisesRegex(ca_store.StoreError, "no sdkconfig"): - self.errors() - - -class EffectiveConfigTest(unittest.TestCase): - """What the build actually uses: its sdkconfig.json (the build passes it), and RELEASE from the - environment of every build, not only of the configure step.""" - - def setUp(self): - self.tmp = tempfile.mkdtemp() - self.addCleanup(shutil.rmtree, self.tmp) - self.tree = Tree(self.tmp) - self.json = pathlib.Path(self.tmp) / "sdkconfig.json" - - def write_json(self, **changes): - config = {"MBEDTLS_CERTIFICATE_BUNDLE": True, "MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL": False, - "MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN": False, - "MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE": True, - "MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE": True, - "MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH": "../ca_store/cacert.pem", - "MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS": 200, - "MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY": True} - config.update(changes) - self.json.write_text(__import__("json").dumps(config)) - - def errors(self, **kwargs): - return ca_store.check(self.tree.root, today=datetime.date(2026, 9, 29), now=NOW, - effective={self.tree.bridge: self.json}, **kwargs)[0] - - def test_the_effective_config_passes_when_it_agrees(self): - self.write_json() - self.assertEqual(self.errors(), []) - - def test_an_effective_config_that_takes_the_default_bundle_fails(self): - # idf.py -D SDKCONFIG=alt with DEFAULT_CMN: the project's own sdkconfig still says NONE. - self.write_json(MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=True, - MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=False) - self.assertIn("DEFAULT_NONE", self.errors()[0]) - - def test_the_effective_limit_and_cross_signed_setting_count(self): - self.write_json(MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=19, - MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=False) - errors = self.errors() - self.assertTrue(any("CROSS_SIGNED_VERIFY=y" in e for e in errors), errors) - self.assertTrue(any("MAX_CERTS=19, the store has 20" in e for e in errors), errors) - - def test_the_command_line_takes_the_effective_config(self): - self.write_json(MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=False, - MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=True) - arguments = ["check", "--repo-root", str(self.tree.root), "--today", "2026-09-29"] - with contextlib.redirect_stderr(io.StringIO()), contextlib.redirect_stdout(io.StringIO()): - self.assertEqual(ca_store.main(arguments), 0) - self.assertEqual(ca_store.main([*arguments, "--project", str(self.tree.bridge), - "--sdkconfig-json", str(self.json)]), 1) - - def test_release_in_the_environment_fails_a_stale_store(self): - arguments = ["check", "--repo-root", str(self.tree.root), "--today", "2027-06-01"] - for value, status in (("", 0), ("0", 0), ("1", 1), ("yes", 1)): - with mock.patch.dict(os.environ, {"RELEASE": value}), \ - contextlib.redirect_stderr(io.StringIO()), contextlib.redirect_stdout(io.StringIO()): - self.assertEqual(ca_store.main(arguments), status, value) - - -class StoreDirTest(unittest.TestCase): - """Only cacert.pem holds certificates in the store.""" - - def setUp(self): - self.tmp = tempfile.mkdtemp() - self.addCleanup(shutil.rmtree, self.tmp) - self.tree = Tree(self.tmp) - - def errors(self): - return ca_store.check(self.tree.root, today=datetime.date(2026, 9, 29), now=NOW)[0] - - def test_an_anchors_file_is_refused_as_retired(self): - (self.tree.pem.parent / ca_store.ANCHORS_NAME).write_text(pem_block( - ca_store.certificates(self.tree.pem.read_text())[0])) - errors = self.errors() - self.assertEqual(len(errors), 1) - self.assertIn("anchors.pem: the anchors are retired on ESP-IDF 6", errors[0]) - - def test_a_stray_certificate_file_is_refused(self): - for name in ("extra.pem", "extra.der", "extra.crt"): - (self.tree.pem.parent / name).write_text("x") - self.assertIn("%s: only cacert.pem holds certificates" % name, self.errors()[0]) - (self.tree.pem.parent / name).unlink() - - def test_other_files_are_allowed(self): - (self.tree.pem.parent / "README.md").write_text("notes\n") - self.assertEqual(self.errors(), []) - - -class BundleSetTest(unittest.TestCase): - """CA_BUNDLE_SET_SHA256 and the IDENT rule it drives.""" - - def setUp(self): - self.tmp = tempfile.mkdtemp() - self.addCleanup(shutil.rmtree, self.tmp) - self.tree = Tree(self.tmp) - - def errors(self): - return ca_store.check(self.tree.root, today=datetime.date(2026, 9, 29), now=NOW)[0] - - def test_a_certificate_change_without_the_set_pin_fails_and_names_what_to_bump(self): - # A hand edit that moved CA_SHA256 along with the file, but not the set pin. - text = self.tree.pem.read_text() - self.tree.pem.write_text(text[:text.rindex("\n\n") + 1]) - self.tree.repin() - errors = self.errors() - self.assertEqual(len(errors), 1) - self.assertIn("CA_BUNDLE_SET_SHA256 did not", errors[0]) - self.assertIn("IDENT_MINOR of software/wifi/raw_u64", errors[0]) - - def test_a_comment_only_edit_changes_no_certificate(self): - self.tree.pem.write_text("## another comment\n" + self.tree.pem.read_text()) - self.tree.repin() - self.assertEqual(self.errors(), []) - - def test_the_set_does_not_depend_on_order(self): - ders = ca_store.certificates(COMMITTED)[:5] - self.assertEqual(ca_store.bundle_set_sha256(ders), - ca_store.bundle_set_sha256(list(reversed(ders)))) - self.assertNotEqual(ca_store.bundle_set_sha256(ders), ca_store.bundle_set_sha256(ders[1:])) - - def test_attaching_reads_only_the_projects_own_sources(self): - self.assertTrue(ca_store.attaching(self.tree.bridge)) - self.assertFalse(ca_store.attaching(self.tree.root / "software/u64ctrl")) - - def test_attaching_finds_the_engine_in_the_shared_directory_only_for_its_users(self): - (self.tree.shared / "tls_engine.c").write_text("void setup(void) {}\n") - self.assertFalse(ca_store.attaching(self.tree.bridge)) - (self.tree.bridge / "main/own.c").write_text("esp_crt_bundle_attach(&conf);\n") - self.assertTrue(ca_store.attaching(self.tree.bridge)) - - def test_attaching_fails_when_a_shared_directory_is_missing(self): - shutil.rmtree(self.tree.shared) - with self.assertRaisesRegex(ca_store.StoreError, "no .*tls"): - ca_store.attaching(self.tree.bridge) - - def test_two_roots_with_one_subject_fail(self): - store = ca_store.certificates(self.tree.pem.read_text()) - double = with_key(store[0], ca_store.subject_and_key(store[1])[1]) - self.tree.pem.write_text(self.tree.pem.read_text() + "\nDouble\n======\n" - + pem_block(double)) - self.tree.repin() - self.assertTrue(any("same subject" in e for e in self.errors()), self.errors()) - - def test_bump_ident_refuses_a_header_whose_string_disagrees(self): - header = self.tree.bridge / "main/rpc_dispatch.h" - header.write_text(HEADER.replace("V1.%d", "V1.5") % (6, 6)) - with self.assertRaisesRegex(ca_store.StoreError, "IDENT_STRING says 1.5"): - ca_store.bump_ident(self.tree.bridge, "2026-09-29", 7) - - -class CommittedStoreTest(unittest.TestCase): - """The tree as committed.""" - - def test_the_committed_store_is_consistent(self): - errors, _ = ca_store.check(REPO_ROOT) - self.assertEqual(errors, []) - - def test_the_committed_store_holds_no_anchors(self): - store = REPO_ROOT / ca_store.STORE_DIR - self.assertEqual(sorted(p.name for p in store.iterdir() if p.suffix == ".pem"), - [ca_store.PEM_NAME]) - - def test_the_committed_pins_parse_like_pins_and_as_shell(self): - path = REPO_ROOT / ca_store.STORE_DIR / ca_store.PINS_NAME - pins = ca_store.read_pins(path) - for value in pins.values(): - self.assertNotRegex(value, "[\"' ]") - shell = subprocess.run( - ["sh", "-c", '. "$1" && echo "$CA_MOZILLA_DATE $CA_MAX_AGE_DAYS"', "sh", str(path)], - capture_output=True, text=True, check=True) - self.assertEqual(shell.stdout.split(), - [pins["CA_MOZILLA_DATE"], pins["CA_MAX_AGE_DAYS"]]) - - def test_the_bridge_builds_its_bundle_from_the_store_and_attaches_it(self): - found = [(str(p.relative_to(REPO_ROOT)), ca_store.attaching(p)) - for p, _ in ca_store.projects(REPO_ROOT)] - self.assertEqual(found, [(BRIDGE, True)]) - - def test_every_project_that_uses_the_store_has_a_version_to_bump(self): - for project, _ in ca_store.projects(REPO_ROOT): - _, text, version = ca_store.bump_ident(project, "2026-09-25", 999) - self.assertIn('%s"' % version, text) - - def test_the_bridge_cmake_runs_the_check_at_configure_and_at_every_build(self): - project = (REPO_ROOT / BRIDGE / "CMakeLists.txt").read_text() - self.assertIn("ca_store/ca_store.cmake", project) - self.assertLess(project.index("project(bridge)"), project.index("ca_store.cmake")) - cmake = (REPO_ROOT / ca_store.STORE_DIR / "ca_store.cmake").read_text() - # Included from any project, at any depth: the store is found from this file's own directory, - # and the project being checked is the one that includes it - self.assertIn("set(CA_STORE ${CMAKE_CURRENT_LIST_DIR})", cmake) - self.assertIn("--project ${CMAKE_SOURCE_DIR}", cmake) - self.assertNotIn("--project ${CMAKE_CURRENT_LIST_DIR}", cmake) - self.assertNotIn("${CMAKE_SOURCE_DIR}/..", cmake) - self.assertIn("tools/ca_store/ca_store.py", cmake) - self.assertIn("FATAL_ERROR", cmake) - self.assertIn("--sdkconfig-json", cmake) - self.assertIn("add_custom_target(ca_store_check ALL", cmake) - self.assertIn("add_dependencies(custom_bundle ca_store_check)", cmake) - - -if __name__ == "__main__": - unittest.main() diff --git a/tools/ca_store/test_refresh.py b/tools/ca_store/test_refresh.py deleted file mode 100644 index 66038f01c..000000000 --- a/tools/ca_store/test_refresh.py +++ /dev/null @@ -1,464 +0,0 @@ -#!/usr/bin/env python3 -"""Tests for refresh.py. Need no network: the store is served from file:// URLs built from -the committed cacert.pem, and GitHub (the regeneration from certdata.txt and the revision -checks) is stood in for. CA_STORE_ONLINE=1 adds tests that run the real ones.""" - -import contextlib -import datetime -import hashlib -import io -import json -import os -import pathlib -import shutil -import sys -import tempfile -import unittest -from unittest import mock - -sys.path.insert(0, str(pathlib.Path(__file__).parent)) - -import ca_store -import refresh -from test_ca_store import (BRIDGE, COMMITTED, HEADER, NEW_DATE, NEW_ISO, NEW_REF, NOW, OLD_DATE, - OLD_ISO, OLD_REF, REPO_ROOT, Tree, der_length, pem, pem_block, rekeyed) - -REF_DATE = "2026-09-08T20:22:24Z" - - -def agree(text, now): - """A regeneration that comes out the same as curl's file.""" - return NEW_REF, text.encode(), REF_DATE - - -def with_subject(der, subject): - """der with its subject replaced (the signature no longer matches; nothing here checks it).""" - _, start, _ = ca_store._tlv(der, 0) - _, tbs_start, tbs_end = ca_store._tlv(der, start) - fields, pos = [], tbs_start - while pos < tbs_end: - _, _, end = ca_store._tlv(der, pos) - fields.append(der[pos:end]) - pos = end - fields[5 if fields[0][0] == 0xA0 else 4] = subject - tbs = b"".join(fields) - tbs = bytes([0x30]) + der_length(len(tbs)) + tbs - body = tbs + der[tbs_end:] - return bytes([0x30]) + der_length(len(body)) + body - - -class Served: - """A cacert.pem and its .sha256 as file:// URLs.""" - - def __init__(self, directory, text, sha256=None): - self.path = pathlib.Path(directory) / "cacert.pem" - self.path.write_bytes(text.encode()) - digest = sha256 or hashlib.sha256(text.encode()).hexdigest() - pathlib.Path(str(self.path) + ".sha256").write_text("%s cacert.pem\n" % digest) - self.url = self.path.as_uri() - - -class RefreshTest(unittest.TestCase): - def setUp(self): - self.tmp = tempfile.mkdtemp() - self.addCleanup(shutil.rmtree, self.tmp) - self.tree = Tree(pathlib.Path(self.tmp) / "repo") - self.serve_dir = pathlib.Path(self.tmp) / "served" - self.serve_dir.mkdir() - - def refresh(self, text, sha256=None, **kwargs): - kwargs.setdefault("regenerate", agree) - kwargs.setdefault("descends", lambda old, new: True) - kwargs.setdefault("now", NOW) - kwargs.setdefault("ident_minor", 7) # the bridge in Tree is 1.6 - return refresh.refresh(self.tree.root, Served(self.serve_dir, text, sha256).url, **kwargs) - - def test_a_new_date_writes_the_store_the_pins_and_bumps_the_bridge(self): - new = pem(NEW_DATE, first=5, count=30) - summary = pathlib.Path(self.tmp) / "summary.md" - - written = self.refresh(new, summary=summary) - - self.assertEqual(self.tree.pem.read_text(), new) - pins = ca_store.read_pins(self.tree.pins) - self.assertEqual(pins["CA_MOZILLA_DATE"], NEW_ISO) - self.assertEqual(pins["CA_SHA256"], hashlib.sha256(new.encode()).hexdigest()) - self.assertEqual(pins["CA_SOURCE_URL"], "https://curl.se/ca/cacert.pem") - self.assertEqual(pins["CA_CERTDATA_REF"], NEW_REF) - self.assertIn("# comment kept\n", self.tree.pins.read_text()) - self.assertIn("\nCA_MOZILLA_DATE=%s\n" % NEW_ISO, self.tree.pins.read_text()) - bridge = (self.tree.bridge / "main/rpc_dispatch.h").read_text() - self.assertEqual(bridge, '#define IDENT_STRING "ESP32 WiFi Bridge V1.7"\n' - "#define IDENT_MAJOR 1\n" - "// 1.7: the Mozilla root store as of 2026-09-25.\n" - "// 1.6: something earlier.\n" - "#define IDENT_MINOR 7\n") - u64ctrl = (self.tree.root / "software/u64ctrl/main/rpc_dispatch.h").read_text() - self.assertEqual(u64ctrl, HEADER % (14, 14, 14)) - self.assertEqual(len(written), 3) - self.assertEqual(pins["CA_BUNDLE_SET_SHA256"], - ca_store.bundle_set_sha256(ca_store.certificates(new))) - report = summary.read_text() - self.assertIn("as of %s (was %s), 30 certificates" % (NEW_ISO, OLD_ISO), report) - old_fps = set(ca_store.roots(pem(OLD_DATE))) - new_fps = set(ca_store.roots(new)) - for fp in new_fps - old_fps: - self.assertIn("- `%s` " % fp, report.split("## Added")[1].split("## Removed")[0]) - for fp in old_fps - new_fps: - self.assertIn("- `%s` " % fp, report.split("## Removed")[1]) - self.assertEqual(len(new_fps - old_fps), 15) - self.assertEqual(len(old_fps - new_fps), 5) - self.assertNotIn("SAME SUBJECT", report) - self.assertIn("`%s` (committed %s)" % (NEW_REF, REF_DATE), report) - self.assertEqual(ca_store.check(self.tree.root, today=datetime.date(2026, 9, 29)), ([], [])) - - def test_files_are_replaced_not_rewritten_in_place(self): - # A build that reads the store meanwhile sees the old file or the new one, never half. - before = {p: p.stat().st_ino for p in (self.tree.pem, self.tree.pins)} - self.refresh(pem(NEW_DATE, first=5, count=30)) - for path, inode in before.items(): - self.assertNotEqual(path.stat().st_ino, inode, path.name) - self.assertEqual(sorted(p.name for p in self.tree.pem.parent.iterdir()), - ["CA_PINS", "cacert.pem"]) - - def test_a_second_run_with_the_same_data_changes_nothing(self): - new = pem(NEW_DATE, first=5, count=30) - self.refresh(new) - before = self.tree.snapshot() - - self.assertEqual(self.refresh(new), []) - self.assertEqual(self.tree.snapshot(), before) - - def test_the_same_date_changes_nothing(self): - before = self.tree.snapshot() - - self.assertEqual(self.refresh(pem(OLD_DATE)), []) - self.assertEqual(self.tree.snapshot(), before) - - def test_the_same_date_with_only_a_different_header_changes_nothing(self): - before = self.tree.snapshot() - - self.assertEqual(self.refresh(pem(OLD_DATE).replace("version 1.33", "version 1.34")), []) - self.assertEqual(self.tree.snapshot(), before) - - def assertRefused(self, message, text, sha256=None): - before = self.tree.snapshot() - with self.assertRaisesRegex(ca_store.StoreError, message): - self.refresh(text, sha256) - self.assertEqual(self.tree.snapshot(), before) - - def test_a_wrong_sha256_writes_nothing(self): - self.assertRefused("sha256 mismatch", pem(NEW_DATE), sha256="0" * 64) - - def test_a_sum_file_that_is_not_a_sum_writes_nothing(self): - self.assertRefused("not a sha256 sum", pem(NEW_DATE), sha256="") - - def test_a_truncated_download_fails_its_sum(self): - new = pem(NEW_DATE) - good_sum = hashlib.sha256(new.encode()).hexdigest() - self.assertRefused("sha256 mismatch", new[: len(new) // 2], sha256=good_sum) - - def test_a_truncated_file_is_refused_even_when_its_sum_matches(self): - new = pem(NEW_DATE) - self.assertRefused("truncated", new[: new.rindex(ca_store.END)]) - self.assertRefused("truncated", new[: new.rindex(ca_store.END) + 10]) - self.assertRefused("truncated", new[:-1]) - - def test_a_certificate_that_is_not_der_is_refused(self): - new = pem(NEW_DATE).replace("\nMII", "\nXII", 1) - self.assertRefused("not DER", new) - - def test_a_file_without_the_mozilla_date_is_refused(self): - self.assertRefused("Certificate data from Mozilla", - pem(NEW_DATE).replace("as of: ", "at: ")) - - def test_an_older_store_is_refused(self): - self.assertRefused("older than the committed store", pem("Mon Mar 11 15:25:27 2024 GMT")) - - def test_different_certificates_under_the_same_date_are_refused(self): - self.assertRefused("certificates changed but the Mozilla date did not", - pem(OLD_DATE, first=1)) - - def test_more_certificates_than_the_bundle_allows_are_refused(self): - shutil.rmtree(self.tree.root) - self.tree = Tree(self.tree.root, max_certs=10) - self.assertRefused("11 certificates, but .* allows 10", pem(NEW_DATE, count=11)) - - def test_a_project_whose_version_does_not_parse_writes_nothing(self): - (self.tree.bridge / "main/rpc_dispatch.h").write_text( - HEADER.replace("V1.%d", "V2.%d") % (6, 6, 6)) - self.assertRefused("IDENT_STRING says 2.6", pem(NEW_DATE, first=1)) - - def test_a_network_failure_writes_nothing(self): - before = self.tree.snapshot() - for url in ((self.serve_dir / "missing.pem").as_uri(), "http://127.0.0.1:9/cacert.pem"): - with mock.patch.object(refresh, "FETCH_TIMEOUT", 5): - with self.assertRaisesRegex(ca_store.StoreError, "cannot fetch"): - refresh.refresh(self.tree.root, url) - self.assertEqual(self.tree.snapshot(), before) - - def test_the_command_line_reports_a_failure_with_a_nonzero_status(self): - served = Served(self.serve_dir, pem(NEW_DATE), sha256="0" * 64) - stderr = io.StringIO() - with contextlib.redirect_stderr(stderr): - status = refresh.main(["--repo-root", str(self.tree.root), - "--source", served.url]) - self.assertEqual(status, 1) - self.assertIn("sha256 mismatch", stderr.getvalue()) - - - def test_a_version_given_for_the_project_by_name_bumps_it(self): - self.refresh(pem(NEW_DATE, first=5, count=30), ident_minor={BRIDGE: 9}) - self.assertIn("#define IDENT_MINOR 9", (self.tree.bridge / "main/rpc_dispatch.h").read_text()) - - def test_a_version_for_another_project_is_not_one_for_the_bridge(self): - before = self.tree.snapshot() - with self.assertRaisesRegex(ca_store.StoreError, "software/wifi/raw_u64 needs a new IDENT_MINOR"): - self.refresh(pem(NEW_DATE, first=5, count=30), ident_minor={"software/u64ctrl": 9}) - self.assertEqual(self.tree.snapshot(), before) - - def test_the_command_line_takes_one_number_or_one_per_project(self): - self.assertIsNone(refresh.parse_ident_minors(None)) - self.assertEqual(refresh.parse_ident_minors(["7"]), 7) - self.assertEqual(refresh.parse_ident_minors(["a/b=7", "c=8"]), {"a/b": 7, "c": 8}) - for bad in (["7", "8"], ["a=x"], ["7", "c=8"]): - with self.assertRaises(ca_store.StoreError): - refresh.parse_ident_minors(bad) - - def test_changed_certificates_without_an_allocated_version_write_nothing(self): - # The next minor is not necessarily free on a development line. - before = self.tree.snapshot() - with self.assertRaisesRegex(ca_store.StoreError, "--ident-minor"): - self.refresh(pem(NEW_DATE, first=5, count=30), ident_minor=None) - self.assertEqual(self.tree.snapshot(), before) - - def test_a_version_that_does_not_move_forward_is_refused(self): - for minor in (6, 5): - self.assertRefusedWith("IDENT_MINOR %d is not above 6" % minor, pem(NEW_DATE, first=5, count=30), - agree, ident_minor=minor) - - def test_the_allocated_version_is_the_one_written(self): - self.refresh(pem(NEW_DATE, first=5, count=30), ident_minor=309) - header = (self.tree.bridge / "main/rpc_dispatch.h").read_text() - self.assertIn('#define IDENT_STRING "ESP32 WiFi Bridge V1.309"', header) - self.assertIn("#define IDENT_MINOR 309\n", header) - self.assertIn("// 1.309: the Mozilla root store as of 2026-09-25.", header) - - def test_the_same_certificates_need_no_version(self): - self.assertEqual(len(self.refresh(pem(NEW_DATE), ident_minor=None)), 2) - - def test_the_command_line_passes_the_version(self): - served = Served(self.serve_dir, pem(NEW_DATE, first=5, count=30)) - real = refresh.refresh - - def offline(*args, **kwargs): - return real(*args, regenerate=agree, descends=lambda old, new: True, now=NOW, **kwargs) - with mock.patch.object(refresh, "refresh", offline), \ - contextlib.redirect_stderr(io.StringIO()) as err, contextlib.redirect_stdout(io.StringIO()): - self.assertEqual(refresh.main(["--repo-root", str(self.tree.root), "--source", served.url]), 1) - self.assertIn("--ident-minor", err.getvalue()) - self.assertEqual(refresh.main(["--repo-root", str(self.tree.root), "--source", served.url, - "--ident-minor", "8"]), 0) - self.assertIn("V1.8", (self.tree.bridge / "main/rpc_dispatch.h").read_text()) - - def test_a_new_date_with_the_same_certificates_bumps_nothing(self): - new = pem(NEW_DATE) - summary = pathlib.Path(self.tmp) / "summary.md" - headers = {p: p.read_text() for p in self.tree.root.rglob("rpc_dispatch.h")} - - written = self.refresh(new, summary=summary) - - self.assertEqual(written, [self.tree.pem, self.tree.pins]) - self.assertEqual({p: p.read_text() for p in headers}, headers) - self.assertEqual(ca_store.read_pins(self.tree.pins)["CA_MOZILLA_DATE"], NEW_ISO) - self.assertIn("did not change", summary.read_text()) - - def test_a_file_that_mozillas_data_does_not_give_is_refused(self): - # A mirror serving its own key under ISRG Root X1's name, with a matching sum: the - # regeneration from certdata.txt still gives the real one. - honest = pem(NEW_DATE) - forged = rekeyed(honest, 3, 7) - self.assertNotEqual(forged, honest) - before = self.tree.snapshot() - with self.assertRaisesRegex(ca_store.StoreError, "is not what .* gives"): - self.refresh(forged, regenerate=lambda text, now: (NEW_REF, honest.encode(), REF_DATE)) - self.assertEqual(self.tree.snapshot(), before) - - def test_a_different_header_alone_is_refused_too(self): - honest = pem(NEW_DATE) - with self.assertRaisesRegex(ca_store.StoreError, "is not what"): - self.refresh(honest.replace("version 1.33", "version 1.34"), - regenerate=lambda text, now: (NEW_REF, honest.encode(), REF_DATE)) - - def test_a_key_change_under_the_same_subject_gets_its_own_section(self): - # When Mozilla itself makes the change, both origins agree and the store is written, - # but the description puts it apart from ordinary additions and removals. - new = rekeyed(pem(NEW_DATE), 3, 7) - summary = pathlib.Path(self.tmp) / "summary.md" - - self.refresh(new, summary=summary) - - report = summary.read_text() - section = report.split("## SAME SUBJECT, DIFFERENT CERTIFICATE")[1].split("## Added")[0] - old_fp = hashlib.sha256(ca_store.certificates(pem(OLD_DATE))[3]).hexdigest() - new_fp = hashlib.sha256(ca_store.certificates(new)[3]).hexdigest() - self.assertIn("`%s` became `%s`" % (old_fp, new_fp), section) - self.assertEqual(report.split("## Added")[1].split("## Removed")[0].strip(), "None.") - self.assertIn("V1.7", (self.tree.bridge / "main/rpc_dispatch.h").read_text()) - - def test_labels_cannot_inject_markup_into_the_description(self): - new = pem(NEW_DATE, first=5, count=30) - label = ca_store.names(new)[-1] - new = new.replace("\n%s\n" % label, "\n[x](https://evil)`\n", 1) - summary = pathlib.Path(self.tmp) / "summary.md" - self.refresh(new, summary=summary) - self.assertNotIn("](https", summary.read_text()) - self.assertNotIn("", summary.read_text()) - - def test_a_date_in_the_future_is_refused(self): - self.assertRefused("in the future", pem("Thu Oct 01 12:00:01 2026 GMT")) - - def test_a_date_within_a_day_of_the_clock_is_accepted(self): - self.refresh(pem("Wed Sep 30 11:59:59 2026 GMT")) - self.assertEqual(ca_store.read_pins(self.tree.pins)["CA_MOZILLA_DATE"], - "2026-09-30T11:59:59Z") - - def test_an_earlier_time_on_the_same_day_is_a_rollback(self): - self.assertRefused("older than the committed store", pem("Tue Jul 14 03:12:00 2026 GMT")) - - def test_exactly_as_many_certificates_as_the_bundle_allows_is_accepted(self): - shutil.rmtree(self.tree.root) - self.tree = Tree(self.tree.root, max_certs=10) - self.assertTrue(self.refresh(pem(NEW_DATE, count=10))) - - def test_a_failing_regeneration_writes_nothing(self): - def broken(text, now): - raise ca_store.StoreError("cannot fetch certdata.txt") - self.assertRefusedWith("cannot fetch certdata", pem(NEW_DATE), broken) - - def assertRefusedWith(self, message, text, regenerate, **kwargs): - before = self.tree.snapshot() - with self.assertRaisesRegex(ca_store.StoreError, message): - self.refresh(text, regenerate=regenerate, **kwargs) - self.assertEqual(self.tree.snapshot(), before) - - def test_an_older_certdata_revision_is_refused(self): - # curl.se alone serving an honest conversion of an older certdata.txt under a new date. - seen = [] - - def older(old, new): - seen.append((old, new)) - return False - before = self.tree.snapshot() - with self.assertRaisesRegex(ca_store.StoreError, "not the committed .* or a later commit"): - self.refresh(pem(NEW_DATE, first=5, count=30), descends=older) - self.assertEqual(seen, [(OLD_REF, NEW_REF)]) - self.assertEqual(self.tree.snapshot(), before) - - def test_no_module_attaching_the_bundle_means_no_bump(self): - (self.tree.shared / "tls_engine.c").unlink() - summary = pathlib.Path(self.tmp) / "summary.md" - written = self.refresh(pem(NEW_DATE, first=5, count=30), summary=summary) - self.assertEqual(written, [self.tree.pem, self.tree.pins]) - self.assertIn("No project attaches the bundle", summary.read_text()) - - def test_a_look_alike_added_beside_the_real_root_gets_its_own_section(self): - # The same name spelled with UTF8String where the real root uses PrintableString is a - # different subject, so it is neither the SAME SUBJECT case nor visible in a plain list. - base = pem(NEW_DATE) - victim = ca_store.certificates(base)[0] - label = ca_store.names(base)[0] - subject, _ = ca_store.subject_and_key(victim) - look = subject.replace(b"\x13", b"\x0c") # PrintableString -> UTF8String - self.assertNotEqual(look, subject) - forged = base.rstrip("\n") + "\n\n" + label + "\n" + "=" * len(label) + "\n" + \ - pem_block(with_subject(ca_store.certificates(base)[7], look)) - summary = pathlib.Path(self.tmp) / "summary.md" - self.refresh(forged, summary=summary) - section = summary.read_text().split("## ADDED UNDER THE NAME")[1].split("## Added")[0] - self.assertIn(label, section) - - def test_a_look_alike_under_another_label_is_caught_by_its_name(self): - base = pem(NEW_DATE) - subject, _ = ca_store.subject_and_key(ca_store.certificates(base)[0]) - look = subject.replace(b"\x13", b"\x0c") - forged = base.rstrip("\n") + "\n\nHarmless Root\n=============\n" + \ - pem_block(with_subject(ca_store.certificates(base)[7], look)) - summary = pathlib.Path(self.tmp) / "summary.md" - self.refresh(forged, summary=summary) - section = summary.read_text().split("## ADDED UNDER THE NAME")[1].split("## Added")[0] - self.assertIn("Harmless Root", section) - - -class FindCertdataTest(unittest.TestCase): - """The revision check against Firefox's release branch, with GitHub stood in for.""" - - def serve(self, commits, blobs): - listing = json.dumps([{"sha": sha, "commit": {"committer": {"date": date}}} - for sha, date in commits]).encode() - - def fetch(url, token=False): - if "/commits?" in url: - return listing - return blobs[url.split("/")[5]] - return mock.patch.object(refresh, "fetch", fetch) - - def test_the_newest_revision_is_taken(self): - blob = b"certdata new" - with self.serve([("a" * 40, "2026-09-08T20:22:24Z"), ("b" * 40, "2026-07-15T00:00:00Z")], - {"a" * 40: blob, "b" * 40: b"old"}): - ref, data, date = refresh.find_certdata(hashlib.sha256(blob).hexdigest(), NOW) - self.assertEqual((ref, data, date), ("mozilla-firefox/firefox@" + "a" * 40, blob, - "2026-09-08T20:22:24Z")) - - def test_an_older_revision_is_taken_only_within_the_grace_period(self): - old = b"certdata old" - commits = [("a" * 40, "2026-09-20T00:00:00Z"), ("b" * 40, "2026-07-15T00:00:00Z")] - blobs = {"a" * 40: b"new", "b" * 40: old} - with self.serve(commits, blobs): - ref, _, _ = refresh.find_certdata(hashlib.sha256(old).hexdigest(), - datetime.datetime(2026, 10, 4)) - self.assertTrue(ref.endswith("b" * 40)) - with self.serve(commits, blobs): - with self.assertRaisesRegex(ca_store.StoreError, "now carries a newer one"): - refresh.find_certdata(hashlib.sha256(old).hexdigest(), - datetime.datetime(2026, 10, 4, 0, 0, 1)) - - def test_an_unknown_certdata_is_refused(self): - with self.serve([("a" * 40, "2026-09-08T20:22:24Z")], {"a" * 40: b"x"}): - with self.assertRaisesRegex(ca_store.StoreError, "none of the last 1 revisions"): - refresh.find_certdata("0" * 64, NOW) - - def test_descent_is_asked_of_githubs_compare(self): - answers = {"ahead": ({"status": "ahead", "behind_by": 0}, True), - "behind": ({"status": "behind", "behind_by": 3}, False), - "diverged": ({"status": "diverged", "behind_by": 1}, False)} - for name, (answer, expected) in answers.items(): - with mock.patch.object(refresh, "fetch_json", lambda url: answer) as _: - self.assertEqual(refresh.descends(OLD_REF, NEW_REF), expected, name) - self.assertTrue(refresh.descends(OLD_REF, OLD_REF)) - with mock.patch.object(refresh, "fetch_json", lambda url: []): - with self.assertRaisesRegex(ca_store.StoreError, "did not return an object"): - refresh.descends(OLD_REF, NEW_REF) - self.assertFalse(refresh.descends(OLD_REF, "someone/firefox@" + "2" * 40)) - - -class OnlineTest(unittest.TestCase): - @unittest.skipUnless(os.environ.get("CA_STORE_ONLINE") == "1", "set CA_STORE_ONLINE=1") - def test_the_committed_store_is_what_mozillas_certdata_gives(self): - pins = ca_store.read_pins(REPO_ROOT / ca_store.STORE_DIR / ca_store.PINS_NAME) - ref, again, _ = refresh.regenerate(COMMITTED, ca_store.utc_now()) - self.assertEqual(ref, pins["CA_CERTDATA_REF"]) - self.assertEqual(again, COMMITTED.encode()) - - - @unittest.skipUnless(os.environ.get("CA_STORE_ONLINE") == "1", "set CA_STORE_ONLINE=1") - def test_the_committed_ref_descends_from_itself_and_not_from_a_later_one(self): - pins = ca_store.read_pins(REPO_ROOT / ca_store.STORE_DIR / ca_store.PINS_NAME) - older = "mozilla-firefox/firefox@4e9426ae522c67de47ff3e060774328b42df0134" - self.assertTrue(refresh.descends(older, pins["CA_CERTDATA_REF"])) - self.assertFalse(refresh.descends(pins["CA_CERTDATA_REF"], older)) - - -if __name__ == "__main__": - unittest.main() From 9f418a352e6eb272678cb78e7c15aa953322e726 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Sat, 31 Oct 2026 07:03:31 -0500 Subject: [PATCH 58/95] E2E: move the UCI agent mailbox OPT_WAIT to $C00B The draft #936 uses $C00A for OPT_CANCEL in the same agent. Move OPT_WAIT up one byte in uci_agent.asm and uci_native.py so the two mailbox layouts do not collide; the reserved range now starts at $C00C. Co-Authored-By: Claude Opus 5.5 --- tests/e2e/io/command_interface/uci_agent.asm | 6 +++--- tests/e2e/lib/uci_native.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e/io/command_interface/uci_agent.asm b/tests/e2e/io/command_interface/uci_agent.asm index 534362f38..815e643f5 100644 --- a/tests/e2e/io/command_interface/uci_agent.asm +++ b/tests/e2e/io/command_interface/uci_agent.asm @@ -25,7 +25,7 @@ ; reply ; OPT_WAIT how long a wait may last, for a command that legitimately ; runs longer than the default (an OPEN_TLS can take 41 s) -; $C00B-$C00F and $C440-$C4FF are reserved for further options and results. +; $C00C-$C00F and $C440-$C4FF are reserved for further options and results. ; New behaviour, as opposed to a new value, belongs in a reserved option byte, ; where zero has to keep meaning what the agent does today: the host writes the ; whole option block at once, so an older host leaves zeroes there. @@ -69,8 +69,8 @@ OPT_CAP = $C006 ; 16 bit cap on the data drain READY = $C008 ; agent writes $A5 here once it is running OPT_ABRT = $C009 ; non-zero: abandon the reply after the first ; block by writing the abort bit -OPT_WAIT = $C00A ; wraps a wait may take; zero means WAIT_WRAPS -; $C00B-$C00F ; reserved for further options +OPT_WAIT = $C00B ; wraps a wait may take; zero means WAIT_WRAPS +; $C00C-$C00F ; reserved for further options CMDBUF = $C010 ; command bytes, up to 896 ; ------------------------------------------------------------- result block -- diff --git a/tests/e2e/lib/uci_native.py b/tests/e2e/lib/uci_native.py index d98c4949f..a5be7cc12 100644 --- a/tests/e2e/lib/uci_native.py +++ b/tests/e2e/lib/uci_native.py @@ -36,7 +36,7 @@ OPT_CAP = 0xC006 READY = 0xC008 OPT_ABRT = 0xC009 -OPT_WAIT = 0xC00A +OPT_WAIT = 0xC00B CMDBUF = 0xC010 RESULT_BASE = 0xC400 From dd7f99928438f3ca6288bf25dd2c821d6cce169b Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:29:13 -0500 Subject: [PATCH 59/95] Write the E2E agent's OPT_WAIT at its own address Moving OPT_WAIT to $C00B left the native client writing it together with OPT_ABRT in one two-byte write, which lands on $C00A. The agent then read OPT_WAIT as zero and gave up waiting on a slow TLS handshake. Write the two options separately. Co-Authored-By: Claude Opus 5.5 --- tests/e2e/lib/uci_native.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/e2e/lib/uci_native.py b/tests/e2e/lib/uci_native.py index a5be7cc12..fc8a3a212 100644 --- a/tests/e2e/lib/uci_native.py +++ b/tests/e2e/lib/uci_native.py @@ -125,11 +125,11 @@ def _run(self, command: bytes, overrun_reads: int, cap: int, len(command) & 0xFF, (len(command) >> 8) & 0xFF, min(overrun_reads, MAX_OVERRUN_READS), max_blocks, cap & 0xFF, (cap >> 8) & 0xFF])) - # Outside the option block above, so it is written every time rather - # than left over from the previous transaction. OPT_WAIT follows - # OPT_ABRT, so one write carries both. - self.machine.writemem(OPT_ABRT, bytes([0x01 if abort_first else 0x00, - self.wait_wraps & 0xFF])) + # Outside the option block above, so they are written every time + # rather than left over from the previous transaction. OPT_WAIT is not + # next to OPT_ABRT ($C00A is left free), so each gets its own write. + self.machine.writemem(OPT_ABRT, bytes([0x01 if abort_first else 0x00])) + self.machine.writemem(OPT_WAIT, bytes([self.wait_wraps & 0xFF])) self.machine.writemem(GO, bytes([0x01])) deadline = time.monotonic() + self.busy_timeout From a51f7a91bd0d3a7935622ccbfa8a7ab706dd7887 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 12 Nov 2026 13:31:15 -0600 Subject: [PATCH 60/95] Adapt the getrandompaths host test to the worker-task NetworkTarget from master Master moved command execution to a worker task: the commands run in NetworkTarget::execute(), and network_target.h includes FreeRTOS and takes CMD_MAX_COMMAND_LEN. The test cut the GET_RANDOM case out of parse_command(), which no longer holds it, and did not build against the new header. It now cuts the case out of execute(), supplies the FreeRTOS stand-ins that the wifi_dedicated test already has, and defines CMD_MAX_COMMAND_LEN in its command_intf.h stand-in. No product code changes. Co-Authored-By: Claude Sonnet 5.5 --- software/test/get_random_paths/net_target_test.cc | 4 ++-- software/test/get_random_paths/stub/command_intf.h | 1 + target/pc/linux/getrandompaths/Makefile | 9 +++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/software/test/get_random_paths/net_target_test.cc b/software/test/get_random_paths/net_target_test.cc index ee057370b..e63da535e 100644 --- a/software/test/get_random_paths/net_target_test.cc +++ b/software/test/get_random_paths/net_target_test.cc @@ -2,7 +2,7 @@ * net_target_test.cc * * The UCI network target's GET_RANDOM (NetworkTarget::get_random(), the GET_RANDOM case of - * parse_command() and the status messages, cut out of network_target.cc as they are) with + * execute() and the status messages, cut out of network_target.cc as they are) with * the real wifi_random.cc behind it, and the module's answer stubbed: which UCI status and * which bytes each answer gives, and which command lengths are taken. */ @@ -91,7 +91,7 @@ static void command_length(void) asked = 0; module_result = 0; reply = status = NULL; - t.parse_command(&m, &reply, &status); + t.execute(&m, &reply, &status); if (len == 4) { CHECK(status_is(status, "00,OK") && (asked == 1), "four bytes: asked, 00,OK"); } else { diff --git a/software/test/get_random_paths/stub/command_intf.h b/software/test/get_random_paths/stub/command_intf.h index 453cec000..2ece4fdac 100644 --- a/software/test/get_random_paths/stub/command_intf.h +++ b/software/test/get_random_paths/stub/command_intf.h @@ -3,6 +3,7 @@ #define COMMAND_INTF_H_STUB #include #define CMD_MAX_REPLY_BLOCK 895 +#define CMD_MAX_COMMAND_LEN 896 typedef struct _message { int length; bool last_part; diff --git a/target/pc/linux/getrandompaths/Makefile b/target/pc/linux/getrandompaths/Makefile index f4f2001db..1e99db116 100644 --- a/target/pc/linux/getrandompaths/Makefile +++ b/target/pc/linux/getrandompaths/Makefile @@ -2,7 +2,7 @@ # Host tests of the paths GET_RANDOM takes on the Ultimate and the control module that no # other host test compiles. Each is cut out of its file as it is and built against # stand-ins (software/test/get_random_paths): -# net_target NetworkTarget::get_random(), the GET_RANDOM case of parse_command() and the +# net_target NetworkTarget::get_random(), the GET_RANDOM case of execute() and the # status messages, with wifi_random.cc # isr wifi_rx_isr() from wifi_cmd.cc and DmaUART::ClearRxBuffer() from dma_uart.cc # voltages cmd_get_voltages() from the u64ctrl module's rpc_dispatch.c @@ -33,17 +33,18 @@ $(OUTPUT)/net.cc: $(SRC)/io/network/network_target.cc $(SRC)/io/command_interfac grep -E '^Message c_(message_empty|status_ok) ' $(SRC)/io/command_interface/command_intf.cc; \ grep -E '^Message c_status_' $(SRC)/io/network/network_target.cc; \ $(call FN,void NetworkTarget :: get_random,$(SRC)/io/network/network_target.cc); \ - echo 'void NetworkTarget :: parse_command(Message *command, Message **reply, Message **status)'; \ + echo 'void NetworkTarget :: parse_command(Message *command, Message **reply, Message **status) { execute(command, reply, status); }'; \ + echo 'void NetworkTarget :: execute(Message *command, Message **reply, Message **status)'; \ echo '{'; echo ' switch (command->message[1]) {'; \ awk '/case NET_CMD_GET_RANDOM:/ { p = 1 } p { print } p && /^ break;\r?$$/ { p = 0 }' $(SRC)/io/network/network_target.cc; \ echo ' default:'; echo ' break;'; echo ' }'; echo '}'; } > $@ @grep -q 'NetworkTarget :: get_random' $@ || { echo "getrandompaths: get_random not found"; exit 1; } - @grep -q 'case NET_CMD_GET_RANDOM:' $@ || { echo "getrandompaths: the GET_RANDOM case of parse_command not found"; exit 1; } + @grep -q 'case NET_CMD_GET_RANDOM:' $@ || { echo "getrandompaths: the GET_RANDOM case of execute not found"; exit 1; } $(RESULT)/net_target: $(OUTPUT)/net.cc $(TESTDIR)/net_target_test.cc @mkdir -p $(RESULT) $(CXX) -std=gnu++11 -g -O0 $(WARN) -DU64=1 -I$(TESTDIR)/stub -I$(TESTDIR) -I$(SRC)/io/network -I$(SRC)/io/wifi \ - -I$(PATH_SW)/test/wifi_random -I$(SRC)/wifi/raw_u64/main -I$(SRC)/wifi/common \ + -I$(PATH_SW)/test/wifi_random -I$(PATH_SW)/test/wifi_dedicated/stub -I$(SRC)/wifi/raw_u64/main -I$(SRC)/wifi/common \ -o $@ $(OUTPUT)/net.cc $(TESTDIR)/net_target_test.cc $(SRC)/io/wifi/wifi_random.cc $(OUTPUT)/isr.cc: $(SRC)/io/wifi/wifi_cmd.cc $(SRC)/io/uart/dma_uart.cc From 7569cba785848506b2615042e5c9ecfadfa93788 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 12 Nov 2026 13:55:11 -0600 Subject: [PATCH 61/95] Adapt the TLS host tests to the worker-task NetworkTarget from master Master moved command execution to a worker task and made the socket connect and send wait in slices. The nettls test compiled the real network_target.cc against stand-ins that know neither. The test now calls execute() as the worker does, and close_sockets_after_reset() where the worker would run it after a C64 reset; socket-free commands still go through parse_command(). The stand-ins gain the FreeRTOS queue and task calls, ioctlsocket, select, getsockopt and send, and SO_ERROR for the non-blocking connect. A plain OPEN_TCP socket now carries the send slice as its SO_SNDTIMEO, which the START_TLS checks expect to find unchanged. No product code changes. Co-Authored-By: Claude Sonnet 5.5 --- software/test/wifi_tls/net_tls_test.cc | 38 +++++++++++++++++++++---- software/test/wifi_tls/net_world.cc | 24 ++++++++++++++++ software/test/wifi_tls/netstub/socket.h | 5 ++++ software/test/wifi_tls/stub/FreeRTOS.h | 8 ++++++ software/test/wifi_tls/stub/queue.h | 4 +++ software/test/wifi_tls/stub/task.h | 1 + target/pc/linux/wifitls/Makefile | 2 +- 7 files changed, 75 insertions(+), 7 deletions(-) diff --git a/software/test/wifi_tls/net_tls_test.cc b/software/test/wifi_tls/net_tls_test.cc index b0fe5f82c..77075dd02 100644 --- a/software/test/wifi_tls/net_tls_test.cc +++ b/software/test/wifi_tls/net_tls_test.cc @@ -8,7 +8,9 @@ #include #include #include "net_world.h" +#define class struct // execute() and close_sockets_after_reset() are private #include "network_target.h" +#undef class #include "check.h" int failures; @@ -41,13 +43,33 @@ struct Res { // The longest status any command of the run answered (the cap is 40 bytes). static std::string longest_status; +// A C64 reset: the UCI Server task notes it, and the worker closes the sockets and the TLS sessions. +static void reset_c64(void) +{ + net.c64_reset(); + net.close_sockets_after_reset(); +} + static Res run(const bytes &command) { static uint8_t buf[1024]; memcpy(buf, command.data(), command.size()); Message m = { (int)command.size(), true, buf }; Message *reply, *status; - net.parse_command(&m, &reply, &status); + // The UCI Server task answers a socket-free command itself; any other runs on the worker, which is + // not started here: execute() is called as the worker calls it, between its own housekeeping. + if (net.is_quick(&m)) { + net.parse_command(&m, &reply, &status); + } else { + static volatile bool not_cancelled; + not_cancelled = false; + net.close_sockets_after_reset(); + net.cancel = ¬_cancelled; + net.opened_socket = -1; + net.execute(&m, &reply, &status); + net.cancel = NULL; + net.close_sockets_after_reset(); + } Res r; r.data.assign(reply->message, reply->message + reply->length); r.status.assign((const char *)status->message, status->length); @@ -160,7 +182,7 @@ static Res release(void) static void fresh(void) { world_reset(); - net.c64_reset(); + reset_c64(); world_module.calls.clear(); world_module.close_alls = 0; for (int i = 0; i < 16; i++) { @@ -713,7 +735,7 @@ static void test_reset_during_open(void) uint32_t late = (world_tick - world_reset_at) * 5; check(late <= 110, "reset: the OPEN returns within a slice of the reset (%u ms late)", late); check(world_open_sockets() == 0 && world_count(0x32) == 0, "reset: socket closed, no CLOSE RPC waited for"); - net.c64_reset(); + reset_c64(); world_reset_at = 0xFFFFFFFF; check(world_module.close_alls == 1, "reset: c64_reset sends CLOSE_ALL once"); r = info(0xFF); @@ -741,10 +763,14 @@ static bytes start_cmd(int h, uint8_t trust, uint8_t flags, const std::string &t return cat(cat(B({ first, 0x24, h, trust, flags }), pin), S(tail)); } +// An OPEN_TCP socket carries the send slice (SOCKET_SLICE_MS in software/network/socket_slices.h) as its +// SO_SNDTIMEO; what START_TLS must not change is that, and the TLS value is 500 ms. +#define PLAIN_SNDTIMEO_MS 100 + static void expect_kept(int h, const bytes &cmd, const char *want, const char *what) { Res r = run(cmd); - bool untouched = sock(h).open && !sock(h).nodelay && !sock(h).nonblocking && !sock(h).sndtimeo_ms; + bool untouched = sock(h).open && !sock(h).nodelay && !sock(h).nonblocking && (sock(h).sndtimeo_ms == PLAIN_SNDTIMEO_MS); check(r.status == want && r.data.empty() && untouched, "start: %s -> %s, TCP handle unchanged (got %s)", what, want, r.status.c_str()); } @@ -757,7 +783,7 @@ static void test_start_tls(void) Res u = run(B({ 0x03, 0x08, 0x35, 0x00, 'n', 's' })); int udp = u.data.empty() ? -1 : u.data[0]; check(t >= 0 && udp >= 0, "start: a TCP and a UDP handle to work with"); - check(!sock(t).sndtimeo_ms && !sock(t).nodelay, "start: OPEN_TCP's socket gets neither (TLS sockets only)"); + check((sock(t).sndtimeo_ms == PLAIN_SNDTIMEO_MS) && !sock(t).nodelay, "start: OPEN_TCP's socket gets neither (TLS sockets only)"); Res r = run(start_cmd(udp, 2, 0, "", PIN())); check(r.status == "81,INVALID PARAMS" && sock(udp).open, "start: on a UDP handle -> 81, UDP untouched"); r = run(start_cmd(12, 2, 0, "", PIN())); @@ -1414,7 +1440,7 @@ static void test_cleanup(void) chunk(0, 10, bytes(10, 1)); int a = open_ok(1), b = open_ok(0); world_module.calls.clear(); - net.c64_reset(); + reset_c64(); check(!sock(a).open && !sock(b).open, "reset: both TLS sockets closed"); check(world_module.close_alls == 1, "reset: CLOSE_ALL once"); Res r = info(0xFF); diff --git a/software/test/wifi_tls/net_world.cc b/software/test/wifi_tls/net_world.cc index f88556b9e..99da2eb0f 100644 --- a/software/test/wifi_tls/net_world.cc +++ b/software/test/wifi_tls/net_world.cc @@ -174,6 +174,16 @@ TickType_t xTaskGetTickCount(void) return world_tick; } +// The network target's worker task and its queue are not run (see run() in net_tls_test.cc). +BaseType_t xTaskCreate(void (*)(void *), const char *, uint16_t, void *, UBaseType_t, TaskHandle_t *) { return 0; } +QueueHandle_t xQueueCreate(UBaseType_t, UBaseType_t) { return NULL; } +BaseType_t xQueueSend(QueueHandle_t, const void *, TickType_t) { return 0; } +UBaseType_t uxQueueMessagesWaiting(QueueHandle_t) { return 0; } +void vQueueDelete(QueueHandle_t) { } +BaseType_t xQueueReceive(QueueHandle_t, void *, TickType_t) { return 0; } +uint32_t command_defer(void) { return 0; } +void command_deferred_done(uint32_t) { } + void vTaskDelay(TickType_t ticks) { world_advance(ticks ? ticks : 1); @@ -342,6 +352,20 @@ int lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optl *optlen = sizeof(int); return 0; } + if ((level == SOL_SOCKET) && (optname == SO_ERROR)) { + // The result of a non-blocking connect, which connect_sliced() asks for once select() says it is over. + FakeSock &k = world_socks[s]; + *(int *)optval = 0; + *optlen = sizeof(int); + if (k.nonblocking && !k.connected && k.connect_at) { + if (k.srv.connect_err) { + *(int *)optval = k.srv.connect_err; + } else { + k.connected = true; + } + } + return 0; + } errno = ENOPROTOOPT; return -1; } diff --git a/software/test/wifi_tls/netstub/socket.h b/software/test/wifi_tls/netstub/socket.h index 6f7795a6a..6d706778b 100644 --- a/software/test/wifi_tls/netstub/socket.h +++ b/software/test/wifi_tls/netstub/socket.h @@ -31,6 +31,11 @@ ssize_t lwip_recvmsg(int s, struct msghdr *message, int flags); int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout); int lwip_close(int s); +#define ioctlsocket(a, b, c) lwip_ioctl(a, b, c) +// socket_slices.h and send_all.h (the sliced connect and send) use the BSD names +#define select(a, b, c, d, e) lwip_select(a, b, c, d, e) +#define getsockopt(a, b, c, d, e) lwip_getsockopt(a, b, c, d, e) +#define send(a, b, c, d) lwip_send(a, b, c, d) #define socket(a, b, c) lwip_socket(a, b, c) #define connect(a, b, c) lwip_connect(a, b, c) #define setsockopt(a, b, c, d, e) lwip_setsockopt(a, b, c, d, e) diff --git a/software/test/wifi_tls/stub/FreeRTOS.h b/software/test/wifi_tls/stub/FreeRTOS.h index 44ddca460..9d856b8b9 100644 --- a/software/test/wifi_tls/stub/FreeRTOS.h +++ b/software/test/wifi_tls/stub/FreeRTOS.h @@ -14,4 +14,12 @@ typedef void *TaskHandle_t; #define portTICK_PERIOD_MS (1000 / configTICK_RATE_HZ) // As in software/FreeRTOS/Source/include/projdefs.h. #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) +// The worker task of the network target is not run here: net_tls_test.cc calls execute() itself, as the +// worker does, so these only have to compile. +#define pdPASS 1 +#define portMAX_DELAY 0xffffffffUL +#define configMINIMAL_STACK_SIZE 512 +#define PRIO_NETSERVICE 1 +#define portENTER_CRITICAL() do { } while (0) +#define portEXIT_CRITICAL() do { } while (0) #endif diff --git a/software/test/wifi_tls/stub/queue.h b/software/test/wifi_tls/stub/queue.h index cb7604eb5..1c81345a3 100644 --- a/software/test/wifi_tls/stub/queue.h +++ b/software/test/wifi_tls/stub/queue.h @@ -2,4 +2,8 @@ #define QUEUE_H_STUB #include "FreeRTOS.h" BaseType_t xQueueReceive(QueueHandle_t queue, void *item, TickType_t ticks); +QueueHandle_t xQueueCreate(UBaseType_t length, UBaseType_t item_size); +BaseType_t xQueueSend(QueueHandle_t queue, const void *item, TickType_t ticks); +UBaseType_t uxQueueMessagesWaiting(QueueHandle_t queue); +void vQueueDelete(QueueHandle_t queue); #endif diff --git a/software/test/wifi_tls/stub/task.h b/software/test/wifi_tls/stub/task.h index a6408e654..f1b189274 100644 --- a/software/test/wifi_tls/stub/task.h +++ b/software/test/wifi_tls/stub/task.h @@ -5,4 +5,5 @@ TickType_t xTaskGetTickCount(void); void vTaskSuspendAll(void); BaseType_t xTaskResumeAll(void); void vTaskDelay(TickType_t ticks); +BaseType_t xTaskCreate(void (*code)(void *), const char *name, uint16_t stack, void *arg, UBaseType_t priority, TaskHandle_t *handle); #endif diff --git a/target/pc/linux/wifitls/Makefile b/target/pc/linux/wifitls/Makefile index 77e02de37..8220f4047 100644 --- a/target/pc/linux/wifitls/Makefile +++ b/target/pc/linux/wifitls/Makefile @@ -18,7 +18,7 @@ TLS_OBJS = $(addprefix $(OUTPUT)/tls/, $(TLS_SRCS:%.cc=%.o)) # The network target's sources, which a red run can point at another tree. NET_DIR = $(PATH_SW)/io/network -NET_PATH = $(TEST)/netstub $(TEST)/stub $(NET_DIR) $(PATH_SW)/io/wifi $(PATH_SW)/io/command_interface +NET_PATH = $(TEST)/netstub $(TEST)/stub $(NET_DIR) $(PATH_SW)/io/wifi $(PATH_SW)/io/command_interface $(PATH_SW)/network NET_OPTIONS = -std=gnu++11 -g -O0 -Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -DNIOS=1 -DU64=1 $(addprefix -I, $(NET_PATH)) NET_SRCS = net_tls_test.cc net_world.cc ip4addr_aton.cc NET_OBJS = $(addprefix $(OUTPUT)/net/, $(NET_SRCS:%.cc=%.o)) $(OUTPUT)/net/network_target.o $(OUTPUT)/net/network_target_tls.o $(OUTPUT)/net/wifi_random.o From 3e95730e43c21a2b9947b407670ab24b4c6acb8f Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 12 Nov 2026 15:04:22 -0600 Subject: [PATCH 62/95] Count socket-free and skipped commands as commands for the TLS rules The TLS state belongs to the worker, so tls_before_command() no longer runs for the commands that the UCI Server task answers itself (IDENTIFY and the other socket-free ones), nor for a queued command that was aborted before the worker started it. That broke two rules that rely on every command arriving: a session counts as claimed once any command follows its OPEN, and a CA upload ends when anything else is sent. IDENTIFY and then $25 would have freed a live session. Those commands now leave word in tls_quick_seen, which tls_before_command() reads and clears inside a critical section. The tests (IDENTIFY then $25, IDENTIFY between CA chunks, and the existing 'even IDENTIFY claims') failed without it. Co-Authored-By: Claude Sonnet 5.5 --- software/io/network/network_target.cc | 10 ++++++++++ software/io/network/network_target.h | 1 + software/io/network/network_target_tls.cc | 10 ++++++++-- software/test/wifi_tls/net_tls_test.cc | 24 +++++++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/software/io/network/network_target.cc b/software/io/network/network_target.cc index abc495751..c91759f42 100644 --- a/software/io/network/network_target.cc +++ b/software/io/network/network_target.cc @@ -100,6 +100,12 @@ void NetworkTarget :: answer_quick(Message *command, Message **reply, Message ** { NetworkInterface *interface; +#if NET_TLS + // Every command counts as one for the TLS rules, and the TLS state belongs to the worker: + // this one leaves word for it (tls_before_command). + tls_quick_seen = true; +#endif + switch(command->message[1]) { case NET_CMD_IDENTIFY: *reply = &c_net_message_identification; @@ -296,6 +302,10 @@ void NetworkTarget :: worker_task(void *a) t->execute(&j->command, &j->reply, &j->status); j->opened = t->opened_socket; t->cancel = NULL; + } else { +#if NET_TLS + t->tls_quick_seen = true; // it was a command all the same +#endif } t->close_sockets_after_reset(); portENTER_CRITICAL(); diff --git a/software/io/network/network_target.h b/software/io/network/network_target.h index 738d3c457..c3a12bb14 100644 --- a/software/io/network/network_target.h +++ b/software/io/network/network_target.h @@ -161,6 +161,7 @@ class NetworkTarget : public CommandTarget { TlsSocket tls[NET_MAX_TLS]; uint16_t tls_last_tag; bool tls_generation_known; + volatile bool tls_quick_seen; // a command ran or was skipped apart from the worker; see tls_before_command uint32_t tls_generation; uint8_t ca_state; // CA_EMPTY, CA_UPLOADING or CA_LOADED uint16_t ca_tag; // never 0; a new one whenever the CA changes diff --git a/software/io/network/network_target_tls.cc b/software/io/network/network_target_tls.cc index c9eb088dd..7784db579 100644 --- a/software/io/network/network_target_tls.cc +++ b/software/io/network/network_target_tls.cc @@ -1549,6 +1549,7 @@ void NetworkTarget :: tls_init(void) memset(tls, 0, sizeof(tls)); tls_last_tag = 0; tls_generation_known = false; + tls_quick_seen = false; tls_generation = 0; ca_state = CA_EMPTY; ca_tag = 0; @@ -1570,13 +1571,18 @@ void NetworkTarget :: tls_before_command(Message *command) bool keeps_claims = (code == NET_CMD_TLS_RELEASE) || ((code == NET_CMD_TLS_INFO) && (command->length == 3) && (command->message[2] == 0xFF)); tls_check_generation(); - if (!keeps_claims) { + // A socket-free command, or a queued one that was aborted before it started, set this on the other task. + portENTER_CRITICAL(); + bool other_task = tls_quick_seen; + tls_quick_seen = false; + portEXIT_CRITICAL(); + if (!keeps_claims || other_task) { for (int i = 0; i < NET_MAX_TLS; i++) { tls[i].claimed = true; } } // A CA upload takes no other network command in between. - if ((code != NET_CMD_TLS_TRUST_CA) && (ca_state == CA_UPLOADING)) { + if (((code != NET_CMD_TLS_TRUST_CA) || other_task) && (ca_state == CA_UPLOADING)) { ca_state = CA_EMPTY; } } diff --git a/software/test/wifi_tls/net_tls_test.cc b/software/test/wifi_tls/net_tls_test.cc index 77075dd02..d0c30c4fa 100644 --- a/software/test/wifi_tls/net_tls_test.cc +++ b/software/test/wifi_tls/net_tls_test.cc @@ -1343,6 +1343,29 @@ static bool loaded(void) return (r.data.size() == 16) && (r.data[4] & 0x08); } +// --- socket-free commands are commands too ------------------------------------------------ + +// IDENTIFY and its kin answer on the UCI Server task, apart from the worker that owns the TLS state. They must +// still count as "the next command" for the two rules that depend on one arriving. +static void test_quick_commands(void) +{ + printf("Socket-free commands (UCI Server task) and the TLS rules about a next command\n"); + fresh(); + int a = open_ok(); + run(B({ 0x03, 0x01 })); // IDENTIFY + check(release().data == B({ 0 }) && sock(a).open, "quick: IDENTIFY claims the session, so $25 frees nothing"); + fresh(); + a = open_ok(); + check(release().data == B({ 1 }) && !sock(a).open, "quick: with no command in between, $25 frees the unclaimed session"); + + fresh(); + world_module.set_ca_result = 0; + chunk(0, 100, bytes(50, 1)); + run(B({ 0x03, 0x01 })); + check(chunk(50, 100, bytes(50, 1)).status == "81,INVALID PARAMS" && world_count(0x35) == 0, + "quick: IDENTIFY between CA chunks ends the upload"); +} + static void test_ca(void) { printf("TRUST_CA ($22): the Nios's CA state\n"); @@ -1756,6 +1779,7 @@ int main(int argc, char **argv) test_latch(); test_claims(); test_ca(); + test_quick_commands(); test_cleanup(); test_status_lengths(); test_empty_read_reply(); From 3e878a45d8c61c0c5e63469d742476e3ec053df5 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 12 Nov 2026 15:05:30 -0600 Subject: [PATCH 63/95] Stop the TLS waits for a C64 reset and for an abort, as the worker sees them The TLS waits asked the command interface whether a reset was pending. The UCI Server task (priority 2) clears that flag at once, long before the worker (priority 1) looks, so a C64 reset no longer stopped an OPEN_TLS or START_TLS handshake: it ran on for up to 40 s. An abort never stopped one either, because the waits knew nothing of the job's cancel flag. The waits now stop when the reset count the worker has not yet acted on differs (resets != resets_closed), or when the running job's abort flag is set; that covers DNS, connect, the OPEN and step RPCs, the handshake, the CA retry and the READ and WRITE waits, each within a slice (100 ms). Cleanup stays reset-only, so an aborted OPEN still sends the module its CLOSE. The host test world now behaves like the device: reset_pending() is never true, and a reset or an abort reaches the worker only through c64_reset() and the cancel flag, at a tick the test chooses. The new tests (abort in the handshake, DNS, connect, the OPEN RPC and START_TLS; reset in START_TLS) and the reworked reset test failed before this change. Co-Authored-By: Claude Sonnet 5.5 --- software/io/network/network_target.h | 5 ++ software/io/network/network_target_tls.cc | 36 ++++++++---- software/test/wifi_tls/net_tls_test.cc | 70 ++++++++++++++++++++++- software/test/wifi_tls/net_world.cc | 35 +++++++++++- software/test/wifi_tls/net_world.h | 5 +- 5 files changed, 136 insertions(+), 15 deletions(-) diff --git a/software/io/network/network_target.h b/software/io/network/network_target.h index c3a12bb14..c8d4ff899 100644 --- a/software/io/network/network_target.h +++ b/software/io/network/network_target.h @@ -260,6 +260,11 @@ class NetworkTarget : public CommandTarget { void get_more_data(Message **reply, Message **status); void abort(int a); void c64_reset(void); + + // For the TLS waits, which run on the worker: a C64 reset the UCI Server task has noted but the worker has not + // yet acted on, and an abort of the command that runs. + bool reset_noted(void) { return resets != resets_closed; } + bool job_aborted(void) { return cancel && *cancel; } }; #endif /* IO_NETWORK_NETWORK_TARGET_H_ */ diff --git a/software/io/network/network_target_tls.cc b/software/io/network/network_target_tls.cc index 7784db579..b08734e2f 100644 --- a/software/io/network/network_target_tls.cc +++ b/software/io/network/network_target_tls.cc @@ -245,27 +245,38 @@ static uint32_t earlier(uint32_t a, uint32_t b) return ((int32_t)(a - b) <= 0) ? a : b; } -// The cancel predicate of the module calls: a C64 reset always, and a -// deadline for the waits that have one. Cleanup calls pass no deadline. +// The waits stop for a C64 reset and for an abort of the command that runs. Both are noted by the UCI Server +// task for the worker: the command interface's own reset flag is cleared there at once, long before the worker +// looks, so it cannot be used. Cleanup (the CLOSE of a session that the command opened) stops for a reset only, +// so that an aborted OPEN still tells the module to free its session. +static NetworkTarget *tls_owner; + +// The cancel predicate of the module calls: the above, and a deadline for the waits that have one. typedef struct { bool use_deadline; uint32_t deadline; + bool cleanup; } tls_cancel_context_t; +static bool reset_only(void) +{ + return tls_owner->reset_noted(); +} + +static bool reset_now(void) +{ + return tls_owner->reset_noted() || tls_owner->job_aborted(); +} + static bool tls_cancelled(void *context) { tls_cancel_context_t *c = (tls_cancel_context_t *)context; - if (cmd_if.reset_pending()) { + if (c->cleanup ? reset_only() : reset_now()) { return true; } return c->use_deadline && reached(c->deadline); } -static bool reset_now(void) -{ - return cmd_if.reset_pending(); -} - TlsSocket *NetworkTarget :: tls_find(int socketnr) { for (int i = 0; i < NET_MAX_TLS; i++) { @@ -385,10 +396,10 @@ void NetworkTarget :: tls_fail_step(TlsSocket *e, int esp_err, uint8_t alert_in) // freed it all the same. void NetworkTarget :: tls_cleanup_close(TlsSocket *e) { - if (!e->module_live || reset_now()) { + if (!e->module_live || reset_only()) { return; } - tls_cancel_context_t context = { false, 0 }; + tls_cancel_context_t context = { false, 0, true }; wifi_tls_cancel_t cancel = { tls_cancelled, &context }; uint16_t notify_len; int esp_err; @@ -403,8 +414,8 @@ void NetworkTarget :: tls_cleanup_close(TlsSocket *e) // close_notify best effort, the socket, the entry. void NetworkTarget :: tls_close_entry(TlsSocket *e, bool send_notify) { - if (e->module_live && !reset_now()) { - tls_cancel_context_t context = { false, 0 }; + if (e->module_live && !reset_only()) { + tls_cancel_context_t context = { false, 0, true }; wifi_tls_cancel_t cancel = { tls_cancelled, &context }; uint16_t notify_len = 0; int esp_err; @@ -1548,6 +1559,7 @@ void NetworkTarget :: tls_init(void) { memset(tls, 0, sizeof(tls)); tls_last_tag = 0; + tls_owner = this; tls_generation_known = false; tls_quick_seen = false; tls_generation = 0; diff --git a/software/test/wifi_tls/net_tls_test.cc b/software/test/wifi_tls/net_tls_test.cc index d0c30c4fa..d6e098a57 100644 --- a/software/test/wifi_tls/net_tls_test.cc +++ b/software/test/wifi_tls/net_tls_test.cc @@ -735,7 +735,6 @@ static void test_reset_during_open(void) uint32_t late = (world_tick - world_reset_at) * 5; check(late <= 110, "reset: the OPEN returns within a slice of the reset (%u ms late)", late); check(world_open_sockets() == 0 && world_count(0x32) == 0, "reset: socket closed, no CLOSE RPC waited for"); - reset_c64(); world_reset_at = 0xFFFFFFFF; check(world_module.close_alls == 1, "reset: c64_reset sends CLOSE_ALL once"); r = info(0xFF); @@ -775,6 +774,71 @@ static void expect_kept(int h, const bytes &cmd, const char *want, const char *w want, r.status.c_str()); } +// --- an abort during OPEN, START_TLS and the CA upload --------------------------------------- + +// The job's cancel flag is set by the UCI Server task on an abort. The worker has to be free within a slice, +// and what the aborted command opened on the module is still closed. +static void test_abort_during_open(void) +{ + printf("OPEN_TLS, START_TLS: an abort frees the worker at once, and the module is told to CLOSE\n"); + fresh(); + sock(0).srv.on_hello = SRV_STALL; + world_abort_at = world_tick + 600; // in the handshake + Res r = run(open_cmd(0, 0, "example.com")); + uint32_t late = (world_tick - world_abort_at) * 5; + check(late <= 110, "abort: a stalled handshake returns within a slice of the abort (%u ms late)", late); + check(world_open_sockets() == 0 && world_count(0x32) == 1, "abort: socket closed, the module's session CLOSEd"); + world_abort_at = 0xFFFFFFFF; + check(run(B({ 0x03, 0x23, 0xFF })).status == "00,OK", "abort: the next socket command runs"); + + fresh(); + world_dns.push_back({ "never.example", DNS_NEVER, 0, 0 }); + world_abort_at = world_tick + 200; + r = run(open_cmd(0, 0, "never.example")); + late = (world_tick - world_abort_at) * 5; + check(late <= 110 && world_open_sockets() == 0, "abort: during DNS too (%u ms late)", late); + world_abort_at = 0xFFFFFFFF; + + fresh(); + sock(0).srv.connect_never = true; + world_abort_at = world_tick + 200; + r = run(open_cmd(0, 0, "example.com")); + late = (world_tick - world_abort_at) * 5; + check(late <= 110 && world_open_sockets() == 0, "abort: during connect too (%u ms late)", late); + world_abort_at = 0xFFFFFFFF; + + fresh(); + world_module.open_delay_ms = 4000; + world_abort_at = world_tick + 200; + r = run(open_cmd(0, 0, "example.com")); + late = (world_tick - world_abort_at) * 5; + check(late <= 110, "abort: during the OPEN RPC too (%u ms late)", late); + world_abort_at = 0xFFFFFFFF; + + fresh(); + int t = open_tcp(); + sock(t).srv.on_hello = SRV_STALL; + world_abort_at = world_tick + 600; + r = run(start_cmd(t, 0, 0, "mail.example")); + late = (world_tick - world_abort_at) * 5; + check(late <= 110, "abort: START_TLS's stalled handshake too (%u ms late)", late); + world_abort_at = 0xFFFFFFFF; +} + +// A reset reaches the worker as a count, not as the command interface's flag. +static void test_reset_during_start(void) +{ + printf("START_TLS: a reset ends the handshake at once\n"); + fresh(); + int t = open_tcp(); + sock(t).srv.on_hello = SRV_STALL; + world_reset_at = world_tick + 600; + Res r = run(start_cmd(t, 0, 0, "mail.example")); + uint32_t late = (world_tick - world_reset_at) * 5; + check(late <= 110, "reset: a stalled START_TLS returns within a slice of the reset (%u ms late)", late); + world_reset_at = 0xFFFFFFFF; +} + static void test_start_tls(void) { printf("START_TLS ($24): handle checks first, kept codes, success\n"); @@ -1765,6 +1829,8 @@ static void test_late_send_failures(void) int main(int argc, char **argv) { setvbuf(stdout, NULL, _IOLBF, 0); + world_reset_hook = [] { net.c64_reset(); }; + world_abort_hook = [] { if (net.cancel) { *net.cancel = true; } }; test_info(); test_open(); test_grammar(); @@ -1773,6 +1839,8 @@ int main(int argc, char **argv) test_dns_connect(); test_reset_during_open(); test_start_tls(); + test_abort_during_open(); + test_reset_during_start(); test_read(); test_write(); test_close(); diff --git a/software/test/wifi_tls/net_world.cc b/software/test/wifi_tls/net_world.cc index 99da2eb0f..50733c53b 100644 --- a/software/test/wifi_tls/net_world.cc +++ b/software/test/wifi_tls/net_world.cc @@ -17,6 +17,11 @@ uint32_t world_tick; uint32_t world_reset_at; +uint32_t world_abort_at = 0xFFFFFFFF; +void (*world_reset_hook)(void); +void (*world_abort_hook)(void); +static uint32_t reset_fired_for = 0xFFFFFFFF; +static uint32_t abort_fired_for = 0xFFFFFFFF; FakeSock world_socks[16]; std::vector world_dns; int world_dns_calls; @@ -71,6 +76,30 @@ void world_advance(uint32_t ticks) { world_tick += ticks; fire_dns(false); + // What the UCI Server task does while the worker waits: it sees the reset or the abort in the next + // tick and notes it for the worker (c64_reset(), the job's cancel flag). + if ((world_reset_at == 0xFFFFFFFF) || (world_abort_at == 0xFFFFFFFF)) { + if (world_reset_at == 0xFFFFFFFF) { + reset_fired_for = 0xFFFFFFFF; + } + if (world_abort_at == 0xFFFFFFFF) { + abort_fired_for = 0xFFFFFFFF; + } + } + if ((world_reset_at != 0xFFFFFFFF) && (reset_fired_for != world_reset_at) && + ((int32_t)(world_tick - world_reset_at) >= 0)) { + reset_fired_for = world_reset_at; + if (world_reset_hook) { + world_reset_hook(); + } + } + if ((world_abort_at != 0xFFFFFFFF) && (abort_fired_for != world_abort_at) && + ((int32_t)(world_tick - world_abort_at) >= 0)) { + abort_fired_for = world_abort_at; + if (world_abort_hook) { + world_abort_hook(); + } + } } uint32_t world_ms(void) @@ -112,6 +141,8 @@ void world_reset(void) { world_tick = 1000; world_reset_at = 0xFFFFFFFF; + world_abort_at = 0xFFFFFFFF; + reset_fired_for = abort_fired_for = 0xFFFFFFFF; for (int i = 0; i < 16; i++) { world_socks[i] = FakeSock(); world_socks[i].srv.saw_alert = -1; @@ -189,9 +220,11 @@ void vTaskDelay(TickType_t ticks) world_advance(ticks ? ticks : 1); } +// The UCI Server task clears this at once (command_intf.cc), long before the worker looks, so it is +// never true here: the reset reaches the worker through c64_reset() and its count. bool CommandInterface :: reset_pending(void) { - return (world_reset_at != 0xFFFFFFFF) && ((int32_t)(world_tick - world_reset_at) >= 0); + return false; } uint32_t sntp_utc_now(void) diff --git a/software/test/wifi_tls/net_world.h b/software/test/wifi_tls/net_world.h index af7ae05dd..e12c819bc 100644 --- a/software/test/wifi_tls/net_world.h +++ b/software/test/wifi_tls/net_world.h @@ -16,7 +16,10 @@ typedef std::vector bytes; extern uint32_t world_tick; void world_advance(uint32_t ticks); uint32_t world_ms(void); // world_tick in ms -extern uint32_t world_reset_at; // reset_pending() from this tick on; ~0 for never +extern uint32_t world_reset_at; // the UCI Server task notes a C64 reset at this tick (world_reset_hook); ~0 for never +extern uint32_t world_abort_at; // ... and an abort of the running command (world_abort_hook); ~0 for never +extern void (*world_reset_hook)(void); +extern void (*world_abort_hook)(void); extern uint32_t world_sntp; // what sntp_utc_now() answers // A record of the pretend TLS. From 3c98cfa755e8b5f43e1b5b276d98eb18a9039609 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 12 Nov 2026 18:13:38 -0600 Subject: [PATCH 64/95] Test a C64 reset during a WRITE that has stalled On the native route, a peer that reads nothing fills the socket until a WRITE stays unanswered. A C64 reset then has to let go of it: IDENTIFY is answered, the next socket command (OPEN_UDP, CLOSE_SOCKET) runs within three seconds, and the socket of the stalled WRITE is closed. The REST route cannot fill a socket in reasonable time, and the abort of a stalled WRITE is covered by the host test. Co-Authored-By: Claude Sonnet 5.5 --- .../io/command_interface/net_target_test.py | 98 ++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-) diff --git a/tests/e2e/io/command_interface/net_target_test.py b/tests/e2e/io/command_interface/net_target_test.py index 18e9ce6fb..001b0d622 100644 --- a/tests/e2e/io/command_interface/net_target_test.py +++ b/tests/e2e/io/command_interface/net_target_test.py @@ -84,8 +84,7 @@ FAIL, Failure, OK, SKIP, check, check_fail, check_ok, check_skip, check_start, detail, format_exception, section, suite_fail, suite_ok, warn) from uci import ( # noqa: E402 - MAX_BLOCK_BYTES, REPLY_QUEUE_BYTES, TARGET_NETWORK, Uci, Wedged, - interface_present) + MAX_BLOCK_BYTES, REPLY_QUEUE_BYTES, TARGET_NETWORK, Uci, Wedged, interface_present) from uci_native import NativeUci # noqa: E402 CONFIG_CATEGORY = "C64 and Cartridge Settings" @@ -277,6 +276,7 @@ "get-random-refusals", "get-random-leaves-sockets-alone", "get-random-radio-off", + "stalled-write-reset-and-abort", "reset-closes-uci-sockets", ] # The scenarios that need no network peer, because they open no socket. @@ -1839,6 +1839,92 @@ def run_reset_closes_uci_sockets(net: Net, peer: Peer, reset, device) -> bool: return True +# How long a WRITE has to stay unanswered to count as stalled, and how long the target may take to be +# useful again after the C64 reset that ends it. The send waits in slices (a few hundred milliseconds on +# lwIP), so a worker that sees the reset is free well inside the bound. +STALL_SECONDS = 2.0 +FREE_WITHIN_SECONDS = 3.0 +STALL_FILL_LIMIT = 4096 # WRITEs of 888 bytes, far more than the two buffers hold + + +def stall_a_write(net: Net, handle: int) -> int: + """WRITE until one is still unanswered after STALL_SECONDS because the peer reads nothing. + + The agent keeps waiting in that WRITE; only a reset ends it. Returns how many WRITEs completed first. + """ + uci = net.uci + patient = uci.busy_timeout + uci.busy_timeout = STALL_SECONDS + try: + for done in range(STALL_FILL_LIMIT): + try: + result = net.write(handle, bytes(888)) + except Failure as exc: + if "did not finish" in str(exc): + return done + raise + if result.status_text != STATUS_OK: + raise Failure(f"WRITE #{done + 1} answered {result.status_text!r}") + finally: + uci.busy_timeout = patient + raise Failure(f"{STALL_FILL_LIMIT} WRITEs of 888 bytes all completed: the peer's buffers never filled") + + +def run_stalled_write_reset(net: Net, peer: Peer, reset) -> bool: + """A C64 reset during a WRITE that has stalled on a peer that reads nothing (native route). + + The target must let go of the stalled WRITE: IDENTIFY is answered, the next socket command + (OPEN_UDP + CLOSE_SOCKET) runs within FREE_WITHIN_SECONDS, and the stalled socket is closed. The times are + printed. `reset` resets the C64 and returns a Net that reaches the target afterwards. The abort of a + stalled WRITE is covered by the host test; the REST route cannot fill a socket in reasonable time. + """ + section("stalled-write-reset-and-abort") + conn = None + handle = None + try: + with check("a WRITE to a peer that reads nothing stalls"): + handle = net.open_tcp(peer.ip, peer.tcp_port) + conn = peer.accept_tcp() + conn.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 2048) + completed = stall_a_write(net, handle) + detail(f"{completed} WRITEs completed, the next one has been unanswered for {STALL_SECONDS:.0f} s") + with check("reset the C64 with the WRITE stalled"): + net = reset() + with check("IDENTIFY is answered"): + started = time.time() + identity = net.identify() + if identity.status_text != STATUS_OK: + raise Failure(f"IDENTIFY answered {identity.status_text!r}") + detail(f"{time.time() - started:.2f} s") + with check(f"the next socket command is answered within {FREE_WITHIN_SECONDS:.0f} s"): + took = next_socket_command(net, peer) + detail(f"OPEN_UDP + CLOSE_SOCKET {took:.2f} s") + if took > FREE_WITHIN_SECONDS: + raise Failure(f"took {took:.2f} s: the worker was still held by the stalled WRITE") + with check("the reset closed the socket of the stalled WRITE"): + result = net.close(handle) + if result.status_text == STATUS_OK: + raise Failure("the socket was still open after the reset") + handle = None + finally: + if conn is not None: + try: + conn.close() + except OSError: + pass + return True + + +def next_socket_command(net: Net, peer: Peer) -> float: + """Seconds for an OPEN_UDP and its CLOSE: socket commands run on the worker, IDENTIFY does not.""" + started = time.time() + handle = net.open_udp(peer.ip, peer.udp_port) + result = net.close(handle) + if result.status_text != STATUS_OK: + raise Failure(f"CLOSE_SOCKET answered {result.status_text!r}") + return time.time() - started + + def free_heap(device) -> int | None: """Free FreeRTOS heap, for the record; lwip's pools are static and do not show here.""" try: @@ -2068,6 +2154,14 @@ def reset_and_reopen(route=route): native_started = True return Net(build_driver(route, computer, args.busy_timeout)) return Net(rest_uci) + if route == "native": + def reset_into_net(): + nonlocal net, native_started + computer.machine.reset(force=True) + native_started = True + net = Net(build_driver(route, computer, args.busy_timeout)) + return net + run(route, "stalled-write-reset-and-abort", run_stalled_write_reset, net, peer, reset_into_net) # Last on purpose: on the native route the reset inside it ends # the 6502 agent that `net` wraps, so nothing can follow it here. run(route, "reset-closes-uci-sockets", From 7d15151d1b6e35b3c2869e1ee0475246401c708e Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Thu, 12 Nov 2026 18:13:39 -0600 Subject: [PATCH 65/95] An ABORT cancels an OPEN_TLS or START_TLS in flight: update the doc and S19e, S19e2b The TLS waits now stop on an abort within a slice, and the session the command had begun on the module is closed. The documentation said an ABORT never closes or frees a session, and the two scenarios expected the aborted OPEN to run on and leave an unclaimed session. S19e now expects the ABORTed OPEN to end about a slice after the ABORT, and INFO and $25 to find nothing left; S19e2b expects the aborted OPEN to leave no entry next to the first session. Co-Authored-By: Claude Sonnet 5.5 --- doc/uci_tls.md | 7 ++- .../e2e/io/command_interface/net_tls_test.py | 44 ++++++++----------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/doc/uci_tls.md b/doc/uci_tls.md index 338344ad0..09f51e112 100644 --- a/doc/uci_tls.md +++ b/doc/uci_tls.md @@ -157,11 +157,14 @@ after an `$21` whose reply the program did not read, so that a session the aband ## Sessions after an ABORT -An ABORT never closes or frees a session. Every network target command except `$25` and `$23 $FF` (exactly 3 bytes) +An ABORT cancels an `$21` or `$24` that is still in flight: the wait ends within about 100 ms and the session the +command had begun on the module is closed, so nothing is left behind and `$25` afterwards is harmless and answers 0. +An ABORT that arrives after the session was made does not close or free it. Every network target command except `$25` and `$23 $FF` (exactly 3 bytes) marks all open entries as claimed, so only the entry the most recent `$21`/`$24` created can be unclaimed, and only until the next command. -- After an ABORTed `$21`: treat any handle from it as gone and send `$25` next. `$23 $FF` is allowed in between. +- After an ABORTed `$21`: treat any handle from it as gone and send `$25` next (it answers 0 if the abort cancelled the + open, 1 if the session had been made already). `$23 $FF` is allowed in between. - After an ABORTed `$24`: send CLOSE on the handle. It answers `12,ERROR ON CLOSE: 9` if the handle was already gone, which is harmless if nothing was opened in between. - After an ABORT during a READ, or before all of a READ reply was read, plaintext is lost from the stream without an diff --git a/tests/e2e/io/command_interface/net_tls_test.py b/tests/e2e/io/command_interface/net_tls_test.py index c1bc18bc3..bfa33bae8 100644 --- a/tests/e2e/io/command_interface/net_tls_test.py +++ b/tests/e2e/io/command_interface/net_tls_test.py @@ -17,7 +17,7 @@ S23 hardened TLS 1.2 fallback (EMS bit, one of the six suites) S5 a refused certificate: exactly `93,CERTIFICATE NOT TRUSTED: 0x00000008`, and `96` for a wrong pin - S19e an ABORTed OPEN, then $25 (client deadlines; REST route only) + S19e an ABORTed OPEN is cancelled and leaves nothing, then $25 (REST route only) S30 BUNDLE to real hosts (internet_hosts.json) with an HTTP GET Tier 2 is the other scenarios this machine can drive (see --list). Oracles come from the server side (net_tls_fixture.py logs), never from the device's claim. @@ -101,6 +101,7 @@ READ_BUDGET_SECONDS = 20.0 SLOW_HANDSHAKE_SECONDS = 4.0 ABORT_AFTER_SECONDS = 1.5 +ABORT_ENDS_WITHIN = 1.5 # seconds after the ABORT, for a cancelled OPEN_TLS (a slice is 100 ms; REST polling adds some) HANDSHAKE_MS = 15.0 HTTP_READ_BUDGET_SECONDS = 15.0 RESAMPLE_AFTER_SECONDS = 30.0 @@ -557,39 +558,32 @@ def s19e_abort_release(ctx: Ctx) -> None: ctx.entries(0, "before the OPEN") server = ctx.server("ecdsa", fx.Behaviour(delay_handshake=SLOW_HANDSHAKE_SECONDS)) command = open_tls_command(server.port, ctx.bind_ip, TRUST_PIN, pin=pin_of(ctx)) - with check(f"ABORT {ABORT_AFTER_SECONDS}s into an OPEN_TLS: bit 2 clears only when the " - "command ends (ABORT never shortens it), within the client deadline"): + with check(f"ABORT {ABORT_AFTER_SECONDS}s into an OPEN_TLS: the command ends within about a slice, " + "long before the server's delay"): aborted = ctx.link.abort_in_flight(command, ABORT_AFTER_SECONDS) ctx.note("abort", {"busy_at_abort": aborted.busy_at_abort, "bit2_cleared_after": round(aborted.bit2_cleared_after, 2)}) if not aborted.busy_at_abort: raise Failure("the OPEN had already answered when the ABORT was written, so this " "run did not test an ABORT in PROCESSING") - if aborted.bit2_cleared_after > BOUND_OPEN + 12: - raise Failure(f"bit 2 cleared {aborted.bit2_cleared_after:.1f}s after the PUSH") - # The server holds its answer SLOW_HANDSHAKE_SECONDS, so an OPEN that - # ran to its end cannot clear bit 2 sooner. - if aborted.bit2_cleared_after < SLOW_HANDSHAKE_SECONDS - 0.5: - raise Failure(f"bit 2 cleared {aborted.bit2_cleared_after:.1f}s after the PUSH, before " - f"the server's {SLOW_HANDSHAKE_SECONDS:.0f}s delay: the ABORT shortened it") - with check("`03 23 FF` (allowed in between): [2] = 1 and [14] = 1, the session is unclaimed"): + # The server holds its answer SLOW_HANDSHAKE_SECONDS; an OPEN that was cancelled ends about a + # slice (100 ms) after the ABORT, plus what the register polling over REST adds. + if aborted.bit2_cleared_after > ABORT_AFTER_SECONDS + ABORT_ENDS_WITHIN: + raise Failure(f"bit 2 cleared {aborted.bit2_cleared_after:.1f}s after the PUSH, " + f"{aborted.bit2_cleared_after - ABORT_AFTER_SECONDS:.1f}s after the ABORT") + with check("`03 23 FF` (allowed in between): [2] = 0 and [14] = 0, the cancelled open left nothing"): cap = ctx.info_ff() - if (cap.entries, cap.unclaimed) != (1, 1): + if (cap.entries, cap.unclaimed) != (0, 0): raise Failure(f"[2] = {cap.entries}, [14] = {cap.unclaimed}") - with check("`03 25` as the next command closes it: 1 byte, 01, 00,OK"): - if (closed := ctx.release()) != 1: + with check("`03 25` as the next command closes nothing: 1 byte, 00, 00,OK (harmless after an abort)"): + if (closed := ctx.release()) != 0: raise Failure(f"$25 closed {closed}") - with check("a second `03 25` answers 0 (idempotent); INFO $FF [2] = 0, [14] = 0"): + with check("a second `03 25` answers 0; INFO $FF [2] = 0, [14] = 0"): if (closed := ctx.release()) != 0: raise Failure(f"$25 closed {closed} the second time") cap = ctx.info_ff() if cap.entries or cap.unclaimed: raise Failure(f"[2] = {cap.entries}, [14] = {cap.unclaimed}") - with check("the server saw the handshake complete, then close_notify + FIN from the device"): - log = one_connection(server, timeout=20) - ctx.note("conn", log.as_dict()) - if log.version != "TLSv1.3" or log.peer_end != "close_notify": - raise Failure(f"server: {log.version}, ended by {log.peer_end}") # -- S30: real hosts ----------------------------------------------------------- @@ -968,13 +962,13 @@ def s19e2b_info_does_not_claim(ctx: Ctx) -> None: slow = ctx.server("ecdsa", fx.Behaviour(delay_handshake=SLOW_HANDSHAKE_SECONDS)) a = ctx.expect_open(fast.port, ctx.bind_ip, pin=pin_of(ctx)).handle try: - with check("OPEN A, accept it, unused; ABORTed OPEN B; `03 23 FF` [14] = 1; $25 -> 1"): + with check("OPEN A, accept it, unused; ABORTed OPEN B leaves nothing: `03 23 FF` [2] = 1, [14] = 0; $25 -> 0"): ctx.link.abort_in_flight(open_tls_command(slow.port, ctx.bind_ip, TRUST_PIN, pin=pin_of(ctx)), ABORT_AFTER_SECONDS) cap = ctx.info_ff() - if (cap.entries, cap.unclaimed) != (2, 1): + if (cap.entries, cap.unclaimed) != (1, 0): raise Failure(f"[2] = {cap.entries}, [14] = {cap.unclaimed}") - if (closed := ctx.release()) != 1: + if (closed := ctx.release()) != 0: raise Failure(f"$25 closed {closed}") with check("A still echoes"): echo_round_trip(ctx, a, 64, seed=193) @@ -1094,7 +1088,7 @@ def s33_open_tcp_duration(ctx: Ctx) -> None: s23_tls12, ("fixture",)), Scenario("S5", "refused-cert", 1, "tls", "exactly 93 0x00000008; 96 for a wrong pin", s5_refused_cert, ("fixture",)), - Scenario("S19e", "abort-then-release", 1, "tls", "ABORTed OPEN: [14] = 1, $25 -> 1, then 0", + Scenario("S19e", "abort-then-release", 1, "tls", "ABORTed OPEN is cancelled within a slice: [2] = 0, [14] = 0, $25 -> 0", s19e_abort_release, ("fixture",)), Scenario("S30", "bundle-real-hosts", 1, "tls", "BUNDLE to H1-H3, SPKI as seen here, HTTP/1.", s30_real_hosts, ("internet", "crypto")), @@ -1118,7 +1112,7 @@ def s33_open_tcp_duration(ctx: Ctx) -> None: s19_params, ("fixture",)), Scenario("S19e2", "release-spares-claimed", 2, "tls", "$25 -> 1; A echoes; B -> 02: 9", s19e2_release_spares_claimed, ("fixture",)), - Scenario("S19e2b", "info-ff-does-not-claim", 2, "tls", "[14] = 1 after 03 23 FF; $25 -> 1", + Scenario("S19e2b", "info-ff-does-not-claim", 2, "tls", "an ABORTed OPEN leaves no entry: [2] = 1 (A), [14] = 0 after 03 23 FF; $25 -> 0", s19e2b_info_does_not_claim, ("fixture",)), Scenario("S22", "group-negotiation", 2, "tls", "0x001D default; 0x0017 via HRR", s22_groups, ("fixture",)), From 02dc1a2b0228b069220b8e9e2fdfe4c693b683dd Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 13 Nov 2026 11:30:43 -0600 Subject: [PATCH 66/95] wifitls host test: UNSENT paths, free inside the suspended section, a past-generation answer The world gains frees counted outside the suspended section and a way to tag the next queued answer with a pre-reset generation. New checks drive a failed GetBuffer and a failed TransmitPacket through the TLS calls (UNSENT) and GET_RANDOM (BUSY), and assert the free of taken and skipped answers happens with the scheduler suspended and that a past-generation answer is dropped unread and not freed. Co-Authored-By: Claude Opus 5.5 --- software/test/wifi_tls/wifi_tls_test.cc | 57 +++++++++++++++++++++++++ software/test/wifi_tls/world.cc | 14 ++++++ software/test/wifi_tls/world.h | 3 ++ 3 files changed, 74 insertions(+) diff --git a/software/test/wifi_tls/wifi_tls_test.cc b/software/test/wifi_tls/wifi_tls_test.cc index e1c8a8501..1f46e869c 100644 --- a/software/test/wifi_tls/wifi_tls_test.cc +++ b/software/test/wifi_tls/wifi_tls_test.cc @@ -7,6 +7,7 @@ #include "world.h" #include "wifi_dedicated.h" #include "wifi_tls.h" +#include "wifi_random.h" #include "rpc_calls.h" #include "check.h" #undef printf @@ -693,6 +694,62 @@ static void test_calls(void) dedicated_waiting = true; r = wifi_tls_stats(0, 1, &stats, &esp_err, 1000, NULL); check((r == WIFI_TLS_UNSENT) && dedicated_waiting, "another request outstanding: UNSENT at once"); + // Nothing sent: a failed GetBuffer or TransmitPacket is UNSENT for the TLS calls and BUSY for GET_RANDOM. + uint8_t random_bytes[16]; + world_reset(19, tls_maker, true); + world_no_buffer = true; + r = wifi_tls_stats(0, 1, &stats, &esp_err, 1000, NULL); + check((r == WIFI_TLS_UNSENT) && (world_transmits == 0) && !dedicated_waiting && (world_queued() == 0), + "no buffer: UNSENT (%d), nothing sent, the channel free again", r); + world_reset(19, tls_maker, true); + world_no_buffer = true; + r = wifi_get_random(random_bytes, sizeof(random_bytes)); + check((r == WIFI_RANDOM_BUSY) && (world_transmits == 0) && !dedicated_waiting, + "GET_RANDOM, no buffer: BUSY, not UNSENT (%d)", r); + world_reset(21, tls_maker, true); + world_no_transmit = true; + r = wifi_tls_stats(0, 1, &stats, &esp_err, 1000, NULL); + check((r == WIFI_TLS_UNSENT) && (world_transmits == 0) && !dedicated_waiting && (world_queued() == 0) && + (world_trace.find("print: TLS Stats: no reply.") != std::string::npos), + "a failed transmit: UNSENT, not BUSY (%d): the module never saw the request", r); + world_reset(21, tls_maker, true); + world_no_transmit = true; + r = wifi_get_random(random_bytes, sizeof(random_bytes)); + check((r == WIFI_RANDOM_BUSY) && (world_transmits == 0) && !dedicated_waiting, + "GET_RANDOM, a failed transmit: BUSY, not UNSENT (%d)", r); + world_reset(22, tls_maker, true); + dedicated_waiting = true; + r = wifi_get_random(random_bytes, sizeof(random_bytes)); + check((r == WIFI_RANDOM_BUSY) && dedicated_waiting, "GET_RANDOM, channel taken: BUSY, not UNSENT (%d)", r); + + // The buffer of a taken answer is freed with the scheduler suspended, so that no reset gets in between. + world_reset(23, tls_maker, true); + r = wifi_tls_stats(0, 1, &stats, &esp_err, 1000, NULL); + check((r == 0) && (world_frees == 1) && (world_free_unsuspended == 0) && (world_suspended == 0), + "a taken answer is freed inside the suspended section (%d frees, %d outside)", world_frees, + world_free_unsuspended); + // So is one that is dropped unread after the call gave up. + world_reset(24, late_maker, true); + cancel_calls = 0; + cancel_after = 1; + fresh_step(&st, 1024); + r = wifi_tls_step(0, 1, &st, 5000, &soon); + check((r == WIFI_TLS_BUSY) && (world_frees >= 1) && (world_free_unsuspended == 0) && (world_suspended == 0), + "a skipped answer is freed inside the suspended section (%d frees, %d outside)", world_frees, + world_free_unsuspended); + + // An answer queued before the last buffer pool reset is dropped unread and its buffer not freed. + world_reset(25, tls_maker, true); + world_stale_next = true; + memset(&stats, 0, sizeof(stats)); + r = wifi_tls_stats(0, 1, &stats, &esp_err, 100, NULL); + check((r == WIFI_TLS_BUSY) && (world_isr_calls == 1) && (world_frees == 0) && (stats.heap_free == 0) && + !dedicated_waiting && (world_queued() == 0), + "a right-looking answer of a past generation is not taken and not freed: BUSY (%d)", r); + world_reset(26, tls_maker, true); + world_stale_next = true; + r = wifi_get_random(random_bytes, sizeof(random_bytes)); + check((r == WIFI_RANDOM_BUSY) && (world_frees == 0), "GET_RANDOM: a past generation's answer is dropped (%d)", r); } int main(void) diff --git a/software/test/wifi_tls/world.cc b/software/test/wifi_tls/world.cc index e459fb125..366133b91 100644 --- a/software/test/wifi_tls/world.cc +++ b/software/test/wifi_tls/world.cc @@ -19,6 +19,9 @@ std::string world_trace; int world_suspended; int world_transmits; int world_isr_calls; +int world_frees; +int world_free_unsuspended; +bool world_stale_next; #define QUEUE_DEPTH 4 // as wifi_cmd.cc creates it #define RX_BUFFERS 16 @@ -73,6 +76,9 @@ void world_reset(uint32_t seed, world_maker_t maker, bool quiet) world_suspended = 0; world_transmits = 0; world_isr_calls = 0; + world_frees = 0; + world_free_unsuspended = 0; + world_stale_next = false; rx_next = 0; last_tx_size = -1; // Now and then start just short of the tick counter wrapping. @@ -102,6 +108,10 @@ static void isr_deliver(void) if (!calm && (world_rand(10) == 0)) { generation--; // tagged before a reset that has since happened } + if (world_stale_next) { + generation--; // tagged before a reset that has since happened + world_stale_next = false; + } world_isr_calls++; if (!dedicated_waiting) { trace("isr drop b%x (not waiting)\n", rx->bufnr); @@ -237,6 +247,10 @@ BaseType_t DmaUART::TransmitPacket(command_buf_t *buf, uint16_t *ms) BaseType_t DmaUART::FreeBuffer(command_buf_t *buf) { + world_frees++; + if (!world_suspended) { + world_free_unsuspended++; + } trace("free b%x%s\n", buf->bufnr, world_suspended ? "" : " (not suspended)"); return pdTRUE; } diff --git a/software/test/wifi_tls/world.h b/software/test/wifi_tls/world.h index 25f58db64..6de8196a7 100644 --- a/software/test/wifi_tls/world.h +++ b/software/test/wifi_tls/world.h @@ -24,6 +24,9 @@ extern std::string world_trace; // every call, in order extern int world_suspended; // vTaskSuspendAll minus xTaskResumeAll extern int world_transmits; // requests that went out extern int world_isr_calls; // replies the interrupt handled +extern int world_frees; // FreeBuffer calls +extern int world_free_unsuspended; // of those, made with the scheduler not suspended +extern bool world_stale_next; // the next reply the interrupt queues is tagged with a pre-reset generation size_t world_queued(void); // replies still in dedicated_replies void world_deliver_now(void); // the receive interrupt hands over an answer now void world_reset_maker(world_maker_t maker); // answers from now on come from maker From ec0b5e474dde9e18a637f3977e7f03e60f6da742 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 13 Nov 2026 11:36:45 -0600 Subject: [PATCH 67/95] TLS handshake draws hold the entropy gate, one draw at a time mbedTLS draws every random byte through mbedtls_psa_external_get_random(), which is esp_fill_random() here. The entropy check ran at OPEN only, on the premise that the radio never stops once started; a Disable now stops it, and a read of the voltages switches the ADC source off, so a draw on the TLS task could land in a window with no source. The link now wraps that function (-Wl,--wrap, tls_rng_gate.c). A draw made on the TLS task holds the gate shared for that one draw and needs a source that is on; any other task passes straight through. A refused draw returns PSA_ERROR_INSUFFICIENT_ENTROPY and the session ends as TLS_FAIL_NO_ENTROPY. The hold is microseconds, so a radio change never waits for ECC or RSA work. The cipher list is AEAD only, so the handshake is the only place that draws; the comment in tls_open says what a CBC suite, DTLS or server tickets would need. Co-Authored-By: Claude Opus 5.5 --- software/wifi/common/radio_entropy.h | 3 +- software/wifi/raw_u64/main/CMakeLists.txt | 6 ++- software/wifi/raw_u64/main/rpc_dispatch.h | 7 +++- software/wifi/tls/rpc_tls.h | 6 ++- software/wifi/tls/tls_engine.c | 18 +++++++-- software/wifi/tls/tls_rng_gate.c | 48 +++++++++++++++++++++++ software/wifi/tls/tls_rng_gate.h | 21 ++++++++++ software/wifi/tls/tls_rpc.c | 2 + 8 files changed, 101 insertions(+), 10 deletions(-) create mode 100644 software/wifi/tls/tls_rng_gate.c create mode 100644 software/wifi/tls/tls_rng_gate.h diff --git a/software/wifi/common/radio_entropy.h b/software/wifi/common/radio_entropy.h index 6d84d83ba..3997d196a 100644 --- a/software/wifi/common/radio_entropy.h +++ b/software/wifi/common/radio_entropy.h @@ -10,7 +10,8 @@ * ENTROPY_ADC. * * A writer-preferring reader/writer gate keeps those transitions away from the draws: - * - shared holders: a GET_RANDOM draw; + * - shared holders: a GET_RANDOM draw, and a draw of the TLS task's handshake + * (software/wifi/tls/tls_rng_gate.c, one draw at a time); * - exclusive holders: a radio start or stop (wifi_radio.c), a read of the voltages that * needs the SAR ADC, and a retry of a failed readback. * Rules for every holder: no re-acquire (it is refused, never waited for), no UART, queue diff --git a/software/wifi/raw_u64/main/CMakeLists.txt b/software/wifi/raw_u64/main/CMakeLists.txt index 13be65c48..95d6b07c3 100644 --- a/software/wifi/raw_u64/main/CMakeLists.txt +++ b/software/wifi/raw_u64/main/CMakeLists.txt @@ -3,11 +3,13 @@ set(EXTERNAL "../../../io/uart") set(TLS_DIR "../../tls") # BRIDGE_TLS_STUB (idf.py -D BRIDGE_TLS_STUB=1) builds a size-measurement image without the TLS engine if(BRIDGE_TLS_STUB) - set(TLS_SRCS "${TLS_DIR}/tls_engine_stub.c") + set(TLS_SRCS "${TLS_DIR}/tls_engine_stub.c" "${TLS_DIR}/tls_rng_gate.c") else() - set(TLS_SRCS "${TLS_DIR}/tls_engine.c") + set(TLS_SRCS "${TLS_DIR}/tls_engine.c" "${TLS_DIR}/tls_rng_gate.c") endif() set(COMMON "../../common") idf_component_register(SRCS "main.c" "my_uart.c" "rpc_dispatch.c" "dump_hex.c" "wifi_modem.c" "sntp.c" "${TLS_DIR}/tls_rpc.c" ${TLS_SRCS} ${EXTERNAL}/cmd_buffer.c ${COMMON}/wifi_radio.c ${COMMON}/wifi_radio_esp.c ${COMMON}/radio_boot.c ${COMMON}/radio_entropy.c ${COMMON}/radio_entropy_esp.c INCLUDE_DIRS "." ${TLS_DIR} ${EXTERNAL} ${COMMON} LDFRAGMENTS "linker.lf") +# The TLS task's random draws hold the entropy gate (tls_rng_gate.h): every draw of mbedTLS goes through this function +target_link_options(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=mbedtls_psa_external_get_random") diff --git a/software/wifi/raw_u64/main/rpc_dispatch.h b/software/wifi/raw_u64/main/rpc_dispatch.h index 5673133a4..060fee7e5 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.h +++ b/software/wifi/raw_u64/main/rpc_dispatch.h @@ -27,8 +27,11 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.22" +#define IDENT_STRING "ESP32 WiFi Bridge V1.25" #define IDENT_MAJOR 1 +// 1.25: every random draw of the TLS task holds the entropy gate for that draw (tls_rng_gate), so a radio +// start or stop or a read of the voltages cannot switch the random source off in the middle of one; +// a draw with no source ends the handshake as NO ENTROPY. // 1.22: TLS client sessions (CMD_TLS_*) on their own task, and the Mozilla root list of // software/u64ctrl/ca as the certificate bundle. // 1.21: CMD_GET_RANDOM, served with the radio off too, from the SAR ADC source. @@ -49,7 +52,7 @@ void send_keepalive(); // Disconnected forever. The Ultimate's updater only reflashes the module // when this differs from what the module reports, so a module change that // does not bump it is silently never installed. -#define IDENT_MINOR 22 +#define IDENT_MINOR 25 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 // TLS runs on its own task, so this stays small diff --git a/software/wifi/tls/rpc_tls.h b/software/wifi/tls/rpc_tls.h index 8913743e6..6a0df3914 100644 --- a/software/wifi/tls/rpc_tls.h +++ b/software/wifi/tls/rpc_tls.h @@ -31,7 +31,7 @@ typedef enum { // rpc_tls_open_resp.reason, telling the ESP_ERR_INVALID_STATE refusals apart #define TLS_OPEN_REASON_NONE 0 -#define TLS_OPEN_REASON_NO_ENTROPY 1 // the radio has not started: no RNG seed +#define TLS_OPEN_REASON_NO_ENTROPY 1 // no entropy source is on (radio off and no ADC source): no RNG seed #define TLS_OPEN_REASON_NO_TIME 2 // BUNDLE or CUSTOM, but no trustworthy clock #define TLS_OPEN_REASON_NO_CUSTOM_CA 3 // CUSTOM, but no CA held under the request's ca_tag @@ -57,6 +57,7 @@ typedef enum { TLS_FAIL_CERT_VERIFY = 4, // verify_flags = mbedtls_ssl_get_verify_result(), 0xFFFFFFFF if it never completed TLS_FAIL_PIN_MISMATCH = 5, // PIN: the leaf key is not the pinned one TLS_FAIL_PEER_CLOSED = 6, // close_notify during the handshake + TLS_FAIL_NO_ENTROPY = 7, // a draw found no entropy source (radio stopped or voltages read mid-handshake) } tls_fail_reason_t; // rpc_tls_set_ca_resp.reject, with ESP_ERR_INVALID_ARG @@ -263,7 +264,8 @@ _Static_assert((TLS_STATE_HANDSHAKING == 0) && (TLS_STATE_ESTABLISHED == 1) && (TLS_STATE_CLOSED == 2) && (TLS_STATE_FAILED == 3), "tls_state_t"); _Static_assert((TLS_TRUST_BUNDLE == 0) && (TLS_TRUST_CUSTOM == 1) && (TLS_TRUST_PIN == 2), "tls_trust_t"); _Static_assert((TLS_FAIL_VERSION_REFUSED == 1) && (TLS_FAIL_DOWNGRADE == 2) && (TLS_FAIL_NO_EMS == 3) && - (TLS_FAIL_CERT_VERIFY == 4) && (TLS_FAIL_PIN_MISMATCH == 5) && (TLS_FAIL_PEER_CLOSED == 6), "tls_fail_reason_t"); + (TLS_FAIL_CERT_VERIFY == 4) && (TLS_FAIL_PIN_MISMATCH == 5) && (TLS_FAIL_PEER_CLOSED == 6) && + (TLS_FAIL_NO_ENTROPY == 7), "tls_fail_reason_t"); _Static_assert((TLS_OPEN_REASON_NO_ENTROPY == 1) && (TLS_OPEN_REASON_NO_TIME == 2) && (TLS_OPEN_REASON_NO_CUSTOM_CA == 3), "rpc_tls_open_resp.reason"); _Static_assert((TLS_CA_REJECT_RSA_KEY_SHORT == 1) && (TLS_CA_REJECT_CURVE == 3) && (TLS_CA_REJECT_NOT_CA == 4), diff --git a/software/wifi/tls/tls_engine.c b/software/wifi/tls/tls_engine.c index 85990ec26..e294f8a7c 100644 --- a/software/wifi/tls/tls_engine.c +++ b/software/wifi/tls/tls_engine.c @@ -24,6 +24,7 @@ #endif #include "cmd_buffer.h" #include "wifi_modem.h" +#include "tls_rng_gate.h" #include "sntp.h" #include "tls_engine.h" @@ -392,8 +393,15 @@ int tls_open(uint8_t slot, uint16_t tag, const tls_open_params_t *p, uint8_t *re } #endif // All randomness comes from PSA, which (MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) keeps no seeded state and draws every byte - // from esp_fill_random() when needed. The entropy gate above runs at OPEN only and the handshake steps draw later: - // this relies on the bridge never stopping the radio once started. + // from esp_fill_random() when needed. The check above is at OPEN only: the radio may stop, or the voltages be read, + // before the handshake steps draw. Each draw therefore holds the entropy gate itself (tls_rng_gate.c); a draw with no + // source ends the handshake as TLS_FAIL_NO_ENTROPY (tls_classify). + // + // That covers every draw of this engine because its cipher list is AEAD only. In mbedTLS 4.1.1 (the IDF 6.0.3 one) + // the draws are the ClientHello random and session id (ssl_client.c), the ECDHE key share (ssl_tls12_client.c, + // ssl_tls13_generic.c) and, for CBC suites only, the per-record IV (ssl_msg.c); AEAD nonces come from the record + // sequence number, so records, KeyUpdate and NewSessionTicket of an established session draw nothing. A CBC suite, + // DTLS (cookies) or server-side tickets would draw elsewhere: any of them needs the same treatment of its draws. if (!tls_psa_ready()) { return ESP_FAIL; } @@ -506,7 +514,10 @@ static int tls_note_handshake(tls_session_t *s, int state_before, int version_be // Classifies a failed handshake step for the Ultimate's failure reasons. The Ultimate infers nothing from bare mbedTLS codes. static void tls_classify(tls_session_t *s, int ret, int state_before, int version_before, tls_step_result_t *r) { - if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { + if (tls_rng_gate_take_refusal()) { + // A draw found no entropy source (the radio stopped, or a voltage read ran, and the source is off): not the peer's + r->fail_reason = TLS_FAIL_NO_ENTROPY; + } else if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { r->fail_reason = TLS_FAIL_PEER_CLOSED; } else if ((state_before == MBEDTLS_SSL_SERVER_HELLO) && (ret == MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION)) { // A TLS 1.2 ServerHello below the minimum: the 1.2 parser has set tls_version to the server's choice @@ -544,6 +555,7 @@ static void tls_classify(tls_session_t *s, int ret, int state_before, int versio // Runs handshake steps until mbedTLS wants input or output, the handshake is over, or it fails static int tls_handshake(tls_session_t *s, tls_step_result_t *r) { + tls_rng_gate_take_refusal(); // one left by an earlier session is not this one's while (!mbedtls_ssl_is_handshake_over(&s->ssl)) { int state_before = s->ssl.state; int version_before = s->ssl.tls_version; diff --git a/software/wifi/tls/tls_rng_gate.c b/software/wifi/tls/tls_rng_gate.c new file mode 100644 index 000000000..f8cd9cc5f --- /dev/null +++ b/software/wifi/tls/tls_rng_gate.c @@ -0,0 +1,48 @@ +/* tls_rng_gate.c: see tls_rng_gate.h. Linked in with -Wl,--wrap=mbedtls_psa_external_get_random. */ +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "psa/crypto.h" +#include "radio_entropy.h" +#include "tls_rng_gate.h" + +psa_status_t __real_mbedtls_psa_external_get_random(mbedtls_psa_external_random_context_t *context, uint8_t *output, + size_t output_size, size_t *output_length); + +static TaskHandle_t tls_task; // set once by the TLS task itself +static volatile int refused; // written and read by the TLS task only + +void tls_rng_gate_bind_task(void) +{ + tls_task = xTaskGetCurrentTaskHandle(); +} + +int tls_rng_gate_take_refusal(void) +{ + int was = refused; + refused = 0; + return was; +} + +psa_status_t __wrap_mbedtls_psa_external_get_random(mbedtls_psa_external_random_context_t *context, uint8_t *output, + size_t output_size, size_t *output_length) +{ + if ((tls_task == NULL) || (xTaskGetCurrentTaskHandle() != tls_task)) { + return __real_mbedtls_psa_external_get_random(context, output, output_size, output_length); + } + // No lock, queue or UART is held or waited for in here: the hold is one draw. The wait covers a voltage read (the + // ADC source is off for it, RE_WAIT_ADC_MS at most), so the read every 10 s delays a draw and does not fail it; a + // radio change holds the gate longer and the source is off through it, so a draw then fails. + int rc = radio_entropy_acquire_shared(RE_WAIT_ADC_MS); + if (rc != RE_OK) { + refused = 1; + return PSA_ERROR_INSUFFICIENT_ENTROPY; + } + if (entropy_source() == ENTROPY_NONE) { + radio_entropy_release_shared(); + refused = 1; + return PSA_ERROR_INSUFFICIENT_ENTROPY; + } + psa_status_t status = __real_mbedtls_psa_external_get_random(context, output, output_size, output_length); + radio_entropy_release_shared(); + return status; +} diff --git a/software/wifi/tls/tls_rng_gate.h b/software/wifi/tls/tls_rng_gate.h new file mode 100644 index 000000000..6723ab262 --- /dev/null +++ b/software/wifi/tls/tls_rng_gate.h @@ -0,0 +1,21 @@ +/* tls_rng_gate.h: keeps the radio's entropy source on for the draws of the TLS task. + * + * mbedTLS 4 draws every random byte through mbedtls_psa_external_get_random() (MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG), which + * is esp_fill_random() here. esp_fill_random() is random only while the radio runs or the ADC source is on, and a radio + * start or stop or a read of the voltages switches the source off (radio_entropy.h). The module's link wraps that function + * (-Wl,--wrap=mbedtls_psa_external_get_random, in the component's CMakeLists.txt) with tls_rng_gate.c: + * - a draw made on the TLS task holds the entropy gate shared for that one draw, which is microseconds, so a radio change + * never waits for ECC or RSA work; with no source, or no gate within RE_WAIT_ADC_MS (50 ms, the longest a voltage read may hold it), the draw fails with + * PSA_ERROR_INSUFFICIENT_ENTROPY and the engine ends the session with TLS_FAIL_NO_ENTROPY; + * - a draw made on any other task passes straight through, so the Wi-Fi stack's draws are never held up by it. + */ +#ifndef SOFTWARE_WIFI_TLS_TLS_RNG_GATE_H_ +#define SOFTWARE_WIFI_TLS_TLS_RNG_GATE_H_ + +// The TLS task, once, before it serves its first command: its draws are the ones that are gated +void tls_rng_gate_bind_task(void); + +// 1 once if a draw was refused since the last call (no source, or the gate not free in time), and clears it +int tls_rng_gate_take_refusal(void); + +#endif /* SOFTWARE_WIFI_TLS_TLS_RNG_GATE_H_ */ diff --git a/software/wifi/tls/tls_rpc.c b/software/wifi/tls/tls_rpc.c index da080bd82..1fa346366 100644 --- a/software/wifi/tls/tls_rpc.c +++ b/software/wifi/tls/tls_rpc.c @@ -13,6 +13,7 @@ #include "my_uart.h" #include "wifi_modem.h" #include "tls_engine.h" +#include "tls_rng_gate.h" #include "tls_rpc.h" // Every request and reply must fit one command buffer @@ -209,6 +210,7 @@ void tls_serve(command_buf_t *buf) static void tls_task(void *arg) { + tls_rng_gate_bind_task(); command_buf_t *buf; while (1) { if (xQueueReceive(tls_queue, &buf, portMAX_DELAY) == pdTRUE) { From 218a862a9417c49a8203532d5e4c53f154dd12b8 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 13 Nov 2026 11:36:45 -0600 Subject: [PATCH 68/95] Report a handshake that lost its entropy source as 87, and document it The module reports TLS_FAIL_NO_ENTROPY (7); the Ultimate maps it to the status of the same cause at OPEN, 87 NO ENTROPY SOURCE, instead of 13 with the bare mbedTLS code. The status table and the handle table in doc/uci_tls.md say what happens at OPEN and what happens in the handshake (the ClientHello may have been sent, the handle is gone). Co-Authored-By: Claude Opus 5.5 --- doc/uci_tls.md | 8 ++++---- software/io/network/network_target_tls.cc | 2 ++ software/io/wifi/wifi_tls.cc | 1 + software/io/wifi/wifi_tls.h | 3 ++- software/test/wifi_tls/net_tls_test.cc | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/uci_tls.md b/doc/uci_tls.md index 09f51e112..78364a76a 100644 --- a/doc/uci_tls.md +++ b/doc/uci_tls.md @@ -100,7 +100,7 @@ Handle `$FF`, the capability record, 16 bytes, `00,OK`. It makes one module STAT | 1 | maximum sessions, 2 | | 2 | table entries in use, including failed ones not yet closed | | 3 | trust modes: bit 0 BUNDLE, bit 1 CUSTOM, bit 2 PIN (always `07`) | -| 4 | ready: bit 0 the module answered a STATS (kept while the module is merely busy, cleared when it stops, has no TLS or restarts); bit 1 entropy (radio started, never set without bit 0); bit 2 trusted time (SNTP time not before 2025-01-01, or the module's clock while bit 0); bit 3 custom CA LOADED | +| 4 | ready: bit 0 the module answered a STATS (kept while the module is merely busy, cleared when it stops, has no TLS or restarts); bit 1 entropy (the module has an entropy source on, the radio or the ADC source; never set without bit 0); bit 2 trusted time (SNTP time not before 2025-01-01, or the module's clock while bit 0); bit 3 custom CA LOADED | | 5 | versions: bit 0 TLS 1.2, bit 1 TLS 1.3 (always `03`) | | 6 | module major version (0 with no module) | | 7..8 | module minor version (LE). 0 while no module application is detected, and on builds without TLS | @@ -146,8 +146,8 @@ On failure the code decides what the handle is: | Codes | Handle afterwards | |---|---| -| 81, 82, 87, 90, 91, 92, 97 | unchanged: still an open TCP handle, nothing was sent | -| every other code (11-19, 93-96, 17, 86) | gone: closed and untracked; do not close it | +| 81, 82, 87 at OPEN, 90, 91, 92, 97 | unchanged: still an open TCP handle, nothing was sent | +| every other code (11-19, 93-96, 17, 86), and 87 from the handshake | gone: closed and untracked; do not close it | ### `$25` TLS_RELEASE @@ -231,7 +231,7 @@ A pending chunk of `$16` is dropped by any other command, as for plain sockets. | 84 | UNRESOLVED HOST | OPEN | as OPEN_TCP, also a 10 s DNS timeout | | 85 | ERROR OPENING SOCKET | OPEN | as OPEN_TCP | | 86 | INTERNAL ERROR | any | | -| 87 | NO ENTROPY SOURCE | OPEN, START_TLS | the radio has not started, so there is no random seed | +| 87 | NO ENTROPY SOURCE | OPEN, START_TLS | no entropy source is on, so there is no random seed. At the module's OPEN (step 5) the radio is off and the ADC source did not read back; the handle is unchanged and nothing was sent. In the handshake that follows, a random draw that finds the source off (the radio stopped, or the voltages were being read, since the OPEN) fails the handshake with the same code; the ClientHello may already have been sent, and the handle is gone, as for 13. A radio change or a voltage read never waits for the handshake's computing: each draw holds the source only for itself | | 90 | TLS NOT AVAILABLE | OPEN, START_TLS, TRUST | no module, WiFi disabled, a module image without TLS, or a build without TLS | | 91 | TLS SESSIONS IN USE | OPEN, START_TLS | both table entries are used, failed ones included; none is ever evicted | | 92 | NO TRUSTED TIME | OPEN, START_TLS | BUNDLE and CUSTOM need a trusted clock; PIN does not | diff --git a/software/io/network/network_target_tls.cc b/software/io/network/network_target_tls.cc index b08734e2f..ef001a99f 100644 --- a/software/io/network/network_target_tls.cc +++ b/software/io/network/network_target_tls.cc @@ -718,6 +718,8 @@ Message *NetworkTarget :: tls_classify(TlsSocket *e, void *step) return pin ? &c_status_tls_pin_mismatch : &c_status_tls_module; case WIFI_TLS_FAIL_PEER_CLOSED: return set_status("13,TLS HANDSHAKE FAILED: PEER CLOSED"); + case WIFI_TLS_FAIL_NO_ENTROPY: + return &c_status_no_entropy; // the source went off after the OPEN: the same code as at OPEN default: return &c_status_tls_module; } diff --git a/software/io/wifi/wifi_tls.cc b/software/io/wifi/wifi_tls.cc index e4fb3e670..cc8e521af 100644 --- a/software/io/wifi/wifi_tls.cc +++ b/software/io/wifi/wifi_tls.cc @@ -112,6 +112,7 @@ static_assert(WIFI_TLS_FAIL_NO_EMS == TLS_FAIL_NO_EMS, "fail reasons differ"); static_assert(WIFI_TLS_FAIL_CERT_VERIFY == TLS_FAIL_CERT_VERIFY, "fail reasons differ"); static_assert(WIFI_TLS_FAIL_PIN_MISMATCH == TLS_FAIL_PIN_MISMATCH, "fail reasons differ"); static_assert(WIFI_TLS_FAIL_PEER_CLOSED == TLS_FAIL_PEER_CLOSED, "fail reasons differ"); +static_assert(WIFI_TLS_FAIL_NO_ENTROPY == TLS_FAIL_NO_ENTROPY, "fail reasons differ"); static_assert(WIFI_TLS_ALERT_NONE == TLS_ALERT_NONE, "alerts differ"); static_assert(WIFI_TLS_REJECT_RSA_KEY_SHORT == TLS_CA_REJECT_RSA_KEY_SHORT, "rejects differ"); static_assert(WIFI_TLS_REJECT_CURVE == TLS_CA_REJECT_CURVE, "rejects differ"); diff --git a/software/io/wifi/wifi_tls.h b/software/io/wifi/wifi_tls.h index abf615efa..2778bdc55 100644 --- a/software/io/wifi/wifi_tls.h +++ b/software/io/wifi/wifi_tls.h @@ -23,7 +23,7 @@ #define WIFI_TLS_STEP_NO_READ 0x01 // the module takes no plaintext out of the session in this step // Why an OPEN was refused. -#define WIFI_TLS_REASON_NO_ENTROPY 1 // the radio has not started, so there is no seed +#define WIFI_TLS_REASON_NO_ENTROPY 1 // no entropy source is on, so there is no seed #define WIFI_TLS_REASON_NO_TIME 2 // BUNDLE or CUSTOM, and neither side has a trustworthy clock #define WIFI_TLS_REASON_NO_CUSTOM_CA 3 // CUSTOM, and the module holds no CA under the given ca_tag @@ -45,6 +45,7 @@ #define WIFI_TLS_FAIL_CERT_VERIFY 4 // verify_flags is the final verify result #define WIFI_TLS_FAIL_PIN_MISMATCH 5 #define WIFI_TLS_FAIL_PEER_CLOSED 6 +#define WIFI_TLS_FAIL_NO_ENTROPY 7 // a draw found no entropy source mid-handshake: status 87 #define WIFI_TLS_ALERT_NONE 0xFF diff --git a/software/test/wifi_tls/net_tls_test.cc b/software/test/wifi_tls/net_tls_test.cc index d6e098a57..e93492a52 100644 --- a/software/test/wifi_tls/net_tls_test.cc +++ b/software/test/wifi_tls/net_tls_test.cc @@ -630,6 +630,7 @@ static void test_classify(void) expect_fail(2, 5, 0x08, N, -0x2700, "96,PINNED KEY MISMATCH", "PIN, reason 5"); expect_fail(0, 5, 0x08, N, -0x2700, "17,TLS MODULE NOT RESPONDING", "BUNDLE, reason 5 (PIN only: malformed)"); expect_fail(0, 6, 0, N, -0x7280, "13,TLS HANDSHAKE FAILED: PEER CLOSED", "reason 6"); + expect_fail(0, 7, 0, N, -0x0103, "87,NO ENTROPY SOURCE", "reason 7 (the source went off after the OPEN)"); expect_fail(0, 9, 0, N, -0x7280, "17,TLS MODULE NOT RESPONDING", "an unknown reason"); fresh(); From 929826962ebf11190f882bc98b2da6af150dadcb Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 13 Nov 2026 11:53:04 -0600 Subject: [PATCH 69/95] Document that a server KeyUpdate ends a TLS session with status 16 Co-Authored-By: Claude Opus 5.5 --- doc/uci_tls.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/uci_tls.md b/doc/uci_tls.md index 78364a76a..070123523 100644 --- a/doc/uci_tls.md +++ b/doc/uci_tls.md @@ -267,6 +267,9 @@ Policy of the module's client, for both versions: - Key exchange groups, in order: x25519, secp256r1, secp384r1, secp521r1. - TLS 1.2 requires the extended master secret (else `13,...: NO EMS`). No renegotiation, no session tickets or resumption. +- A TLS 1.3 KeyUpdate from the server is not supported (mbedTLS 4.1.1 treats it as an unexpected message): the READ or + WRITE that meets it fails with `16,TLS SESSION FAILED: -0x7700` and the handle is closed. Servers send a KeyUpdate + only near the record limit of the cipher, about 2^24 records, so a C64 transfer does not reach it. - A ServerHello without `supported_versions` is 18 under REQUIRE_TLS13; in default mode it is 19 only when its random ends in the downgrade sentinel, else 13. A protocol_version alert is always 14 with 70. From a077b5d752fd0b0fa1c3696b3ea79c9ffad988f7 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 13 Nov 2026 12:14:46 -0600 Subject: [PATCH 70/95] Keep status 87 to the OPEN, and bind the entropy gate in the engine Status 87 meant two things under START_TLS: at the OPEN the TCP handle was kept, from the handshake it was closed and untracked. A C64 program cannot tell them apart, and lwIP reuses socket numbers, so following "87: handle unchanged" could close an unrelated connection. 87 is now answered at the OPEN only, always with the handle kept. A source lost during the handshake is `13,TLS HANDSHAKE FAILED: NO ENTROPY`, and the handle is closed as for every 13. The tests check the status and the handle outcome for START_TLS and OPEN_TLS; doc/uci_tls.md gives each code exactly one handle outcome. The TLS task bound the gate to itself in tls_task(), which no test of the engine runs, so deleting that call left the gate off for every draw and still passed. tls_open() now binds it, first (idempotent and cheap), and the host harness no longer binds on its own. A draw before the binding is still not gated: the Wi-Fi stack draws before the TLS task starts. A draw waits for the gate RE_WAIT_ADC_MS rounded up to whole ticks plus one tick, since a waiting draw looks once per tick (10 ms on the module). The header no longer claims that 50 ms is how long a voltage read may hold the gate: it is how long the read itself waits, and the hold is recorded in adc_hold_max_ms. The documentation now names the causes of a refused draw (a radio change, a failed readback, and the implicit radio starts), and the engine comment lists the ECDH blinding draws. Co-Authored-By: Claude Opus 5.5 --- doc/uci_tls.md | 8 ++++---- software/io/network/network_target_tls.cc | 4 +++- software/io/wifi/wifi_tls.h | 2 +- software/test/wifi_tls/net_tls_test.cc | 12 +++++++++++- software/wifi/tls/tls_engine.c | 4 +++- software/wifi/tls/tls_rng_gate.c | 13 +++++++++---- software/wifi/tls/tls_rng_gate.h | 9 +++++++-- software/wifi/tls/tls_rpc.c | 2 -- 8 files changed, 38 insertions(+), 16 deletions(-) diff --git a/doc/uci_tls.md b/doc/uci_tls.md index 070123523..7ed1a190f 100644 --- a/doc/uci_tls.md +++ b/doc/uci_tls.md @@ -146,8 +146,8 @@ On failure the code decides what the handle is: | Codes | Handle afterwards | |---|---| -| 81, 82, 87 at OPEN, 90, 91, 92, 97 | unchanged: still an open TCP handle, nothing was sent | -| every other code (11-19, 93-96, 17, 86), and 87 from the handshake | gone: closed and untracked; do not close it | +| 81, 82, 87, 90, 91, 92, 97 | unchanged: still an open TCP handle, nothing was sent | +| every other code (11-19, 93-96, 17, 86) | gone: closed and untracked; do not close it | ### `$25` TLS_RELEASE @@ -219,7 +219,7 @@ A pending chunk of `$16` is dropped by any other command, as for plain sockets. | 05 | TLS CLOSED WITHOUT NOTIFY | READ | TCP end without close_notify, possible truncation; handle gone | | 11 | ERROR ON CONNECT: errno | OPEN | as OPEN_TCP, including the connect timeout | | 12 | SEND ERROR: errno, RECEIVE ERROR: errno | READ, WRITE | failed handle; never from `$21` or `$24` | -| 13 | TLS HANDSHAKE FAILED: -0xNNNN, or `: NO EMS`, `: PEER CLOSED`, `: PEER RESET: errno`, `: SEND ERROR: errno` | OPEN | a handshake failure that is none of 14, 15, 18, 19, 93-96 | +| 13 | TLS HANDSHAKE FAILED: -0xNNNN, or `: NO EMS`, `: NO ENTROPY`, `: PEER CLOSED`, `: PEER RESET: errno`, `: SEND ERROR: errno` | OPEN | a handshake failure that is none of 14, 15, 18, 19, 93-96 | | 14 | TLS ALERT RECEIVED: n | OPEN, READ, WRITE | fatal alert n from the server; 70 is protocol_version | | 15 | TLS HANDSHAKE TIMEOUT | OPEN | no established session in 15 s, or the 40 s open budget ran out in the handshake | | 16 | TLS SESSION FAILED: -0xNNNN | READ, WRITE | bad record MAC, decode error, too many empty records, KeyUpdate | @@ -231,7 +231,7 @@ A pending chunk of `$16` is dropped by any other command, as for plain sockets. | 84 | UNRESOLVED HOST | OPEN | as OPEN_TCP, also a 10 s DNS timeout | | 85 | ERROR OPENING SOCKET | OPEN | as OPEN_TCP | | 86 | INTERNAL ERROR | any | | -| 87 | NO ENTROPY SOURCE | OPEN, START_TLS | no entropy source is on, so there is no random seed. At the module's OPEN (step 5) the radio is off and the ADC source did not read back; the handle is unchanged and nothing was sent. In the handshake that follows, a random draw that finds the source off (the radio stopped, or the voltages were being read, since the OPEN) fails the handshake with the same code; the ClientHello may already have been sent, and the handle is gone, as for 13. A radio change or a voltage read never waits for the handshake's computing: each draw holds the source only for itself | +| 87 | NO ENTROPY SOURCE | OPEN, START_TLS | no entropy source is on, so there is no random seed. Answered only at the module's OPEN (step 5), before anything is sent: the radio is off and the ADC source did not read back. The handle is always unchanged, so 87 never ends a handle. A source that is lost after the OPEN is answered as `13,TLS HANDSHAKE FAILED: NO ENTROPY` and the handle is gone, as for every 13: only a random draw that lands inside a radio change, or after a failed readback, finds no source (a finished radio stop leaves the ADC source on, and a voltage read only delays a draw). A radio change is also started implicitly, by a `CMD_WIFI_IS_CONNECTED` on an Ultimate without the radio switch and by the WiFi connector when it enables a disabled radio. A radio change or a voltage read never waits for the handshake's computing: each draw holds the source only for itself | | 90 | TLS NOT AVAILABLE | OPEN, START_TLS, TRUST | no module, WiFi disabled, a module image without TLS, or a build without TLS | | 91 | TLS SESSIONS IN USE | OPEN, START_TLS | both table entries are used, failed ones included; none is ever evicted | | 92 | NO TRUSTED TIME | OPEN, START_TLS | BUNDLE and CUSTOM need a trusted clock; PIN does not | diff --git a/software/io/network/network_target_tls.cc b/software/io/network/network_target_tls.cc index ef001a99f..fd3fad299 100644 --- a/software/io/network/network_target_tls.cc +++ b/software/io/network/network_target_tls.cc @@ -719,7 +719,9 @@ Message *NetworkTarget :: tls_classify(TlsSocket *e, void *step) case WIFI_TLS_FAIL_PEER_CLOSED: return set_status("13,TLS HANDSHAKE FAILED: PEER CLOSED"); case WIFI_TLS_FAIL_NO_ENTROPY: - return &c_status_no_entropy; // the source went off after the OPEN: the same code as at OPEN + // The source went off after the OPEN. 87 is only ever answered with the TCP handle kept, and this ends it, so + // it is a handshake failure with a detail that names the cause. + return set_status("13,TLS HANDSHAKE FAILED: NO ENTROPY"); default: return &c_status_tls_module; } diff --git a/software/io/wifi/wifi_tls.h b/software/io/wifi/wifi_tls.h index 2778bdc55..2ef524676 100644 --- a/software/io/wifi/wifi_tls.h +++ b/software/io/wifi/wifi_tls.h @@ -45,7 +45,7 @@ #define WIFI_TLS_FAIL_CERT_VERIFY 4 // verify_flags is the final verify result #define WIFI_TLS_FAIL_PIN_MISMATCH 5 #define WIFI_TLS_FAIL_PEER_CLOSED 6 -#define WIFI_TLS_FAIL_NO_ENTROPY 7 // a draw found no entropy source mid-handshake: status 87 +#define WIFI_TLS_FAIL_NO_ENTROPY 7 // a draw found no entropy source mid-handshake: status 13, ": NO ENTROPY" #define WIFI_TLS_ALERT_NONE 0xFF diff --git a/software/test/wifi_tls/net_tls_test.cc b/software/test/wifi_tls/net_tls_test.cc index e93492a52..2c23e3acc 100644 --- a/software/test/wifi_tls/net_tls_test.cc +++ b/software/test/wifi_tls/net_tls_test.cc @@ -630,7 +630,7 @@ static void test_classify(void) expect_fail(2, 5, 0x08, N, -0x2700, "96,PINNED KEY MISMATCH", "PIN, reason 5"); expect_fail(0, 5, 0x08, N, -0x2700, "17,TLS MODULE NOT RESPONDING", "BUNDLE, reason 5 (PIN only: malformed)"); expect_fail(0, 6, 0, N, -0x7280, "13,TLS HANDSHAKE FAILED: PEER CLOSED", "reason 6"); - expect_fail(0, 7, 0, N, -0x0103, "87,NO ENTROPY SOURCE", "reason 7 (the source went off after the OPEN)"); + expect_fail(0, 7, 0, N, -0x0103, "13,TLS HANDSHAKE FAILED: NO ENTROPY", "reason 7 (the source went off after the OPEN)"); expect_fail(0, 9, 0, N, -0x7280, "17,TLS MODULE NOT RESPONDING", "an unknown reason"); fresh(); @@ -904,6 +904,16 @@ static void test_start_tls(void) "start: a 93 closes the handle (every code but the kept ones)"); r = close_cmd(t); check(r.status == "12,ERROR ON CLOSE: " + num(EBADF), "start: CLOSE after it -> 12,ERROR ON CLOSE: 9"); + // 87 is answered at the OPEN only, with the handle kept. A source lost in the handshake is a 13 and ends the handle. + fresh(); + t = open_tcp(); + world_module.hs_fail = true; + world_module.hs_fail_reason = 7; + r = run(start_cmd(t, 0, 0, "mail.example")); + check(r.status == "13,TLS HANDSHAKE FAILED: NO ENTROPY" && !sock(t).open, + "start: a source lost in the handshake -> 13 NO ENTROPY, handle closed (87 is only ever kept)"); + r = close_cmd(t); + check(r.status == "12,ERROR ON CLOSE: " + num(EBADF), "start: CLOSE after the 13 NO ENTROPY -> 12"); fresh(); t = open_tcp(); world_module.open_delay_ms = 6000; diff --git a/software/wifi/tls/tls_engine.c b/software/wifi/tls/tls_engine.c index e294f8a7c..205b48caf 100644 --- a/software/wifi/tls/tls_engine.c +++ b/software/wifi/tls/tls_engine.c @@ -359,6 +359,7 @@ int tls_open(uint8_t slot, uint16_t tag, const tls_open_params_t *p, uint8_t *re { char hostname[TLS_SNI_MAX_LEN + 1]; + tls_rng_gate_bind_task(); // from here on, this task's random draws hold the entropy gate (tls_rng_gate.h) *reason = TLS_OPEN_REASON_NONE; // Verifying without a host name would skip the name check, so only PIN may go without one if ((slot >= TLS_MAX_SESSIONS) || (tag == 0) || (p->trust > TLS_TRUST_PIN) || @@ -399,7 +400,8 @@ int tls_open(uint8_t slot, uint16_t tag, const tls_open_params_t *p, uint8_t *re // // That covers every draw of this engine because its cipher list is AEAD only. In mbedTLS 4.1.1 (the IDF 6.0.3 one) // the draws are the ClientHello random and session id (ssl_client.c), the ECDHE key share (ssl_tls12_client.c, - // ssl_tls13_generic.c) and, for CBC suites only, the per-record IV (ssl_msg.c); AEAD nonces come from the record + // ssl_tls13_generic.c), the blinding of the ECDH scalar multiplications (psa_crypto_ecp.c: the public key and the + // shared secret) and, for CBC suites only, the per-record IV (ssl_msg.c); AEAD nonces come from the record // sequence number, so records, KeyUpdate and NewSessionTicket of an established session draw nothing. A CBC suite, // DTLS (cookies) or server-side tickets would draw elsewhere: any of them needs the same treatment of its draws. if (!tls_psa_ready()) { diff --git a/software/wifi/tls/tls_rng_gate.c b/software/wifi/tls/tls_rng_gate.c index f8cd9cc5f..c0623c81a 100644 --- a/software/wifi/tls/tls_rng_gate.c +++ b/software/wifi/tls/tls_rng_gate.c @@ -8,7 +8,11 @@ psa_status_t __real_mbedtls_psa_external_get_random(mbedtls_psa_external_random_context_t *context, uint8_t *output, size_t output_size, size_t *output_length); -static TaskHandle_t tls_task; // set once by the TLS task itself +// How long a draw waits for the gate: RE_WAIT_ADC_MS rounded up to whole ticks, and one tick more. A waiting draw looks at +// the gate once per tick (the module's tick is 10 ms), so a wait of exactly RE_WAIT_ADC_MS could end up to a tick short. +#define TLS_RNG_GATE_WAIT_MS ((((RE_WAIT_ADC_MS + portTICK_PERIOD_MS - 1) / portTICK_PERIOD_MS) + 1) * portTICK_PERIOD_MS) + +static TaskHandle_t tls_task; // set by the TLS task itself, from the engine entry (tls_open) static volatile int refused; // written and read by the TLS task only void tls_rng_gate_bind_task(void) @@ -30,9 +34,10 @@ psa_status_t __wrap_mbedtls_psa_external_get_random(mbedtls_psa_external_random_ return __real_mbedtls_psa_external_get_random(context, output, output_size, output_length); } // No lock, queue or UART is held or waited for in here: the hold is one draw. The wait covers a voltage read (the - // ADC source is off for it, RE_WAIT_ADC_MS at most), so the read every 10 s delays a draw and does not fail it; a - // radio change holds the gate longer and the source is off through it, so a draw then fails. - int rc = radio_entropy_acquire_shared(RE_WAIT_ADC_MS); + // ADC source is off for it; the read itself waits RE_WAIT_ADC_MS for the gate, and the hold it makes is recorded in + // stats.adc_hold_max_ms), so the read every 10 s delays a draw and does not fail it; a radio change holds the gate + // longer and the source is off through it, so a draw then fails. + int rc = radio_entropy_acquire_shared(TLS_RNG_GATE_WAIT_MS); if (rc != RE_OK) { refused = 1; return PSA_ERROR_INSUFFICIENT_ENTROPY; diff --git a/software/wifi/tls/tls_rng_gate.h b/software/wifi/tls/tls_rng_gate.h index 6723ab262..678fb57b7 100644 --- a/software/wifi/tls/tls_rng_gate.h +++ b/software/wifi/tls/tls_rng_gate.h @@ -5,14 +5,19 @@ * start or stop or a read of the voltages switches the source off (radio_entropy.h). The module's link wraps that function * (-Wl,--wrap=mbedtls_psa_external_get_random, in the component's CMakeLists.txt) with tls_rng_gate.c: * - a draw made on the TLS task holds the entropy gate shared for that one draw, which is microseconds, so a radio change - * never waits for ECC or RSA work; with no source, or no gate within RE_WAIT_ADC_MS (50 ms, the longest a voltage read may hold it), the draw fails with + * never waits for ECC or RSA work; with no source, or no gate within the wait below, the draw fails with * PSA_ERROR_INSUFFICIENT_ENTROPY and the engine ends the session with TLS_FAIL_NO_ENTROPY; + * The wait is RE_WAIT_ADC_MS (50 ms: how long a voltage read itself waits for the gate; nothing bounds how long the + * read then holds it, that is recorded in radio_entropy_stats_t.adc_hold_max_ms) rounded up to whole ticks plus one + * tick, because a waiting draw looks at the gate once per tick (10 ms on the module); * - a draw made on any other task passes straight through, so the Wi-Fi stack's draws are never held up by it. */ #ifndef SOFTWARE_WIFI_TLS_TLS_RNG_GATE_H_ #define SOFTWARE_WIFI_TLS_TLS_RNG_GATE_H_ -// The TLS task, once, before it serves its first command: its draws are the ones that are gated +// The TLS task: its draws are the ones that are gated. Idempotent and cheap; tls_open() calls it first, on the TLS task, so +// that the binding is part of the engine and a test of the engine exercises it. A draw made before it is not gated +// (the Wi-Fi stack draws before the TLS task exists, and must never be held). void tls_rng_gate_bind_task(void); // 1 once if a draw was refused since the last call (no source, or the gate not free in time), and clears it diff --git a/software/wifi/tls/tls_rpc.c b/software/wifi/tls/tls_rpc.c index 1fa346366..da080bd82 100644 --- a/software/wifi/tls/tls_rpc.c +++ b/software/wifi/tls/tls_rpc.c @@ -13,7 +13,6 @@ #include "my_uart.h" #include "wifi_modem.h" #include "tls_engine.h" -#include "tls_rng_gate.h" #include "tls_rpc.h" // Every request and reply must fit one command buffer @@ -210,7 +209,6 @@ void tls_serve(command_buf_t *buf) static void tls_task(void *arg) { - tls_rng_gate_bind_task(); command_buf_t *buf; while (1) { if (xQueueReceive(tls_queue, &buf, portMAX_DELAY) == pdTRUE) { From aaa04b081e8c439c2d0039a3363c6c228c08d87f Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 13 Nov 2026 12:31:20 -0600 Subject: [PATCH 71/95] Pin the TLS entropy wait at build time, and state its limits in the docs The extra tick in the wait is margin over the voltage read's hold of the gate, not a rounding correction. A static assert on the module build pins the 60 ms. The host harness can now unbind the gate, so a case starts unbound and only the bind in tls_open counts. The docs say that a voltage read delays a draw only while its hold stays under the wait, and that a busy gate is also reported as NO ENTROPY. Co-Authored-By: Claude Opus 5.5 --- doc/uci_tls.md | 2 +- software/wifi/tls/tls_rng_gate.c | 21 ++++++++++++++++++--- software/wifi/tls/tls_rng_gate.h | 10 +++++++--- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/doc/uci_tls.md b/doc/uci_tls.md index 7ed1a190f..e60774c88 100644 --- a/doc/uci_tls.md +++ b/doc/uci_tls.md @@ -231,7 +231,7 @@ A pending chunk of `$16` is dropped by any other command, as for plain sockets. | 84 | UNRESOLVED HOST | OPEN | as OPEN_TCP, also a 10 s DNS timeout | | 85 | ERROR OPENING SOCKET | OPEN | as OPEN_TCP | | 86 | INTERNAL ERROR | any | | -| 87 | NO ENTROPY SOURCE | OPEN, START_TLS | no entropy source is on, so there is no random seed. Answered only at the module's OPEN (step 5), before anything is sent: the radio is off and the ADC source did not read back. The handle is always unchanged, so 87 never ends a handle. A source that is lost after the OPEN is answered as `13,TLS HANDSHAKE FAILED: NO ENTROPY` and the handle is gone, as for every 13: only a random draw that lands inside a radio change, or after a failed readback, finds no source (a finished radio stop leaves the ADC source on, and a voltage read only delays a draw). A radio change is also started implicitly, by a `CMD_WIFI_IS_CONNECTED` on an Ultimate without the radio switch and by the WiFi connector when it enables a disabled radio. A radio change or a voltage read never waits for the handshake's computing: each draw holds the source only for itself | +| 87 | NO ENTROPY SOURCE | OPEN, START_TLS | no entropy source is on, so there is no random seed. Answered only at the module's OPEN (step 5), before anything is sent: the radio is off and the ADC source did not read back. The handle is always unchanged, so 87 never ends a handle. A source that is lost after the OPEN is answered as `13,TLS HANDSHAKE FAILED: NO ENTROPY` and the handle is gone, as for every 13: only a random draw that lands inside a radio change, or after a failed readback, finds no source (a finished radio stop leaves the ADC source on; a voltage read, on a product that has one, only delays a draw while its hold of the entropy gate stays under the 60 ms a draw waits, and a longer hold fails the draw; `raw_u64` has no voltage read). A draw that finds the entropy gate busy for that whole wait, which on `raw_u64` means a radio change in progress, is answered the same way, `13,TLS HANDSHAKE FAILED: NO ENTROPY`, even with the source on. A radio change is also started implicitly, by a `CMD_WIFI_IS_CONNECTED` on an Ultimate without the radio switch and by the WiFi connector when it enables a disabled radio. A radio change or a voltage read never waits for the handshake's computing: each draw holds the source only for itself | | 90 | TLS NOT AVAILABLE | OPEN, START_TLS, TRUST | no module, WiFi disabled, a module image without TLS, or a build without TLS | | 91 | TLS SESSIONS IN USE | OPEN, START_TLS | both table entries are used, failed ones included; none is ever evicted | | 92 | NO TRUSTED TIME | OPEN, START_TLS | BUNDLE and CUSTOM need a trusted clock; PIN does not | diff --git a/software/wifi/tls/tls_rng_gate.c b/software/wifi/tls/tls_rng_gate.c index c0623c81a..9c4416d54 100644 --- a/software/wifi/tls/tls_rng_gate.c +++ b/software/wifi/tls/tls_rng_gate.c @@ -8,10 +8,18 @@ psa_status_t __real_mbedtls_psa_external_get_random(mbedtls_psa_external_random_context_t *context, uint8_t *output, size_t output_size, size_t *output_length); -// How long a draw waits for the gate: RE_WAIT_ADC_MS rounded up to whole ticks, and one tick more. A waiting draw looks at -// the gate once per tick (the module's tick is 10 ms), so a wait of exactly RE_WAIT_ADC_MS could end up to a tick short. +// How long a draw waits for the gate: RE_WAIT_ADC_MS rounded up to whole ticks, and one tick more. The extra tick is margin +// over the voltage read, not a correction of the rounding: radio_entropy_acquire_shared() measures its deadline in esp_timer +// milliseconds, so RE_WAIT_ADC_MS alone was never short. What the margin covers is the hold of the read itself, which +// nothing bounds and which radio_entropy_stats_t.adc_hold_max_ms records (to be measured on hardware). #define TLS_RNG_GATE_WAIT_MS ((((RE_WAIT_ADC_MS + portTICK_PERIOD_MS - 1) / portTICK_PERIOD_MS) + 1) * portTICK_PERIOD_MS) +// The module runs the tick at 100 Hz (CONFIG_FREERTOS_HZ=100, 10 ms) and the wait is 60 ms: a build that truncates instead of +// rounding up (50), or drops the extra tick (50), fails here. Host builds use a 1 ms stand-in tick and do not check it. +#ifdef ESP_PLATFORM +_Static_assert(TLS_RNG_GATE_WAIT_MS == 60, "TLS_RNG_GATE_WAIT_MS: 50 ms rounded up to whole 10 ms ticks, plus one tick"); +#endif + static TaskHandle_t tls_task; // set by the TLS task itself, from the engine entry (tls_open) static volatile int refused; // written and read by the TLS task only @@ -20,6 +28,13 @@ void tls_rng_gate_bind_task(void) tls_task = xTaskGetCurrentTaskHandle(); } +#ifdef TLS_RNG_GATE_HOST_TEST +void tls_rng_gate_unbind_task_for_test(void) +{ + tls_task = NULL; +} +#endif + int tls_rng_gate_take_refusal(void) { int was = refused; @@ -35,7 +50,7 @@ psa_status_t __wrap_mbedtls_psa_external_get_random(mbedtls_psa_external_random_ } // No lock, queue or UART is held or waited for in here: the hold is one draw. The wait covers a voltage read (the // ADC source is off for it; the read itself waits RE_WAIT_ADC_MS for the gate, and the hold it makes is recorded in - // stats.adc_hold_max_ms), so the read every 10 s delays a draw and does not fail it; a radio change holds the gate + // stats.adc_hold_max_ms), so a read whose hold stays under the wait delays a draw and does not fail it; a radio change holds the gate // longer and the source is off through it, so a draw then fails. int rc = radio_entropy_acquire_shared(TLS_RNG_GATE_WAIT_MS); if (rc != RE_OK) { diff --git a/software/wifi/tls/tls_rng_gate.h b/software/wifi/tls/tls_rng_gate.h index 678fb57b7..bfa69bb4f 100644 --- a/software/wifi/tls/tls_rng_gate.h +++ b/software/wifi/tls/tls_rng_gate.h @@ -7,9 +7,8 @@ * - a draw made on the TLS task holds the entropy gate shared for that one draw, which is microseconds, so a radio change * never waits for ECC or RSA work; with no source, or no gate within the wait below, the draw fails with * PSA_ERROR_INSUFFICIENT_ENTROPY and the engine ends the session with TLS_FAIL_NO_ENTROPY; - * The wait is RE_WAIT_ADC_MS (50 ms: how long a voltage read itself waits for the gate; nothing bounds how long the - * read then holds it, that is recorded in radio_entropy_stats_t.adc_hold_max_ms) rounded up to whole ticks plus one - * tick, because a waiting draw looks at the gate once per tick (10 ms on the module); + * The wait is RE_WAIT_ADC_MS (50 ms) rounded up to whole ticks (10 ms on the module) plus one tick, 60 ms: margin over + * the voltage read's hold of the gate, which nothing bounds (radio_entropy_stats_t.adc_hold_max_ms records it); * - a draw made on any other task passes straight through, so the Wi-Fi stack's draws are never held up by it. */ #ifndef SOFTWARE_WIFI_TLS_TLS_RNG_GATE_H_ @@ -20,6 +19,11 @@ // (the Wi-Fi stack draws before the TLS task exists, and must never be held). void tls_rng_gate_bind_task(void); +#ifdef TLS_RNG_GATE_HOST_TEST +// Host harness only: forgets the binding, so that a case starts unbound and only tls_open() can bind it. +void tls_rng_gate_unbind_task_for_test(void); +#endif + // 1 once if a draw was refused since the last call (no source, or the gate not free in time), and clears it int tls_rng_gate_take_refusal(void); From d4c42ab535dd320927bf889b719d2512ddea7591 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 13 Nov 2026 12:47:26 -0600 Subject: [PATCH 72/95] Selftest: model the ABORT that cancels an OPEN_TLS, and keep INFO-claims covered 7d15151d1 changed S19e and S19e2b to expect an ABORTed OPEN to end within a slice and leave nothing; the mock and the REST double still ran it to its end and left an unclaimed session, so both scenarios failed against the model. The mock now cancels, with abort-ignored and abort-leaves-entry mutants. S19e2b lost its INFO-does-not-claim guard (the OPEN claims A), so it checks [14] = 1 twice before the abort; the release-noop and info-ff-claims mutants are judged on S19e2 and S19e2b. Co-Authored-By: Claude Opus 5.5 --- .../e2e/io/command_interface/net_tls_mock.py | 26 +++++++++---- .../io/command_interface/net_tls_selftest.py | 37 +++++++++++++++---- .../e2e/io/command_interface/net_tls_test.py | 7 +++- 3 files changed, 55 insertions(+), 15 deletions(-) diff --git a/tests/e2e/io/command_interface/net_tls_mock.py b/tests/e2e/io/command_interface/net_tls_mock.py index 63498a59f..42f7ecbee 100644 --- a/tests/e2e/io/command_interface/net_tls_mock.py +++ b/tests/e2e/io/command_interface/net_tls_mock.py @@ -17,8 +17,10 @@ "group-zero" the OPEN reply's group is 0 (S2 must catch it) "info-ff-claims" `03 23 FF` claims every session (S19e2b must catch it) "no-notify-reply" the peer's close_notify is not answered with ours (S6 must catch it) - "abort-shortens" an ABORT ends PROCESSING early: bit 2 clears at the ABORT, - while the open still completes behind it (S19e must catch it) + "abort-ignored" an ABORT does not cancel an OPEN: it runs to its end and + leaves an unclaimed session (S19e, S19e2b must catch it) + "abort-leaves-entry" an ABORT ends the OPEN within a slice, but the session it + had begun stays open (S19e, S19e2b must catch it) It is a model of the contract, not of the firmware: timings are not simulated, a READ takes what the socket has, and the group is reported as @@ -47,9 +49,10 @@ x509 = None MUTANTS = ("bundle-accepts-all", "release-noop", "group-zero", "info-ff-claims", - "abort-shortens", "no-notify-reply") + "abort-ignored", "abort-leaves-entry", "no-notify-reply") FLAVOURS = ("tls", "stock", *MUTANTS) MAX_TLS = 2 +ABORT_SLICE = 0.1 # a cancelled wait ends within one slice of the ABORT SUITES = { "TLS_AES_128_GCM_SHA256": 0x1301, "TLS_AES_256_GCM_SHA384": 0x1302, @@ -120,13 +123,22 @@ def _command(self, command: bytes, bound: float) -> Result: def abort_in_flight(self, command: bytes, abort_after: float, bound: float | None = None) -> AbortedCommand: - # ABORT never shortens a command: it runs to its end, and only - # its reply is dropped. + # An ABORT cancels an OPEN_TLS / START_TLS within a slice and the module + # closes the session the command had begun (doc/uci_tls.md); the + # "abort-ignored" mutant lets it run to its end instead, and + # "abort-leaves-entry" ends it early but keeps the session. + before = set(self.handles) started = time.monotonic() self._dispatch(command) elapsed = time.monotonic() - started - if self.flavour == "abort-shortens": - elapsed = abort_after + if self.flavour != "abort-ignored": + elapsed = abort_after + ABORT_SLICE + if self.flavour != "abort-leaves-entry": + for handle in set(self.handles) - before: + try: + self.handles.pop(handle).sock.close() + except OSError: + pass self.log.append({"t": round(time.time(), 3), "link": self.name, "command": command.hex(" "), "abort_after": abort_after, "busy_at_abort": True, "bit2_cleared_after": round(elapsed, 3)}) diff --git a/tests/e2e/io/command_interface/net_tls_selftest.py b/tests/e2e/io/command_interface/net_tls_selftest.py index c1fe1a017..1fb188371 100644 --- a/tests/e2e/io/command_interface/net_tls_selftest.py +++ b/tests/e2e/io/command_interface/net_tls_selftest.py @@ -42,7 +42,7 @@ import net_tls_fixture as fx # noqa: E402 import net_tls_proto as proto # noqa: E402 import net_tls_test as suite # noqa: E402 -from net_tls_mock import MockDevice # noqa: E402 +from net_tls_mock import ABORT_SLICE, MockDevice # noqa: E402 SUITE = "net_tls_selftest" STANDINS = (("H1", "h1.standin.test"), ("H2", "h2.standin.test")) @@ -240,10 +240,24 @@ def _reset(self, params): return self._ok_json(params) def _run(self, command: bytes) -> None: - data, text = self.mock._dispatch(command) + # An ABORT cancels the command within a slice and the module closes the session it + # had begun (doc/uci_tls.md): the dispatch runs on a worker, and what it opens after + # the ABORT is closed again when it ends. + before = set(self.mock.handles) + box: list[tuple[bytes, bytes]] = [] + worker = threading.Thread(target=lambda: box.append(self.mock._dispatch(command)), daemon=True) + worker.start() + while worker.is_alive() and not self.abort: + worker.join(0.02) + if self.abort: + time.sleep(ABORT_SLICE) + with self.uci_lock: + self.state, self.abort, self.blocks = "idle", False, [] + threading.Thread(target=self._discard, args=(worker, before), daemon=True).start() + return + data, text = box[0] with self.uci_lock: if self.abort: - # The ABORT is serviced once the command returns: reply dropped. self.state, self.abort, self.blocks = "idle", False, [] return chunks = [data[i:i + MAX_BLOCK_BYTES] for i in range(0, len(data), MAX_BLOCK_BYTES)] @@ -252,6 +266,14 @@ def _run(self, command: bytes) -> None: for i, chunk in enumerate(chunks)] self._next_block() + def _discard(self, worker: threading.Thread, before: set) -> None: + worker.join() + for handle in set(self.mock.handles) - before: + try: + self.mock.handles.pop(handle).sock.close() + except OSError: + pass + def _next_block(self) -> None: chunk, text = self.blocks.pop(0) self.resp, self.stat = bytearray(chunk), bytearray(text) @@ -670,15 +692,16 @@ def main() -> int: ok = False section("part 3: each mutant turns its guard red") for flavour, sids in (("bundle-accepts-all", ["S0", "S5"]), - ("release-noop", ["S0", "S19e", "S19e2"]), + ("release-noop", ["S0", "S19e2"]), ("group-zero", ["S0", "S2"]), - ("info-ff-claims", ["S0", "S19e", "S19e2b"])): + ("info-ff-claims", ["S0", "S19e2b"])): outcomes = world.run(flavour, sids) ok &= judge_flavour(flavour, outcomes, {sid: "FAIL" for sid in sids[1:]}) outcomes = world.run("no-notify-reply", ["S0", "S6"]) ok &= judge_flavour("no-notify-reply", outcomes, {"S6": "FAIL"}) - outcomes = world.run("abort-shortens", ["S0", "S19e"]) - ok &= judge_flavour("abort-shortens", outcomes, {"S19e": "FAIL"}) + for flavour in ("abort-ignored", "abort-leaves-entry"): + outcomes = world.run(flavour, ["S0", "S19e", "S19e2b"]) + ok &= judge_flavour(flavour, outcomes, {"S19e": "FAIL", "S19e2b": "FAIL"}) if not args.quick: ok &= part4(world) ok &= part5(world) diff --git a/tests/e2e/io/command_interface/net_tls_test.py b/tests/e2e/io/command_interface/net_tls_test.py index bfa33bae8..1444ffaa5 100644 --- a/tests/e2e/io/command_interface/net_tls_test.py +++ b/tests/e2e/io/command_interface/net_tls_test.py @@ -962,7 +962,12 @@ def s19e2b_info_does_not_claim(ctx: Ctx) -> None: slow = ctx.server("ecdsa", fx.Behaviour(delay_handshake=SLOW_HANDSHAKE_SECONDS)) a = ctx.expect_open(fast.port, ctx.bind_ip, pin=pin_of(ctx)).handle try: - with check("OPEN A, accept it, unused; ABORTed OPEN B leaves nothing: `03 23 FF` [2] = 1, [14] = 0; $25 -> 0"): + with check("OPEN A, accept it, unused; `03 23 FF` twice: [2] = 1, [14] = 1 both times (INFO claims nothing)"): + for _ in range(2): + cap = ctx.info_ff() + if (cap.entries, cap.unclaimed) != (1, 1): + raise Failure(f"[2] = {cap.entries}, [14] = {cap.unclaimed}") + with check("ABORTed OPEN B leaves no entry: `03 23 FF` [2] = 1, [14] = 0; $25 -> 0"): ctx.link.abort_in_flight(open_tls_command(slow.port, ctx.bind_ip, TRUST_PIN, pin=pin_of(ctx)), ABORT_AFTER_SECONDS) cap = ctx.info_ff() From fdc70fbd43a81e8e01607da7a7bb5139e421d0bb Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Fri, 13 Nov 2026 20:04:01 -0600 Subject: [PATCH 73/95] Test requirements: list cryptography, and let the TLS fixture and mock import without it net_tls_fixture.py and net_tls_mock.py need the cryptography package but tests/requirements.txt did not list it. Without it, the module-level x509 annotations could raise NameError at import instead of the intended missing-package message. Defer annotation evaluation. Co-Authored-By: Claude Opus 5.5 --- tests/e2e/io/command_interface/net_tls_fixture.py | 7 ++++--- tests/e2e/io/command_interface/net_tls_mock.py | 1 + tests/requirements.txt | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/e2e/io/command_interface/net_tls_fixture.py b/tests/e2e/io/command_interface/net_tls_fixture.py index da0f62f3b..2329ab9b6 100644 --- a/tests/e2e/io/command_interface/net_tls_fixture.py +++ b/tests/e2e/io/command_interface/net_tls_fixture.py @@ -25,6 +25,7 @@ `Behaviour`. The device reaches it at this machine's address on the route to the device, as net_target_test.py's Peer does. """ +from __future__ import annotations import datetime import hashlib @@ -139,7 +140,7 @@ def root_pem_file(self) -> Path: def _name(cn: str) -> x509.Name: return x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, cn)]) - def _ca(self, cn, key, issuer, issuer_key, now) -> "x509.Certificate": + def _ca(self, cn, key, issuer, issuer_key, now) -> x509.Certificate: day = datetime.timedelta(days=1) builder = (x509.CertificateBuilder() .subject_name(self._name(cn)) @@ -203,8 +204,8 @@ def issue(self, label: str, cn: str) -> Chain: @dataclass class Behaviour: """What one server does with each connection.""" - min_version: "ssl.TLSVersion" = ssl.TLSVersion.TLSv1_3 - max_version: "ssl.TLSVersion" = ssl.TLSVersion.TLSv1_3 + min_version: ssl.TLSVersion = ssl.TLSVersion.TLSv1_3 + max_version: ssl.TLSVersion = ssl.TLSVersion.TLSv1_3 # OpenSSL cipher string for TLS 1.2; TLS 1.3 suites are left at their default. ciphers: str | None = None # One curve name ("prime256v1"), to force an HRR or a P-256 group. diff --git a/tests/e2e/io/command_interface/net_tls_mock.py b/tests/e2e/io/command_interface/net_tls_mock.py index 63498a59f..6710833ff 100644 --- a/tests/e2e/io/command_interface/net_tls_mock.py +++ b/tests/e2e/io/command_interface/net_tls_mock.py @@ -25,6 +25,7 @@ x25519 because Python's ssl does not expose the negotiated one. Nothing here is evidence about a device. """ +from __future__ import annotations import hashlib import ipaddress diff --git a/tests/requirements.txt b/tests/requirements.txt index 60a75461d..a1bc0be6c 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -13,6 +13,7 @@ openapi-schema-validator # tests/lib/openapi_contract.py, checks device answers -r requirements-lint.txt # ruff, pinned there because tests/lib/lint_test.py is a gate Pillow # e2e/api/input_test.py, e2e/io/printer/printer_test.py pyftpdlib # e2e/filesystem/ftp_client_test.py +cryptography # e2e/io/command_interface/net_tls_fixture.py, net_tls_mock.py, net_tls_selftest.py, throwaway PKI for the TLS suite selenium # e2e/web/theme_test.py, drives an installed Chrome and Firefox pytesseract # e2e/io/printer/printer_test.py, only under --stage verify PyYAML # tests/lib/openapi_contract.py, reads doc/api/rest_api_openapi_*.yaml From 78f16856f6d67934fc2f6dfc50829e39a5736654 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:30:57 -0600 Subject: [PATCH 74/95] Drop roots NSS master removed from u64ctrl's root list curl builds cacert.pem from Mozilla's release branch, which lags NSS master. Roots master has deleted (Buypass Class 2 and 3), no longer trusts for websites (QuoVadis Root CA 1 G3 and 3 G3, Certigna Root CA) or distrusts after a date that has made all their certificates expire (Izenpe.com) stayed in the store. refresh.py now cuts the roots named in REMOVED out of curl's file and pins the result; the rest stays curl's, byte for byte. Roots with a distrust-after date that mbedTLS cannot apply (Firmaprofesional, emSign Root CA - G1, DigiCert Trusted Root G4) stay, listed in DISTRUST_AFTER. The test fails once the date plus 200 days has passed, when the line moves to REMOVED. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/ca/README.md | 18 ++- software/u64ctrl/ca/cacert.pem | 196 +-------------------------- software/u64ctrl/ca/refresh.py | 34 ++++- software/u64ctrl/main/rpc_dispatch.h | 7 +- tests/lib/u64ctrl_ca_test.py | 93 ++++++++++++- 5 files changed, 141 insertions(+), 207 deletions(-) diff --git a/software/u64ctrl/ca/README.md b/software/u64ctrl/ca/README.md index a27dbe75a..a2fca83b3 100644 --- a/software/u64ctrl/ca/README.md +++ b/software/u64ctrl/ca/README.md @@ -1,11 +1,25 @@ # Root list for u64ctrl's network recovery -`cacert.pem` is curl's copy of Mozilla's root list of 2026-10-20 (118 roots), unmodified; its sha256 is pinned in -`tests/lib/u64ctrl_ca_test.py` (`CACERT_SHA256`, the value curl publishes next to the file). u64ctrl's recovery trusts it +`cacert.pem` is curl's copy of Mozilla's root list of 2026-11-05 (112 roots) without the roots in `REMOVED` +(see below); its sha256 is pinned in `tests/lib/u64ctrl_ca_test.py` (`CACERT_SHA256`). u64ctrl's recovery trusts it instead of ESP-IDF 5.3.1's list, which still holds `emSign ECC Root CA - G3` (removed after the eMudhra key compromise) and `emSign Root CA - C1` and `emSign ECC Root CA - C3` (removed in the same NSS release). `emSign Root CA - G1` stays, because Mozilla still ships it. +## Roots curl still ships + +curl builds its file from Mozilla's release branch, which lags NSS master. `REMOVED` in the test also names roots +that master has deleted (Buypass Class 2 and 3), no longer trusts for websites (QuoVadis Root CA 1 G3 and 3 G3, +Certigna Root CA) or distrusts after a date that has made all their certificates expire (Izenpe.com, whose +certificates issued before 2026-04-15 are all expired, because TLS certificates are capped at 200 days since +2026-03-15). `refresh.py` cuts them out of curl's file, and everything else stays curl's, byte for byte. Delete a +line of `REMOVED` once curl's file no longer holds the root. + +`DISTRUST_AFTER` lists the roots Mozilla trusts only for certificates issued before a date (Firmaprofesional, +emSign Root CA - G1, DigiCert Trusted Root G4). mbedTLS cannot apply the date, so these also accept later +certificates. They stay while a certificate issued before the date can still be valid, which is the date plus 200 +days (`MAX_CERT_DAYS`); the test fails after that, and the line moves to `REMOVED`. + ## Chains The list has no ISRG Root YE or YR. Both built-in servers send the cross-signed ISRG Root X2 (and X1) after diff --git a/software/u64ctrl/ca/cacert.pem b/software/u64ctrl/ca/cacert.pem index c5818b24d..e8d553f2f 100644 --- a/software/u64ctrl/ca/cacert.pem +++ b/software/u64ctrl/ca/cacert.pem @@ -1,7 +1,7 @@ ## ## Bundle of CA Root Certificates ## -## Certificate data from Mozilla as of: Tue Oct 20 13:32:40 2026 GMT +## Certificate data from Mozilla as of: Thu Nov 5 04:12:01 2026 GMT ## ## Find updated versions here: https://curl.se/docs/caextract.html ## @@ -16,7 +16,7 @@ ## Configure this file as the SSLCACertificateFile. ## ## Conversion done with mk-ca-bundle.pl version 1.35. -## SHA256: beb7e6dfe6499926e52c075c27bcfbe4c957f8609c575b3860273ae2806f63eb +## SHA256: 3ec2b4d240dc12c747eaf450061db84af757c483bbda302f9e29ceb5d70be510 ## @@ -110,39 +110,6 @@ YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r kpeDMdmztcpHWD9f -----END CERTIFICATE----- -Izenpe.com -========== -# Fingerprint (SHA-256): 25:30:CC:8E:98:32:15:02:BA:D9:6F:9B:1F:BA:1B:09:9E:2D:29:9E:0F:45:48:BB:91:4F:36:3B:C0:D4:53:1F ------BEGIN CERTIF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-SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG -NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx -MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O -BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l -Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga -kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q -hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs -g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5 -aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5 -nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC -ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo -Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z -WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw== ------END CERTIFICATE----- - Go Daddy Root Certificate Authority - G2 ======================================== # Fingerprint (SHA-256): 45:14:0B:32:47:EB:9C:C8:C5:B4:F0:D7:B5:30:91:F7:32:92:08:9E:6E:5A:63:E2:74:9D:D3:AC:A9:19:8E:DA @@ -313,68 +280,6 @@ OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9 vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg== -----END CERTIFICATE----- -Buypass Class 2 Root CA -======================= -# Fingerprint (SHA-256): 9A:11:40:25:19:7C:5B:B9:5D:94:E6:3D:55:CD:43:79:08:47:B6:46:B2:3C:DF:11:AD:A4:A0:0E:FF:15:FB:48 ------BEGIN CERTIFICATE----- -MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU -QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X -DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1 -eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw -DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1 -g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn -9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b -/+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU -CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116r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7koS -CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN -rJgWVqA= ------END CERTIFICATE----- - -Buypass Class 3 Root CA -======================= -# Fingerprint (SHA-256): ED:F7:EB:BC:A2:7A:2A:38:4D:38:7B:7D:40:10:C6:66:E2:ED:B4:84:3E:4C:29:B4:AE:1D:5B:93:32:E6:B2:4D ------BEGIN CERTIFICATE----- -MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU -QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X -DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1 -eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw -DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH -sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR -5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh -7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ -ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH -2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV -/afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ -RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA -Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq -j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD -VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF -AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV -cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G -uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG -Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8 -ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2 -KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz -6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug -UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe -eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi -Cp/HuZc= ------END CERTIFICATE----- - T-TeleSec GlobalRoot Class 3 ============================ # Fingerprint (SHA-256): FD:73:DA:D3:1C:64:4F:F1:B4:3B:EF:0C:CD:DA:96:71:0B:9C:D9:87:5E:CA:7E:31:70:7A:F3:E9:6D:52:2B:BD @@ -575,37 +480,6 @@ vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg== -----END CERTIFICATE----- -QuoVadis Root CA 1 G3 -===================== -# Fingerprint (SHA-256): 8A:86:6F:D1:B2:76:B5:7E:57:8E:92:1C:65:82:8A:2B:ED:58:E9:F2:F2:88:05:41:34:B7:F1:F4:BF:C9:CC:74 ------BEGIN CERTIFICATE----- -MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG -A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv -b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN -MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg -RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE -PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm -PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6 -Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN -ofjSxxR3W5A2B4GbPgb6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b+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0 -FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV -hMJKzRwuJIczYOXD ------END CERTIFICATE----- - QuoVadis Root CA 2 G3 ===================== # Fingerprint (SHA-256): 8F:E4:FB:0A:F9:3A:4D:0D:67:DB:0B:EB:B2:3E:37:C7:1B:F3:25:DC:BC:DD:24:0E:A0:4D:AF:58:B4:7E:18:40 @@ -637,37 +511,6 @@ JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr O3jtZsSOeWmD3n+M -----END CERTIFICATE----- -QuoVadis Root CA 3 G3 -===================== -# Fingerprint (SHA-256): 88:EF:81:DE:20:2E:B0:18:45:2E:43:F8:64:72:5C:EA:5F:BD:1F:C2:D9:D2:05:73:07:09:C5:D8:B8:69:0F:46 ------BEGIN CERTIFICATE----- -MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG -A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv -b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN -MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg -RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286 -IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL -Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTz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Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD -hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX -0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW -dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2 -PpxxVJkES/1Y+Zj0 ------END CERTIFICATE----- - DigiCert Assured ID Root G2 =========================== # Fingerprint (SHA-256): 7D:05:EB:B6:82:33:9F:8C:94:51:EE:09:4E:EB:FE:FA:79:53:A1:14:ED:B2:F4:49:49:45:2F:AB:7D:2F:C1:85 @@ -1514,41 +1357,6 @@ djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr dhh2n1ax -----END CERTIFICATE----- -Certigna Root CA -================ -# Fingerprint (SHA-256): D4:8D:3D:23:EE:DB:50:A4:59:E5:51:97:60:1C:27:77:4B:9D:7B:18:C9:4D:5A:05:95:11:A1:02:50:B9:31:68 ------BEGIN CERTIFICATE----- -MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE -BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ -MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda -MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz -MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4I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l -cnRpZ25hcm9vdGNhLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOIt -OoldaDgvUSILSo3L6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxP -TGRGHVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH60BGM+RFq -7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncBlA2c5uk5jR+mUYyZDDl3 -4bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdio2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd -8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS -6Cvu5zHbugRqh5jnxV/vfaci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY -tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS -aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde -E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0= ------END CERTIFICATE----- - emSign Root CA - G1 =================== # Fingerprint (SHA-256): 40:F6:AF:03:46:A9:9A:A1:CD:1D:55:5A:4E:9C:CE:62:C7:F9:63:46:03:EE:40:66:15:83:3D:C8:C8:D0:03:67 diff --git a/software/u64ctrl/ca/refresh.py b/software/u64ctrl/ca/refresh.py index b3272b107..66d4ba98d 100644 --- a/software/u64ctrl/ca/refresh.py +++ b/software/u64ctrl/ca/refresh.py @@ -5,8 +5,9 @@ Downloads curl's cacert.pem and the sha256 curl publishes next to it (HTTPS only, into memory), and changes nothing in the tree unless every check passes: the hash matches, the file is PEM with at least MIN_ROOTS roots, -it holds the roots the recovery needs and none Mozilla removed, and both built-in recovery servers verify against -it (`openssl s_client -CAfile`, and the last certificate a server sends must be issued by a root of the list, +it holds the roots the recovery needs once the roots in REMOVED (which curl may still ship) are cut out, and both +built-in recovery servers verify against it (`openssl s_client -CAfile`, and the last certificate a server sends +must be issued by a root of the list, because mbedTLS builds no path). Then it replaces cacert.pem and updates the pinned sha256 in tests/lib/u64ctrl_ca_test.py and the date in ca/README.md. It prints the roots added and removed; add the removed ones to REMOVED in the test, and bump IDENT_MINOR in main/rpc_dispatch.h. Nothing downloaded is executed. @@ -85,6 +86,28 @@ def header_date(text): return datetime.datetime.strptime(f"{match.group(1)} {match.group(2)}", "%b %d %Y").date() +BLOCK = re.compile(r"^\S[^\n]*\n=+\n(?:#[^\n]*\n)*-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----\n\n?", + re.MULTILINE | re.DOTALL) + + +def drop_removed(text, ca): + """(text without the roots in REMOVED, [names of the roots dropped]). + + curl builds its file from Mozilla's release branch, which lags NSS master: a root deleted from master, or one + that lost its Websites trust bit there, stays in curl's file for a release or more. REMOVED names them, and they + are cut out here, block by block, so the rest of the file stays curl's, byte for byte. + """ + dropped = [] + + def keep(match): + found = ca.fingerprints(match.group(0)) & set(ca.REMOVED.values()) + if found: + dropped.append(match.group(0).split("\n", 1)[0]) + return "" if found else match.group(0) + + return BLOCK.sub(keep, text), dropped + + def servers(root): """Hosts of the built-in recovery servers, from recovery_trust.c.""" path = os.path.join(root, "software", "u64ctrl", "main", "recovery_trust.c") @@ -171,14 +194,15 @@ def refresh(root=ROOT, get=fetch, verify_server=check_server, out=sys.stdout): published = re.match(r"\s*([0-9a-f]{64})\b", get(URL + ".sha256").decode("ascii", "replace")) if not published or hashlib.sha256(data).hexdigest() != published.group(1): raise RefreshError("the downloaded cacert.pem does not match the sha256 curl publishes") - new_hash = published.group(1) try: text = data.decode("utf-8") except UnicodeDecodeError as error: raise RefreshError("the downloaded file is not UTF-8 text") from error + text, dropped = drop_removed(text, ca) problems = ca.list_problems(text) if problems: raise RefreshError("the downloaded list is not usable: " + "; ".join(problems)) + new_hash = hashlib.sha256(text.encode("utf-8")).hexdigest() # of the file as committed, without REMOVED date = header_date(text) with open(pem_path, "rb") as handle: @@ -192,7 +216,9 @@ def refresh(root=ROOT, get=fetch, verify_server=check_server, out=sys.stdout): if changed and too_old: raise RefreshError(f"the download {too_old}") print(f"downloaded cacert.pem of {date}, {len(new)} roots, sha256 {new_hash}", file=out) - for fp in sorted(set(old) - set(new), key=old.get): + for name in dropped: + print(f"dropped: {name} (in REMOVED; curl still ships it)", file=out) + for fp in sorted(set(old) - set(new) - set(ca.REMOVED.values()), key=old.get): print(f"removed: {old[fp]} (add {fp} to REMOVED)", file=out) for fp in sorted(set(new) - set(old), key=new.get): print(f"added: {new[fp]}", file=out) diff --git a/software/u64ctrl/main/rpc_dispatch.h b/software/u64ctrl/main/rpc_dispatch.h index fcddc176a..4e4f877ce 100644 --- a/software/u64ctrl/main/rpc_dispatch.h +++ b/software/u64ctrl/main/rpc_dispatch.h @@ -26,8 +26,11 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.29" +#define IDENT_STRING "ESP32 WiFi Bridge V1.30" #define IDENT_MAJOR 1 +// 1.30: the recovery's root list drops the roots NSS master has deleted, no longer trusts +// for websites or distrusts for every certificate still valid (Buypass Class 2 and 3, +// QuoVadis Root CA 1 and 3 G3, Certigna Root CA, Izenpe.com). // 1.29: the idle connector handles every queued command and event before it waits, so a // Disable behind an Enable is not left queued; the wait for its own disconnect is bounded // (3 s); events from before a radio stop are dropped; a CMD_WIFI_CONNECT must hold the @@ -50,7 +53,7 @@ void send_keepalive(); // when this is higher than what the module reports, so a module change that // does not bump it is silently never installed, and an older release never // replaces a newer module. -#define IDENT_MINOR 29 +#define IDENT_MINOR 30 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 diff --git a/tests/lib/u64ctrl_ca_test.py b/tests/lib/u64ctrl_ca_test.py index 278a4cfa8..4637ff4d2 100644 --- a/tests/lib/u64ctrl_ca_test.py +++ b/tests/lib/u64ctrl_ca_test.py @@ -29,6 +29,7 @@ import subprocess import sys import tempfile +import types from pathlib import Path # The one stanza that puts the shared library on sys.path; see tests/lib/bootstrap.py. @@ -47,14 +48,42 @@ "ISRG Root X1": "96bcec06264976f37460779acf28c5a7cfe8a3c0aae11a8ffcee05c0bddf08c6", "ISRG Root X2": "69729b8e15a86efc177a57afb7171dfc64add28c2fca8cf1507e34453ccb1470", } -REMOVED = { # removed from Mozilla's list in NSS 3.131.1 (2026-10-20); G3 is bug 2084101, C1 and C3 bug 2083709 +REMOVED = { # not in the store, though curl's copy may still hold them (it follows Mozilla's release branch) + # removed from Mozilla's list in NSS 3.131.1 (2026-10-20); G3 is bug 2084101, C1 and C3 bug 2083709 "emSign ECC Root CA - G3": "86a1ecba089c4a8d3bbe2734c612ba341d813e043cf9e8a862cd5c57a36bbe6b", "emSign Root CA - C1": "125609aa301da0a249b97a8239cb6a34216f44dcac9f3954b14292f2e8c8608f", "emSign ECC Root CA - C3": "bc4d809b15189d78db3e1d8cf4f9726a795da1643ca5f1358e1ddb0edc0d7eb3", + # Removed on NSS master only (2026-11-05). When curl's file no longer holds one of these, delete its line. + # Bug 2085917 (NSS commit 0bc5fc37c2): Buypass Class 2 and 3 removed from NSS. + "Buypass Class 2 Root CA": "9a114025197c5bb95d94e63d55cd43790847b646b23cdf11ada4a00eff15fb48", + "Buypass Class 3 Root CA": "edf7ebbca27a2a384d387b7d4010c666e2edb4843e4c29b4ae1d5b9332e6b24d", + # Bug 2088266 (99c6ac3f7c): Websites trust bit removed from QuoVadis Root CA 1 G3 and 3 G3. + "QuoVadis Root CA 1 G3": "8a866fd1b276b57e578e921c65828a2bed58e9f2f288054134b7f1f4bfc9cc74", + "QuoVadis Root CA 3 G3": "88ef81de202eb018452e43f864725cea5fbd1fc2d9d205730709c5d8b8690f46", + # Bug 2085928 (ca6b9b0021): Websites trust bit removed from Certigna Root CA. + "Certigna Root CA": "d48d3d23eedb50a459e55197601c27774b9d7b18c94d5a059511a10250b93168", + # Bug 2017322 (0dae6498e1, fc168131f8): distrust-after 2026-04-15. The Baseline Requirements cap TLS certificates + # at 200 days since 2026-03-15, so every certificate issued before that date has expired (by 2026-11-01); + # keeping the root would only admit certificates Firefox refuses. + "Izenpe.com": "2530cc8e98321502bad96f9b1fba1b099e2d299e0f4548bb914f363bc0d4531f", } -# sha256 of the whole file, as curl publishes it next to cacert.pem: the file is curl's copy, unmodified. +# Roots Mozilla trusts only for certificates issued before a date (CKA_NSS_SERVER_DISTRUST_AFTER). mbedTLS cannot +# apply the date, so these also accept a certificate issued after it. Kept while a certificate issued before the date +# can still be valid: the Baseline Requirements cap TLS certificates at 200 days. Once the date plus +# MAX_CERT_DAYS has passed the test fails; move the line to REMOVED then. +MAX_CERT_DAYS = 200 +DISTRUST_AFTER = { + # Bug 2085912 (e5cb445f1f) + "Autoridad de Certificacion Firmaprofesional CIF A62634068": + ("57de0583efd2b26e0361da99da9df4648def7ee8441c3b728afa9bcde0f9b26a", "2026-08-06"), + # Bug 2089115 (30e59d44dc) + "emSign Root CA - G1": ("40f6af0346a99aa1cd1d555a4e9cce62c7f9634603ee406615833dc8c8d00367", "2026-11-16"), + # Bug 2092662 (8c60e757c3, 2026-11-13): Websites trust bit restored with this date + "DigiCert Trusted Root G4": ("552f7bdcf1a7af9e6ce672017f4f12abf77240c78e761ac203d1d9d20ac89988", "2026-09-14"), +} +# sha256 of the whole file: curl's cacert.pem with the roots of REMOVED cut out (curl's own file when it holds none). # A refresh changes this, the date in ca/README.md and the lists above together. -CACERT_SHA256 = "796f1389bfea13c0ed78f663b765baaff54a508e5483786bd6ece73c5e3e3cbe" +CACERT_SHA256 = "91787cf04ecb352f74cc3bd18730f986d6238f83643db331a6c3f2b3f1d300c2" MAX_AGE_DAYS = 365 # the list is refreshed at least yearly; offline, so CI needs no network MIN_ROOTS = 100 # Mozilla's list has about 120; an empty or truncated file is not it @@ -88,6 +117,18 @@ def bundle_path(settings): return os.path.join(PROJECT, path) +def expiry_problems(today, distrust_after=None): + """The DISTRUST_AFTER roots whose last possible certificate (date + MAX_CERT_DAYS) has expired.""" + distrust_after = DISTRUST_AFTER if distrust_after is None else distrust_after + problems = [] + for name, (_, date) in distrust_after.items(): + last = datetime.date.fromisoformat(date) + datetime.timedelta(days=MAX_CERT_DAYS) + if today > last: + problems.append(f"{name}: no certificate issued before its distrust-after date {date} is valid after {last}; " + "move it from DISTRUST_AFTER to REMOVED and refresh") + return problems + + def list_problems(pem_text, required=None, removed=None): """What is wrong with a root list: the roots it lacks, the removed ones it holds.""" required = REQUIRED if required is None else required @@ -97,7 +138,9 @@ def list_problems(pem_text, required=None, removed=None): if len(seen) < MIN_ROOTS: problems.append(f"only {len(seen)} certificates (expected at least {MIN_ROOTS})") problems += [f"lacks {name}" for name, fp in required.items() if fp not in seen] - problems += [f"holds {name}, which Mozilla removed" for name, fp in removed.items() if fp in seen] + problems += [f"holds {name}, which is in REMOVED" for name, fp in removed.items() if fp in seen] + if removed is REMOVED: + problems += [f"lacks {name}, which DISTRUST_AFTER keeps" for name, (fp, _) in DISTRUST_AFTER.items() if fp not in seen] return problems @@ -179,7 +222,7 @@ def run_contents_check(path): text = raw.decode("utf-8") problems = list_problems(text) if hashlib.sha256(raw).hexdigest() != CACERT_SHA256: - problems.insert(0, "is not the file CACERT_SHA256 pins (curl's published cacert.pem.sha256); " + problems.insert(0, "is not the file CACERT_SHA256 pins (curl's cacert.pem without REMOVED); " "a refresh changes both together") if problems: raise Failure("; ".join(problems)) @@ -202,6 +245,24 @@ def run_contents_check(path): raise Failure("a list holding a removed root was accepted") + with check("a DISTRUST_AFTER root is kept, a list that lacks one is caught, and one that has expired is caught"): + name, (fp, _) = next(iter(DISTRUST_AFTER.items())) + without = PEM_BLOCK.sub( + lambda block: "" if hashlib.sha256(base64.b64decode("".join(block.group(1).split()))).hexdigest() == fp + else block.group(0), text) + if not any(f"lacks {name}" in p for p in list_problems(without)): + raise Failure("a list without a DISTRUST_AFTER root was accepted") + problems = expiry_problems(datetime.date.today()) + if problems: + raise Failure("; ".join(problems)) + probe = {"probe": ("", "2026-01-01")} + day = datetime.date(2026, 1, 1) + datetime.timedelta(days=MAX_CERT_DAYS) + if expiry_problems(day, probe) or not expiry_problems(day + datetime.timedelta(days=1), probe): + raise Failure("the expiry of a DISTRUST_AFTER root is not caught on the day after its last certificate") + if len(expiry_problems(datetime.date(2030, 1, 1))) != len(DISTRUST_AFTER): + raise Failure("expired DISTRUST_AFTER roots were not all caught") + + def run_embedded_check_mutants(text): """The check of a build's output accepts a bundle made from the list and refuses the others.""" with check("the embedded-bundle check accepts the list's bundle and refuses an extra or a missing root"): @@ -334,6 +395,28 @@ def refuse(host, pem, ca): # the refreshed tree passes the checks that read it: the pin and the date the test now holds if re.search(r'^CACERT_SHA256 = "([0-9a-f]{64})"', done[4][2].decode(), re.MULTILINE).group(1) != new_hash: raise Failure("the pin in the test does not match the new list") + # a REMOVED root that curl still ships is cut, and the pin is the hash of the cut file, not of curl's + ca = types.ModuleType("ca_with_removed") + ca.__dict__.update(sys.modules[__name__].__dict__) + ca.REMOVED = {**REMOVED, name: victim} + original_load = refresh.load_test + refresh.load_test = lambda: ca + later_text = committed.replace(committed[committed.index("as of: ") + 7:committed.index(" GMT")], + later.strftime("%a %b %d 13:32:40 %Y")) + cut_text = later_text.replace(block.group(0) + "\n", "") + if cut_text == later_text or cut_text.count("\n\n\n") != later_text.count("\n\n\n"): + raise Failure("could not build the cut list; this check needs updating") + cut = run(served(later_text)) + cut_hash = hashlib.sha256(cut_text.encode()).hexdigest() + if cut[0] is not True or cut[1] or cut[4][0] != cut_text.encode(): + raise Failure(f"a REMOVED root that curl ships was not cut from the new list: {cut[1]}") + if f'CACERT_SHA256 = "{cut_hash}"'.encode() not in cut[4][2] \ + or hashlib.sha256(later_text.encode()).hexdigest().encode() in cut[4][2]: + raise Failure("the pin is not the hash of the cut list") + if f"dropped: {name}" not in cut[2] or f"removed: {name}" in cut[2] \ + or f"({roots - 1} roots)".encode() not in cut[4][1]: + raise Failure("the output or the README does not show the dropped root:\n" + cut[2]) + refresh.load_test = original_load same = run(served(committed)) if same[0] is not False or "no change" not in same[2]: raise Failure("the committed list was not reported as no change") From 7d7f744f252213596773c9cb2ce663e97290fd20 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:54:18 -0600 Subject: [PATCH 75/95] raw_u64: bump the module identity for the new root list The module embeds software/u64ctrl/ca/cacert.pem, and the updater skips a module whose identity did not rise. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/main/rpc_dispatch.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/software/wifi/raw_u64/main/rpc_dispatch.h b/software/wifi/raw_u64/main/rpc_dispatch.h index 060fee7e5..8bcb1b543 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.h +++ b/software/wifi/raw_u64/main/rpc_dispatch.h @@ -27,8 +27,11 @@ void start_dispatch(QueueHandle_t queue); void send_button_event(uint8_t button); void send_keepalive(); -#define IDENT_STRING "ESP32 WiFi Bridge V1.25" +#define IDENT_STRING "ESP32 WiFi Bridge V1.26" #define IDENT_MAJOR 1 +// 1.26: the TLS root list (software/u64ctrl/ca) drops the roots NSS master has deleted, no longer trusts +// for websites or distrusts for every certificate still valid (Buypass Class 2 and 3, QuoVadis Root CA 1 +// and 3 G3, Certigna Root CA, Izenpe.com). // 1.25: every random draw of the TLS task holds the entropy gate for that draw (tls_rng_gate), so a radio // start or stop or a read of the voltages cannot switch the random source off in the middle of one; // a draw with no source ends the handshake as NO ENTROPY. @@ -52,7 +55,7 @@ void send_keepalive(); // Disconnected forever. The Ultimate's updater only reflashes the module // when this differs from what the module reports, so a module change that // does not bump it is silently never installed. -#define IDENT_MINOR 25 +#define IDENT_MINOR 26 #define MULTITHREADED 0 #define DISPATCHER_STACK 3072 // TLS runs on its own task, so this stays small From 37fb40324292c7bf4eb7fc2f445a3cd643dd174b Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:25:34 -0600 Subject: [PATCH 76/95] Build raw_u64 with ESP-IDF 6.1.1 The build instructions name the 6.1.1 image, and the sdkconfig is regenerated by 6.1.1 with every existing value unchanged, including the IRAM placement options. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/README.md | 6 +- software/wifi/raw_u64/sdkconfig | 284 ++++++++++++++++++++++++++++++-- 2 files changed, 272 insertions(+), 18 deletions(-) diff --git a/software/wifi/raw_u64/README.md b/software/wifi/raw_u64/README.md index b1160d591..1e7541fe6 100644 --- a/software/wifi/raw_u64/README.md +++ b/software/wifi/raw_u64/README.md @@ -2,13 +2,13 @@ ## Building -The bridge needs ESP-IDF 6 (CI uses v6.0.3); `CMakeLists.txt` stops an older one at configure. +The bridge needs ESP-IDF 6 (CI uses v6.1.1); `CMakeLists.txt` stops an older one at configure. raw_c3 still builds with ESP-IDF 5.3.1, as in `docker/Dockerfile`, so CI builds this -project (and u64ctrl) in `espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. +project (and u64ctrl) in `espressif/idf:v6.1.1`, pinned by digest in `.github/workflows/build.yml`. Locally, from the top of the repository, the same way as CI: docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp -v "$PWD":/project -w /project/software/wifi/raw_u64 \ - espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 idf.py build + espressif/idf:v6.1.1@sha256:2b4f966c37eaedc19542b0637a5f850b2eff9478d8e858192aa0073d92c2dc91 idf.py build then `make u64_no_esp` packs `build/bridge.bin` into `update.u64`. `make esp32_raw_u64` (and so `make u64`) works only where `IDF_PATH` is an ESP-IDF 6; `make all` cannot complete with one `IDF_PATH`, diff --git a/software/wifi/raw_u64/sdkconfig b/software/wifi/raw_u64/sdkconfig index 2db5170f5..e6cadbaaf 100644 --- a/software/wifi/raw_u64/sdkconfig +++ b/software/wifi/raw_u64/sdkconfig @@ -1,6 +1,6 @@ # # Automatically generated file. DO NOT EDIT. -# Espressif IoT Development Framework (ESP-IDF) 6.0.3 Project Configuration +# Espressif IoT Development Framework (ESP-IDF) 6.1.1 Project Configuration # # default: CONFIG_SOC_CAPS_ECO_VER_MAX=301 @@ -43,7 +43,7 @@ CONFIG_SOC_RTC_SLOW_MEM_SUPPORTED=y # default: CONFIG_SOC_RTC_MEM_SUPPORTED=y # default: -CONFIG_SOC_RTC_TIMER_V1_SUPPORTED=y +CONFIG_SOC_RTC_TIMER_SUPPORTED=y # default: CONFIG_SOC_I2S_SUPPORTED=y # default: @@ -81,10 +81,14 @@ CONFIG_SOC_ULP_FSM_SUPPORTED=y # default: CONFIG_SOC_CLK_TREE_SUPPORTED=y # default: +CONFIG_SOC_REGI2C_SUPPORTED=y +# default: CONFIG_SOC_MPU_SUPPORTED=y # default: CONFIG_SOC_WDT_SUPPORTED=y # default: +CONFIG_SOC_RTC_WDT_SUPPORTED=y +# default: CONFIG_SOC_SPI_FLASH_SUPPORTED=y # default: CONFIG_SOC_RNG_SUPPORTED=y @@ -97,6 +101,8 @@ CONFIG_SOC_LP_PERIPH_SHARE_INTERRUPT=y # default: CONFIG_SOC_PM_SUPPORTED=y # default: +CONFIG_SOC_SPI_EXTERNAL_NOR_FLASH_SUPPORTED=y +# default: CONFIG_SOC_DPORT_WORKAROUND_DIS_INTERRUPT_LVL=5 # default: CONFIG_SOC_XTAL_SUPPORT_26M=y @@ -169,6 +175,10 @@ CONFIG_SOC_GPIO_PORT=1 # default: CONFIG_SOC_GPIO_PIN_COUNT=40 # default: +CONFIG_SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP=y +# default: +CONFIG_SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK=0 +# default: CONFIG_SOC_GPIO_VALID_GPIO_MASK=0xFFFFFFFFFF # default: CONFIG_SOC_GPIO_IN_RANGE_MAX=39 @@ -245,28 +255,18 @@ CONFIG_SOC_RTCIO_WAKE_SUPPORTED=y # default: CONFIG_SOC_RTC_CNTL_NEEDS_ATOMIC_ACCESS=y # default: -CONFIG_SOC_SPI_HD_BOTH_INOUT_SUPPORTED=y -# default: -CONFIG_SOC_SPI_AS_CS_SUPPORTED=y -# default: CONFIG_SOC_SPI_PERIPH_NUM=3 # default: -CONFIG_SOC_SPI_DMA_CHAN_NUM=2 -# default: -CONFIG_SOC_SPI_MAX_CS_NUM=3 -# default: -CONFIG_SOC_SPI_SUPPORT_CLK_APB=y +CONFIG_SOC_SPI_HD_BOTH_INOUT_SUPPORTED=y # default: CONFIG_SOC_SPI_MAXIMUM_BUFFER_SIZE=64 # default: -CONFIG_SOC_SPI_MAX_PRE_DIVIDER=8192 -# default: -CONFIG_SOC_MEMSPI_ENCRYPTION_ALIGNMENT=16 -# default: CONFIG_SOC_LP_TIMER_BIT_WIDTH_LO=32 # default: CONFIG_SOC_LP_TIMER_BIT_WIDTH_HI=16 # default: +CONFIG_SOC_RTC_TIMER_V1=y +# default: CONFIG_SOC_TOUCH_SENSOR_VERSION=1 # default: CONFIG_SOC_TOUCH_MIN_CHAN_ID=0 @@ -299,6 +299,8 @@ CONFIG_SOC_SPIRAM_SUPPORTED=y # default: CONFIG_SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE=y # default: +CONFIG_SOC_MEMSPI_ENCRYPTION_ALIGNMENT=16 +# default: CONFIG_SOC_SHA_SUPPORT_PARALLEL_ENG=y # default: CONFIG_SOC_SHA_ENDIANNESS_BE=y @@ -355,6 +357,8 @@ CONFIG_SOC_CONFIGURABLE_VDDSDIO_SUPPORTED=y # default: CONFIG_SOC_PM_MODEM_PD_BY_SW=y # default: +CONFIG_SOC_PM_RTC_NOT_SUPPORT_UART2_WAKEUP=y +# default: CONFIG_SOC_CLK_APLL_SUPPORTED=y # default: CONFIG_SOC_CLK_RC_FAST_D256_SUPPORTED=y @@ -401,6 +405,8 @@ CONFIG_SOC_PHY_COMBO_MODULE=y # default: CONFIG_SOC_EMAC_RMII_CLK_OUT_INTERNAL_LOOPBACK=y # default: +CONFIG_SOC_EMAC_REF_CLK_FROM_APLL=y +# default: CONFIG_IDF_CMAKE=y # default: CONFIG_IDF_TOOLCHAIN="gcc" @@ -430,6 +436,14 @@ CONFIG_APP_BUILD_GENERATE_BINARIES=y CONFIG_APP_BUILD_BOOTLOADER=y # default: CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y + +# +# Minimize binary changes between builds +# +# default: +# CONFIG_APP_BUILD_MINIMIZE_BINARY_CHANGES is not set +# end of Minimize binary changes between builds + # CONFIG_APP_REPRODUCIBLE_BUILD is not set # CONFIG_APP_NO_BLOBS is not set # CONFIG_APP_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set @@ -582,6 +596,10 @@ CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM=-1 CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y # default: CONFIG_ESP_ROM_HAS_OUTPUT_PUTC_FUNC=y +# default: +CONFIG_ESP_ROM_HAS_REGI2C_IMPL=y +# default: +CONFIG_ESP_ROM_BOOTLOADER_OFFSET_FLASH=0x1000 # # Serial flasher config @@ -594,6 +612,8 @@ CONFIG_ESPTOOLPY_FLASHMODE_DIO=y CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y # default: CONFIG_ESPTOOLPY_FLASHMODE="dio" +# default: +CONFIG_ESPTOOLPY_FLASHMODE_VAL=3 # CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set CONFIG_ESPTOOLPY_FLASHFREQ_40M=y # CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set @@ -1005,6 +1025,8 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y # default: # CONFIG_UHCI_ISR_HANDLER_IN_IRAM is not set # default: +# CONFIG_UHCI_RECV_FUNC_IN_IRAM is not set +# default: # CONFIG_UHCI_ISR_CACHE_SAFE is not set # default: # CONFIG_UHCI_ENABLE_DEBUG_LOG is not set @@ -1020,6 +1042,12 @@ CONFIG_ETH_DMA_BUFFER_SIZE=512 CONFIG_ETH_DMA_RX_BUFFER_NUM=10 CONFIG_ETH_DMA_TX_BUFFER_NUM=10 # CONFIG_ETH_IRAM_OPTIMIZATION is not set + +# +# Ethernet Clock +# +# end of Ethernet Clock + CONFIG_ETH_USE_SPI_ETHERNET=y # CONFIG_ETH_USE_OPENETH is not set # CONFIG_ETH_TRANSMIT_MUTEX is not set @@ -1030,6 +1058,8 @@ CONFIG_ETH_USE_SPI_ETHERNET=y # # CONFIG_ESP_EVENT_LOOP_PROFILING is not set CONFIG_ESP_EVENT_POST_FROM_ISR=y +# default: +CONFIG_ESP_EVENT_POST_FROM_ISR_SIZE=4 CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y # end of Event Loop Library @@ -1094,6 +1124,8 @@ CONFIG_HTTPD_SERVER_EVENT_POST_TIMEOUT=2000 CONFIG_ESP_HTTPS_OTA_EVENT_POST_TIMEOUT=2000 # default: # CONFIG_ESP_HTTPS_OTA_ENABLE_PARTIAL_DOWNLOAD is not set +# default: +CONFIG_ESP_HTTPS_OTA_VERIFY_SPI_MODE=y # end of ESP HTTPS OTA # @@ -1389,6 +1421,8 @@ CONFIG_ESP_CONSOLE_UART_NUM=0 # default: CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +# default: +CONFIG_ESP_STDIO_MAX_VFS_ENTRIES=2 # end of ESP-STDIO # @@ -1541,6 +1575,10 @@ CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT=y CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y # default: CONFIG_ESP_WIFI_WPA3_COMPATIBLE_SUPPORT=y +# default: +CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP=y +# default: +# CONFIG_ESP_WIFI_PASN_SUPPORT is not set # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set CONFIG_ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME=50 # default: @@ -1558,6 +1596,8 @@ CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y # CONFIG_ESP_WIFI_WAPI_PSK is not set # CONFIG_ESP_WIFI_11KV_SUPPORT is not set # CONFIG_ESP_WIFI_MBO_SUPPORT is not set +# default: +# CONFIG_ESP_WIFI_ENABLE_ROAMING_APP is not set # CONFIG_ESP_WIFI_DPP_SUPPORT is not set # CONFIG_ESP_WIFI_11R_SUPPORT is not set # CONFIG_ESP_WIFI_WPS_SOFTAP_REGISTRAR is not set @@ -1576,8 +1616,189 @@ CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=y # CONFIG_ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER is not set # default: # CONFIG_ESP_WIFI_PASSIVE_HIDDEN_AP_SUPPORT is not set +# default: +# CONFIG_ESP_WIFI_PRIVACY_ENHANCEMENTS_ENABLED is not set # end of Wi-Fi +# +# Wi-Fi Remote +# +# default: +CONFIG_ESP_WIFI_REMOTE_IN_IDF=y +# default: +CONFIG_ESP_WIFI_REMOTE_ENABLED=y +# default: +CONFIG_SLAVE_IDF_TARGET_ESP32=y +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32S2 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C3 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32S3 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C2 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C6 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C5 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C61 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32S31 is not set +# default: +CONFIG_SLAVE_SOC_WIFI_SUPPORTED=y +# default: +CONFIG_SLAVE_SOC_WIFI_WAPI_SUPPORT=y +# default: +CONFIG_SLAVE_SOC_WIFI_CSI_SUPPORT=y +# default: +CONFIG_SLAVE_SOC_WIFI_MESH_SUPPORT=y +# default: +CONFIG_SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y +# default: +CONFIG_SLAVE_SOC_WIFI_NAN_SUPPORT=y +# default: +CONFIG_SLAVE_IDF_TARGET_ARCH_XTENSA=y + +# +# Wi-Fi configuration +# +# default: +CONFIG_WIFI_RMT_STATIC_RX_BUFFER_NUM=10 +# default: +CONFIG_WIFI_RMT_DYNAMIC_RX_BUFFER_NUM=32 +# default: +# CONFIG_WIFI_RMT_STATIC_TX_BUFFER is not set +# default: +CONFIG_WIFI_RMT_DYNAMIC_TX_BUFFER=y +# default: +CONFIG_WIFI_RMT_TX_BUFFER_TYPE=1 +# default: +CONFIG_WIFI_RMT_DYNAMIC_TX_BUFFER_NUM=32 +# default: +CONFIG_WIFI_RMT_STATIC_RX_MGMT_BUFFER=y +# default: +# CONFIG_WIFI_RMT_DYNAMIC_RX_MGMT_BUFFER is not set +# default: +CONFIG_WIFI_RMT_DYNAMIC_RX_MGMT_BUF=0 +# default: +CONFIG_WIFI_RMT_RX_MGMT_BUF_NUM_DEF=5 +# default: +# CONFIG_WIFI_RMT_CSI_ENABLED is not set +# default: +CONFIG_WIFI_RMT_AMPDU_TX_ENABLED=y +# default: +CONFIG_WIFI_RMT_TX_BA_WIN=6 +# default: +CONFIG_WIFI_RMT_AMPDU_RX_ENABLED=y +# default: +CONFIG_WIFI_RMT_RX_BA_WIN=6 +# default: +CONFIG_WIFI_RMT_NVS_ENABLED=y +# default: +CONFIG_WIFI_RMT_TASK_PINNED_TO_CORE_0=y +# default: +# CONFIG_WIFI_RMT_TASK_PINNED_TO_CORE_1 is not set +# default: +CONFIG_WIFI_RMT_SOFTAP_BEACON_MAX_LEN=752 +# default: +CONFIG_WIFI_RMT_MGMT_SBUF_NUM=32 +# default: +CONFIG_WIFI_RMT_IRAM_OPT=y +# default: +# CONFIG_WIFI_RMT_EXTRA_IRAM_OPT is not set +# default: +CONFIG_WIFI_RMT_RX_IRAM_OPT=y +# default: +CONFIG_WIFI_RMT_ENABLE_WPA3_SAE=y +# default: +CONFIG_WIFI_RMT_ENABLE_SAE_H2E=y +# default: +CONFIG_WIFI_RMT_ENABLE_SAE_PK=y +# default: +CONFIG_WIFI_RMT_SOFTAP_SAE_SUPPORT=y +# default: +CONFIG_WIFI_RMT_ENABLE_WPA3_OWE_STA=y +# default: +CONFIG_WIFI_RMT_WPA3_COMPATIBLE_SUPPORT=y +# default: +CONFIG_WIFI_RMT_ENABLE_WPA3_OWE_SOFTAP=y +# default: +# CONFIG_WIFI_RMT_PASN_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_SLP_IRAM_OPT is not set +# default: +CONFIG_WIFI_RMT_SLP_DEFAULT_MIN_ACTIVE_TIME=50 +# default: +# CONFIG_WIFI_RMT_BSS_MAX_IDLE_SUPPORT is not set +# default: +CONFIG_WIFI_RMT_SLP_DEFAULT_MAX_ACTIVE_TIME=10 +# default: +CONFIG_WIFI_RMT_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME=15 +# default: +CONFIG_WIFI_RMT_STA_DISCONNECTED_PM_ENABLE=y +# default: +CONFIG_WIFI_RMT_GMAC_SUPPORT=y +# default: +CONFIG_WIFI_RMT_SOFTAP_SUPPORT=y +# default: +# CONFIG_WIFI_RMT_SLP_BEACON_LOST_OPT is not set +# default: +CONFIG_WIFI_RMT_ESPNOW_MAX_ENCRYPT_NUM=7 +# default: +# CONFIG_WIFI_RMT_NAN_SYNC_ENABLE is not set +# default: +CONFIG_WIFI_RMT_MBEDTLS_CRYPTO=y +# default: +CONFIG_WIFI_RMT_MBEDTLS_TLS_CLIENT=y +# default: +# CONFIG_WIFI_RMT_WAPI_PSK is not set +# default: +# CONFIG_WIFI_RMT_11KV_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_MBO_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_ENABLE_ROAMING_APP is not set +# default: +# CONFIG_WIFI_RMT_DPP_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_11R_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_WPS_SOFTAP_REGISTRAR is not set + +# +# WPS Configuration Options +# +# default: +# CONFIG_WIFI_RMT_WPS_STRICT is not set +# default: +# CONFIG_WIFI_RMT_WPS_PASSPHRASE is not set +# default: +# CONFIG_WIFI_RMT_WPS_RECONNECT_ON_FAIL is not set +# end of WPS Configuration Options + +# default: +# CONFIG_WIFI_RMT_DEBUG_PRINT is not set +# default: +CONFIG_WIFI_RMT_ENTERPRISE_SUPPORT=y +# default: +# CONFIG_WIFI_RMT_ENT_FREE_DYNAMIC_BUFFER is not set +# default: +# CONFIG_WIFI_RMT_PASSIVE_HIDDEN_AP_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_PRIVACY_ENHANCEMENTS_ENABLED is not set +# end of Wi-Fi configuration + +# default: +CONFIG_ESP_WIFI_REMOTE_LIBRARY_HOSTED=y +# default: +# CONFIG_ESP_WIFI_REMOTE_LIBRARY_EPPP is not set +# default: +# CONFIG_ESP_WIFI_REMOTE_LIBRARY_CUSTOM is not set +# default: +CONFIG_ESP_WIFI_REMOTE_EAP_ENABLED=y +# end of Wi-Fi Remote + # # Core dump # @@ -1622,6 +1843,8 @@ CONFIG_FATFS_CODEPAGE=437 CONFIG_FATFS_FS_LOCK=0 CONFIG_FATFS_TIMEOUT_MS=10000 CONFIG_FATFS_PER_FILE_CACHE=y +# default: +CONFIG_FATFS_ALLOC_PREFER_ALIGNED_WORK_BUFFERS=y # CONFIG_FATFS_USE_FASTSEEK is not set # default: CONFIG_FATFS_USE_STRFUNC_NONE=y @@ -1836,6 +2059,8 @@ CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # CONFIG_LWIP_EXTRA_IRAM_OPTIMIZATION is not set CONFIG_LWIP_TIMERS_ONDEMAND=y CONFIG_LWIP_ND6=y +# default: +# CONFIG_LWIP_ND6_SUPPORT_STATIC_ENTRIES is not set # CONFIG_LWIP_FORCE_ROUTER_FORWARDING is not set CONFIG_LWIP_MAX_SOCKETS=16 # CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set @@ -2357,6 +2582,8 @@ CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # # default: CONFIG_SD_ENABLE_SDIO_SUPPORT=y +# default: +CONFIG_SD_READY_POLL_PERIOD_START_US=100 # end of SD Protocol Layer Configuration # @@ -2727,6 +2954,33 @@ CONFIG_WPA_MBEDTLS_TLS_CLIENT=y # CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set # CONFIG_WPA_WPS_STRICT is not set # CONFIG_WPA_DEBUG_PRINT is not set +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +CONFIG_ESP32_WIFI_NVS_ENABLED=y +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA=y +# CONFIG_ESP_WIFI_NAN_ENABLE is not set +CONFIG_WPA_MBEDTLS_CRYPTO=y +CONFIG_WPA_MBEDTLS_TLS_CLIENT=y +# CONFIG_WPA_WAPI_PSK is not set +# CONFIG_WPA_11KV_SUPPORT is not set +# CONFIG_WPA_MBO_SUPPORT is not set +# CONFIG_WPA_DPP_SUPPORT is not set +# CONFIG_WPA_11R_SUPPORT is not set +# CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set +# CONFIG_WPA_WPS_STRICT is not set +# CONFIG_WPA_DEBUG_PRINT is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y From 1031428e8ed631e3225c77aa0016c1ca5b8f8bff Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:25:34 -0600 Subject: [PATCH 77/95] Build raw_c3 with ESP-IDF 6.1.1 The build instructions name the 6.1.1 image, and the sdkconfig is regenerated by 6.1.1 with every existing value unchanged, including the IRAM placement options. Co-Authored-By: Claude Sonnet 5.5 --- README.txt | 2 +- software/wifi/raw_c3/README.md | 6 +- software/wifi/raw_c3/sdkconfig | 303 ++++++++++++++++++++++++++++----- 3 files changed, 260 insertions(+), 51 deletions(-) diff --git a/README.txt b/README.txt index e3a3dc9cb..47a388c05 100644 --- a/README.txt +++ b/README.txt @@ -57,7 +57,7 @@ The U64E-II firmware can be built by typing 'make u64ii' The ESP32 module firmware (software/wifi/raw_u64 for the U64, software/wifi/raw_c3 for the U2+L and software/u64ctrl for the U64E-II) needs ESP-IDF 6, so IDF_PATH has to be an ESP-IDF 6 for 'make', 'make esp32', 'make u64', 'make u64ii', 'make u2pl' and 'make clean'. The Dockerfile in docker/ still installs ESP-IDF 5.3.1; CI -builds the modules in the espressif/idf:v6.0.3 image (see .github/workflows/build.yml) and then packs them with +builds the modules in the espressif/idf:v6.1.1 image (see .github/workflows/build.yml) and then packs them with 'make u64_no_esp', 'make u64ii_no_esp' and 'make u2pl_no_esp'. The README.md in each module directory shows the command. diff --git a/software/wifi/raw_c3/README.md b/software/wifi/raw_c3/README.md index 7da946296..ae062b616 100644 --- a/software/wifi/raw_c3/README.md +++ b/software/wifi/raw_c3/README.md @@ -4,13 +4,13 @@ The WiFi module of the U2+L. ## Building -The bridge needs ESP-IDF 6 (CI uses v6.0.3); `CMakeLists.txt` stops an older one at configure. +The bridge needs ESP-IDF 6 (CI uses v6.1.1); `CMakeLists.txt` stops an older one at configure. `docker/Dockerfile` still installs ESP-IDF 5.3.1, so CI builds this project (and raw_u64 and u64ctrl) in -`espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. Locally, from the top of the +`espressif/idf:v6.1.1`, pinned by digest in `.github/workflows/build.yml`. Locally, from the top of the repository, the same way as CI: docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp -v "$PWD":/project -w /project/software/wifi/raw_c3 \ - espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 idf.py build + espressif/idf:v6.1.1@sha256:2b4f966c37eaedc19542b0637a5f850b2eff9478d8e858192aa0073d92c2dc91 idf.py build then `make u2pl_no_esp` packs `build/bridge.bin` into the update file. `make esp32_raw_c3` (and so `make u2pl`) works only where `IDF_PATH` is an ESP-IDF 6. Once `build/` exists here, `make clean` also diff --git a/software/wifi/raw_c3/sdkconfig b/software/wifi/raw_c3/sdkconfig index 530842e6b..c1cd7580a 100644 --- a/software/wifi/raw_c3/sdkconfig +++ b/software/wifi/raw_c3/sdkconfig @@ -1,6 +1,6 @@ # # Automatically generated file. DO NOT EDIT. -# Espressif IoT Development Framework (ESP-IDF) 6.0.3 Project Configuration +# Espressif IoT Development Framework (ESP-IDF) 6.1.1 Project Configuration # # default: CONFIG_SOC_ADC_SUPPORTED=y @@ -45,7 +45,7 @@ CONFIG_SOC_RTC_FAST_MEM_SUPPORTED=y # default: CONFIG_SOC_RTC_MEM_SUPPORTED=y # default: -CONFIG_SOC_RTC_TIMER_V1_SUPPORTED=y +CONFIG_SOC_RTC_TIMER_SUPPORTED=y # default: CONFIG_SOC_I2S_SUPPORTED=y # default: @@ -83,10 +83,14 @@ CONFIG_SOC_BOD_SUPPORTED=y # default: CONFIG_SOC_CLK_TREE_SUPPORTED=y # default: +CONFIG_SOC_REGI2C_SUPPORTED=y +# default: CONFIG_SOC_ASSIST_DEBUG_SUPPORTED=y # default: CONFIG_SOC_WDT_SUPPORTED=y # default: +CONFIG_SOC_RTC_WDT_SUPPORTED=y +# default: CONFIG_SOC_SPI_FLASH_SUPPORTED=y # default: CONFIG_SOC_RNG_SUPPORTED=y @@ -99,6 +103,8 @@ CONFIG_SOC_LP_PERIPH_SHARE_INTERRUPT=y # default: CONFIG_SOC_PM_SUPPORTED=y # default: +CONFIG_SOC_SPI_EXTERNAL_NOR_FLASH_SUPPORTED=y +# default: CONFIG_SOC_XTAL_SUPPORT_40M=y # default: CONFIG_SOC_AES_SUPPORT_DMA=y @@ -203,8 +209,6 @@ CONFIG_SOC_GPIO_OUT_RANGE_MAX=21 # default: CONFIG_SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK=0 # default: -CONFIG_SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_PIN_CNT=6 -# default: CONFIG_SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK=0x00000000003FFFC0 # default: CONFIG_SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX=y @@ -305,38 +309,10 @@ CONFIG_SOC_SHA_SUPPORT_SHA256=y # default: CONFIG_SOC_SPI_PERIPH_NUM=2 # default: -CONFIG_SOC_SPI_MAX_CS_NUM=6 -# default: CONFIG_SOC_SPI_MAXIMUM_BUFFER_SIZE=64 # default: -CONFIG_SOC_SPI_SUPPORT_DDRCLK=y -# default: -CONFIG_SOC_SPI_SLAVE_SUPPORT_SEG_TRANS=y -# default: -CONFIG_SOC_SPI_SUPPORT_CD_SIG=y -# default: -CONFIG_SOC_SPI_SUPPORT_CONTINUOUS_TRANS=y -# default: CONFIG_SOC_SPI_SUPPORT_SLAVE_HD_VER2=y # default: -CONFIG_SOC_SPI_SUPPORT_CLK_APB=y -# default: -CONFIG_SOC_SPI_SUPPORT_CLK_XTAL=y -# default: -CONFIG_SOC_SPI_PERIPH_SUPPORT_CONTROL_DUMMY_OUT=y -# default: -CONFIG_SOC_SPI_SCT_SUPPORTED=y -# default: -CONFIG_SOC_SPI_SCT_REG_NUM=14 -# default: -CONFIG_SOC_SPI_SCT_BUFFER_NUM_MAX=y -# default: -CONFIG_SOC_SPI_SCT_CONF_BITLEN_MAX=0x3FFFA -# default: -CONFIG_SOC_MEMSPI_IS_INDEPENDENT=y -# default: -CONFIG_SOC_SPI_MAX_PRE_DIVIDER=16 -# default: CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE=y # default: CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_SUSPEND=y @@ -353,19 +329,9 @@ CONFIG_SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE=y # default: CONFIG_SOC_SPI_MEM_SUPPORT_WRAP=y # default: -CONFIG_SOC_SYSTIMER_COUNTER_NUM=2 -# default: -CONFIG_SOC_SYSTIMER_ALARM_NUM=3 -# default: -CONFIG_SOC_SYSTIMER_BIT_WIDTH_LO=32 +CONFIG_SOC_MEMSPI_SUPPORT_CONTROL_DUMMY_OUT=y # default: -CONFIG_SOC_SYSTIMER_BIT_WIDTH_HI=20 -# default: -CONFIG_SOC_SYSTIMER_FIXED_DIVIDER=y -# default: -CONFIG_SOC_SYSTIMER_INT_LEVEL=y -# default: -CONFIG_SOC_SYSTIMER_ALARM_MISS_COMPENSATE=y +CONFIG_SOC_MEMSPI_IS_INDEPENDENT=y # default: CONFIG_SOC_MEMSPI_ENCRYPTION_ALIGNMENT=16 # default: @@ -373,6 +339,8 @@ CONFIG_SOC_LP_TIMER_BIT_WIDTH_LO=32 # default: CONFIG_SOC_LP_TIMER_BIT_WIDTH_HI=16 # default: +CONFIG_SOC_RTC_TIMER_V1=y +# default: CONFIG_SOC_MWDT_SUPPORT_XTAL=y # default: CONFIG_SOC_TWAI_CONTROLLER_NUM=1 @@ -431,8 +399,6 @@ CONFIG_SOC_UART_SUPPORT_WAKEUP_INT=y # default: CONFIG_SOC_UART_WAKEUP_SUPPORT_ACTIVE_THRESH_MODE=y # default: -CONFIG_SOC_UHCI_NUM=1 -# default: CONFIG_SOC_COEX_HW_PTI=y # default: CONFIG_SOC_PHY_DIG_REGS_MEM_SIZE=21 @@ -536,6 +502,14 @@ CONFIG_APP_BUILD_GENERATE_BINARIES=y CONFIG_APP_BUILD_BOOTLOADER=y # default: CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y + +# +# Minimize binary changes between builds +# +# default: +# CONFIG_APP_BUILD_MINIMIZE_BINARY_CHANGES is not set +# end of Minimize binary changes between builds + # CONFIG_APP_REPRODUCIBLE_BUILD is not set # CONFIG_APP_NO_BLOBS is not set # end of Build type @@ -712,6 +686,10 @@ CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y CONFIG_ESP_ROM_CONSOLE_OUTPUT_SECONDARY=y # default: CONFIG_ESP_ROM_HAS_SUBOPTIMAL_NEWLIB_ON_MISALIGNED_MEMORY=y +# default: +CONFIG_ESP_ROM_HAS_REGI2C_IMPL=y +# default: +CONFIG_ESP_ROM_BOOTLOADER_OFFSET_FLASH=0x0 # # Boot ROM Behavior @@ -733,6 +711,8 @@ CONFIG_ESPTOOLPY_FLASHMODE_DIO=y CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y # default: CONFIG_ESPTOOLPY_FLASHMODE="dio" +# default: +CONFIG_ESPTOOLPY_FLASHMODE_VAL=3 CONFIG_ESPTOOLPY_FLASHFREQ_80M=y # CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set @@ -1081,6 +1061,8 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y # default: # CONFIG_UHCI_ISR_HANDLER_IN_IRAM is not set # default: +# CONFIG_UHCI_RECV_FUNC_IN_IRAM is not set +# default: # CONFIG_UHCI_ISR_CACHE_SAFE is not set # default: # CONFIG_UHCI_ENABLE_DEBUG_LOG is not set @@ -1107,6 +1089,8 @@ CONFIG_ETH_USE_SPI_ETHERNET=y # # CONFIG_ESP_EVENT_LOOP_PROFILING is not set CONFIG_ESP_EVENT_POST_FROM_ISR=y +# default: +CONFIG_ESP_EVENT_POST_FROM_ISR_SIZE=4 CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y # end of Event Loop Library @@ -1171,6 +1155,8 @@ CONFIG_HTTPD_SERVER_EVENT_POST_TIMEOUT=2000 CONFIG_ESP_HTTPS_OTA_EVENT_POST_TIMEOUT=2000 # default: # CONFIG_ESP_HTTPS_OTA_ENABLE_PARTIAL_DOWNLOAD is not set +# default: +CONFIG_ESP_HTTPS_OTA_VERIFY_SPI_MODE=y # end of ESP HTTPS OTA # @@ -1251,6 +1237,8 @@ CONFIG_ESP_SLEEP_WAIT_FLASH_READY_EXTRA_DELAY=0 # CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION is not set # CONFIG_ESP_SLEEP_DEBUG is not set CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS=y +# default: +# CONFIG_ESP_SLEEP_SET_FLASH_DPD is not set # end of Sleep Config # @@ -1462,6 +1450,8 @@ CONFIG_ESP_CONSOLE_UART_NUM=0 # default: CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +# default: +CONFIG_ESP_STDIO_MAX_VFS_ENTRIES=2 # end of ESP-STDIO # @@ -1596,6 +1586,10 @@ CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT=y CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y # default: CONFIG_ESP_WIFI_WPA3_COMPATIBLE_SUPPORT=y +# default: +CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP=y +# default: +# CONFIG_ESP_WIFI_PASN_SUPPORT is not set # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set CONFIG_ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME=50 # default: @@ -1615,6 +1609,8 @@ CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y # CONFIG_ESP_WIFI_SUITE_B_192 is not set # CONFIG_ESP_WIFI_11KV_SUPPORT is not set # CONFIG_ESP_WIFI_MBO_SUPPORT is not set +# default: +# CONFIG_ESP_WIFI_ENABLE_ROAMING_APP is not set # CONFIG_ESP_WIFI_DPP_SUPPORT is not set # CONFIG_ESP_WIFI_11R_SUPPORT is not set # CONFIG_ESP_WIFI_WPS_SOFTAP_REGISTRAR is not set @@ -1633,8 +1629,189 @@ CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=y # CONFIG_ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER is not set # default: # CONFIG_ESP_WIFI_PASSIVE_HIDDEN_AP_SUPPORT is not set +# default: +# CONFIG_ESP_WIFI_PRIVACY_ENHANCEMENTS_ENABLED is not set # end of Wi-Fi +# +# Wi-Fi Remote +# +# default: +CONFIG_ESP_WIFI_REMOTE_IN_IDF=y +# default: +CONFIG_ESP_WIFI_REMOTE_ENABLED=y +# default: +CONFIG_SLAVE_IDF_TARGET_ESP32=y +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32S2 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C3 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32S3 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C2 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C6 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C5 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C61 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32S31 is not set +# default: +CONFIG_SLAVE_SOC_WIFI_SUPPORTED=y +# default: +CONFIG_SLAVE_SOC_WIFI_WAPI_SUPPORT=y +# default: +CONFIG_SLAVE_SOC_WIFI_CSI_SUPPORT=y +# default: +CONFIG_SLAVE_SOC_WIFI_MESH_SUPPORT=y +# default: +CONFIG_SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y +# default: +CONFIG_SLAVE_SOC_WIFI_NAN_SUPPORT=y +# default: +CONFIG_SLAVE_IDF_TARGET_ARCH_XTENSA=y + +# +# Wi-Fi configuration +# +# default: +CONFIG_WIFI_RMT_STATIC_RX_BUFFER_NUM=10 +# default: +CONFIG_WIFI_RMT_DYNAMIC_RX_BUFFER_NUM=32 +# default: +# CONFIG_WIFI_RMT_STATIC_TX_BUFFER is not set +# default: +CONFIG_WIFI_RMT_DYNAMIC_TX_BUFFER=y +# default: +CONFIG_WIFI_RMT_TX_BUFFER_TYPE=1 +# default: +CONFIG_WIFI_RMT_DYNAMIC_TX_BUFFER_NUM=32 +# default: +CONFIG_WIFI_RMT_STATIC_RX_MGMT_BUFFER=y +# default: +# CONFIG_WIFI_RMT_DYNAMIC_RX_MGMT_BUFFER is not set +# default: +CONFIG_WIFI_RMT_DYNAMIC_RX_MGMT_BUF=0 +# default: +CONFIG_WIFI_RMT_RX_MGMT_BUF_NUM_DEF=5 +# default: +# CONFIG_WIFI_RMT_CSI_ENABLED is not set +# default: +CONFIG_WIFI_RMT_AMPDU_TX_ENABLED=y +# default: +CONFIG_WIFI_RMT_TX_BA_WIN=6 +# default: +CONFIG_WIFI_RMT_AMPDU_RX_ENABLED=y +# default: +CONFIG_WIFI_RMT_RX_BA_WIN=6 +# default: +CONFIG_WIFI_RMT_NVS_ENABLED=y +# default: +CONFIG_WIFI_RMT_TASK_PINNED_TO_CORE_0=y +# default: +# CONFIG_WIFI_RMT_TASK_PINNED_TO_CORE_1 is not set +# default: +CONFIG_WIFI_RMT_SOFTAP_BEACON_MAX_LEN=752 +# default: +CONFIG_WIFI_RMT_MGMT_SBUF_NUM=32 +# default: +CONFIG_WIFI_RMT_IRAM_OPT=y +# default: +# CONFIG_WIFI_RMT_EXTRA_IRAM_OPT is not set +# default: +CONFIG_WIFI_RMT_RX_IRAM_OPT=y +# default: +CONFIG_WIFI_RMT_ENABLE_WPA3_SAE=y +# default: +CONFIG_WIFI_RMT_ENABLE_SAE_H2E=y +# default: +CONFIG_WIFI_RMT_ENABLE_SAE_PK=y +# default: +CONFIG_WIFI_RMT_SOFTAP_SAE_SUPPORT=y +# default: +CONFIG_WIFI_RMT_ENABLE_WPA3_OWE_STA=y +# default: +CONFIG_WIFI_RMT_WPA3_COMPATIBLE_SUPPORT=y +# default: +CONFIG_WIFI_RMT_ENABLE_WPA3_OWE_SOFTAP=y +# default: +# CONFIG_WIFI_RMT_PASN_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_SLP_IRAM_OPT is not set +# default: +CONFIG_WIFI_RMT_SLP_DEFAULT_MIN_ACTIVE_TIME=50 +# default: +# CONFIG_WIFI_RMT_BSS_MAX_IDLE_SUPPORT is not set +# default: +CONFIG_WIFI_RMT_SLP_DEFAULT_MAX_ACTIVE_TIME=10 +# default: +CONFIG_WIFI_RMT_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME=15 +# default: +CONFIG_WIFI_RMT_STA_DISCONNECTED_PM_ENABLE=y +# default: +CONFIG_WIFI_RMT_GMAC_SUPPORT=y +# default: +CONFIG_WIFI_RMT_SOFTAP_SUPPORT=y +# default: +# CONFIG_WIFI_RMT_SLP_BEACON_LOST_OPT is not set +# default: +CONFIG_WIFI_RMT_ESPNOW_MAX_ENCRYPT_NUM=7 +# default: +# CONFIG_WIFI_RMT_NAN_SYNC_ENABLE is not set +# default: +CONFIG_WIFI_RMT_MBEDTLS_CRYPTO=y +# default: +CONFIG_WIFI_RMT_MBEDTLS_TLS_CLIENT=y +# default: +# CONFIG_WIFI_RMT_WAPI_PSK is not set +# default: +# CONFIG_WIFI_RMT_11KV_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_MBO_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_ENABLE_ROAMING_APP is not set +# default: +# CONFIG_WIFI_RMT_DPP_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_11R_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_WPS_SOFTAP_REGISTRAR is not set + +# +# WPS Configuration Options +# +# default: +# CONFIG_WIFI_RMT_WPS_STRICT is not set +# default: +# CONFIG_WIFI_RMT_WPS_PASSPHRASE is not set +# default: +# CONFIG_WIFI_RMT_WPS_RECONNECT_ON_FAIL is not set +# end of WPS Configuration Options + +# default: +# CONFIG_WIFI_RMT_DEBUG_PRINT is not set +# default: +CONFIG_WIFI_RMT_ENTERPRISE_SUPPORT=y +# default: +# CONFIG_WIFI_RMT_ENT_FREE_DYNAMIC_BUFFER is not set +# default: +# CONFIG_WIFI_RMT_PASSIVE_HIDDEN_AP_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_PRIVACY_ENHANCEMENTS_ENABLED is not set +# end of Wi-Fi configuration + +# default: +CONFIG_ESP_WIFI_REMOTE_LIBRARY_HOSTED=y +# default: +# CONFIG_ESP_WIFI_REMOTE_LIBRARY_EPPP is not set +# default: +# CONFIG_ESP_WIFI_REMOTE_LIBRARY_CUSTOM is not set +# default: +CONFIG_ESP_WIFI_REMOTE_EAP_ENABLED=y +# end of Wi-Fi Remote + # # Core dump # @@ -1679,6 +1856,8 @@ CONFIG_FATFS_CODEPAGE=437 CONFIG_FATFS_FS_LOCK=0 CONFIG_FATFS_TIMEOUT_MS=10000 CONFIG_FATFS_PER_FILE_CACHE=y +# default: +# CONFIG_FATFS_ALLOC_PREFER_ALIGNED_WORK_BUFFERS is not set # CONFIG_FATFS_USE_FASTSEEK is not set # default: CONFIG_FATFS_USE_STRFUNC_NONE=y @@ -1710,7 +1889,6 @@ CONFIG_FATFS_DONT_TRUST_LAST_ALLOC=0 # # Kernel # -# CONFIG_FREERTOS_SMP is not set CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_HZ=100 CONFIG_FREERTOS_OPTIMIZED_SCHEDULER=y @@ -1891,6 +2069,8 @@ CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # CONFIG_LWIP_EXTRA_IRAM_OPTIMIZATION is not set CONFIG_LWIP_TIMERS_ONDEMAND=y CONFIG_LWIP_ND6=y +# default: +# CONFIG_LWIP_ND6_SUPPORT_STATIC_ENTRIES is not set # CONFIG_LWIP_FORCE_ROUTER_FORWARDING is not set CONFIG_LWIP_MAX_SOCKETS=10 # CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set @@ -2426,6 +2606,8 @@ CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # # default: CONFIG_SD_ENABLE_SDIO_SUPPORT=y +# default: +CONFIG_SD_READY_POLL_PERIOD_START_US=100 # end of SD Protocol Layer Configuration # @@ -2760,6 +2942,33 @@ CONFIG_WPA_MBEDTLS_TLS_CLIENT=y # CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set # CONFIG_WPA_WPS_STRICT is not set # CONFIG_WPA_DEBUG_PRINT is not set +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +CONFIG_ESP32_WIFI_NVS_ENABLED=y +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA=y +CONFIG_WPA_MBEDTLS_CRYPTO=y +CONFIG_WPA_MBEDTLS_TLS_CLIENT=y +# CONFIG_WPA_WAPI_PSK is not set +# CONFIG_WPA_SUITE_B_192 is not set +# CONFIG_WPA_11KV_SUPPORT is not set +# CONFIG_WPA_MBO_SUPPORT is not set +# CONFIG_WPA_DPP_SUPPORT is not set +# CONFIG_WPA_11R_SUPPORT is not set +# CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set +# CONFIG_WPA_WPS_STRICT is not set +# CONFIG_WPA_DEBUG_PRINT is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y From 443bdbc488f74cc251f784aab8867fbfb62cc9e6 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:25:34 -0600 Subject: [PATCH 78/95] Build the control module with ESP-IDF 6.1.1 CI and the build instructions move from the 6.0.3 image to espressif/idf:v6.1.1, pinned by digest. The sdkconfig is regenerated by 6.1.1; every value the module sets is unchanged, including the IRAM placement options (FreeRTOS, ring buffer and Wi-Fi in IRAM). Its mbedTLS is the same Mbed TLS 4.1.1 commit as 6.0.3. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/build.yml | 2 +- software/u64ctrl/README.md | 6 +- software/u64ctrl/sdkconfig | 315 ++++++++++++++++++++++++++++++------ 3 files changed, 272 insertions(+), 51 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8fc9d8c07..a366a8ce9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: runs-on: self-hosted env: # u64ctrl needs ESP-IDF 6, so it builds here; raw_u64 and raw_c3 stay on my_docker_image's 5.3.1 - IDF6_IMAGE: espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 + IDF6_IMAGE: espressif/idf:v6.1.1@sha256:2b4f966c37eaedc19542b0637a5f850b2eff9478d8e858192aa0073d92c2dc91 steps: - name: Checkout repository uses: actions/checkout@v7 diff --git a/software/u64ctrl/README.md b/software/u64ctrl/README.md index 8ab889bd9..57cd37c41 100644 --- a/software/u64ctrl/README.md +++ b/software/u64ctrl/README.md @@ -4,13 +4,13 @@ The ESP32-S3 module of the Ultimate 64 Elite II and the C64 Ultimate: WiFi, powe ## Building -The module needs ESP-IDF 6 (CI uses v6.0.3); `CMakeLists.txt` stops an older one at configure. +The module needs ESP-IDF 6 (CI uses v6.1.1); `CMakeLists.txt` stops an older one at configure. raw_u64 and raw_c3 still build with ESP-IDF 5.3.1, as in `docker/Dockerfile`, so CI builds this -project in `espressif/idf:v6.0.3`, pinned by digest in `.github/workflows/build.yml`. Locally, from +project in `espressif/idf:v6.1.1`, pinned by digest in `.github/workflows/build.yml`. Locally, from the top of the repository, the same way as CI: docker run --rm --user $(id -u):$(id -g) -e HOME=/tmp -v "$PWD":/project -w /project/software/u64ctrl \ - espressif/idf:v6.0.3@sha256:54278f2c01e6e759502e2f04c9103589c17528923426f4d63193490c7a08f555 idf.py build + espressif/idf:v6.1.1@sha256:2b4f966c37eaedc19542b0637a5f850b2eff9478d8e858192aa0073d92c2dc91 idf.py build then `make u64ii_no_esp` packs `build/u64ctrl.bin` into the update files. `make esp32_u64ctrl` and `make u64ii` work only where `IDF_PATH` is an ESP-IDF 6, and `make` (all) cannot complete with one diff --git a/software/u64ctrl/sdkconfig b/software/u64ctrl/sdkconfig index f89a3a326..459c78e5d 100644 --- a/software/u64ctrl/sdkconfig +++ b/software/u64ctrl/sdkconfig @@ -1,6 +1,6 @@ # # Automatically generated file. DO NOT EDIT. -# Espressif IoT Development Framework (ESP-IDF) 6.0.3 Project Configuration +# Espressif IoT Development Framework (ESP-IDF) 6.1.1 Project Configuration # # default: CONFIG_SOC_ADC_SUPPORTED=y @@ -49,6 +49,10 @@ CONFIG_SOC_BT_SUPPORTED=y # default: CONFIG_SOC_USB_OTG_SUPPORTED=y # default: +CONFIG_SOC_USB_DFU_SUPPORTED=y +# default: +CONFIG_SOC_USB_OTG_CONSOLE_SUPPORTED=y +# default: CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED=y # default: CONFIG_SOC_CCOMP_TIMER_SUPPORTED=y @@ -69,7 +73,7 @@ CONFIG_SOC_RTC_SLOW_MEM_SUPPORTED=y # default: CONFIG_SOC_RTC_MEM_SUPPORTED=y # default: -CONFIG_SOC_RTC_TIMER_V1_SUPPORTED=y +CONFIG_SOC_RTC_TIMER_SUPPORTED=y # default: CONFIG_SOC_PSRAM_DMA_CAPABLE=y # default: @@ -115,10 +119,14 @@ CONFIG_SOC_BOD_SUPPORTED=y # default: CONFIG_SOC_CLK_TREE_SUPPORTED=y # default: +CONFIG_SOC_REGI2C_SUPPORTED=y +# default: CONFIG_SOC_MPU_SUPPORTED=y # default: CONFIG_SOC_WDT_SUPPORTED=y # default: +CONFIG_SOC_RTC_WDT_SUPPORTED=y +# default: CONFIG_SOC_SPI_FLASH_SUPPORTED=y # default: CONFIG_SOC_RNG_SUPPORTED=y @@ -133,6 +141,8 @@ CONFIG_SOC_PM_SUPPORTED=y # default: CONFIG_SOC_SIMD_INSTRUCTION_SUPPORTED=y # default: +CONFIG_SOC_SPI_EXTERNAL_NOR_FLASH_SUPPORTED=y +# default: CONFIG_SOC_XTAL_SUPPORT_40M=y # default: CONFIG_SOC_APPCPU_HAS_CLOCK_GATING_BUG=y @@ -239,6 +249,10 @@ CONFIG_SOC_GPIO_CLOCKOUT_BY_IO_MUX=y # default: CONFIG_SOC_GPIO_CLOCKOUT_CHANNEL_NUM=3 # default: +CONFIG_SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP=y +# default: +CONFIG_SOC_GPIO_HP_PERIPH_PD_SLEEP_WAKEABLE_MASK=0 +# default: CONFIG_SOC_I2C_NUM=2 # default: CONFIG_SOC_HP_I2C_NUM=2 @@ -327,62 +341,22 @@ CONFIG_SOC_LP_IO_CLOCK_IS_INDEPENDENT=y # default: CONFIG_SOC_SPI_PERIPH_NUM=3 # default: -CONFIG_SOC_SPI_MAX_CS_NUM=6 -# default: CONFIG_SOC_SPI_MAXIMUM_BUFFER_SIZE=64 # default: -CONFIG_SOC_SPI_SUPPORT_DDRCLK=y -# default: -CONFIG_SOC_SPI_SLAVE_SUPPORT_SEG_TRANS=y -# default: -CONFIG_SOC_SPI_SUPPORT_CD_SIG=y -# default: -CONFIG_SOC_SPI_SUPPORT_CONTINUOUS_TRANS=y -# default: CONFIG_SOC_SPI_SUPPORT_SLAVE_HD_VER2=y # default: -CONFIG_SOC_SPI_SUPPORT_CLK_APB=y -# default: -CONFIG_SOC_SPI_SUPPORT_CLK_XTAL=y -# default: -CONFIG_SOC_SPI_PERIPH_SUPPORT_CONTROL_DUMMY_OUT=y -# default: -CONFIG_SOC_MEMSPI_IS_INDEPENDENT=y -# default: -CONFIG_SOC_SPI_MAX_PRE_DIVIDER=16 -# default: CONFIG_SOC_SPI_SUPPORT_OCT=y # default: -CONFIG_SOC_SPI_SCT_SUPPORTED=y -# default: -CONFIG_SOC_SPI_SCT_REG_NUM=14 -# default: -CONFIG_SOC_SPI_SCT_BUFFER_NUM_MAX=y -# default: -CONFIG_SOC_SPI_SCT_CONF_BITLEN_MAX=0x3FFFA -# default: CONFIG_SOC_SPIRAM_SUPPORTED=y # default: CONFIG_SOC_SPIRAM_XIP_SUPPORTED=y # default: -CONFIG_SOC_SYSTIMER_COUNTER_NUM=2 -# default: -CONFIG_SOC_SYSTIMER_ALARM_NUM=3 -# default: -CONFIG_SOC_SYSTIMER_BIT_WIDTH_LO=32 -# default: -CONFIG_SOC_SYSTIMER_BIT_WIDTH_HI=20 -# default: -CONFIG_SOC_SYSTIMER_FIXED_DIVIDER=y -# default: -CONFIG_SOC_SYSTIMER_INT_LEVEL=y -# default: -CONFIG_SOC_SYSTIMER_ALARM_MISS_COMPENSATE=y -# default: CONFIG_SOC_LP_TIMER_BIT_WIDTH_LO=32 # default: CONFIG_SOC_LP_TIMER_BIT_WIDTH_HI=16 # default: +CONFIG_SOC_RTC_TIMER_V1=y +# default: CONFIG_SOC_TOUCH_SENSOR_VERSION=2 # default: CONFIG_SOC_TOUCH_MIN_CHAN_ID=1 @@ -425,8 +399,6 @@ CONFIG_SOC_UART_SUPPORT_XTAL_CLK=y # default: CONFIG_SOC_UART_WAKEUP_SUPPORT_ACTIVE_THRESH_MODE=y # default: -CONFIG_SOC_UHCI_NUM=1 -# default: CONFIG_SOC_USB_OTG_PERIPH_NUM=1 # default: CONFIG_SOC_USB_FSLS_PHY_NUM=1 @@ -505,6 +477,8 @@ CONFIG_SOC_PM_MODEM_RETENTION_BY_BACKUPDMA=y # default: CONFIG_SOC_PM_MODEM_PD_BY_SW=y # default: +CONFIG_SOC_PM_RTC_NOT_SUPPORT_UART2_WAKEUP=y +# default: CONFIG_SOC_CLK_RC_FAST_D256_SUPPORTED=y # default: CONFIG_SOC_RTC_SLOW_CLK_SUPPORT_RC_FAST_D256=y @@ -587,6 +561,10 @@ CONFIG_SOC_SPI_MEM_SUPPORT_CACHE_32BIT_ADDR_MAP=y # default: CONFIG_SOC_SPI_MEM_FLASH_SUPPORT_HPM=y # default: +CONFIG_SOC_MEMSPI_SUPPORT_CONTROL_DUMMY_OUT=y +# default: +CONFIG_SOC_MEMSPI_IS_INDEPENDENT=y +# default: CONFIG_SOC_MEMSPI_ENCRYPTION_ALIGNMENT=16 # default: CONFIG_SOC_COEX_HW_PTI=y @@ -666,6 +644,14 @@ CONFIG_APP_BUILD_GENERATE_BINARIES=y CONFIG_APP_BUILD_BOOTLOADER=y # default: CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y + +# +# Minimize binary changes between builds +# +# default: +# CONFIG_APP_BUILD_MINIMIZE_BINARY_CHANGES is not set +# end of Minimize binary changes between builds + # CONFIG_APP_REPRODUCIBLE_BUILD is not set # CONFIG_APP_NO_BLOBS is not set # end of Build type @@ -851,6 +837,10 @@ CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y CONFIG_ESP_ROM_HAS_OUTPUT_PUTC_FUNC=y # default: CONFIG_ESP_ROM_CONSOLE_OUTPUT_SECONDARY=y +# default: +CONFIG_ESP_ROM_HAS_REGI2C_IMPL=y +# default: +CONFIG_ESP_ROM_BOOTLOADER_OFFSET_FLASH=0x0 # # Boot ROM Behavior @@ -874,6 +864,8 @@ CONFIG_ESPTOOLPY_FLASHMODE_DIO=y CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y # default: CONFIG_ESPTOOLPY_FLASHMODE="dio" +# default: +CONFIG_ESPTOOLPY_FLASHMODE_VAL=3 # CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set CONFIG_ESPTOOLPY_FLASHFREQ_80M=y # CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set @@ -1288,6 +1280,8 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y # default: # CONFIG_UHCI_ISR_HANDLER_IN_IRAM is not set # default: +# CONFIG_UHCI_RECV_FUNC_IN_IRAM is not set +# default: # CONFIG_UHCI_ISR_CACHE_SAFE is not set # default: # CONFIG_UHCI_ENABLE_DEBUG_LOG is not set @@ -1314,6 +1308,8 @@ CONFIG_ETH_USE_SPI_ETHERNET=y # # CONFIG_ESP_EVENT_LOOP_PROFILING is not set CONFIG_ESP_EVENT_POST_FROM_ISR=y +# default: +CONFIG_ESP_EVENT_POST_FROM_ISR_SIZE=4 CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y # end of Event Loop Library @@ -1378,6 +1374,8 @@ CONFIG_HTTPD_SERVER_EVENT_POST_TIMEOUT=2000 CONFIG_ESP_HTTPS_OTA_EVENT_POST_TIMEOUT=2000 # default: # CONFIG_ESP_HTTPS_OTA_ENABLE_PARTIAL_DOWNLOAD is not set +# default: +CONFIG_ESP_HTTPS_OTA_VERIFY_SPI_MODE=y # end of ESP HTTPS OTA # @@ -1457,6 +1455,8 @@ CONFIG_ESP_SLEEP_WAIT_FLASH_READY_EXTRA_DELAY=2000 # CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION is not set # CONFIG_ESP_SLEEP_DEBUG is not set CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS=y +# default: +# CONFIG_ESP_SLEEP_SET_FLASH_DPD is not set # end of Sleep Config # @@ -1675,6 +1675,8 @@ CONFIG_ESP_CONSOLE_UART_NUM=0 # default: CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +# default: +CONFIG_ESP_STDIO_MAX_VFS_ENTRIES=2 # end of ESP-STDIO # @@ -1859,6 +1861,10 @@ CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT=y CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y # default: CONFIG_ESP_WIFI_WPA3_COMPATIBLE_SUPPORT=y +# default: +CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP=y +# default: +# CONFIG_ESP_WIFI_PASN_SUPPORT is not set # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set CONFIG_ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME=50 # default: @@ -1878,6 +1884,8 @@ CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y # CONFIG_ESP_WIFI_SUITE_B_192 is not set # CONFIG_ESP_WIFI_11KV_SUPPORT is not set # CONFIG_ESP_WIFI_MBO_SUPPORT is not set +# default: +# CONFIG_ESP_WIFI_ENABLE_ROAMING_APP is not set # CONFIG_ESP_WIFI_DPP_SUPPORT is not set # CONFIG_ESP_WIFI_11R_SUPPORT is not set # CONFIG_ESP_WIFI_WPS_SOFTAP_REGISTRAR is not set @@ -1896,8 +1904,189 @@ CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=y # CONFIG_ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER is not set # default: # CONFIG_ESP_WIFI_PASSIVE_HIDDEN_AP_SUPPORT is not set +# default: +# CONFIG_ESP_WIFI_PRIVACY_ENHANCEMENTS_ENABLED is not set # end of Wi-Fi +# +# Wi-Fi Remote +# +# default: +CONFIG_ESP_WIFI_REMOTE_IN_IDF=y +# default: +CONFIG_ESP_WIFI_REMOTE_ENABLED=y +# default: +CONFIG_SLAVE_IDF_TARGET_ESP32=y +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32S2 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C3 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32S3 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C2 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C6 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C5 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32C61 is not set +# default: +# CONFIG_SLAVE_IDF_TARGET_ESP32S31 is not set +# default: +CONFIG_SLAVE_SOC_WIFI_SUPPORTED=y +# default: +CONFIG_SLAVE_SOC_WIFI_WAPI_SUPPORT=y +# default: +CONFIG_SLAVE_SOC_WIFI_CSI_SUPPORT=y +# default: +CONFIG_SLAVE_SOC_WIFI_MESH_SUPPORT=y +# default: +CONFIG_SLAVE_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y +# default: +CONFIG_SLAVE_SOC_WIFI_NAN_SUPPORT=y +# default: +CONFIG_SLAVE_IDF_TARGET_ARCH_XTENSA=y + +# +# Wi-Fi configuration +# +# default: +CONFIG_WIFI_RMT_STATIC_RX_BUFFER_NUM=10 +# default: +CONFIG_WIFI_RMT_DYNAMIC_RX_BUFFER_NUM=32 +# default: +# CONFIG_WIFI_RMT_STATIC_TX_BUFFER is not set +# default: +CONFIG_WIFI_RMT_DYNAMIC_TX_BUFFER=y +# default: +CONFIG_WIFI_RMT_TX_BUFFER_TYPE=1 +# default: +CONFIG_WIFI_RMT_DYNAMIC_TX_BUFFER_NUM=32 +# default: +CONFIG_WIFI_RMT_STATIC_RX_MGMT_BUFFER=y +# default: +# CONFIG_WIFI_RMT_DYNAMIC_RX_MGMT_BUFFER is not set +# default: +CONFIG_WIFI_RMT_DYNAMIC_RX_MGMT_BUF=0 +# default: +CONFIG_WIFI_RMT_RX_MGMT_BUF_NUM_DEF=5 +# default: +# CONFIG_WIFI_RMT_CSI_ENABLED is not set +# default: +CONFIG_WIFI_RMT_AMPDU_TX_ENABLED=y +# default: +CONFIG_WIFI_RMT_TX_BA_WIN=6 +# default: +CONFIG_WIFI_RMT_AMPDU_RX_ENABLED=y +# default: +CONFIG_WIFI_RMT_RX_BA_WIN=6 +# default: +CONFIG_WIFI_RMT_NVS_ENABLED=y +# default: +CONFIG_WIFI_RMT_TASK_PINNED_TO_CORE_0=y +# default: +# CONFIG_WIFI_RMT_TASK_PINNED_TO_CORE_1 is not set +# default: +CONFIG_WIFI_RMT_SOFTAP_BEACON_MAX_LEN=752 +# default: +CONFIG_WIFI_RMT_MGMT_SBUF_NUM=32 +# default: +CONFIG_WIFI_RMT_IRAM_OPT=y +# default: +# CONFIG_WIFI_RMT_EXTRA_IRAM_OPT is not set +# default: +CONFIG_WIFI_RMT_RX_IRAM_OPT=y +# default: +CONFIG_WIFI_RMT_ENABLE_WPA3_SAE=y +# default: +CONFIG_WIFI_RMT_ENABLE_SAE_H2E=y +# default: +CONFIG_WIFI_RMT_ENABLE_SAE_PK=y +# default: +CONFIG_WIFI_RMT_SOFTAP_SAE_SUPPORT=y +# default: +CONFIG_WIFI_RMT_ENABLE_WPA3_OWE_STA=y +# default: +CONFIG_WIFI_RMT_WPA3_COMPATIBLE_SUPPORT=y +# default: +CONFIG_WIFI_RMT_ENABLE_WPA3_OWE_SOFTAP=y +# default: +# CONFIG_WIFI_RMT_PASN_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_SLP_IRAM_OPT is not set +# default: +CONFIG_WIFI_RMT_SLP_DEFAULT_MIN_ACTIVE_TIME=50 +# default: +# CONFIG_WIFI_RMT_BSS_MAX_IDLE_SUPPORT is not set +# default: +CONFIG_WIFI_RMT_SLP_DEFAULT_MAX_ACTIVE_TIME=10 +# default: +CONFIG_WIFI_RMT_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME=15 +# default: +CONFIG_WIFI_RMT_STA_DISCONNECTED_PM_ENABLE=y +# default: +CONFIG_WIFI_RMT_GMAC_SUPPORT=y +# default: +CONFIG_WIFI_RMT_SOFTAP_SUPPORT=y +# default: +# CONFIG_WIFI_RMT_SLP_BEACON_LOST_OPT is not set +# default: +CONFIG_WIFI_RMT_ESPNOW_MAX_ENCRYPT_NUM=7 +# default: +# CONFIG_WIFI_RMT_NAN_SYNC_ENABLE is not set +# default: +CONFIG_WIFI_RMT_MBEDTLS_CRYPTO=y +# default: +CONFIG_WIFI_RMT_MBEDTLS_TLS_CLIENT=y +# default: +# CONFIG_WIFI_RMT_WAPI_PSK is not set +# default: +# CONFIG_WIFI_RMT_11KV_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_MBO_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_ENABLE_ROAMING_APP is not set +# default: +# CONFIG_WIFI_RMT_DPP_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_11R_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_WPS_SOFTAP_REGISTRAR is not set + +# +# WPS Configuration Options +# +# default: +# CONFIG_WIFI_RMT_WPS_STRICT is not set +# default: +# CONFIG_WIFI_RMT_WPS_PASSPHRASE is not set +# default: +# CONFIG_WIFI_RMT_WPS_RECONNECT_ON_FAIL is not set +# end of WPS Configuration Options + +# default: +# CONFIG_WIFI_RMT_DEBUG_PRINT is not set +# default: +CONFIG_WIFI_RMT_ENTERPRISE_SUPPORT=y +# default: +# CONFIG_WIFI_RMT_ENT_FREE_DYNAMIC_BUFFER is not set +# default: +# CONFIG_WIFI_RMT_PASSIVE_HIDDEN_AP_SUPPORT is not set +# default: +# CONFIG_WIFI_RMT_PRIVACY_ENHANCEMENTS_ENABLED is not set +# end of Wi-Fi configuration + +# default: +CONFIG_ESP_WIFI_REMOTE_LIBRARY_HOSTED=y +# default: +# CONFIG_ESP_WIFI_REMOTE_LIBRARY_EPPP is not set +# default: +# CONFIG_ESP_WIFI_REMOTE_LIBRARY_CUSTOM is not set +# default: +CONFIG_ESP_WIFI_REMOTE_EAP_ENABLED=y +# end of Wi-Fi Remote + # # Core dump # @@ -1942,6 +2131,8 @@ CONFIG_FATFS_CODEPAGE=437 CONFIG_FATFS_FS_LOCK=0 CONFIG_FATFS_TIMEOUT_MS=10000 CONFIG_FATFS_PER_FILE_CACHE=y +# default: +CONFIG_FATFS_ALLOC_PREFER_ALIGNED_WORK_BUFFERS=y # CONFIG_FATFS_USE_FASTSEEK is not set # default: CONFIG_FATFS_USE_STRFUNC_NONE=y @@ -1973,7 +2164,6 @@ CONFIG_FATFS_DONT_TRUST_LAST_ALLOC=0 # # Kernel # -# CONFIG_FREERTOS_SMP is not set # CONFIG_FREERTOS_UNICORE is not set CONFIG_FREERTOS_HZ=100 # CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set @@ -2157,6 +2347,8 @@ CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # CONFIG_LWIP_EXTRA_IRAM_OPTIMIZATION is not set CONFIG_LWIP_TIMERS_ONDEMAND=y CONFIG_LWIP_ND6=y +# default: +# CONFIG_LWIP_ND6_SUPPORT_STATIC_ENTRIES is not set # CONFIG_LWIP_FORCE_ROUTER_FORWARDING is not set CONFIG_LWIP_MAX_SOCKETS=10 # CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set @@ -2696,6 +2888,8 @@ CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" # # default: CONFIG_SD_ENABLE_SDIO_SUPPORT=y +# default: +CONFIG_SD_READY_POLL_PERIOD_START_US=100 # end of SD Protocol Layer Configuration # @@ -3061,6 +3255,33 @@ CONFIG_WPA_MBEDTLS_TLS_CLIENT=y # CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set # CONFIG_WPA_WPS_STRICT is not set # CONFIG_WPA_DEBUG_PRINT is not set +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +CONFIG_ESP32_WIFI_NVS_ENABLED=y +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA=y +CONFIG_WPA_MBEDTLS_CRYPTO=y +CONFIG_WPA_MBEDTLS_TLS_CLIENT=y +# CONFIG_WPA_WAPI_PSK is not set +# CONFIG_WPA_SUITE_B_192 is not set +# CONFIG_WPA_11KV_SUPPORT is not set +# CONFIG_WPA_MBO_SUPPORT is not set +# CONFIG_WPA_DPP_SUPPORT is not set +# CONFIG_WPA_11R_SUPPORT is not set +# CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set +# CONFIG_WPA_WPS_STRICT is not set +# CONFIG_WPA_DEBUG_PRINT is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y From a98dea98474c0965cec7169c2e786715d431c8da Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:38:01 -0600 Subject: [PATCH 79/95] Name 6.1.1 in the Wi-Fi password-failure reason comment The reason codes WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT, _AUTH_FAIL and _HANDSHAKE_TIMEOUT keep the values 15, 202 and 204 in ESP-IDF 6.1.1. Co-Authored-By: Claude Sonnet 5.5 --- software/io/wifi/wifi_connect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/io/wifi/wifi_connect.h b/software/io/wifi/wifi_connect.h index 644afb02a..6f8dfd5ad 100644 --- a/software/io/wifi/wifi_connect.h +++ b/software/io/wifi/wifi_connect.h @@ -54,7 +54,7 @@ static inline bool wifi_disconnect_is_radio_start(const void *pkt, int size) // Authentication or the 4-way handshake failed: the access point took the client // for one with the wrong key (WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT, _AUTH_FAIL, -// _HANDSHAKE_TIMEOUT; the same values in ESP-IDF 5.3.1 and 6.0.3) +// _HANDSHAKE_TIMEOUT; the same values in ESP-IDF 5.3.1, 6.0.3 and 6.1.1) static inline bool wifi_disconnect_is_password(uint8_t reason) { return reason == 15 || reason == 202 || reason == 204; From a1f091dcccb3da0c4f402b4b8246aa5d99d8d7ba Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:57:16 -0600 Subject: [PATCH 80/95] Say 6.1.1 in the control module's version history The 1.31 line of the version history said the module was built with ESP-IDF 6.0.3. It is now built with 6.1.1. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/main/rpc_dispatch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/u64ctrl/main/rpc_dispatch.h b/software/u64ctrl/main/rpc_dispatch.h index d5066fe0f..1942a756c 100644 --- a/software/u64ctrl/main/rpc_dispatch.h +++ b/software/u64ctrl/main/rpc_dispatch.h @@ -28,7 +28,7 @@ void send_keepalive(); #define IDENT_STRING "ESP32 WiFi Bridge V1.31" #define IDENT_MAJOR 1 -// 1.31: built with ESP-IDF 6.0.3; the recovery code uses PSA Crypto (mbedTLS 4). +// 1.31: built with ESP-IDF 6.1.1; the recovery code uses PSA Crypto (mbedTLS 4). // 1.29: the idle connector handles every queued command and event before it waits, so a // Disable behind an Enable is not left queued; the wait for its own disconnect is bounded // (3 s); events from before a radio stop are dropped; a CMD_WIFI_CONNECT must hold the From b533543a084b83dfef3d7ef172959269353b9a4b Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:57:16 -0600 Subject: [PATCH 81/95] Leave the Wi-Fi OWE soft-AP support out of the control module ESP-IDF 6.1.1 added CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP, which defaults to y. 6.0.3 had no such option, and the module only runs as a station, so it is set to n to keep the 6.0.3 behavior and not link soft-AP code. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/sdkconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/u64ctrl/sdkconfig b/software/u64ctrl/sdkconfig index 459c78e5d..7c6276447 100644 --- a/software/u64ctrl/sdkconfig +++ b/software/u64ctrl/sdkconfig @@ -1862,7 +1862,7 @@ CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y # default: CONFIG_ESP_WIFI_WPA3_COMPATIBLE_SUPPORT=y # default: -CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP=y +# CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP is not set # default: # CONFIG_ESP_WIFI_PASN_SUPPORT is not set # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set From 1f07e245b27f5125833f1c28143cde1e5af88712 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:58:17 -0600 Subject: [PATCH 82/95] Say 6.1.1 in raw_u64's version history The 1.20 line of the version history said the module was built with ESP-IDF 6.0.3. It is now built with 6.1.1. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/main/rpc_dispatch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/wifi/raw_u64/main/rpc_dispatch.h b/software/wifi/raw_u64/main/rpc_dispatch.h index 652dc1a88..664a8dbaf 100644 --- a/software/wifi/raw_u64/main/rpc_dispatch.h +++ b/software/wifi/raw_u64/main/rpc_dispatch.h @@ -28,7 +28,7 @@ void send_keepalive(); #define IDENT_STRING "ESP32 WiFi Bridge V1.20" #define IDENT_MAJOR 1 -// 1.20: built with ESP-IDF 6.0.3. +// 1.20: built with ESP-IDF 6.1.1. // 1.18: the idle connector handles every queued command and event before it waits, so a // Disable behind an Enable is not left queued; the wait for its own disconnect is bounded // (3 s); events from before a radio stop are dropped; a CMD_WIFI_CONNECT must hold the From c87463c25662293dcc35d8d87ff7609d8c340b9e Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:58:17 -0600 Subject: [PATCH 83/95] Leave the Wi-Fi OWE soft-AP support out of raw_u64 ESP-IDF 6.1.1 added CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP, which defaults to y. 6.0.3 had no such option, and the module only runs as a station, so it is set to n to keep the 6.0.3 behavior and not link soft-AP code. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/sdkconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/wifi/raw_u64/sdkconfig b/software/wifi/raw_u64/sdkconfig index e6cadbaaf..c3c202dfb 100644 --- a/software/wifi/raw_u64/sdkconfig +++ b/software/wifi/raw_u64/sdkconfig @@ -1576,7 +1576,7 @@ CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y # default: CONFIG_ESP_WIFI_WPA3_COMPATIBLE_SUPPORT=y # default: -CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP=y +# CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP is not set # default: # CONFIG_ESP_WIFI_PASN_SUPPORT is not set # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set From d994d2d19bb1a380282b5575a8a1c3408fc11b1c Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:58:53 -0600 Subject: [PATCH 84/95] Say 6.1.1 in raw_c3's version history The 1.13 line of the version history said the module was built with ESP-IDF 6.0.3. It is now built with 6.1.1. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_c3/main/rpc_dispatch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/wifi/raw_c3/main/rpc_dispatch.h b/software/wifi/raw_c3/main/rpc_dispatch.h index 12e88097a..c4db09ea0 100644 --- a/software/wifi/raw_c3/main/rpc_dispatch.h +++ b/software/wifi/raw_c3/main/rpc_dispatch.h @@ -26,7 +26,7 @@ void send_keepalive(); #define IDENT_STRING "ESP32 WiFi Bridge V1.13" #define IDENT_MAJOR 1 -// 1.13: built with ESP-IDF 6.0.3. Labels the image; the U2+L updater does not compare it. +// 1.13: built with ESP-IDF 6.1.1. Labels the image; the U2+L updater does not compare it. // 1.11: the idle connector handles every queued command and event before it waits, so a // Disable behind an Enable is not left queued; the wait for its own disconnect is bounded // (3 s); events from before a radio stop are dropped; a CMD_WIFI_CONNECT must hold the From 23a7db658e6d78bd2331c0f999fccbadda4ed8bb Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:58:54 -0600 Subject: [PATCH 85/95] Leave the Wi-Fi OWE soft-AP support out of raw_c3 ESP-IDF 6.1.1 added CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP, which defaults to y. 6.0.3 had no such option, and the module only runs as a station, so it is set to n to keep the 6.0.3 behavior and not link soft-AP code. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_c3/sdkconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/wifi/raw_c3/sdkconfig b/software/wifi/raw_c3/sdkconfig index c1cd7580a..b6f71d203 100644 --- a/software/wifi/raw_c3/sdkconfig +++ b/software/wifi/raw_c3/sdkconfig @@ -1587,7 +1587,7 @@ CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y # default: CONFIG_ESP_WIFI_WPA3_COMPATIBLE_SUPPORT=y # default: -CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP=y +# CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_SOFTAP is not set # default: # CONFIG_ESP_WIFI_PASN_SUPPORT is not set # CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set From 94bbcfdcc05fb989a185315ff46a3c6523378e42 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:59:16 -0600 Subject: [PATCH 86/95] Carry the raw_u64 Wi-Fi TLS client setting over to the 6.1.1 sdkconfig This branch turns off the supplicant's TLS client. The option is ESP_WIFI_MBEDTLS_TLS_CLIENT in 6.0.3 and in 6.1.1 alike; WPA_MBEDTLS_TLS_CLIENT is its deprecated alias. 6.1.1 writes the deprecated-alias block twice, and the merged sdkconfig held the second copy at y, next to the real option set to off. The first build under 6.1.1 resolved the alias to off and rewrote the file. The file now holds what the build produces, so the setting is the same as before. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/sdkconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/wifi/raw_u64/sdkconfig b/software/wifi/raw_u64/sdkconfig index 37fb0f630..e092b5cf9 100644 --- a/software/wifi/raw_u64/sdkconfig +++ b/software/wifi/raw_u64/sdkconfig @@ -2991,7 +2991,7 @@ CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA=y # CONFIG_ESP_WIFI_NAN_ENABLE is not set CONFIG_WPA_MBEDTLS_CRYPTO=y -CONFIG_WPA_MBEDTLS_TLS_CLIENT=y +# CONFIG_WPA_MBEDTLS_TLS_CLIENT is not set # CONFIG_WPA_WAPI_PSK is not set # CONFIG_WPA_11KV_SUPPORT is not set # CONFIG_WPA_MBO_SUPPORT is not set From f33d11b3865532b23b213f75fbbb223815c44ad2 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:59:57 -0600 Subject: [PATCH 87/95] Name the Mozilla data and mbedTLS source of 6.1.1 in the TLS texts The raw_u64 README gave the date of the Mozilla root list that ESP-IDF ships as that of 6.0.3 (2025-12-02). The list in 6.1.1 is of 2026-02-11. The comment on the entropy draws of the TLS engine named the IDF 6.0.3 copy of mbedTLS 4.1.1; it names 6.1.1 now. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/raw_u64/README.md | 4 ++-- software/wifi/tls/tls_engine.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/software/wifi/raw_u64/README.md b/software/wifi/raw_u64/README.md index b94f04562..6be9402a5 100644 --- a/software/wifi/raw_u64/README.md +++ b/software/wifi/raw_u64/README.md @@ -34,8 +34,8 @@ ESP32 dev board, with a red/green gate: Date: Mon, 16 Nov 2026 15:00:21 -0600 Subject: [PATCH 88/95] Do not pass a null pointer to memcpy for an empty step input fill_step copied the ciphertext and plaintext input of a step with memcpy whatever their length. A step with nothing to send of one kind has a null pointer for it, and memcpy's pointer arguments must not be null even when it copies 0 bytes. Built with UndefinedBehaviorSanitizer, the wifitls host test stopped there ("null pointer passed as argument 2, which is declared to never be null"). Each copy is now made only when its length is not 0. The wifitls and nettls tests pass under the sanitizer. Co-Authored-By: Claude Sonnet 5.5 --- software/io/wifi/wifi_tls.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/software/io/wifi/wifi_tls.cc b/software/io/wifi/wifi_tls.cc index cc8e521af..f2a1344a8 100644 --- a/software/io/wifi/wifi_tls.cc +++ b/software/io/wifi/wifi_tls.cc @@ -419,8 +419,13 @@ static int fill_step(uint8_t *request, void *context) args->tag = c->tag; args->ct_in_len = step->ct_in_len; args->pt_in_len = step->pt_in_len; - memcpy(args->data, step->ct_in, step->ct_in_len); - memcpy(args->data + step->ct_in_len, step->pt_in, step->pt_in_len); + // A step with no input of one kind passes a null pointer for it; memcpy takes none, even for 0 bytes. + if (step->ct_in_len) { + memcpy(args->data, step->ct_in, step->ct_in_len); + } + if (step->pt_in_len) { + memcpy(args->data + step->ct_in_len, step->pt_in, step->pt_in_len); + } return offsetof(rpc_tls_step_req, data) + step->ct_in_len + step->pt_in_len; } From b759883f274e0aee239449983d924bf722fb020e Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 17 Nov 2026 08:34:00 -0600 Subject: [PATCH 89/95] Refuse a TLS 1.2 ServerHello that leaves the session version above 1.2 mbedTLS's TLS 1.2 ServerHello parser takes legacy_version as the session version, so a hello claiming 0x0304 carried on in the TLS 1.3 machine without a key exchange. After a HelloRetryRequest the engine's group check does not catch it. Refuse it at the ServerHello with protocol_version. Host test (host-tls rig): hrr_legacy_version_13 and legacy_version_13. Co-Authored-By: Claude Sonnet 5.5 --- software/wifi/tls/tls_engine.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/software/wifi/tls/tls_engine.c b/software/wifi/tls/tls_engine.c index 55b28c012..64594d1a0 100644 --- a/software/wifi/tls/tls_engine.c +++ b/software/wifi/tls/tls_engine.c @@ -479,8 +479,9 @@ static int tls_sh_ext(const uint8_t *m, size_t len, uint16_t type, const uint8_t // After each successful handshake step: records the negotiated group (no mbedTLS getter) from the TLS 1.3 ServerHello // key_share (or the HelloRetryRequest group) or the TLS 1.2 ServerKeyExchange curve, and requires EMS in a TLS 1.2 -// ServerHello, as mbedTLS has just parsed them. Returns MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE when EMS is not echoed. -static int tls_note_handshake(tls_session_t *s, int state_before, int version_before) +// ServerHello, as mbedTLS has just parsed them. Also refuses a TLS 1.2 ServerHello that left the version above 1.2. +// Returns an mbedTLS error, with r->fail_reason set, when it refuses. +static int tls_note_handshake(tls_session_t *s, int state_before, int version_before, tls_step_result_t *r) { int state = s->ssl.state; const uint8_t *m, *d; @@ -492,6 +493,13 @@ static int tls_note_handshake(tls_session_t *s, int state_before, int version_be s->stats.group = (d[0] << 8) | d[1]; } // Not found: the group stays 0, and tls_handshake() refuses the session + } else if (s->ssl.tls_version != MBEDTLS_SSL_VERSION_TLS1_2) { + // mbedTLS's TLS 1.2 ServerHello parser takes legacy_version as the version (ssl_tls12_client.c:1226), so a + // ServerHello claiming 0x0304 would carry on in the TLS 1.3 machine without a key exchange: refuse it + r->fail_reason = TLS_FAIL_VERSION_REFUSED; + r->verify_flags = (uint16_t)s->ssl.tls_version; + mbedtls_ssl_send_alert_message(&s->ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION); + return MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION; } else if (!s->ems_checked) { // mbedtls_ssl_conf_extended_master_secret() only offers it: a server that does not echo it is accepted // (ssl_tls12_client.c:742-759), so the engine refuses it here, before any key is derived. A ServerHello @@ -500,6 +508,7 @@ static int tls_note_handshake(tls_session_t *s, int state_before, int version_be s->stats.ems = m && (tls_sh_ext(m, len, 23, &d) == 0); if (!s->stats.ems) { ESP_LOGW(TAG, "TLS 1.2 server without the extended master secret: refused"); + r->fail_reason = TLS_FAIL_NO_EMS; mbedtls_ssl_send_alert_message(&s->ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE); return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE; @@ -564,9 +573,8 @@ static int tls_handshake(tls_session_t *s, tls_step_result_t *r) int64_t start = esp_timer_get_time(); int ret = mbedtls_ssl_handshake_step(&s->ssl); s->stats.handshake_us += (uint32_t)(esp_timer_get_time() - start); - int ems = (ret == 0) ? tls_note_handshake(s, state_before, version_before) : 0; + int ems = (ret == 0) ? tls_note_handshake(s, state_before, version_before, r) : 0; if (ems) { - r->fail_reason = TLS_FAIL_NO_EMS; return ems; } if ((ret == MBEDTLS_ERR_SSL_WANT_READ) || (ret == MBEDTLS_ERR_SSL_WANT_WRITE)) { From f2655e3cb998ef5da862bae95d925be4988c2860 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 17 Nov 2026 08:34:32 -0600 Subject: [PATCH 90/95] Disable the elliptic curves the TLS engine does not offer The engine offers x25519, P-256, P-384 and P-521 only; the build also carried secp256k1 and the three Brainpool curves. The roots in the CA store use P-256, P-384 and P-521 (and RSA), so nothing shipped needs the others. Applied to all three module products. Co-Authored-By: Claude Sonnet 5.5 --- software/u64ctrl/sdkconfig | 8 ++++---- software/wifi/raw_c3/sdkconfig | 8 ++++---- software/wifi/raw_u64/sdkconfig | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/software/u64ctrl/sdkconfig b/software/u64ctrl/sdkconfig index 7c6276447..dd2d57b11 100644 --- a/software/u64ctrl/sdkconfig +++ b/software/u64ctrl/sdkconfig @@ -2724,10 +2724,10 @@ CONFIG_MBEDTLS_ECP_C=y CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +# CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED is not set +# CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED is not set +# CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED is not set +# CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED is not set CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y # end of Supported Curves diff --git a/software/wifi/raw_c3/sdkconfig b/software/wifi/raw_c3/sdkconfig index b6f71d203..4bcdd124b 100644 --- a/software/wifi/raw_c3/sdkconfig +++ b/software/wifi/raw_c3/sdkconfig @@ -2445,10 +2445,10 @@ CONFIG_MBEDTLS_ECP_C=y CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +# CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED is not set +# CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED is not set +# CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED is not set +# CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED is not set CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y # end of Supported Curves diff --git a/software/wifi/raw_u64/sdkconfig b/software/wifi/raw_u64/sdkconfig index 121f877d3..2a2211c53 100644 --- a/software/wifi/raw_u64/sdkconfig +++ b/software/wifi/raw_u64/sdkconfig @@ -2444,10 +2444,10 @@ CONFIG_MBEDTLS_ECP_C=y CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +# CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED is not set +# CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED is not set +# CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED is not set +# CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED is not set CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y # end of Supported Curves From ec31688c5677110d2554edc65862682910a454fd Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 17 Nov 2026 08:56:50 -0600 Subject: [PATCH 91/95] Document the TLS 1.3 claim through the 1.2 path under VERSION REFUSED Co-Authored-By: Claude Sonnet 5.5 --- doc/uci_tls.md | 2 +- software/wifi/tls/rpc_tls.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/uci_tls.md b/doc/uci_tls.md index e60774c88..8b1dde6fa 100644 --- a/doc/uci_tls.md +++ b/doc/uci_tls.md @@ -224,7 +224,7 @@ A pending chunk of `$16` is dropped by any other command, as for plain sockets. | 15 | TLS HANDSHAKE TIMEOUT | OPEN | no established session in 15 s, or the 40 s open budget ran out in the handshake | | 16 | TLS SESSION FAILED: -0xNNNN | READ, WRITE | bad record MAC, decode error, too many empty records, KeyUpdate | | 17 | TLS MODULE NOT RESPONDING | any | module timeout, full queue, malformed reply, restart or WRITE stall | -| 18 | TLS VERSION REFUSED: 0xNNNN | OPEN | the ServerHello chose a version not offered (TLS 1.2 under REQUIRE_TLS13, or below 1.2) | +| 18 | TLS VERSION REFUSED: 0xNNNN | OPEN | the ServerHello chose a version not offered (TLS 1.2 under REQUIRE_TLS13, or below 1.2), or a TLS 1.2 ServerHello carried version 0x0304 (TLS 1.3 claimed through the 1.2 path) | | 19 | TLS DOWNGRADE DETECTED | OPEN | a TLS 1.2 ServerHello carrying the RFC 8446 4.1.3 downgrade sentinel | | 81 | INVALID PARAMS | all | layout, lengths, tail grammar, name rule, not a TLS handle for `$23`, bad handle for `$24`, `$22` sequence error, no-reply bit on `$21`/`$24` | | 82 | PARAMETER(S) OUT OF RANGE | all | trust > 2, reserved flag bit, all-zero pin, READ maxlen 0 or > 1472, CA total > 1472 | diff --git a/software/wifi/tls/rpc_tls.h b/software/wifi/tls/rpc_tls.h index 6a0df3914..ec7ae3040 100644 --- a/software/wifi/tls/rpc_tls.h +++ b/software/wifi/tls/rpc_tls.h @@ -51,7 +51,7 @@ typedef enum { // rpc_tls_step_resp.fail_reason, set with FAILED typedef enum { TLS_FAIL_NONE = 0, // generic: esp_err has the mbedTLS code (alert_in the alert, if any) - TLS_FAIL_VERSION_REFUSED = 1, // the ServerHello chose a version not offered; it is in verify_flags' low 16 bits + TLS_FAIL_VERSION_REFUSED = 1, // the ServerHello chose a version not offered, or a TLS 1.2 ServerHello carried 0x0304; it is in verify_flags' low 16 bits TLS_FAIL_DOWNGRADE = 2, // TLS 1.2 chosen by a ServerHello carrying the RFC 8446 downgrade sentinel TLS_FAIL_NO_EMS = 3, // a TLS 1.2 server without the extended master secret TLS_FAIL_CERT_VERIFY = 4, // verify_flags = mbedtls_ssl_get_verify_result(), 0xFFFFFFFF if it never completed From 64da082d4340bebd74b07dfa5b9e688f55fcf1d0 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:15:08 -0600 Subject: [PATCH 92/95] Link network_target_tls.cc into the network target host test network_target.cc dispatches the TLS commands to NetworkTarget::open_tls and four more, which live in network_target_tls.cc, so the network-target test could not link (upstream CI fails "Test Ethernet Transmit Framing" on it). The host build has U64 undefined, so NET_TLS is 0 and the file contributes the "TLS not available" branch the product also uses without the WiFi module; no fakes are needed. Co-Authored-By: Claude Fable 5.2 --- software/io/network/tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/io/network/tests/Makefile b/software/io/network/tests/Makefile index b83afa7d2..4da48ccc3 100644 --- a/software/io/network/tests/Makefile +++ b/software/io/network/tests/Makefile @@ -190,7 +190,7 @@ timeout-pool-red: # Target 3 on its worker task, against loopback peers. network-target: mkdir -p $(OUTPUT_DIR) - $(CXX) $(NETWORK_TARGET_FLAGS) network_target_test.cpp ../network_target.cc -lpthread -o $(NETWORK_TARGET_TEST) \ + $(CXX) $(NETWORK_TARGET_FLAGS) network_target_test.cpp ../network_target.cc ../network_target_tls.cc -lpthread -o $(NETWORK_TARGET_TEST) \ -Wl,--wrap=gethostbyname_r -Wl,--wrap=send -Wl,--wrap=close env -u LD_PRELOAD timeout 60s $(NETWORK_TARGET_TEST) From bd28479d2b381758405841d97e4991fddc84a182 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 24 Nov 2026 06:04:56 -0600 Subject: [PATCH 93/95] Test the TLS version-confusion guard in tls_engine.c on the host Mbed TLS advisory 2026-11 (CVE-2026-115490): a ServerHello without supported_versions, legacy_version 0x0304 and a TLS 1.3 suite moves a client that offers TLS 1.2 and 1.3 into the TLS 1.3 machine with no key exchange. ESP-IDF v6.1.1 ships the affected Mbed TLS 4.1.1. tls_engine.c refuses that ServerHello (fail_reason VERSION_REFUSED, Ultimate status 18) but no test sent it. software/test/tls_engine/tls_guard_test.c includes the unmodified engine, built against the Mbed TLS source in the espressif/idf:v6.1.1 image with stand-ins for ESP-IDF and the entropy gate, and drives it with a scripted attacker (two ServerHello forms) and with honest TLS 1.2 and TLS 1.3 servers as controls. "make test" is green; "make red" builds a copy of the engine with the guard branch disabled and fails the attack checks. Not wired into CI: it needs the IDF image. Co-Authored-By: Claude Fable 5.2 --- software/test/tls_engine/stub/cmd_buffer.h | 0 software/test/tls_engine/stub/esp_err.h | 11 + software/test/tls_engine/stub/esp_heap_caps.h | 4 + software/test/tls_engine/stub/esp_log.h | 7 + software/test/tls_engine/stub/esp_timer.h | 8 + .../test/tls_engine/stub/freertos/FreeRTOS.h | 0 software/test/tls_engine/stub/rpc_calls.h | 15 ++ software/test/tls_engine/stub/sdkconfig.h | 6 + software/test/tls_engine/stub/sntp.h | 1 + software/test/tls_engine/stub/wifi_modem.h | 3 + software/test/tls_engine/stub_rng_gate.c | 4 + software/test/tls_engine/test_cert.h | 37 +++ software/test/tls_engine/test_key.h | 14 + software/test/tls_engine/tls_guard_test.c | 250 ++++++++++++++++++ .../test/tls_engine/tlsguard_mbedtls_config.h | 4 + target/pc/linux/tlsguard/Makefile | 50 ++++ target/pc/linux/tlsguard/build-mbedtls.sh | 18 ++ 17 files changed, 432 insertions(+) create mode 100644 software/test/tls_engine/stub/cmd_buffer.h create mode 100644 software/test/tls_engine/stub/esp_err.h create mode 100644 software/test/tls_engine/stub/esp_heap_caps.h create mode 100644 software/test/tls_engine/stub/esp_log.h create mode 100644 software/test/tls_engine/stub/esp_timer.h create mode 100644 software/test/tls_engine/stub/freertos/FreeRTOS.h create mode 100644 software/test/tls_engine/stub/rpc_calls.h create mode 100644 software/test/tls_engine/stub/sdkconfig.h create mode 100644 software/test/tls_engine/stub/sntp.h create mode 100644 software/test/tls_engine/stub/wifi_modem.h create mode 100644 software/test/tls_engine/stub_rng_gate.c create mode 100644 software/test/tls_engine/test_cert.h create mode 100644 software/test/tls_engine/test_key.h create mode 100644 software/test/tls_engine/tls_guard_test.c create mode 100644 software/test/tls_engine/tlsguard_mbedtls_config.h create mode 100644 target/pc/linux/tlsguard/Makefile create mode 100755 target/pc/linux/tlsguard/build-mbedtls.sh diff --git a/software/test/tls_engine/stub/cmd_buffer.h b/software/test/tls_engine/stub/cmd_buffer.h new file mode 100644 index 000000000..e69de29bb diff --git a/software/test/tls_engine/stub/esp_err.h b/software/test/tls_engine/stub/esp_err.h new file mode 100644 index 000000000..8497af374 --- /dev/null +++ b/software/test/tls_engine/stub/esp_err.h @@ -0,0 +1,11 @@ +#ifndef STUB_ESP_ERR_H +#define STUB_ESP_ERR_H +typedef int esp_err_t; +#define ESP_OK 0 +#define ESP_FAIL (-1) +#define ESP_ERR_NO_MEM 0x101 +#define ESP_ERR_INVALID_ARG 0x102 +#define ESP_ERR_INVALID_STATE 0x103 +#define ESP_ERR_NOT_FOUND 0x105 +#define ESP_ERR_NOT_SUPPORTED 0x106 +#endif diff --git a/software/test/tls_engine/stub/esp_heap_caps.h b/software/test/tls_engine/stub/esp_heap_caps.h new file mode 100644 index 000000000..ebaed95fd --- /dev/null +++ b/software/test/tls_engine/stub/esp_heap_caps.h @@ -0,0 +1,4 @@ +#define MALLOC_CAP_INTERNAL 1 +#define MALLOC_CAP_8BIT 2 +static inline void heap_caps_monitor_local_minimum_free_size_start(void) {} +static inline void heap_caps_monitor_local_minimum_free_size_stop(void) {} diff --git a/software/test/tls_engine/stub/esp_log.h b/software/test/tls_engine/stub/esp_log.h new file mode 100644 index 000000000..366d476a9 --- /dev/null +++ b/software/test/tls_engine/stub/esp_log.h @@ -0,0 +1,7 @@ +#ifndef STUB_ESP_LOG_H +#define STUB_ESP_LOG_H +#include +extern int tlsguard_verbose; +#define ESP_LOGE(tag, ...) do { if (tlsguard_verbose) { fprintf(stderr, "E %s: ", tag); fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } } while (0) +#define ESP_LOGW(tag, ...) do { if (tlsguard_verbose) { fprintf(stderr, "W %s: ", tag); fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } } while (0) +#endif diff --git a/software/test/tls_engine/stub/esp_timer.h b/software/test/tls_engine/stub/esp_timer.h new file mode 100644 index 000000000..a57f4506c --- /dev/null +++ b/software/test/tls_engine/stub/esp_timer.h @@ -0,0 +1,8 @@ +#include +#include +static inline int64_t esp_timer_get_time(void) +{ + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000; +} diff --git a/software/test/tls_engine/stub/freertos/FreeRTOS.h b/software/test/tls_engine/stub/freertos/FreeRTOS.h new file mode 100644 index 000000000..e69de29bb diff --git a/software/test/tls_engine/stub/rpc_calls.h b/software/test/tls_engine/stub/rpc_calls.h new file mode 100644 index 000000000..59571089f --- /dev/null +++ b/software/test/tls_engine/stub/rpc_calls.h @@ -0,0 +1,15 @@ +/* Stand-in for raw_u64/main/rpc_calls.h: only the header type rpc_tls.h builds on. */ +#ifndef STUB_RPC_CALLS_H +#define STUB_RPC_CALLS_H +#include +typedef struct { + uint8_t command; + uint8_t thread; + uint16_t sequence; +} rpc_header_t; +typedef struct { + rpc_header_t hdr; + int esp_err; +} rpc_espcmd_resp; +#include "rpc_tls.h" +#endif diff --git a/software/test/tls_engine/stub/sdkconfig.h b/software/test/tls_engine/stub/sdkconfig.h new file mode 100644 index 000000000..b58cbf3a9 --- /dev/null +++ b/software/test/tls_engine/stub/sdkconfig.h @@ -0,0 +1,6 @@ +/* Host stand-in for the ESP-IDF sdkconfig: what tls_engine.c checks, set as the module's sdkconfig sets it (TLS 1.3 and 1.2, + * time and date, no certificate bundle: the test pins keys). */ +#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 1 +#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 1 +#define CONFIG_MBEDTLS_HAVE_TIME_DATE 1 +#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE 0 diff --git a/software/test/tls_engine/stub/sntp.h b/software/test/tls_engine/stub/sntp.h new file mode 100644 index 000000000..385ad3cdb --- /dev/null +++ b/software/test/tls_engine/stub/sntp.h @@ -0,0 +1 @@ +static inline int sntp_has_time(void) { return 0; } diff --git a/software/test/tls_engine/stub/wifi_modem.h b/software/test/tls_engine/stub/wifi_modem.h new file mode 100644 index 000000000..67a0f07d3 --- /dev/null +++ b/software/test/tls_engine/stub/wifi_modem.h @@ -0,0 +1,3 @@ +/* Stand-in: entropy_source() is radio_entropy.h's. The host draws from the OS, so a source is always there. */ +enum { ENTROPY_NONE = 0, ENTROPY_HOST = 1 }; +static inline int entropy_source(void) { return ENTROPY_HOST; } diff --git a/software/test/tls_engine/stub_rng_gate.c b/software/test/tls_engine/stub_rng_gate.c new file mode 100644 index 000000000..1c1839cc7 --- /dev/null +++ b/software/test/tls_engine/stub_rng_gate.c @@ -0,0 +1,4 @@ +/* Host stand-in for tls_rng_gate.c (the radio's entropy gate): the host has no gate, so no draw is ever refused. */ +#include "tls_rng_gate.h" +void tls_rng_gate_bind_task(void) {} +int tls_rng_gate_take_refusal(void) { return 0; } diff --git a/software/test/tls_engine/test_cert.h b/software/test/tls_engine/test_cert.h new file mode 100644 index 000000000..5a7dad79e --- /dev/null +++ b/software/test/tls_engine/test_cert.h @@ -0,0 +1,37 @@ +static const unsigned char test_cert_der[] = { + 0x30, 0x82, 0x01, 0x96, 0x30, 0x82, 0x01, 0x3b, 0xa0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x14, 0x31, 0xca, 0xde, 0x36, 0x6d, 0x73, 0xb8, 0x76, 0x63, + 0x5d, 0x12, 0x51, 0x02, 0xac, 0x1a, 0xff, 0xae, 0xca, 0x2a, 0x78, 0x30, + 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, + 0x1f, 0x31, 0x1d, 0x30, 0x1b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x14, + 0x74, 0x6c, 0x73, 0x67, 0x75, 0x61, 0x72, 0x64, 0x20, 0x74, 0x65, 0x73, + 0x74, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x30, 0x20, 0x17, 0x0d, + 0x32, 0x36, 0x31, 0x31, 0x32, 0x34, 0x31, 0x32, 0x30, 0x30, 0x34, 0x35, + 0x5a, 0x18, 0x0f, 0x32, 0x31, 0x32, 0x36, 0x31, 0x30, 0x33, 0x31, 0x31, + 0x32, 0x30, 0x30, 0x34, 0x35, 0x5a, 0x30, 0x1f, 0x31, 0x1d, 0x30, 0x1b, + 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x14, 0x74, 0x6c, 0x73, 0x67, 0x75, + 0x61, 0x72, 0x64, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, + 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, + 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x65, 0x1d, 0x2e, 0xbe, 0xbf, 0x37, + 0x19, 0x68, 0x2d, 0x94, 0xbb, 0xe6, 0x56, 0x1f, 0xf1, 0xa5, 0x6f, 0xc7, + 0xd4, 0xbb, 0x80, 0x19, 0x80, 0x69, 0x9b, 0x89, 0x85, 0xaa, 0xca, 0x37, + 0x76, 0x2d, 0x4d, 0xe3, 0xb0, 0xcf, 0xb8, 0xd3, 0x53, 0x7c, 0x5a, 0x07, + 0x55, 0x6f, 0x12, 0x91, 0x87, 0xd8, 0x45, 0x6f, 0xfb, 0x6f, 0x89, 0x50, + 0x30, 0x10, 0x78, 0xb0, 0xb9, 0x4a, 0xc4, 0x46, 0x13, 0x06, 0xa3, 0x53, + 0x30, 0x51, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, + 0x14, 0xa1, 0xf0, 0xf4, 0x4d, 0x32, 0x11, 0x0e, 0x13, 0x57, 0x70, 0x01, + 0x3f, 0xa2, 0x86, 0x35, 0xa8, 0x79, 0xb2, 0x33, 0x33, 0x30, 0x1f, 0x06, + 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xa1, 0xf0, + 0xf4, 0x4d, 0x32, 0x11, 0x0e, 0x13, 0x57, 0x70, 0x01, 0x3f, 0xa2, 0x86, + 0x35, 0xa8, 0x79, 0xb2, 0x33, 0x33, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, + 0x13, 0x01, 0x01, 0xff, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, + 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, + 0x49, 0x00, 0x30, 0x46, 0x02, 0x21, 0x00, 0xba, 0x8c, 0xf8, 0x85, 0xe5, + 0x5c, 0x0c, 0x42, 0x0d, 0xd2, 0x25, 0x13, 0x57, 0x0d, 0xcb, 0x7d, 0x4c, + 0x10, 0x25, 0xcc, 0x2c, 0xdc, 0xac, 0xb8, 0xdd, 0xf7, 0xe2, 0x4a, 0x8a, + 0x20, 0x7c, 0xb0, 0x02, 0x21, 0x00, 0xe6, 0x79, 0xcd, 0xfb, 0x86, 0x28, + 0x68, 0xa9, 0xaf, 0x26, 0xab, 0xd5, 0xfa, 0xd7, 0x37, 0xd6, 0x06, 0xd1, + 0x34, 0xc9, 0x3a, 0x58, 0x00, 0xa7, 0xc0, 0xaa, 0xc3, 0x30, 0xd1, 0x1a, + 0xde, 0x6b, +}; diff --git a/software/test/tls_engine/test_key.h b/software/test/tls_engine/test_key.h new file mode 100644 index 000000000..8ee289121 --- /dev/null +++ b/software/test/tls_engine/test_key.h @@ -0,0 +1,14 @@ +static const unsigned char test_key_der[] = { + 0x30, 0x81, 0x87, 0x02, 0x01, 0x00, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, + 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, + 0x03, 0x01, 0x07, 0x04, 0x6d, 0x30, 0x6b, 0x02, 0x01, 0x01, 0x04, 0x20, + 0xa0, 0xcf, 0x12, 0x7f, 0x32, 0x88, 0x76, 0x53, 0xbc, 0x0d, 0x9c, 0x2e, + 0xcf, 0x53, 0x43, 0xea, 0x3b, 0x0a, 0x34, 0x5a, 0x99, 0x84, 0x97, 0x91, + 0x7c, 0x9e, 0x66, 0x2b, 0xe5, 0x9c, 0xe5, 0x19, 0xa1, 0x44, 0x03, 0x42, + 0x00, 0x04, 0x65, 0x1d, 0x2e, 0xbe, 0xbf, 0x37, 0x19, 0x68, 0x2d, 0x94, + 0xbb, 0xe6, 0x56, 0x1f, 0xf1, 0xa5, 0x6f, 0xc7, 0xd4, 0xbb, 0x80, 0x19, + 0x80, 0x69, 0x9b, 0x89, 0x85, 0xaa, 0xca, 0x37, 0x76, 0x2d, 0x4d, 0xe3, + 0xb0, 0xcf, 0xb8, 0xd3, 0x53, 0x7c, 0x5a, 0x07, 0x55, 0x6f, 0x12, 0x91, + 0x87, 0xd8, 0x45, 0x6f, 0xfb, 0x6f, 0x89, 0x50, 0x30, 0x10, 0x78, 0xb0, + 0xb9, 0x4a, 0xc4, 0x46, 0x13, 0x06, +}; diff --git a/software/test/tls_engine/tls_guard_test.c b/software/test/tls_engine/tls_guard_test.c new file mode 100644 index 000000000..d174a33e8 --- /dev/null +++ b/software/test/tls_engine/tls_guard_test.c @@ -0,0 +1,250 @@ +/* tls_guard_test.c: host test of the TLS version-confusion guard in tls_engine.c (Mbed TLS advisory 2026-11, + * CVE-2026-115490: a ServerHello without supported_versions, legacy_version 0x0304 and a TLS 1.3 suite, sent to a + * client that offers both TLS 1.2 and 1.3, moves mbedTLS 4.1.1 into its TLS 1.3 machine with no key exchange). + * + * The unit under test is tls_engine.c itself, included below so the test can look at the session it holds. Build and + * run with target/pc/linux/tlsguard (make test). The peers are in this file: + * - a scripted attacker that answers the ClientHello with the ServerHello above; + * - an honest mbedTLS server, once limited to TLS 1.2 and once to TLS 1.3 (control: the guard refuses neither). + * Exit status 0 only when every check passes. With the guard compiled out (make red) the attack check fails and the + * test prints what the client did instead. */ + +#include TLS_ENGINE_SRC // the engine under test (default: the tree's own tls_engine.c) + +#include +#include +#include "mbedtls/ssl.h" +#include "mbedtls/x509_crt.h" +#include "mbedtls/pk.h" +#include "psa/crypto.h" +#include "test_cert.h" +#include "test_key.h" + +int tlsguard_verbose; +static int failures; + +#define CHECK(cond, ...) do { if (!(cond)) { failures++; printf(" FAIL: "); printf(__VA_ARGS__); printf("\n"); } \ + else { printf(" ok: "); printf(__VA_ARGS__); printf("\n"); } } while (0) + +static void hexline(const char *label, const uint8_t *p, size_t n) +{ + printf(" %s (%u bytes):", label, (unsigned)n); + for (size_t i = 0; i < n && i < 48; i++) { + printf(" %02x", p[i]); + } + printf(n > 48 ? " ...\n" : "\n"); +} + +// SHA-256 of the test certificate's SubjectPublicKeyInfo: what the engine's PIN trust compares +static void pin_of_test_cert(uint8_t pin[TLS_PIN_LEN]) +{ + mbedtls_x509_crt crt; + mbedtls_x509_crt_init(&crt); + if (mbedtls_x509_crt_parse_der(&crt, test_cert_der, sizeof(test_cert_der)) != 0) { + printf("test certificate does not parse\n"); + exit(2); + } + size_t n = 0; + if (psa_hash_compute(PSA_ALG_SHA_256, crt.pk_raw.p, crt.pk_raw.len, pin, TLS_PIN_LEN, &n) != PSA_SUCCESS) { + exit(2); + } + mbedtls_x509_crt_free(&crt); +} + +static int open_client(void) +{ + uint8_t pin[TLS_PIN_LEN], reason = 0; + pin_of_test_cert(pin); + tls_open_params_t p = { .trust = TLS_TRUST_PIN, .opts = 0, .time_source = TLS_TIME_NONE, .pin = pin, .sni = NULL, .sni_len = 0 }; + tls_close_all(); + return tls_open(0, 1, &p, &reason); +} + +static int client_step(const uint8_t *in, int in_len, uint8_t *out, uint16_t *out_len, tls_step_result_t *r) +{ + uint16_t pt = 0; + return tls_step(0, 1, TLS_STEP_NO_READ, in, in_len, NULL, 0, out, out_len, &pt, r); +} + +// ---- the attacker ----------------------------------------------------------------------------------------------- + +// ServerHello per the advisory: legacy_version 0x0304, a TLS 1.3 suite the client offered, and no supported_versions +// (RFC 8446 4.1.3 would make it mandatory). The session id is echoed as a TLS 1.3 server does. Two forms: with no +// extensions at all, and with the extended_master_secret extension, which a real attacker adds because the engine +// refuses a TLS 1.2 ServerHello without it (a second barrier that would otherwise hide the guard under test). +static size_t build_attack_server_hello(const uint8_t *client_hello_record, uint8_t *out, int with_ems) +{ + const uint8_t *ch = client_hello_record + 5; // handshake header, then the body + const uint8_t *body = ch + 4; + uint8_t sid_len = body[2 + 32]; + const uint8_t *sid = body + 2 + 32 + 1; + uint8_t *p = out + 5 + 4; + *p++ = 0x03; *p++ = 0x04; // legacy_version 0x0304 + for (int i = 0; i < 32; i++) { + *p++ = (uint8_t)(0xA0 + i); // random: no downgrade sentinel + } + *p++ = sid_len; + memcpy(p, sid, sid_len); p += sid_len; + *p++ = 0x13; *p++ = 0x01; // TLS_AES_128_GCM_SHA256, in the client's list + *p++ = 0x00; // compression null + if (with_ems) { // extensions: extended_master_secret only, which the engine's TLS 1.2 + *p++ = 0x00; *p++ = 0x04; // checks demand (tls_note_handshake); still no supported_versions + *p++ = 0x00; *p++ = 0x17; *p++ = 0x00; *p++ = 0x00; + } // else nothing follows: no extensions at all + size_t hs_len = (size_t)(p - (out + 5 + 4)); + out[5] = 2; out[6] = 0; out[7] = (uint8_t)(hs_len >> 8); out[8] = (uint8_t)hs_len; + size_t rec_len = hs_len + 4; + out[0] = 22; out[1] = 3; out[2] = 3; out[3] = (uint8_t)(rec_len >> 8); out[4] = (uint8_t)rec_len; + return rec_len + 5; +} + +// Without the guard: shows that the TLS 1.3 machine takes a plaintext TLS 1.3 Certificate (the attacker holds the pinned +// key here, as the intended server would) and moves on to CertificateVerify, with no key schedule behind it. +static void observe_certificate_path(void) +{ + uint8_t msg[5 + 4 + 1 + 3 + 3 + sizeof(test_cert_der) + 2], out[TLS_STEP_OUT_MAX]; + size_t cl = sizeof(test_cert_der), hl = 1 + 3 + 3 + cl + 2; + uint8_t *p = msg; + *p++ = 22; *p++ = 3; *p++ = 3; *p++ = (uint8_t)((hl + 4) >> 8); *p++ = (uint8_t)(hl + 4); + *p++ = 11; *p++ = 0; *p++ = (uint8_t)(hl >> 8); *p++ = (uint8_t)hl; + *p++ = 0; // certificate_request_context + size_t ll = 3 + cl + 2; + *p++ = 0; *p++ = (uint8_t)(ll >> 8); *p++ = (uint8_t)ll; // certificate_list + *p++ = 0; *p++ = (uint8_t)(cl >> 8); *p++ = (uint8_t)cl; + memcpy(p, test_cert_der, cl); p += cl; + *p++ = 0; *p++ = 0; // no entry extensions + uint16_t out_len = 0; + tls_step_result_t r; + int ret = client_step(msg, (int)(p - msg), out, &out_len, &r); + printf(" OBSERVED (wrong): a plaintext TLS 1.3 Certificate from the attacker: ret=%d state=%d fail_reason=%d, ", ret, r.state, r.fail_reason); + if (sessions[0]) { + printf("ssl.state now %d (%s)\n", sessions[0]->ssl.state, + (sessions[0]->ssl.state == MBEDTLS_SSL_CERTIFICATE_VERIFY && !sessions[0]->pin_mismatch) ? "CERTIFICATE_VERIFY: the certificate was taken, PIN matched" : "?"); + } else { + printf("session freed\n"); + } +} + +static void test_attack(int with_ems) +{ + uint8_t ch[TLS_STEP_OUT_MAX], sh[256], out[TLS_STEP_OUT_MAX]; + uint16_t ch_len = 0, out_len = 0; + tls_step_result_t r; + printf("attack%s: ServerHello, legacy_version 0x0304, suite 0x1301, no supported_versions%s\n", with_ems ? " B" : " A", + with_ems ? ", with extended_master_secret" : ", no extensions"); + CHECK(open_client() == ESP_OK, "client opened (TLS 1.2 + 1.3 offered, PIN trust)"); + int ret = client_step(NULL, 0, ch, &ch_len, &r); + CHECK(ret == 0 && ch_len > 5 && ch[0] == 22 && ch[5] == 1, "ClientHello produced (%u bytes)", ch_len); + size_t sh_len = build_attack_server_hello(ch, sh, with_ems); + hexline("attack ServerHello record", sh, sh_len); + + ret = client_step(sh, (int)sh_len, out, &out_len, &r); + printf(" client result: ret=%d (-0x%04x) state=%d fail_reason=%d verify_flags=0x%x alert_out=%d alert_in=%d\n", ret, + (unsigned)(ret < 0 ? -ret : ret), r.state, r.fail_reason, (unsigned)r.verify_flags, r.alert_out, r.alert_in); + hexline("client output", out, out_len); + if (sessions[0]) { + // Only without the guard. mbedTLS now runs its TLS 1.3 machine on a connection that never had a key exchange. + printf(" OBSERVED (wrong): the session is still live, ssl.tls_version=0x%04x, ssl.state=%d%s, handshake_over=%d\n", + (unsigned)sessions[0]->ssl.tls_version, sessions[0]->ssl.state, + sessions[0]->ssl.state == MBEDTLS_SSL_SERVER_CERTIFICATE ? " (SERVER_CERTIFICATE: EncryptedExtensions skipped)" : "", + mbedtls_ssl_is_handshake_over(&sessions[0]->ssl)); + observe_certificate_path(); + } + CHECK(ret == MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION, "step returns BAD_PROTOCOL_VERSION (got %d)", ret); + CHECK(r.state == TLS_STATE_FAILED, "session state FAILED (got %d)", r.state); + CHECK(r.fail_reason == TLS_FAIL_VERSION_REFUSED, "fail_reason TLS_FAIL_VERSION_REFUSED = Ultimate status 18 (got %d)", r.fail_reason); + CHECK((r.verify_flags & 0xFFFF) == 0x0304, "version reported is 0x0304 (got 0x%x)", (unsigned)(r.verify_flags & 0xFFFF)); + static const uint8_t alert[] = { 0x15, 0x03, 0x03, 0x00, 0x02, 0x02, 0x46 }; // fatal protocol_version + CHECK(r.alert_out == 0x46, "engine reports the unencrypted fatal alert it sent: protocol_version (got %d)", r.alert_out); + CHECK(out_len == sizeof(alert) && !memcmp(out, alert, sizeof(alert)), "the alert record is on the wire to the peer"); + CHECK(sessions[0] == NULL, "session freed"); +} + +// ---- the honest servers (controls) ------------------------------------------------------------------------------ + +typedef struct { uint8_t b[16384]; size_t n; } queue_t; +static queue_t to_client, to_server; + +static int srv_send(void *ctx, const unsigned char *buf, size_t len) +{ + (void)ctx; + memcpy(to_client.b + to_client.n, buf, len); + to_client.n += len; + return (int)len; +} + +static int srv_recv(void *ctx, unsigned char *buf, size_t len) +{ + (void)ctx; + if (to_server.n == 0) { + return MBEDTLS_ERR_SSL_WANT_READ; + } + size_t n = len < to_server.n ? len : to_server.n; + memcpy(buf, to_server.b, n); + memmove(to_server.b, to_server.b + n, to_server.n - n); + to_server.n -= n; + return (int)n; +} + +static void test_honest(int version, const char *name) +{ + printf("control: honest %s server\n", name); + mbedtls_ssl_context srv; + mbedtls_ssl_config conf; + mbedtls_x509_crt crt; + mbedtls_pk_context pk; + mbedtls_ssl_init(&srv); mbedtls_ssl_config_init(&conf); mbedtls_x509_crt_init(&crt); mbedtls_pk_init(&pk); + int ok = (mbedtls_x509_crt_parse_der(&crt, test_cert_der, sizeof(test_cert_der)) == 0) && + (mbedtls_pk_parse_key(&pk, test_key_der, sizeof(test_key_der), NULL, 0) == 0) && + (mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_SERVER, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT) == 0); + if (ok) { + mbedtls_ssl_conf_min_tls_version(&conf, version); + mbedtls_ssl_conf_max_tls_version(&conf, version); + ok = (mbedtls_ssl_conf_own_cert(&conf, &crt, &pk) == 0) && (mbedtls_ssl_setup(&srv, &conf) == 0); + } + CHECK(ok, "server set up"); + mbedtls_ssl_set_bio(&srv, NULL, srv_send, srv_recv, NULL); + to_client.n = to_server.n = 0; + CHECK(open_client() == ESP_OK, "client opened"); + + uint8_t out[TLS_STEP_OUT_MAX]; + uint16_t out_len; + tls_step_result_t r = { .state = TLS_STATE_HANDSHAKING }; + int ret = 0; + for (int i = 0; ok && i < 60 && r.state == TLS_STATE_HANDSHAKING && ret == 0; i++) { + int n = to_client.n < TLS_STEP_IN_MAX ? (int)to_client.n : TLS_STEP_IN_MAX; + ret = client_step(to_client.b, n, out, &out_len, &r); + memmove(to_client.b, to_client.b + n, to_client.n - n); + to_client.n -= n; + memcpy(to_server.b + to_server.n, out, out_len); + to_server.n += out_len; + int sret; + do { + sret = mbedtls_ssl_handshake(&srv); + } while (sret == 0 && !mbedtls_ssl_is_handshake_over(&srv) && to_server.n); + } + CHECK(ret == 0 && r.state == TLS_STATE_ESTABLISHED, "client ESTABLISHED (ret=%d state=%d fail_reason=%d)", ret, r.state, r.fail_reason); + tls_session_stats_t st; + memset(&st, 0, sizeof(st)); + if (tls_get_stats(0, 1, &st) == ESP_OK) { + CHECK(st.tls_version == (version == MBEDTLS_SSL_VERSION_TLS1_3 ? 0x0304 : 0x0303), "negotiated version 0x%04x", st.tls_version); + printf(" suite 0x%04x group 0x%04x\n", st.ciphersuite, st.group); + } + tls_close_all(); + mbedtls_ssl_free(&srv); mbedtls_ssl_config_free(&conf); mbedtls_x509_crt_free(&crt); mbedtls_pk_free(&pk); +} + +int main(int argc, char **argv) +{ + tlsguard_verbose = (argc > 1) && !strcmp(argv[1], "-v"); + printf("Mbed TLS %s\n", MBEDTLS_VERSION_STRING); + if (psa_crypto_init() != PSA_SUCCESS) { + return 2; + } + test_honest(MBEDTLS_SSL_VERSION_TLS1_2, "TLS 1.2"); + test_honest(MBEDTLS_SSL_VERSION_TLS1_3, "TLS 1.3"); + test_attack(1); + test_attack(0); + printf("%s (%d failed checks)\n", failures ? "FAIL" : "PASS", failures); + return failures ? 1 : 0; +} diff --git a/software/test/tls_engine/tlsguard_mbedtls_config.h b/software/test/tls_engine/tlsguard_mbedtls_config.h new file mode 100644 index 000000000..1d0558867 --- /dev/null +++ b/software/test/tls_engine/tlsguard_mbedtls_config.h @@ -0,0 +1,4 @@ +/* MBEDTLS_USER_CONFIG_FILE for the host build of the engine test: Mbed TLS 4.1.1's default configuration, with the one + * option tls_engine.c refuses ("Renegotiation must stay off") that the default turns on. Library and test must be + * built with the same file. */ +#undef MBEDTLS_SSL_RENEGOTIATION diff --git a/target/pc/linux/tlsguard/Makefile b/target/pc/linux/tlsguard/Makefile new file mode 100644 index 000000000..53980d1f8 --- /dev/null +++ b/target/pc/linux/tlsguard/Makefile @@ -0,0 +1,50 @@ +# Host test of the TLS version-confusion guard in software/wifi/tls/tls_engine.c (Mbed TLS advisory 2026-11), device-free. +# tls_engine.c is compiled as is, against Mbed TLS 4.1.1 (the ESP-IDF v6.1.1 submodule) with its default config; ESP-IDF, +# FreeRTOS and the radio entropy gate are stand-ins (software/test/tls_engine/stub). +# make MBEDTLS_SRC= MBEDTLS_LIB= test green: the tree's engine, with its guard +# make ... red red: a copy of the engine with the guard branch disabled +# build-mbedtls.sh (next to this Makefile) builds the library inside the espressif/idf:v6.1.1 image, which carries the source. +OUTPUT = output +RESULT = result + +PATH_SW = ../../../../software +TEST = $(PATH_SW)/test/tls_engine +TLS_DIR = $(PATH_SW)/wifi/tls + +MBEDTLS_SRC ?= mbedtls +MBEDTLS_LIB ?= libmbed.a +ENGINE_SRC ?= $(abspath $(TLS_DIR)/tls_engine.c) + +MBED_INC = -I$(MBEDTLS_SRC)/include -I$(MBEDTLS_SRC)/library -I$(MBEDTLS_SRC)/tf-psa-crypto/include \ + -I$(MBEDTLS_SRC)/tf-psa-crypto/core -I$(MBEDTLS_SRC)/tf-psa-crypto/extras \ + -I$(MBEDTLS_SRC)/tf-psa-crypto/utilities -I$(MBEDTLS_SRC)/tf-psa-crypto/platform \ + -I$(MBEDTLS_SRC)/tf-psa-crypto/dispatch -I$(MBEDTLS_SRC)/tf-psa-crypto/drivers/builtin/include \ + -I$(MBEDTLS_SRC)/tf-psa-crypto/drivers/builtin/src +CFLAGS = -std=gnu11 -DMBEDTLS_USER_CONFIG_FILE=\"tlsguard_mbedtls_config.h\" -g -O0 -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -I$(TEST)/stub -I$(TEST) -I$(TLS_DIR) $(MBED_INC) + +# The guard is the TLS 1.2 ServerHello branch of tls_note_handshake() that tests tls_version; the red copy makes it unreachable. +GUARD_LINE = } else if (s->ssl.tls_version != MBEDTLS_SSL_VERSION_TLS1_2) { + +.PHONY: all test red clean + +all: $(RESULT)/tlsguard + +$(RESULT)/tlsguard: $(TEST)/tls_guard_test.c $(TEST)/stub_rng_gate.c $(ENGINE_SRC) + @mkdir -p $(RESULT) + $(CC) $(CFLAGS) -DTLS_ENGINE_SRC='"$(ENGINE_SRC)"' -o $@ $(TEST)/tls_guard_test.c $(TEST)/stub_rng_gate.c $(MBEDTLS_LIB) + +test: all + env -u LD_PRELOAD ./$(RESULT)/tlsguard + +$(OUTPUT)/tls_engine_noguard.c: $(TLS_DIR)/tls_engine.c + @mkdir -p $(OUTPUT) + @test `grep -cF '$(GUARD_LINE)' $<` = 1 || { echo "guard line not found exactly once"; exit 3; } + sed 's/} else if (s->ssl.tls_version != MBEDTLS_SSL_VERSION_TLS1_2) {/} else if (0 \&\& s->ssl.tls_version != MBEDTLS_SSL_VERSION_TLS1_2) {/' $< > $@ + @test `grep -cF 'else if (0 && s->ssl.tls_version' $@` = 1 || { echo "red copy not made"; exit 3; } + +red: $(OUTPUT)/tls_engine_noguard.c + $(MAKE) ENGINE_SRC=$(abspath $<) RESULT=$(OUTPUT)/red all + -env -u LD_PRELOAD ./$(OUTPUT)/red/tlsguard + +clean: + rm -rf $(OUTPUT) $(RESULT) $(OUTPUT)/red diff --git a/target/pc/linux/tlsguard/build-mbedtls.sh b/target/pc/linux/tlsguard/build-mbedtls.sh new file mode 100755 index 000000000..c914c6520 --- /dev/null +++ b/target/pc/linux/tlsguard/build-mbedtls.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Builds the Mbed TLS the test links against: the ESP-IDF v6.1.1 submodule (4.1.1 plus 18 commits), default config but for +# tlsguard_mbedtls_config.h, as one static lib. Runs in the espressif/idf:v6.1.1 image, which carries the source. +# The submodule copy has no top-level framework/ dir, so upstream's CMake cannot run: the sources are compiled directly. +# usage: build-mbedtls.sh writes /libmbed.a +set -e +OUT=$(mkdir -p "$1" && cd "$1" && pwd) +HERE=$(cd "$(dirname "$0")" && pwd) +CFG=$HERE/../../../../software/test/tls_engine +CFG=$(cd "$CFG" && pwd) +docker run --rm --name tlsguard-mbedbuild -v "$CFG:/cfg:ro" -v "$OUT:/build" espressif/idf:v6.1.1 bash -c ' + set -e; cd /opt/esp/idf/components/mbedtls/mbedtls + INC="-Iinclude -Itf-psa-crypto/dispatch -Itf-psa-crypto/platform -Ilibrary -Itf-psa-crypto/extras -Itf-psa-crypto/include -Itf-psa-crypto/core -Itf-psa-crypto/utilities -Itf-psa-crypto/drivers/builtin/include -Itf-psa-crypto/drivers/builtin/src -Itf-psa-crypto/drivers/everest/include -I/cfg -I/build/shim" + mkdir -p /build/shim/mbedtls /build/obj; echo "/* the tree names these headers in bignum.c and ecp.c and does not ship them */" | tee /build/shim/mbedtls/bignum.h > /build/shim/mbedtls/ecp.h && rm -f /build/obj/*.o + for f in library/*.c tf-psa-crypto/extras/*.c tf-psa-crypto/utilities/*.c tf-psa-crypto/platform/*.c tf-psa-crypto/core/*.c tf-psa-crypto/drivers/builtin/src/*.c; do + gcc -std=c99 -g -O0 -w -D_DEFAULT_SOURCE -DMBEDTLS_USER_CONFIG_FILE=\"tlsguard_mbedtls_config.h\" $INC -c $f -o /build/obj/$(echo $f | tr / _).o || echo "FAIL $f" + done + rm -f /build/libmbed.a; ar rcs /build/libmbed.a /build/obj/*.o; ls -la /build/libmbed.a' From a2a5f4ae2009359c6ff48c2bc363792f28af7101 Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 24 Nov 2026 06:21:11 -0600 Subject: [PATCH 94/95] Report the ServerHello version that was refused, not ssl->tls_version When mbedTLS refuses a ServerHello with BAD_PROTOCOL_VERSION, tls_classify reported ssl->tls_version as the version the server sent. That is the server's version on Mbed TLS 4.1.1 but not on a 4.1.x that has the upstream fix for the legacy_version confusion: the fixed library puts tls_version back to TLS 1.2 before it returns, so a server that sent 0x0304 would have been reported as 0x0303. Take legacy_version from the ServerHello bytes, and the selected version of supported_versions when the message has one, as the REQUIRE_TLS13 branch of the same function already does. ssl->tls_version stays as the fallback for a message that is no longer there. Also correct a comment in tls_note_handshake: the group of a HelloRetryRequest is not recorded. mbedTLS has cleared the message when that step returns, so the group comes from the ServerHello that follows. Co-Authored-By: Claude Fable 5.2 --- software/wifi/tls/tls_engine.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/software/wifi/tls/tls_engine.c b/software/wifi/tls/tls_engine.c index 64594d1a0..1a544dea5 100644 --- a/software/wifi/tls/tls_engine.c +++ b/software/wifi/tls/tls_engine.c @@ -478,7 +478,7 @@ static int tls_sh_ext(const uint8_t *m, size_t len, uint16_t type, const uint8_t } // After each successful handshake step: records the negotiated group (no mbedTLS getter) from the TLS 1.3 ServerHello -// key_share (or the HelloRetryRequest group) or the TLS 1.2 ServerKeyExchange curve, and requires EMS in a TLS 1.2 +// key_share or the TLS 1.2 ServerKeyExchange curve, and requires EMS in a TLS 1.2 // ServerHello, as mbedTLS has just parsed them. Also refuses a TLS 1.2 ServerHello that left the version above 1.2. // Returns an mbedTLS error, with r->fail_reason set, when it refuses. static int tls_note_handshake(tls_session_t *s, int state_before, int version_before, tls_step_result_t *r) @@ -492,7 +492,9 @@ static int tls_note_handshake(tls_session_t *s, int state_before, int version_be if (m && (tls_sh_ext(m, len, 51, &d) >= 2)) { // key_share: the group comes first in both forms s->stats.group = (d[0] << 8) | d[1]; } - // Not found: the group stays 0, and tls_handshake() refuses the session + // Not found: the group stays 0, and tls_handshake() refuses the session. This includes a HelloRetryRequest: + // mbedTLS has already cleared the message when that step returns, so nothing is read from it, and the group + // comes from the ServerHello that follows } else if (s->ssl.tls_version != MBEDTLS_SSL_VERSION_TLS1_2) { // mbedTLS's TLS 1.2 ServerHello parser takes legacy_version as the version (ssl_tls12_client.c:1226), so a // ServerHello claiming 0x0304 would carry on in the TLS 1.3 machine without a key exchange: refuse it @@ -531,9 +533,19 @@ static void tls_classify(tls_session_t *s, int ret, int state_before, int versio } else if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { r->fail_reason = TLS_FAIL_PEER_CLOSED; } else if ((state_before == MBEDTLS_SSL_SERVER_HELLO) && (ret == MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION)) { - // A TLS 1.2 ServerHello below the minimum: the 1.2 parser has set tls_version to the server's choice + // A ServerHello whose version mbedTLS refused. Report the version the server sent, from the message (legacy_version, + // or the selected version of supported_versions when present): ssl->tls_version is not that on every mbedTLS + // (a fixed 4.1.x puts it back to 1.2 before returning), and is the fallback only if the message is gone + size_t len; + const uint8_t *d, *m = tls_hs_msg(s, MBEDTLS_SSL_HS_SERVER_HELLO, &len); r->fail_reason = TLS_FAIL_VERSION_REFUSED; r->verify_flags = (uint16_t)s->ssl.tls_version; + if (m && (len >= 4 + 2 + 32)) { + r->verify_flags = (m[4] << 8) | m[5]; + if (tls_sh_ext(m, len, 43, &d) == 2) { + r->verify_flags = (d[0] << 8) | d[1]; + } + } } else if ((state_before == MBEDTLS_SSL_SERVER_HELLO) && (version_before == MBEDTLS_SSL_VERSION_TLS1_3) && (ret == MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER)) { // This one step is all of mbedTLS's TLS 1.3 ServerHello processing (ssl_tls13_client.c:1995-2060), so From eae99f80fcc6ebc628ed8a73b50f50e40a815d8c Mon Sep 17 00:00:00 2001 From: JC-000 <3798556+JC-000@users.noreply.github.com> Date: Tue, 24 Nov 2026 06:21:20 -0600 Subject: [PATCH 95/95] Make the TLS guard test pass on a fixed Mbed TLS, show the second barrier The guard test now passes on Mbed TLS 4.1.1 and on a 4.1.x with the upstream fix for the legacy_version confusion. It asserts what holds on both: the ServerHello is refused, with a fatal protocol_version alert, the session is freed, and the version reported is the 0x0304 the server sent. A bare Mbed TLS client probes which library is linked and the test prints the case that ran: on 4.1.1 the engine's guard refuses; on the fixed library the library refuses first and the guard is not reached. The guard is defence in depth, an early and specific refusal, and not the only barrier. With the guard disabled, "make test" also drives the whole attack (ServerHello, Certificate, CertificateVerify and Finished, computed from the client's own key schedule) and shows that the engine's end-of-handshake check still refuses ("Negotiated group not found") and the session never reaches ESTABLISHED. That check is a generic refusal with no fail reason, which is what the guard improves on. "make red" builds the engine with the guard disabled and now fails (non-zero) if that build passes on a library that accepts the ServerHello. On the fixed library it reports that it is not applicable. New controls: TLS 1.3 with a HelloRetryRequest (server limited to secp384r1) and a server offering both TLS 1.2 and 1.3 reach ESTABLISHED. build-mbedtls.sh fails on any compile error, uses a unique container name, and can build a scratch copy of the library with a patch applied (MBEDTLS_PATCH). The Makefile header says how to run it (the IDF v6.1.1 image) and how the throwaway test key and certificate were generated. Co-Authored-By: Claude Fable 5.2 --- software/test/tls_engine/stub/esp_log.h | 3 +- software/test/tls_engine/tls_guard_test.c | 230 ++++++++++++++++++++-- target/pc/linux/tlsguard/Makefile | 51 +++-- target/pc/linux/tlsguard/build-mbedtls.sh | 33 +++- 4 files changed, 279 insertions(+), 38 deletions(-) diff --git a/software/test/tls_engine/stub/esp_log.h b/software/test/tls_engine/stub/esp_log.h index 366d476a9..76d59540f 100644 --- a/software/test/tls_engine/stub/esp_log.h +++ b/software/test/tls_engine/stub/esp_log.h @@ -2,6 +2,7 @@ #define STUB_ESP_LOG_H #include extern int tlsguard_verbose; -#define ESP_LOGE(tag, ...) do { if (tlsguard_verbose) { fprintf(stderr, "E %s: ", tag); fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } } while (0) +extern char tlsguard_last_error[160]; // the last ESP_LOGE text, for tests that assert on which check refused +#define ESP_LOGE(tag, ...) do { snprintf(tlsguard_last_error, sizeof(tlsguard_last_error), __VA_ARGS__); if (tlsguard_verbose) { fprintf(stderr, "E %s: ", tag); fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } } while (0) #define ESP_LOGW(tag, ...) do { if (tlsguard_verbose) { fprintf(stderr, "W %s: ", tag); fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } } while (0) #endif diff --git a/software/test/tls_engine/tls_guard_test.c b/software/test/tls_engine/tls_guard_test.c index d174a33e8..9ecd36fdf 100644 --- a/software/test/tls_engine/tls_guard_test.c +++ b/software/test/tls_engine/tls_guard_test.c @@ -3,11 +3,26 @@ * client that offers both TLS 1.2 and 1.3, moves mbedTLS 4.1.1 into its TLS 1.3 machine with no key exchange). * * The unit under test is tls_engine.c itself, included below so the test can look at the session it holds. Build and - * run with target/pc/linux/tlsguard (make test). The peers are in this file: + * run with target/pc/linux/tlsguard (see its Makefile). The peers are in this file: * - a scripted attacker that answers the ClientHello with the ServerHello above; - * - an honest mbedTLS server, once limited to TLS 1.2 and once to TLS 1.3 (control: the guard refuses neither). - * Exit status 0 only when every check passes. With the guard compiled out (make red) the attack check fails and the - * test prints what the client did instead. */ + * - honest mbedTLS servers (TLS 1.2 only, TLS 1.3 only, TLS 1.3 with a HelloRetryRequest, and one offering both): + * controls, the guard refuses none of them. + * + * What it asserts, on Mbed TLS 4.1.1 and on a 4.1.x that has the upstream fix, alike: the handshake is refused at the + * ServerHello, with a fatal protocol_version alert, the session is freed, and the version reported to the Ultimate is + * the 0x0304 the server sent. Which layer refuses differs: on 4.1.1 the engine's guard (the library accepts the + * ServerHello); on the fixed library the library does, before the guard is reached. The test probes the linked library + * with a bare client and prints which case ran. + * + * The guard is defence in depth and an early, specific refusal, not the only barrier: with the guard compiled out + * (make red) the ServerHello is accepted, but the handshake still cannot end ESTABLISHED, because the engine's + * end-of-handshake check finds no negotiated group. The "barrier" mode of this test shows that, on the guard-disabled + * build, by driving the whole attack (Certificate, CertificateVerify and Finished, computed from the client's own + * key schedule, which has no secret in it). + * + * Usage: tlsguard [-v] the guard checks and the controls; exit status 0 only when every check passes + * tlsguard barrier only on the guard-disabled build: the second barrier; "make test" runs it + * With the guard compiled out the guard checks fail (make red expects that) and the test prints what the client did. */ #include TLS_ENGINE_SRC // the engine under test (default: the tree's own tls_engine.c) @@ -19,8 +34,12 @@ #include "psa/crypto.h" #include "test_cert.h" #include "test_key.h" +#include "ssl_misc.h" +#include "ssl_tls13_keys.h" +#include "mbedtls/md.h" int tlsguard_verbose; +char tlsguard_last_error[160]; static int failures; #define CHECK(cond, ...) do { if (!(cond)) { failures++; printf(" FAIL: "); printf(__VA_ARGS__); printf("\n"); } \ @@ -99,7 +118,8 @@ static size_t build_attack_server_hello(const uint8_t *client_hello_record, uint } // Without the guard: shows that the TLS 1.3 machine takes a plaintext TLS 1.3 Certificate (the attacker holds the pinned -// key here, as the intended server would) and moves on to CertificateVerify, with no key schedule behind it. +// key here, as the intended server would) and moves on to CertificateVerify, with no key exchange behind it. The +// handshake is not established by this: see test_second_barrier for how it ends. static void observe_certificate_path(void) { uint8_t msg[5 + 4 + 1 + 3 + 3 + sizeof(test_cert_der) + 2], out[TLS_STEP_OUT_MAX]; @@ -116,7 +136,7 @@ static void observe_certificate_path(void) uint16_t out_len = 0; tls_step_result_t r; int ret = client_step(msg, (int)(p - msg), out, &out_len, &r); - printf(" OBSERVED (wrong): a plaintext TLS 1.3 Certificate from the attacker: ret=%d state=%d fail_reason=%d, ", ret, r.state, r.fail_reason); + printf(" OBSERVED without the guard: a plaintext TLS 1.3 Certificate from the attacker: ret=%d state=%d fail_reason=%d, ", ret, r.state, r.fail_reason); if (sessions[0]) { printf("ssl.state now %d (%s)\n", sessions[0]->ssl.state, (sessions[0]->ssl.state == MBEDTLS_SSL_CERTIFICATE_VERIFY && !sessions[0]->pin_mismatch) ? "CERTIFICATE_VERIFY: the certificate was taken, PIN matched" : "?"); @@ -143,8 +163,9 @@ static void test_attack(int with_ems) (unsigned)(ret < 0 ? -ret : ret), r.state, r.fail_reason, (unsigned)r.verify_flags, r.alert_out, r.alert_in); hexline("client output", out, out_len); if (sessions[0]) { - // Only without the guard. mbedTLS now runs its TLS 1.3 machine on a connection that never had a key exchange. - printf(" OBSERVED (wrong): the session is still live, ssl.tls_version=0x%04x, ssl.state=%d%s, handshake_over=%d\n", + // Only without the guard (and on an unfixed library). mbedTLS now runs its TLS 1.3 machine on a connection that + // never had a key exchange; the handshake is not over, and does not end ESTABLISHED (see test_second_barrier). + printf(" OBSERVED without the guard: the session is still live, ssl.tls_version=0x%04x, ssl.state=%d%s, handshake_over=%d\n", (unsigned)sessions[0]->ssl.tls_version, sessions[0]->ssl.state, sessions[0]->ssl.state == MBEDTLS_SSL_SERVER_CERTIFICATE ? " (SERVER_CERTIFICATE: EncryptedExtensions skipped)" : "", mbedtls_ssl_is_handshake_over(&sessions[0]->ssl)); @@ -186,7 +207,9 @@ static int srv_recv(void *ctx, unsigned char *buf, size_t len) return (int)n; } -static void test_honest(int version, const char *name) +// min/max: the server's TLS versions; groups: its supported groups (NULL: the default, so no HelloRetryRequest); +// want_version/want_group: what the client must report (group 0: only that one is set) +static void test_honest(const char *name, int min_v, int max_v, const uint16_t *groups, uint16_t want_version, uint16_t want_group) { printf("control: honest %s server\n", name); mbedtls_ssl_context srv; @@ -198,8 +221,11 @@ static void test_honest(int version, const char *name) (mbedtls_pk_parse_key(&pk, test_key_der, sizeof(test_key_der), NULL, 0) == 0) && (mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_SERVER, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT) == 0); if (ok) { - mbedtls_ssl_conf_min_tls_version(&conf, version); - mbedtls_ssl_conf_max_tls_version(&conf, version); + mbedtls_ssl_conf_min_tls_version(&conf, min_v); + mbedtls_ssl_conf_max_tls_version(&conf, max_v); + if (groups) { + mbedtls_ssl_conf_groups(&conf, groups); + } ok = (mbedtls_ssl_conf_own_cert(&conf, &crt, &pk) == 0) && (mbedtls_ssl_setup(&srv, &conf) == 0); } CHECK(ok, "server set up"); @@ -227,24 +253,196 @@ static void test_honest(int version, const char *name) tls_session_stats_t st; memset(&st, 0, sizeof(st)); if (tls_get_stats(0, 1, &st) == ESP_OK) { - CHECK(st.tls_version == (version == MBEDTLS_SSL_VERSION_TLS1_3 ? 0x0304 : 0x0303), "negotiated version 0x%04x", st.tls_version); + CHECK(st.tls_version == want_version, "negotiated version 0x%04x (want 0x%04x)", st.tls_version, want_version); + CHECK(want_group ? st.group == want_group : st.group != 0, "negotiated group 0x%04x%s", st.group, want_group ? "" : " (not 0)"); printf(" suite 0x%04x group 0x%04x\n", st.ciphersuite, st.group); } tls_close_all(); mbedtls_ssl_free(&srv); mbedtls_ssl_config_free(&conf); mbedtls_x509_crt_free(&crt); mbedtls_pk_free(&pk); } +// ---- which library is linked ------------------------------------------------------------------------------------- + +static uint8_t probe_out[TLS_STEP_OUT_MAX * 2]; +static size_t probe_out_n; +static const uint8_t *probe_in; +static size_t probe_in_n; + +static int probe_send(void *ctx, const unsigned char *buf, size_t len) +{ + (void)ctx; + memcpy(probe_out + probe_out_n, buf, len); + probe_out_n += len; + return (int)len; +} + +static int probe_recv(void *ctx, unsigned char *buf, size_t len) +{ + (void)ctx; + if (probe_in_n == 0) { + return MBEDTLS_ERR_SSL_WANT_READ; + } + size_t n = len < probe_in_n ? len : probe_in_n; + memcpy(buf, probe_in, n); + probe_in += n; + probe_in_n -= n; + return (int)n; +} + +// Sends the attack ServerHello to a bare Mbed TLS client (TLS 1.2 + 1.3, no engine) and returns 1 when the library +// itself refuses it (BAD_PROTOCOL_VERSION: the upstream fix), 0 when it takes it (4.1.1: only the guard stops it) +static int library_refuses_first(void) +{ + mbedtls_ssl_context ssl; + mbedtls_ssl_config conf; + mbedtls_ssl_init(&ssl); mbedtls_ssl_config_init(&conf); + int ok = (mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT) == 0); + if (ok) { + mbedtls_ssl_conf_authmode(&conf, MBEDTLS_SSL_VERIFY_NONE); + ok = (mbedtls_ssl_setup(&ssl, &conf) == 0); + } + int ret = -1; + for (int i = 0; ok && i < 10 && ssl.state != MBEDTLS_SSL_SERVER_HELLO; i++) { + mbedtls_ssl_set_bio(&ssl, NULL, probe_send, probe_recv, NULL); + ret = mbedtls_ssl_handshake_step(&ssl); + ok = (ret == 0); + } + uint8_t sh[256]; + if (ok && mbedtls_ssl_flush_output(&ssl) != 0) { // the ClientHello is sent by the next step: flush it + ok = 0; + } + if (ok && probe_out_n > 9 && probe_out[0] == 22 && probe_out[5] == 1) { + probe_in_n = build_attack_server_hello(probe_out, sh, 1); + probe_in = sh; + // the first step may only switch from the TLS 1.3 to the TLS 1.2 parser (no supported_versions): step on + for (int i = 0; i < 4 && ret == 0 && ssl.state == MBEDTLS_SSL_SERVER_HELLO; i++) { + ret = mbedtls_ssl_handshake_step(&ssl); + } + } else { + ok = 0; + } + mbedtls_ssl_free(&ssl); mbedtls_ssl_config_free(&conf); + if (!ok || (ret != 0 && ret != MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION)) { + printf("library probe inconclusive (ret=-0x%04x)\n", (unsigned)(ret < 0 ? -ret : ret)); + exit(2); + } + return ret == MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION; +} + +// ---- the second barrier (guard-disabled build only) ------------------------------------------------------------- + +// Drives the attack as far as it goes, as an attacker that holds the pinned key and computes Finished from the client's +// own key schedule (public: no key exchange went into it). Then the engine's end-of-handshake check must refuse. +static void test_second_barrier(void) +{ + uint8_t ch[TLS_STEP_OUT_MAX], sh[256], out[TLS_STEP_OUT_MAX], msg[2048]; + uint16_t ch_len = 0, out_len = 0; + tls_step_result_t r; + printf("second barrier (guard disabled): the full attack, ServerHello B then Certificate, CertificateVerify, Finished\n"); + CHECK(open_client() == ESP_OK, "client opened"); + int ret = client_step(NULL, 0, ch, &ch_len, &r); + CHECK(ret == 0 && ch_len > 5 && ch[0] == 22 && ch[5] == 1, "ClientHello produced (%u bytes)", ch_len); + size_t sh_len = build_attack_server_hello(ch, sh, 1); + ret = client_step(sh, (int)sh_len, out, &out_len, &r); + CHECK(ret == 0 && sessions[0], "ServerHello accepted (ret=%d): this is the guard-disabled build", ret); + if (ret != 0 || !sessions[0]) { + return; + } + CHECK(sessions[0]->ssl.tls_version == MBEDTLS_SSL_VERSION_TLS1_3, "mbedTLS is in its TLS 1.3 machine (0x%04x)", (unsigned)sessions[0]->ssl.tls_version); + mbedtls_ssl_context *ssl = &sessions[0]->ssl; + + size_t cl = sizeof(test_cert_der), hl = 1 + 3 + 3 + cl + 2, ll = 3 + cl + 2; + uint8_t *p = msg; + *p++ = 22; *p++ = 3; *p++ = 3; *p++ = (uint8_t)((hl + 4) >> 8); *p++ = (uint8_t)(hl + 4); + *p++ = 11; *p++ = 0; *p++ = (uint8_t)(hl >> 8); *p++ = (uint8_t)hl; *p++ = 0; + *p++ = 0; *p++ = (uint8_t)(ll >> 8); *p++ = (uint8_t)ll; + *p++ = 0; *p++ = (uint8_t)(cl >> 8); *p++ = (uint8_t)cl; + memcpy(p, test_cert_der, cl); p += cl; + *p++ = 0; *p++ = 0; + ret = client_step(msg, (int)(p - msg), out, &out_len, &r); + CHECK(ret == 0 && sessions[0], "Certificate accepted (PIN matched), ret=%d", ret); + if (ret != 0 || !sessions[0]) { + return; + } + + // CertificateVerify over the client's own transcript hash + uint8_t th[32], tbs[64 + 33 + 1 + 32], hash[32], sig[128]; + size_t thl = 0, sl = 0, hn = 0; + mbedtls_pk_context pk; + mbedtls_pk_init(&pk); + memset(tbs, 0x20, 64); memcpy(tbs + 64, "TLS 1.3, server CertificateVerify", 33); tbs[97] = 0; + int ok = (mbedtls_ssl_get_handshake_transcript(ssl, MBEDTLS_MD_SHA256, th, sizeof(th), &thl) == 0) && (thl == 32); + memcpy(tbs + 98, th, 32); + ok = ok && (psa_hash_compute(PSA_ALG_SHA_256, tbs, sizeof(tbs), hash, 32, &hn) == PSA_SUCCESS) && + (mbedtls_pk_parse_key(&pk, test_key_der, sizeof(test_key_der), NULL, 0) == 0) && + (mbedtls_pk_sign(&pk, MBEDTLS_MD_SHA256, hash, 32, sig, sizeof(sig), &sl) == 0); + mbedtls_pk_free(&pk); + CHECK(ok, "attacker signed the CertificateVerify"); + if (!ok) { + return; + } + hl = 2 + 2 + sl; + p = msg; + *p++ = 22; *p++ = 3; *p++ = 3; *p++ = (uint8_t)((hl + 4) >> 8); *p++ = (uint8_t)(hl + 4); + *p++ = 15; *p++ = 0; *p++ = (uint8_t)(hl >> 8); *p++ = (uint8_t)hl; *p++ = 4; *p++ = 3; *p++ = (uint8_t)(sl >> 8); *p++ = (uint8_t)sl; + memcpy(p, sig, sl); p += sl; + ret = client_step(msg, (int)(p - msg), out, &out_len, &r); + CHECK(ret == 0 && sessions[0], "CertificateVerify accepted, ret=%d", ret); + if (ret != 0 || !sessions[0]) { + return; + } + + // Finished, from the client's own key schedule + uint8_t vd[64]; + size_t vl = 0; + ok = (mbedtls_ssl_tls13_calculate_verify_data(ssl, vd, sizeof(vd), &vl, MBEDTLS_SSL_IS_SERVER) == 0) && (vl <= 48); + CHECK(ok, "attacker computed the Finished verify data (%u bytes)", (unsigned)vl); + if (!ok) { + return; + } + CHECK(sessions[0]->stats.group == 0, "no negotiated group was ever recorded (group 0x%04x)", sessions[0]->stats.group); + p = msg; + *p++ = 22; *p++ = 3; *p++ = 3; *p++ = (uint8_t)((vl + 4) >> 8); *p++ = (uint8_t)(vl + 4); + *p++ = 20; *p++ = 0; *p++ = 0; *p++ = (uint8_t)vl; + memcpy(p, vd, vl); p += vl; + ret = client_step(msg, (int)(p - msg), out, &out_len, &r); + printf(" client result: ret=%d (-0x%04x) state=%d fail_reason=%d\n", ret, (unsigned)(ret < 0 ? -ret : ret), r.state, r.fail_reason); + CHECK(ret == MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE, "end of the handshake refused: 'Negotiated group not found' (got %d)", ret); + CHECK(strstr(tlsguard_last_error, "Negotiated group not found") != NULL, "the engine logged: %s", tlsguard_last_error); + CHECK(r.state == TLS_STATE_FAILED && r.state != TLS_STATE_ESTABLISHED, "session FAILED, never ESTABLISHED (state %d)", r.state); + CHECK(r.fail_reason == 0, "no specific reason: this is the late, generic refusal, not the guard's (got %d)", r.fail_reason); + CHECK(sessions[0] == NULL, "session freed"); +} + int main(int argc, char **argv) { + int barrier = (argc > 1) && !strcmp(argv[1], "barrier"); tlsguard_verbose = (argc > 1) && !strcmp(argv[1], "-v"); printf("Mbed TLS %s\n", MBEDTLS_VERSION_STRING); if (psa_crypto_init() != PSA_SUCCESS) { return 2; } - test_honest(MBEDTLS_SSL_VERSION_TLS1_2, "TLS 1.2"); - test_honest(MBEDTLS_SSL_VERSION_TLS1_3, "TLS 1.3"); - test_attack(1); - test_attack(0); + int lib_first = library_refuses_first(); + if (lib_first) { + printf("case: library refuses first (the linked Mbed TLS refuses the ServerHello itself; the guard is not reached)\n"); + } else { + printf("case: engine guard refuses (the linked Mbed TLS accepts the ServerHello; only the guard stops it)\n"); + } + if (barrier) { + if (lib_first) { + printf("second barrier: not applicable: library refuses first\n"); + return 0; + } + test_second_barrier(); + } else { + static const uint16_t g384[] = { MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1, MBEDTLS_SSL_IANA_TLS_GROUP_NONE }; + test_honest("TLS 1.2", MBEDTLS_SSL_VERSION_TLS1_2, MBEDTLS_SSL_VERSION_TLS1_2, NULL, 0x0303, 0); + test_honest("TLS 1.3", MBEDTLS_SSL_VERSION_TLS1_3, MBEDTLS_SSL_VERSION_TLS1_3, NULL, 0x0304, 0); + test_honest("TLS 1.3 with HelloRetryRequest (secp384r1 only)", MBEDTLS_SSL_VERSION_TLS1_3, MBEDTLS_SSL_VERSION_TLS1_3, g384, 0x0304, 0x0018); + test_honest("dual TLS 1.2 + 1.3", MBEDTLS_SSL_VERSION_TLS1_2, MBEDTLS_SSL_VERSION_TLS1_3, NULL, 0x0304, 0); + test_attack(1); + test_attack(0); + } printf("%s (%d failed checks)\n", failures ? "FAIL" : "PASS", failures); return failures ? 1 : 0; } diff --git a/target/pc/linux/tlsguard/Makefile b/target/pc/linux/tlsguard/Makefile index 53980d1f8..6075fdfdc 100644 --- a/target/pc/linux/tlsguard/Makefile +++ b/target/pc/linux/tlsguard/Makefile @@ -1,9 +1,28 @@ # Host test of the TLS version-confusion guard in software/wifi/tls/tls_engine.c (Mbed TLS advisory 2026-11), device-free. # tls_engine.c is compiled as is, against Mbed TLS 4.1.1 (the ESP-IDF v6.1.1 submodule) with its default config; ESP-IDF, -# FreeRTOS and the radio entropy gate are stand-ins (software/test/tls_engine/stub). -# make MBEDTLS_SRC= MBEDTLS_LIB= test green: the tree's engine, with its guard -# make ... red red: a copy of the engine with the guard branch disabled -# build-mbedtls.sh (next to this Makefile) builds the library inside the espressif/idf:v6.1.1 image, which carries the source. +# FreeRTOS and the radio entropy gate are stand-ins (software/test/tls_engine/stub). Not part of CI: it needs the IDF image. +# +# How to run (from the repository root; Docker must be able to mount the paths, so use a directory under $HOME): +# LIB=$HOME/tlsguard-lib +# target/pc/linux/tlsguard/build-mbedtls.sh $LIB/411 # Mbed TLS 4.1.1 as in the IDF v6.1.1 image +# MBEDTLS_PATCH= target/pc/linux/tlsguard/build-mbedtls.sh $LIB/fixed # optional: a 4.1.x with the upstream fix +# docker run --rm -v "$PWD:/w" -v "$LIB/411:/build" espressif/idf:v6.1.1 bash -c \ +# 'cd /w/target/pc/linux/tlsguard && make MBEDTLS_SRC=/opt/esp/idf/components/mbedtls/mbedtls MBEDTLS_LIB=/build/libmbed.a test red' +# (MBEDTLS_SRC is the source inside the image, for the headers; MBEDTLS_LIB is the library built above. For the fixed +# library mount $LIB/fixed on /build instead; the headers are the same.) +# +# make test the guard test (default mode) on the tree's engine, then the "barrier" mode on a copy of the engine with the +# guard disabled (the second barrier). Exit 0 only if both pass, on 4.1.1 and on the fixed library alike. +# make red the guard test on that guard-disabled copy: on 4.1.1 it must FAIL (the guard is what stops the attack), and +# make red exits non-zero if it passes. On the fixed library the library refuses before the guard is reached, +# so red is not applicable; it says so and exits 0. +# +# test_key.h and test_cert.h are a throwaway test key (EC P-256, PKCS#8 DER) and its self-signed certificate; the key +# protects nothing. Generated with: +# openssl ecparam -name prime256v1 -genkey -noout | openssl pkcs8 -topk8 -nocrypt -outform der -out key.der +# openssl req -new -x509 -key key.der -keyform der -subj "/CN=tlsguard test server" -days 36500 -sha256 -outform der -out cert.der +# xxd -i key.der | sed 's/unsigned char key_der/static const unsigned char test_key_der/' > test_key.h +# xxd -i cert.der | sed 's/unsigned char cert_der/static const unsigned char test_cert_der/' > test_cert.h OUTPUT = output RESULT = result @@ -25,16 +44,17 @@ CFLAGS = -std=gnu11 -DMBEDTLS_USER_CONFIG_FILE=\"tlsguard_mbedtls_config.h\" -g # The guard is the TLS 1.2 ServerHello branch of tls_note_handshake() that tests tls_version; the red copy makes it unreachable. GUARD_LINE = } else if (s->ssl.tls_version != MBEDTLS_SSL_VERSION_TLS1_2) { -.PHONY: all test red clean +.PHONY: all test noguard red clean all: $(RESULT)/tlsguard -$(RESULT)/tlsguard: $(TEST)/tls_guard_test.c $(TEST)/stub_rng_gate.c $(ENGINE_SRC) +$(RESULT)/tlsguard: $(TEST)/tls_guard_test.c $(TEST)/stub_rng_gate.c $(ENGINE_SRC) $(MBEDTLS_LIB) @mkdir -p $(RESULT) $(CC) $(CFLAGS) -DTLS_ENGINE_SRC='"$(ENGINE_SRC)"' -o $@ $(TEST)/tls_guard_test.c $(TEST)/stub_rng_gate.c $(MBEDTLS_LIB) -test: all - env -u LD_PRELOAD ./$(RESULT)/tlsguard +test: all noguard + ./$(RESULT)/tlsguard + ./$(OUTPUT)/red/tlsguard barrier $(OUTPUT)/tls_engine_noguard.c: $(TLS_DIR)/tls_engine.c @mkdir -p $(OUTPUT) @@ -42,9 +62,18 @@ $(OUTPUT)/tls_engine_noguard.c: $(TLS_DIR)/tls_engine.c sed 's/} else if (s->ssl.tls_version != MBEDTLS_SSL_VERSION_TLS1_2) {/} else if (0 \&\& s->ssl.tls_version != MBEDTLS_SSL_VERSION_TLS1_2) {/' $< > $@ @test `grep -cF 'else if (0 && s->ssl.tls_version' $@` = 1 || { echo "red copy not made"; exit 3; } -red: $(OUTPUT)/tls_engine_noguard.c +noguard: $(OUTPUT)/tls_engine_noguard.c $(MAKE) ENGINE_SRC=$(abspath $<) RESULT=$(OUTPUT)/red all - -env -u LD_PRELOAD ./$(OUTPUT)/red/tlsguard + +# RED must be red: the guard-disabled build has to fail the attack checks. If the library refuses the ServerHello itself +# (a fixed Mbed TLS) the guard is never reached and the comparison means nothing: say so. +red: noguard + @./$(OUTPUT)/red/tlsguard > $(OUTPUT)/red.log; rc=$$?; cat $(OUTPUT)/red.log; \ + if grep -q '^case: library refuses first' $(OUTPUT)/red.log; then \ + echo "RED: not applicable: library refuses first (the guard is not reached on this Mbed TLS)"; exit 0; \ + elif [ $$rc -eq 0 ]; then \ + echo "RED IS NOT RED: the guard-disabled build passed on an Mbed TLS that accepts the ServerHello"; exit 1; \ + else echo "RED is red as expected: the guard-disabled build fails ($$rc)"; exit 0; fi clean: - rm -rf $(OUTPUT) $(RESULT) $(OUTPUT)/red + rm -rf $(OUTPUT) $(RESULT) diff --git a/target/pc/linux/tlsguard/build-mbedtls.sh b/target/pc/linux/tlsguard/build-mbedtls.sh index c914c6520..2e47e78e9 100755 --- a/target/pc/linux/tlsguard/build-mbedtls.sh +++ b/target/pc/linux/tlsguard/build-mbedtls.sh @@ -2,17 +2,30 @@ # Builds the Mbed TLS the test links against: the ESP-IDF v6.1.1 submodule (4.1.1 plus 18 commits), default config but for # tlsguard_mbedtls_config.h, as one static lib. Runs in the espressif/idf:v6.1.1 image, which carries the source. # The submodule copy has no top-level framework/ dir, so upstream's CMake cannot run: the sources are compiled directly. -# usage: build-mbedtls.sh writes /libmbed.a +# usage: [MBEDTLS_PATCH=] build-mbedtls.sh writes /libmbed.a +# With MBEDTLS_PATCH (a unified diff, -p1 against the Mbed TLS tree) the build is of a scratch copy of the tree with the +# diff applied, e.g. a fixed 4.1.x, so the test can be run against a library that refuses the ServerHello itself. +# Any compile or patch error fails the script. set -e OUT=$(mkdir -p "$1" && cd "$1" && pwd) HERE=$(cd "$(dirname "$0")" && pwd) -CFG=$HERE/../../../../software/test/tls_engine -CFG=$(cd "$CFG" && pwd) -docker run --rm --name tlsguard-mbedbuild -v "$CFG:/cfg:ro" -v "$OUT:/build" espressif/idf:v6.1.1 bash -c ' - set -e; cd /opt/esp/idf/components/mbedtls/mbedtls +CFG=$(cd "$HERE/../../../../software/test/tls_engine" && pwd) +PATCH_MOUNT=() +PATCH_PATH= +if [ -n "$MBEDTLS_PATCH" ]; then + PATCH_MOUNT=(-v "$(cd "$(dirname "$MBEDTLS_PATCH")" && pwd)/$(basename "$MBEDTLS_PATCH"):/patch.diff:ro") + PATCH_PATH=/patch.diff +fi +docker run --rm --name "tlsguard2-mbedbuild-$$" -e PATCH_PATH="$PATCH_PATH" "${PATCH_MOUNT[@]}" \ + -v "$CFG:/cfg:ro" -v "$OUT:/build" espressif/idf:v6.1.1 bash -c ' + set -e + SRC=/opt/esp/idf/components/mbedtls/mbedtls + if [ -n "$PATCH_PATH" ]; then rm -rf /tmp/src && cp -r $SRC /tmp/src && SRC=/tmp/src && (cd $SRC && patch -p1 < $PATCH_PATH); fi + cd $SRC INC="-Iinclude -Itf-psa-crypto/dispatch -Itf-psa-crypto/platform -Ilibrary -Itf-psa-crypto/extras -Itf-psa-crypto/include -Itf-psa-crypto/core -Itf-psa-crypto/utilities -Itf-psa-crypto/drivers/builtin/include -Itf-psa-crypto/drivers/builtin/src -Itf-psa-crypto/drivers/everest/include -I/cfg -I/build/shim" - mkdir -p /build/shim/mbedtls /build/obj; echo "/* the tree names these headers in bignum.c and ecp.c and does not ship them */" | tee /build/shim/mbedtls/bignum.h > /build/shim/mbedtls/ecp.h && rm -f /build/obj/*.o - for f in library/*.c tf-psa-crypto/extras/*.c tf-psa-crypto/utilities/*.c tf-psa-crypto/platform/*.c tf-psa-crypto/core/*.c tf-psa-crypto/drivers/builtin/src/*.c; do - gcc -std=c99 -g -O0 -w -D_DEFAULT_SOURCE -DMBEDTLS_USER_CONFIG_FILE=\"tlsguard_mbedtls_config.h\" $INC -c $f -o /build/obj/$(echo $f | tr / _).o || echo "FAIL $f" - done - rm -f /build/libmbed.a; ar rcs /build/libmbed.a /build/obj/*.o; ls -la /build/libmbed.a' + mkdir -p /build/shim/mbedtls /build/obj + echo "/* the tree names these headers in bignum.c and ecp.c and does not ship them */" | tee /build/shim/mbedtls/bignum.h > /build/shim/mbedtls/ecp.h + rm -f /build/obj/*.o /build/libmbed.a + ls library/*.c tf-psa-crypto/extras/*.c tf-psa-crypto/utilities/*.c tf-psa-crypto/platform/*.c tf-psa-crypto/core/*.c tf-psa-crypto/drivers/builtin/src/*.c | + xargs -P 4 -I{} sh -c "gcc -std=c99 -g -O0 -w -D_DEFAULT_SOURCE -DMBEDTLS_USER_CONFIG_FILE=\\\"tlsguard_mbedtls_config.h\\\" $INC -c {} -o /build/obj/\$(echo {} | tr / _).o" + ar rcs /build/libmbed.a /build/obj/*.o; ls -la /build/libmbed.a'