Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build the container
run: docker build -t ubuntucontainer tss-esapi/tests/ --build-arg TPM2_TSS_VERSION=4.0.1 --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tss-install-dir
run: docker build -t ubuntucontainer tss-esapi/tests/ --build-arg TPM2_TSS_VERSION=4.1.3 --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tss-install-dir
- name: Run the container
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/all-ubuntu.sh

Expand Down
9 changes: 7 additions & 2 deletions tss-esapi-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ links = "tss2-esys"
rust-version = "1.74.0"

[build-dependencies]
bindgen = { version = "0.70.1", optional = true }
bindgen = { version = "0.72.0", optional = true }
pkg-config = "0.3.18"
target-lexicon = "0.12.0"
target-lexicon = "0.13.2"
cfg-if = "1.0.0"
semver = "1.0.7"
autotools = { version = "0.2.6", optional = true }

[target.'cfg(windows)'.build-dependencies]
msbuild = { version = "0.2.0", optional = true }

[features]
generate-bindings = ["bindgen"]
bundled = ["dep:autotools", "dep:msbuild"]
71 changes: 67 additions & 4 deletions tss-esapi-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ interface to Rust to [TSS](https://github.com/tpm2-software/tpm2-tss).

This crate exposes an interface for the TSS Enhanced System API and thus
links to libraries that expose this interface. In order to allow proper use
of the ESAPI, this FFI layer includes bindings to TCTI and MU headers, and
of the ESAPI, this FFI layer includes bindings to TCTI and MU headers, and
must therefore link to all of them at build time.

The paths to the libraries are discovered using `pkg-config` - make sure they
are discoverable in this way on your system. Our build script looks for
`tss2-esys`, `tss2-tctildr` and `tss2-mu`. A minimum version of `4.0.1` is
are discoverable in this way on your system. Our build script looks for
`tss2-esys`, `tss2-tctildr` and `tss2-mu`. A minimum version of `4.1.3` is
required for all of them.

Having installed the open-source implementation libraries at `/usr/local/lib` (by default), it
Expand All @@ -41,9 +41,72 @@ available, feel free to raise a Pull Request to add it or to use build-time
generation of bindings. All the committed bindings **MUST** be generated from
the library version found under the `vendor` submodule.

## Bundling TPM-TSS

[`tpm-tss`](https://github.com/tpm2-software/tpm2-tss) is used by this
library to communicate with TPMs. If this library is not available on
your system you may optionally bundle (vendor) tpm-tss during builds.
tpm-tss can be provided from a local source path with the
environment variable `TPM_TSS_SOURCE_PATH` or it will be retrieved from
Github during the build. The version to retrieve can be controlled by setting
the `TPM2_TSS_SOURCE_VERSION` environment variable.
[!IMPORTANT]
On windows it might be necessary to manually create the VERSION file
when a local source is being used.

To enable this feature:

```bash
cargo build --features=bundled
```

```bash
TPM2_TSS_VERSION="4.1.3" cargo build --features=bundled
```

```bash
TPM_TSS_SOURCE_PATH=/path/to/tpm-tss cargo build --features=bundled
```

If using this feature from an external project

```
tss-esapi-sys = { version = "...", features = ["bundled"] }
```

### Windows

Compiling for windows requires a bit of setup to work with the bundled feature.

* OpenSSL must be installed to a non-standard location at `C:\OpenSSL-v11-Win64`
* Visual Studio 2019 must be installed with the Clang/C2 experimental component,
and windows sdk 10.0 (Other versions of Visual Studio may work but are untested
at this point).

### MacOS

Compiling on MacOS requires the bundling feature. This requires dependencies
from brew.

```bashbre
brew install autoconf autoconf-archive automake json-c libtool m4 pkg-config
```

Optionally you may require these libraries for certain classes of TPM transport

```
brew install libftdi
```

### OpenSUSE / SUSE

```
sudo zypper in autoconf autoconf-archive automake libjson-c-devel libtool libtpms-devel gawk make
```

## Cross compiling

Cross-compilation can be done as long as you have on your build system the TSS
Cross-compilation can be done as long as you have on your build system the TSS
libraries compiled for your target system of choice. We rely on `pkg-config` to
identify the libraries which we link against. Installing `tpm2-tss` does yield
`.pc` files which can be used for this purpose, but depending on the exact build
Expand Down
Loading