in src/tpm_comm_emulator.c [96:164]
static int power_on_simulator(TPM_COMM_INFO* tpm_comm_info)
{
int result;
TPM_SOCKET_HANDLE platform_conn;
if ((platform_conn = tpm_socket_create(tpm_comm_info->socket_ip, TPM_SIMULATOR_PLATFORM_PORT) ) == NULL)
{
LogError("Failure: connecting to tpm simulator platform interface.");
result = MU_FAILURE;
}
else
{
uint32_t power_on_cmd = htonl(REMOTE_SIGNAL_POWER_ON_CMD);
uint32_t signal_nv_cmd = htonl(REMOTE_SIGNAL_NV_ON_CMD);
if (tpm_socket_send(platform_conn, (const unsigned char*)&power_on_cmd, sizeof(power_on_cmd) ) != 0)
{
LogError("Failure sending remote handshake.");
result = MU_FAILURE;
}
else
{
uint32_t ack_value;
if (tpm_socket_read(platform_conn, (unsigned char*)&ack_value, sizeof(uint32_t)) != 0)
{
LogError("Failure sending remote handshake.");
result = MU_FAILURE;
}
else
{
if (htonl(ack_value) != 0)
{
LogError("Failure reading cmd sync.");
result = MU_FAILURE;
}
else
{
if (tpm_socket_send(platform_conn, (const unsigned char*)&signal_nv_cmd, sizeof(signal_nv_cmd) ) != 0)
{
LogError("Failure sending remote handshake.");
result = MU_FAILURE;
}
else
{
if (tpm_socket_read(platform_conn, (unsigned char*)&ack_value, sizeof(uint32_t)) != 0)
{
LogError("Failure sending remote handshake.");
result = MU_FAILURE;
}
else
{
if (htonl(ack_value) != 0)
{
LogError("Failure reading cmd sync.");
result = MU_FAILURE;
}
else
{
result = 0;
}
}
}
}
}
}
tpm_socket_destroy(platform_conn);
}
return result;
}