-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tpm2: Add TPM2 as PCR provider to TCG eventlog parsing framework
TCG eventlog parsing framework parses the eventlog and extends the PCR's. For this, it needs a provider for PCR's. Register TPM2 as a provider to this framework. Signed-off-by: Ruchika Gupta <[email protected]> Acked-by: Jens Wiklander <[email protected]> Acked-by: Etienne Carriere <[email protected]>
- Loading branch information
1 parent
b8da5d8
commit 2e1b85f
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
srcs-$(CFG_DRIVERS_TPM2) += tpm2_chip.c tpm2_ptp_fifo.c tpm2_cmd.c | ||
srcs-$(CFG_DRIVERS_TPM2_MMIO) += tpm2_mmio.c | ||
srcs-$(CFG_CORE_TCG_PROVIDER) += tpm2_tcg.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-License-Identifier: BSD-2-Clause | ||
/* | ||
* Copyright (c) 2022, Linaro Limited | ||
*/ | ||
|
||
#include <drivers/tpm2_chip.h> | ||
#include <kernel/tcg.h> | ||
#include <tpm2.h> | ||
|
||
static TEE_Result tpm2_tcg_get_pcr_info(uint32_t *selection_mask, | ||
uint32_t *active_mask, | ||
uint32_t *num_pcr) | ||
{ | ||
struct tpm2_caps caps = { }; | ||
enum tpm2_result rc = TPM2_OK; | ||
|
||
rc = tpm2_chip_get_caps(&caps); | ||
if (rc) | ||
return TEE_ERROR_COMMUNICATION; | ||
|
||
*num_pcr = caps.num_pcrs; | ||
*selection_mask = caps.selection_mask; | ||
*active_mask = caps.active_mask; | ||
|
||
return TEE_SUCCESS; | ||
} | ||
|
||
static TEE_Result tpm2_tcg_pcr_extend(uint8_t pcr_idx, uint16_t alg, | ||
void *digest, uint32_t digest_len) | ||
{ | ||
if (tpm2_pcr_extend(pcr_idx, alg, digest, digest_len)) | ||
return TEE_ERROR_GENERIC; | ||
|
||
return TEE_SUCCESS; | ||
} | ||
|
||
static struct tcg_pcr_ops tpm2_tcg_ops = { | ||
.pcr_info = tpm2_tcg_get_pcr_info, | ||
.pcr_extend = tpm2_tcg_pcr_extend, | ||
}; | ||
|
||
TEE_Result tpm2_tcg_register(void) | ||
{ | ||
return register_tcg_pcr_provider(&tpm2_tcg_ops); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters