]> xenbits.xensource.com Git - seabios.git/commitdiff
tpm: Don't call tpm_build_and_send_cmd() from tpm20_stirrandom()
authorKevin O'Connor <kevin@koconnor.net>
Wed, 10 Aug 2016 21:45:05 +0000 (17:45 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 27 Nov 2016 20:04:48 +0000 (15:04 -0500)
Instead call tpmhw_transmit() directly.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/std/tcg.h
src/tcgbios.c

index d5bf15a7315b0a6923eb23e44aa303ad19a615d4..61a759a80f794c6a31dea7faf79f0076ca32da64 100644 (file)
@@ -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;
index 5475535ac445723b736f50a9d1c472c12a4c48cb..10f8ba500804d863532fdc7cf4e9c7802d3eb26e 100644 (file)
@@ -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);