]> git.proxmox.com Git - libtpms.git/log
libtpms.git
5 years agorev148: Rework USE_MARSHALING_DEFINES
Stefan Berger [Wed, 11 Jul 2018 16:54:28 +0000 (12:54 -0400)]
rev148: Rework USE_MARSHALING_DEFINES

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework _DRBG_STATE_SAVE
Stefan Berger [Wed, 11 Jul 2018 16:50:40 +0000 (12:50 -0400)]
rev148: Rework _DRBG_STATE_SAVE

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework FIPS_COMPLIANT
Stefan Berger [Wed, 11 Jul 2018 16:45:11 +0000 (12:45 -0400)]
rev148: Rework FIPS_COMPLIANT

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework DRBG_DEBUG_PRINT
Stefan Berger [Wed, 11 Jul 2018 16:37:47 +0000 (12:37 -0400)]
rev148: Rework DRBG_DEBUG_PRINT

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework ACCUMULATE_SELF_HEAL_TIMER
Stefan Berger [Wed, 11 Jul 2018 16:34:22 +0000 (12:34 -0400)]
rev148: Rework ACCUMULATE_SELF_HEAL_TIMER

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework RUNTIME_SIZE_CHECKS
Stefan Berger [Wed, 11 Jul 2018 16:17:16 +0000 (12:17 -0400)]
rev148: Rework RUNTIME_SIZE_CHECKS

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework COMPRESSED_LIST
Stefan Berger [Wed, 11 Jul 2018 16:14:49 +0000 (12:14 -0400)]
rev148: Rework COMPRESSED_LIST

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework SELF_TEST
Stefan Berger [Wed, 11 Jul 2018 15:57:25 +0000 (11:57 -0400)]
rev148: Rework SELF_TEST

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework TABLE_DRIVEN_DISPATCH
Stefan Berger [Wed, 11 Jul 2018 15:51:32 +0000 (11:51 -0400)]
rev148: Rework TABLE_DRIVEN_DISPATCH

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework USE_DA_USED
Stefan Berger [Wed, 11 Jul 2018 15:48:38 +0000 (11:48 -0400)]
rev148: Rework USE_DA_USED

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework CLOCK_STOPS
Stefan Berger [Wed, 11 Jul 2018 15:43:09 +0000 (11:43 -0400)]
rev148: Rework CLOCK_STOPS

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework USE_SPEC_COMPLIANT_PROOFS
Stefan Berger [Wed, 11 Jul 2018 15:34:52 +0000 (11:34 -0400)]
rev148: Rework USE_SPEC_COMPLIANT_PROOFS

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework SKIP_PROOF_ERRORS
Stefan Berger [Wed, 11 Jul 2018 15:27:29 +0000 (11:27 -0400)]
rev148: Rework SKIP_PROOF_ERRORS

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework bitfield structure accesses
Stefan Berger [Wed, 11 Jul 2018 14:56:15 +0000 (10:56 -0400)]
rev148: Rework bitfield structure accesses

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Changes for bit field access to data
Stefan Berger [Wed, 11 Jul 2018 13:42:10 +0000 (09:42 -0400)]
rev148: Changes for bit field access to data

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Some changes to CommandDispatchData.h
Stefan Berger [Wed, 11 Jul 2018 13:33:00 +0000 (09:33 -0400)]
rev148: Some changes to CommandDispatchData.h

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Add files for Cmac and Smac
Stefan Berger [Wed, 11 Jul 2018 13:15:37 +0000 (09:15 -0400)]
rev148: Add files for Cmac and Smac

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Initialize handleCount to 0 in ParseHandleBuffer
Stefan Berger [Wed, 11 Jul 2018 20:28:09 +0000 (16:28 -0400)]
rev148: Initialize handleCount to 0 in ParseHandleBuffer

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Fix handling of some STARTUP flags
Stefan Berger [Wed, 11 Jul 2018 12:56:11 +0000 (08:56 -0400)]
rev148: Fix handling of some STARTUP flags

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Fixes to EccSignature math and test cases
Stefan Berger [Wed, 11 Jul 2018 12:12:14 +0000 (08:12 -0400)]
rev148: Fixes to EccSignature math and test cases

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Some fixes to AlgorithmTest.c
Stefan Berger [Wed, 11 Jul 2018 12:01:00 +0000 (08:01 -0400)]
rev148: Some fixes to AlgorithmTest.c

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Implement _plat__RealTime [incomplete patch]
Stefan Berger [Wed, 11 Jul 2018 11:54:56 +0000 (07:54 -0400)]
rev148: Implement _plat__RealTime [incomplete patch]

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Removed commented code
Stefan Berger [Wed, 11 Jul 2018 11:32:40 +0000 (07:32 -0400)]
rev148: Removed commented code

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Refactoring and cleanups in CrytpRand.c
Stefan Berger [Wed, 11 Jul 2018 11:25:25 +0000 (07:25 -0400)]
rev148: Refactoring and cleanups in CrytpRand.c

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Fixes in Object.c
Stefan Berger [Wed, 11 Jul 2018 04:56:19 +0000 (00:56 -0400)]
rev148: Fixes in Object.c

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Check for blockSize==0 to make static analyzer happy
Stefan Berger [Wed, 11 Jul 2018 04:44:56 +0000 (00:44 -0400)]
rev148: Check for blockSize==0 to make static analyzer happy

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Place access to variable after check for NULL
Stefan Berger [Wed, 11 Jul 2018 04:41:21 +0000 (00:41 -0400)]
rev148: Place access to variable after check for NULL

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Reformatting of #defines in CommandAttributes.h
Stefan Berger [Wed, 11 Jul 2018 04:36:36 +0000 (00:36 -0400)]
rev148: Reformatting of #defines in CommandAttributes.h

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Follow changes to CompilerDependencies.h
Stefan Berger [Wed, 11 Jul 2018 04:35:08 +0000 (00:35 -0400)]
rev148: Follow changes to CompilerDependencies.h

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Fix in CryptUtil.c
Stefan Berger [Wed, 11 Jul 2018 04:27:49 +0000 (00:27 -0400)]
rev148: Fix in CryptUtil.c

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Use AccessCurveData rather than a pointer
Stefan Berger [Wed, 11 Jul 2018 04:23:46 +0000 (00:23 -0400)]
rev148: Use AccessCurveData rather than a pointer

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rename a variable and a few comment changes
Stefan Berger [Wed, 11 Jul 2018 04:13:19 +0000 (00:13 -0400)]
rev148: Rename a variable and a few comment changes

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Cleanups in CryptHash.c
Stefan Berger [Wed, 11 Jul 2018 04:09:32 +0000 (00:09 -0400)]
rev148: Cleanups in CryptHash.c

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Reformatting in RsaTestData.h
Stefan Berger [Wed, 11 Jul 2018 04:04:25 +0000 (00:04 -0400)]
rev148: Reformatting in RsaTestData.h

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Implement IsNumeric() [not used]
Stefan Berger [Wed, 11 Jul 2018 04:00:10 +0000 (00:00 -0400)]
rev148: Implement IsNumeric() [not used]

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Capitalizing names of #defines
Stefan Berger [Wed, 11 Jul 2018 03:58:03 +0000 (23:58 -0400)]
rev148: Capitalizing names of #defines

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Rework of IoBuffer functions
Stefan Berger [Wed, 11 Jul 2018 03:54:50 +0000 (23:54 -0400)]
rev148: Rework of IoBuffer functions

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Cleanup of BigNum related macros
Stefan Berger [Wed, 11 Jul 2018 03:37:11 +0000 (23:37 -0400)]
rev148: Cleanup of BigNum related macros

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: BigNum related fixes
Stefan Berger [Wed, 11 Jul 2018 03:32:54 +0000 (23:32 -0400)]
rev148: BigNum related fixes

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Initialize crypto libraries during manufacturing
Stefan Berger [Wed, 11 Jul 2018 03:21:57 +0000 (23:21 -0400)]
rev148: Initialize crypto libraries during manufacturing

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Enable a few macros for big endian
Stefan Berger [Wed, 11 Jul 2018 03:15:48 +0000 (23:15 -0400)]
rev148: Enable a few macros for big endian

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Changes to comments only
Stefan Berger [Wed, 11 Jul 2018 03:13:56 +0000 (23:13 -0400)]
rev148: Changes to comments only

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Cleanup some TSS related extensions to Unmarshal functions
Stefan Berger [Thu, 12 Jul 2018 13:40:53 +0000 (09:40 -0400)]
rev148: Cleanup some TSS related extensions to Unmarshal functions

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Implement TPMI_DH_SAVED_Unmarshal/Marshal
Stefan Berger [Wed, 11 Jul 2018 03:11:43 +0000 (23:11 -0400)]
rev148: Implement TPMI_DH_SAVED_Unmarshal/Marshal

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Simplify preprocessor test for number of radix bits
Stefan Berger [Wed, 11 Jul 2018 00:33:36 +0000 (20:33 -0400)]
rev148: Simplify preprocessor test for number of radix bits

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev148: Files with header changes only
Stefan Berger [Wed, 11 Jul 2018 00:20:58 +0000 (20:20 -0400)]
rev148: Files with header changes only

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agorev147: Change parameter to TPMI_ALG_HASH_Unmarshal to NO
Stefan Berger [Mon, 27 Aug 2018 17:24:57 +0000 (13:24 -0400)]
rev147: Change parameter to TPMI_ALG_HASH_Unmarshal to NO

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agotpm2: Remove TcpServer{Posix}.c since we do not need it
Stefan Berger [Wed, 11 Jul 2018 00:31:22 +0000 (20:31 -0400)]
tpm2: Remove TcpServer{Posix}.c since we do not need it

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agotests: Add simple test case reading PCRs and writing state file
Stefan Berger [Tue, 18 Dec 2018 00:13:04 +0000 (19:13 -0500)]
tests: Add simple test case reading PCRs and writing state file

Add a simple test case to make sure that reading the PCRs
works as expected and that the state file is written
as expected. This state file (NVChip) is only written because
libtpms doesn't have any callbacks registered.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotests: Wrap the fuzzer test in a script
Stefan Berger [Sun, 9 Dec 2018 19:10:11 +0000 (14:10 -0500)]
tests: Wrap the fuzzer test in a script

Wrap the fuzzer test in a script to we can set up a per fuzzer
temporary directory where the NvChip file is written into.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Log command that put TPM 2 into failure mode
Stefan Berger [Tue, 4 Dec 2018 21:39:32 +0000 (16:39 -0500)]
tpm2: Log command that put TPM 2 into failure mode

Once we detect that the TPM 2 was put into failure mode, log
the command that did it.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Check returned buffer pointer after call to _rpc__Send_Command()
Stefan Berger [Sun, 9 Dec 2018 19:01:22 +0000 (14:01 -0500)]
tpm2: Check returned buffer pointer after call to _rpc__Send_Command()

_rcp__SendCommand() may come back with a different buffer than what was
passed in. This happens when the TPM 2 is in failure more and the TPM 2
code uses an internal buffer. In this case we just copy from that inter-
nal buffer into the buffer that was passed into the function.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Disable CC_Vendor_TCG_Test
Stefan Berger [Tue, 27 Nov 2018 23:19:00 +0000 (18:19 -0500)]
tpm2: Disable CC_Vendor_TCG_Test

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: ubsan: prevent address calc on member of pointer with NULL address
Stefan Berger [Sat, 24 Nov 2018 01:52:24 +0000 (20:52 -0500)]
tpm2: ubsan: prevent address calc on member of pointer with NULL address

name maybe NULL and we may calculate the address of &name->b, which
is a member access error following ubsan. Solve this by treating the name
NULL pointer case separately.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: ubsan: prevent address calc on member of pointer with NULL address
Stefan Berger [Sat, 24 Nov 2018 00:51:34 +0000 (19:51 -0500)]
tpm2: ubsan: prevent address calc on member of pointer with NULL address

pAuth maybe NULL and we may calculate the address of &pAuth->b, which
is a member access error following ubsan. Solve this by treating the pAuth
NULL pointer case separately.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: ubsan: Cast type to UINT32 before shifting by 24 bits
Stefan Berger [Sat, 24 Nov 2018 00:48:07 +0000 (19:48 -0500)]
tpm2: ubsan: Cast type to UINT32 before shifting by 24 bits

TPM_HT_TRANSIENT has value 0x80. We have to case it to UINT32 before
shifting it by 24 bits to make ubsan quiet,

TPM_HR_PERSISTENT has value 0x81 and needs the same cast.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm12: ubsan: prevent source address NULL passed to memcpy
Stefan Berger [Sat, 24 Nov 2018 00:21:54 +0000 (19:21 -0500)]
tpm12: ubsan: prevent source address NULL passed to memcpy

memcpy() is called with source address NULL, which causes an error
with ubsan. Coincidentally data_length is also 0, so nothing bad happens.
So we simply intercept the data_length = 0 case.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Fix coverity scan issue related to error log output
Stefan Berger [Mon, 19 Nov 2018 15:19:13 +0000 (10:19 -0500)]
tpm2: Fix coverity scan issue related to error log output

Do not display the datasize, which is not initialized at this point,
but display the comparison between two size variables that is the
source of the problem.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Address a coverity issue related to buffer size
Stefan Berger [Mon, 19 Nov 2018 14:59:52 +0000 (09:59 -0500)]
tpm2: Address a coverity issue related to buffer size

Initialize the buffer size to 0 before passing it to the function filling
it from the byte stream. When comparing sizes of TPM2B, use the integers
rather than doing a memory comparison.

I don't think existing code was wrong, but this gets rid of a coverity
issue.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agodocs: Update the INSTALL file to reflect current build system
Stefan Berger [Mon, 29 Oct 2018 22:52:20 +0000 (18:52 -0400)]
docs: Update the INSTALL file to reflect current build system

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agobuild-sys: Support --disable-hardening as an option
Stefan Berger [Mon, 29 Oct 2018 22:56:39 +0000 (18:56 -0400)]
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>
5 years agotpm2: Only write STATE_RESET and STATE_CLEAR blobs when needed
Stefan Berger [Thu, 18 Oct 2018 19:22:11 +0000 (15:22 -0400)]
tpm2: Only write STATE_RESET and STATE_CLEAR blobs when needed

STATE_RESET_DATA and STATE_CLEAR_DATA need to only be written if the
orderlyState has TPM_SU_STATE (after masking out some other bits) set.

We bump up the version of the PERSISTENT_STATE to 3 and since previous
versions cannot deal with the missing STATE_{RESET,CLEAR}_DATA we require
that the minimum supported version understood by the implementation is
also '3'. This prevents downgrading of libtpms to a version prior to this
(patch).

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Fix license headers in files written by 'me'
Stefan Berger [Sat, 6 Oct 2018 14:24:49 +0000 (10:24 -0400)]
tpm2: Fix license headers in files written by 'me'

Some files have an incorrect license header. Fix this.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agobuild-sys: Only use AX_CHECK_LINK_FLAG with autoconf >= 2.64
Stefan Berger [Sat, 6 Oct 2018 14:07:58 +0000 (10:07 -0400)]
build-sys: Only use AX_CHECK_LINK_FLAG with autoconf >= 2.64

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agobuild-sys: Pass header file to compiler for checking for supported flag
Stefan Berger [Fri, 5 Oct 2018 23:07:48 +0000 (19:07 -0400)]
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>
5 years agotpm2: Introduce TPM_HAVE_TPM2_DECLARATIONS to avoid re-declarations
Stefan Berger [Fri, 5 Oct 2018 23:00:50 +0000 (19:00 -0400)]
tpm2: Introduce TPM_HAVE_TPM2_DECLARATIONS to avoid re-declarations

Older gcc versions are unhappy that some types declared by TPM 1.2
headers are re-declared by TPM 2 headers. All of these types have
the same UINT32 datatype and we can avoid having the re-declared
by introducing TPM_HAVE_TPM2_DECLARATIONS and inlcuding the TPM2
headers first and then the TPM 1.2 headers where we then do not re-
declare those datatypes that are clashing.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
5 years agotpm2: Remove unnecessary re-definition of TPM_RC in header
Stefan Berger [Fri, 5 Oct 2018 22:57:07 +0000 (18:57 -0400)]
tpm2: Remove unnecessary re-definition of TPM_RC in header

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
5 years agotpm2: Move callback invocations into their own file
Stefan Berger [Fri, 5 Oct 2018 21:03:58 +0000 (17:03 -0400)]
tpm2: Move callback invocations into their own file

Move all handling of callback invokcations in the TPM 2 code into
their own file so that we have less mixing of TPM 2 headers and
TPM 1.2 headers from the library.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
6 years agotpm12: Initialize a few pointers with NULL
Stefan Berger [Wed, 26 Sep 2018 21:55:41 +0000 (17:55 -0400)]
tpm12: Initialize a few pointers with NULL

gcc 4.2.1 on i386 OpenBSD complains about a few uninitialized pointers
being used. These seem to be false positives but we can still initialize
the pointers to NULL.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Initialize needed_size with 0
Stefan Berger [Wed, 26 Sep 2018 21:53:30 +0000 (17:53 -0400)]
tpm2: Initialize needed_size with 0

gcc 4.2.1 on i386 OpenBSD complains about needed_size being used
uninitilized. It seems a false positive but we can still initialize
it to 0.

Also set t = NULL in the error case to speed up the exit from the loop.

Signed-off-by: Stefam Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Address two more complaints by gcc 4.2.1 on i386 OpenBSD
Stefan Berger [Wed, 26 Sep 2018 21:09:55 +0000 (17:09 -0400)]
tpm2: Address two more complaints by gcc 4.2.1 on i386 OpenBSD

gcc 4.2.1 on i386 OpenBSD complains about two variables not having the
proper data type for %zu. This patch just casts the variables to size_t.

The comparison of a casted int against '< 0' also was a reason for
complaint since the evaluation of the variable would always be false
due to limited datatype. This patch also addresses this issue.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Append ULL to 64bit constants for gcc 4.2.1 on i386 OpenBSD
Stefan Berger [Wed, 26 Sep 2018 21:02:38 +0000 (17:02 -0400)]
tpm2: Append ULL to 64bit constants for gcc 4.2.1 on i386 OpenBSD

The i386 gcc 4.2.1 compiler complains about some 64bit constants
being too large. Append ULL to the constants to fix this issue.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Initialize stack variable indexOrderlyRam to zeros
Stefan Berger [Thu, 27 Sep 2018 00:41:50 +0000 (20:41 -0400)]
tpm2: Initialize stack variable indexOrderlyRam to zeros

Valgrind reports uninitialized bytes when running some of the swtpm test
cases. The reason is that the indexOrderlyRam variable, which resides on
the stack, was not initialized. This patch fixes this valgrind complaint.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: The state file exists on return code != TPM_RETRY
Stefan Berger [Mon, 17 Sep 2018 13:07:24 +0000 (09:07 -0400)]
tpm2: The state file exists on return code != TPM_RETRY

Modify the test for whether a state file exists by return code from the
load function being != TPM_RETRY. All other error codes indicate that some
form of state file exists, independent whether it is readable or not.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agorpm: Address some of the rpmlint complaints
Stefan Berger [Wed, 12 Sep 2018 23:31:05 +0000 (19:31 -0400)]
rpm: Address some of the rpmlint complaints

Remaining rpmlint complaint is the download URL. There's currently no
public tar to download.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com
6 years agodebian: Use autogen.sh and pass --with-tpm2 to configure
Stefan Berger [Thu, 13 Sep 2018 13:13:27 +0000 (09:13 -0400)]
debian: Use autogen.sh and pass --with-tpm2 to configure

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agoscripting: Use #!/usr/bin/env bash rather than /bin/bash
Stefan Berger [Mon, 10 Sep 2018 16:31:28 +0000 (16:31 +0000)]
scripting: Use #!/usr/bin/env bash rather than /bin/bash

On some systems /bin/bash does not exists but is somewhere else and can
be invoked with /usr/bin/env.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agobuild-sys: Pick up user-provided LDFLAGS
Stefan Berger [Mon, 10 Sep 2018 16:22:05 +0000 (12:22 -0400)]
build-sys: Pick up user-provided LDFLAGS

Pick up the user-provided LDFLAGS by assigning LDFLAGS using +=.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Enable compilation on DragonflyBSD
Stefan Berger [Mon, 10 Sep 2018 16:15:26 +0000 (16:15 +0000)]
tpm2: Enable compilation on DragonflyBSD

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agobuild-sys: Make 'make check' work on FreeBSD
Stefan Berger [Wed, 5 Sep 2018 22:27:53 +0000 (22:27 +0000)]
build-sys: Make 'make check' work on FreeBSD

On FreeBSD we need to set the SHELL explicitly to /bin/bash since csh
is used otherwise and wouldn't allow us to run the check-local rule.
Besides that we need -shared for the check to pass. However, the FreeBSD
compiler doesn't allow us to recognize undefined symbols, which seem
to get suppressed with the -shared parameter. If the -shared is not passed
we get error messages due to undefined symbols _progname and environ from
libc.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agobuild-sys: Fix undefined symbol check on Darwin (OS X)
Stefan Berger [Tue, 4 Sep 2018 12:00:11 +0000 (08:00 -0400)]
build-sys: Fix undefined symbol check on Darwin (OS X)

OS X needs the -shared parameter when running the undefined symbol
check.

Do not fail if a.out was not created, like on Cygwin.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotravis: use 'distcheck' rather than 'check'
Stefan Berger [Sat, 1 Sep 2018 15:14:54 +0000 (11:14 -0400)]
travis: use 'distcheck' rather than 'check'

To test the creation of the tar and out-of-tree builds all the time, do
'distcheck' rather than a simple 'check'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agobuild-sys: work around broken linker when testing --version-script support
Stefan Berger [Thu, 30 Aug 2018 21:44:18 +0000 (21:44 +0000)]
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>
6 years agobuild-sys: Remove libtpms_tpm2_la_LDFLAGS
Stefan Berger [Thu, 30 Aug 2018 21:42:26 +0000 (17:42 -0400)]
build-sys: Remove libtpms_tpm2_la_LDFLAGS

Remove libtpms_tpm2_la_LDFLAGS since they are not needed.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Make compileable on OS X/Darwin
Stefan Berger [Thu, 30 Aug 2018 18:55:04 +0000 (14:55 -0400)]
tpm2: Make compileable on OS X/Darwin

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agobuild-sys: Check for supported linker flag --version-script
Stefan Berger [Thu, 30 Aug 2018 16:50:06 +0000 (12:50 -0400)]
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>
6 years agotpm2: activate field 'a' as renamed 'a_unused' in PRC_POLICY
Stefan Berger [Thu, 30 Aug 2018 10:31:04 +0000 (06:31 -0400)]
tpm2: activate field 'a' as renamed 'a_unused' in PRC_POLICY

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agobuild-sys: Use X="$X ..." rather than X+="..." in configure.ac
Stefan Berger [Wed, 29 Aug 2018 17:47:19 +0000 (17:47 +0000)]
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>
6 years agoconfigure.ac: Replace tests with '==' through '='
Stefan Berger [Wed, 29 Aug 2018 12:12:34 +0000 (12:12 +0000)]
configure.ac: Replace tests with '==' through '='

On NetBSD configure.ac cannot have '==' in tests. So we have to replace them
with '='.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Make compileable on NetBSD
Stefan Berger [Wed, 29 Aug 2018 11:52:03 +0000 (11:52 +0000)]
tpm2: Make compileable on NetBSD

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Make compileable on FreeBSD
Stefan Berger [Wed, 29 Aug 2018 01:03:28 +0000 (01:03 +0000)]
tpm2: Make compileable on FreeBSD

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Do padding of bytes for i386 via additional bytes in array
Stefan Berger [Wed, 8 Aug 2018 22:16:59 +0000 (18:16 -0400)]
tpm2: Do padding of bytes for i386 via additional bytes in array

Instead of adding padding bytes to the end of the structure
extend the d array with 3 additional entries that are not going
to be used but provide the padding so that the structure has the
same size on 32 bit and 64 bit machines.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Fix printf format for 32 bit machines
Stefan Berger [Wed, 8 Aug 2018 16:10:48 +0000 (12:10 -0400)]
tpm2: Fix printf format for 32 bit machines

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agobuild-sys: Include autogen.sh in the tarball and use for RPM building
Stefan Berger [Wed, 8 Aug 2018 11:08:10 +0000 (07:08 -0400)]
build-sys: Include autogen.sh in the tarball and use for RPM building

Include the autogen.sh in the tarball and use it for building
the RPM.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agobuild-sys: Only remove generated .3 man files
Stefan Berger [Fri, 3 Aug 2018 17:14:36 +0000 (13:14 -0400)]
build-sys: Only remove generated .3 man files

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agopkg-config: add cryptolib to libtpms.pc
Stefan Berger [Fri, 3 Aug 2018 17:06:26 +0000 (13:06 -0400)]
pkg-config: add cryptolib to libtpms.pc

Add the cryptolib libtpms has been compiled with to libtpms.pc[.in]

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agobuild-sys: fix make distcheck
Marc-André Lureau [Thu, 2 Aug 2018 16:15:02 +0000 (18:15 +0200)]
build-sys: fix make distcheck

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoFix regression from 'Recalculate the entrysize in front of ...'
Stefan Berger [Fri, 27 Jul 2018 21:17:18 +0000 (17:17 -0400)]
Fix regression from 'Recalculate the entrysize in front of ...'

The patch 'Recalculate the entrysize in front of every USER_NVRAM blob'
did not properly account for the TPM_HANDLE when recalculating the
entry size of an OBJECT in NVRAM. As a consequence all OBJECTS and NVRAM
indices following the first OBJECT got lost.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Determine which PCR banks need to be restored
Stefan Berger [Tue, 17 Jul 2018 02:31:16 +0000 (22:31 -0400)]
tpm2: Determine which PCR banks need to be restored

Determine which PCR banks need to be restored by determining which PCR banks
are active. We only expect data for active PCR banks and the other ones do
not need data.

The tricky part here is that the TPM 2 maintains a variable that indicates
which PCR banks are active in gp.pcrAllocated and another variable in NVRAM
indicating which ones will become active after a reboot. So far we only saved
the one from NVRAM when marshalling the state but now we have to save the one
holding the current active PCR banks also. The restauration of this variable
needs to happen when we resume the VM with volatile state.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
6 years agotpm2: Recalculate the entrysize in front of every USER_NVRAM blob
Stefan Berger [Tue, 17 Jul 2018 14:32:20 +0000 (10:32 -0400)]
tpm2: Recalculate the entrysize in front of every USER_NVRAM blob

Since the sizeof(TPM_NV_INDEX) and sizeof(OBJECT) may expand when new hash
algorithms are enabled, the size of each entry in the USER_NVRAM may also
expand. We have to account for this when writing the entry size into the
NVRAM and cannot use the one from the unmarshalled state unless it is 0
or the sizes were the same. So the best is to calculate the entry size and
write it again.

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