From 62eff27459dc395b6c4b9033aa20a456a0f02d9d Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 30 Jul 2024 13:21:45 -0700 Subject: [PATCH 1/2] Updated CMake to include new examples. Fixed doxygen issue with `wolfTPM2_GetKeyTemplate_EK` -> `curveID`. Fixed issue with possible create key timeout by always adding `XTPM_WAIT` for Linux. --- CMakeLists.txt | 8 ++++++++ wolftpm/tpm2_types.h | 15 +++++++-------- wolftpm/tpm2_wrap.h | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d11f2ba3..74a14651 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -291,17 +291,25 @@ if (WOLFTPM_EXAMPLES) add_tpm_example(make_credential attestation/make_credential.c) add_tpm_example(bench bench/bench.c) add_tpm_example(csr csr/csr.c) + add_tpm_example(get_ek_certs endorsement/get_ek_certs.c) + add_tpm_example(ifx_fw_extract firmware/ifx_fw_extract.c) + add_tpm_example(ifx_fw_update firmware/ifx_fw_update.c) add_tpm_example(gpio_config gpio/gpio_config.c) add_tpm_example(gpio_read gpio/gpio_read.c) add_tpm_example(gpio_set gpio/gpio_set.c) + add_tpm_example(create_primary keygen/create_primary.c) + add_tpm_example(external_import keygen/external_import.c) add_tpm_example(keygen keygen/keygen.c) add_tpm_example(keyimport keygen/keyimport.c) add_tpm_example(keyload keygen/keyload.c) add_tpm_example(flush management/flush.c) add_tpm_example(native_test native/native_test.c) + add_tpm_example(counter nvram/counter.c) + add_tpm_example(policy_nv nvram/policy_nv.c) add_tpm_example(read nvram/read.c) add_tpm_example(store nvram/store.c) add_tpm_example(extend pcr/extend.c) + add_tpm_example(policy_sign pcr/policy_sign.c) add_tpm_example(quote pcr/quote.c) add_tpm_example(read_pcr pcr/read_pcr.c) add_tpm_example(reset pcr/reset.c) diff --git a/wolftpm/tpm2_types.h b/wolftpm/tpm2_types.h index 0b7f771a..3635ef62 100644 --- a/wolftpm/tpm2_types.h +++ b/wolftpm/tpm2_types.h @@ -432,16 +432,15 @@ typedef int64_t INT64; /* ---------------------------------------------------------------------------*/ /* Optional delay between polling */ -#if (defined(WOLFTPM_SLB9670) || defined(WOLFTPM_SLB9672)) && !defined(XTPM_WAIT) - /* For Infineon SLB9670 and SLB9672 adding 10us delay improves performance +#if defined(__linux__) && !defined(XTPM_WAIT) + /* Avoid excessive polling. + * For Infineon SLB9670 and SLB9672 adding 10us delay improves performance * and prevents issue with rapid use at higher speeds */ - #ifdef __linux__ - #ifndef XTPM_WAIT_POLLING_US - #define XTPM_WAIT_POLLING_US 10 /* 0.01ms */ - #endif - #include - #define XTPM_WAIT() usleep(XTPM_WAIT_POLLING_US); + #ifndef XTPM_WAIT_POLLING_US + #define XTPM_WAIT_POLLING_US 10 /* 0.01ms */ #endif + #include + #define XTPM_WAIT() usleep(XTPM_WAIT_POLLING_US); #endif #ifndef XTPM_WAIT #define XTPM_WAIT() /* just poll without delay by default */ diff --git a/wolftpm/tpm2_wrap.h b/wolftpm/tpm2_wrap.h index a3013dfe..84bbc28a 100644 --- a/wolftpm/tpm2_wrap.h +++ b/wolftpm/tpm2_wrap.h @@ -2684,7 +2684,7 @@ WOLFTPM_API int wolfTPM2_GetKeyTemplate_KeySeal(TPMT_PUBLIC* publicTemplate, TPM \param publicTemplate pointer to an empty structure of TPMT_PUBLIC type, to store the new template \param alg can be only TPM_ALG_RSA or TPM_ALG_ECC, see Note above \param keyBits integer value, specifying bits for the key, typically 2048 (RSA) or 256 (ECC) - \param curveId use one of the accepted TPM_ECC_CURVE values like TPM_ECC_NIST_P256 (only used when alg=TPM_ALG_ECC) + \param curveID use one of the accepted TPM_ECC_CURVE values like TPM_ECC_NIST_P256 (only used when alg=TPM_ALG_ECC) \param nameAlg integer value of TPMI_ALG_HASH type, specifying a valid TPM2 hashing algorithm (typically TPM_ALG_SHA256) \param highRange integer value: 0=low range, 1=high range From a441646682552601130aab2fa73011a758754f3c Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 30 Jul 2024 14:52:34 -0700 Subject: [PATCH 2/2] Fixes for wolfTPM documentation generation. --- docs/Doxyfile | 20 ++++++++++---------- docs/README.md | 12 ++++++------ examples/README.md | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/Doxyfile b/docs/Doxyfile index a072ad38..b94acf0c 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -865,7 +865,14 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = ./docs/README.md ./wolftpm/tpm2.h ./wolftpm/tpm2_wrap.h ./hal/tpm_io.h +INPUT = ./docs/README.md \ + ./examples/README.md \ + ./examples/pcr/README.md \ + ./examples/attestation/README.md \ + ./examples/boot/README.md \ + ./wolftpm/tpm2.h \ + ./wolftpm/tpm2_wrap.h \ + ./hal/tpm_io.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -954,7 +961,7 @@ RECURSIVE = NO # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = ./examples +EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -1162,13 +1169,6 @@ VERBATIM_HEADERS = YES ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored @@ -2065,7 +2065,7 @@ MAN_LINKS = NO # captures the structure of the code including all documentation. # The default value is: NO. -GENERATE_XML = NO +GENERATE_XML = YES # The XML_OUTPUT tag is used to specify where the XML pages will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of diff --git a/docs/README.md b/docs/README.md index b72472fa..537a4484 100644 --- a/docs/README.md +++ b/docs/README.md @@ -63,7 +63,7 @@ cd wolftpm make ``` -For detailed build instructions see [/README.md](/README.md#building). +For detailed build instructions see [README.md](/README.md#building). ## Getting Started @@ -73,17 +73,17 @@ To interface with the hardware platform that is running these applications, plea ### Examples -See [/examples/README.md](/examples/README.md) +See [examples/README.md](/examples/README.md) ### Benchmarks -See [/README.md](/README.md#tpm2-benchmarks) +See [README.md](/README.md#tpm2-benchmarks) ## wolfTPM Library Design ### Library Headers -wolfTPM header files are located in [/wolftpm](/wolftpm). +wolfTPM header files are located in [wolftpm](/wolftpm). The general header files that should be included from wolfTPM is shown below: @@ -104,11 +104,11 @@ See [https://www.wolfssl.com/docs/wolftpm-manual/](https://www.wolfssl.com/docs/ ### TPM 2.0 TCG API's -See [/wolftpm/tpm2.h](/wolftpm/tpm2.h) for inline doxygen style API documentation. +See [wolftpm/tpm2.h](/wolftpm/tpm2.h) for inline doxygen style API documentation. ### wolfTPM Wrapper API's -See [/wolftpm/tpm2_wrap.h](/wolftpm/tpm2_wrap.h) for inline doxygen style API documentation. +See [wolftpm/tpm2_wrap.h](/wolftpm/tpm2_wrap.h) for inline doxygen style API documentation. ## Support diff --git a/examples/README.md b/examples/README.md index cc557090..cc3601b2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -38,7 +38,7 @@ This example demonstrates the use of `authSession` (authorization Session) and ` Demonstrates the generation of TPM2.0 Quote used for attestation of the system state by putting PCR value(s) in a TPM signed structure. -More information about how to test and use PCR attestation can be found in the in [examples/pcr/README.md](./examples/pcr/README.md). +More information about how to test and use PCR attestation can be found in the in [examples/pcr/README.md](/examples/pcr/README.md). `./examples/pcr/quote` `./examples/pcr/extend`