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

8 (edited by yinzixuansz 2025-09-08 03:25:15)

Re: Raspberry Pi Pico-2W RSA not working

Hi,

I was able to get RSA working by 1. increasing the stack/heap by customizing the memmap_custom.ld and linking it and 2. removing the following code from my CMakeList (this is from the RPI-Pico example repository):

if (${PICO_PLATFORM} STREQUAL "rp2350")
    add_compile_definitions(wolfssl WOLFSSL_SP_ARM_CORTEX_M_ASM)
elseif (${PICO_PLATFORM} STREQUAL "rp2350-riscv")
    add_compile_definitions(wolfSSL WOLFSSL_SP_RISCV32)
else()
    add_compile_definitions(wolfssl WOLFSSL_SP_ARM_THUMB_ASM)
endif()

The above code is right before:

pico_add_extra_outputs(benchmark)

in the Benchmark wolfCrypt algorithms section.

Thank you all for your help.

Share

Re: Raspberry Pi Pico-2W RSA not working

Right... There appears to be a bug in the CMakeLists.txt here which should have been fixed a few months ago, but I see it hasn't.

Long story short:

1. You should never try to override PICO_PLATFORM in your cmake command line
2. That line in the CMakeLists.txt should say rp2350-arm-s, there was a behaviour change in the ARM SDK 2.x which broke it

I think that is the key to your problem. I'll run some tests and open a PR to fix it.

Share

Re: Raspberry Pi Pico-2W RSA not working

Further to my previous message, this PR fixes the problem.

https://github.com/wolfSSL/wolfssl-examples/pull/524

Share

11 (edited by ThomasS 2026-07-23 03:48:19)

Re: Raspberry Pi Pico-2W RSA not working

yinzixuansz wrote:

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
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:

The code gets stuck at RSA.


I saw a blog post here related to this issue:


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

I’d first check if it’s actually hung or just taking a long time. wc_MakeRsaKey() for a 2048-bit key is a heavy operation on embedded hardware.

Try a smaller key size to confirm it works, and check that wolfCrypt is built with the proper optimizations (SP math, memory settings, etc.). Also verify heap/stack size, because RSA key generation needs a lot of temporary memory. The Pico 2W is faster than the Pico W, but RSA generation can still take a while. Problems of this kind always cause inconvenience; it’s good that this doesn’t happen with https://mostbet.com.kp/.

Share