Help - how to store a certificate in the NV under the platform hierarchy?
arlotito at microsoft.com
Hi,
the use case is related to idevid onboarding identity, an immutable identity created by the platform manufacturer and stored as follows:
-key under the Endorsement Hierarchy
-certificate under the Platform Hierarchy
I managed to create the key under the EK hierarchy and store it in the NV, but how to store the certificate under the PH? I have a idevid.der with a size=898.
If I do:tpm2_nvdefine 0x01C90000 -C p -s 898 -a "ownerread|ownerwrite"
this is what i get:
WARNING:esys:src/tss2-esys/api/Esys_NV_DefineSpace.c:344:Esys_NV_DefineSpace_Finish() Received TPM Error ERROR:esys:src/tss2-esys/api/Esys_NV_DefineSpace.c:122:Esys_NV_DefineSpace() Esys Finish ErrorCode (0x000009a2)
ERROR: Failed to define NV area at index 0x1C90000
ERROR: Esys_NV_DefineSpace(0x9A2) - tpm:session(1):authorization failure without DA implications
ERROR: Failed to create NV index 0x1c90000.
ERROR: Unable to run tpm2_nvdefine
I understood that the PH comes with an empty password and a policy that cannot be satisfied.
I read somewhere that I should:
-obtain a random number via tpm2_getrandom
-install the random number as platformAuth via tpm2_hierarchychangeauth authorized using "empty buffer" as platformAuth
...but how to do that and how to eventually store the cert in the NV?
I'm using tpm2 tss / tools on a linux box with a simulated TPM.
I know that all what I stated above could be wrong or inaccurate... but i'm moving my first steps with TPM and I hope you can help.
Thanks!
Arturo.
Fuchs
The TPM resets the PH password to the empty password on every boot, correct. But the BIOS is supposed to set the PH password to a random value directly after boot. Reason being that the OS/UserSpace shall not be able to interfere with it. So you need to do this operation within the BIOS context.
---
Andreas Fuchs
Head of Department Cyberphysical System Security Head of Group Trustworthy Platforms
Fraunhofer Institute for Secure Information Technology SIT National Research Center for Applied Cybersecurity ATHENE Rheinstr. 75 | 64295 Darmstadt | Germany
T +49 6151 869 228 | F +49 6151 869 224
https://www.sit.fraunhofer.de | https://www.athene-center.de
________________________________________
Von: arlotito(a)microsoft.com <arlotito(a)microsoft.com>
Gesendet: Donnerstag, 17. Februar 2022 10:19
An: tpm2(a)lists.01.org
Betreff: [tpm2] Help - how to store a certificate in the NV under the platform hierarchy?
Hi,
the use case is related to idevid onboarding identity, an immutable identity created by the platform manufacturer and stored as follows:
-key under the Endorsement Hierarchy
-certificate under the Platform Hierarchy
I managed to create the key under the EK hierarchy and store it in the NV, but how to store the certificate under the PH? I have a idevid.der with a size=898.
If I do:tpm2_nvdefine 0x01C90000 -C p -s 898 -a "ownerread|ownerwrite"
this is what i get:
WARNING:esys:src/tss2-esys/api/Esys_NV_DefineSpace.c:344:Esys_NV_DefineSpace_Finish() Received TPM Error ERROR:esys:src/tss2-esys/api/Esys_NV_DefineSpace.c:122:Esys_NV_DefineSpace() Esys Finish ErrorCode (0x000009a2)
ERROR: Failed to define NV area at index 0x1C90000
ERROR: Esys_NV_DefineSpace(0x9A2) - tpm:session(1):authorization failure without DA implications
ERROR: Failed to create NV index 0x1c90000.
ERROR: Unable to run tpm2_nvdefine
I understood that the PH comes with an empty password and a policy that cannot be satisfied.
I read somewhere that I should:
-obtain a random number via tpm2_getrandom
-install the random number as platformAuth via tpm2_hierarchychangeauth authorized using "empty buffer" as platformAuth
...but how to do that and how to eventually store the cert in the NV?
I'm using tpm2 tss / tools on a linux box with a simulated TPM.
I know that all what I stated above could be wrong or inaccurate... but i'm moving my first steps with TPM and I hope you can help.
Thanks!
Arturo.
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
arlotito at microsoft.com
Got it, thanks!
Is there a way/tool to simulate what the OEM would do from the BIOS context to eventually store that certificate in the PH? (I'm building a PoC, and I need a TPM provisioned with that certificate in the PH)
Fuchs
If you use a TPM simulator (e.g. swtpm) you can interact with it, as it has an empty PH password on start.
________________________________________
Von: arlotito(a)microsoft.com <arlotito(a)microsoft.com>
Gesendet: Donnerstag, 17. Februar 2022 10:52
An: tpm2(a)lists.01.org
Betreff: [tpm2] Re: Help - how to store a certificate in the NV under the platform hierarchy?
Got it, thanks!
Is there a way/tool to simulate what the OEM would do from the BIOS context to eventually store that certificate in the PH? (I'm building a PoC, and I need a TPM provisioned with that certificate in the PH)
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
arlotito at microsoft.com
I'm using the ibm swtpm... but I get the error anyway and I'm not able to understand what's wrong.
This is what I do:
openssl x509 -outform der -in idevid.crt -out idevid.der DER_SIZE=$(wc -c idevid.der | awk '{ print $1 }') echo $DER_SIZE
tpm2_nvdefine 0x01C90000 -C p -s $DER_SIZE -a "ppread|ppwrite"
...and I get the error I already mentione:
WARNING:esys:src/tss2-esys/api/Esys_NV_DefineSpace.c:344:Esys_NV_DefineSpace_Finish() Received TPM Error ERROR:esys:src/tss2-esys/api/Esys_NV_DefineSpace.c:122:Esys_NV_DefineSpace() Esys Finish ErrorCode (0x000009a2)
ERROR: Failed to define NV area at index 0x1C90000
ERROR: Esys_NV_DefineSpace(0x9A2) - tpm:session(1):authorization failure without DA implications
ERROR: Failed to create NV index 0x1c90000.
ERROR: Unable to run tpm2_nvdefine
Fuchs
I guess you need to add the platformcreate attribute to -a
That would be my last idea I'm afraid...
Next advice would be to gdb into swtpm; set some breakpoints and have a look inside... ;-)
________________________________________
Von: arlotito(a)microsoft.com <arlotito(a)microsoft.com>
Gesendet: Donnerstag, 17. Februar 2022 11:03
An: tpm2(a)lists.01.org
Betreff: [tpm2] Re: Help - how to store a certificate in the NV under the platform hierarchy?
I'm using the ibm swtpm... but I get the error anyway and I'm not able to understand what's wrong.
This is what I do:
openssl x509 -outform der -in idevid.crt -out idevid.der DER_SIZE=$(wc -c idevid.der | awk '{ print $1 }') echo $DER_SIZE
tpm2_nvdefine 0x01C90000 -C p -s $DER_SIZE -a "ppread|ppwrite"
...and I get the error I already mentione:
WARNING:esys:src/tss2-esys/api/Esys_NV_DefineSpace.c:344:Esys_NV_DefineSpace_Finish() Received TPM Error ERROR:esys:src/tss2-esys/api/Esys_NV_DefineSpace.c:122:Esys_NV_DefineSpace() Esys Finish ErrorCode (0x000009a2)
ERROR: Failed to define NV area at index 0x1C90000
ERROR: Esys_NV_DefineSpace(0x9A2) - tpm:session(1):authorization failure without DA implications
ERROR: Failed to create NV index 0x1c90000.
ERROR: Unable to run tpm2_nvdefine
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
arlotito at microsoft.com
I tried:tpm2_nvdefine 0x01C90000 -C p -s $DER_SIZE -a "ppread|ppwrite|platformcreate"
but i get the same error:
WARNING:esys:src/tss2-esys/api/Esys_NV_DefineSpace.c:344:Esys_NV_DefineSpace_Finish() Received TPM Error ERROR:esys:src/tss2-esys/api/Esys_NV_DefineSpace.c:122:Esys_NV_DefineSpace() Esys Finish ErrorCode (0x000009a2)
ERROR: Failed to define NV area at index 0x1C90000
ERROR: Esys_NV_DefineSpace(0x9A2) - tpm:session(1):authorization failure without DA implications
ERROR: Failed to create NV index 0x1c90000.
ERROR: Unable to run tpm2_nvdefine
Thanks anyway for your help and clarifications!
arlotito at microsoft.com
hmm, interesting...
I tried the same command on a RPI4 with a physical TPM (Infineon SLB9670)... and it worked.
tpm2_nvdefine 0x01C90000 -C p -s 898 -a "ppread|ppwrite|platformcreate"
and this is what I get:
nv-index: 0x1c90000
Maybe, as you commented, it could be a specific issue of the ibm swtpm (v1661).
I'll keep on working on both (swtpm and rpi4/slb9670)
Thanks!
Fuchs
Ok, I guess you are using swtpm_bios, right ?
In that case the BIOS behavior is simulated, including setting the PH password.
You want to pass -u to swtpm_bios to keep PH open:
https://github.com/stefanberger/swtpm/blob/master/man/man8/swtpm_bios.pod
________________________________________
Von: arlotito(a)microsoft.com <arlotito(a)microsoft.com>
Gesendet: Donnerstag, 17. Februar 2022 11:21
An: tpm2(a)lists.01.org
Betreff: [tpm2] Re: Help - how to store a certificate in the NV under the platform hierarchy?
hmm, interesting...
I tried the same command on a RPI4 with a physical TPM (Infineon SLB9670)... and it worked.
tpm2_nvdefine 0x01C90000 -C p -s 898 -a "ppread|ppwrite|platformcreate"
and this is what I get:
nv-index: 0x1c90000
Maybe, as you commented, it could be a specific issue of the ibm swtpm (v1661).
I'll keep on working on both (swtpm and rpi4/slb9670)
Thanks!
_______________________________________________
tpm2 mailing list -- tpm2(a)lists.01.org
To unsubscribe send an email to tpm2-leave(a)lists.01.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s