]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tpm2: rename struct tpm2_context to Tpm2Context
authorDan Streetman <ddstreet@ieee.org>
Tue, 24 Jan 2023 00:52:56 +0000 (19:52 -0500)
committerDan Streetman <ddstreet@ieee.org>
Wed, 1 Feb 2023 17:51:17 +0000 (12:51 -0500)
This aligns with systemd coding guidelines for struct naming

src/boot/measure.c
src/boot/pcrphase.c
src/cryptsetup/cryptsetup.c
src/shared/tpm2-util.c
src/shared/tpm2-util.h

index b0bcfe0f983f8b023d71db6dbca15a519751bee3..0d1737200b529bda174780987796878ac1895d08 100644 (file)
@@ -726,7 +726,7 @@ static int verb_sign(int argc, char *argv[], void *userdata) {
         _cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
         _cleanup_(pcr_state_free_all) PcrState *pcr_states = NULL;
         _cleanup_(EVP_PKEY_freep) EVP_PKEY *privkey = NULL, *pubkey = NULL;
-        _cleanup_(tpm2_context_destroy) struct tpm2_context c = {};
+        _cleanup_(tpm2_context_destroy) Tpm2Context c = {};
         _cleanup_fclose_ FILE *privkeyf = NULL;
         ESYS_TR session_handle = ESYS_TR_NONE;
         TSS2_RC rc;
index 2add7f1f894bf7797f7541833f2f1f663f11b98c..057b9f495caa3c9235cc14971a30e9d139f4083b 100644 (file)
@@ -155,7 +155,7 @@ static int parse_argv(int argc, char *argv[]) {
         return 1;
 }
 
-static int determine_banks(struct tpm2_context *c, unsigned target_pcr_nr) {
+static int determine_banks(Tpm2Context *c, unsigned target_pcr_nr) {
         _cleanup_strv_free_ char **l = NULL;
         int r;
 
@@ -240,7 +240,7 @@ static int get_file_system_word(
 }
 
 static int run(int argc, char *argv[]) {
-        _cleanup_(tpm2_context_destroy) struct tpm2_context c = {};
+        _cleanup_(tpm2_context_destroy) Tpm2Context c = {};
         _cleanup_free_ char *joined = NULL, *word = NULL;
         unsigned target_pcr_nr;
         size_t length;
index 819d5bbb978217c0e6d4cd6e89f0c83f3068f26f..27d7c2769a40711a19f07c61274a4a1807793b60 100644 (file)
@@ -841,7 +841,7 @@ static int measure_volume_key(
         if (r < 0)
                 return log_error_errno(r, "Failed to load TPM2 libraries: %m");
 
-        _cleanup_(tpm2_context_destroy) struct tpm2_context c = {};
+        _cleanup_(tpm2_context_destroy) Tpm2Context c = {};
         r = tpm2_context_init(arg_tpm2_device, &c);
         if (r < 0)
                 return r;
index 363e8df5cc87d22f7463e79b68e4cf4df2dae841..9bbf1bba44332ac424ad46518a87047a3fe51e9c 100644 (file)
@@ -104,7 +104,7 @@ int dlopen_tpm2(void) {
                         DLSYM_ARG(Tss2_MU_TPM2B_PUBLIC_Unmarshal));
 }
 
-void tpm2_context_destroy(struct tpm2_context *c) {
+void tpm2_context_destroy(Tpm2Context *c) {
         assert(c);
 
         if (c->esys_context)
@@ -138,7 +138,7 @@ ESYS_TR tpm2_flush_context_verbose(ESYS_CONTEXT *c, ESYS_TR handle) {
         return ESYS_TR_NONE;
 }
 
-int tpm2_context_init(const char *device, struct tpm2_context *ret) {
+int tpm2_context_init(const char *device, Tpm2Context *ret) {
         _cleanup_(Esys_Finalize_wrapper) ESYS_CONTEXT *c = NULL;
         _cleanup_free_ TSS2_TCTI_CONTEXT *tcti = NULL;
         _cleanup_(dlclosep) void *dl = NULL;
@@ -238,7 +238,7 @@ int tpm2_context_init(const char *device, struct tpm2_context *ret) {
                 return log_error_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE),
                                        "Failed to start up TPM: %s", sym_Tss2_RC_Decode(rc));
 
-        *ret = (struct tpm2_context) {
+        *ret = (Tpm2Context) {
                 .esys_context = TAKE_PTR(c),
                 .tcti_context = TAKE_PTR(tcti),
                 .tcti_dl = TAKE_PTR(dl),
@@ -1403,7 +1403,7 @@ int tpm2_seal(const char *device,
               uint16_t *ret_pcr_bank,
               uint16_t *ret_primary_alg) {
 
-        _cleanup_(tpm2_context_destroy) struct tpm2_context c = {};
+        _cleanup_(tpm2_context_destroy) Tpm2Context c = {};
         _cleanup_(Esys_Freep) TPM2B_DIGEST *policy_digest = NULL;
         _cleanup_(Esys_Freep) TPM2B_PRIVATE *private = NULL;
         _cleanup_(Esys_Freep) TPM2B_PUBLIC *public = NULL;
@@ -1624,7 +1624,7 @@ int tpm2_unseal(const char *device,
                 void **ret_secret,
                 size_t *ret_secret_size) {
 
-        _cleanup_(tpm2_context_destroy) struct tpm2_context c = {};
+        _cleanup_(tpm2_context_destroy) Tpm2Context c = {};
         ESYS_TR primary = ESYS_TR_NONE, session = ESYS_TR_NONE, hmac_session = ESYS_TR_NONE,
                 hmac_key = ESYS_TR_NONE;
         _cleanup_(Esys_Freep) TPM2B_SENSITIVE_DATA* unsealed = NULL;
index 99b258c2900274fbc1d715baa76ddb10cf83d254..d48cbecd42e6fdc37cbac6c035f1de3cae45e8af 100644 (file)
@@ -53,11 +53,11 @@ int dlopen_tpm2(void);
 int tpm2_seal(const char *device, uint32_t hash_pcr_mask, const void *pubkey, size_t pubkey_size, uint32_t pubkey_pcr_mask, const char *pin, void **ret_secret, size_t *ret_secret_size, void **ret_blob, size_t *ret_blob_size, void **ret_pcr_hash, size_t *ret_pcr_hash_size, uint16_t *ret_pcr_bank, uint16_t *ret_primary_alg);
 int tpm2_unseal(const char *device, uint32_t hash_pcr_mask, uint16_t pcr_bank, const void *pubkey, size_t pubkey_size, uint32_t pubkey_pcr_mask, JsonVariant *signature, const char *pin, uint16_t primary_alg, const void *blob, size_t blob_size, const void *policy_hash, size_t policy_hash_size, void **ret_secret, size_t *ret_secret_size);
 
-struct tpm2_context {
+typedef struct {
         void *tcti_dl;
         TSS2_TCTI_CONTEXT *tcti_context;
         ESYS_CONTEXT *esys_context;
-};
+} Tpm2Context;
 
 ESYS_TR tpm2_flush_context_verbose(ESYS_CONTEXT *c, ESYS_TR handle);
 
@@ -73,12 +73,12 @@ int tpm2_get_good_pcr_banks_strv(ESYS_CONTEXT *c, uint32_t pcr_mask, char ***ret
 
 int tpm2_extend_bytes(ESYS_CONTEXT *c, char **banks, unsigned pcr_index, const void *data, size_t data_size, const void *secret, size_t secret_size);
 
-#else
-struct tpm2_context;
-#endif
+#else /* HAVE_TPM2 */
+typedef struct {} Tpm2Context;
+#endif /* HAVE_TPM2 */
 
-int tpm2_context_init(const char *device, struct tpm2_context *ret);
-void tpm2_context_destroy(struct tpm2_context *c);
+int tpm2_context_init(const char *device, Tpm2Context *ret);
+void tpm2_context_destroy(Tpm2Context *c);
 
 int tpm2_list_devices(void);
 int tpm2_find_device_auto(int log_level, char **ret);