aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-08-10 17:45:05 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-11-27 15:04:48 -0500
commit538d9b7110c178e02f02b029416952f3eb42bc5d (patch)
tree55958a40e7dc7474539e1abb6dd306cc4b61ccea
parent9ec57de1db32fc75d2acd740d4a3bf47cdf023e6 (diff)
downloadseabios-538d9b7110c178e02f02b029416952f3eb42bc5d.tar.gz
seabios-538d9b7110c178e02f02b029416952f3eb42bc5d.tar.xz
seabios-538d9b7110c178e02f02b029416952f3eb42bc5d.zip
tpm: Don't call tpm_build_and_send_cmd() from tpm20_stirrandom()
Instead call tpmhw_transmit() directly. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/std/tcg.h3
-rw-r--r--src/tcgbios.c14
2 files changed, 12 insertions, 5 deletions
diff --git a/src/std/tcg.h b/src/std/tcg.h
index d5bf15a..61a759a 100644
--- a/src/std/tcg.h
+++ b/src/std/tcg.h
@@ -356,7 +356,8 @@ struct tpm_res_sha1complete {
/* TPM 2 data structures */
-struct tpm2b_stir {
+struct tpm2_req_stirrandom {
+ struct tpm_req_header hdr;
u16 size;
u64 stir;
} PACKED;
diff --git a/src/tcgbios.c b/src/tcgbios.c
index 5475535..10f8ba5 100644
--- a/src/tcgbios.c
+++ b/src/tcgbios.c
@@ -591,16 +591,22 @@ tpm_extend(struct tpm_log_entry *le, int digest_len)
static int
tpm20_stirrandom(void)
{
- struct tpm2b_stir stir = {
+ struct tpm2_req_stirrandom stir = {
+ .hdr.tag = cpu_to_be16(TPM2_ST_NO_SESSIONS),
+ .hdr.totlen = cpu_to_be32(sizeof(stir)),
+ .hdr.ordinal = cpu_to_be32(TPM2_CC_StirRandom),
.size = cpu_to_be16(sizeof(stir.stir)),
.stir = rdtscll(),
};
/* set more bits to stir with */
stir.stir += swab64(rdtscll());
- int ret = tpm_build_and_send_cmd(0, TPM2_CC_StirRandom,
- (u8 *)&stir, sizeof(stir),
- TPM_DURATION_TYPE_SHORT);
+ struct tpm_rsp_header rsp;
+ u32 resp_length = sizeof(rsp);
+ int ret = tpmhw_transmit(0, &stir.hdr, &rsp, &resp_length,
+ TPM_DURATION_TYPE_SHORT);
+ if (ret || resp_length != sizeof(rsp) || rsp.errcode)
+ ret = -1;
dprintf(DEBUG_tcg, "TCGBIOS: Return value from sending TPM2_CC_StirRandom = 0x%08x\n",
ret);