mirror of https://github.com/wolfSSL/wolfTPM.git
Moved the new clock_set example into the existing timestamp examples directory. Minor cleanups and fix for printf warning.
parent
4ece9900cb
commit
ebfbd4dd2d
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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 \
|
||||
|
|
|
@ -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)
|
||||
|
@ -67,10 +67,10 @@ int TPM2_ClockSet_Test(void* userCtx, int argc, char *argv[])
|
|||
|
||||
UINT64 oldClock, newClock;
|
||||
|
||||
if(argc == 2) {
|
||||
if (argc == 2) {
|
||||
newClock = atoi(argv[1]);
|
||||
}
|
||||
else if(argc == 1) {
|
||||
else if (argc == 1) {
|
||||
newClock = 0;
|
||||
}
|
||||
else {
|
||||
|
@ -106,15 +106,15 @@ 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;
|
||||
|
||||
/* Set the TPM clock forward */
|
||||
cmdIn.clockSet.auth = TPM_RH_OWNER;
|
||||
if(newClock)
|
||||
if (newClock)
|
||||
cmdIn.clockSet.newTime = newClock;
|
||||
else
|
||||
cmdIn.clockSet.newTime = oldClock + 50000;
|
||||
|
@ -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 */
|
|
@ -1,4 +1,4 @@
|
|||
/* clockSet.h
|
||||
/* clock_set.h
|
||||
*
|
||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||
*
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue