Skip to contentSkip to conversation

Stablishing trust on to TPM simulator

tpm2 Eduardo Falcão <eduardolfalcao at gmail.com> 2 participants 4 messages May 20, 2020 – May 23, 2020

lore
Share & tools
lore

Eduardo Falcão <eduardolfalcao at gmail.com>

#0 lore raw

Hello, everyone :)

I am creating a demo where I attest the state of a machine (VM) using a simulated TPM. I think I've done properly the core operations of my demonstration, but I'm still wondering how would I stablish trust with TPM in this simulated scenario.

I think that in a real setup, with a real TPM, there may be a service that validates the TPM Ek certificate. Is there something similar I could do in simulation mode, or I would have to mock this action (in simulation environment)?

Also, in case I have a real TPM, how would I use this service (for instance, with a TPM from Intel)? Where would I check the parameters of this API?

--------
More info on my setup:
The TPM I am using is simulated. Thus, my setup involves installing the SWTPM (https://github.com/stefanberger/swtpm.git and https://github.com/stefanberger/libtpms.git), QEMU (https://github.com/qemu/qemu), and EDK2 (https://github.com/tianocore/edk2.git).
When configuring my simulator, I run it with --createek, --create-ek-cert, and --create-platform-cert flag, as follows:

sudo swtpm_setup --tpmstate ${VTPM_DIR_PATH} --createek --create-ek-cert --create-platform-cert --allow-signing --tpm2

Through Qemu, I am able to start a VM with TPM2 features, and then I install TSS (https://github.com/tpm2-software/tpm2-tss), ABRMD (https://github.com/tpm2-software/tpm2-abrmd), and TPM2_TOOLS (https://github.com/tpm2-software/tpm2-tools). This setup allows me to try out TPM in simulation mode.

Steps of attestation:
1. (VM to be attested) getting the public portion of my endorsement key
2. (VM to be attested) creating an attestation key (AK)
3. (VM to be attested) quoting given PCRs with freshly created AK (outputing the quote, pcrs, and signature)
4. (Attestator VM) run python program that checks quote signatue, and checks if value of PCR digest from quote matches an expected value

Missing step:
1. (Attestator VM) check if vendor root certificates validate the EK certificate
--------

Best regards

#2 lore raw
In reply to Eduardo Falcão <eduardolfalcao at gmail.com>
Quoted 4 lines

Missing step:
1. (Attestator VM) check if vendor root certificates validate the EK certificate
--------

So as Imran points out keylime.dev has a system that does all of this. To verify a certificate on the server, it would be some form of openssl verify command. I don't recall if tpm2_createek will output stable keys between ibmtpm server invocations where the NVChip file is removed, so be wary of that. NVChip is where the ibmtpm simulator stores its persistent data, like the endorsement hiearchy seed. If that seed is randomized, removing that will get you a new key. The NVChip file is always in the CWD of the ibmtpm process. For an actual TPM, it depends, TL;DR is that recent versions of tpm2_getekcertificate will fetch it for you (offhand I cannot recall the version, but its at least 4.0 for ecc keys). Certificates are stored in NV Indexes defined by the TCG, and some Intel platforms have it available via a web URL. The simulator does none of these steps, so you would have to mock it by creating your own EK Cert and storing it to the tpm NV index. You can then use openssl verify command to make sure that its a good certificate.

#3 lore raw

Hi Desai and Roberts.

Thank you for yours responses.

Yes, Desai, I already knew the Keylime project. And, indeed, I got the feeling that they were doing what I wanted. But in a first moment, I want to do the demo by myself, so I can better understand the concepts and steps involved to create the chain of trust. Perhaps I'll consider using Keylime when I'll be comfortable with the whole process.

Roberts, the path you pointed was really correct. Thank you.

I created an issue on the swtpm project and Stefan extended a wiki about certificate creation.
For those interested, it is here: https://github.com/stefanberger/swtpm/wiki/Certificiates-created-by-swtpm_setup#verifying-your-ek-cert-against-the-ca

Regards