[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] vTPM/TPM2: TPM 2.0 PCRs read
commit 98cbe872432aa63db4c13810a3e32c03be8d5186 Author: Quan Xu <quan.xu@xxxxxxxxx> AuthorDate: Thu Jan 15 04:21:49 2015 -0500 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Wed Jan 28 12:54:50 2015 +0000 vTPM/TPM2: TPM 2.0 PCRs read Signed-off-by: Quan Xu <quan.xu@xxxxxxxxx> Acked-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx> --- stubdom/vtpmmgr/init.c | 34 ++++++++++++++++++++++++++++++++++ stubdom/vtpmmgr/tpm2_types.h | 2 ++ stubdom/vtpmmgr/vtpmmgr.h | 1 + 3 files changed, 37 insertions(+), 0 deletions(-) diff --git a/stubdom/vtpmmgr/init.c b/stubdom/vtpmmgr/init.c index 980f622..1506735 100644 --- a/stubdom/vtpmmgr/init.c +++ b/stubdom/vtpmmgr/init.c @@ -51,6 +51,7 @@ #include "vtpm_disk.h" #include "tpm.h" #include "marshal.h" +#include "tpm2_marshal.h" #include "tpm2.h" struct Opts { @@ -754,3 +755,36 @@ abort_egress: egress: return status; } + +TPM_RC tpm2_pcr_read(int index, uint8_t *buf) +{ + TPM_RESULT status = TPM_SUCCESS; + TPML_PCR_SELECTION pcrSelectionIn = { + .count = 1,}; + + TPMS_PCR_SELECTION tpms_pcr_selection = { + .hash = TPM2_ALG_SHA1, + .sizeofSelect = PCR_SELECT_MAX,}; + + UINT32 pcrUpdateCounter; + TPML_PCR_SELECTION pcrSelectionOut; + TPML_DIGEST pcrValues; + TPM2B_DIGEST tpm2b_digest; + + tpms_pcr_selection.pcrSelect[PCR_SELECT_NUM(index)] = PCR_SELECT_VALUE(index); + memcpy(&pcrSelectionIn.pcrSelections[0], &tpms_pcr_selection, + sizeof(TPMS_PCR_SELECTION)); + + TPMTRYRETURN(TPM2_PCR_Read(pcrSelectionIn, &pcrUpdateCounter, + &pcrSelectionOut, &pcrValues)); + + if (pcrValues.count < 1) + goto egress; + + unpack_TPM2B_DIGEST((uint8_t *) &pcrValues, &tpm2b_digest); + memcpy(buf, tpm2b_digest.buffer, SHA1_DIGEST_SIZE); + +abort_egress: +egress: + return status; +} diff --git a/stubdom/vtpmmgr/tpm2_types.h b/stubdom/vtpmmgr/tpm2_types.h index 214335c..ac2830d 100644 --- a/stubdom/vtpmmgr/tpm2_types.h +++ b/stubdom/vtpmmgr/tpm2_types.h @@ -432,6 +432,8 @@ typedef struct { #define IMPLEMENTATION_PCR 24 #define PLATFORM_PCR 24 #define PCR_SELECT_MAX ((IMPLEMENTATION_PCR+7)/8) +#define PCR_SELECT_NUM(x) (uint8_t)(x/8) +#define PCR_SELECT_VALUE(x) (uint8_t)(0x1)<<(x%8) //Table 79 -- TPMS_PCR_SELECT Structure <I/O> typedef struct { diff --git a/stubdom/vtpmmgr/vtpmmgr.h b/stubdom/vtpmmgr/vtpmmgr.h index c8cd073..46fd14f 100644 --- a/stubdom/vtpmmgr/vtpmmgr.h +++ b/stubdom/vtpmmgr/vtpmmgr.h @@ -107,6 +107,7 @@ inline TPM_RESULT vtpmmgr_rand(unsigned char* bytes, size_t num_bytes) { /* TPM 2.0 */ TPM_RC tpm2_take_ownership(void); +TPM_RC tpm2_pcr_read(int index, uint8_t *buf); TPM_RESULT vtpmmgr2_create(void); TPM_RESULT vtpmmgr2_init(int argc, char** argv); int parse_cmdline_hw(int argc, char** argv); -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |