diff --git a/Makefile.am b/Makefile.am index d8601d8b..e023c977 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,14 +6,18 @@ noinst_HEADERS = check_PROGRAMS = dist_noinst_SCRIPTS = DISTCLEANFILES = +pkginclude_HEADERS = +EXTRA_DIST = ACLOCAL_AMFLAGS = -I m4 +AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libwolfprov.la include src/include.am include include/include.am include test/include.am +include certs/include.am #include scripts/include.am #noinst_PROGRAMS += bench @@ -22,3 +26,17 @@ include test/include.am #DISTCLEANFILES += .libs/bench test: check +# By default, make distcheck will only add wolfProvider/ as an include directory. +# So, for example, a file like unit.h that has #include +# won't be able to find wp_logging.h, because +# wolfProvider/include isn't an include directory. We add it here. +# +# The OpenSSL lib and include directories won't be visible to make distcheck +# either because make distcheck runs ./configure with no other options. If +# OpenSSL isn't installed in a standard location, this naked configure command +# will fail to find it. We tell it where to find the include and lib directory +# for OpenSSL here. +AM_DISTCHECK_CONFIGURE_FLAGS=CPPFLAGS="-I@abs_top_srcdir@/include \ + @OPENSSL_INCLUDES@" \ + LDFLAGS="@OPENSSL_LDFLAGS@" + diff --git a/certs/include.am b/certs/include.am new file mode 100644 index 00000000..3c30b33c --- /dev/null +++ b/certs/include.am @@ -0,0 +1,8 @@ + +# for test_rsa.c +dist_noinst_SCRIPTS += certs/server-key.pem +dist_noinst_SCRIPTS += certs/server-cert.pem + +# for test_ecc.c +dist_noinst_SCRIPTS += certs/server-ecc.pem +dist_noinst_SCRIPTS += certs/ecc-key.pem diff --git a/configure.ac b/configure.ac index c4ab0d1b..483189d6 100644 --- a/configure.ac +++ b/configure.ac @@ -51,8 +51,6 @@ if test "x$have_wolfssl" = "xyes"; then LDFLAGS="$LDFLAGS $WOLFSSL_LDFLAGS" fi -AC_CHECK_HEADERS([wolfssl/wolfcrypt/kdf.h]) - # DEBUG DEBUG_CFLAGS="-g -O0 -DWOLFPROV_DEBUG" diff --git a/include/include.am b/include/include.am index c185defc..aabbf9a1 100644 --- a/include/include.am +++ b/include/include.am @@ -2,14 +2,12 @@ # All paths should be given relative to the root # -noinst_HEADERS += include/wolfprovider/version.h -noinst_HEADERS += include/wolfprovider/alg_funcs.h noinst_HEADERS += include/wolfprovider/internal.h -noinst_HEADERS += include/wolfprovider/settings.h -noinst_HEADERS += include/wolfprovider/wp_logging.h -noinst_HEADERS += include/wolfprovider/wp_fips.h -noinst_HEADERS += include/wolfprovider/wp_params.h -noinst_HEADERS += include/wolfprovider/wp_wolfprov.h - -#pkginclude_HEADERS = +pkginclude_HEADERS += include/wolfprovider/version.h +pkginclude_HEADERS += include/wolfprovider/alg_funcs.h +pkginclude_HEADERS += include/wolfprovider/settings.h +pkginclude_HEADERS += include/wolfprovider/wp_logging.h +pkginclude_HEADERS += include/wolfprovider/wp_fips.h +pkginclude_HEADERS += include/wolfprovider/wp_params.h +pkginclude_HEADERS += include/wolfprovider/wp_wolfprov.h diff --git a/scripts/utils-wolfssl.sh b/scripts/utils-wolfssl.sh index ef4dbad3..497cdf3c 100755 --- a/scripts/utils-wolfssl.sh +++ b/scripts/utils-wolfssl.sh @@ -24,7 +24,7 @@ # SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -WOLFSSL_GIT="https://github.com/wolfSSL/wolfssl.git" +WOLFSSL_GIT=${WOLFSSL_GIT:-"https://github.com/wolfSSL/wolfssl.git"} WOLFSSL_TAG=${WOLFSSL_TAG:-"v5.6.3-stable"} WOLFSSL_SOURCE_DIR=${SCRIPT_DIR}/../wolfssl-source WOLFSSL_INSTALL_DIR=${SCRIPT_DIR}/../wolfssl-install @@ -42,7 +42,7 @@ clone_wolfssl() { if [ ! -d ${WOLFSSL_SOURCE_DIR} ]; then printf "\tClone wolfSSL ${WOLFSSL_TAG} ... " - git clone --depth=1 -b ${WOLFSSL_TAG} ${WOLFSSL_GIT} \ + git clone -b ${WOLFSSL_TAG} ${WOLFSSL_GIT} \ ${WOLFSSL_SOURCE_DIR} >>$LOG_FILE 2>&1 if [ $? != 0 ]; then printf "ERROR.\n" diff --git a/test/include.am b/test/include.am index 3549d638..75b90760 100644 --- a/test/include.am +++ b/test/include.am @@ -9,6 +9,8 @@ check_PROGRAMS += test/unit.test noinst_PROGRAMS += test/unit.test DISTCLEANFILES += test/.libs/unit.test +# Override the 'certs' directory with the toplevel source directory for 'make distcheck' to work +test_unit_test_CPPFLAGS = -DCERTS_DIR='"$(abs_top_srcdir)/certs"' test_unit_test_SOURCES = \ test/test_aestag.c \ test/test_cipher.c \ diff --git a/test/test_ecc.c b/test/test_ecc.c index 4dc8272f..fcb51ebe 100644 --- a/test/test_ecc.c +++ b/test/test_ecc.c @@ -1411,7 +1411,7 @@ int test_ec_load_key(void* data) params[0] = OSSL_PARAM_construct_end(); PRINT_MSG("Open ECC private key"); - ctx = OSSL_STORE_open_ex("./certs/ecc-key.pem", wpLibCtx, NULL, NULL, NULL, + ctx = OSSL_STORE_open_ex(CERTS_DIR "/ecc-key.pem", wpLibCtx, NULL, NULL, NULL, params, NULL, NULL); err = ctx == NULL; if (err == 0) { @@ -1446,7 +1446,7 @@ int test_ec_load_cert(void* data) params[0] = OSSL_PARAM_construct_end(); PRINT_MSG("Open certificate with ECC public key"); - ctx = OSSL_STORE_open_ex("./certs/server-ecc.pem", wpLibCtx, NULL, NULL, + ctx = OSSL_STORE_open_ex(CERTS_DIR "/server-ecc.pem", wpLibCtx, NULL, NULL, NULL, params, NULL, NULL); err = ctx == NULL; if (err == 0) { diff --git a/test/test_rsa.c b/test/test_rsa.c index 1f4deebd..fd07be1f 100644 --- a/test/test_rsa.c +++ b/test/test_rsa.c @@ -749,7 +749,7 @@ int test_rsa_load_key(void* data) params[0] = OSSL_PARAM_construct_end(); PRINT_MSG("Open RSA private key"); - ctx = OSSL_STORE_open_ex("./certs/server-key.pem", wpLibCtx, NULL, NULL, + ctx = OSSL_STORE_open_ex(CERTS_DIR "/server-key.pem", wpLibCtx, NULL, NULL, NULL, params, NULL, NULL); err = ctx == NULL; if (err == 0) { @@ -784,7 +784,7 @@ int test_rsa_load_cert(void* data) params[0] = OSSL_PARAM_construct_end(); PRINT_MSG("Open certificate with RSA public key"); - ctx = OSSL_STORE_open_ex("./certs/server-cert.pem", wpLibCtx, NULL, NULL, + ctx = OSSL_STORE_open_ex(CERTS_DIR "/server-cert.pem", wpLibCtx, NULL, NULL, NULL, params, NULL, NULL); err = ctx == NULL; if (err == 0) { diff --git a/test/unit.h b/test/unit.h index 224911af..749cbd79 100644 --- a/test/unit.h +++ b/test/unit.h @@ -62,6 +62,10 @@ void print_buffer(const char *desc, const unsigned char *buffer, size_t len); #define TEST_DECL(func, data) { #func, func, data, 0, 0, 0 } #endif +#ifndef CERTS_DIR +#define CERTS_DIR "./certs" +#endif + typedef int (*TEST_FUNC)(void *data); typedef struct TEST_CASE { const char *name;