diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tpm-v2.c | 14 | ||||
-rw-r--r-- | lib/tpm_tcg2.c | 17 |
2 files changed, 22 insertions, 9 deletions
diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c index 0edb0aa90c9..96c164f2a54 100644 --- a/lib/tpm-v2.c +++ b/lib/tpm-v2.c @@ -884,6 +884,18 @@ const char *tpm2_algorithm_name(enum tpm2_algorithms algo) return ""; } +bool tpm2_algorithm_supported(enum tpm2_algorithms algo) +{ + size_t i; + + for (i = 0; i < ARRAY_SIZE(hash_algo_list); ++i) { + if (hash_algo_list[i].hash_alg == algo) + return hash_algo_list[i].supported; + } + + return false; +} + u16 tpm2_algorithm_to_len(enum tpm2_algorithms algo) { size_t i; @@ -908,7 +920,7 @@ bool tpm2_check_active_banks(struct udevice *dev) for (i = 0; i < pcrs.count; i++) { if (tpm2_is_active_bank(&pcrs.selection[i]) && - !tpm2_algorithm_to_len(pcrs.selection[i].hash)) + !tpm2_algorithm_supported(pcrs.selection[i].hash)) return false; } diff --git a/lib/tpm_tcg2.c b/lib/tpm_tcg2.c index 0e267ff0a7d..99671804e3b 100644 --- a/lib/tpm_tcg2.c +++ b/lib/tpm_tcg2.c @@ -36,16 +36,17 @@ int tcg2_get_pcr_info(struct udevice *dev, u32 *supported_bank, u32 *active_bank return ret; for (i = 0; i < pcrs.count; i++) { - u32 hash_mask = tcg2_algorithm_to_mask(pcrs.selection[i].hash); + struct tpms_pcr_selection *sel = &pcrs.selection[i]; + u32 hash_mask = tcg2_algorithm_to_mask(sel->hash); - if (hash_mask) { + if (tpm2_algorithm_supported(sel->hash)) *supported_bank |= hash_mask; - if (tpm2_is_active_bank(&pcrs.selection[i])) - *active_bank |= hash_mask; - } else { - printf("%s: unknown algorithm %x\n", __func__, - pcrs.selection[i].hash); - } + else + log_warning("%s: unknown algorithm %x\n", __func__, + sel->hash); + + if (tpm2_is_active_bank(sel)) + *active_bank |= hash_mask; } *bank_num = pcrs.count; |