tpm2: add TPM2_PCR_VALID()

This commit is contained in:
Dan Streetman
2023-03-09 10:46:19 -05:00
parent 23b972d571
commit aa07a4fa35
4 changed files with 15 additions and 9 deletions
@@ -271,7 +271,7 @@ _public_ int cryptsetup_token_validate(
}
u = json_variant_unsigned(e);
if (u >= TPM2_PCRS_MAX) {
if (!TPM2_PCR_VALID(u)) {
crypt_log_debug(cd, "TPM2 PCR number out of range.");
return 1;
}
+1 -1
View File
@@ -438,7 +438,7 @@ static int parse_one_option(const char *option) {
}
pcr = r ? TPM_PCR_INDEX_VOLUME_KEY : UINT_MAX;
} else if (pcr >= TPM2_PCRS_MAX) {
} else if (!TPM2_PCR_VALID(pcr)) {
log_error("Selected TPM index for measurement %u outside of allowed range 0…%u, ignoring.", pcr, TPM2_PCRS_MAX-1);
return 0;
}