Discussion:
[TrouSerS-users] HMAC calculation clarification for TPM 1.2
David Van Arnem
2016-04-25 23:47:24 UTC
Permalink
Hi all,

I've been trying to recalculate some HMACs for authenticated commands
using bytes-on-the-wire printed by TrouSerS debug mode during a
tpm_sealdata command from tpm-tools. I've been having trouble getting
the correct values out of my HMAC calculations, and I'm hoping I can get
some clarification on the construction of the HMAC equation.

According to page 21 of the TPM 1.2 Spec, Part 1 - Design Principles,
HMAC calculation for use with a TPM 1.2 should follow RFC 2104, where

HMAC = H(K XOR opad, H(K XOR ipad, text))

where

H - SHA1
K - key or AuthData
ipad - B bytes of 0x36, where B is the block length, 64
opad - B bytes of 0x5C

On page 75 of the same spec, an example using a TPM_OSAP authenticated
session is given. In the table, it states that

sharedSecret = HMAC(key.usageAuth, nonceEvenOSAP, nonceOddOSAP)

Does this mean that, using the RFC 2104 calculation method,

K = key.usageAuth and
text = nonceEvenOSAP || nonceOddOSAP (concatenated)

which would create the final HMAC equation of:

sharedSecret = SHA1(key.usageAuth XOR opad,
SHA1(key.usageAuth XOR ipad, nonceEvenOSAP || nonceOddOSAP))

Is that correct?

And also:

[key.usageAuth XOR opad] would be 64 bytes (XOR'd opad length)?

[key.usageAuth XOR ipad, nonceEvenOSAP || nonceOddOSAP] would be 104
bytes (64 bytes for XOR'd ipad, 20 bytes for nonceEvenOSAP, 20 bytes for
nonceOddOSAP)?

Thanks in advance for any insights on this.
--
Thanks,
David
Ken Goldman
2016-05-03 11:57:27 UTC
Permalink
Probably the easiest way to debug this is with the SW TPM. It dumps a
trace of the calculation, and you can see where you diverge.
Alternatively, you can step through the code in a debugger and compare
the implementation to yours.
David Van Arnem
2016-05-03 17:27:22 UTC
Permalink
Post by Ken Goldman
Probably the easiest way to debug this is with the SW TPM. It dumps a
trace of the calculation, and you can see where you diverge.
Alternatively, you can step through the code in a debugger and compare
the implementation to yours.
Hi Ken,

Thanks for the suggestion! I will look into it.

David
Post by Ken Goldman
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
TrouSerS-users mailing list
https://lists.sourceforge.net/lists/listinfo/trousers-users
--
Thanks,
David
Loading...