__calc_tpm2_event_size(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __calc_tpm2_event_size β€” the Kernel API Manual, bestie edition

okay so this is a page straight out of the Kernel API Manual (man section 9, iykyk) and it's about one very specific little function: __calc_tpm2_event_size. she's niche, she's precise, she's literally just here to do math on your TPM2 event log. slay.


✨ NAME ✨

__calc_tpm2_event_size β€” calculate the size of a TPM2 event log entry πŸŽ€


🌸 SYNOPSIS 🌸

u32 __calc_tpm2_event_size (struct tcg_pcr_event2_head *event , struct
       tcg_pcr_event *event_header , bool do_mapping );

like, three arguments, one u32 coming back at you. that's the whole vibe.


πŸ¦‹ ARGUMENTS πŸ¦‹

  • event β€” Pointer to the event whose size should be calculated. yes bestie, this is the one we're measuring πŸ’…
  • event_header β€” Pointer to the initial event containing the digest lengths. she's the one holding the receipts (the digest length info) so the math actually works πŸ‘‘
  • do_mapping β€” Whether or not the event needs to be mapped. bool, so like… yes or no, no in-between ✨

πŸ’– DESCRIPTION πŸ’–

okay so here's the situation. the TPM2 event log format can contain multiple digests corresponding to separate PCR banks, and it also contains a variable length of the data that was measured. the way it's giving "surprise, the length is different every time" 😭

this means you need knowledge of how long each digest type is β€” and that info lives inside the first event in the log. she's the main character, she knows everything 🫢

so how do we get the length? we examine the number of events, and then look at each event in turn to determine how much space is used for events in total. once we've done all that, we know the offset of the data length field, and then we can calculate the total size of the event. it's giving detective work, ngl πŸ”₯


🌈 RETURN 🌈

  • size of the event on success πŸ’œ
  • 0 on failure πŸ’€

⭐ SEE ALSO ⭐

  • Kernel file ./include/linux/tpm_eventlog.h β€” go read it, i'm obsessed πŸ™ˆ

and that's the whole page, bestie! ✨ source/version vibes: ./include/linux, dated October 2026 β€” mwah, no cap, that's a wrap πŸ’…πŸŽ€πŸ’–

πŸ“¦ where this page comes from