Topic: Raspberry Pi Pico-2W RSA not working

Hi all,

I have been trying to implement RSA on the Raspberry Pi Pico 2W RP2350 microcontroller with the Dual Cortex-M33 processor. However, I am getting stuck at wc_MakeRsaKey

RsaKey priv;
WC_RNG rng;
int ret = 0;
long e = 65537; // standard value to use for exponent

ret = wc_InitRsaKey(&priv, NULL);
printf("wc_InitRsaKey ret: %d\n", ret);
ret = wc_InitRng(&rng);
printf("wc_InitRng ret: %d\n", ret);
ret = wc_RsaSetRNG(&priv, &rng);
printf("wc_RsaSetRNG ret: %d\n", ret);
// generate 2048 bit long private key
ret = wc_MakeRsaKey(&priv, 2048, e, &rng);
printf("wc_MakeRsaKey ret: %d\n", ret);

I have tried the benchmark tests and have been unable to replicate the results at https://www.wolfssl.com/docs/benchmarks/
The platform that WolfSSL tested with is slightly different:
Raspberry Pi Pico-W
ARM Cortext M0+, 125MHz
When trying to run to run bench_main from the example repository in WolfSSL:
https://github.com/wolfSSL/wolfssl-exam … nch_main.c
The code gets stuck at RSA.


I saw a blog post here related to this issue:
https://www.wolfssl.com/forums/topic125 … stops.html

However, I am unsure if this is the issue and, if so, how to resolve it for my Pico 2W. Any help is appreciated.

Share

Re: Raspberry Pi Pico-2W RSA not working

Hi Yin,

The RSA Key Generation is extremely computational and I would expect it to take several minutes on an M0+ at 125MHz. It must find two large primes. The RSA key generation on a device like this is fairly impractical and many companies will load a pre-provisioned RSA key. What is your use-case? Can you tell us more about your project?

Thanks,
David Garske, wolfSSL

Share

Re: Raspberry Pi Pico-2W RSA not working

Hi David,

Thanks for the reply. For now, I'm trying to replicate the benchmark results at the link below, but it seems that I get stuck at RSA, I'm not sure why.
Additionally, are you aware whether it's possible to use ML_DSA on the Pico? Thanks.

https://www.wolfssl.com/a-slice-of-secu … y-pi-pico/

Share

Re: Raspberry Pi Pico-2W RSA not working

Hi Yin,

It is possible you are hitting a heap / stack limit or there is some other configuration issue. I highly recommend looking at the user_settings.h file in our examples repository here: https://github.com/wolfSSL/wolfssl-exam … r/RPi-Pico

Options such as WOLFSSL_SMALL_STACK is highly recommended. WOLFSSL_SP_SMALL and RSA_LOW_MEM can help, even though they are not used in the examples.

Also, if you are using ARM assembly options, make sure you compile with `WOLFSSL_SP_ARM_CORTEX_M_ASM` defined, you can see this in the CMakeList.txt for the examples.

If you don't have one already, I highly recommend obtaining an SWD debug probe for the Pico, or using Raspberry Pi's examples on converting a second Pico into an SWD debug probe. This way you will be able to observe what the problem might be.

Whilst we haven't tested ML_DSA with the RP2040 or RP2350, it works on similar ARM platforms, so should work without issue.

Kind Regards
Andrew Hutchings, wolfSSL

Share

Re: Raspberry Pi Pico-2W RSA not working

Hello Andrew,

Thanks for the reply; I've cloned the wolfssl-examples repository and ran the benchmark tests with the config settings that you suggested, but it seems to still stop at RSA. Please let me know what I can do to fix this issue. I'm currently looking into ways to redefine heap/stack memory for the Pico 2W, but it seems like there's very little documentation on that.

Share

Re: Raspberry Pi Pico-2W RSA not working

Hi Yin,

Can you please let us know what version of the Pico SDK you are using? Also, can you please confirm you are using `cmake -DPICO_BOARD=pico2`?

Kind Regards
Andrew Hutchings, wolfSSL

Share

Re: Raspberry Pi Pico-2W RSA not working

Hi Andrew,

I am using Pico SDK 2.2.0
For cmake, I am using "cmake -DPICO_BOARD=pico2_w -DPICO_PLATFORM=rp2350 .."

Share