I've been asked to implement what amounts to a license-dongle using TPM for an x86_64 appliance which has a TPM chip. Essentially what is desired is to ensure that software released for the appliance can only run on the appliance itself such that if the software is migrated to a virtual machine or different hardware that it would refuse to function.
I don't expect the solution to be reverse-engineering resistant, but rather a typical 'dongle' type solution where it will impede normal users and keep enterprise customers honest.
I have successfully built and included the TPM modules, as well as TrouSerS, and the openssl-tpm-engine code - I can successfully take ownership of the TPM but beyond that the available documentation doesn't quite cover this use-case - or if it does I've so far been unable to find a plain english solution.
I'd prefer if possible to rely on the secret nature of the private keys stored in the TPM rather than utilizing the platform components hashes (a hard-drive may die, CPU may be replaced, etc.. I'd rather err on the side of the customer such that the system doesn't become unusable after a routine hardware upgrade.
As well, ideally I suspect that this solution could be designed such that in manufacturing the public keys of each appliance are collected and added to a signing keychain so that the software could be signed against a single key that each appliance could have stored in the TPM, rather than requiring that the software be signed multiple times? I could be mistaken here but there has to be some bulk method of satisfying the platform authentication method otherwise it would seem very difficult to scale.
If the appliance is setup by you, you can follow this scheme:
A. Before shipping:
B. Preparing the application:
C. When starting the application:
Note 1: From a theoretical point of view this solution is insecure since the binary can be patched. You know that, so this should work.
Note 2: If the appliance is not setup by yourself, you can't trust the public key a customer might give you.
Edit 1: explain certain points more precisely
@A.2: Since I use jtt & jTSS instead of TrouSerS I don't know whether there is a command line tool included in the TrouSerS package to create keys. But I know for sure that it provides the proper API to do so. Anyway, jtt for example has a command
create_key
which does this. When you use this tool you'll have the problem that the key store of jTSS and TrouSerS is AFAIK not compatible.@A.3: No, there are no keys stored inside the TPM besides the Storage Root Key (SRk) and the Endorsement Key (EK). But the TPM guarantees that no private part of the keys belonging to the TPM will ever be outside the TPM in an unencrypted format. So you have a key-store which is somehow managed by a Trusted Software Stack (TSS -> jTSS, TrouSerS) that contains the encrypted key material. The TSS is also responsible for loading the proper keys in the TPM before using them for example for a signing operation.
@C*: The cryptographic part on the application side is quite standard. I don't know how your knowledge in that field is. For the TPM part again the TSSs provide high-level APIs. I don't know whether there are existing command line tools for signing with the TPM.