mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
tpm: add a function that performs selftest + startup
As described in [0] if a command requires use of an untested algorithm or functional module, the TPM performs the test and then completes the command actions. Since we don't check for TPM_RC_NEEDS_TEST (which is the return code of the TPM in that case) and even if we would, it would complicate our TPM code for no apparent reason, add a wrapper function that performs both the selftest and the startup sequence of the TPM. It's worth noting that this is implemented on TPMv2.0. The code for 1.2 would look similar, but I don't have a device available to test. [0] https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-1-Architecture-01.07-2014-03-13.pdf §12.3 Self-test modes Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
parent
5b197eee33
commit
a595be3a4a
4 changed files with 57 additions and 0 deletions
25
lib/tpm-v2.c
25
lib/tpm-v2.c
|
@ -44,6 +44,31 @@ u32 tpm2_self_test(struct udevice *dev, enum tpm2_yes_no full_test)
|
|||
return tpm_sendrecv_command(dev, command_v2, NULL, NULL);
|
||||
}
|
||||
|
||||
u32 tpm2_auto_start(struct udevice *dev)
|
||||
{
|
||||
u32 rc;
|
||||
|
||||
/*
|
||||
* the tpm_init() will return -EBUSY if the init has already happened
|
||||
* The selftest and startup code can run multiple times with no side
|
||||
* effects
|
||||
*/
|
||||
rc = tpm_init(dev);
|
||||
if (rc && rc != -EBUSY)
|
||||
return rc;
|
||||
rc = tpm2_self_test(dev, TPMI_YES);
|
||||
|
||||
if (rc == TPM2_RC_INITIALIZE) {
|
||||
rc = tpm2_startup(dev, TPM2_SU_CLEAR);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = tpm2_self_test(dev, TPMI_YES);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
u32 tpm2_clear(struct udevice *dev, u32 handle, const char *pw,
|
||||
const ssize_t pw_sz)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue