fails to build with tpm2-tss 4 and the generate-bindings feature of tss-esapi-sys
tss-esapi-sys offers both pregenerated bindings (the default) and the ability to request binding generation at build time. The latter is needed to build tss-esapi-sys (and hence sequoia-tpm) on systems for which pregenerated bindings are not available.
tpm2-tss version 4 increased the size of the buffer in TPM2B_PRIVATE_KEY_RSA from "TPM2_MAX_RSA_KEY_BYTES/2" (aka 256) to "TPM2_MAX_RSA_KEY_BYTES/2 * 5" https://github.com/tpm2-software/tpm2-tss/commit/e5e1a81231b1ae6b5f9201e2778a38bcd126eb40
As a result of this is that trying to build sequoia-tpm with the generate-bindings feature of tss-esapi-sys in an environment with tpm2-tss 4 (e.g. debian trixie/sid) results in.
cargo test --features tss-esapi-sys/generate-bindings
Compiling sequoia-tpm v0.1.0 (/sequoia-tpm)
error[E0308]: mismatched types
--> src/lib.rs:103:21
|
103 | buffer: key_prime_buffer,
| ^^^^^^^^^^^^^^^^ expected an array with a fixed size of 1280 elements, found one with 256 elements
If the build environment has tpm2-tss 3, then the crate builds sucessfully even with tss-esapi-sys/generate-bindings
If tss-esapi-sys/generate-bindings is not specified then the crate builds successfully, but only on architectures for which tpm2-tss has pregenerated bindings.
I fixed this in Debian by replacing the key_prime_buffer and key_prime_length variables with a single variable of type TPM2B_PRIVATE_KEY_RSA. The patch is available at https://salsa.debian.org/rust-team/debcargo-conf/-/blob/master/src/sequoia-tpm/debian/patches/fix-build-with-regenerated-bindings.patch