diff --git a/tss-esapi/README.md b/tss-esapi/README.md index 3ee4a12b..45721777 100644 --- a/tss-esapi/README.md +++ b/tss-esapi/README.md @@ -1,4 +1,4 @@ -# TPM2 Software Stack Rust Wrapper +# TPM2 Software Stack Rust Wrapper
-This is the high-level, Rust idiomatic wrapper crate that exposes an interface +This is the high-level, Rust idiomatic wrapper crate that exposes an interface to [TSS](https://github.com/tpm2-software/tpm2-tss). This crate depends on the [`tss-esapi-sys`](../tss-esapi-sys/) crate for its FFI interface. By default, pre-generated bindings are used. If you'd like the -bindings to be generated at build time, please enable either the +bindings to be generated at build time, please enable either the `generate-bindings` feature - the FFI bindings will then be generated at build time using the headers identified on the system. @@ -31,7 +31,7 @@ The crate currently offers the following features: * `abstraction` (enabled by default) - provides a set of abstracted primitives on top of the basic Rust-native ESAPI API provided by the crate. This feature can be turned off to reduce the number of dependencies built. -* `serde` - enable serde `Serialize`/`Deserialize` traits for types. +* `serde` - enable serde `Serialize`/`Deserialize` traits for types. * `rustcrypto-full` (disabled by default) - provides conversion from all supported elliptic curves, rsa or hashes. Support for individual hash, rsa or curves can be pulled individually. @@ -45,4 +45,11 @@ The crate currently offers the following features: For more information on cross-compiling the `tss-esapi` crate, please see the README of the `tss-esapi-sys` crate. +## Building against libtss2 + +The [TSS](https://github.com/tpm2-software/tpm2-tss) library can be installed from Debian, RPM, or other packaging manager. +It will install a pkg-config definition to indicate how to compile and link against the library. +When it is installed via source, and/or if it has been edited (such as to debug things), then the version number will be marked with the git commit (and dirty flag). The resulting version string is unfortunately not compatible with the semver parser/comparing mechanism, and it can be rejected. +Setting the environment variable TPM2\_TSS\_VERSION\_IGNORE\_PRERELEASE to a non-empty string will cause the build system to ignore this pre-release information. + *Copyright 2021 Contributors to the Parsec project.* diff --git a/tss-esapi/build.rs b/tss-esapi/build.rs index 39c3a0a1..ddbbf48b 100644 --- a/tss-esapi/build.rs +++ b/tss-esapi/build.rs @@ -1,8 +1,9 @@ // Copyright 2021 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -use semver::{Version, VersionReq}; +use semver::{Prerelease, Version, VersionReq}; const TPM2_TSS_MINIMUM_VERSION: Version = Version::new(4, 1, 3); +const TPM2_TSS_VERSION_IGNORE_PRERELEASE: &str = "TPM2_TSS_VERSION_IGNORE_PRERELEASE"; fn main() { println!("cargo:rustc-check-cfg=cfg(hierarchy_is_esys_tr)"); @@ -20,7 +21,13 @@ fn main() { .expect("Failed to parse ENV variable DEP_TSS2_ESYS_VERSION as string"); Version::parse(&tss_version_string) - .expect("Failed to parse the DEP_TSS2_ESYS_VERSION variable as a semver version") + .map(|mut v| { + if std::env::var(TPM2_TSS_VERSION_IGNORE_PRERELEASE).is_ok() { + v.pre = Prerelease::EMPTY; + } + v + }) + .expect("Failed to parse the DEP_TSS2_ESYS_VERSION variable {tss_version_string} as a semver version") }; let supported_tss_version = @@ -28,7 +35,7 @@ fn main() { assert!( supported_tss_version.matches(&tss_version), - "Unsupported TSS version {tss_version}" + "Unsupported TSS version {tss_version}, maybe try {TPM2_TSS_VERSION_IGNORE_PRERELEASE}=true" ); let hierarchy_is_esys_tr_req = VersionReq::parse(">=3.0.0").unwrap();