Coverage Report

Created: 2026-06-15 06:54

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/fu-tpm-struct.c
Line
Count
Source
1
/*
2
 * This file is auto-generated, do not modify!
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
7
#include "config.h"
8
9
#include <glib.h>
10
11
#include "fu-tpm-struct.h"
12
#include "fu-byte-array.h"
13
#include "fu-bytes.h"
14
#include "fu-mem-private.h"
15
#include "fu-string.h"
16
17
#ifdef G_LOG_DOMAIN
18
  #undef G_LOG_DOMAIN
19
#endif
20
0
#define G_LOG_DOMAIN "FuStruct"
21
22
/**
23
 * fu_tpm_alg_to_string:
24
 * @val: value, e.g. %FU_TPM_ALG_SHA1
25
 *
26
 * Converts an enumerated value to a string.
27
 *
28
 * Returns: identifier string
29
 **/
30
const gchar *
31
fu_tpm_alg_to_string(FuTpmAlg val)
32
0
{
33
0
    if (val == FU_TPM_ALG_SHA1)
34
0
        return "sha1";
35
0
    if (val == FU_TPM_ALG_SHA256)
36
0
        return "sha256";
37
0
    if (val == FU_TPM_ALG_SHA384)
38
0
        return "sha384";
39
0
    if (val == FU_TPM_ALG_SHA512)
40
0
        return "sha512";
41
0
    if (val == FU_TPM_ALG_SM3_256)
42
0
        return "sm3-256";
43
0
    if (val == FU_TPM_ALG_SHA3_256)
44
0
        return "sha3-256";
45
0
    if (val == FU_TPM_ALG_SHA3_384)
46
0
        return "sha3-384";
47
0
    if (val == FU_TPM_ALG_SHA3_512)
48
0
        return "sha3-512";
49
0
    return NULL;
50
0
}
51
/**
52
 * fu_tpm_alg_from_string:
53
 * @val: (nullable): a string, e.g. `sha1`
54
 *
55
 * Converts a string to an enumerated value.
56
 *
57
 * Returns: enumerated value
58
 **/
59
FuTpmAlg
60
fu_tpm_alg_from_string(const gchar *val)
61
0
{
62
0
    if (g_strcmp0(val, "sha1") == 0)
63
0
        return FU_TPM_ALG_SHA1;
64
0
    if (g_strcmp0(val, "sha256") == 0)
65
0
        return FU_TPM_ALG_SHA256;
66
0
    if (g_strcmp0(val, "sha384") == 0)
67
0
        return FU_TPM_ALG_SHA384;
68
0
    if (g_strcmp0(val, "sha512") == 0)
69
0
        return FU_TPM_ALG_SHA512;
70
0
    if (g_strcmp0(val, "sm3-256") == 0)
71
0
        return FU_TPM_ALG_SM3_256;
72
0
    if (g_strcmp0(val, "sha3-256") == 0)
73
0
        return FU_TPM_ALG_SHA3_256;
74
0
    if (g_strcmp0(val, "sha3-384") == 0)
75
0
        return FU_TPM_ALG_SHA3_384;
76
0
    if (g_strcmp0(val, "sha3-512") == 0)
77
0
        return FU_TPM_ALG_SHA3_512;
78
0
    return FU_TPM_ALG_UNKNOWN;
79
0
}
80
81
/**
82
 * fu_tpm_eventlog_item_kind_to_string:
83
 * @val: value, e.g. %FU_TPM_EVENTLOG_ITEM_KIND_POST_CODE
84
 *
85
 * Converts an enumerated value to a string.
86
 *
87
 * Returns: identifier string
88
 **/
89
const gchar *
90
fu_tpm_eventlog_item_kind_to_string(FuTpmEventlogItemKind val)
91
0
{
92
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_PREBOOT_CERT)
93
0
        return "preboot-cert";
94
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_POST_CODE)
95
0
        return "post-code";
96
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_NO_ACTION)
97
0
        return "no-action";
98
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_SEPARATOR)
99
0
        return "separator";
100
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_ACTION)
101
0
        return "action";
102
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EVENT_TAG)
103
0
        return "event-tag";
104
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_S_CRTM_CONTENTS)
105
0
        return "s-crtm-contents";
106
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_S_CRTM_VERSION)
107
0
        return "s-crtm-version";
108
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_CPU_MICROCODE)
109
0
        return "cpu-microcode";
110
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_PLATFORM_CONFIG_FLAGS)
111
0
        return "platform-config-flags";
112
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_TABLE_OF_DEVICES)
113
0
        return "table-of-devices";
114
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_COMPACT_HASH)
115
0
        return "compact-hash";
116
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_NONHOST_CODE)
117
0
        return "nonhost-code";
118
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_NONHOST_CONFIG)
119
0
        return "nonhost-config";
120
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_NONHOST_INFO)
121
0
        return "nonhost-info";
122
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_OMIT_BOOT_DEVICE_EVENTS)
123
0
        return "omit-boot-device-events";
124
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_EVENT_BASE)
125
0
        return "efi-event-base";
126
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_VARIABLE_DRIVER_CONFIG)
127
0
        return "efi-variable-driver-config";
128
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_VARIABLE_BOOT)
129
0
        return "efi-variable-boot";
130
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_BOOT_SERVICES_APPLICATION)
131
0
        return "efi-boot-services-application";
132
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_BOOT_SERVICES_DRIVER)
133
0
        return "efi-boot-services-driver";
134
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_RUNTIME_SERVICES_DRIVER)
135
0
        return "efi-runtime-services-driver";
136
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_GPT_EVENT)
137
0
        return "efi-gpt-event";
138
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_ACTION)
139
0
        return "efi-action";
140
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_PLATFORM_FIRMWARE_BLOB)
141
0
        return "efi-platform-firmware-blob";
142
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_HANDOFF_TABLES)
143
0
        return "efi-handoff-tables";
144
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_HCRTM_EVENT)
145
0
        return "efi-hcrtm-event";
146
0
    if (val == FU_TPM_EVENTLOG_ITEM_KIND_EFI_VARIABLE_AUTHORITY)
147
0
        return "efi-variable-authority";
148
0
    return NULL;
149
0
}
150
/**
151
 * fu_tpm_eventlog_item_kind_from_string:
152
 * @val: (nullable): a string, e.g. `post-code`
153
 *
154
 * Converts a string to an enumerated value.
155
 *
156
 * Returns: enumerated value
157
 **/
158
FuTpmEventlogItemKind
159
fu_tpm_eventlog_item_kind_from_string(const gchar *val)
160
0
{
161
0
    if (g_strcmp0(val, "preboot-cert") == 0)
162
0
        return FU_TPM_EVENTLOG_ITEM_KIND_PREBOOT_CERT;
163
0
    if (g_strcmp0(val, "post-code") == 0)
164
0
        return FU_TPM_EVENTLOG_ITEM_KIND_POST_CODE;
165
0
    if (g_strcmp0(val, "no-action") == 0)
166
0
        return FU_TPM_EVENTLOG_ITEM_KIND_NO_ACTION;
167
0
    if (g_strcmp0(val, "separator") == 0)
168
0
        return FU_TPM_EVENTLOG_ITEM_KIND_SEPARATOR;
169
0
    if (g_strcmp0(val, "action") == 0)
170
0
        return FU_TPM_EVENTLOG_ITEM_KIND_ACTION;
171
0
    if (g_strcmp0(val, "event-tag") == 0)
172
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EVENT_TAG;
173
0
    if (g_strcmp0(val, "s-crtm-contents") == 0)
174
0
        return FU_TPM_EVENTLOG_ITEM_KIND_S_CRTM_CONTENTS;
175
0
    if (g_strcmp0(val, "s-crtm-version") == 0)
176
0
        return FU_TPM_EVENTLOG_ITEM_KIND_S_CRTM_VERSION;
177
0
    if (g_strcmp0(val, "cpu-microcode") == 0)
178
0
        return FU_TPM_EVENTLOG_ITEM_KIND_CPU_MICROCODE;
179
0
    if (g_strcmp0(val, "platform-config-flags") == 0)
180
0
        return FU_TPM_EVENTLOG_ITEM_KIND_PLATFORM_CONFIG_FLAGS;
181
0
    if (g_strcmp0(val, "table-of-devices") == 0)
182
0
        return FU_TPM_EVENTLOG_ITEM_KIND_TABLE_OF_DEVICES;
183
0
    if (g_strcmp0(val, "compact-hash") == 0)
184
0
        return FU_TPM_EVENTLOG_ITEM_KIND_COMPACT_HASH;
185
0
    if (g_strcmp0(val, "nonhost-code") == 0)
186
0
        return FU_TPM_EVENTLOG_ITEM_KIND_NONHOST_CODE;
187
0
    if (g_strcmp0(val, "nonhost-config") == 0)
188
0
        return FU_TPM_EVENTLOG_ITEM_KIND_NONHOST_CONFIG;
189
0
    if (g_strcmp0(val, "nonhost-info") == 0)
190
0
        return FU_TPM_EVENTLOG_ITEM_KIND_NONHOST_INFO;
191
0
    if (g_strcmp0(val, "omit-boot-device-events") == 0)
192
0
        return FU_TPM_EVENTLOG_ITEM_KIND_OMIT_BOOT_DEVICE_EVENTS;
193
0
    if (g_strcmp0(val, "efi-event-base") == 0)
194
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_EVENT_BASE;
195
0
    if (g_strcmp0(val, "efi-variable-driver-config") == 0)
196
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_VARIABLE_DRIVER_CONFIG;
197
0
    if (g_strcmp0(val, "efi-variable-boot") == 0)
198
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_VARIABLE_BOOT;
199
0
    if (g_strcmp0(val, "efi-boot-services-application") == 0)
200
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_BOOT_SERVICES_APPLICATION;
201
0
    if (g_strcmp0(val, "efi-boot-services-driver") == 0)
202
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_BOOT_SERVICES_DRIVER;
203
0
    if (g_strcmp0(val, "efi-runtime-services-driver") == 0)
204
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_RUNTIME_SERVICES_DRIVER;
205
0
    if (g_strcmp0(val, "efi-gpt-event") == 0)
206
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_GPT_EVENT;
207
0
    if (g_strcmp0(val, "efi-action") == 0)
208
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_ACTION;
209
0
    if (g_strcmp0(val, "efi-platform-firmware-blob") == 0)
210
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_PLATFORM_FIRMWARE_BLOB;
211
0
    if (g_strcmp0(val, "efi-handoff-tables") == 0)
212
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_HANDOFF_TABLES;
213
0
    if (g_strcmp0(val, "efi-hcrtm-event") == 0)
214
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_HCRTM_EVENT;
215
0
    if (g_strcmp0(val, "efi-variable-authority") == 0)
216
0
        return FU_TPM_EVENTLOG_ITEM_KIND_EFI_VARIABLE_AUTHORITY;
217
0
    return FU_TPM_EVENTLOG_ITEM_KIND_PREBOOT_CERT;
218
0
}
219
/**
220
 * fu_struct_tpm_efi_startup_locality_event_ref: (skip):
221
 **/
222
FuStructTpmEfiStartupLocalityEvent *
223
fu_struct_tpm_efi_startup_locality_event_ref(FuStructTpmEfiStartupLocalityEvent *st)
224
0
{
225
0
    g_return_val_if_fail(st != NULL, NULL);
226
0
    st->refcount++;
227
0
    return st;
228
0
}
229
/**
230
 * fu_struct_tpm_efi_startup_locality_event_unref: (skip):
231
 **/
232
void
233
fu_struct_tpm_efi_startup_locality_event_unref(FuStructTpmEfiStartupLocalityEvent *st)
234
0
{
235
0
    g_return_if_fail(st != NULL);
236
0
    if (st->refcount == 0) {
237
0
        g_critical("FuStructTpmEfiStartupLocalityEvent refcount already zero");
238
0
        return;
239
0
    }
240
0
    if (--st->refcount > 0)
241
0
        return;
242
0
    if (st->buf != NULL)
243
0
        g_byte_array_unref(st->buf);
244
0
    g_free(st);
245
0
}
246
/**
247
 * fu_struct_tpm_efi_startup_locality_event_new_internal: (skip):
248
 **/
249
static FuStructTpmEfiStartupLocalityEvent *
250
fu_struct_tpm_efi_startup_locality_event_new_internal(void)
251
0
{
252
0
    FuStructTpmEfiStartupLocalityEvent *st = g_new0(FuStructTpmEfiStartupLocalityEvent, 1);
253
0
    st->refcount = 1;
254
0
    return st;
255
0
}
256
257
/* getters */
258
/**
259
 * fu_struct_tpm_efi_startup_locality_event_get_signature: (skip):
260
 **/
261
static gchar *
262
fu_struct_tpm_efi_startup_locality_event_get_signature(const FuStructTpmEfiStartupLocalityEvent *st)
263
0
{
264
0
    g_return_val_if_fail(st != NULL, NULL);
265
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 0, 16, NULL);
266
0
}
267
/**
268
 * fu_struct_tpm_efi_startup_locality_event_get_locality: (skip):
269
 **/
270
guint8
271
fu_struct_tpm_efi_startup_locality_event_get_locality(const FuStructTpmEfiStartupLocalityEvent *st)
272
0
{
273
0
    g_return_val_if_fail(st != NULL, 0x0);
274
0
    return st->buf->data[16];
275
0
}
276
277
/* setters */
278
/**
279
 * fu_struct_tpm_efi_startup_locality_event_to_string: (skip):
280
 **/
281
static gchar *
282
fu_struct_tpm_efi_startup_locality_event_to_string(const FuStructTpmEfiStartupLocalityEvent *st)
283
0
{
284
0
    g_autoptr(GString) str = g_string_new("FuStructTpmEfiStartupLocalityEvent:\n");
285
0
    g_return_val_if_fail(st != NULL, NULL);
286
0
    {
287
0
        g_autofree gchar *tmp = fu_struct_tpm_efi_startup_locality_event_get_signature(st);
288
0
        if (tmp != NULL)
289
0
            g_string_append_printf(str, "  signature: %s\n", tmp);
290
0
    }
291
0
    g_string_append_printf(str, "  locality: 0x%x\n",
292
0
                           (guint) fu_struct_tpm_efi_startup_locality_event_get_locality(st));
293
0
    if (str->len > 0)
294
0
        g_string_set_size(str, str->len - 1);
295
0
    return g_string_free(g_steal_pointer(&str), FALSE);
296
0
}
297
static gboolean
298
fu_struct_tpm_efi_startup_locality_event_validate_internal(FuStructTpmEfiStartupLocalityEvent *st, GError **error)
299
0
{
300
0
    g_return_val_if_fail(st != NULL, FALSE);
301
0
    if (strncmp((const gchar *) (st->buf->data + 0), "StartupLocality", 16) != 0) {
302
0
        g_autofree gchar *str = fu_struct_tpm_efi_startup_locality_event_get_signature(st);
303
0
        g_set_error(error,
304
0
                    FWUPD_ERROR,
305
0
                    FWUPD_ERROR_INVALID_DATA,
306
0
                    "constant FuStructTpmEfiStartupLocalityEvent.signature was not valid, "
307
0
                    "expected 'StartupLocality' and got '%s'",
308
0
                    str);
309
0
        return FALSE;
310
0
    }
311
0
    return TRUE;
312
0
}
313
static gboolean
314
fu_struct_tpm_efi_startup_locality_event_parse_internal(FuStructTpmEfiStartupLocalityEvent *st, GError **error)
315
0
{
316
0
    if (g_log_get_debug_enabled()) {
317
0
        g_autofree gchar *str = fu_struct_tpm_efi_startup_locality_event_to_string(st);
318
0
        g_debug("%s", str);
319
0
    }
320
0
    if (!fu_struct_tpm_efi_startup_locality_event_validate_internal(st, error))
321
0
        return FALSE;
322
0
    return TRUE;
323
0
}
324
325
/**
326
 * fu_struct_tpm_efi_startup_locality_event_parse: (skip):
327
 **/
328
static FuStructTpmEfiStartupLocalityEvent *
329
fu_struct_tpm_efi_startup_locality_event_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
330
0
{
331
0
    g_autoptr(FuStructTpmEfiStartupLocalityEvent) st = fu_struct_tpm_efi_startup_locality_event_new_internal();
332
0
    g_return_val_if_fail(buf != NULL, NULL);
333
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
334
0
    if (!fu_memchk_read(bufsz, offset, 17, error)) {
335
0
        g_prefix_error_literal(error, "invalid struct FuStructTpmEfiStartupLocalityEvent: ");
336
0
        return NULL;
337
0
    }
338
0
    st->buf = g_byte_array_new();
339
0
    g_byte_array_append(st->buf, buf + offset, 17);
340
0
    if (!fu_struct_tpm_efi_startup_locality_event_parse_internal(st, error))
341
0
        return NULL;
342
0
    return g_steal_pointer(&st);
343
0
}
344
/**
345
 * fu_struct_tpm_efi_startup_locality_event_parse_bytes: (skip):
346
 **/
347
FuStructTpmEfiStartupLocalityEvent *
348
fu_struct_tpm_efi_startup_locality_event_parse_bytes(GBytes *blob, gsize offset, GError **error)
349
0
{
350
0
    gsize bufsz = 0;
351
0
    const guint8 *buf = fu_bytes_get_data_safe(blob, &bufsz, error);
352
0
    if (buf == NULL)
353
0
        return NULL;
354
0
    return fu_struct_tpm_efi_startup_locality_event_parse(buf, bufsz, offset, error);
355
0
}
356
/**
357
 * fu_struct_tpm_event_log1_item_ref: (skip):
358
 **/
359
FuStructTpmEventLog1Item *
360
fu_struct_tpm_event_log1_item_ref(FuStructTpmEventLog1Item *st)
361
0
{
362
0
    g_return_val_if_fail(st != NULL, NULL);
363
0
    st->refcount++;
364
0
    return st;
365
0
}
366
/**
367
 * fu_struct_tpm_event_log1_item_unref: (skip):
368
 **/
369
void
370
fu_struct_tpm_event_log1_item_unref(FuStructTpmEventLog1Item *st)
371
0
{
372
0
    g_return_if_fail(st != NULL);
373
0
    if (st->refcount == 0) {
374
0
        g_critical("FuStructTpmEventLog1Item refcount already zero");
375
0
        return;
376
0
    }
377
0
    if (--st->refcount > 0)
378
0
        return;
379
0
    if (st->buf != NULL)
380
0
        g_byte_array_unref(st->buf);
381
0
    g_free(st);
382
0
}
383
/**
384
 * fu_struct_tpm_event_log1_item_new_internal: (skip):
385
 **/
386
static FuStructTpmEventLog1Item *
387
fu_struct_tpm_event_log1_item_new_internal(void)
388
0
{
389
0
    FuStructTpmEventLog1Item *st = g_new0(FuStructTpmEventLog1Item, 1);
390
0
    st->refcount = 1;
391
0
    return st;
392
0
}
393
394
/* getters */
395
/**
396
 * fu_struct_tpm_event_log1_item_get_pcr: (skip):
397
 **/
398
guint32
399
fu_struct_tpm_event_log1_item_get_pcr(const FuStructTpmEventLog1Item *st)
400
0
{
401
0
    g_return_val_if_fail(st != NULL, 0x0);
402
0
    return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
403
0
}
404
/**
405
 * fu_struct_tpm_event_log1_item_get_type: (skip):
406
 **/
407
FuTpmEventlogItemKind
408
fu_struct_tpm_event_log1_item_get_type(const FuStructTpmEventLog1Item *st)
409
0
{
410
0
    g_return_val_if_fail(st != NULL, 0x0);
411
0
    return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN);
412
0
}
413
/**
414
 * fu_struct_tpm_event_log1_item_get_digest: (skip):
415
 **/
416
const guint8 *
417
fu_struct_tpm_event_log1_item_get_digest(const FuStructTpmEventLog1Item *st, gsize *bufsz)
418
0
{
419
0
    g_return_val_if_fail(st != NULL, NULL);
420
0
    if (bufsz != NULL)
421
0
        *bufsz = 20;
422
0
    return st->buf->data + 8;
423
0
}
424
/**
425
 * fu_struct_tpm_event_log1_item_get_datasz: (skip):
426
 **/
427
guint32
428
fu_struct_tpm_event_log1_item_get_datasz(const FuStructTpmEventLog1Item *st)
429
0
{
430
0
    g_return_val_if_fail(st != NULL, 0x0);
431
0
    return fu_memread_uint32(st->buf->data + 28, G_LITTLE_ENDIAN);
432
0
}
433
434
/* setters */
435
/**
436
 * fu_struct_tpm_event_log1_item_set_pcr: (skip):
437
 **/
438
void
439
fu_struct_tpm_event_log1_item_set_pcr(FuStructTpmEventLog1Item *st, guint32 value)
440
0
{
441
0
    g_return_if_fail(st != NULL);
442
0
    fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN);
443
0
}
444
/**
445
 * fu_struct_tpm_event_log1_item_set_type: (skip):
446
 **/
447
void
448
fu_struct_tpm_event_log1_item_set_type(FuStructTpmEventLog1Item *st, FuTpmEventlogItemKind value)
449
0
{
450
0
    g_return_if_fail(st != NULL);
451
0
    fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN);
452
0
}
453
/**
454
 * fu_struct_tpm_event_log1_item_set_digest: (skip):
455
 **/
456
gboolean
457
fu_struct_tpm_event_log1_item_set_digest(FuStructTpmEventLog1Item *st, const guint8 *buf, gsize bufsz, GError **error)
458
0
{
459
0
    g_return_val_if_fail(st != NULL, FALSE);
460
0
    g_return_val_if_fail(buf != NULL, FALSE);
461
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
462
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 8, buf, bufsz, 0x0, bufsz, error);
463
0
}
464
/**
465
 * fu_struct_tpm_event_log1_item_set_datasz: (skip):
466
 **/
467
void
468
fu_struct_tpm_event_log1_item_set_datasz(FuStructTpmEventLog1Item *st, guint32 value)
469
0
{
470
0
    g_return_if_fail(st != NULL);
471
0
    fu_memwrite_uint32(st->buf->data + 28, value, G_LITTLE_ENDIAN);
472
0
}
473
/**
474
 * fu_struct_tpm_event_log1_item_new: (skip):
475
 **/
476
FuStructTpmEventLog1Item *
477
fu_struct_tpm_event_log1_item_new(void)
478
0
{
479
0
    FuStructTpmEventLog1Item *st = fu_struct_tpm_event_log1_item_new_internal();
480
0
    st->buf = g_byte_array_sized_new(32);
481
0
    fu_byte_array_set_size(st->buf, 32, 0x0);
482
0
    return st;
483
0
}
484
/**
485
 * fu_struct_tpm_event_log1_item_to_string: (skip):
486
 **/
487
static gchar *
488
fu_struct_tpm_event_log1_item_to_string(const FuStructTpmEventLog1Item *st)
489
0
{
490
0
    g_autoptr(GString) str = g_string_new("FuStructTpmEventLog1Item:\n");
491
0
    g_return_val_if_fail(st != NULL, NULL);
492
0
    g_string_append_printf(str, "  pcr: 0x%x\n",
493
0
                           (guint) fu_struct_tpm_event_log1_item_get_pcr(st));
494
0
    {
495
0
        const gchar *tmp = fu_tpm_eventlog_item_kind_to_string(fu_struct_tpm_event_log1_item_get_type(st));
496
0
        if (tmp != NULL) {
497
0
            g_string_append_printf(str, "  type: 0x%x [%s]\n", (guint) fu_struct_tpm_event_log1_item_get_type(st), tmp);
498
0
        } else {
499
0
            g_string_append_printf(str, "  type: 0x%x\n", (guint) fu_struct_tpm_event_log1_item_get_type(st));
500
0
        }
501
0
    }
502
0
    {
503
0
        gsize bufsz = 0;
504
0
        const guint8 *buf = fu_struct_tpm_event_log1_item_get_digest(st, &bufsz);
505
0
        g_autoptr(GString) tmp = g_string_new(NULL);
506
0
        for (gsize i = 0; i < bufsz; i++)
507
0
            g_string_append_printf(tmp, "%02X", buf[i]);
508
0
        g_string_append_printf(str, "  digest: 0x%s\n", tmp->str);
509
0
    }
510
0
    g_string_append_printf(str, "  datasz: 0x%x\n",
511
0
                           (guint) fu_struct_tpm_event_log1_item_get_datasz(st));
512
0
    if (str->len > 0)
513
0
        g_string_set_size(str, str->len - 1);
514
0
    return g_string_free(g_steal_pointer(&str), FALSE);
515
0
}
516
static gboolean
517
fu_struct_tpm_event_log1_item_parse_internal(FuStructTpmEventLog1Item *st, GError **error)
518
0
{
519
0
    if (g_log_get_debug_enabled()) {
520
0
        g_autofree gchar *str = fu_struct_tpm_event_log1_item_to_string(st);
521
0
        g_debug("%s", str);
522
0
    }
523
0
    return TRUE;
524
0
}
525
/**
526
 * fu_struct_tpm_event_log1_item_parse_stream: (skip):
527
 **/
528
FuStructTpmEventLog1Item *
529
fu_struct_tpm_event_log1_item_parse_stream(GInputStream *stream, gsize offset, GError **error)
530
0
{
531
0
    g_autoptr(FuStructTpmEventLog1Item) st = fu_struct_tpm_event_log1_item_new_internal();
532
0
    st->buf = fu_input_stream_read_byte_array(stream, offset, 32, NULL, error);
533
0
    if (st->buf == NULL) {
534
0
        g_prefix_error(error, "FuStructTpmEventLog1Item failed read of 0x%x: ", (guint) 32);
535
0
        return NULL;
536
0
    }
537
0
    if (st->buf->len != 32) {
538
0
        g_set_error(error,
539
0
                    FWUPD_ERROR,
540
0
                    FWUPD_ERROR_INVALID_DATA,
541
0
                    "FuStructTpmEventLog1Item requested 0x%x and got 0x%x",
542
0
                    (guint) 32,
543
0
                    (guint) st->buf->len);
544
0
        return NULL;
545
0
    }
546
0
    if (!fu_struct_tpm_event_log1_item_parse_internal(st, error))
547
0
        return NULL;
548
0
    return g_steal_pointer(&st);
549
0
}
550
/**
551
 * fu_struct_tpm_event_log2_hdr_ref: (skip):
552
 **/
553
FuStructTpmEventLog2Hdr *
554
fu_struct_tpm_event_log2_hdr_ref(FuStructTpmEventLog2Hdr *st)
555
0
{
556
0
    g_return_val_if_fail(st != NULL, NULL);
557
0
    st->refcount++;
558
0
    return st;
559
0
}
560
/**
561
 * fu_struct_tpm_event_log2_hdr_unref: (skip):
562
 **/
563
void
564
fu_struct_tpm_event_log2_hdr_unref(FuStructTpmEventLog2Hdr *st)
565
0
{
566
0
    g_return_if_fail(st != NULL);
567
0
    if (st->refcount == 0) {
568
0
        g_critical("FuStructTpmEventLog2Hdr refcount already zero");
569
0
        return;
570
0
    }
571
0
    if (--st->refcount > 0)
572
0
        return;
573
0
    if (st->buf != NULL)
574
0
        g_byte_array_unref(st->buf);
575
0
    g_free(st);
576
0
}
577
/**
578
 * fu_struct_tpm_event_log2_hdr_new_internal: (skip):
579
 **/
580
static FuStructTpmEventLog2Hdr *
581
fu_struct_tpm_event_log2_hdr_new_internal(void)
582
0
{
583
0
    FuStructTpmEventLog2Hdr *st = g_new0(FuStructTpmEventLog2Hdr, 1);
584
0
    st->refcount = 1;
585
0
    return st;
586
0
}
587
588
/* getters */
589
/**
590
 * fu_struct_tpm_event_log2_hdr_get_pcr: (skip):
591
 **/
592
static guint32
593
fu_struct_tpm_event_log2_hdr_get_pcr(const FuStructTpmEventLog2Hdr *st)
594
0
{
595
0
    g_return_val_if_fail(st != NULL, 0x0);
596
0
    return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
597
0
}
598
/**
599
 * fu_struct_tpm_event_log2_hdr_get_type: (skip):
600
 **/
601
static FuTpmEventlogItemKind
602
fu_struct_tpm_event_log2_hdr_get_type(const FuStructTpmEventLog2Hdr *st)
603
0
{
604
0
    g_return_val_if_fail(st != NULL, 0x0);
605
0
    return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN);
606
0
}
607
/**
608
 * fu_struct_tpm_event_log2_hdr_get_datasz: (skip):
609
 **/
610
guint32
611
fu_struct_tpm_event_log2_hdr_get_datasz(const FuStructTpmEventLog2Hdr *st)
612
0
{
613
0
    g_return_val_if_fail(st != NULL, 0x0);
614
0
    return fu_memread_uint32(st->buf->data + 28, G_LITTLE_ENDIAN);
615
0
}
616
/**
617
 * fu_struct_tpm_event_log2_hdr_get_data: (skip):
618
 **/
619
static gchar *
620
fu_struct_tpm_event_log2_hdr_get_data(const FuStructTpmEventLog2Hdr *st)
621
0
{
622
0
    g_return_val_if_fail(st != NULL, NULL);
623
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 32, 15, NULL);
624
0
}
625
626
/* setters */
627
/**
628
 * fu_struct_tpm_event_log2_hdr_set_pcr: (skip):
629
 **/
630
static void
631
fu_struct_tpm_event_log2_hdr_set_pcr(FuStructTpmEventLog2Hdr *st, guint32 value)
632
0
{
633
0
    g_return_if_fail(st != NULL);
634
0
    fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN);
635
0
}
636
/**
637
 * fu_struct_tpm_event_log2_hdr_set_type: (skip):
638
 **/
639
static void
640
fu_struct_tpm_event_log2_hdr_set_type(FuStructTpmEventLog2Hdr *st, FuTpmEventlogItemKind value)
641
0
{
642
0
    g_return_if_fail(st != NULL);
643
0
    fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN);
644
0
}
645
/**
646
 * fu_struct_tpm_event_log2_hdr_set_datasz: (skip):
647
 **/
648
void
649
fu_struct_tpm_event_log2_hdr_set_datasz(FuStructTpmEventLog2Hdr *st, guint32 value)
650
0
{
651
0
    g_return_if_fail(st != NULL);
652
0
    fu_memwrite_uint32(st->buf->data + 28, value, G_LITTLE_ENDIAN);
653
0
}
654
/**
655
 * fu_struct_tpm_event_log2_hdr_set_data: (skip):
656
 **/
657
static gboolean
658
fu_struct_tpm_event_log2_hdr_set_data(FuStructTpmEventLog2Hdr *st, const gchar *value, GError **error)
659
0
{
660
0
    gsize len;
661
0
    g_return_val_if_fail(st != NULL, FALSE);
662
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
663
0
    if (value == NULL) {
664
0
        memset(st->buf->data + 32, 0x0, 15);
665
0
        return TRUE;
666
0
    }
667
0
    len = strlen(value);
668
0
    if (len > 15) {
669
0
        g_set_error(error,
670
0
                    FWUPD_ERROR,
671
0
                    FWUPD_ERROR_INVALID_DATA,
672
0
                    "string '%s' (0x%x bytes) does not fit in FuStructTpmEventLog2Hdr.data (0x%x bytes)",
673
0
                    value, (guint) len, (guint) 15);
674
0
        return FALSE;
675
0
    }
676
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 32, (const guint8 *)value, len, 0x0, len, error);
677
0
}
678
/**
679
 * fu_struct_tpm_event_log2_hdr_new: (skip):
680
 **/
681
FuStructTpmEventLog2Hdr *
682
fu_struct_tpm_event_log2_hdr_new(void)
683
0
{
684
0
    FuStructTpmEventLog2Hdr *st = fu_struct_tpm_event_log2_hdr_new_internal();
685
0
    st->buf = g_byte_array_sized_new(47);
686
0
    fu_byte_array_set_size(st->buf, 47, 0x0);
687
0
    fu_struct_tpm_event_log2_hdr_set_pcr(st, 0x0);
688
0
    fu_struct_tpm_event_log2_hdr_set_type(st, FU_TPM_EVENTLOG_ITEM_KIND_NO_ACTION);
689
0
    fu_struct_tpm_event_log2_hdr_set_datasz(st, 15);
690
0
    fu_struct_tpm_event_log2_hdr_set_data(st, "Spec ID Event03", NULL);
691
0
    return st;
692
0
}
693
/**
694
 * fu_struct_tpm_event_log2_hdr_to_string: (skip):
695
 **/
696
static gchar *
697
fu_struct_tpm_event_log2_hdr_to_string(const FuStructTpmEventLog2Hdr *st)
698
0
{
699
0
    g_autoptr(GString) str = g_string_new("FuStructTpmEventLog2Hdr:\n");
700
0
    g_return_val_if_fail(st != NULL, NULL);
701
0
    g_string_append_printf(str, "  pcr: 0x%x\n",
702
0
                           (guint) fu_struct_tpm_event_log2_hdr_get_pcr(st));
703
0
    {
704
0
        const gchar *tmp = fu_tpm_eventlog_item_kind_to_string(fu_struct_tpm_event_log2_hdr_get_type(st));
705
0
        if (tmp != NULL) {
706
0
            g_string_append_printf(str, "  type: 0x%x [%s]\n", (guint) fu_struct_tpm_event_log2_hdr_get_type(st), tmp);
707
0
        } else {
708
0
            g_string_append_printf(str, "  type: 0x%x\n", (guint) fu_struct_tpm_event_log2_hdr_get_type(st));
709
0
        }
710
0
    }
711
0
    g_string_append_printf(str, "  datasz: 0x%x\n",
712
0
                           (guint) fu_struct_tpm_event_log2_hdr_get_datasz(st));
713
0
    {
714
0
        g_autofree gchar *tmp = fu_struct_tpm_event_log2_hdr_get_data(st);
715
0
        if (tmp != NULL)
716
0
            g_string_append_printf(str, "  data: %s\n", tmp);
717
0
    }
718
0
    if (str->len > 0)
719
0
        g_string_set_size(str, str->len - 1);
720
0
    return g_string_free(g_steal_pointer(&str), FALSE);
721
0
}
722
static gboolean
723
fu_struct_tpm_event_log2_hdr_validate_internal(FuStructTpmEventLog2Hdr *st, GError **error)
724
0
{
725
0
    g_return_val_if_fail(st != NULL, FALSE);
726
0
    if (fu_struct_tpm_event_log2_hdr_get_pcr(st) != 0x0) {
727
0
        g_set_error(error,
728
0
                    FWUPD_ERROR,
729
0
                    FWUPD_ERROR_INVALID_DATA,
730
0
                    "constant FuStructTpmEventLog2Hdr.pcr was not valid, "
731
0
                    "expected 0x%x and got 0x%x",
732
0
                    (guint) 0x0,
733
0
                    (guint) fu_struct_tpm_event_log2_hdr_get_pcr(st));
734
0
        return FALSE;
735
0
    }
736
0
    if (fu_struct_tpm_event_log2_hdr_get_type(st) != FU_TPM_EVENTLOG_ITEM_KIND_NO_ACTION) {
737
0
        g_set_error(error,
738
0
                    FWUPD_ERROR,
739
0
                    FWUPD_ERROR_INVALID_DATA,
740
0
                    "constant FuStructTpmEventLog2Hdr.type was not valid, "
741
0
                    "expected 'FU_TPM_EVENTLOG_ITEM_KIND_NO_ACTION' and got 0x%x '%s'",
742
0
                    fu_struct_tpm_event_log2_hdr_get_type(st),
743
0
                    fu_tpm_eventlog_item_kind_to_string(fu_struct_tpm_event_log2_hdr_get_type(st)));
744
0
        return FALSE;
745
0
    }
746
0
    if (strncmp((const gchar *) (st->buf->data + 32), "Spec ID Event03", 15) != 0) {
747
0
        g_autofree gchar *str = fu_struct_tpm_event_log2_hdr_get_data(st);
748
0
        g_set_error(error,
749
0
                    FWUPD_ERROR,
750
0
                    FWUPD_ERROR_INVALID_DATA,
751
0
                    "constant FuStructTpmEventLog2Hdr.data was not valid, "
752
0
                    "expected 'Spec ID Event03' and got '%s'",
753
0
                    str);
754
0
        return FALSE;
755
0
    }
756
0
    return TRUE;
757
0
}
758
static gboolean
759
fu_struct_tpm_event_log2_hdr_parse_internal(FuStructTpmEventLog2Hdr *st, GError **error)
760
0
{
761
0
    if (g_log_get_debug_enabled()) {
762
0
        g_autofree gchar *str = fu_struct_tpm_event_log2_hdr_to_string(st);
763
0
        g_debug("%s", str);
764
0
    }
765
0
    if (!fu_struct_tpm_event_log2_hdr_validate_internal(st, error))
766
0
        return FALSE;
767
0
    return TRUE;
768
0
}
769
/**
770
 * fu_struct_tpm_event_log2_hdr_parse_stream: (skip):
771
 **/
772
FuStructTpmEventLog2Hdr *
773
fu_struct_tpm_event_log2_hdr_parse_stream(GInputStream *stream, gsize offset, GError **error)
774
0
{
775
0
    g_autoptr(FuStructTpmEventLog2Hdr) st = fu_struct_tpm_event_log2_hdr_new_internal();
776
0
    st->buf = fu_input_stream_read_byte_array(stream, offset, 47, NULL, error);
777
0
    if (st->buf == NULL) {
778
0
        g_prefix_error(error, "FuStructTpmEventLog2Hdr failed read of 0x%x: ", (guint) 47);
779
0
        return NULL;
780
0
    }
781
0
    if (st->buf->len != 47) {
782
0
        g_set_error(error,
783
0
                    FWUPD_ERROR,
784
0
                    FWUPD_ERROR_INVALID_DATA,
785
0
                    "FuStructTpmEventLog2Hdr requested 0x%x and got 0x%x",
786
0
                    (guint) 47,
787
0
                    (guint) st->buf->len);
788
0
        return NULL;
789
0
    }
790
0
    if (!fu_struct_tpm_event_log2_hdr_parse_internal(st, error))
791
0
        return NULL;
792
0
    return g_steal_pointer(&st);
793
0
}
794
/**
795
 * fu_struct_tpm_event_log2_ref: (skip):
796
 **/
797
FuStructTpmEventLog2 *
798
fu_struct_tpm_event_log2_ref(FuStructTpmEventLog2 *st)
799
0
{
800
0
    g_return_val_if_fail(st != NULL, NULL);
801
0
    st->refcount++;
802
0
    return st;
803
0
}
804
/**
805
 * fu_struct_tpm_event_log2_unref: (skip):
806
 **/
807
void
808
fu_struct_tpm_event_log2_unref(FuStructTpmEventLog2 *st)
809
0
{
810
0
    g_return_if_fail(st != NULL);
811
0
    if (st->refcount == 0) {
812
0
        g_critical("FuStructTpmEventLog2 refcount already zero");
813
0
        return;
814
0
    }
815
0
    if (--st->refcount > 0)
816
0
        return;
817
0
    if (st->buf != NULL)
818
0
        g_byte_array_unref(st->buf);
819
0
    g_free(st);
820
0
}
821
/**
822
 * fu_struct_tpm_event_log2_new_internal: (skip):
823
 **/
824
static FuStructTpmEventLog2 *
825
fu_struct_tpm_event_log2_new_internal(void)
826
0
{
827
0
    FuStructTpmEventLog2 *st = g_new0(FuStructTpmEventLog2, 1);
828
0
    st->refcount = 1;
829
0
    return st;
830
0
}
831
832
/* getters */
833
/**
834
 * fu_struct_tpm_event_log2_get_pcr: (skip):
835
 **/
836
guint32
837
fu_struct_tpm_event_log2_get_pcr(const FuStructTpmEventLog2 *st)
838
0
{
839
0
    g_return_val_if_fail(st != NULL, 0x0);
840
0
    return fu_memread_uint32(st->buf->data + 0, G_LITTLE_ENDIAN);
841
0
}
842
/**
843
 * fu_struct_tpm_event_log2_get_type: (skip):
844
 **/
845
FuTpmEventlogItemKind
846
fu_struct_tpm_event_log2_get_type(const FuStructTpmEventLog2 *st)
847
0
{
848
0
    g_return_val_if_fail(st != NULL, 0x0);
849
0
    return fu_memread_uint32(st->buf->data + 4, G_LITTLE_ENDIAN);
850
0
}
851
/**
852
 * fu_struct_tpm_event_log2_get_digest_count: (skip):
853
 **/
854
guint32
855
fu_struct_tpm_event_log2_get_digest_count(const FuStructTpmEventLog2 *st)
856
0
{
857
0
    g_return_val_if_fail(st != NULL, 0x0);
858
0
    return fu_memread_uint32(st->buf->data + 8, G_LITTLE_ENDIAN);
859
0
}
860
861
/* setters */
862
/**
863
 * fu_struct_tpm_event_log2_set_pcr: (skip):
864
 **/
865
void
866
fu_struct_tpm_event_log2_set_pcr(FuStructTpmEventLog2 *st, guint32 value)
867
0
{
868
0
    g_return_if_fail(st != NULL);
869
0
    fu_memwrite_uint32(st->buf->data + 0, value, G_LITTLE_ENDIAN);
870
0
}
871
/**
872
 * fu_struct_tpm_event_log2_set_type: (skip):
873
 **/
874
void
875
fu_struct_tpm_event_log2_set_type(FuStructTpmEventLog2 *st, FuTpmEventlogItemKind value)
876
0
{
877
0
    g_return_if_fail(st != NULL);
878
0
    fu_memwrite_uint32(st->buf->data + 4, value, G_LITTLE_ENDIAN);
879
0
}
880
/**
881
 * fu_struct_tpm_event_log2_set_digest_count: (skip):
882
 **/
883
void
884
fu_struct_tpm_event_log2_set_digest_count(FuStructTpmEventLog2 *st, guint32 value)
885
0
{
886
0
    g_return_if_fail(st != NULL);
887
0
    fu_memwrite_uint32(st->buf->data + 8, value, G_LITTLE_ENDIAN);
888
0
}
889
/**
890
 * fu_struct_tpm_event_log2_new: (skip):
891
 **/
892
FuStructTpmEventLog2 *
893
fu_struct_tpm_event_log2_new(void)
894
0
{
895
0
    FuStructTpmEventLog2 *st = fu_struct_tpm_event_log2_new_internal();
896
0
    st->buf = g_byte_array_sized_new(12);
897
0
    fu_byte_array_set_size(st->buf, 12, 0x0);
898
0
    return st;
899
0
}
900
/**
901
 * fu_struct_tpm_event_log2_to_string: (skip):
902
 **/
903
static gchar *
904
fu_struct_tpm_event_log2_to_string(const FuStructTpmEventLog2 *st)
905
0
{
906
0
    g_autoptr(GString) str = g_string_new("FuStructTpmEventLog2:\n");
907
0
    g_return_val_if_fail(st != NULL, NULL);
908
0
    g_string_append_printf(str, "  pcr: 0x%x\n",
909
0
                           (guint) fu_struct_tpm_event_log2_get_pcr(st));
910
0
    {
911
0
        const gchar *tmp = fu_tpm_eventlog_item_kind_to_string(fu_struct_tpm_event_log2_get_type(st));
912
0
        if (tmp != NULL) {
913
0
            g_string_append_printf(str, "  type: 0x%x [%s]\n", (guint) fu_struct_tpm_event_log2_get_type(st), tmp);
914
0
        } else {
915
0
            g_string_append_printf(str, "  type: 0x%x\n", (guint) fu_struct_tpm_event_log2_get_type(st));
916
0
        }
917
0
    }
918
0
    g_string_append_printf(str, "  digest_count: 0x%x\n",
919
0
                           (guint) fu_struct_tpm_event_log2_get_digest_count(st));
920
0
    if (str->len > 0)
921
0
        g_string_set_size(str, str->len - 1);
922
0
    return g_string_free(g_steal_pointer(&str), FALSE);
923
0
}
924
static gboolean
925
fu_struct_tpm_event_log2_parse_internal(FuStructTpmEventLog2 *st, GError **error)
926
0
{
927
0
    if (g_log_get_debug_enabled()) {
928
0
        g_autofree gchar *str = fu_struct_tpm_event_log2_to_string(st);
929
0
        g_debug("%s", str);
930
0
    }
931
0
    return TRUE;
932
0
}
933
/**
934
 * fu_struct_tpm_event_log2_parse_stream: (skip):
935
 **/
936
FuStructTpmEventLog2 *
937
fu_struct_tpm_event_log2_parse_stream(GInputStream *stream, gsize offset, GError **error)
938
0
{
939
0
    g_autoptr(FuStructTpmEventLog2) st = fu_struct_tpm_event_log2_new_internal();
940
0
    st->buf = fu_input_stream_read_byte_array(stream, offset, 12, NULL, error);
941
0
    if (st->buf == NULL) {
942
0
        g_prefix_error(error, "FuStructTpmEventLog2 failed read of 0x%x: ", (guint) 12);
943
0
        return NULL;
944
0
    }
945
0
    if (st->buf->len != 12) {
946
0
        g_set_error(error,
947
0
                    FWUPD_ERROR,
948
0
                    FWUPD_ERROR_INVALID_DATA,
949
0
                    "FuStructTpmEventLog2 requested 0x%x and got 0x%x",
950
0
                    (guint) 12,
951
0
                    (guint) st->buf->len);
952
0
        return NULL;
953
0
    }
954
0
    if (!fu_struct_tpm_event_log2_parse_internal(st, error))
955
0
        return NULL;
956
0
    return g_steal_pointer(&st);
957
0
}