Thanks, I think :-) certainly is a large file. Searching for AES_CTR or AES_COUNTER revealed a few hits, but nothing jumped out at me.
My project is quite straight forward ... I'm building an instrumentation system for a small electric vehicle. To monitor battery condition I have a Smartshunt made by Victron Energy: https://www.victronenergy.com/battery-m … tery-shunt
My project uses a high powered Arduino relative (a Teensy 4.x https://www.pjrc.com/store/ ) to integrate information from several sensors around the vehicle (e.g temperatures, GPS, speed, battery voltage, current, % remaining etc) into a small display ... a dashboard if you like.
Victron have kindly made information on their Bluetooth Low Energy (BLE) Advertising protocol available to the public, for many of their bluetooth devices. So now people like me can continually receive data from a Smartshunt (or any 'smart' Victron product) over BLE. This is the same protocol and data the VictronConnect mobile phone app utilises to display device information.
BTW a neat aspect of the advertised data: it's broadcast and available without needing a BLE connection.
A portion of the data continually advertised by the Smartshunt (less than 16 bytes) is encrypted using AES-CTR. These few bytes include voltages, current etc. so I need to decrypt them. The data updates every 150ms or so.
From the unencypted portion I can see and extract the "salt" as two bytes (also called "Nonce/Data Counter")
I also have the encryption key (128 bits) specific to my SmartShunt (retreived via the VictronConnect app)
So I think have all the inputs, I just need to code the AES-CTR algorithm in C/C++ in the Arduino IDE. I am very experienced in that environment, so I don't need the whole solution, just the Algorithm, how to call it, with salt and key in hand.
As I see the algorithm simply has to process the encrypted byte array as an input stream using the salt and key, and output the decrypted bytes to a bytes array/variable that I can print or display. ON further thought I will also need code for the reverse, i.e. to encrypt 16 bytes, then I could generate specific data and test the encryption/decyprion cycle is working.
Searching on the Arduino forum I came across a few mentions of wolfSSL, but none were looking at AES-CTR. Hence why I am here ...
I was going to attach a rather detailed but very useful extract (in PDF) from the Victon forum, a user post that explains some of the finer points of decrypting the Victron data (e.g. watch out for the little endians!) :-)
but I keep getting a warning "The server was unable to save the uploaded file"
best regards
PS: If I can get this to work it would make a great additional example in the wolfSSL library for ArduinoIDE. I would be happy to contribute towards that ...