Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing cryptographic library dependency in tpm2 tool build configuration #3453

Open
petrovr opened this issue Jan 26, 2025 · 1 comment
Open

Comments

@petrovr
Copy link

petrovr commented Jan 26, 2025

Use case - build and tests using non-system default paths for executables and binaries.
Such environment allows functionality to use releases different from provided by OS.

[[ basis ]]

$  ./configure --help

CRYPTO_CFLAGS
C compiler flags for CRYPTO, overriding pkg-config
CRYPTO_LIBS linker flags for CRYPTO, overriding pkg-config

[[ part 1 ]]

Proposed correction is to update Makefile.am - prepend libraries and append flags:

tools_tpm2_LDADD = $(CRYPTO_LIBS) $(CURL_LIBS) $(LDADD)
tools_tpm2_CFLAGS = $(AM_CFLAGS) -DTPM2_TOOLS_MAX="$(words $(tpm2_tools))" $(CRYPTO_CFLAGS)

Off-topic: for consistency curl flags should be listed as well.

[[ part 2 ]]

tpm2 tools depends from ssl library. Depending from linker (RPATH vs RUNPATH) above correction is not enough.
One solution is explicit list of ssl library.

tools_tpm2_LDADD = $(CRYPTO_LIBS) -lssl $(CURL_LIBS) $(LDADD)

This ensures working binary when linked produce binary with RUNPATH - ssl library located in location of cryptographic library.

Second solution is more complex - change configuration script pkg-config to check for libssl and to it.

@petrovr
Copy link
Author

petrovr commented Feb 1, 2025

To do correct static linking cryptographic libraries must be in right order -lssl -lcrypto.
Check for libssl will output only ssl library.
It seems to me check for libcrypto should be replaced by check for openssl.

PKG_CONFIG_PATH=.../lib/pkgconfig pkg-config openssl --libs
-L.../lib -lssl -lcrypto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant