Skip to content

Commit

Permalink
tpm: add the null key name as a sysfs export
Browse files Browse the repository at this point in the history
This is the last component of encrypted tpm2 session handling that
allows us to verify from userspace that the key derived from the NULL
seed genuinely belongs to the TPM and has not been spoofed.

The procedure for doing this involves creating an attestation identity
key (which requires verification of the TPM EK certificate) and then
using that AIK to sign a certification of the Elliptic Curve key over
the NULL seed.  Userspace must create this EC Key using the parameters
prescribed in TCG TPM v2.0 Provisioning Guidance for the SRK ECC; if
this is done correctly the names will match and the TPM can then run a
TPM2_Certify operation on this derived primary key using the newly
created AIK.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
  • Loading branch information
James Bottomley authored and intel-lab-lkp committed Feb 16, 2023
1 parent 863dcbf commit 4c35ecc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/char/tpm/tpm-sysfs.c
Expand Up @@ -309,6 +309,21 @@ static ssize_t tpm_version_major_show(struct device *dev,
}
static DEVICE_ATTR_RO(tpm_version_major);

#ifdef CONFIG_TPM_BUS_SECURITY
static ssize_t null_name_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct tpm_chip *chip = to_tpm_chip(dev);
int size = TPM2_NAME_SIZE;

bin2hex(buf, chip->tpmkeyname, size);
size *= 2;
buf[size++] = '\n';
return size;
}
static DEVICE_ATTR_RO(null_name);
#endif

static struct attribute *tpm1_dev_attrs[] = {
&dev_attr_pubek.attr,
&dev_attr_pcrs.attr,
Expand All @@ -326,6 +341,9 @@ static struct attribute *tpm1_dev_attrs[] = {

static struct attribute *tpm2_dev_attrs[] = {
&dev_attr_tpm_version_major.attr,
#if CONFIG_TPM_BUS_SECURITY
&dev_attr_null_name.attr,
#endif
NULL
};

Expand Down

0 comments on commit 4c35ecc

Please sign in to comment.