static int tpm_passthrough_unix_tx_bufs(int tpm_fd,

                                        const uint8_t *in, uint32_t in_len,

                                        uint8_t *out, uint32_t out_len)

{

    int ret;



    ret = tpm_passthrough_unix_write(tpm_fd, in, in_len);

    if (ret != in_len) {

        error_report("tpm_passthrough: error while transmitting data "

                     "to TPM: %s (%i)\n",

                     strerror(errno), errno);

        goto err_exit;

    }



    ret = tpm_passthrough_unix_read(tpm_fd, out, out_len);

    if (ret < 0) {

        error_report("tpm_passthrough: error while reading data from "

                     "TPM: %s (%i)\n",

                     strerror(errno), errno);

    } else if (ret < sizeof(struct tpm_resp_hdr) ||

               tpm_passthrough_get_size_from_buffer(out) != ret) {

        ret = -1;

        error_report("tpm_passthrough: received invalid response "

                     "packet from TPM\n");

    }



err_exit:

    if (ret < 0) {

        tpm_write_fatal_error_response(out, out_len);

    }



    return ret;

}

static int tpm_passthrough_unix_tx_bufs(int tpm_fd,

                                        const uint8_t *in, uint32_t in_len,

                                        uint8_t *out, uint32_t out_len)

{

    int ret;



    ret = tpm_passthrough_unix_write(tpm_fd, in, in_len);

    if (ret != in_len) {

        error_report("tpm_passthrough: error while transmitting data "

                     "to TPM: %s (%i)\n",

                     strerror(errno), errno);

        goto err_exit;

    }



    ret = tpm_passthrough_unix_read(tpm_fd, out, out_len);

    if (ret < 0) {

        error_report("tpm_passthrough: error while reading data from "

                     "TPM: %s (%i)\n",

                     strerror(errno), errno);

    } else if (ret < sizeof(struct tpm_resp_hdr) ||

               tpm_passthrough_get_size_from_buffer(out) != ret) {

        ret = -1;

        error_report("tpm_passthrough: received invalid response "

                     "packet from TPM\n");

    }



err_exit:

    if (ret < 0) {

        tpm_write_fatal_error_response(out, out_len);

    }



    return ret;

}

static int FUNC_0(int VAR_0,

                                        const uint8_t *VAR_1, uint32_t VAR_2,

                                        uint8_t *VAR_3, uint32_t VAR_4)

{

    int VAR_5;



    VAR_5 = tpm_passthrough_unix_write(VAR_0, VAR_1, VAR_2);

    if (VAR_5 != VAR_2) {

        error_report("tpm_passthrough: error while transmitting data "

                     "to TPM: %s (%i)\n",

                     strerror(errno), errno);

        goto err_exit;

    }



    VAR_5 = tpm_passthrough_unix_read(VAR_0, VAR_3, VAR_4);

    if (VAR_5 < 0) {

        error_report("tpm_passthrough: error while reading data from "

                     "TPM: %s (%i)\n",

                     strerror(errno), errno);

    } else if (VAR_5 < sizeof(struct tpm_resp_hdr) ||

               tpm_passthrough_get_size_from_buffer(VAR_3) != VAR_5) {

        VAR_5 = -1;

        error_report("tpm_passthrough: received invalid response "

                     "packet from TPM\n");

    }



err_exit:

    if (VAR_5 < 0) {

        tpm_write_fatal_error_response(VAR_3, VAR_4);

    }



    return VAR_5;

}

static int FUNC_0(int VAR_0,
const uint8_t *VAR_1, uint32_t VAR_2,
uint8_t *VAR_3, uint32_t VAR_4)
{ int VAR_5; VAR_5 = tpm_passthrough_unix_write(VAR_0, VAR_1, VAR_2); if (VAR_5 != VAR_2) { error_report("tpm_passthrough: error while transmitting data "
"to TPM: %s (%i)\n",
strerror(errno), errno); goto err_exit; } VAR_5 = tpm_passthrough_unix_read(VAR_0, VAR_3, VAR_4); if (VAR_5 < 0) { error_report("tpm_passthrough: error while reading data from "
"TPM: %s (%i)\n",
strerror(errno), errno); } else if (VAR_5 < sizeof(struct tpm_resp_hdr) || tpm_passthrough_get_size_from_buffer(VAR_3) != VAR_5) { VAR_5 = -1; error_report("tpm_passthrough: received invalid response "
"packet from TPM\n"); } err_exit:
if (VAR_5 < 0) { tpm_write_fatal_error_response(VAR_3, VAR_4); } return VAR_5; }