Commit Graph

75 Commits

Author SHA1 Message Date
Stefan Berger
e2e25cad40 build-sys: Build libtpms v0.10.1
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2024-11-15 11:43:20 -05:00
Stefan Berger
64d263aff0 build-sys: Do not build statically linked tests when --disable-static used
When --disable-static is used statically linked tests cannot be run.
Therefore, put the evaluation of --enable-static-tests after
--disable-static has been tested for and only set ENABLE_STATIC_TESTS
if both are 'yes'.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-11-11 17:11:19 -05:00
Stefan Berger
3b0bc31692 build-sys: Set -Wshadow to avoid shadowing variables
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-09-23 19:39:55 -04:00
Stefan Berger
37ca5d3ddb build-sys: Check for availability of SSKDF (KDFe) in OpenSSL
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-09-09 14:56:44 -04:00
Stefan Berger
bb4dafb1e7 tpm2: NVMarshal: Introduce MAX_MARSHALLED_OBJECT_SIZE
Introduce the #define MAX_MARSHALLED_OBJECT_SIZE to be used for a size of
a byte buffer that is supposed to hold a marshalled OBJECT. The number
is not exact but provides for a 'safe' size of a buffer.

Add a test case to check that MAX_MARSHALLED_OBJECT_SIZE is sufficient.
The test case needs access to ANY_OBJECT_Marshal, which is only available
when -static can be used for linking since otherwise the function is
private to the library. Static linking the test case does not work when
test-coverage is enabled, therefore disable statically linked test cases
in when test-coverage is enabled and give control to the user to disable
statically linked test cases in other cases as well.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-03-05 21:13:57 -05:00
Stefan Berger
c4390d0d66 build-sys: Display whether test coverage is enabled
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-03-05 21:13:57 -05:00
Stefan Berger
e955d926df tpm2: Check libcrypto for EC_POINT_get_affine_coordinates availability
Check -lcrypto for availability of the more recent
EC_POINT_get_affine_coordinates function and use a #define to call it
instead of the older EC_POINT_get_affine_coordinates_GFp. Make the
same change to EC_POINT_set_affine_coordinates_GFp.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-01-09 08:36:35 -05:00
Stefan Berger
13dcff6592 Fix configure script to support _FORTIFY_SOURCE=3
gcc 12.1 supports _FORTIFY_SOURCE=3. Modify the existing check for whether
_FORTIFY_SOURCE=2 can be used to test compile with the user provided
CFLAGS and only add _D_FORTIFY_SOURCE=2 to the HARDENING_CFLAGS if the
user doesn't provide anything that's not compatible.

Following an online article _FORTIFY_SOURCE=3 may add more overhead, so
we only go up to level 2 for now and let build servers or user provide
the higher level via the CFLAGS.

https://developers.redhat.com/blog/2021/04/16/broadening-compiler-checks-for-buffer-overflows-in-_fortify_source#what_s_next_for__fortify_source

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-04-04 12:40:36 -04:00
Stefan Berger
bd42b67edb build-sys: Add probing for -fstack-protector
Add probing for -fstack-protector to the existing
-fstack-protector-strong since not all platforms support either one
of them.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2022-03-02 13:26:04 -05:00
Stefan Berger
9b76f24a07 build-sys: Build libtpms v0.10.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-16 09:08:58 -04:00
Stefan Berger
435abf8cda build-sys: Build libtpms v0.9.1
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-10-15 15:19:12 -04:00
Stefan Berger
4bc846f869 build-sys: Use -DOPENSSL_SUPPRESS_DEPRECATED to suppress warning (OSSL 3)
Instead of using -Wno-deprecated-declarations use
-DOPENSSL_SUPPRESS_DEPRECATED to only suppress OpenSSL deprecated
declarations warnings.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-21 16:52:22 -04:00
Stefan Berger
f45bafa9bd build-sys: Add -Wno-deprecated-declarations to default CFLAGS (OSSL 3)
To be able to build with OpenSSL 3.0 we need to added
-Wno-deprecated-declarations to the default CFLAGS.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-15 13:28:08 -04:00
Stefan Berger
3091ef1184 build-sys: Test for functions if #defines are not found (OSSL 3)
OpenSSL 3.0 has converted several RSA-related #defines to functions, so
that AX_CHECK_DEFINE only works for OpenSSL 1.1.0 but for OpenSSL 3.0.0
we have to also use AC_CHECK_LIB to determine whether the function is
available.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-09-15 13:28:08 -04:00
Marc-André Lureau
3482da113c build-sys: add with_tpm1/with_tpm2 variables to .pc
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-08-06 08:04:37 -04:00
Marc-André Lureau
057242b84d build-sys: add optional --with-tpm1
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-08-06 08:04:37 -04:00
Stefan Berger
dd088932d7 build-sys: Run autoupdate on configure.ac for autconf 2.71
Run autoupdate and address the following issue:

configure.ac:10: warning: 'AM_CONFIG_HEADER': this macro is obsolete.
configure.ac:10: You should use the 'AC_CONFIG_HEADERS' macro instead.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-06-21 21:54:25 -04:00
Marc-André Lureau
96383e1e9c build-sys: leave CFLAGS/LDFLAGS for user to be defined
This allows user to set specific flags during compilation, without
overriding configure-time cflags necessary for compilation.

See also:
https://www.gnu.org/software/automake/manual/html_node/User-Variables.html
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-05-18 12:21:31 -04:00
Stefan Berger
32c159ab53 tpm2: CryptSym: fix AES output IV
The TPM is supposed to provide the output IV in the ivInOut parameter in
CryptSymmetricEncrypt. In the case of using the openssl routines, the
output IV is missed, and the resulting output from the TPM is in the
input IV.

OpenSSL unfortunately does not export EVP_CIPHER_CTX_iv() until
tags/OpenSSL_1_1_0, so we have to fall back to the reference code for
previous OpenSSL versions.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-03-01 12:54:27 -05:00
Stefan Berger
1253aa359b Bump up the revision of the library for next version to 0.9.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-02-24 15:08:38 -05:00
William Roberts
90cba58180 configure: support --with-pkgconfigdir
Support setting different install paths for package config files
using the --with-pkgconfigdir option.

Drop the hardcoded pkgconfigdir variable in the Makefile.am as per the
manpage http://manpages.ubuntu.com/manpages/cosmic/man7/pkg.m4.7.html
the macro PKG_INSTALLDIR defaults to $libdir/pkgconfig.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
2021-02-09 13:33:15 -05:00
Stefan Berger
1a58c73bc8 build-sys: Make --with-tpm2 the default and if used choose openssl
Make --with-tpm2 the implicit default now and choosen openssl.
When using --without-tpm2 one has to again choose the crypto-library
which defaults to freebl as before. This type of build seems rather
rare by now.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-13 17:02:53 -04:00
Stefan Berger
8df35ac8da build-sys: Fix freebl build of TPM 1.2
The freebl build (TPM 1.2 only) is currently broken:

configure: error: OpenSSL crypto function usage requires openssl as crypto library

Set 'enable_use_openssl_functions=no' in the freebl case to avoid probing
the OpenSSL crypto functions.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-10-13 17:02:53 -04:00
Stefan Berger
d41dedca4d build-sys: Use AC_LINK_IFELSE to check for understood linker flags
Use AC_LINK_IFELSE to check whether linker flags like 'now' and
'relro' are understood or remain unused (= useless), and only add them
to the set of HARDENING_LDFLAGS, if they are used by the linker. clang
for example does not seem to use them and Cygwin's linker does not
understand them.

Note: This patch merely improves on the handling of these flags but does
not solve a compilation issue when clang is used, unlike swtpm where
this created issues.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-09-11 12:23:26 -04:00
Stefan Berger
6b65a6bd97 build-sys: Enable automake silent rules
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-06-18 14:04:59 -04:00
Stefan Berger
5d7a04c624 [build-sys] Add -Wmissing-prototypes to CFLAGS and clean up
Add -Wmissing-prototypes to CFLAGS and make functions static add #include
where necessary.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-06-01 18:23:07 -04:00
Stefan Berger
db80bd9ea1 build-sys: Remove 'experimental' tag from --with-tpm2
TPM 2 support has been in libtpms for quite some time now
and the experimental tag can be removed.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-21 11:23:23 -04:00
Stefan Berger
15687b63bc tpm2: Add missing Camellia code including test cases
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2020-04-14 16:03:45 -04:00
Stefan Berger
4c1dfefa7b build-sys: Avoid accumulation of -lcrypto
Avoid the accumulation of -lcrypto while testing for symbols in the -lcrypto
library by saving the LIBS variable before doing the series of tests.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-10-23 16:10:13 -04:00
Stefan Berger
625abcc688 Bump up the revision of the library for next version to 0.8.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-07-19 13:54:18 -04:00
Stefan Berger
763d7a89de build-sys: Implement AX_CHECK_DEFINE and use for OpenSSL #define's
Some of the functions that OpenSSL uses are #define's for which
we need to check using a new AX_CHECK_DEFINE. We need to check for
them also because they were added at different points in time.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-20 12:42:58 -04:00
Stefan Berger
6ae0d8c52c tpm2: Implement key creation with OpenSSL for rand == NULL
Implement key creation with OpenSSL if rand == NULL, meaning
that we create a non-KDF-derived key, so a purely random key.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-20 12:23:29 -04:00
Stefan Berger
6c901e3270 build-sys: Check for RSA functions needed in OpenSSL libcrypto
Check for RSA functions we need for calling the cryto lib for
doing RSA operations. Set the environment variable
USE_OPENSSL_FUNCTIONS_RSA to '1' if found, to '0' otherwise.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-19 13:57:45 -04:00
Stefan Berger
73264c8442 build-sys: Add missing space at end of string
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-19 13:57:45 -04:00
Stefan Berger
fee2ae97bc tpm2: Use OpenSSL to create TDES keys if rand == NULL
Use OpenSSL function to create TDES keys if rand == NULL,
which indicates that a truely random key needs to be generated
rather than one derived from a KDF.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-19 10:12:24 -04:00
Stefan Berger
afbb327423 Implement EC key generation using OpenSSL functions if rand == NULL
Use OpenSSL functions to create EC keys only for the case that
rand == NULL in which case no KDF is being used and where we can
create a truly random key. This doesn't break the upgrade path.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-10 11:19:58 -04:00
Stefan Berger
55f5988781 tpm2: Switch ECDSA signature creation to OpenSSL
Use OpenSSL crypto library now also for the ECDSA signature creation.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-04 15:36:10 -04:00
Stefan Berger
46869d307e Switch ECDSA signature verification to OpenSSL
Switch the ECDSA signature verification to OpenSSL. Do the signature
creation in the next step so we can verify the creation / verification
against the original TPM 2 code.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-06-03 18:18:13 -04:00
Stefan Berger
4e1cd261ef build-sys: Add support for --disable-use-openssl-functions
OpenSSL's crypto library does not support all crypto functionality
we need in all versions. Elliptic curve support via EVP seems to
have been added much later than for example symmetric crypto support.
So, we move the USE_OPENSSL_FUNCTIONS out of Implementation.h
into configure.ac and let the build system detect what functionality
is available in the crypto library. In this patch we now also rename
USE_OPENSSL_FUNCTIONS to USE_OPENSSL_FUNCTIONS_SYMMETRIC to indicate
that we can use the symmetric crypto functions of the crypto lib.

Using the OpenSSL crypto support is enabled by default, so one has
to use --disable-use-openssl-functions, which we do for Travis now.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-05-30 16:25:15 -04:00
Marc-André Lureau
b214dabfc8 fuzz: better oss-fuzz integration
There were a few issues with the oss-fuzz integration from commit
8373f09854 ("build-sys: add oss-fuzz
support").

When building on OSS-Fuzz, the projects should use the provided CFLAGS
and CXXFLAGS and don't append any extra sanitization / fuzzing flags.

$LIB_FUZZING_ENGINE is defined to set the library to link to, and it
is a c++ library, so we should build fuzzer with c++...

Now --enable-fuzzer is only used for -fsanitize=fuzzer.

Add a tests/fuzz-main.c as fallback, to run the corpus on other builds.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-04-01 11:22:03 -04:00
Stefan Berger
af7e924372 Bump up the revision of the library for next version to 0.7.0
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-18 21:14:49 -04:00
Stefan Berger
d9ea4ea3c3 build-sys: Allow user to pass CFLAGS
Allow the user to pass in the CFLAGS. Previously they were overwritten
with -O2 -g, which are the default CFLAGS if none are passed.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-09 11:51:41 -05:00
Stefan Berger
139925229d build-sys: Add support for --enable-test-coverage to configure
Add support for --enable-test-coverage that sets additional CFLAGS
and LDFLAGS.

gcov creates files with suffixes .gcov, .gcno, and .gcda that we
need clean up in a few directories.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-09 11:51:41 -05:00
Stefan Berger
6b444ad3ff rev148: Rework how the TPM internal clock works
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
be9b50f1f8 build-sys: Support --disable-hardening as an option
By default the hardening compiler flags are enabled and
--disable-hardening disables them.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-29 19:50:35 -04:00
Stefan Berger
dd9c2f2138 build-sys: Only use AX_CHECK_LINK_FLAG with autoconf >= 2.64
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-06 11:00:26 -04:00
Stefan Berger
79275ce87c build-sys: Pass header file to compiler for checking for supported flag
Older versions of gcc need some input file to compile so that
we learn whether -fstack-protector-strong is supported.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-10-05 21:47:15 -04:00
Stefan Berger
59f46464d5 build-sys: work around broken linker when testing --version-script support
The linker on FreeBSD seems to be broken and fails for other reasons
when testing for support of the --version-script flag. The error
that is reported is:

local symbol 'environ' in /usr/lib/crt1.o is referenced by DSO.

Also __progname is needed.

To work around this problem we add a test.syms file that only has
these two symbols in it, which is enough for the test in
configure.ac and gives version script support in case of the
broken linker.

On FreeBSD TPM 1.2 related tests were failing due to test case 6
failures in case no linker script was used. (Very odd.) This patch
fixes this problem.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 21:45:16 +00:00
Stefan Berger
27904459e3 build-sys: Check for supported linker flag --version-script
Check whether the linker supports the linker flag --version-script.
The OS X linkwer does not seem to support it.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-30 13:24:54 -04:00
Stefan Berger
b6a89b2f55 build-sys: Use X="$X ..." rather than X+="..." in configure.ac
Some configure interpreters do not like X+="...", so we have to
use X="$X ..." instead.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2018-08-29 17:47:25 +00:00