Topic: Issues when building with STM32_CRYPTO for STM32L4

I added __HAL_RCC_AES_CLK_ENABLE in numerous routines in aes.c to enable the hardware clock; wc_AesEncrypt, wc_AesDecrypt, wc_AesCbcEncrypt, wc_AesCbcDecrypt, wc_AesCtrEncryptBlock.  Is this missing functionality in WolfSSL or is there some other way to enable this in WolfSSL without having to add these code blocks?

I also had to add an include file in des3.c to avoid compiler errors.  Can you please comment if this is an oversight in the WolfSSL code?

#ifdef STM32_CRYPTO
    #include <wolfssl/wolfcrypt/port/st/stm32.h>
#endif

Thank you!

Share

Re: Issues when building with STM32_CRYPTO for STM32L4

Hi Tammy,

This sounds very similar to the ST HAL issue described here:
https://community.st.com/s/question/0D5 … le-missing

Thanks,
Eric @ wolfSSL Support

Re: Issues when building with STM32_CRYPTO for STM32L4

Thanks for the research, Eric, but this is not quite the same issue.  I'm not getting undefined reference to `__HAL_RCC_AES_CLK_ENABLE' - I have that routine present in the build.  The problem is that I have to manually enable the crypto clock within the WolfSSL routines.

For example:

    static int wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
    {
        int ret = 0;
    #ifdef WOLFSSL_STM32_CUBEMX
        CRYP_HandleTypeDef hcryp;
        #if defined(NUCLEUS) && defined(WOLFSSL_STM32L4)
            /* Enable CRYP clock */
            __HAL_RCC_AES_CLK_ENABLE();
        #endif

Share

Re: Issues when building with STM32_CRYPTO for STM32L4

Hmm. Does it need to be called once (as in during some init), or in every encrypt / decrypt routine? I'd like to ping David about this next week.

Re: Issues when building with STM32_CRYPTO for STM32L4

Hi Tammy,

Are you using the Cube MX HAL? If so what version? The Cube HAL handles enabling the clock automatically with the generated code.

If you still need to manually control the peripheral clock for power consumption reasons you can do it with the following:

The __HAL_RCC_AES_CLK_ENABLE() API comes from stm32l4xx_hal_rcc.h which gets included via stm32l4xx_hal_conf.h if the HAL has been generated with HAL_CRYP_MODULE_ENABLED set.

Which L4 part are you using and what wolfSSL build options have you defined in the user_settings.h or wolfSSL.wolfSSL_conf.h?

Thanks,
David Garske, wolfSSL

Share