From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: jarkko@kernel.org, linux-integrity@vger.kernel.org
Cc: peterhuewe@gmx.de, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org,
Stefan Berger <stefanb@linux.ibm.com>
Subject: [PATCH v3 3/3] selftests: tpm2: Add support for SHA-384 and SHA-512
Date: Wed, 24 Nov 2021 19:38:27 -0500 [thread overview]
Message-ID: <20211125003827.1360432-4-stefanb@linux.vnet.ibm.com> (raw)
In-Reply-To: <20211125003827.1360432-1-stefanb@linux.vnet.ibm.com>
From: Stefan Berger <stefanb@linux.ibm.com>
Add support for SHA-384 and SHA-512 to the TPM2 library and extend
the test case's PCR bank probing function to also probe for SHA-384
and SHA-512 banks in case SHA-1 and SHA-256 banks are not available
for use.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
tools/testing/selftests/tpm2/tpm2.py | 12 +++++++++++-
tools/testing/selftests/tpm2/tpm2_tests.py | 3 ++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/tpm2/tpm2.py b/tools/testing/selftests/tpm2/tpm2.py
index f34486cd7342..d0960fe0e029 100644
--- a/tools/testing/selftests/tpm2/tpm2.py
+++ b/tools/testing/selftests/tpm2/tpm2.py
@@ -37,6 +37,8 @@ TPM2_ALG_SHA1 = 0x0004
TPM2_ALG_AES = 0x0006
TPM2_ALG_KEYEDHASH = 0x0008
TPM2_ALG_SHA256 = 0x000B
+TPM2_ALG_SHA384 = 0x000C
+TPM2_ALG_SHA512 = 0x000D
TPM2_ALG_NULL = 0x0010
TPM2_ALG_CBC = 0x0042
TPM2_ALG_CFB = 0x0043
@@ -67,6 +69,8 @@ HR_TRANSIENT = 0x80000000
SHA1_DIGEST_SIZE = 20
SHA256_DIGEST_SIZE = 32
+SHA384_DIGEST_SIZE = 48
+SHA512_DIGEST_SIZE = 64
TPM2_VER0_ERRORS = {
0x000: "TPM_RC_SUCCESS",
@@ -186,16 +190,22 @@ RC_WARN = 0x900
ALG_DIGEST_SIZE_MAP = {
TPM2_ALG_SHA1: SHA1_DIGEST_SIZE,
TPM2_ALG_SHA256: SHA256_DIGEST_SIZE,
+ TPM2_ALG_SHA384: SHA384_DIGEST_SIZE,
+ TPM2_ALG_SHA512: SHA512_DIGEST_SIZE,
}
ALG_HASH_FUNCTION_MAP = {
TPM2_ALG_SHA1: hashlib.sha1,
- TPM2_ALG_SHA256: hashlib.sha256
+ TPM2_ALG_SHA256: hashlib.sha256,
+ TPM2_ALG_SHA384: hashlib.sha384,
+ TPM2_ALG_SHA512: hashlib.sha512,
}
NAME_ALG_MAP = {
"sha1": TPM2_ALG_SHA1,
"sha256": TPM2_ALG_SHA256,
+ "sha384": TPM2_ALG_SHA384,
+ "sha512": TPM2_ALG_SHA512,
}
diff --git a/tools/testing/selftests/tpm2/tpm2_tests.py b/tools/testing/selftests/tpm2/tpm2_tests.py
index ae88d8866e5d..3feca25038f5 100644
--- a/tools/testing/selftests/tpm2/tpm2_tests.py
+++ b/tools/testing/selftests/tpm2/tpm2_tests.py
@@ -29,7 +29,8 @@ class SmokeTest(unittest.TestCase):
def determine_bank_alg(self):
# Probe for available PCR bank
- for bank_alg in [tpm2.TPM2_ALG_SHA1, tpm2.TPM2_ALG_SHA256]:
+ for bank_alg in [tpm2.TPM2_ALG_SHA1, tpm2.TPM2_ALG_SHA256,
+ tpm2.TPM2_ALG_SHA384, tpm2.TPM2_ALG_SHA512]:
try:
handle = self.client.start_auth_session(tpm2.TPM2_SE_TRIAL)
self.client.policy_pcr(handle, [17], bank_alg=bank_alg)
--
2.31.1
prev parent reply other threads:[~2021-11-25 0:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 0:38 [PATCH v3 0/3] selftests: tpm2: Probe for available PCR bank Stefan Berger
2021-11-25 0:38 ` [PATCH v3 1/3] " Stefan Berger
2021-11-27 0:29 ` Jarkko Sakkinen
2021-11-27 3:43 ` Stefan Berger
2021-11-29 23:37 ` Jarkko Sakkinen
2021-11-25 0:38 ` [PATCH v3 2/3] selftests: tpm2: Reset the dictionary attack lock Stefan Berger
2021-11-25 0:38 ` Stefan Berger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211125003827.1360432-4-stefanb@linux.vnet.ibm.com \
--to=stefanb@linux.vnet.ibm.com \
--cc=jarkko@kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=skhan@linuxfoundation.org \
--cc=stefanb@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).