From: Eric Biggers <ebiggers@kernel.org>
To: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: Peter Huewe <peterhuewe@gmx.de>,
Jarkko Sakkinen <jarkko@kernel.org>,
linux-integrity@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 1/2] tpm: Compare HMAC values in constant time
Date: Fri, 1 Aug 2025 13:14:55 -0700 [thread overview]
Message-ID: <20250801201455.GA5141@sol> (raw)
In-Reply-To: <605314b70efde2e31f9e6a34a6bb0ea0060e0c67.camel@HansenPartnership.com>
On Fri, Aug 01, 2025 at 03:20:52PM -0400, James Bottomley wrote:
> On Fri, 2025-08-01 at 12:03 -0700, Eric Biggers wrote:
> > On Fri, Aug 01, 2025 at 02:53:09PM -0400, James Bottomley wrote:
> > > On Fri, 2025-08-01 at 11:40 -0700, Eric Biggers wrote:
> > > > On Fri, Aug 01, 2025 at 02:03:47PM -0400, James Bottomley wrote:
> > > > > On Fri, 2025-08-01 at 10:11 -0700, Eric Biggers wrote:
> > > [...]
> > > > > > It's true that such attacks don't work with one-time keys.
> > > > > > But here it's not necessarily a one-time key. E.g.,
> > > > > > tpm2_get_random() sets a key, then authenticates multiple
> > > > > > messages using that key.
> > > > >
> > > > > The nonces come one from us and one from the TPM. I think ours
> > > > > doesn't change if the session is continued although it could,
> > > > > whereas the TPM one does, so the HMAC key is different for
> > > > > every communication of a continued session.
> > > >
> > > > Again, tpm2_get_random() sets a HMAC key once and then uses it
> > > > multiple times.
> > >
> > > No it doesn't. If you actually read the code, you'd find it does
> > > what I say above. Specifically tpm_buf_fill_hmac_session() which
> > > is called inside that loop recalculates the hmac key from the
> > > nonces. This recalculated key is what is used in
> > > tpm_buf_check_hmac_response(), and which is where the new tpm nonce
> > > is collected for the next
> > > iteration.
> >
> > tpm_buf_fill_hmac_session() computes a HMAC value, but it doesn't
> > modify the HMAC key. tpm2_parse_start_auth_session() is the only
> > place where the HMAC key is changed. You may be confusing HMAC
> > values with keys.
>
> Is this simply a semantic quibble about what gets called a key? For
> each TPM command we compute a cphash across all the command parameters
> (and for each return a rphash). This hash then forms a
> hmac(session_key, cphash | our_nonce | tpm_nonce | attrs). The point
> being that although session_key is fixed across the session, the
> our_nonce and tpm_nonce can change with every iteration. Since the
> cphash is over the ciphertext, it's the only bit you get to vary with a
> chosen ciphertext attack, so the other parameters effectively key the
> hmac.
No, it's not "simply a semantic quibble". You're just wrong.
As I said earlier, our_nonce (which is not a key) does appear to make
MAC timing attacks not possible. All the other fields appear to be
attacker-controlled, contrary to what you're claiming above.
Anyway, point taken: I'll drop the Fixes and Cc stable from the commit,
and include my own analysis of why MAC timing attacks don't appear to be
possible with this protocol. Everything else in this thread has just
been a pointless distraction.
- Eric
next prev parent reply other threads:[~2025-08-01 20:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-31 21:52 [PATCH 0/2] tpm: HMAC fix and cleanup Eric Biggers
2025-07-31 21:52 ` [PATCH 1/2] tpm: Compare HMAC values in constant time Eric Biggers
2025-08-01 2:28 ` James Bottomley
2025-08-01 3:02 ` Eric Biggers
2025-08-01 11:36 ` James Bottomley
2025-08-01 17:11 ` Eric Biggers
2025-08-01 18:03 ` James Bottomley
2025-08-01 18:40 ` Eric Biggers
2025-08-01 18:53 ` James Bottomley
2025-08-01 19:03 ` Eric Biggers
2025-08-01 19:20 ` James Bottomley
2025-08-01 20:14 ` Eric Biggers [this message]
2025-07-31 21:52 ` [PATCH 2/2] tpm: Use HMAC-SHA256 library instead of open-coded HMAC Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250801201455.GA5141@sol \
--to=ebiggers@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=jarkko@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).