]> xenbits.xensource.com Git - seabios.git/commitdiff
tcgbios: Add support for SHA3 type of algorithms
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Mon, 30 Mar 2020 11:55:57 +0000 (07:55 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 19 Apr 2020 15:35:34 +0000 (11:35 -0400)
Add support for SHA3 type of algorithms that a TPM2 may support
some time in the future.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
src/std/tcg.h
src/tcgbios.c

index 1c9eeb4e80d519b3ca36b5b55b41a1f66700e6a0..98cca49964fbd4001692777218a52bf1e1c47a87 100644 (file)
@@ -8,6 +8,9 @@
 #define SHA384_BUFSIZE              48
 #define SHA512_BUFSIZE              64
 #define SM3_256_BUFSIZE             32
+#define SHA3_256_BUFSIZE            32
+#define SHA3_384_BUFSIZE            48
+#define SHA3_512_BUFSIZE            64
 
 
 /****************************************************************
@@ -335,12 +338,18 @@ struct tpm_res_sha1complete {
 #define TPM2_ALG_SHA384             0x000c
 #define TPM2_ALG_SHA512             0x000d
 #define TPM2_ALG_SM3_256            0x0012
+#define TPM2_ALG_SHA3_256           0x0027
+#define TPM2_ALG_SHA3_384           0x0028
+#define TPM2_ALG_SHA3_512           0x0029
 
 #define TPM2_ALG_SHA1_FLAG          (1 << 0)
 #define TPM2_ALG_SHA256_FLAG        (1 << 1)
 #define TPM2_ALG_SHA384_FLAG        (1 << 2)
 #define TPM2_ALG_SHA512_FLAG        (1 << 3)
 #define TPM2_ALG_SM3_256_FLAG       (1 << 4)
+#define TPM2_ALG_SHA3_256_FLAG      (1 << 5)
+#define TPM2_ALG_SHA3_384_FLAG      (1 << 6)
+#define TPM2_ALG_SHA3_512_FLAG      (1 << 7)
 
 /* TPM 2 command tags */
 #define TPM2_ST_NO_SESSIONS         0x8001
index 6a3a613ded723ef08e1624b6fb4552ec4fc97d1c..82894f5c4dc985569d62462ca661cef5a524c9af 100644 (file)
@@ -156,9 +156,10 @@ static struct tpml_pcr_selection *tpm20_pcr_selection;
 struct tpm_log_entry {
     struct tpm_log_header hdr;
     u8 pad[sizeof(struct tpm2_digest_values)
-           + 5 * sizeof(struct tpm2_digest_value)
+           + 8 * sizeof(struct tpm2_digest_value)
            + SHA1_BUFSIZE + SHA256_BUFSIZE + SHA384_BUFSIZE
-           + SHA512_BUFSIZE + SM3_256_BUFSIZE];
+           + SHA512_BUFSIZE + SM3_256_BUFSIZE + SHA3_256_BUFSIZE
+           + SHA3_384_BUFSIZE + SHA3_512_BUFSIZE];
 } PACKED;
 
 static const struct hash_parameters {
@@ -192,6 +193,21 @@ static const struct hash_parameters {
         .hashalg_flag = TPM2_ALG_SM3_256_FLAG,
         .hash_buffersize = SM3_256_BUFSIZE,
         .name = "SM3-256",
+    }, {
+        .hashalg = TPM2_ALG_SHA3_256,
+        .hashalg_flag = TPM2_ALG_SHA3_256_FLAG,
+        .hash_buffersize = SHA3_256_BUFSIZE,
+        .name = "SHA3-256",
+    }, {
+        .hashalg = TPM2_ALG_SHA3_384,
+        .hashalg_flag = TPM2_ALG_SHA3_384_FLAG,
+        .hash_buffersize = SHA3_384_BUFSIZE,
+        .name = "SHA3-384",
+    }, {
+        .hashalg = TPM2_ALG_SHA3_512,
+        .hashalg_flag = TPM2_ALG_SHA3_512_FLAG,
+        .hash_buffersize = SHA3_512_BUFSIZE,
+        .name = "SHA3-512",
     }
 };
 
@@ -252,7 +268,7 @@ tpm20_write_EfiSpecIdEventStruct(void)
 
     struct {
         struct TCG_EfiSpecIdEventStruct hdr;
-        u8 pad[256];
+        u8 pad[sizeof(struct tpm_log_entry) + sizeof(u8)];
     } event = {
         .hdr.signature = "Spec ID Event03",
         .hdr.platformClass = TPM_TCPA_ACPI_CLASS_CLIENT,