[PATCH v3 3/3] selftests: tpm2: Add support for SHA-384 and SHA-512

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Stefan Berger <stefanb@xxxxxxxxxxxxx>

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@xxxxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux