From 51f3860dfeb021d1fc2a69958bef3bca09f684b8 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Tue, 9 Jul 2019 09:46:55 -0400 Subject: [PATCH] swtpm: Have swtpm report PTM_CAP_SEND_COMMAND_HEADER flag Have swtpm report PTM_CAP_SEND_COMMAND_HEADER flag for a TPM 2 indicating that it knows how to handle the TCG header prefix for the data channel. Signed-off-by: Stefan Berger --- include/swtpm/tpm_ioctl.h | 1 + src/swtpm/ctrlchannel.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/swtpm/tpm_ioctl.h b/include/swtpm/tpm_ioctl.h index 7e19e4b9..d4ff660e 100644 --- a/include/swtpm/tpm_ioctl.h +++ b/include/swtpm/tpm_ioctl.h @@ -245,6 +245,7 @@ typedef struct ptm_getinfo ptm_getinfo; #define PTM_CAP_SET_DATAFD (1 << 12) #define PTM_CAP_SET_BUFFERSIZE (1 << 13) #define PTM_CAP_GET_INFO (1 << 14) +#define PTM_CAP_SEND_COMMAND_HEADER (1 << 15) enum { PTM_GET_CAPABILITY = _IOR('P', 0, ptm_cap), diff --git a/src/swtpm/ctrlchannel.c b/src/swtpm/ctrlchannel.c index 1ecf4f07..4f046dbc 100644 --- a/src/swtpm/ctrlchannel.c +++ b/src/swtpm/ctrlchannel.c @@ -424,9 +424,10 @@ wait_chunk: return recvd; } -static uint64_t get_ptm_caps_supported(void) +static uint64_t get_ptm_caps_supported(TPMLIB_TPMVersion tpmversion) { - return PTM_CAP_INIT + uint64_t caps = + PTM_CAP_INIT | PTM_CAP_SHUTDOWN | PTM_CAP_GET_TPMESTABLISHED | PTM_CAP_SET_LOCALITY @@ -443,6 +444,10 @@ static uint64_t get_ptm_caps_supported(void) #endif | PTM_CAP_SET_BUFFERSIZE | PTM_CAP_GET_INFO; + if (tpmversion == TPMLIB_TPM_VERSION_2) + caps |= PTM_CAP_SEND_COMMAND_HEADER; + + return caps; } /* @@ -532,7 +537,7 @@ int ctrlchannel_process_fd(int fd, switch (be32toh(input.cmd)) { case CMD_GET_CAPABILITY: - *ptm_caps = htobe64(get_ptm_caps_supported()); + *ptm_caps = htobe64(get_ptm_caps_supported(mlp->tpmversion)); out_len = sizeof(*ptm_caps); break;