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>
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>
_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>
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>
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>
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>
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>
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>
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>
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>