Commit Graph

1293 Commits

Author SHA1 Message Date
Stefan Berger
4498888ac9 rev148: Removed commented code
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
6c1d960564 rev148: Refactoring and cleanups in CrytpRand.c
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
5e9039f0af rev148: Fixes in Object.c
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
a3f3d346e8 rev148: Check for blockSize==0 to make static analyzer happy
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
01544ab239 rev148: Place access to variable after check for NULL
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
8b7913fbfd rev148: Reformatting of #defines in CommandAttributes.h
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
d81e616deb rev148: Follow changes to CompilerDependencies.h
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
59c369e0c0 rev148: Fix in CryptUtil.c
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
81695b9f43 rev148: Use AccessCurveData rather than a pointer
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
633019ab6f rev148: Rename a variable and a few comment changes
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
ff260e958f rev148: Cleanups in CryptHash.c
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
3c75b28711 rev148: Reformatting in RsaTestData.h
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
207f0b7ebd rev148: Implement IsNumeric() [not used]
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
d36842a68e rev148: Capitalizing names of #defines
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
fe17eeafb5 rev148: Rework of IoBuffer functions
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
6fe6519ac7 rev148: Cleanup of BigNum related macros
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
e6e45db44c rev148: BigNum related fixes
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
2e0546138f rev148: Initialize crypto libraries during manufacturing
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
fc0cf8fce9 rev148: Enable a few macros for big endian
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
2c04830af9 rev148: Changes to comments only
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
f79c8800fd rev148: Cleanup some TSS related extensions to Unmarshal functions
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
381f3a75e8 rev148: Implement TPMI_DH_SAVED_Unmarshal/Marshal
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
5c5c5c1ba3 rev148: Simplify preprocessor test for number of radix bits
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
db920d16d6 rev148: Files with header changes only
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
2e868893bc rev147: Change parameter to TPMI_ALG_HASH_Unmarshal to NO
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
7be14dd35a tpm2: Remove TcpServer{Posix}.c since we do not need it
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
2019-01-03 13:15:44 -05:00
Stefan Berger
eb14174640 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>
2018-12-17 19:52:32 -05:00
Stefan Berger
ba56737b93 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>
2018-12-10 09:17:25 -05:00
Stefan Berger
bc4aab3613 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>
2018-12-10 09:17:25 -05:00
Stefan Berger
b1832e9fed 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>
2018-12-10 09:17:25 -05:00
Stefan Berger
ad041fd1d4 tpm2: Disable CC_Vendor_TCG_Test
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-11-28 07:38:27 -05:00
Stefan Berger
823bac0fd9 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>
2018-11-23 20:52:41 -05:00
Stefan Berger
fa9163f379 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>
2018-11-23 20:28:40 -05:00
Stefan Berger
0e60fbdd3d 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>
2018-11-23 20:28:40 -05:00
Stefan Berger
8b4944fec2 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>
2018-11-23 20:28:40 -05:00
Stefan Berger
60c64ddaaf 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>
2018-11-19 12:22:50 -05:00
Stefan Berger
208218cc59 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>
2018-11-19 12:22:50 -05:00
Stefan Berger
0466fcf6a4 docs: Update the INSTALL file to reflect current build system
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-29 19:50:35 -04: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
8cc7807655 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>
2018-10-23 11:45:05 -04:00
Stefan Berger
2f3334d657 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>
2018-10-06 11:00:26 -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
73cad883ba 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>
2018-10-05 21:47:15 -04:00
Stefan Berger
8df4b30270 tpm2: Remove unnecessary re-definition of TPM_RC in header
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2018-10-05 21:47:15 -04:00
Stefan Berger
a48ea0a23d 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>
2018-10-05 21:47:15 -04:00
Stefan Berger
85eddd74ce 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>
2018-09-26 17:57:43 -04:00
Stefan Berger
3606971639 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>
2018-09-26 17:53:32 -04:00
Stefan Berger
7827f8450b 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>
2018-09-26 17:21:48 -04:00
Stefan Berger
2f1f49594a 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>
2018-09-26 17:21:41 -04:00