thinx-aes-lib
thinx-aes-lib copied to clipboard
Support for esp-idf 4.0
I tried to run this library in esp32-idf, but i got errors in build. Someone handled this case?
??
Sorry, no time to deal with this. I have finaly vacation after 2 years.
What type of errors?
On 27. 8. 2021, at 19:47:46, roysG @.***> wrote:
??
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/suculent/thinx-aes-lib/issues/57#issuecomment-907369410, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABWFR7S357U27LBS6XZHHDT67FUFANCNFSM5C375YMQ.
Hi, Thank you for your response, send you now
-DESP_PLATFORM -DARDUINO=10812 -DARDUINO_ESP32_DEV -DARDUINO_ARCH_ESP32 -DARDUINO_BOARD="ESP32_DEV" -DARDUINO_VARIANT="esp32" -DESP32 -MD -MT esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj -MF esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj.d -o esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj -c /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp: In member function 'uint8_t AES::getrandom()': /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp:351:26: error: 'time' was not declared in this scope srand ((unsigned int)time(NULL)); ^~~~ /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp:351:26: note: suggested alternative: 'size' srand ((unsigned int)time(NULL)); ^~~~ size
And in case i remove the time, this is the next error i get:
DEV" -DARDUINO_VARIANT="esp32" -DESP32 -MD -MT esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj -MF esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj.d -o esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj -c /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp: In member function 'void AES::set_IV(long long unsigned int)': /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp:478:9: error: 'void* memcpy(void*, const void*, size_t)' offset 64 is out of the bounds [0, 8] of object 'IVCl' with type 'long long unsigned int' [-Werror=array-bounds] memcpy(iv+8,&IVCl+8,8);
/Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp:476:41: note: 'IVCl' declared here
void AES::set_IV(unsigned long long int IVCl){
~~~~~~~~~~~~~~~~~~~~~~~^~~~
cc1plus: some warnings being treated as errors
This seems like a type confusion between 32/64 but worlds. Long long may not be correctly typed as uint_64.
What’s your MCU exactly?
It seems the compiler is too strict. Should be solvable on proper hardware with right #define overrides.
Maybe I’m wrong. But anyway, trying to help offline is hard.
Matej
On 27. 8. 2021, at 22:07, roysG @.***> wrote:
And in case i remove the time, this is the next error i get:
DEV" -DARDUINO_VARIANT="esp32" -DESP32 -MD -MT esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj -MF esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj.d -o esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj -c /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp: In member function 'void AES::set_IV(long long unsigned int)': /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp:478:9: error: 'void* memcpy(void*, const void*, size_t)' offset 64 is out of the bounds [0, 8] of object 'IVCl' with type 'long long unsigned int' [-Werror=array-bounds] memcpy(iv+8,&IVCl+8,8);
/Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp:476:41: note: 'IVCl' declared here void AES::set_IV(unsigned long long int IVCl){ ~~~~~~~~~~~~~~~~~~~~~~~^~~~ cc1plus: some warnings being treated as errors — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
The ESP32 has better RNG (random number generator) options than 16-bit chips like oldschool Arduino. This library does not leverage it yet.
M.
On 27. 8. 2021, at 22:02, roysG @.***> wrote:
-DESP_PLATFORM -DARDUINO=10812 -DARDUINO_ESP32_DEV -DARDUINO_ARCH_ESP32 -DARDUINO_BOARD="ESP32_DEV" -DARDUINO_VARIANT="esp32" -DESP32 -MD -MT esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj -MF esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj.d -o esp-idf/arduino/CMakeFiles/__idf_arduino.dir/libraries/ThinxAesLib/src/AES.cpp.obj -c /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp: In member function 'uint8_t AES::getrandom()': /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp:351:26: error: 'time' was not declared in this scope srand ((unsigned int)time(NULL)); ^~~~ /Users/roysabah/esp/esp32-arduino-lib-builder/components/arduino/libraries/ThinxAesLib/src/AES.cpp:351:26: note: suggested alternative: 'size' srand ((unsigned int)time(NULL)); ^~~~ size
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
You know what leave these errors for now, in later time you may download idf4 install it as wrapper component, test your library and fix the errors.
For now i need a solution, maybe you may assist me in other way.
See this link: https://techtutorialsx.com/2018/05/10/esp32-arduino-decrypt-aes-128-in-ecb-mode/
In case you understand better all about encryption. Can you tell me how can i send the ciphertext to server as string/base64 and convert it back to chars without corrupted it? Thanks.
Part of this library is the xbase64.h/.cpp which is a Base64 implementation used to convert data to string for network transport. Docs are in the header.
First you can calculate encoded length, allocate string of sufficient length and then do the base64 transformation.
Example you’ve linked only prints hex bytes using ´sprintf(str, "%02x", (int)cipherTextOutput[i]´
Hope it helps. M.
On 28. 8. 2021, at 7:19, roysG @.***> wrote:
You know what leave these errors for now, in later time you may download idf4 install it as wrapper component, test your library and fix the errors.
For now i need a solution, maybe you may assist me in other way.
See this link: https://techtutorialsx.com/2018/05/10/esp32-arduino-decrypt-aes-128-in-ecb-mode/
In case you understand better all about encryption. Can you tell me how can i send the ciphertext to server as string/base64 and convert it back without corrupted it? Thanks.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Still at this point, I don't use IDF for any of my projects so I have no environment to fix this. Either this library will be replaced by better implementation, or someone using IDF would have to fix this.
I have a working example of using this library AESLib in ESP32. So therefore I think it should works the same in ESP32-idf (I have not tried AESLib on ESP32-idf). Nonetheless, if you are interested, you may visit my github page at:
https://github.com/adriancs2/arduino.aes.asp.net
A full explanation is available at there: https://adriancs.com/c-sharp/1081/aes-encrypted-http-request-between-arduino-esp32-and-c-asp-net/
a simplified version: https://adriancs.com/arduino/1096/arduino-aes-encryption-128-bits-cbc/
This is awesome. We may look at the issues with IDF builds to be solved. 31. 7. 2023 v 8:48, adriancs @.***>: I have a working example of using this library AESLib in ESP32, but not ESP32-idf. but anyway, the AESLib should be able to work with any Arduino board. If you are interested, you may visit my github page at: https://github.com/adriancs2/arduino.aes.asp.net A full explanation is available at there: https://adriancs.com/c-sharp/1081/aes-encrypted-http-request-between-arduino-esp32-and-c-asp-net/ a simplified version: https://adriancs.com/arduino/1096/arduino-aes-encryption-128-bits-cbc/
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were assigned.Message ID: @.***>