Topic: [SOLVED] "RSA_FUNCTION MP_EXPTMOD_E: memory/config problem" error

Hello:
What exactly means the "RSA_FUNCTION MP_EXPTMOD_E: memory/config problem" error?
I 'm using wolfSSL (with RTOS) to connect to AWS and it works perfect.

Now, I had to add a routine to write flash in the mcu ATSAM4, and for some reason (?), the stack does not longer connect. Checking the log, I see the above error.

I can't find the way the flash routines affect the stack. These routines use an array of 512 bytes but at local scope (inside a function) so it shouldn't affect. The flash routine is a wrapper around routines in ROM (from Atmel) and has few functions to init, unlock, erase and write the flash. Making tests I discover only the write function (last step in the procedure) is the one affects the stack. So the array in memory is not the cause of the problem. I don't know exactly how the flash_write() affects this.

Anyway, I would need to understand what above error means... It's the memory not enough? Why memory config problem? Is there any way to check additional parameters to see how the other code affects the stack?

I hope someone can help.
Thanks
Gus

Share

Re: [SOLVED] "RSA_FUNCTION MP_EXPTMOD_E: memory/config problem" error

Update:
I realized the flash routines add 512 bytes of RAM so I guess the current memory configuration for the stack is at the limit, so this change affects the overall wolfSSL stack functioning (to clarify, this doesn't come from my local array, but from the flash routines as it seems they need an extra space to handle the data before writing the flash).

I also wanted to share that, even without the flash routines, it was working fine BUT if at some point the SSL connection breaks, an attempt to reconnect (going through the SSL process again) gives the same error (RSA....: memory/config problem). So it seems there are some memory leakage or garbage that doesn't allow to do the TLS handshaking process for a second time. Only way is to reboot to start from fresh....

It seems I will need to reconfigure memory, but I would like to understand the wolfSSL stack memory requirements to avoid this problem.  The current value of FP_MAX_BITS is 4096. Changing it to 8192 doesn't solve the problem.

Thanks
Gus

Share

Re: [SOLVED] "RSA_FUNCTION MP_EXPTMOD_E: memory/config problem" error

Hi Gussabina,

Once the connection fails you should tear down the connection. wolfSSL provides some cleanup routines for the SSL objects. After the SSL object is released you can then create a new SSL object using the WOLFSSL_CTX factory you initially setup. This should clear up any issues with leakage.

Warm Regards,

Kaleb