Topic: [SOLVED] Making an RSA key using wc_MakeRsaKey never stops

Hi

I appreciate your help. I am running a very basic RSA code snippet on STM32F7xx. But it is stuck at wc_MakeRsaKey and never stops. Here is the code:

    int    ret;

    size_t bytes;
    WC_RNG rng;
    RsaKey key;

    /* initialize stack structures */
    XMEMSET(&rng, 0, sizeof(rng));
    XMEMSET(&key, 0, sizeof(key));


    bytes = (size_t)sizeof_client_key_der_2048;

     ret = wc_InitRsaKey(&key, NULL);
    
    ret = wc_InitRng(&rng);

    ret = wc_MakeRsaKey(&key, 1024, 65537, &rng);

Share

Re: [SOLVED] Making an RSA key using wc_MakeRsaKey never stops

Hi Ehsan,

The RSA key generation is a very intensive operation. Even on a top end Intel i7 part is takes almost 1 second. Generating an RSA 2048-bit key requires two 256 byte prime numbers. It requires a large amount of RNG data. I suspect it appears to hang, but its still running.

Example:

./configure --enable-keygen && make
./wolfcrypt/benchmark/benchmark -rsa-kg
wolfCrypt Benchmark (block bytes 1048576, min 1.0 sec each)
RSA     1024 key gen         8 ops took 1.058 sec, avg 132.305 ms, 7.558 ops/sec
RSA     2048 key gen         3 ops took 2.862 sec, avg 954.070 ms, 1.048 ops/sec

Thanks,
David Garske, wolfSSL

Share

Re: [SOLVED] Making an RSA key using wc_MakeRsaKey never stops

Hi David

Thanks for your reply.
In fact it I had defined small heap/stack memory. I increased it, then it resolved.

Share