From 0dc510ab03e25e4a8a3dec225c06b5cf45e127f1 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 14 May 2025 22:27:28 +0200 Subject: [PATCH] tpm2-util: Make sure structs/enums are named and add to forward.h We have to name structs/enums to be able to forward declare them, so let's do that and add the missing ones to forward.h. --- src/basic/forward.h | 4 ++++ src/shared/tpm2-util.h | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/basic/forward.h b/src/basic/forward.h index 5f34874f337..27d248ce9d1 100644 --- a/src/basic/forward.h +++ b/src/basic/forward.h @@ -244,6 +244,8 @@ typedef enum PagerFlags PagerFlags; typedef enum PatternCompileCase PatternCompileCase; typedef enum ResolveSupport ResolveSupport; typedef enum TPM2Flags TPM2Flags; +typedef enum Tpm2Support Tpm2Support; +typedef enum Tpm2UserspaceEventType Tpm2UserspaceEventType; typedef enum UnitFileFlags UnitFileFlags; typedef enum UnitFilePresetMode UnitFilePresetMode; typedef enum UnitFileState UnitFileState; @@ -269,6 +271,8 @@ typedef struct MountOptions MountOptions; typedef struct OpenFile OpenFile; typedef struct Pkcs11EncryptedKey Pkcs11EncryptedKey; typedef struct Table Table; +typedef struct Tpm2Context Tpm2Context; +typedef struct Tpm2Handle Tpm2Handle; typedef struct Tpm2PCRValue Tpm2PCRValue; typedef struct UnitInfo UnitInfo; typedef struct UserRecord UserRecord; diff --git a/src/shared/tpm2-util.h b/src/shared/tpm2-util.h index d6e5297ce93..08c6bd45dd6 100644 --- a/src/shared/tpm2-util.h +++ b/src/shared/tpm2-util.h @@ -55,7 +55,7 @@ static inline bool TPM2_PCR_MASK_VALID(uint32_t pcr_mask) { int dlopen_tpm2(void); -typedef struct { +typedef struct Tpm2Context { unsigned n_ref; void *tcti_dl; @@ -78,7 +78,7 @@ Tpm2Context *tpm2_context_ref(Tpm2Context *context); Tpm2Context *tpm2_context_unref(Tpm2Context *context); DEFINE_TRIVIAL_CLEANUP_FUNC(Tpm2Context*, tpm2_context_unref); -typedef struct { +typedef struct Tpm2Handle { Tpm2Context *tpm2_context; ESYS_TR esys_handle; @@ -94,7 +94,7 @@ int tpm2_handle_new(Tpm2Context *context, Tpm2Handle **ret_handle); Tpm2Handle *tpm2_handle_free(Tpm2Handle *handle); DEFINE_TRIVIAL_CLEANUP_FUNC(Tpm2Handle*, tpm2_handle_free); -typedef struct { +typedef struct Tpm2PCRValue { unsigned index; TPMI_ALG_HASH hash; TPM2B_DIGEST value; @@ -370,9 +370,9 @@ int tpm2_hmac_key_from_pin(Tpm2Context *c, const Tpm2Handle *session, const TPM2 }) #else /* HAVE_TPM2 */ -typedef struct {} Tpm2Context; -typedef struct {} Tpm2Handle; -typedef struct {} Tpm2PCRValue; +typedef struct Tpm2Context {} Tpm2Context; +typedef struct Tpm2Handle {} Tpm2Handle; +typedef struct Tpm2PCRValue {} Tpm2PCRValue; #define TPM2_PCR_VALUE_MAKE(i, h, v) (Tpm2PCRValue) {} @@ -440,7 +440,7 @@ char* tpm2_pcr_mask_to_string(uint32_t mask); extern const uint16_t tpm2_hash_algorithms[]; -typedef struct { +typedef struct systemd_tpm2_plugin_params { uint32_t search_pcr_mask; const char *device; const char *signature_path; -- 2.47.3