in src/tpm_comm_emulator.c [166:216]
static int execute_simulator_setup(TPM_COMM_INFO* tpm_comm_info)
{
int result;
uint32_t tmp_client_version = 1;
uint32_t tmp_server_version = 1;
uint32_t tpm_info;
// Send the handshake request
if (send_sync_cmd(tpm_comm_info, REMOTE_HANDSHAKE_CMD) != 0)
{
LogError("Failure sending remote handshake.");
result = MU_FAILURE;
}
// Send desired protocol version
else if (send_sync_cmd(tpm_comm_info, tmp_client_version) != 0)
{
LogError("Failure sending client version.");
result = MU_FAILURE;
}
else if (read_sync_cmd(tpm_comm_info, &tmp_server_version) != 0)
{
LogError("Failure reading cmd sync.");
result = MU_FAILURE;
}
else if (tmp_client_version != tmp_server_version)
{
LogError("Failure client and server version does not match.");
result = MU_FAILURE;
}
else if (read_sync_cmd(tpm_comm_info, &tpm_info) != 0)
{
LogError("Failure reading cmd sync.");
result = MU_FAILURE;
}
// GetAck
else if (!is_ack_ok(tpm_comm_info))
{
LogError("Failure ack byte from tpm is invalid.");
result = MU_FAILURE;
}
else if (power_on_simulator(tpm_comm_info) != 0)
{
LogError("Failure powering on simulator.");
result = MU_FAILURE;
}
else
{
result = 0;
}
return result;
}