• For a 4MB ESP8266 NodeMCU board running Espruino, your choices for secure encryption libraries are somewhat limited due to the constraints of the device, including its memory and processing power.

    One of the smallest and most secure encryption libraries that could fit this criterion is TweetNaCl. TweetNaCl is a cryptography library that offers a compact implementation of the NaCl library (Networking and Cryptography library), which is well-regarded for its simplicity and high security. The TweetNaCl library has been ported to various languages and platforms, and there is a JavaScript version that could potentially be used with Espruino.

    Anyone, any ideas?

    XOR Cipher: For very lightweight applications, a simple XOR cipher with a pseudo-random sequence generator (like a linear feedback shift register for the sequence) could be implemented. However, this method is not recommended for securing sensitive data, as it can be relatively easily broken without proper precautions.

    RC4: Another small and simple option could be RC4 (although it's now considered insecure for many applications, it might suffice for scenarios with low security requirements). You would need to be careful with its initialization and usage to avoid common pitfalls that make it vulnerable.

    Simplified AES (SAES): This is a reduced, more straightforward version of AES designed for educational purposes and might serve as a basis for a custom implementation. It can demonstrate how to perform secure encryption with less complexity, though adapting it for production use requires caution to maintain security.

    Found those on the net, but I am open to discussion and knowledge exchange before attempt to embed any of them.

    1. TweetNaCl / TweetNaCl.js - A compact, tweet-sized NaCl cryptography library, with a JavaScript version suitable for adaptation.
    2. micro-ecc - A small Elliptic Curve Cryptography (ECC) library for microcontrollers.
    3. uCryptoLib - A micro cryptographic library designed for embedded devices.
    4. LibHydrogen - A lightweight, secure, easy-to-use crypto library for constrained environments.
    5. Tiny-AES-c - A small and portable implementation of the AES algorithm, potentially adaptable for JavaScript.
    6. BearSSL - A secure and relatively small SSL/TLS library, with potential for lightweight implementations.
    7. mbedTLS (minimal configuration) - A library that can be configured to be minimalistic for embedded devices.
    8. wolfSSL (with --enable-smallstack or --enable-minimal options) - A small, portable, and embeddable SSL/TLS library.
    9. sodium-native - A low-level Node.js binding to libsodium, which might be adapted or inspire a minimal implementation.
    10. TinyCrypt - A small, portable, and easy-to-use library of cryptographic algorithms.
    11. speck.js - A JavaScript implementation of the SPECK block cipher, known for its simplicity and small size.
    12. microjs/crypto - A collection of micro libraries in JavaScript, including some for cryptography, which are very small.
    13. SJCL (Stanford JavaScript Crypto Library) - While not the smallest, it can be customized to include only necessary features.
    14. asmCrypto - A JavaScript cryptographic library with AssemblyScript optimization, potentially adaptable for size.
    15. js-nacl - A high-level cryptographic library that can be adapted or stripped down for essential functionality.
    16. noble - A family of compact, secure, and easy-to-use cryptographic primitives for JavaScript.
    17. Heatshrink - A data compression library suitable for small microcontrollers, useful for reducing data size before encryption.
    18. PicoCrypt - A hypothetical minimal cryptographic library designed with the smallest footprint in mind.
    19. CryptoJS (minimal build) - While generally larger, it can be customized to only include necessary components.
    20. Salty - A minimal secure encryption library for JavaScript, focusing on ease of use and small size.
    21. Elliptic (minimal configuration) - A lightweight implementation of elliptic curve cryptography in JavaScript.
    22. SOSEMANUK - A fast, software-oriented stream cipher that can potentially be adapted for JavaScript environments.
    23. Rabbit - A fast stream cipher that can be implemented in a compact form for JavaScript.
    24. Simon and Speck - Lightweight block ciphers designed for simplicity and efficiency, potentially adaptable to JavaScript.
    25. ChaCha - A stream cipher that offers good performance and security, with potential for a minimal JavaScript implementation.
About

Avatar for Jurand @Jurand started