1

(6 replies, posted in wolfCrypt)

Thank you David!  You were indeed correct.  I switched to ECDH with wc_ecc_shared_secret using "6=Single Precision C all small" and my code is finally able to run.  Any other math option causes the hard fault to occur.

Do you have any other suggestions to minimize wolfCrypt memory usage as I begin to add in all my other code?

2

(6 replies, posted in wolfCrypt)

Thank you both for your responses.

I tried including the wolfSSL config header before other includes but it made no difference.

I also tried increasing the minimum stack size with no changes.  I am using HAVE_FFDHE_2048.

I cannot run the wolfCrypt tests because my microcontroller is not large enough to run wolfCryptDemo if that is what you're referring to.

3

(6 replies, posted in wolfCrypt)

I have been struggling for the last few days to get wolfCrypt to work on a STM32L432 microcontroller.  I am trying to first generate a Diffie Hellman keypair among other things.  No matter what I've tried, I still get hard fault errors.

Here are the exact steps to replicate the problem:

  • Install STM32CubeIDE (version 1.12.0 at time of writing)

  • Create a new STM32 project for STM32L432KCU6

  • Install the STM32Cube pack for STM32CubeIDE under Manage Software Packs

  • Select wolfCrypt Core from Select Components

  • Enable the RNG in Security

  • Enable wolfSSL in Middleware and Software Packs

  • Automatically resolve any clock issues

  • Generate Project Code

  • Change the hardware platform to WOLFSSL_STM32L4 under wolfSSL.I-CUBE-wolfSSL_conf.h and comment out the warning

  • Build and debug the code to make sure it runs without issues (it does)

  • In main.c add #include <wolfssl/wolfcrypt/dh.h>

  • In main.c add wolfCrypt_Init();

  • Copy/paste the example code under wc_DhGenerateKeyPair() https://www.wolfssl.com/doxygen/group__ … 6fe9dc3b72

  • Build the project (builds without errors)

  • Debug the project

This is where the problems occur.  The project immediately hard faults.  The CFSR register sometimes shows UNDEFINSTR, while other times it shows NOCP.  If I comment out the line with wc_DhGenerateKeyPair it runs fine, so I believe this problem is related to wolfCrypt in some way.

I've tried changing tons of options in CubeMX as well as the wolfSSL settings file.  I have tried older versions of STM32CubeIDE as well as older versions of wolfSSL.  Nothing seems to help.

Any suggestions?