diff options
author | Stefan Berger <stefanb@linux.vnet.ibm.com> | 2016-02-02 13:09:15 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2016-02-05 20:47:37 -0500 |
commit | 8b7a0add3acfa14ea28ca9a9fbc410d314c62a10 (patch) | |
tree | 33be5eae98f243b697891ade7107ab6c390c7139 /src/tcgbios.c | |
parent | d766c1ab99a2c2a88b59a3e25a492f424e42a62e (diff) | |
download | seabios-8b7a0add3acfa14ea28ca9a9fbc410d314c62a10.tar.gz |
tpm: Implement tpm20_extend
Implement the tpm20_extend function. We use it with only SHA1.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Diffstat (limited to 'src/tcgbios.c')
-rw-r--r-- | src/tcgbios.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/tcgbios.c b/src/tcgbios.c index a99d58d6..435e2ebc 100644 --- a/src/tcgbios.c +++ b/src/tcgbios.c @@ -361,6 +361,37 @@ tpm12_extend(u32 pcrindex, const u8 *digest) return 0; } +static int tpm20_extend(u32 pcrindex, const u8 *digest) +{ + struct tpm2_req_extend tre = { + .hdr.tag = cpu_to_be16(TPM2_ST_SESSIONS), + .hdr.totlen = cpu_to_be32(sizeof(tre)), + .hdr.ordinal = cpu_to_be32(TPM2_CC_PCR_Extend), + .pcrindex = cpu_to_be32(pcrindex), + .authblocksize = cpu_to_be32(sizeof(tre.authblock)), + .authblock = { + .handle = cpu_to_be32(TPM2_RS_PW), + .noncesize = cpu_to_be16(0), + .contsession = TPM2_YES, + .pwdsize = cpu_to_be16(0), + }, + .digest = { + .count = cpu_to_be32(1), + .hashalg = cpu_to_be16(TPM2_ALG_SHA1), + }, + }; + memcpy(tre.digest.sha1, digest, sizeof(tre.digest.sha1)); + + struct tpm_rsp_header rsp; + u32 resp_length = sizeof(rsp); + int ret = tpmhw_transmit(0, &tre.hdr, &rsp, &resp_length, + TPM_DURATION_TYPE_SHORT); + if (ret || resp_length != sizeof(rsp) || rsp.errcode) + return -1; + + return 0; +} + static int tpm_extend(u32 pcrindex, const u8 *digest) { @@ -371,8 +402,7 @@ tpm_extend(u32 pcrindex, const u8 *digest) case TPM_VERSION_1_2: return tpm12_extend(pcrindex, digest); case TPM_VERSION_2: - // FIXME: missing code - return -1; + return tpm20_extend(pcrindex, digest); } return -1; } |