From 3058711f8b12cf11585e0eda2a1b573f0d871667 Mon Sep 17 00:00:00 2001 From: kavsrf Date: Mon, 17 Apr 2017 23:30:06 +0300 Subject: TPM 2.0 --- DcsCfg/DcsCfg.h | 9 ++++++++- DcsCfg/DcsCfgCrypt.c | 23 ++++++++++++----------- DcsCfg/DcsCfgMain.c | 12 ++++++++++-- DcsCfg/DcsCfgTpm.c | 20 +++++++++++++++++++- 4 files changed, 49 insertions(+), 15 deletions(-) (limited to 'DcsCfg') diff --git a/DcsCfg/DcsCfg.h b/DcsCfg/DcsCfg.h index 37fdbca..4152fe9 100644 --- a/DcsCfg/DcsCfg.h +++ b/DcsCfg/DcsCfg.h @@ -185,6 +185,13 @@ EFI_STATUS Tpm12NvList(); EFI_STATUS -Tpm12DcsConfigure(); +TpmDcsConfigure(); + +EFI_STATUS +Tpm2ListPcrs( + UINT32 sPcr, + UINT32 ePcr + ); + #endif // DcsCfg_h__ diff --git a/DcsCfg/DcsCfgCrypt.c b/DcsCfg/DcsCfgCrypt.c index e4e0e2e..0ca45ec 100644 --- a/DcsCfg/DcsCfgCrypt.c +++ b/DcsCfg/DcsCfgCrypt.c @@ -410,7 +410,7 @@ RangeCrypt( IN UINT64 headerSector ) { - EFI_STATUS res = 0; + EFI_STATUS res = EFI_SUCCESS; EFI_BLOCK_IO_PROTOCOL *io; UINT8* buf; UINT64 remains; @@ -1306,18 +1306,19 @@ PartitionOuterInit( UINTN endIndex) { INT32 vcres; - int mode = 0; - int ea = 0; - int pkcs5 = 0; - UINT64 encSectorStart; - UINT64 encSectorEnd; - UINT64 hiddenVolumeSize; - UINT64 VolumeSize; - int8 master_keydata[MASTER_KEYDATA_SIZE]; + int mode = 0; + int ea = 0; + int pkcs5 = 0; + UINT64 encSectorStart; + UINT64 encSectorEnd; + UINT64 hiddenVolumeSize; + UINT64 VolumeSize; + int8 master_keydata[MASTER_KEYDATA_SIZE]; EFI_BLOCK_IO_PROTOCOL* bio; EFI_STATUS res; EFI_LBA vhsector; EFI_LBA vhsector2; + UINT64 savePadding = 256; if (!RandgetBytes(master_keydata, MASTER_KEYDATA_SIZE, FALSE)) { ERR_PRINT(L"No randoms\n"); @@ -1383,8 +1384,8 @@ PartitionOuterInit( // init header outer end VCAuthAsk(); encSectorStart = GptMainEntrys[endIndex].StartingLBA - GptMainEntrys[outerIndex].StartingLBA; - encSectorEnd = GptMainEntrys[endIndex].EndingLBA - GptMainEntrys[outerIndex].StartingLBA - 256; - VolumeSize = GptMainEntrys[endIndex].EndingLBA - GptMainEntrys[endIndex].StartingLBA - 256 + 1; + encSectorEnd = GptMainEntrys[endIndex].EndingLBA - GptMainEntrys[outerIndex].StartingLBA - 256 - savePadding; + VolumeSize = GptMainEntrys[endIndex].EndingLBA - GptMainEntrys[endIndex].StartingLBA - 256 + 1 - savePadding; hiddenVolumeSize = VolumeSize; res = CreateVolumeHeadersInMemory( ea, mode, pkcs5, diff --git a/DcsCfg/DcsCfgMain.c b/DcsCfg/DcsCfgMain.c index 3abd759..5e5d819 100644 --- a/DcsCfg/DcsCfgMain.c +++ b/DcsCfg/DcsCfgMain.c @@ -29,6 +29,7 @@ https://opensource.org/licenses/LGPL-3.0 #include "common/Tcdefs.h" #include "crypto/cpu.h" #include "Library/DcsCfgLib.h" +#include "../Include/Library/DcsTpmLib.h" ////////////////////////////////////////////////////////////////////////// @@ -368,7 +369,14 @@ DcsCfgMain( opt2++; } ePcr = (UINT32)StrDecimalToUintn(opt2); - Tpm12ListPcrs(sPcr, ePcr); + res = GetTpm(); + if (!EFI_ERROR(res)) { + if (gTpm->TpmVersion == 0x102) { + Tpm12ListPcrs(sPcr, ePcr); + } else { + Tpm2ListPcrs(sPcr, ePcr); + } + } } if (ShellCommandLineGetFlag(Package, OPT_TPM_NVLIST)) { @@ -376,7 +384,7 @@ DcsCfgMain( } if (ShellCommandLineGetFlag(Package, OPT_TPM_CFG)) { - Tpm12DcsConfigure(); + TpmDcsConfigure(); } // Graph diff --git a/DcsCfg/DcsCfgTpm.c b/DcsCfg/DcsCfgTpm.c index 5003132..5880c19 100644 --- a/DcsCfg/DcsCfgTpm.c +++ b/DcsCfg/DcsCfgTpm.c @@ -71,7 +71,7 @@ Tpm12NvList( } EFI_STATUS -Tpm12DcsConfigure( +TpmDcsConfigure( ) { EFI_STATUS res; Password pwd; @@ -86,3 +86,21 @@ err: ERR_PRINT(L"%r, line %d", res, gCELine); return res; } + +////////////////////////////////////////////////////////////////////////// +// TPM 2.0 +////////////////////////////////////////////////////////////////////////// +EFI_STATUS +Tpm2ListPcrs( + UINT32 sPcr, + UINT32 ePcr + ) { + EFI_STATUS res; + res = InitTpm20(); + if (EFI_ERROR(res)) { + ERR_PRINT(L"%r\n", res); + return res; + } + return DcsTpm2DumpPcrs(sPcr, ePcr); +} + -- cgit v1.2.3