Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5244711ybe; Tue, 10 Sep 2019 00:15:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUxRe5jnJ6iZJyfN2BhTJv8byIzNlQI4lwdWx0It1WGr54YKECkqTi1HIqFDVELZdO+AUC X-Received: by 2002:a17:906:3948:: with SMTP id g8mr1427609eje.102.1568099753300; Tue, 10 Sep 2019 00:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568099753; cv=none; d=google.com; s=arc-20160816; b=MjcJfZ4cDryEuKM1Lsp7bhiYMT/lNHFT691AO8vgntwVWlgvUQ2g+OtCM0c0YjhPaA j6FMBBghzSJIzwNKl8Zph/eWut/Cw7iDlknLS/rAi7bVcnQuTg1oaoQTwxMK2UgGPaRO aVG8zqizy2gSuDXT5mMfUDy+pVXYKHMgLKh8SdKyNS6Z9hes43yEuxZPUXUMG+sAjKB4 P2m1QvIDiFz4/Iuf7eIILbzButWRbHHoIl7JRrXPfjYDz8KFELe/YObBsVaNoQrV67lo tTPKS3tZZmOCY6hdPdKNm9brJ5m/X9TPO/PnjTt13Om1G06t5VaYXBlNoFmwo1v584h8 QMmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:dkim-signature; bh=w2XABrYJ5z9mbEpL7Fspinp2DOqNa8Re8QvLD3w3PCk=; b=c5VA4IznLxgLf3ULDY0pxnTqaHAGc20Sb8q+QT2Q9Ioe4JI7lX6weYbuIPqTVRIWzY 8qpQxzsRU8iVeq69264/3bZAnLCeDJbPhltYguEpseFs0AXbovC0h6Q3IOch2myk1NJs 5p0CF8DjXzKVN5EG38Z+kXZ4quV16sZ1hPtTU6BfiZKc+H9M0TZMTwzRkhNaCC5hz1xf lh7DxZiIKMOHAGK8fizut8eJIBr82fGoXAb9p5hPPLzcYpCD0ECw8ProoGFsrrzkiRle pniXwc23dyOyaGbC7oRkiE51iOGSdVQAuX8iT1vQBeyu6bQzdwIgG5ZaAOr1hKW1fSAq v4KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=DGc9HNQd; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=mawsk6pG; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16si4786154edx.150.2019.09.10.00.15.18; Tue, 10 Sep 2019 00:15:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=DGc9HNQd; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=mawsk6pG; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726362AbfIIMUE (ORCPT + 99 others); Mon, 9 Sep 2019 08:20:04 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:48186 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbfIIMUE (ORCPT ); Mon, 9 Sep 2019 08:20:04 -0400 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id BC2AD8EE180; Mon, 9 Sep 2019 05:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1568031603; bh=KXUW5MwFH4ZhX3qBxy4t/HdQ9LPvfezeJaC2TPCrG5g=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=DGc9HNQdOEw7J0xdNyZCFkcBF477fSBvmclNG3rx/OE8C2oAEoyGWXTZbAt4ezsu0 aWlokB00e4gKASjK9w/R8xVxslXsLKTR3UGABj2A2gbSlJQO3HN6w0eF6+RwrVORHX ugddzGlDWFjj3jZvBbd0gBP/krzOSKUFutez72Fk= Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fKPoujI_lU3O; Mon, 9 Sep 2019 05:20:02 -0700 (PDT) Received: from [192.168.6.117] (unknown [148.69.85.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 9BB3D8EE105; Mon, 9 Sep 2019 05:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1568031602; bh=KXUW5MwFH4ZhX3qBxy4t/HdQ9LPvfezeJaC2TPCrG5g=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=mawsk6pGG7+6kgvUxZcUd+8+dChXZan57HzkJcg4f/wN6NJnfTK0XXz30h/SIpHLh DAO2Hyzs+/RWW7UT55rkGVzciaQlPqPzsoe2vJM5InBpZBlRm26TpZSzLSBCJzfRxI M0KNb4JixFOTnKu1fL/X2FOTz3p3JJK4ATsqmoCE= Message-ID: <1568031599.6613.33.camel@HansenPartnership.com> Subject: [PATCH v6 04/12] tpm2-space: export the context save and load commands From: James Bottomley To: linux-integrity@vger.kernel.org Cc: linux-crypto@vger.kernel.org, linux-security-module@vger.kernel.org, Jarkko Sakkinen Date: Mon, 09 Sep 2019 13:19:59 +0100 In-Reply-To: <1568031408.6613.29.camel@HansenPartnership.com> References: <1568031408.6613.29.camel@HansenPartnership.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The TPM2 session handling code needs to save and restore a single volatile context for the elliptic curve version of the NULL seed, so export the APIs which do this for internal use. Signed-off-by: James Bottomley --- drivers/char/tpm/tpm.h | 4 ++++ drivers/char/tpm/tpm2-space.c | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index d942188debc9..85a7302ddfeb 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -399,6 +399,10 @@ int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u8 *cmd, size_t cmdsiz); int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space, void *buf, size_t *bufsiz); +int tpm2_save_context(struct tpm_chip *chip, u32 handle, u8 *buf, + unsigned int buf_size, unsigned int *offset); +int tpm2_load_context(struct tpm_chip *chip, u8 *buf, + unsigned int *offset, u32 *handle); int tpm_bios_log_setup(struct tpm_chip *chip); void tpm_bios_log_teardown(struct tpm_chip *chip); diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c index 982d341d8837..ca1cb56ccc51 100644 --- a/drivers/char/tpm/tpm2-space.c +++ b/drivers/char/tpm/tpm2-space.c @@ -65,8 +65,8 @@ void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space) kfree(space->session_buf); } -static int tpm2_load_context(struct tpm_chip *chip, u8 *buf, - unsigned int *offset, u32 *handle) +int tpm2_load_context(struct tpm_chip *chip, u8 *buf, + unsigned int *offset, u32 *handle) { struct tpm_buf tbuf; struct tpm2_context *ctx; @@ -116,8 +116,8 @@ static int tpm2_load_context(struct tpm_chip *chip, u8 *buf, return 0; } -static int tpm2_save_context(struct tpm_chip *chip, u32 handle, u8 *buf, - unsigned int buf_size, unsigned int *offset) +int tpm2_save_context(struct tpm_chip *chip, u32 handle, u8 *buf, + unsigned int buf_size, unsigned int *offset) { struct tpm_buf tbuf; unsigned int body_size; -- 2.16.4