suculent / thinx-aes-lib

AES wrapper for ESP8266/ESP32/Arduino/nRF5x
Other
113 stars 39 forks source link

Ram use problem in Mega2560 with encrypt base64_iv sample #70

Closed motniemtin closed 1 year ago

motniemtin commented 1 year ago

I upload this code to my mega2560, and after a loop, RAM in mega decrease quickly, after that, no free ram and fail decrypt in some loop

suculent commented 1 year ago

Unfortunately, Mega2650 does not have enough RAM to process the Base64 conversion. That's why there is a simple example specially designed for low-memory conditions.

motniemtin commented 1 year ago

It is not small ram problem in mega2560, i tested your code with base64_iv and i found problem with your AESLib.cpp char msgOut = (char)malloc(msgLen); int b64len = base64_decode(msgOut, msg, msgLen);

If i add free(msgOut); problem solved

suculent commented 1 year ago

I see,

the malloc was a 3rd party contribution, it's bad idea to use malloc in emedded code.

Thanks for review, I'll release the decrypt64 fix in next version.

Matej

On 17. 2. 2023, at 8:49, Lam Nguyen @.***> wrote:

It is not small ram problem in mega2560, i tested your code with base64_iv and i found problem with your AESLib.cpp char msgOut = (char)malloc(msgLen); int b64len = base64_decode(msgOut, msg, msgLen);

If i add free(msgOut); problem solved

— Reply to this email directly, view it on GitHub https://github.com/suculent/thinx-aes-lib/issues/70#issuecomment-1434255594, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABWFR334QMFV4SZPKSXEATWX4UQ7ANCNFSM6AAAAAAU5TJ354. You are receiving this because you modified the open/close state.

suculent commented 1 year ago

I've tested your suggestion measuring memory consumption on my ATmega2650 and it seems to work. Releasing as 2.3.5. Thanks again.

motniemtin commented 1 year ago

I really appreciate your contribution and I thank you very much for this, I'm glad to have there