]> git.proxmox.com Git - libtpms.git/log
libtpms.git
5 years agotpm2: Also include openssl/ecdsa.h for older openssl versions
Stefan Berger [Tue, 4 Jun 2019 16:26:02 +0000 (12:26 -0400)]
tpm2: Also include openssl/ecdsa.h for older openssl versions

Older OpenSSL versions had the ECDSA headers in openssl/ecdsa.h, so
include this file as well.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Switch ECDSA signature creation to OpenSSL
Stefan Berger [Tue, 14 May 2019 17:54:56 +0000 (13:54 -0400)]
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>
5 years agotpm2: Make OsslToTpmBn's BIGNUM parameter const
Stefan Berger [Tue, 7 May 2019 18:05:05 +0000 (14:05 -0400)]
tpm2: Make OsslToTpmBn's BIGNUM parameter const

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agoSwitch ECDSA signature verification to OpenSSL
Stefan Berger [Tue, 14 May 2019 17:36:31 +0000 (13:36 -0400)]
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>
5 years agobuild-sys: Add support for --disable-use-openssl-functions
Stefan Berger [Thu, 30 May 2019 19:49:34 +0000 (15:49 -0400)]
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>
5 years agoTravis: Add a Travis build for the case 'USE_OPENSSL_FUNCTIONS NO'
Stefan Berger [Thu, 30 May 2019 14:59:48 +0000 (10:59 -0400)]
Travis: Add a Travis build for the case 'USE_OPENSSL_FUNCTIONS NO'

Maintain the build for the case of USE_OPENSSL_FUNCTIONS set to NO
where we build the original TPM 2 code.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Convert symmetric cipher implementations to use OpenSSL functions
Stefan Berger [Fri, 3 May 2019 17:45:20 +0000 (13:45 -0400)]
tpm2: Convert symmetric cipher implementations to use OpenSSL functions

Convert functions for symmetric encryption via AES and TDES to
use OpenSSL EVP functions where necessary. Leave the old code around
and use the #if USE_OPENSSL_FUNCTIONS to activate the new parts.

OpenSSL does not provide an implementation for TDES in CTR mode, so
we reuse the original TPM 2 code for this mode.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Implement helper for getting OpenSSL crypto functions
Stefan Berger [Fri, 3 May 2019 17:45:20 +0000 (13:45 -0400)]
tpm2: Implement helper for getting OpenSSL crypto functions

Implement helper for getting OpenSSL crypto functions from
crytpo algorithm IDs, encryption modes, and key sizes.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Introduce clear_and_free() to clear memory before freeing
Stefan Berger [Fri, 24 May 2019 17:19:55 +0000 (13:19 -0400)]
tpm2: Introduce clear_and_free() to clear memory before freeing

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Introduce #define USE_OPENSSL_FUNCTIONS
Stefan Berger [Tue, 7 May 2019 11:38:56 +0000 (07:38 -0400)]
tpm2: Introduce #define USE_OPENSSL_FUNCTIONS

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Add fall through comment to address Coverity finding
Stefan Berger [Wed, 29 May 2019 17:47:16 +0000 (13:47 -0400)]
tpm2: Add fall through comment to address Coverity finding

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Rearrange code in _plat__IsNvAvailable to avoid unused var
Stefan Berger [Wed, 29 May 2019 17:41:59 +0000 (13:41 -0400)]
tpm2: Rearrange code in _plat__IsNvAvailable to avoid unused var

Rerrange the code in _plat__IsNvavailable to avoid an unused
variable.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Fix coverity scan errors in NvFileSize
Stefan Berger [Wed, 29 May 2019 14:23:03 +0000 (10:23 -0400)]
tpm2: Fix coverity scan errors in NvFileSize

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agoTravis: If building coverity_scan branch, build only job number 1
Stefan Berger [Thu, 30 May 2019 11:50:01 +0000 (07:50 -0400)]
Travis: If building coverity_scan branch, build only job number 1

Only build one job when building the coverity branch.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Clear all EC_POINT and BIGNUM before freeing
Stefan Berger [Thu, 23 May 2019 22:32:30 +0000 (18:32 -0400)]
tpm2: Clear all EC_POINT and BIGNUM before freeing

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Rename NV_ROUNDUP to TPM2_ROUNDUP and move to new Utils.h
Stefan Berger [Thu, 23 May 2019 15:14:40 +0000 (11:14 -0400)]
tpm2: Rename NV_ROUNDUP to TPM2_ROUNDUP and move to new Utils.h

Move NV_ROUNDUP to Utils.h and call it TPM2_ROUNDUP for reuse by
other functions.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Add CMAC test cases from RFC 4493
Stefan Berger [Fri, 10 May 2019 00:49:53 +0000 (20:49 -0400)]
tpm2: Add CMAC test cases from RFC 4493

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Reset the internal CMAC state when starting a CMAC
Stefan Berger [Fri, 10 May 2019 01:42:59 +0000 (21:42 -0400)]
tpm2: Reset the internal CMAC state when starting a CMAC

Initialize the internal CMAC state to 0s when starting a CMAC.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agoExtend TDES test cases (CFB, OFB) with test cases for short input
Stefan Berger [Wed, 8 May 2019 18:05:18 +0000 (14:05 -0400)]
Extend TDES test cases (CFB, OFB) with test cases for short input

Add TDES test cases testing CFB and OFB with non-blocksized short
input.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Extend internal test case with tests for TDES
Stefan Berger [Fri, 3 May 2019 21:03:59 +0000 (17:03 -0400)]
tpm2: Extend internal test case with tests for TDES

Also test the TDES implementations.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Add script to re-generate the test data for AES and new test for TDES
Stefan Berger [Fri, 3 May 2019 18:29:47 +0000 (14:29 -0400)]
tpm2: Add script to re-generate the test data for AES and new test for TDES

Add a script that uses openssl to create the test data we are using
in the TPM 2 code already. Extend this script with TDES 128 and 192 bit
key sizes and tests.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotests: Add a test program to run the TPM 2 self tests
Stefan Berger [Fri, 3 May 2019 17:32:11 +0000 (13:32 -0400)]
tests: Add a test program to run the TPM 2 self tests

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotests: Restrict number of command line parameters to fuzz
Stefan Berger [Sat, 4 May 2019 13:28:11 +0000 (09:28 -0400)]
tests: Restrict number of command line parameters to fuzz

Restrict the number of command line parameters passed to the
fuzz program in order not to overstep command line parameter
size restrictions.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotests: run a lot less tests in base64decode.sh
Stefan Berger [Sat, 4 May 2019 14:18:45 +0000 (10:18 -0400)]
tests: run a lot less tests in base64decode.sh

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agoTravis: Display test failures
Stefan Berger [Sat, 4 May 2019 13:07:57 +0000 (09:07 -0400)]
Travis: Display test failures

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotests: Fix memory leak in test cases
Stefan Berger [Sat, 4 May 2019 12:40:18 +0000 (08:40 -0400)]
tests: Fix memory leak in test cases

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agobuild-sys: don't tweak LD_LIBRARY_PATH
Marc-André Lureau [Tue, 16 Apr 2019 10:56:52 +0000 (12:56 +0200)]
build-sys: don't tweak LD_LIBRARY_PATH

libtool already provides helper scripts around executables.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5 years agoAdd missing #define TPM_HAVE_TPM2_DECLARATIONS in tpm2 code (RHEL 6)
Stefan Berger [Fri, 12 Apr 2019 15:32:17 +0000 (10:32 -0500)]
Add missing #define TPM_HAVE_TPM2_DECLARATIONS in tpm2 code (RHEL 6)

Add some missing #define TPM_HAVE_TPM2_DECLARATIONS before the include
of "tpm_library_intern.h" in TPM 2 code so we don't run into compile
errors on RHEL 6 when data types are redefined in TPM 1.2 code.

Previous patch 73cad883bac seems to have missed those.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Sync with TPM 2 code comments or commented code
Stefan Berger [Fri, 5 Apr 2019 19:20:38 +0000 (15:20 -0400)]
tpm2: Sync with TPM 2 code comments or commented code

Sync with TPM 2 code where the only difference is now comments
or commented/dead code.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agobuild-sys: Remove cruft from 'check'
Stefan Berger [Thu, 4 Apr 2019 13:29:12 +0000 (09:29 -0400)]
build-sys: Remove cruft from 'check'

Remove some cruft that was useful when TPM 2 code was still in the
works but now that things have settled don't need it anymore.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotravis: Run cpp-coveralls without sudo
Stefan Berger [Wed, 3 Apr 2019 14:50:25 +0000 (10:50 -0400)]
travis: Run cpp-coveralls without sudo

Change file and directory ownerships so that we can run cpp-coveralls
without sudo.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: TPMT_PUBLIC_PARMS_Marshal is unused
Stefan Berger [Mon, 1 Apr 2019 20:46:01 +0000 (16:46 -0400)]
tpm2: TPMT_PUBLIC_PARMS_Marshal is unused

... and TPMU_PUBLIC_PARMS_Marshal is used, so leave its prototype active.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Deactivate unused code
Stefan Berger [Mon, 1 Apr 2019 18:45:07 +0000 (14:45 -0400)]
tpm2: Deactivate unused code

Also TPM 2 code has a lot of unused code that we can #if 0 out.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agogitignore: Ignore coverage related files
Stefan Berger [Mon, 1 Apr 2019 18:40:27 +0000 (14:40 -0400)]
gitignore: Ignore coverage related files

Ignore files related to gcov.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agofuzz: better oss-fuzz integration
Marc-André Lureau [Mon, 1 Apr 2019 12:54:46 +0000 (14:54 +0200)]
fuzz: better oss-fuzz integration

There were a few issues with the oss-fuzz integration from commit
8373f098542ecba3e0c58537f03760ea30c64ac2 ("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>
5 years agobuild-sys: fix grep warnings when building out-of-tree
Marc-André Lureau [Mon, 1 Apr 2019 10:50:52 +0000 (12:50 +0200)]
build-sys: fix grep warnings when building out-of-tree

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5 years agotpm12: Build without support for maintentance commands
Stefan Berger [Sat, 30 Mar 2019 12:42:12 +0000 (08:42 -0400)]
tpm12: Build without support for maintentance commands

Introduce TPM_NOMAINTENANCE_COMMANDS #define to build the TPM 1.2 code
without maintenance commands support. The state for the maintenance
commands has been written out so far, so we have to leave this part
alive even though nothing can be done with the maintenance key anymore.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm12: Deactivate unused code
Stefan Berger [Sat, 30 Mar 2019 00:18:44 +0000 (20:18 -0400)]
tpm12: Deactivate unused code

There are several functions in the code that do not have a caller.
Deactivate all of them to get higher coverage of the code.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotravis: Use cpp-coveralls with the -b option for proper path creation
Stefan Berger [Fri, 29 Mar 2019 19:02:38 +0000 (15:02 -0400)]
travis: Use cpp-coveralls with the -b option for proper path creation

Add the option -b ./src for proper path creation. Exclude the test
dir to avoid malformed path creation. Also exclude the swtpm dir
since nothing interesting is to be found there.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agobuild-sys: add oss-fuzz support
Marc-André Lureau [Wed, 27 Mar 2019 14:02:13 +0000 (15:02 +0100)]
build-sys: add oss-fuzz support

This script will permit integration with Google OSS-FUZZ
https://github.com/google/oss-fuzz

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5 years agogitignore: Ignore corpus of test cases and auto-created files
Stefan Berger [Tue, 26 Mar 2019 00:29:39 +0000 (20:29 -0400)]
gitignore: Ignore corpus of test cases and auto-created files

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agoman: Leave note about leaving store- and loaddata functions unset
Stefan Berger [Mon, 25 Mar 2019 18:27:14 +0000 (14:27 -0400)]
man: Leave note about leaving store- and loaddata functions unset

Leave a note in the TPMLIB_RegisterCallbacks() function about
the effects of leaving the store- and loaddata functions in the
interface unset.

Leave another not in TPMLIB_MainInit() to not use the library without
calling TPMLIB_RegiserCallbacks().

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotests: Add test case for testing permanent state restore
Stefan Berger [Mon, 25 Mar 2019 18:06:27 +0000 (14:06 -0400)]
tests: Add test case for testing permanent state restore

Add a test case that test the restoring of the permanent
state that must have a persisted key.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotests: Extend PCR and read again after restart of TPM with restored state
Stefan Berger [Sat, 23 Mar 2019 23:51:41 +0000 (19:51 -0400)]
tests: Extend PCR and read again after restart of TPM with restored state

Extend the existing test case with extending PCR 10 and reading back
the result, then storing the state blobs and setting them and checking
the value of PCR 10 again.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: TPM2_MainInit: Enable NVRAM in NVChip file case
Stefan Berger [Mon, 25 Mar 2019 14:16:00 +0000 (10:16 -0400)]
tpm2: TPM2_MainInit: Enable NVRAM in NVChip file case

When no callbacks are set and the plain NVChip file is used it wasn't
possible to save the state of the TPM 2 after a TPMLIB_Terminate()
TPMLIB_MainInit() sequence with a cached state (TPMLIB_SetState) since
in this case the NVRAM was not initialized. We now initialize the NV
in case no callback for restoring the state is set.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Split off _plat__NVEnable_NVChipFile from _plat__NVEnable
Stefan Berger [Mon, 25 Mar 2019 16:08:13 +0000 (12:08 -0400)]
tpm2: Split off _plat__NVEnable_NVChipFile from _plat__NVEnable

Split off the part that was handling the NVChip file in _plat__NVEnable
and call this new function _plat__NVEnable_ChipFile so we can call it
separately in case the caller works with the plain NVChip file.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Adapt code for OpenSSL 1.2 deprecated API calls
Stefan Berger [Tue, 19 Mar 2019 00:21:42 +0000 (20:21 -0400)]
tpm2: Adapt code for OpenSSL 1.2 deprecated API calls

Some OpenSSL EC API calls are deprecated starting in OpenSSL 1.2
and may fail the build due to the #warning they produce.

The affected functions have been renamed and consolidated with
other functions inside OpenSSL:

- EC_POINT_set_affine_coorindates_GFp
https://github.com/openssl/openssl/blob/OpenSSL_1_1_1-stable/crypto/ec/ec_lib.c#L730

- EC_POINT_get_affine_coordinates_GFp
https://github.com/openssl/openssl/blob/OpenSSL_1_1_1-stable/crypto/ec/ec_lib.c#L768

On both functions the suffix _GFp has been removed by the renaming.
We need to call the new functions if OPENSSL_API_COMPAT is defined
and is >= 0x10200000L.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotravis: Add libseccomp-dev as package to install for swtpm
Stefan Berger [Tue, 19 Mar 2019 00:49:16 +0000 (20:49 -0400)]
travis: Add libseccomp-dev as package to install for swtpm

To build recent swtpm we also need libseccomp-dev now.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agoBump up the revision of the library for next version to 0.7.0
Stefan Berger [Mon, 14 Jan 2019 14:26:33 +0000 (09:26 -0500)]
Bump up the revision of the library for next version to 0.7.0

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agobuild-sys: Fix typo in manpages variable name
Stefan Berger [Wed, 16 Jan 2019 14:40:29 +0000 (09:40 -0500)]
build-sys: Fix typo in manpages variable name

Some man pages were not installed due to a typo in the name of
the variable. This patch fixes the issue.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agoExtend CHANGES file with what is new in v0.6.0
Stefan Berger [Mon, 14 Jan 2019 13:50:41 +0000 (08:50 -0500)]
Extend CHANGES file with what is new in v0.6.0

Mention support for TPM 2 (up to rev 150) and new API calls.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agodebian: Set version to 0.6.0-1 for release.
Stefan Berger [Wed, 9 Jan 2019 16:54:53 +0000 (16:54 +0000)]
debian: Set version to 0.6.0-1 for release.

Set the version to 0.6.0-1 for a release. Cheat a bit on the previous
version by changing the suffix to ~dev from -dev.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agodebian: Fix Architecture and Depends of libtpms-dev
Stefan Berger [Wed, 9 Jan 2019 17:14:26 +0000 (17:14 +0000)]
debian: Fix Architecture and Depends of libtpms-dev

Fix Architecture and Depends entries of libtpms-dev in control file.

Thanks to alex@strugee.net for pointing this out in PR#22.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agodebian: Fix the build dependencies
Stefan Berger [Wed, 9 Jan 2019 17:03:34 +0000 (17:03 +0000)]
debian: Fix the build dependencies

Fix the build dependencies.

Thanks to alex@strugee.net for pointing this out in PR#22.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agodebian: Rename package libtpms to libtpms0
Stefan Berger [Wed, 9 Jan 2019 17:00:39 +0000 (17:00 +0000)]
debian: Rename package libtpms to libtpms0

Fix the lintian complaint about wrong package name for the shared library.

Thanks to alex@strugee.net for pointing this out in PR#22.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotravis: Add OS X target
Stefan Berger [Tue, 8 Jan 2019 17:21:23 +0000 (12:21 -0500)]
travis: Add OS X target

Also test-compile on OS X. The 'distcheck' target cannot be used
since it results in deplicate symbol errors while linking (no idea
why it happens only with distcheck).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotravis: Build libtpms for coverage and test with swtpm
Stefan Berger [Mon, 7 Jan 2019 19:31:14 +0000 (14:31 -0500)]
travis: Build libtpms for coverage and test with swtpm

Build libtpms with code coverage enabled and run the swtpm test
suite on it.

Unfortunately cpp-coveralls has a problem creating correct file paths when
collecting the results so that the coverage results are not correctly sub-
mitted to coveralls.io. The issue may stem from the fact that the
Makefile.am in src/ contains rules for source files in subdirs src/tmp12/
and src/tpm2/ etc. I hope that this issue can be fixed at some point.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agobuild-sys: Allow user to pass CFLAGS
Stefan Berger [Mon, 7 Jan 2019 22:56:01 +0000 (17:56 -0500)]
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>
5 years agobuild-sys: Add support for --enable-test-coverage to configure
Stefan Berger [Mon, 7 Jan 2019 19:16:44 +0000 (14:16 -0500)]
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>
5 years agotravis: Parameterize script and invoke from matrix
Stefan Berger [Mon, 7 Jan 2019 19:03:37 +0000 (14:03 -0500)]
travis: Parameterize script and invoke from matrix

Add a matrix: part so we can test on multiple systems concurrently and
make the script use environment variables.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotravis: Move package installation under addons
Stefan Berger [Mon, 7 Jan 2019 18:59:33 +0000 (13:59 -0500)]
travis: Move package installation under addons

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Remove unnecessary LITTLE_ENDIAN_TPM #define for __APPLE__
Stefan Berger [Mon, 7 Jan 2019 16:40:03 +0000 (16:40 +0000)]
tpm2: Remove unnecessary LITTLE_ENDIAN_TPM #define for __APPLE__

Remove an unnecessary LITTLE_ENDIAN_TPM #define for the __APPLE__
case.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotests: Fix missing semicolon in test case
Stefan Berger [Sun, 6 Jan 2019 20:58:00 +0000 (15:58 -0500)]
tests: Fix missing semicolon in test case

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotests: Do not fail the test in case of an error but display message
Stefan Berger [Thu, 6 Dec 2018 18:42:31 +0000 (13:42 -0500)]
tests: Do not fail the test in case of an error but display message

Do not fail the entire test run in case of a failure but display an
error message instead and continue running tests.

Errors may happen in very rare cases and we just continue then while
assuming the output is logged.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Propagate error from CryptRandStartup() and report error info
Stefan Berger [Wed, 5 Dec 2018 17:24:59 +0000 (12:24 -0500)]
tpm2: Propagate error from CryptRandStartup() and report error info

CryptRandStartup() did not propagate initialization errors to the caller
but always returned TRUE. We now return the initialization errors and
display an error message and some state variables.

This error should almost never occur, but the fuzzer was able to trigger
it with rev 146 when the random number generated returned 32 bit numbers only
and the same 32 bit number was returned as the one before it. With rev 150
the random number generating function now returns as many random numbers as
the caller requested and this error is not getting triggered anymore.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agorev150: Remove unnecessary parameters from unmarshaling functions
Stefan Berger [Mon, 3 Dec 2018 23:03:39 +0000 (18:03 -0500)]
rev150: Remove unnecessary parameters from unmarshaling functions

The first functions in UnmarshalArray before HANDLE_FIRST_FLAG_TYPE
must not have an additional flag and so we remove it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: fix undefined behavior of macro expansion
Stefan Berger [Fri, 30 Nov 2018 02:06:35 +0000 (21:06 -0500)]
tpm2: fix undefined behavior of macro expansion

Fix the preprocessor warning:

macro expansion producing 'defined' has undefined behavior

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Coverity: Deactivate dead functions
Stefan Berger [Thu, 22 Nov 2018 14:17:09 +0000 (09:17 -0500)]
tpm2: Coverity: Deactivate dead functions

CryptHashCopyState is not called from anywhere and the useless
call to CryptGetHashDef() it does obviously doesn't matter. Deactivate
the whole function using #if 0.

NvClearPersistent() and NvUpdatePersistent() are not used, either,
so we can also deactivate them and suppress a pointer related issue
that Coverity is complaining about.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agorev150: Update spec defines to revision 150
Stefan Berger [Thu, 8 Nov 2018 20:05:45 +0000 (15:05 -0500)]
rev150: Update spec defines to revision 150

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agorev150: Remove obsolete CryptoHashData.h
Stefan Berger [Thu, 8 Nov 2018 20:27:35 +0000 (15:27 -0500)]
rev150: Remove obsolete CryptoHashData.h

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agorev150: Replace BnEccData.c with CryptEccData.c
Stefan Berger [Thu, 8 Nov 2018 20:13:57 +0000 (15:13 -0500)]
rev150: Replace BnEccData.c with CryptEccData.c

5 years agorev150: Add #error to prevent users from defining SIMULATION
Stefan Berger [Thu, 8 Nov 2018 20:04:36 +0000 (15:04 -0500)]
rev150: Add #error to prevent users from defining SIMULATION

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Set LIBRARY_COMPATIBILITY_CHECK to YES
Stefan Berger [Thu, 8 Nov 2018 19:59:37 +0000 (14:59 -0500)]
tpm2: Set LIBRARY_COMPATIBILITY_CHECK to YES

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agorev150: Add LIBRARY_COMPATIBILITY_CHECK build switch
Stefan Berger [Thu, 8 Nov 2018 19:58:07 +0000 (14:58 -0500)]
rev150: Add LIBRARY_COMPATIBILITY_CHECK build switch

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agorev150: Fix a bug in TPM2_Certify()
Stefan Berger [Thu, 8 Nov 2018 19:53:52 +0000 (14:53 -0500)]
rev150: Fix a bug in TPM2_Certify()

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agorev150: Reformatting of code
Stefan Berger [Thu, 8 Nov 2018 19:51:26 +0000 (14:51 -0500)]
rev150: Reformatting of code

Reformatting of code and some fixes in code paths not used by libtpms.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agorev150: Code comment changes only
Stefan Berger [Thu, 8 Nov 2018 19:46:14 +0000 (14:46 -0500)]
rev150: Code comment changes only

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Remove Bn2bin conversion function used during OSSL 1.1 conversion
Stefan Berger [Wed, 3 Oct 2018 19:25:11 +0000 (15:25 -0400)]
tpm2: Remove Bn2bin conversion function used during OSSL 1.1 conversion

Bn2bin was used during the conversion of the code for supporting OSSL 1.1
and testing the math results of < OSSL 1.1 against those produced by
the bignum code in the TPM 2. It's not needed anymore since the upstream
code has support for any OSSL version now.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agotpm2: Remove NVRAM marshalling/unmarshalling test code
Stefan Berger [Tue, 25 Sep 2018 20:01:00 +0000 (16:01 -0400)]
tpm2: Remove NVRAM marshalling/unmarshalling test code

The test code for marshalling and unmarshalling the NVRAM hasn't
been used anymore, so remove it.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agotpm2: Remove code verifying math results
Stefan Berger [Tue, 25 Sep 2018 19:55:08 +0000 (15:55 -0400)]
tpm2: Remove code verifying math results

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agotpm2: Mark all libtpms changes with comments
Stefan Berger [Tue, 25 Sep 2018 19:38:53 +0000 (15:38 -0400)]
tpm2: Mark all libtpms changes with comments

Mark all libtpms changes with comments for easy identification
when diff'ing with the original TPM code.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agotpm2: Fix an error in BnValidateSignatureEcSm2()
Stefan Berger [Thu, 30 Aug 2018 10:20:48 +0000 (06:20 -0400)]
tpm2: Fix an error in BnValidateSignatureEcSm2()

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: Update spec version to 149
Stefan Berger [Mon, 27 Aug 2018 16:43:06 +0000 (12:43 -0400)]
rev149: Update spec version to 149

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: Sync code related to FILE_BACKED_NV #define
Stefan Berger [Mon, 27 Aug 2018 17:57:51 +0000 (13:57 -0400)]
rev149: Sync code related to FILE_BACKED_NV #define

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: Fix Initilazation of EPSeed if USE_PLATFORM_EPS is defined
Stefan Berger [Mon, 27 Aug 2018 17:43:48 +0000 (13:43 -0400)]
rev149: Fix Initilazation of EPSeed if USE_PLATFORM_EPS is defined

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: Set retVal to initial value when defining it
Stefan Berger [Mon, 27 Aug 2018 17:29:56 +0000 (13:29 -0400)]
rev149: Set retVal to initial value when defining it

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: Change #if ALG_SM3 to #if ALG_SM3_256
Stefan Berger [Mon, 27 Aug 2018 17:26:40 +0000 (13:26 -0400)]
rev149: Change #if ALG_SM3 to #if ALG_SM3_256

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: Move #if SIMULATION into function
Stefan Berger [Mon, 27 Aug 2018 17:22:15 +0000 (13:22 -0400)]
rev149: Move #if SIMULATION into function

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: add pAssert to NvClearPersistent
Stefan Berger [Mon, 27 Aug 2018 17:12:16 +0000 (13:12 -0400)]
rev149: add pAssert to NvClearPersistent

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: Use #if define SELF_TEST rather than #if SELF_TEST
Stefan Berger [Mon, 27 Aug 2018 17:01:54 +0000 (13:01 -0400)]
rev149: Use #if define SELF_TEST rather than #if SELF_TEST

Signed-off-nby: Stefan Berger <stefanb@linux.vnet.ibm.com>

5 years agorev149: Fix #define consistency check for big endian
Stefan Berger [Mon, 27 Aug 2018 16:53:14 +0000 (12:53 -0400)]
rev149: Fix #define consistency check for big endian

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: Remove usage of INLINE_FUNCTIONS #define
Stefan Berger [Mon, 27 Aug 2018 16:42:21 +0000 (12:42 -0400)]
rev149: Remove usage of INLINE_FUNCTIONS #define

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: Change CryptRandomStir to take UINT32 parameter
Stefan Berger [Mon, 27 Aug 2018 16:33:09 +0000 (12:33 -0400)]
rev149: Change CryptRandomStir to take UINT32 parameter

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: Comment and reformatting changes
Stefan Berger [Mon, 27 Aug 2018 16:30:53 +0000 (12:30 -0400)]
rev149: Comment and reformatting changes

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev149: Replace TPM_ALG_XYZ with ALG_XYZ_VALUE
Stefan Berger [Mon, 27 Aug 2018 15:41:09 +0000 (11:41 -0400)]
rev149: Replace TPM_ALG_XYZ with ALG_XYZ_VALUE

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agotpm2: Enable ALG_CMAC
Stefan Berger [Fri, 13 Jul 2018 16:46:38 +0000 (12:46 -0400)]
tpm2: Enable ALG_CMAC

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework how the TPM internal clock works
Stefan Berger [Thu, 12 Jul 2018 16:08:22 +0000 (12:08 -0400)]
rev148: Rework how the TPM internal clock works

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Remove a #ifdef from TpmToOsslMath.c
Stefan Berger [Thu, 12 Jul 2018 23:20:30 +0000 (19:20 -0400)]
rev148: Remove a #ifdef from TpmToOsslMath.c

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework entropy generation
Stefan Berger [Thu, 12 Jul 2018 23:10:52 +0000 (19:10 -0400)]
rev148: Rework entropy generation

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework BIG/LITTLE ENDIAN #defines
Stefan Berger [Thu, 12 Jul 2018 23:13:08 +0000 (19:13 -0400)]
rev148: Rework BIG/LITTLE ENDIAN #defines

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>