mirror of https://github.com/wolfSSL/wolfTPM.git
HAL refactor and documentation improvements. Move example HAL implementations into new `hal` directory. Include the example HAL in the library when building. Updated HAL IO documentation.
parent
c038cede44
commit
1ea4a591a8
|
@ -35,8 +35,10 @@ set(TPM_SOURCES
|
|||
src/tpm2_tis.c
|
||||
src/tpm2_winapi.c
|
||||
src/tpm2_wrap.c
|
||||
hal/tpm_io.c
|
||||
)
|
||||
|
||||
|
||||
# default to build shared library
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" ON)
|
||||
add_library(wolftpm ${TPM_SOURCES})
|
||||
|
@ -157,7 +159,6 @@ endif()
|
|||
|
||||
if (WOLFTPM_EXAMPLES)
|
||||
add_library(tpm_test_lib STATIC
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
)
|
||||
target_link_libraries(tpm_test_lib wolftpm)
|
||||
|
|
|
@ -40,6 +40,7 @@ include certs/include.am
|
|||
include tests/include.am
|
||||
include docs/include.am
|
||||
include wrapper/include.am
|
||||
include hal/include.am
|
||||
|
||||
EXTRA_DIST+= README.md
|
||||
EXTRA_DIST+= ChangeLog.md
|
||||
|
|
10
README.md
10
README.md
|
@ -70,13 +70,15 @@ Acronyms:
|
|||
|
||||
The examples in this library are written for use on a Raspberry Pi and use the `spi_dev` interface.
|
||||
|
||||
### IO Callback
|
||||
### IO Callback (HAL)
|
||||
|
||||
For interfacing to your hardware platform see the example `examples/tpm_io.c` callback function `TPM2_IoCb`. Here you can modify or insert your own IO callback code for the TPM demo.
|
||||
See the HAL manual in [`hal/README.md] (hal/README.md).
|
||||
|
||||
There are examples here for Linux, STM32 CubeMX, Atmel ASF, Xilinx, Infineon TriCore and BareBox.
|
||||
For interfacing to your hardware interface (SPI/I2C) a single HAL callback is used and configuration on initialization when calling `TPM2_Init` or `wolfTPM2_Init`.
|
||||
|
||||
The advanced IO option (`--enable-advio`/`WOLFTPM_ADV_IO`) is required for I2C support because it adds the register and read/write flag as parameter to the IO callback.
|
||||
There are HAL examples in `hal` directory for Linux, STM32 CubeMX, Atmel ASF, Xilinx, Infineon TriCore and BareBox.
|
||||
|
||||
We also support an advanced IO option (`--enable-advio`/`WOLFTPM_ADV_IO`), which adds the register and read/write flag as parameter to the IO callback. This is required for I2C support.
|
||||
|
||||
### Hardware
|
||||
|
||||
|
|
14
configure.ac
14
configure.ac
|
@ -387,6 +387,18 @@ then
|
|||
fi
|
||||
|
||||
|
||||
# Example HAL implementations
|
||||
AC_ARG_ENABLE([hal],
|
||||
[AS_HELP_STRING([--enable-hal],[Enable example HAL interfaces (default: enabled)])],
|
||||
[ ENABLED_EXAMPLE_HAL=$enableval ],
|
||||
[ ENABLED_EXAMPLE_HAL=yes ]
|
||||
)
|
||||
if test "x$ENABLED_EXAMPLE_HAL" = "xyes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFTPM_EXAMPLE_HAL"
|
||||
fi
|
||||
|
||||
|
||||
# TIS / SPI Check Wait State support
|
||||
# Required for all but Infineon only
|
||||
if test "x$ENABLED_CHECKWAITSTATE" = "xyes" || test "x$ENABLED_AUTODETECT" = "xyes" || test "x$ENABLED_INFINEON" = "xno"
|
||||
|
@ -418,7 +430,7 @@ AM_CONDITIONAL([BUILD_WINAPI], [test "x$ENABLED_WINAPI" = "xyes"])
|
|||
AM_CONDITIONAL([BUILD_NUVOTON], [test "x$ENABLED_NUVOTON" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_CHECKWAITSTATE], [test "x$ENABLED_CHECKWAITSTATE" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_AUTODETECT], [test "x$ENABLED_AUTODETECT" = "xyes"])
|
||||
|
||||
AM_CONDITIONAL([BUILD_HAL], [test "x$ENABLED_EXAMPLE_HAL" = "xyes"])
|
||||
|
||||
|
||||
CREATE_HEX_VERSION
|
||||
|
|
|
@ -66,7 +66,7 @@ For detailed build instructions see [/README.md](/README.md#building).
|
|||
|
||||
The wolfTPM library has TPM 2.0 wrapper tests, native tests, and a sample benchmark application that come ready-to-use after a successful installation of wolfTPM. Below are some instructions on how to run the sample applications yourself.
|
||||
|
||||
To interface with the hardware platform that is running these applications, please see the function "TPM2_IoCb" inside of examples/tpm_io.c.
|
||||
To interface with the hardware platform that is running these applications, please see the function `TPM2_IoCb` inside of `hal/tpm_io.c`.
|
||||
|
||||
### Examples
|
||||
|
||||
|
@ -91,7 +91,7 @@ The general header files that should be included from wolfTPM is shown below:
|
|||
|
||||
### Example Design
|
||||
|
||||
Every example application that is included with wolfTPM includes the `tpm_io.h` header file, located in `/examples`.
|
||||
Every example application that is included with wolfTPM includes the `tpm_io.h` header file, located in `/hal`.
|
||||
|
||||
The `tpm_io.c` file sets up the example HAL IO callback necessary for testing and running the example applications with a Linux Kernel, STM32 CubeMX HAL or Atmel/Microchip ASF. The reference is easily modified, such that custom IO callbacks or different callbacks may be added or removed as desired.
|
||||
|
||||
|
|
|
@ -8,13 +8,11 @@ noinst_PROGRAMS += examples/attestation/make_credential \
|
|||
noinst_HEADERS += examples/attestation/credential.h
|
||||
|
||||
examples_attestation_make_credential_SOURCES = examples/attestation/make_credential.c \
|
||||
examples/tpm_io.c \
|
||||
examples/tpm_test_keys.c
|
||||
examples_attestation_make_credential_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_attestation_make_credential_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
examples_attestation_activate_credential_SOURCES = examples/attestation/activate_credential.c \
|
||||
examples/tpm_io.c \
|
||||
examples/tpm_test_keys.c
|
||||
examples_attestation_activate_credential_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_attestation_activate_credential_DEPENDENCIES = src/libwolftpm.la
|
||||
|
|
|
@ -5,7 +5,6 @@ if BUILD_EXAMPLES
|
|||
noinst_PROGRAMS += examples/bench/bench
|
||||
noinst_HEADERS += examples/bench/bench.h
|
||||
examples_bench_bench_SOURCES = examples/bench/bench.c \
|
||||
examples/tpm_io.c \
|
||||
examples/tpm_test_keys.c
|
||||
examples_bench_bench_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_bench_bench_DEPENDENCIES = src/libwolftpm.la
|
||||
|
|
|
@ -5,8 +5,7 @@ if BUILD_EXAMPLES
|
|||
noinst_PROGRAMS += examples/csr/csr
|
||||
noinst_HEADERS += examples/csr/csr.h
|
||||
examples_csr_csr_SOURCES = examples/csr/csr.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_csr_csr_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_csr_csr_DEPENDENCIES = src/libwolftpm.la
|
||||
endif
|
||||
|
|
|
@ -8,18 +8,15 @@ noinst_PROGRAMS += examples/gpio/gpio_config \
|
|||
|
||||
noinst_HEADERS += examples/gpio/gpio.h
|
||||
|
||||
examples_gpio_gpio_config_SOURCES = examples/gpio/gpio_config.c \
|
||||
examples/tpm_io.c
|
||||
examples_gpio_gpio_config_SOURCES = examples/gpio/gpio_config.c
|
||||
examples_gpio_gpio_config_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_gpio_gpio_config_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
examples_gpio_gpio_read_SOURCES = examples/gpio/gpio_read.c \
|
||||
examples/tpm_io.c
|
||||
examples_gpio_gpio_read_SOURCES = examples/gpio/gpio_read.c
|
||||
examples_gpio_gpio_read_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_gpio_gpio_read_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
examples_gpio_gpio_set_SOURCES = examples/gpio/gpio_set.c \
|
||||
examples/tpm_io.c
|
||||
examples_gpio_gpio_set_SOURCES = examples/gpio/gpio_set.c
|
||||
examples_gpio_gpio_set_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_gpio_gpio_set_DEPENDENCIES = src/libwolftpm.la
|
||||
endif
|
||||
|
|
|
@ -17,16 +17,6 @@ include examples/seal/include.am
|
|||
include examples/attestation/include.am
|
||||
|
||||
dist_example_DATA+= examples/README.md \
|
||||
examples/tpm_io.c \
|
||||
examples/tpm_io_atmel.c \
|
||||
examples/tpm_io_barebox.c \
|
||||
examples/tpm_io_linux.c \
|
||||
examples/tpm_io_infineon.c \
|
||||
examples/tpm_io_microchip.c \
|
||||
examples/tpm_io_st.c \
|
||||
examples/tpm_io_qnx.c \
|
||||
examples/tpm_io_xilinx.c \
|
||||
examples/tpm_io.h \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_test_keys.h \
|
||||
examples/tpm_test.h
|
||||
|
|
|
@ -6,29 +6,25 @@ noinst_HEADERS += examples/keygen/keygen.h
|
|||
|
||||
noinst_PROGRAMS += examples/keygen/create_primary
|
||||
examples_keygen_create_primary_SOURCES = examples/keygen/create_primary.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_keygen_create_primary_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_keygen_create_primary_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
noinst_PROGRAMS += examples/keygen/keyload
|
||||
examples_keygen_keyload_SOURCES = examples/keygen/keyload.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_keygen_keyload_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_keygen_keyload_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
noinst_PROGRAMS += examples/keygen/keygen
|
||||
examples_keygen_keygen_SOURCES = examples/keygen/keygen.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_keygen_keygen_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_keygen_keygen_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
noinst_PROGRAMS += examples/keygen/keyimport
|
||||
examples_keygen_keyimport_SOURCES = examples/keygen/keyimport.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_keygen_keyimport_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_keygen_keyimport_DEPENDENCIES = src/libwolftpm.la
|
||||
endif
|
||||
|
|
|
@ -6,8 +6,7 @@ noinst_PROGRAMS += examples/management/flush
|
|||
|
||||
noinst_HEADERS += examples/management/flush.h
|
||||
|
||||
examples_management_flush_SOURCES = examples/management/flush.c \
|
||||
examples/tpm_io.c
|
||||
examples_management_flush_SOURCES = examples/management/flush.c
|
||||
examples_management_flush_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_management_flush_DEPENDENCIES = src/libwolftpm.la
|
||||
endif
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
if BUILD_EXAMPLES
|
||||
noinst_PROGRAMS += examples/native/native_test
|
||||
noinst_HEADERS += examples/native/native_test.h
|
||||
examples_native_native_test_SOURCES = examples/native/native_test.c \
|
||||
examples/tpm_io.c
|
||||
examples_native_native_test_SOURCES = examples/native/native_test.c
|
||||
examples_native_native_test_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_native_native_test_DEPENDENCIES = src/libwolftpm.la
|
||||
endif
|
||||
|
|
|
@ -6,22 +6,19 @@ noinst_HEADERS += examples/nvram/nvram.h
|
|||
|
||||
noinst_PROGRAMS += examples/nvram/store
|
||||
examples_nvram_store_SOURCES = examples/nvram/store.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_nvram_store_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_nvram_store_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
noinst_PROGRAMS += examples/nvram/read
|
||||
examples_nvram_read_SOURCES = examples/nvram/read.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_nvram_read_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_nvram_read_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
noinst_PROGRAMS += examples/nvram/counter
|
||||
examples_nvram_counter_SOURCES = examples/nvram/counter.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_nvram_counter_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_nvram_counter_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
|
|
|
@ -11,23 +11,19 @@ noinst_HEADERS += examples/pcr/quote.h \
|
|||
examples/pcr/pcr.h
|
||||
|
||||
examples_pcr_quote_SOURCES = examples/pcr/quote.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_pcr_quote_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_pcr_quote_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
examples_pcr_read_pcr_SOURCES = examples/pcr/read_pcr.c \
|
||||
examples/tpm_io.c
|
||||
examples_pcr_read_pcr_SOURCES = examples/pcr/read_pcr.c
|
||||
examples_pcr_read_pcr_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_pcr_read_pcr_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
examples_pcr_extend_SOURCES = examples/pcr/extend.c \
|
||||
examples/tpm_io.c
|
||||
examples_pcr_extend_SOURCES = examples/pcr/extend.c
|
||||
examples_pcr_extend_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_pcr_extend_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
examples_pcr_reset_SOURCES = examples/pcr/reset.c \
|
||||
examples/tpm_io.c
|
||||
examples_pcr_reset_SOURCES = examples/pcr/reset.c
|
||||
examples_pcr_reset_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_pcr_reset_DEPENDENCIES = src/libwolftpm.la
|
||||
endif
|
||||
|
|
|
@ -5,8 +5,7 @@ if BUILD_EXAMPLES
|
|||
noinst_PROGRAMS += examples/pkcs7/pkcs7
|
||||
noinst_HEADERS += examples/pkcs7/pkcs7.h
|
||||
examples_pkcs7_pkcs7_SOURCES = examples/pkcs7/pkcs7.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_pkcs7_pkcs7_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_pkcs7_pkcs7_DEPENDENCIES = src/libwolftpm.la
|
||||
endif
|
||||
|
|
|
@ -8,14 +8,12 @@ noinst_PROGRAMS += examples/seal/seal \
|
|||
noinst_HEADERS += examples/seal/seal.h
|
||||
|
||||
examples_seal_seal_SOURCES = examples/seal/seal.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_seal_seal_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_seal_seal_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
examples_seal_unseal_SOURCES = examples/seal/unseal.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_seal_unseal_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_seal_unseal_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
|
|
|
@ -5,16 +5,14 @@ if BUILD_EXAMPLES
|
|||
noinst_PROGRAMS += examples/timestamp/signed_timestamp
|
||||
noinst_HEADERS += examples/timestamp/signed_timestamp.h
|
||||
examples_timestamp_signed_timestamp_SOURCES = examples/timestamp/signed_timestamp.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_timestamp_signed_timestamp_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_timestamp_signed_timestamp_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
|
||||
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_SOURCES = examples/timestamp/clock_set.c
|
||||
examples_timestamp_clock_set_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_timestamp_clock_set_DEPENDENCIES = src/libwolftpm.la
|
||||
endif
|
||||
|
|
|
@ -6,8 +6,7 @@ noinst_PROGRAMS += examples/tls/tls_client
|
|||
noinst_HEADERS += examples/tls/tls_client.h \
|
||||
examples/tls/tls_common.h
|
||||
examples_tls_tls_client_SOURCES = examples/tls/tls_client.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_tls_tls_client_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_tls_tls_client_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
|
@ -15,8 +14,7 @@ noinst_PROGRAMS += examples/tls/tls_client_notpm
|
|||
noinst_HEADERS += examples/tls/tls_client.h \
|
||||
examples/tls/tls_common.h
|
||||
examples_tls_tls_client_notpm_SOURCES = examples/tls/tls_client_notpm.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_tls_tls_client_notpm_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_tls_tls_client_notpm_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
|
@ -24,8 +22,7 @@ noinst_PROGRAMS += examples/tls/tls_server
|
|||
noinst_HEADERS += examples/tls/tls_server.h \
|
||||
examples/tls/tls_common.h
|
||||
examples_tls_tls_server_SOURCES = examples/tls/tls_server.c \
|
||||
examples/tpm_test_keys.c \
|
||||
examples/tpm_io.c
|
||||
examples/tpm_test_keys.c
|
||||
examples_tls_tls_server_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_tls_tls_server_DEPENDENCIES = src/libwolftpm.la
|
||||
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
if BUILD_EXAMPLES
|
||||
noinst_PROGRAMS += examples/wrap/wrap_test
|
||||
noinst_HEADERS += examples/wrap/wrap_test.h
|
||||
examples_wrap_wrap_test_SOURCES = examples/wrap/wrap_test.c \
|
||||
examples/tpm_io.c
|
||||
examples_wrap_wrap_test_SOURCES = examples/wrap/wrap_test.c
|
||||
examples_wrap_wrap_test_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
examples_wrap_wrap_test_DEPENDENCIES = src/libwolftpm.la
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
# wolfTPM Hardware Interface Abstraction Layer (HAL) IO
|
||||
|
||||
A single HAL callback must be registered to handle communication to the hardware.
|
||||
|
||||
We distribute examples for several platforms to help with initial setup.
|
||||
|
||||
If using one of the builtin system provided hardware interfaces then `NULL` can be supplied for the HAL IO callback.
|
||||
|
||||
The available system TPM interfaces are:
|
||||
* Linux `/dev/tpm0`: Enabled with `WOLFTPM_LINUX_DEV` or `--enable-devtpm`.
|
||||
* Windows TBS: Enabled with `WOLFTPM_WINAPI` or `--enable-winapi`.
|
||||
* Software TPM Simulator: Enabled with `WOLFTPM_SWTPM` or `--enable-swtpm`.
|
||||
|
||||
If using a HAL IO callback it is registered on library initialization using:
|
||||
* TPM2 Native API's: `TPM2_Init`
|
||||
* wolfTPM Wrappers: `wolfTPM2_Init`
|
||||
|
||||
## Example HAL Implementations
|
||||
|
||||
| Platform | Example File | Build Option |
|
||||
| -------- | ------------ | ------------ |
|
||||
| Atmel ASF | `tpm_io_atmel.c` | `WOLFSSL_ATMEL` |
|
||||
| Barebox | `tpm_io_barebox.c` | `__BAREBOX__` |
|
||||
| Infineon | `tpm_io_infineon.c` | `WOLFTPM_INFINEON_TRICORE` |
|
||||
| Linux | `tpm_io_linux.c` | `__linux__` |
|
||||
| Microchip | `tpm_io_microchip.c` | `WOLFTPM_MICROCHIP` |
|
||||
| QNX | `tpm_io_qnx.c` | `__QNX__` |
|
||||
| ST Cube HAL | `tpm_io_st.c` | `WOLFSSL_STM32_CUBEMX` |
|
||||
| Xilinx | `tpm_io_xilinx.c` | `__XILINX__` |
|
||||
|
||||
## HAL IO Callback Function
|
||||
|
||||
Here are the prototypes for the HAL callback function:
|
||||
|
||||
```c
|
||||
#ifdef WOLFTPM_ADV_IO
|
||||
typedef int (*TPM2HalIoCb)(struct TPM2_CTX*, INT32 isRead, UINT32 addr,
|
||||
BYTE* xferBuf, UINT16 xferSz, void* userCtx);
|
||||
#else
|
||||
typedef int (*TPM2HalIoCb)(struct TPM2_CTX*, const BYTE* txBuf, BYTE* rxBuf,
|
||||
UINT16 xferSz, void* userCtx);
|
||||
#endif
|
||||
```
|
||||
|
||||
Here are example function definitions:
|
||||
|
||||
```c
|
||||
#ifdef WOLFTPM_ADV_IO
|
||||
int TPM2_IoCb(TPM2_CTX*, int isRead, word32 addr, byte* buf, word16 size,
|
||||
void* userCtx);
|
||||
#else
|
||||
int TPM2_IoCb(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
|
||||
word16 xferSz, void* userCtx);
|
||||
#endif
|
||||
```
|
||||
|
||||
## Additional Build options
|
||||
|
||||
* `WOLFTPM_CHECK_WAIT_STATE`: Enables check of the wait state during a SPI transaction. Most TPM 2.0 chips require this and typically only require 0-2 wait cycles depending on the command. Only the Infineon TPM's guarantee no wait states.
|
||||
* `WOLFTPM_ADV_IO`: Enables advanced IO callback mode that includes TIS register and read/write flag. This is requires for I2C, but can be used with SPI also.
|
||||
* `WOLFTPM_DEBUG_IO`: Enable logging of the IO (if using the example HAL).
|
|
@ -0,0 +1,18 @@
|
|||
# vim:ft=automake
|
||||
# All paths should be given relative to the root
|
||||
|
||||
if BUILD_HAL
|
||||
src_libwolftpm_la_SOURCES += \
|
||||
hal/tpm_io.c \
|
||||
hal/tpm_io_atmel.c \
|
||||
hal/tpm_io_barebox.c \
|
||||
hal/tpm_io_linux.c \
|
||||
hal/tpm_io_infineon.c \
|
||||
hal/tpm_io_microchip.c \
|
||||
hal/tpm_io_st.c \
|
||||
hal/tpm_io_qnx.c \
|
||||
hal/tpm_io_xilinx.c
|
||||
endif
|
||||
|
||||
nobase_include_HEADERS += hal/tpm_io.h
|
||||
EXTRA_DIST += hal/README.md
|
|
@ -54,56 +54,68 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#if defined(WOLFTPM_LINUX_DEV) || defined(WOLFTPM_SWTPM) || defined(WOLFTPM_WINAPI)
|
||||
#if defined(WOLFTPM_LINUX_DEV) || defined(WOLFTPM_SWTPM) || \
|
||||
defined(WOLFTPM_WINAPI)
|
||||
|
||||
/* HAL not required, so use NULL */
|
||||
#define TPM2_IoCb NULL
|
||||
|
||||
#else
|
||||
|
||||
#ifdef WOLFTPM_EXAMPLE_HAL
|
||||
|
||||
#ifdef WOLFTPM_ADV_IO
|
||||
int TPM2_IoCb(TPM2_CTX*, int isRead, word32 addr, byte* buf, word16 size,
|
||||
WOLFTPM_API int TPM2_IoCb(TPM2_CTX*, int isRead, word32 addr, byte* buf, word16 size,
|
||||
void* userCtx);
|
||||
#else
|
||||
int TPM2_IoCb(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
|
||||
WOLFTPM_API int TPM2_IoCb(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
|
||||
word16 xferSz, void* userCtx);
|
||||
#endif
|
||||
#endif /* !(WOLFTPM_LINUX_DEV || WOLFTPM_SWTPM || WOLFTPM_WINAPI) */
|
||||
|
||||
/* Platform support, in alphabetical order */
|
||||
#ifdef WOLFTPM_I2C
|
||||
|
||||
#if defined(__linux__)
|
||||
int TPM2_IoCb_Linux_I2C(TPM2_CTX* ctx, int isRead, word32 addr, byte* buf,
|
||||
WOLFTPM_LOCAL int TPM2_IoCb_Linux_I2C(TPM2_CTX* ctx, int isRead, word32 addr, byte* buf,
|
||||
word16 size, void* userCtx);
|
||||
#elif defined(WOLFSSL_STM32_CUBEMX)
|
||||
int TPM2_IoCb_STCubeMX_I2C(TPM2_CTX* ctx, int isRead, word32 addr,
|
||||
WOLFTPM_LOCAL int TPM2_IoCb_STCubeMX_I2C(TPM2_CTX* ctx, int isRead, word32 addr,
|
||||
byte* buf, word16 size, void* userCtx);
|
||||
#endif /* __linux__ */
|
||||
|
||||
#else /* SPI */
|
||||
|
||||
#if defined(WOLFSSL_ATMEL)
|
||||
int TPM2_IoCb_Atmel_SPI(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
|
||||
WOLFTPM_LOCAL int TPM2_IoCb_Atmel_SPI(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
|
||||
word16 xferSz, void* userCtx);
|
||||
#elif defined(__BAREBOX__)
|
||||
int TPM2_IoCb_Barebox_SPI(TPM2_CTX* ctx, const byte* txBuf,
|
||||
WOLFTPM_LOCAL int TPM2_IoCb_Barebox_SPI(TPM2_CTX* ctx, const byte* txBuf,
|
||||
byte* rxBuf, word16 xferSz, void* userCtx);
|
||||
#elif defined(__linux__)
|
||||
int TPM2_IoCb_Linux_SPI(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
|
||||
WOLFTPM_LOCAL int TPM2_IoCb_Linux_SPI(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
|
||||
word16 xferSz, void* userCtx);
|
||||
#elif defined(WOLFSSL_STM32_CUBEMX)
|
||||
int TPM2_IoCb_STCubeMX_SPI(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
|
||||
WOLFTPM_LOCAL int TPM2_IoCb_STCubeMX_SPI(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
|
||||
word16 xferSz, void* userCtx);
|
||||
#elif defined(__QNX__) || defined(__QNXTO__)
|
||||
int TPM2_IoCb_QNX_SPI(TPM2_CTX* ctx, const byte* txBuf,
|
||||
WOLFTPM_LOCAL int TPM2_IoCb_QNX_SPI(TPM2_CTX* ctx, const byte* txBuf,
|
||||
byte* rxBuf, word16 xferSz, void* userCtx);
|
||||
#elif defined(__XILINX__)
|
||||
int TPM2_IoCb_Xilinx_SPI(TPM2_CTX* ctx, const byte* txBuf,
|
||||
WOLFTPM_LOCAL int TPM2_IoCb_Xilinx_SPI(TPM2_CTX* ctx, const byte* txBuf,
|
||||
byte* rxBuf, word16 xferSz, void* userCtx);
|
||||
#elif defined(WOLFTPM_INFINEON_TRICORE)
|
||||
int TPM2_IoCb_Infineon_TriCore_SPI(TPM2_CTX* ctx, const byte* txBuf,
|
||||
WOLFTPM_LOCAL int TPM2_IoCb_Infineon_TriCore_SPI(TPM2_CTX* ctx, const byte* txBuf,
|
||||
byte* rxBuf, word16 xferSz, void* userCtx);
|
||||
#elif defined(WOLFTPM_MICROCHIP)
|
||||
int TPM2_IoCb_Microchip_SPI(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
|
||||
WOLFTPM_LOCAL int TPM2_IoCb_Microchip_SPI(TPM2_CTX* ctx, const byte* txBuf, byte* rxBuf,
|
||||
word16 xferSz, void* userCtx);
|
||||
#endif /* WOLFSSL_ATMEL */
|
||||
#endif
|
||||
|
||||
#endif /* WOLFTPM_I2C */
|
||||
|
||||
#endif /* WOLFTPM_EXAMPLE_HAL */
|
||||
#endif /* !(WOLFTPM_LINUX_DEV || WOLFTPM_SWTPM || WOLFTPM_WINAPI) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
|
@ -19,6 +19,7 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
#include <wolftpm/tpm2_types.h>
|
||||
|
||||
#ifdef WOLFTPM_LINUX_DEV
|
||||
#include <wolftpm/tpm2_linux.h>
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
* See docs/SWTPM.md
|
||||
*/
|
||||
|
||||
#include <wolftpm/tpm2_types.h>
|
||||
|
||||
#ifdef WOLFTPM_SWTPM
|
||||
#include <wolftpm/tpm2.h>
|
||||
#include <wolftpm/tpm2_swtpm.h>
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <wolftpm/tpm2_types.h>
|
||||
|
||||
#ifdef WOLFTPM_WINAPI
|
||||
#include <wolftpm/tpm2_winapi.h>
|
||||
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
if BUILD_EXAMPLES
|
||||
check_PROGRAMS += tests/unit.test
|
||||
noinst_PROGRAMS += tests/unit.test
|
||||
tests_unit_test_SOURCES = \
|
||||
tests/unit_tests.c \
|
||||
examples/tpm_io.c
|
||||
tests_unit_test_SOURCES = tests/unit_tests.c
|
||||
tests_unit_test_CFLAGS = $(AM_CFLAGS)
|
||||
tests_unit_test_LDADD = src/libwolftpm.la $(LIB_STATIC_ADD)
|
||||
tests_unit_test_DEPENDENCIES = src/libwolftpm.la
|
||||
|
|
Loading…
Reference in New Issue