Skip to content

Commit

Permalink
Add support for --with-wolfcrypt=/dir/. Fix for build error with `-…
Browse files Browse the repository at this point in the history
…-disable-wolfcrypt`. Fix for unused `auth` in store example. ZD 12204
  • Loading branch information
dgarske committed May 13, 2021
1 parent 2f00a4b commit 4e351b1
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 62 deletions.
43 changes: 42 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@ fi


# wolfCrypt
AC_MSG_CHECKING([for wolfSSL])
WOLFSSL_URL="http://www.wolfssl.com/download.html"
AC_ARG_WITH(wolfcrypt,
[AC_HELP_STRING([--with-wolfcrypt=PATH], [PATH to wolfssl install (default /usr/local)])],
[
if test "x$withval" != "xno" ; then
if test -d "$withval/lib"; then
LDFLAGS="$LDFLAGS -L${withval}/lib"
fi
if test -d "$withval/include"; then
CPPFLAGS="$CPPFLAGS -I${withval}/include"
fi
fi
if test "x$withval" = "xyes" ; then
LDFLAGS="$LDFLAGS -L/usr/local/lib"
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
fi
]
)

AC_ARG_ENABLE([wolfcrypt],
[AS_HELP_STRING([--enable-wolfcrypt],[Enable wolfCrypt hooks for RNG, Auth Sessions and Parameter encryption (default: enabled)])],
[ ENABLED_WOLFCRYPT=$enableval ],
Expand All @@ -135,12 +155,33 @@ AC_ARG_ENABLE([wolfcrypt],

if test "x$ENABLED_WOLFCRYPT" = "xyes"
then
TAO_REQUIRE_LIBWOLFSSL
LIBS="$LIBS -lwolfssl"

AC_LIB_HAVE_LINKFLAGS(wolfssl,,
[
#include <wolfssl/wolfcrypt/wc_port.h>
],[
wolfCrypt_Init();
])
AM_CONDITIONAL(HAVE_LIBWOLFSSL, [test "x${ac_cv_libwolfssl}" = "xyes"])

AS_IF([test "x${ac_cv_libwolfssl}" = "xyes"],[
save_LIBS="${LIBS}"
LIBS="${LIBS} ${LTLIBWOLFSSL}"
AC_CHECK_FUNCS(wolfCrypt_Cleanup)
LIBS="$save_LIBS"
])

if test "x$ac_cv_libwolfssl" = "xno" && test "x$ENABLED_WOLFCRYPT" = "xno"; then
AC_MSG_ERROR([WolfSSL library not found. You can get it from $WOLFSSL_URL
If it's already installed, specify its path using --with-wolfcrypt=/dir/])
fi
else
AM_CFLAGS="$AM_CFLAGS -DWOLFTPM2_NO_WOLFCRYPT"
fi



# I2C Support
AC_ARG_ENABLE([i2c],
[AS_HELP_STRING([--enable-i2c],[Enable I2C TPM Support (default: disabled)])],
Expand Down
4 changes: 3 additions & 1 deletion examples/attestation/activate_credential.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ int TPM2_ActivateCredential_Example(void* userCtx, int argc, char *argv[])
WOLFTPM2_KEY storage;
WOLFTPM2_KEYBLOB akKey;
WOLFTPM2_SESSION tpmSession;
#if !defined(WOLFTPM2_NO_WOLFCRYPT) && !defined(NO_FILESYSTEM)
FILE *fp;
int dataSize = 0;
#endif
const char *input = "cred.blob";
const char *keyblob = "keyblob.bin";
int dataSize = 0;

union {
ActivateCredential_In activCred;
Expand Down
4 changes: 3 additions & 1 deletion examples/attestation/make_credential.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ int TPM2_MakeCredential_Example(void* userCtx, int argc, char *argv[])
WOLFTPM2_DEV dev;
WOLFTPM2_KEY storage;
WOLFTPM2_KEYBLOB akKey;
#if !defined(WOLFTPM2_NO_WOLFCRYPT) && !defined(NO_FILESYSTEM)
FILE *fp;
int dataSize = 0;
#endif
const char *output = "cred.blob";
const char *keyblob = "keyblob.bin";
int dataSize = 0;

union {
MakeCredential_In makeCred;
Expand Down
2 changes: 0 additions & 2 deletions examples/nvram/store.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ int TPM2_NVRAM_Store_Example(void* userCtx, int argc, char *argv[])
WOLFTPM2_SESSION tpmSession;
WOLFTPM2_HANDLE parent;
WOLFTPM2_NV nv;
TPM2B_AUTH auth;
word32 nvAttributes;
const char* filename = "keyblob.bin";
int paramEncAlg = TPM_ALG_NULL;
Expand Down Expand Up @@ -112,7 +111,6 @@ int TPM2_NVRAM_Store_Example(void* userCtx, int argc, char *argv[])
XMEMSET(&keyBlob, 0, sizeof(keyBlob));
XMEMSET(&tpmSession, 0, sizeof(tpmSession));
XMEMSET(&parent, 0, sizeof(parent));
XMEMSET(&auth, 0, sizeof(auth));

rc = wolfTPM2_Init(&dev, TPM2_IoCb, userCtx);
if (rc != TPM_RC_SUCCESS) {
Expand Down
57 changes: 0 additions & 57 deletions m4/have_wolfssl.m4

This file was deleted.

0 comments on commit 4e351b1

Please sign in to comment.