1 (edited by lalonde 2017-12-01 13:54:23)

Topic: [SOLVED] Undefined RSA functions from wolfssl.lib

Hello,

Firstly, I am having a blast working with your library (even though nothing is working yet) - kudos!

Anyways, I have created a user_setting.h file (defined WOLFSSL_USER_SETTINGS in <IDE\WIN\user_settings.h>)with intentions of creating a code singing scheme eventually, but for now, my app is just trying to create a file and dump the generated key-pair in the file. I have been following the 'signature' example in your GitHub (I do need a plaintext file since when the future embedded target needs both keys)... The following settings are enabled:

#define NO_DES3
#define NO_DSA
#define NO_MD4
#define NO_RC4
#define NO_RABBIT
#define NO_HC128
#define NO_SESSION_CACHE
#undef NO_PSK
    #define NO_PSK
#define WOLFSSL_KEY_GEN
#define SINGLE_THREADED

I have built wolfSSL with these settings and that is fine - wolfssl.lib sits at 4.3 Mb (a little too big but not the concern right now).

I think I have linked the wolfssl.lib in my application in Visual Studio as I normally would do correctly (very basic stuff) while including the necessary headers in my app code:

#include <stdio.h>
#include <wolfssl/options.h>
#include <wolfssl/ssl.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/wolfcrypt/rsa.h>
#include <wolfssl/wolfcrypt/types.h>

The problems start arising when I compile my app and see the following warnings in the log:

...
c:\wolfssl\test_apps\src\genkeyfiles.c(123): warning C4013: 'wc_MakeRsaKey' undefined; assuming extern returning int
c:\wolfssl\test_apps\src\genkeyfiles.c(134): warning C4013: 'wc_RsaKeyToDer' undefined; assuming extern returning int
c:\wolfssl\test_apps\src\genkeyfiles.c(149): warning C4013: 'wc_RsaKeyToPublicDer' undefined; assuming extern returning int

So it looks as if my app can't find the definitions of these functions but sees the declaration in the headers provided, and I didn't turn off anything that RSA needs from my settings (I think?).

Note: I have tried building my app with default settings and the same warnings about 'warning C4013: 'wc_RsaXxxXxx' undefined still occurs.

When build, the linker has errors (expected since the .exe I am trying to create can't find the essential RSA functions):

wolfssl.lib(wolfio.obj) : error LNK2019: unresolved external symbol __imp__recv@16 referenced in function _wolfIO_Recv
wolfssl.lib(wolfio.obj) : error LNK2019: unresolved external symbol __imp__send@16 referenced in function _wolfIO_Send
wolfssl.lib(wolfio.obj) : error LNK2019: unresolved external symbol __imp__WSAGetLastError@0 referenced in function _LastError

Any insight on why the compiler can't find these functions: wc_MakeRsaKey, wc_RsaKeyToDer, & wc_RsaKeyToPublicDer would be greatly appreciated!


Thanks and Regards,

Dylan

Share

Re: [SOLVED] Undefined RSA functions from wolfssl.lib

Hi lalonde,

Since you are working in a windows environment I am surprised the include

#include <wolfssl/options.h>

is working properly! That is typically automatically generated when you build with "./configure && make" on a unix/linux platform.

To ensure that the application and the library have the same settings could you instead use

#include "user_settings.h"

in place of options.h?

The library and the application should both have the exact same configuration to ensure proper functionality.

Please let me know if this resolves the link-time issues you are seeing!


Warmest Regards,

Kaleb

3 (edited by lalonde 2017-12-05 08:09:48)

Re: [SOLVED] Undefined RSA functions from wolfssl.lib

Kaleb,

Thanks for the quick response.

Adding user_settings.h and removing options.h from my application fixed the compiler warnings.

I figured it out the linker errors, I had to ...

#define WOLFSSL_USER_IO

in my user settings, removing the default auto settings for IO functions. I'd assume by using these RSA functions, the application was looking for socket from network.h (from the macros RECV_FUNCTION and SEND_FUNCTION) for SSL/TLS usage.

Thanks for the great support Kaleb!

Best Regards,

Dylan

Share