From patchwork Mon Sep 9 12:19:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Bottomley X-Patchwork-Id: 11137811 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DCE3A1599 for ; Mon, 9 Sep 2019 12:20:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ABCCD218AF for ; Mon, 9 Sep 2019 12:20:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b="DGc9HNQd"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b="mawsk6pG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731066AbfIIMUE (ORCPT ); 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> X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@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;