1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-09 01:18:19 +03:00

tpm2-util: add common array for TPM2 hash algorithms

This is useful to enumerate all hash algorithms we want to predict
measurements for.
This commit is contained in:
Lennart Poettering 2023-10-23 22:36:09 +02:00
parent 40ce73214a
commit b52e950598
2 changed files with 14 additions and 0 deletions

View File

@ -5419,6 +5419,16 @@ int tpm2_extend_bytes(
}
#endif
const uint16_t tpm2_hash_algorithms[] = {
TPM2_ALG_SHA1,
TPM2_ALG_SHA256,
TPM2_ALG_SHA384,
TPM2_ALG_SHA512,
0,
};
assert_cc(ELEMENTSOF(tpm2_hash_algorithms) == TPM2_N_HASH_ALGORITHMS + 1);
char *tpm2_pcr_mask_to_string(uint32_t mask) {
_cleanup_free_ char *s = NULL;

View File

@ -37,6 +37,8 @@ static inline bool TPM2_PCR_MASK_VALID(uint32_t pcr_mask) {
#define FOREACH_PCR_IN_MASK(pcr, mask) BIT_FOREACH(pcr, mask)
#define TPM2_N_HASH_ALGORITHMS 4U
#if HAVE_TPM2
#include <tss2/tss2_esys.h>
@ -353,6 +355,8 @@ int tpm2_asym_alg_from_string(const char *alg) _pure_;
char *tpm2_pcr_mask_to_string(uint32_t mask);
extern const uint16_t tpm2_hash_algorithms[];
typedef struct {
uint32_t search_pcr_mask;
const char *device;