in src/tpm_comm_linux.c [311:341]
TPM_COMM_HANDLE tpm_comm_create(const char* endpoint)
{
TPM_COMM_INFO* result;
(void)endpoint;
if ((result = malloc(sizeof(TPM_COMM_INFO))) == NULL)
{
LogError("Failure: malloc tpm communication info.");
}
else
{
memset(result, 0, sizeof(TPM_COMM_INFO));
// First check if kernel mode TPM Resource Manager is available
if ((result->dev_info.tpm_device = open(TPM_RM_DEVICE_NAME, O_RDWR)) >= 0)
{
result->conn_info = TCI_SYS_DEV | TCI_TRM;
}
// If not, connect to the raw TPM device
else if ((result->dev_info.tpm_device = open(TPM_DEVICE_NAME, O_RDWR)) >= 0)
{
result->conn_info = TCI_SYS_DEV;
}
// If the system TPM device is unavalable, try connecting to the user mode TPM resource manager
else if (tpm_usermode_resmgr_connect(result) != 0)
{
LogError("Failure: connecting to the TPM device");
free(result);
result = NULL;
}
}
return result;
}