I'm working with a Trusted Platform Module (TPM) and need to generate a Signing Key (SK) that can be proven to reside within the same TPM as the Attestation Identity Key (AIK). My goal is to enable a server, which does not have a TPM, to verify that the SK originated from my TPM using OpenSSL. Here's what I have accomplished so far:
sudo tpm2_createek -c ek.ctx -G rsa -u ek.pub -P 123
sudo tpm2_createak -C ek.ctx -c ak.ctx -G rsa -g sha256 -s rsassa -u ak.pub -n ak.name -P 123
sudo tpm2_load -C ek.ctx -u ak.pub -r ak.priv -n ak.name -c ak.ctx
sudo tpm2_createprimary -C o -c primary.ctx -G rsa -P 123
sudo tpm2_create -C primary.ctx -G rsa -u sk.pub -r sk.priv -a "fixedtpm|fixedparent|sensitivedataorigin|userwithauth"
sudo tpm2_load -C primary.ctx -u sk.pub -r sk.priv -n sk.name -c sk.ctx
sudo tpm2_certify -C ak.ctx -c sk.ctx -g sha256 -o certify.signature -f plain
After generating the signature, I attempted to verify it using OpenSSL with the following command:
openssl dgst -sha256 -verify ak.pub -signature certify.signature sk.pub
Verification Failure
The certify.signature file is a binary file and I suspect it contains more than just the signature (likely it includes TPM structures). How can I extract just the raw signature from this binary file in a format that OpenSSL can verify?
Any help on how to correctly verify the TPM-generated signature using OpenSSL would be greatly appreciated.
I currently cannot reproduce your problem, but the following should help. Essentially
tpm2_readpublic
can give you a PEM-formatted key, which seems to be what you need, here.From the tpm2-tools integration tests: