Lightweight/smallest libraries that implement strong encryption standards like AES for 4MB ESP8266 NodeMCU board running Espruino. #6473
Replies: 1 comment
-
Posted at 2024-04-03 by Jurand This is interesting: Posted at 2024-04-03 by Jurand Or this: Posted at 2024-04-04 by @gfwilliams Espruino actually already includes mbedtls: https://github.com/espruino/Espruino/tree/master/libs/crypto You should be able to include it in the ESP8266 build quite easily by adding the following lines: https://github.com/espruino/Espruino/blob/master/boards/PICO_R1_3.py#L40-L41 Note that including TLS will use a lot more memory, but I believe you can still have AES without TLS. When you say ESP8266 4MB do you mean 4MBit of 4MByte? Because my understanding was that only the very earliest modules available were 4MBit (512kB), and now they're basically all 4MByte. Espruino does build and run for those early 512k chips, and obviously that creates a lot more restrictions that something with 8x the flash - but if you're on the 4MByte version then you really shouldn't have to be concerned about flash memory usage at all - it's really only RAM usage you care about. Posted at 2024-04-04 by @MaBecker @gfwilliams is there a chance that mbedtls will be updated? Posted at 2024-04-04 by @gfwilliams
You mean just the version of the library? It's not high on my list right now, but if someone makes a PR then I'd definitely pull it in :) Posted at 2024-04-04 by Jurand I have read about XXTEA and other libraries but unfortunately failed to upload it to ESP board. Too large or too resource hungry... but still fighting :) Posted at 2024-04-04 by Jurand Hi guys :) Posted at 2024-04-04 by Jurand I have read both Encryption threads: https://forum.espruino.com/conversations/267841/ So after 7 years we just have SHA256 in crypto for ESP build in? I went through git repo and read readme for building, but for windows there was only information: basically do it in Linux. Unfortunately not a solution I can use. I was hoping it can be done in Windows with Python :) Could you add additional builds for ESP chips with AES, so there is one with and one without for each? Posted at 2024-04-10 by Jurand Have you seen ESP32 S2 Mini V1.0.0 Development Board with ESP32-S2FN4R2 4MB FLASH 2MB PSRAM? There is hope :) Attachments: Posted at 2024-04-11 by @gfwilliams
You can choose to build it in I think. At the end of the day anyone is able to contribute changes to the Espruino repository Posted at 2025-01-19 by @joakim Adding a hashing algorithm to the list: The latest version uses Wasm, but version 8 (11.4 KB before minification) might work on Espruino? As for an alternative to AES, an interesting newcomer (50 weeks old) is ChaCha20-BLAKE3. It's supposedly simpler, faster and more secure in certain aspects than (software) AES. But there's no implementation yet, certainly not in JS. When one is available, it could be ported to JS with Blake3 and a ChaCha20 library. I'll keep an eye on this one. Obviously not for TLS though. I also like TweetNaCl.js. It's ported from TweetNaCl, made by smart people, and has had a security audit. It's small, well written and easy to use. As a crypto noob, I only dare use the NaCl family of crypto libraries (libsodium, TweetNaCl and by extension TweetNaCl.js). Posted at 2025-01-20 by @gfwilliams Thanks for the update!
I would have thought so, yes! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2024-04-03 by Jurand
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.
Beta Was this translation helpful? Give feedback.
All reactions