linuxkm: WIP support for wolfcrypt_test() at module load time.

This commit is contained in:
Daniel Pouzzner 2020-08-21 00:10:45 -05:00
parent 0c35998178
commit 34fd53b4fc
7 changed files with 29445 additions and 6 deletions

View File

@ -195,7 +195,7 @@ endif
include scripts/include.am
if BUILD_LINUXKM
export KROOT KARCH AM_CFLAGS CFLAGS AM_CCASFLAGS CCASFLAGS src_libwolfssl_la_OBJECTS
export KROOT KARCH AM_CFLAGS CFLAGS AM_CCASFLAGS CCASFLAGS src_libwolfssl_la_OBJECTS ENABLED_CRYPT_TESTS
SUBDIRS = linuxkm
endif

View File

@ -4127,6 +4127,7 @@ AC_ARG_ENABLE([crypttests],
[ ENABLED_CRYPT_TESTS=$enableval ],
[ ENABLED_CRYPT_TESTS=$ENABLED_CRYPT_TESTS_DEFAULT ]
)
AC_SUBST([ENABLED_CRYPT_TESTS])
# LIBZ
@ -5365,9 +5366,6 @@ if test "x$ENABLED_LINUXKM" = "xyes"; then
if test "$ENABLED_EXAMPLES" = "yes"; then
AC_MSG_ERROR([--enable-examples is incompatible with --enable-linuxkm.])
fi
if test "$ENABLED_CRYPT_TESTS" = "yes"; then
AC_MSG_ERROR([--enable-crypttests is incompatible with --enable-linuxkm.])
fi
if test "$ENABLED_SMALL_STACK" != "yes"; then
AC_MSG_ERROR([--enable-smallstack is required for --enable-linuxkm.])
fi

View File

@ -22,5 +22,6 @@ libwolfssl-y := $(WOLFSSL_OBJ_FILES)
ccflags-y := $(WOLFSSL_CFLAGS)
%/libwolfssl.mod.o: ccflags-y :=
%/lkm_testcrypto.o: ccflags-y += -DNO_MAIN_DRIVER
asflags-y := $(WOLFSSL_ASFLAGS)

View File

@ -27,6 +27,12 @@ WOLFSSL_ASFLAGS=-DHAVE_CONFIG_H -I$(SRC_TOP) -DBUILDING_WOLFSSL $(AM_CCASFLAGS)
WOLFSSL_OBJ_FILES=linuxkm/module_hooks.o $(patsubst %.lo, %.o, $(patsubst src/src_libwolfssl_la-%, src/%, $(patsubst src/libwolfssl_la-%, src/%, $(patsubst wolfcrypt/src/src_libwolfssl_la-%, wolfcrypt/src/%, $(src_libwolfssl_la_OBJECTS)))))
ifeq "$(ENABLED_CRYPT_TESTS)" "yes"
WOLFSSL_OBJ_FILES+=linuxkm/lkm_testcrypto.o
else
WOLFSSL_CFLAGS+=-DNO_CRYPT_TEST
endif
export WOLFSSL_CFLAGS WOLFSSL_ASFLAGS WOLFSSL_OBJ_FILES
libwolfssl.ko:

29425
linuxkm/lkm_testcrypto.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,9 @@
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/ssl.h>
#ifndef NO_CRYPT_TEST
#include <wolfcrypt/test/test.h>
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
static int __init wolfssl_init(void)
@ -22,6 +25,14 @@ static int wolfssl_init(void)
return -ENOTRECOVERABLE;
}
#ifndef NO_CRYPT_TEST
ret = wolfcrypt_test(NULL);
if (ret != WOLFSSL_SUCCESS) {
pr_err("wolfcrypt_test() failed: %s", wc_GetErrorString(ret));
return -ENOTRECOVERABLE;
}
#endif
pr_info("wolfSSL " LIBWOLFSSL_VERSION_STRING " loaded. See https://www.wolfssl.com/ for information.\n");
pr_info("Copyright (C) 2006-2020 wolfSSL Inc. All Rights Reserved.\n");

View File

@ -2089,8 +2089,6 @@ extern void uITRON4_free(void *p) ;
#define NO_DEV_RANDOM
#define NO_WRITEV
#define NO_FILESYSTEM
#define NO_CRYPT_BENCHMARK 1
#define NO_CRYPT_TEST 1
#define SIZEOF_LONG 8
#define SIZEOF_LONG_LONG 8
#define CHAR_BIT 8