tpm2 PCRs: fix unchecked attempt to set PCR[24]

This commit is contained in:
OMOJOLA 2023-05-04 22:21:04 +00:00 committed by Luca Boccassi
parent 5de02fe107
commit d685a5f6a4
2 changed files with 3 additions and 2 deletions

View file

@ -3152,4 +3152,4 @@ static const char* const pcr_index_table[_PCR_INDEX_MAX_DEFINED] = {
[PCR_APPLICATION_SUPPORT] = "application-support",
};
DEFINE_STRING_TABLE_LOOKUP_FROM_STRING_WITH_FALLBACK(pcr_index, int, TPM2_PCRS_MAX);
DEFINE_STRING_TABLE_LOOKUP_FROM_STRING_WITH_FALLBACK(pcr_index, int, TPM2_PCRS_MAX - 1);

View file

@ -33,7 +33,7 @@ TEST(tpm2_mask_from_string) {
test_tpm2_pcr_mask_from_string_one("sysexts,shim-policy+kernel-boot", 26624, 0);
test_tpm2_pcr_mask_from_string_one("sysexts,shim+kernel-boot", 0, -EINVAL);
test_tpm2_pcr_mask_from_string_one("sysexts+17+23", 8527872, 0);
test_tpm2_pcr_mask_from_string_one("debug+24", 16842752, 0);
test_tpm2_pcr_mask_from_string_one("debug+24", 0, -EINVAL);
}
TEST(pcr_index_from_string) {
@ -73,6 +73,7 @@ TEST(pcr_index_from_string) {
assert_se(pcr_index_from_string("8") == 8);
assert_se(pcr_index_from_string("44") == -EINVAL);
assert_se(pcr_index_from_string("-5") == -EINVAL);
assert_se(pcr_index_from_string("24") == -EINVAL);
}
TEST(tpm2_util_pbkdf2_hmac_sha256) {