Topic: Linker error: adding custom crypto functions to WolfSSL
Hello everyone,
I am trying to add custom crypto algorithms in wolfssl for my project, however I have a couple problems and I am not sure why.
The setup is as follows:
1. In the wolfssl/wolfcrypt/src directory I added a new file, PQ.c, where new functions wc_InitPQKey(),
wc_FreePQKey(), wc_GeneratePQKeyPair() etc. are implemented. The corresponding header is in wolfssl/wolfssl/wolfcrypt/PQ.h.
2. I defined a new WolfSSL configuration: --enable-pq.
- For that, I added the following into wolfssl/configure.ac:
...
enable_pq=yes
...
# PQ
AC_ARG_ENABLE([pq],
[AS_HELP_STRING([--enable-pq],[Enable wolfSSL PQ support (default: disabled)])],
[ ENABLED_PQ=$enableval ],
[ ENABLED_PQ=no ]
)
if test "$ENABLED_PQ" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DHAVE_PQ"
fi
...
AM_CONDITIONAL([BUILD_PQ],[test "x$ENABLED_PQ" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
...
echo " * PQ: $ENABLED_PQ"
...
- in the wolfssl/src/include.am I added:
...
if BUILD_PQ
src_libwolfssl_la_SOURCES += wolfcrypt/src/PQ.c
endif
...
- in the wolfssl/wolfssl/wolfcrypt/include.am:
...
nobase_include_HEADERS+= \
wolfssl/wolfcrypt/aes.h \
...
wolfssl/wolfcrypt/PQ.h \
...
...
if BUILD_PQ
nobase_include_HEADERS+= wolfssl/wolfcrypt/PQ.h
endif
3. To build the library, I do:
./configure --enable-pq
make
sudo make install
4. In my test project file I include <wolfssl/options.h>, <wolfssl/wolfcrypt/PQ.h>, <wolfssl/wolfcrypt/settings.h> etc. and call my functions
wc_InitPQKey(), wc_FreePQKey(), wc_GeneratePQKeyPair().
However, when I am trying to compile the project I get the following:
make
gcc -Wall -c -o main.o main.c
gcc -o myprog main.o -lwolfssl
/usr/bin/ld: main.o: in function `main':
main.c:(.text+0x12d): undefined reference to `wc_InitPQKey'
/usr/bin/ld: main.c:(.text+0x14a): undefined reference to `wc_InitPQKey'
/usr/bin/ld: main.c:(.text+0x1ce): undefined reference to `wc_GeneratePQKeyPair'
...
Am I missing something?
Thank your very much for your help!