Minor cleanups. Added way to get TPM's WC_RNG.

pull/12/head
David Garske 2018-05-17 16:21:10 -07:00
parent cecf33ae03
commit 9f574a89fb
4 changed files with 18 additions and 4 deletions

View File

@ -103,13 +103,18 @@ AC_ARG_ENABLE([examples],
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$ENABLED_EXAMPLES" = "xyes"])
# Examples
# Wrapper
AC_ARG_ENABLE([wrapper],
[AS_HELP_STRING([--enable-wrapper],[Enable wrapper code (default: enabled)])],
[ ENABLED_WRAPPER=$enableval ],
[ ENABLED_WRAPPER=yes ]
)
if test "$ENABLED_WRAPPER" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFTPM2_NO_WRAPPER"
fi
AM_CONDITIONAL([BUILD_WRAPPER], [test "x$ENABLED_WRAPPER" = "xyes"])

View File

@ -101,7 +101,7 @@ int TPM2_Wrapper_Test(void* userCtx)
if (rc != 0) return rc;
#endif
/* Get the RSA endosement key (EK) */
/* Get the RSA endorsement key (EK) */
rc = wolfTPM2_GetKeyTemplate_RSA_EK(&publicTemplate);
if (rc != 0) goto exit;
rc = wolfTPM2_CreatePrimaryKey(&dev, &ekKey, TPM_RH_ENDORSEMENT,
@ -109,7 +109,7 @@ int TPM2_Wrapper_Test(void* userCtx)
if (rc != 0) goto exit;
wolfTPM2_UnloadHandle(&dev, &ekKey.handle);
/* Get the ECC endosement key (EK) */
/* Get the ECC endorsement key (EK) */
rc = wolfTPM2_GetKeyTemplate_ECC_EK(&publicTemplate);
if (rc != 0) goto exit;
rc = wolfTPM2_CreatePrimaryKey(&dev, &ekKey, TPM_RH_ENDORSEMENT,
@ -131,7 +131,7 @@ int TPM2_Wrapper_Test(void* userCtx)
&publicTemplate, (byte*)storageKeyAuth, sizeof(storageKeyAuth)-1);
if (rc != 0) goto exit;
/* Move this key into peristent storage */
/* Move this key into persistent storage */
rc = wolfTPM2_NVStoreKey(&dev, TPM_RH_OWNER, &storageKey,
TPM2_DEMO_PERSISTENT_STORAGE_KEY_HANDLE);
if (rc != 0) goto exit;

View File

@ -1015,6 +1015,13 @@ int wolfTPM2_NVDelete(WOLFTPM2_DEV* dev, TPM_HANDLE authHandle,
return rc;
}
WC_RNG* wolfTPM2_GetRng(WOLFTPM2_DEV* dev)
{
if (dev)
return &dev->ctx.rng;
return NULL;
}
int wolfTPM2_Clear(WOLFTPM2_DEV* dev)
{
int rc;

View File

@ -111,6 +111,8 @@ WOLFTPM_API int wolfTPM2_NVStoreKey(WOLFTPM2_DEV* dev, TPM_HANDLE primaryHandle,
WOLFTPM_API int wolfTPM2_NVDeleteKey(WOLFTPM2_DEV* dev, TPM_HANDLE primaryHandle,
WOLFTPM2_KEY* key);
WOLFTPM_API WC_RNG* wolfTPM2_GetRng(WOLFTPM2_DEV* dev);
WOLFTPM_API int wolfTPM2_UnloadHandle(WOLFTPM2_DEV* dev, WOLFTPM2_HANDLE* handle);
WOLFTPM_API int wolfTPM2_Clear(WOLFTPM2_DEV* dev);