From 985abb5eae9fea9316364300349767a15fb92856 Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 6 May 2025 16:52:28 -0700 Subject: [PATCH] Updated docs. Add test case for `TPM2_GetAlgId`. --- examples/u-boot/README.md | 28 ++++++++++++++++++++++++---- tests/unit_tests.c | 7 +++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/examples/u-boot/README.md b/examples/u-boot/README.md index 47350fd..c9597b6 100644 --- a/examples/u-boot/README.md +++ b/examples/u-boot/README.md @@ -121,12 +121,32 @@ No USB controllers found Net: eth0: virtio-net#32 Hit any key to stop autoboot: 0 -=> tpm help -tpm - Issue a TPMv1.x command +=> tpm2 help +tpm2 - Issue a TPMv2.x command Usage: -tpm cmd args... +tpm2 [] + +device [num device] + Show all devices or set the specified device +info + Show information about the TPM. ``` -7. Exiting the QEMU: +7. Example commands: + +``` +=> tpm2 info +tpm_tis@0 v2.0: VendorID 0x1014, DeviceID 0x0001, RevisionID 0x01 [open] +=> tpm2 startup TPM2_SU_CLEAR +=> tpm2 get_capability 0x6 0x20e 0x200 1 +Capabilities read from TPM: +Property 0x6a2e45a9: 0x6c3646a9 +=> tpm2 pcr_read 10 0x100000 +PCR #10 sha256 32 byte content (20 known updates): + 20 25 73 0a 00 56 61 6c 75 65 3a 0a 00 23 23 20 + 4f 75 74 20 6f 66 20 6d 65 6d 6f 72 79 0a 00 23 +``` + +8. Exiting the QEMU: Press Ctrl-A followed by X diff --git a/tests/unit_tests.c b/tests/unit_tests.c index 948ea15..99e9b31 100644 --- a/tests/unit_tests.c +++ b/tests/unit_tests.c @@ -357,6 +357,12 @@ static void test_TPM2_KDFa(void) rc >= 0 ? "Passed" : "Failed"); } +static void test_GetAlgId(void) +{ + TPM_ALG_ID alg = TPM2_GetAlgId("SHA256"); + AssertIntEQ(alg, TPM_ALG_SHA256); +} + static void test_wolfTPM2_CSR(void) { #if defined(WOLFTPM2_CERT_GEN) && !defined(WOLFTPM2_NO_HEAP) && \ @@ -663,6 +669,7 @@ int unit_tests(int argc, char *argv[]) test_wolfTPM2_GetRandom(); test_TPM2_PCRSel(); test_TPM2_KDFa(); + test_GetAlgId(); test_wolfTPM2_ReadPublicKey(); test_wolfTPM2_CSR(); #if !defined(WOLFTPM2_NO_WOLFCRYPT) && defined(WOLFTPM2_PEM_DECODE) && \