Topic: Memory Configuration for STM32G071RB

I am trying to port wolfCrypt library for STM32G071RB. Purpose of porting is derive key from password and salt using PBKDF2.
After following each step mentioned in https://github.com/wolfSSL/wolfssl/blob … /README.md given link I tried calling
if (wc_PBKDF2(key, (const byte*)password, pLen, (const byte*)salt, sLen, iteration_count, KEY_SIZE, WC_HASH_TYPE_SHA256) != 0) {
        printf("Error deriving key\n");
        return;
    }
But this is returning MEMORY_E error code which is out of memory error.
I just want to know is it due to Microcontroller's insufficient RAM memory or any other reason?

Share

Re: Memory Configuration for STM32G071RB

Hello pathakpulkit06

Welcome to the wolfSSL Forums!

Yes, that error is usually an indication that the available stack should be increased. Could you share some more of your application code?

Here is an example that uses wc_PBKDF2 to stretch a password:
https://github.com/wolfSSL/wolfssl-exam … .c#L56-L60

Could you tell us a bit about your project goals using wolfSSL? Feel free to email support@wolfssl.com if you'd prefer a more private format.

Thanks,
Eric - wolfSSL Support

Re: Memory Configuration for STM32G071RB

Hi Pulkit,

Thanks for the question and talk this morning. You had WOLFSSL_SMALL_STACK defined and the HMAC struct was exceeding the available heap. The -125 error means an XMALLOC failed. Make sure you have all the SHA algorithms disabled that you do not need, leaving just SHA2-256 enabled. I also recommend removing WOLFSSL_SMALL_STACK in your case and increasing just the stack space in the linker script. Please let us know if you have any further issues.

Thanks,
David Garske, wolfSSL

Share