Stack-allocate the two mbedtls DES contexts in loclass optimized_elite
(128 bytes each) and the APDU runner progress text buffer (24 bytes).
All three were static/global but are used only within single call frames.
- Strip unused XER, PER, and OER codec support via persistent skeleton gating.
- Refactor high-frequency ASN.1 logic to use stack allocation.
- Implement zero-copy transmission path using 32-byte header offset in UART TX buffer.
- Correct CCID header initialization and DER encoding buffer size calculation.
- Add ASN_DISABLE_* macros to application.fam for consistent gating across builds.
The app was definitely carrying some extra weight that we didn't need.
* Stripped the Bloat: I fully gated out the OER, PER, and XER support libraries. Even though some generation flags were there, the actual library code was still being linked. I also removed the random_fill logic since we aren't using it.
* Big Wins: The binary is now 7 KB smaller 📉. I verified this by checking the symbol table—all those extra codec functions are officially gone.
* Bug Fix: I found a pretty serious issue in sam_api.c where the local calloc was just a wrapper for malloc and wasn't actually zeroing out memory. I added a memset fix so we don't run into any weird non-deterministic crashes. 🛠️
* Stack Optimization: Since the ASN.1 path is much leaner now, I was able to safely drop the stack size in application.fam from 5 KB to 3 KB.
Refs: https://github.com/cindersocket/seader/issues/2