tpm_buf_check_hmac_response(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… tpm_buf_check_hmac_response(9)

okay so bestie, we're in the Kernel API Manual today and this one is lowkey iconic β€” it's tpm_buf_check_hmac_response, and it does exactly what the name screams: it checks the TPM return HMAC for correctness. no cap. πŸ¦‹


✨ NAME ✨

tpm_buf_check_hmac_response β€” check the TPM return HMAC for correctness


🌸 SYNOPSIS 🌸

int tpm_buf_check_hmac_response (struct tpm_chip *chip , struct tpm_buf
*buf , int rc );

πŸŽ€ ARGUMENTS πŸŽ€

  • chip β€” the TPM chip structure. that's your whole TPM vibe right there πŸ’–
  • buf β€” the original command buffer, which now contains the response. it's giving "same buffer, new era" ✨
  • rc β€” the return code from tpm_transmit_cmd. yes, the lowercase tpm_transmit_cmd, not the function above it, don't get it twisted πŸ™ˆ

🧚 DESCRIPTION 🧚

okay so first case, bestie: if rc is non zero, buf may not contain an actual return. so rc is passed through as the return, and the session gets cleaned up and de-allocated if required. and when is it required? literally when TPM2_SA_CONTINUE_SESSION was not specified as a session flag. noted. πŸ’…

second case, and this is the main character moment: if rc is zero, the response HMAC is computed against the returned buf and matched to the TPM one in the session area. if there's a mismatch, an error is logged and -EINVAL is returned. boom, roasted. πŸ”₯

and the reason for all this? the command issue and HMAC check sequence should look like this:

rc = tpm_transmit_cmd(...); rc = tpm_buf_check_hmac_response(buf, auth,
rc); if (rc) ...

which is easily layered into the current contrl flow. 🫢

ngl that code block is the whole point β€” it's the "check your HMAC before you do anything else" pattern, and it slots right into the flow you already have.

πŸ‘‘ RETURN πŸ‘‘

0 on success or an error. that's it. that's the tea. ⭐


🌈 SEE ALSO 🌈


and that's the whole page, bestie 🩷 this little icon lives in ./drivers/char/tpm, straight from the October 2026 drops β€” go read the source, it's right there, iykyk πŸ’œπŸ§š

πŸ“¦ where this page comes from