summaryrefslogtreecommitdiff
path: root/src/lib/tpm2_tlcl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/tpm2_tlcl.c')
-rw-r--r--src/lib/tpm2_tlcl.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/lib/tpm2_tlcl.c b/src/lib/tpm2_tlcl.c
index 1118afb1df..754f835719 100644
--- a/src/lib/tpm2_tlcl.c
+++ b/src/lib/tpm2_tlcl.c
@@ -23,29 +23,34 @@
static void *tpm_process_command(TPM_CC command, void *command_body)
{
- ssize_t out_size;
+ struct obuf ob;
+ struct ibuf ib;
+ size_t out_size;
size_t in_size;
+ const uint8_t *sendb;
/* Command/response buffer. */
static uint8_t cr_buffer[TPM_BUFFER_SIZE] CAR_GLOBAL;
uint8_t *cr_buffer_ptr = car_get_var_ptr(cr_buffer);
- out_size = tpm_marshal_command(command, command_body,
- cr_buffer_ptr, sizeof(cr_buffer));
- if (out_size < 0) {
- printk(BIOS_ERR, "command %#x, cr size %zd\n",
- command, out_size);
+ obuf_init(&ob, cr_buffer_ptr, sizeof(cr_buffer));
+
+ if (tpm_marshal_command(command, command_body, &ob) < 0) {
+ printk(BIOS_ERR, "command %#x\n", command);
return NULL;
}
+ sendb = obuf_contents(&ob, &out_size);
+
in_size = sizeof(cr_buffer);
- if (tis_sendrecv(cr_buffer_ptr, out_size,
- cr_buffer_ptr, &in_size)) {
+ if (tis_sendrecv(sendb, out_size, cr_buffer_ptr, &in_size)) {
printk(BIOS_ERR, "tpm transaction failed\n");
return NULL;
}
- return tpm_unmarshal_response(command, cr_buffer_ptr, in_size);
+ ibuf_init(&ib, cr_buffer_ptr, in_size);
+
+ return tpm_unmarshal_response(command, &ib);
}