summaryrefslogtreecommitdiff
path: root/src/security/tpm/tss
diff options
context:
space:
mode:
Diffstat (limited to 'src/security/tpm/tss')
-rw-r--r--src/security/tpm/tss/tcg-1.2/tss.c17
-rw-r--r--src/security/tpm/tss/tcg-2.0/tss.c21
2 files changed, 18 insertions, 20 deletions
diff --git a/src/security/tpm/tss/tcg-1.2/tss.c b/src/security/tpm/tss/tcg-1.2/tss.c
index 39c44eca9f..7f0607ba82 100644
--- a/src/security/tpm/tss/tcg-1.2/tss.c
+++ b/src/security/tpm/tss/tcg-1.2/tss.c
@@ -24,12 +24,18 @@
#include <console/console.h>
#define VBDEBUG(format, args...) printk(BIOS_DEBUG, format, ## args)
+static tis_sendrecv_fn tis_sendrecv;
+
static int tpm_send_receive(const uint8_t *request,
uint32_t request_length,
uint8_t *response,
uint32_t *response_length)
{
size_t len = *response_length;
+
+ if (tis_sendrecv == NULL)
+ die("TSS 1.2 wasn't initialized\n");
+
if (tis_sendrecv(request, request_length, response, &len))
return VB2_ERROR_UNKNOWN;
/* check 64->32bit overflow and (re)check response buffer overflow */
@@ -140,20 +146,15 @@ static uint32_t send(const uint8_t *command)
/* Exported functions. */
-static uint8_t tlcl_init_done;
-
uint32_t tlcl_lib_init(void)
{
- if (tlcl_init_done)
+ if (tis_sendrecv != NULL)
return VB2_SUCCESS;
- if (tis_init())
- return VB2_ERROR_UNKNOWN;
- if (tis_open())
+ tis_sendrecv = tis_probe();
+ if (tis_sendrecv == NULL)
return VB2_ERROR_UNKNOWN;
- tlcl_init_done = 1;
-
return VB2_SUCCESS;
}
diff --git a/src/security/tpm/tss/tcg-2.0/tss.c b/src/security/tpm/tss/tcg-2.0/tss.c
index d228c7f6a8..a787b13fa1 100644
--- a/src/security/tpm/tss/tcg-2.0/tss.c
+++ b/src/security/tpm/tss/tcg-2.0/tss.c
@@ -16,6 +16,8 @@
* TPM2 specification.
*/
+static tis_sendrecv_fn tis_sendrecv;
+
void *tpm_process_command(TPM_CC command, void *command_body)
{
struct obuf ob;
@@ -26,6 +28,9 @@ void *tpm_process_command(TPM_CC command, void *command_body)
/* Command/response buffer. */
static uint8_t cr_buffer[TPM_BUFFER_SIZE];
+ if (tis_sendrecv == NULL)
+ die("TSS 2.0 wasn't initialized\n");
+
obuf_init(&ob, cr_buffer, sizeof(cr_buffer));
if (tpm_marshal_command(command, command_body, &ob) < 0) {
@@ -201,26 +206,18 @@ uint32_t tlcl_clear_control(bool disable)
return TPM_SUCCESS;
}
-static uint8_t tlcl_init_done;
-
/* This function is called directly by vboot, uses vboot return types. */
uint32_t tlcl_lib_init(void)
{
- if (tlcl_init_done)
+ if (tis_sendrecv != NULL)
return VB2_SUCCESS;
- if (tis_init()) {
- printk(BIOS_ERR, "%s: tis_init returned error\n", __func__);
+ tis_sendrecv = tis_probe();
+ if (tis_sendrecv == NULL) {
+ printk(BIOS_ERR, "%s: tis_probe returned error\n", __func__);
return VB2_ERROR_UNKNOWN;
}
- if (tis_open()) {
- printk(BIOS_ERR, "%s: tis_open returned error\n", __func__);
- return VB2_ERROR_UNKNOWN;
- }
-
- tlcl_init_done = 1;
-
return VB2_SUCCESS;
}