Commit Graph

852 Commits

Author SHA1 Message Date
Stefan Berger
db5af63392 gitignore: Ignore corpus of test cases and auto-created files
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-26 10:24:41 -04:00
Stefan Berger
63433c5be1 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>
2019-03-26 10:24:41 -04:00
Stefan Berger
4b4c3e4ee0 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>
2019-03-26 10:24:41 -04:00
Stefan Berger
399a07e3cd 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>
2019-03-26 10:24:41 -04:00
Stefan Berger
174bae9542 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>
2019-03-26 10:24:41 -04:00
Stefan Berger
f31840453a 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>
2019-03-26 10:24:41 -04:00
Stefan Berger
95ab136b83 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>
2019-03-19 09:25:44 -04:00
Stefan Berger
e6da4834cd 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>
2019-03-18 21:14:49 -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
366af2ac1f 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>
2019-01-16 09:44:12 -05:00
Stefan Berger
0b60a44790 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>
2019-01-14 08:50:41 -05:00
Stefan Berger
61440eebf8 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>
2019-01-11 07:39:50 -05:00
Stefan Berger
6ef15f2a77 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>
2019-01-11 07:39:50 -05:00
Stefan Berger
567ece331f 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>
2019-01-11 07:39:50 -05:00
Stefan Berger
1e71cf48eb 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>
2019-01-11 07:39:50 -05:00
Stefan Berger
1762b62f8c 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>
2019-01-09 11:51:41 -05:00
Stefan Berger
baf9b1ee92 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>
2019-01-09 11:51:41 -05: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
dc6e504522 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>
2019-01-09 11:51:41 -05:00
Stefan Berger
de0d14a6e5 travis: Move package installation under addons
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-09 11:51:41 -05:00
Stefan Berger
9070c15d72 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>
2019-01-07 16:40:03 +00:00
Stefan Berger
163f79e597 tests: Fix missing semicolon in test case
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-06 15:58:02 -05:00
Stefan Berger
580a7f7881 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>
2019-01-03 13:15:44 -05:00
Stefan Berger
8cb5f7d4c0 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>
2019-01-03 13:15:44 -05:00
Stefan Berger
b3509cce84 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>
2019-01-03 13:15:44 -05:00
Stefan Berger
1bd13f5bb5 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>
2019-01-03 13:15:44 -05:00
Stefan Berger
a433bf1217 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>
2019-01-03 13:15:44 -05:00
Stefan Berger
dc55da502e rev150: Update spec defines to revision 150
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
37196ce15a rev150: Remove obsolete CryptoHashData.h
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
c8ef72d930 rev150: Replace BnEccData.c with CryptEccData.c 2019-01-03 13:15:44 -05:00
Stefan Berger
db8a15798d rev150: Add #error to prevent users from defining SIMULATION
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
e327ce3c50 tpm2: Set LIBRARY_COMPATIBILITY_CHECK to YES
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
509c51e803 rev150: Add LIBRARY_COMPATIBILITY_CHECK build switch
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
4f9e942d49 rev150: Fix a bug in TPM2_Certify()
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
e69b7ee294 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>
2019-01-03 13:15:44 -05:00
Stefan Berger
380b232ec9 rev150: Code comment changes only
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
141a71cdbd 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>
2019-01-03 13:15:44 -05:00
Stefan Berger
cd93aacfab 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>
2019-01-03 13:15:44 -05:00
Stefan Berger
ee48021bfd tpm2: Remove code verifying math results
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
3cd5a386f5 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>
2019-01-03 13:15:44 -05:00
Stefan Berger
2bfed46bbc tpm2: Fix an error in BnValidateSignatureEcSm2()
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
1fc753b325 rev149: Update spec version to 149
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
bb2134a40b rev149: Sync code related to FILE_BACKED_NV #define
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
6df36cb56a rev149: Fix Initilazation of EPSeed if USE_PLATFORM_EPS is defined
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
24f6798005 rev149: Set retVal to initial value when defining it
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
10aa33d97e rev149: Change #if ALG_SM3 to #if ALG_SM3_256
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
ec7f2c6d39 rev149: Move #if SIMULATION into function
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
ba8f4aeed3 rev149: add pAssert to NvClearPersistent
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
5c7f5f49b2 rev149: Use #if define SELF_TEST rather than #if SELF_TEST
Signed-off-nby: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00