diff --git a/.gitignore b/.gitignore index b232249..722a012 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/examples/README.md b/examples/README.md index 6736d6a..4a60b7d 100644 --- a/examples/README.md +++ b/examples/README.md @@ -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 diff --git a/examples/clock/include.am b/examples/clock/include.am deleted file mode 100644 index ed9dfc4..0000000 --- a/examples/clock/include.am +++ /dev/null @@ -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 diff --git a/examples/include.am b/examples/include.am index 92a0940..2deb448 100644 --- a/examples/include.am +++ b/examples/include.am @@ -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 \ diff --git a/examples/clock/clockSet.c b/examples/timestamp/clock_set.c similarity index 89% rename from examples/clock/clockSet.c rename to examples/timestamp/clock_set.c index 83b29a5..1d9d131 100644 --- a/examples/clock/clockSet.c +++ b/examples/timestamp/clock_set.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 #include #include +#include "clock_set.h" #include #include /******************************************************************************/ -/* --- 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 */ diff --git a/examples/clock/clockSet.h b/examples/timestamp/clock_set.h similarity index 98% rename from examples/clock/clockSet.h rename to examples/timestamp/clock_set.h index 9c04b2f..555b2ea 100644 --- a/examples/clock/clockSet.h +++ b/examples/timestamp/clock_set.h @@ -1,4 +1,4 @@ -/* clockSet.h +/* clock_set.h * * Copyright (C) 2006-2020 wolfSSL Inc. * diff --git a/examples/timestamp/include.am b/examples/timestamp/include.am index 12c7cc3..580dbf0 100644 --- a/examples/timestamp/include.am +++ b/examples/timestamp/include.am @@ -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 diff --git a/examples/timestamp/signed_timestamp.c b/examples/timestamp/signed_timestamp.c index 8aca12e..3a0152f 100644 --- a/examples/timestamp/signed_timestamp.c +++ b/examples/timestamp/signed_timestamp.c @@ -27,9 +27,9 @@ #ifndef WOLFTPM2_NO_WRAPPER -#include #include #include +#include "signed_timestamp.h" #include