stefanberger / swtpm

Libtpms-based TPM emulator with socket, character device, and Linux CUSE interface.
Other
576 stars 143 forks source link

Deep Quote Operation #145

Closed lukehinds closed 4 years ago

lukehinds commented 5 years ago

Placeholder issue for discussions on Deep Quote support in swtpm. I will start adding content shortly.

stefanberger commented 5 years ago

I haven't looked at keylime nor the Xen implementation or the Deep Quote command so far, but here are some 'bullet points' that I think are worth discussing as a basis for Deep Quote design:

Libtpms should be extended with the above commands but only handle the parsing of the commands and the construction of the responses. A callback function registered by swtpm with libtpms would be used to do the actual work for quoting and getting the data for the above commands. With this I would want to avoid having to link libtpms with a TSS client library. A simple signature of this callback could look like this

TPM_RC Callback(enum Command, void *input, void **output);

The enum Command could be something like COMMAND_QUOTE and void *data would be a struct do_quote * with the necessary parameters. Similarly there would then be COMMAND_GET_LOG to retrieve parts of a log and COMMAND_GET_CERT to retrieve the cert at certain file offsets.

swtpm would need a quite extensive configuration file to know how to handle all of this. Maybe a JSON document like this would help:

{
  "host": {
    "securityfs": "/sys/kernel/security",    # so we know where the logs are
  },
  "tpm1.2": {  # in case there's a TPM 1.2 on the host
    "keys": [
        {
           "handle": 0,
           "file": "path_to_key_file",
           "cert": "certificate",
        }
    ]
  },
  "tpm2.0": {  # in case there's TPM 2.0 on the host
    "keys": [
        {
           "handle": 0,
           "file": "path_to_key_file",
           "cert": "certificate",
           "signature": {
             "hash": "sha256",
             "scheme": "RSA-PSS",
           }
        }
    ]
  }
}

There could be more fields of course. Another possibility is to have swtpm load some form of plugin that handles the commands and have the plugin digest this JSON config file . Question is also which TSS 2 client stack to use, but this decision could be pushed into the plugin.

swtpm [...] --deepquote plugin=plugin.so,config=path_to_config[,tpmfd=fd-of-tpmrm0]

Note: swtpm runs with an SELinux or AppArmor profile under libvirt. Due to SELinux labeling, it will not be able to easily access /dev/tpmrm0, so we may need to be able to pass an open file descriptor of this device into swtpm if we were to use the IBM TSS stack. I am not sure what the requirements for the Intel TSS stack would be, maybe an open Unix socket ? All these file descriptors would need to be kept open then...

stefanberger commented 4 years ago

Closing now due to inactivity.