]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptsetup: validate optional tpm2 pcr bank field in token.
authorOndrej Kozina <okozina@redhat.com>
Wed, 4 Aug 2021 09:38:20 +0000 (11:38 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 6 Aug 2021 12:33:50 +0000 (13:33 +0100)
src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c

index d3aa092f6b841f21653c8538f7558460bde78ea3..0baf21d36d275c831bb7f2749971c311c3f7cb9a 100644 (file)
@@ -212,6 +212,22 @@ _public_ int cryptsetup_token_validate(
                 }
         }
 
+        /* The bank field is optional, since it was added in systemd 250 only. Before the bank was hardcoded to SHA256 */
+        w = json_variant_by_key(v, "tpm2-pcr-bank");
+        if (w) {
+                /* The PCR bank field is optional */
+
+                if (!json_variant_is_string(w)) {
+                        crypt_log_debug(cd, "TPM2 PCR bank is not a string.");
+                        return 1;
+                }
+
+                if (tpm2_pcr_bank_from_string(json_variant_string(w)) < 0) {
+                        crypt_log_debug(cd, "TPM2 PCR bank invalid or not supported: %s.", json_variant_string(w));
+                        return 1;
+                }
+        }
+
         w = json_variant_by_key(v, "tpm2-blob");
         if (!w || !json_variant_is_string(w)) {
                 crypt_log_debug(cd, "TPM2 token data lacks 'tpm2-blob' field.");