From patchwork Mon Apr 29 20:28:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Bottomley X-Patchwork-Id: 13647694 Received: from bedivere.hansenpartnership.com (bedivere.hansenpartnership.com [96.44.175.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5611C160884; Mon, 29 Apr 2024 20:31:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=96.44.175.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714422684; cv=none; b=s6sV8+f3GM9/eQuVfds5Dn43X42U9yOYVhQc/HeB3dpsRmIxsc1jcpQ9AJre6j3L6MXpbjjZrVQz9zU8nligiaohOw51YuCPJdvtxBka70m1MaPD0+ukDE6whd7ofC+xNtav11qA+oHFS7sAWBpxSWSBu0hPkSd/syb+b63JQoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714422684; c=relaxed/simple; bh=JTFrQQ5rppx6jOZ9mbxK6nJZ7H2uf97pjMOLtahQVEU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Fbixt/oUl++WnLKud6ezVcaRqOvA74Hvu0A4M7LUdMb33hVLrDxb64IV8uM4kF1jmLQPdgxGEoxBmY5/fuAZXnX5tul9B8ABAUQObW3FjMNDn9c/jL+u4Hzqq2sSdGvvRQQkz8J8h6vcxWmhLh23VVfQoSwmcTYyiw6/Frg8V+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=HansenPartnership.com; spf=pass smtp.mailfrom=HansenPartnership.com; dkim=pass (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b=X/ZlulUb; arc=none smtp.client-ip=96.44.175.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=HansenPartnership.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=HansenPartnership.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b="X/ZlulUb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1714422682; bh=JTFrQQ5rppx6jOZ9mbxK6nJZ7H2uf97pjMOLtahQVEU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References:From; b=X/ZlulUbr153RYI/WDPJJaD2KmC31eS3vFtp+XwFXL4M99LNs6TVfU6jC2WaK0GP2 zJ+rHa389sKIwAzVKYIDOla/7Vi3QKdi9mivdtPzFEAKq0WsK2aYh1/iyuN7pU2OzU kOXTT7yxsNQCEeo0rSIiciGQHfH6QISR6pXcH8UA= Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id CA2CB1281D87; Mon, 29 Apr 2024 16:31:22 -0400 (EDT) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavis, port 10024) with ESMTP id 4fNjZ6nT83Xe; Mon, 29 Apr 2024 16:31:22 -0400 (EDT) Received: from lingrow.int.hansenpartnership.com (unknown [153.66.160.227]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 389C612819F3; Mon, 29 Apr 2024 16:31:22 -0400 (EDT) From: James Bottomley To: linux-integrity@vger.kernel.org Cc: Jarkko Sakkinen , keyrings@vger.kernel.org, Ard Biesheuvel Subject: [PATCH v8 20/22] tpm: add the null key name as a sysfs export Date: Mon, 29 Apr 2024 16:28:09 -0400 Message-Id: <20240429202811.13643-21-James.Bottomley@HansenPartnership.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240429202811.13643-1-James.Bottomley@HansenPartnership.com> References: <20240429202811.13643-1-James.Bottomley@HansenPartnership.com> Precedence: bulk X-Mailing-List: linux-integrity@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Jarkko Sakkinen --- v6: change config name v7: add review --- drivers/char/tpm/tpm-sysfs.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c index 54c71473aa29..94231f052ea7 100644 --- a/drivers/char/tpm/tpm-sysfs.c +++ b/drivers/char/tpm/tpm-sysfs.c @@ -309,6 +309,21 @@ static ssize_t tpm_version_major_show(struct device *dev, } static DEVICE_ATTR_RO(tpm_version_major); +#ifdef CONFIG_TCG_TPM2_HMAC +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->null_key_name, 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, @@ -326,6 +341,9 @@ static struct attribute *tpm1_dev_attrs[] = { static struct attribute *tpm2_dev_attrs[] = { &dev_attr_tpm_version_major.attr, +#ifdef CONFIG_TCG_TPM2_HMAC + &dev_attr_null_name.attr, +#endif NULL };