Practical IoT Cryptography on the ESP8266 using Arduino

I’ve been working with ESP8266 for a while, building some devices, and one of the features that lacked for a while was encryption. Upon a brief search on “ESP8266 encryption” I stumbled upon this Hackaday article by Sean Boyce. It was implemented using the old Lua/NodeMCU, and since I thought it was well explained I decided to port it to Arduino.

Encryption scheme

I won’t explain in details the encryption theory since it’s covered by the original article. Long story short, messages are encrypted using AES-128-CBC which requires two additional pieces of data to produce ciphertext: an encryption key and an initialization vector (iv).

AES-CBC encryption/decryption scheme simplified
Continue reading “Practical IoT Cryptography on the ESP8266 using Arduino”

Recovering an I2C bus

I have been using ESP8266 in some of my personal projects for a while. When I need more input/output/analog pins, I use an Arduino Nano as I/O expansion programmed as an I2C slave. I chose I2C as a communication protocol because I often use other I2C peripherals such as RTC and alphanumeric LCD. So far so good.

However, on my last project I was facing a problem: the I2c bus stopped working after uploading a new firmware to the ESP. When booting, no devices were being recognized, and the bus would work again only if I power cycled the system.

When I probed the bus, I noticed the SDA line was stuck at a low level due to one of the peripherals.

SDA line being held low
Continue reading “Recovering an I2C bus”