Moved the new clock_set example into the existing timestamp examples directory. Minor cleanups and fix for printf warning.

pull/117/head
David Garske 2020-09-02 07:27:31 -07:00
parent 4ece9900cb
commit ebfbd4dd2d
8 changed files with 29 additions and 31 deletions

2
.gitignore vendored
View File

@ -37,7 +37,7 @@ examples/timestamp/signed_timestamp
examples/pcr/quote
examples/pcr/extend
examples/pcr/reset
examples/clock/clockSet
examples/timestamp/clock_set
pkcs7tpmsigned.p7s
pkcs7tpmsignedex.p7s
examples/tls/tls_server

View File

@ -151,7 +151,7 @@ This way the user can keep track of relative and current time using the TPM cloc
Note: If the new time value makes a change bigger than the TPM clock update interval, then the TPM will first update its volatile register for time and then the non-volatile register for time. This may cause a narrow delay before the commands returns execution to the user. Depending on the TPM manufacturer, the delay can vary from us to few ms.
`./examples/clock/clockSet`
`./examples/timestamp/clock_set`
## Benchmark

View File

@ -1,14 +0,0 @@
# vim:ft=automake
# All paths should be given relative to the root
if BUILD_EXAMPLES
noinst_PROGRAMS += examples/clock/clockSet
noinst_HEADERS += examples/clock/clockSet.h
examples_clock_clockSet_SOURCES = examples/clock/clockSet.c \
examples/tpm_io.c
examples_clock_clockSet_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
examples_clock_clockSet_DEPENDENCIES = src/libwolftpm.la
endif
dist_example_DATA+= examples/clock/clockSet.c
DISTCLEANFILES+= examples/clock/.libs/clockSet

View File

@ -9,7 +9,6 @@ include examples/csr/include.am
include examples/pkcs7/include.am
include examples/timestamp/include.am
include examples/pcr/include.am
include examples/clock/include.am
dist_example_DATA+= examples/README.md \
examples/tpm_io.c \

View File

@ -1,4 +1,4 @@
/* clockSet.c
/* clock_set.c
*
* Copyright (C) 2006-2020 wolfSSL Inc.
*
@ -25,15 +25,15 @@
#ifndef WOLFTPM2_NO_WRAPPER
#include <examples/clock/clockSet.h>
#include <examples/tpm_io.h>
#include <examples/tpm_test.h>
#include "clock_set.h"
#include <stdio.h>
#include <stdlib.h>
/******************************************************************************/
/* --- BEGIN TPM clockSet Test -- */
/* --- BEGIN TPM Clock Set Example -- */
/******************************************************************************/
static void usage(void)
@ -106,9 +106,9 @@ int TPM2_ClockSet_Test(void* userCtx, int argc, char *argv[])
printf("TPM2_ReadClock: success\n");
#ifdef DEBUG_WOLFTPM
printf("TPM2_ReadClock: (uptime) time=%lu\n",
cmdOut.readClock.currentTime.time);
(long unsigned int)cmdOut.readClock.currentTime.time);
printf("TPM2_ReadClock: (total) clock=%lu\n",
cmdOut.readClock.currentTime.clockInfo.clock);
(long unsigned int)cmdOut.readClock.currentTime.clockInfo.clock);
#endif
oldClock = cmdOut.readClock.currentTime.clockInfo.clock;
@ -137,13 +137,14 @@ int TPM2_ClockSet_Test(void* userCtx, int argc, char *argv[])
printf("TPM2_ReadClock: success\n");
#ifdef DEBUG_WOLFTPM
printf("TPM2_ReadClock: (uptime) time=%lu\n",
cmdOut.readClock.currentTime.time);
(long unsigned int)cmdOut.readClock.currentTime.time);
printf("TPM2_ReadClock: (total) clock=%lu\n",
cmdOut.readClock.currentTime.clockInfo.clock);
(long unsigned int)cmdOut.readClock.currentTime.clockInfo.clock);
#endif
newClock = cmdOut.readClock.currentTime.clockInfo.clock;
printf("\n\t oldClock=%lu \n\t newClock=%lu \n\n", oldClock, newClock);
printf("\n\t oldClock=%lu \n\t newClock=%lu \n\n",
(long unsigned int)oldClock, (long unsigned int)newClock);
exit:
@ -159,7 +160,7 @@ exit_badargs:
}
/******************************************************************************/
/* --- END TPM Timestamp Test -- */
/* --- END TPM Clock Set Example -- */
/******************************************************************************/
#endif /* !WOLFTPM2_NO_WRAPPER */

View File

@ -1,4 +1,4 @@
/* clockSet.h
/* clock_set.h
*
* Copyright (C) 2006-2020 wolfSSL Inc.
*

View File

@ -12,3 +12,15 @@ endif
dist_example_DATA+= examples/timestamp/signed_timestamp.c
DISTCLEANFILES+= examples/timestamp/.libs/signed_timestamp
if BUILD_EXAMPLES
noinst_PROGRAMS += examples/timestamp/clock_set
noinst_HEADERS += examples/timestamp/clock_set.h
examples_timestamp_clock_set_SOURCES = examples/timestamp/clock_set.c \
examples/tpm_io.c
examples_timestamp_clock_set_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
examples_timestamp_clock_set_DEPENDENCIES = src/libwolftpm.la
endif
dist_example_DATA+= examples/timestamp/clock_set.c
DISTCLEANFILES+= examples/timestamp/.libs/clock_set

View File

@ -27,9 +27,9 @@
#ifndef WOLFTPM2_NO_WRAPPER
#include <examples/timestamp/signed_timestamp.h>
#include <examples/tpm_io.h>
#include <examples/tpm_test.h>
#include "signed_timestamp.h"
#include <stdio.h>