cryptsetup: validate optional tpm2 pcr bank field in token.

This commit is contained in:
Ondrej Kozina
2021-08-06 13:33:50 +01:00
committed by Luca Boccassi
parent 2525682565
commit 38a0aec61e
@@ -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.");