1 (edited by dragem 2017-10-10 18:18:14)

Topic: [SOLVED] crash on wc_InitRsaKey_ex()

Hi,

I have faced crash with creating RSA key.

code is very simple like belows.

    RsaKey key;
    wc_InitRsaKey( &key, NULL );

Crash logs are belows

Process 987165 (temp) terminated SIGSEGV code=2 fltno=11 ip=000000010050f0ab(/usr/lib/libwolfssl.so.12@wc_InitRsaKey_ex+0x000000000000002f) mapaddr=00000000000180ab. ref=0000000008049800

and gdb back trace logs are belows

(gdb) bt
#0  0x000000010050f0ab in wc_InitRsaKey_ex (key=0x80475b0, heap=0x0, devId=-2) at wolfcrypt/src/rsa.c:188
#1  0x000000010050f1c0 in wc_InitRsaKey (key=0x80475b0, heap=0x0) at wolfcrypt/src/rsa.c:223
(gdb) f 0
#0  0x000000010050f0ab in wc_InitRsaKey_ex (key=0x80475b0, heap=0x0, devId=-2) at wolfcrypt/src/rsa.c:188
188         key->type = RSA_TYPE_UNKNOWN;
(gdb) l
183
184         if (key == NULL) {
185             return BAD_FUNC_ARG;
186         }
187
188         key->type = RSA_TYPE_UNKNOWN;
189         key->state = RSA_STATE_NONE;
190         key->heap = heap;
191         key->data = NULL;
192         key->dataLen = 0;
(gdb) print &(key->type)
$12 = (int *) 0x8049800

There is strange because key variable is okay.

Could you help me for fix it?

Share

Re: [SOLVED] crash on wc_InitRsaKey_ex()

Hi dragem,

Are you compiling your application with the same preprocessor defines that were used to compile the wolfSSL library?

If you compiled wolfSSL with the ./configure script, it will have generated a <wolfssl/options.h> header containing all the preprocessor defines used at compile time.  You should then include that in your application, as the first wolfSSL header:

#include <wolfssl/options.h>
#include <wolfssl/wolfcrypt/rsa.h>
...

Best Regards,
Chris

3 (edited by dragem 2017-10-10 18:16:01)

Re: [SOLVED] crash on wc_InitRsaKey_ex()

modified..

Thanks Chrisc! it works fine smile I simply add options.h into a source file that include wolfssl header first.

Share