Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1968538imu; Tue, 6 Nov 2018 07:08:29 -0800 (PST) X-Google-Smtp-Source: AJdET5eWuet/Pk7mMqfl0h7TF3mYzl32FoZaVpezXzYjGJ7CAtTgKBOuBGeSkqfUel8O86uo/kkx X-Received: by 2002:a65:6295:: with SMTP id f21-v6mr24231363pgv.167.1541516909230; Tue, 06 Nov 2018 07:08:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541516909; cv=none; d=google.com; s=arc-20160816; b=aHUdXE/AxhW8rjgHKh74Vgda/UYU4GUXcZBOrp31qBEQ0bKSzXdKFsm7yG9k1WJ5lP STdEpslh9tZ+0reG8v8NDr9VSXvAWyYH4DnSL6JKyTQNJgyyfBiellDRsCeKUopKPIoL qNFxkHifzEPW1dJmnpl5wk8/9RZjgebWuY1cZacemsqsPykW8AKzBofJbdRfepoSD9kp 8/CazHC/Z4x6xI+jGdNbftPBq29SZNGRWAw62qXKQib+ZnNoB6f8TVP4ymmKth7gUFOX jcanSQEewA08YMXxL6zB4pyZ3eDggDT20Vl6lLWGR7u4rtlpnjk6Sm4Ec4fDdeUCv+dF cKMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=wQmXJvmYY4B5VTIk1QrSn9CVthezgZX8KdYM0lz6X5Q=; b=iY9IN57pGaTTH5yySGPcRDnUfDUkTz8MJ4eZ0Uc51XdaqROvXBbQ8niU80tGF7KX0O s8mo1I4JiUM8IpB6rcvF+V5P5zcDs0Yb55zJ8tOgeqB9e7N0HdsNvytLXP9p6Mbbwnvu SiA9kXQ2b3tViyPr5dRMMEpjL8ojZa7t2qBwo0/mU0Sm7ldEOKSM0qfataiqkthJycM+ tbWBuTMq9Cc52DuXklpBsucq9NN2i5kz6CW6LtcrPhy6hdLZqv0pU1+YV3x0A5fUrM6E wRnirAJuycNv2sr098FKdbWIfeY9sP5A7ssor4zHWIXisZ9u46AHI6fKk3PaGIUJyc6I ix2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si12176902plt.225.2018.11.06.07.07.59; Tue, 06 Nov 2018 07:08:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388336AbeKGAby (ORCPT + 99 others); Tue, 6 Nov 2018 19:31:54 -0500 Received: from lhrrgout.huawei.com ([185.176.76.210]:32717 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387593AbeKGAby (ORCPT ); Tue, 6 Nov 2018 19:31:54 -0500 Received: from LHREML712-CAH.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id 001AB12F4791E; Tue, 6 Nov 2018 15:06:12 +0000 (GMT) Received: from roberto-HP-EliteDesk-800-G2-DM-65W.huawei.com (10.204.65.153) by smtpsuk.huawei.com (10.201.108.35) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 6 Nov 2018 15:06:04 +0000 From: Roberto Sassu To: , CC: , , , , Roberto Sassu Subject: [PATCH v4 3/6] tpm: rename and export tpm2_digest and tpm2_algorithms Date: Tue, 6 Nov 2018 16:01:56 +0100 Message-ID: <20181106150159.1136-4-roberto.sassu@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181106150159.1136-1-roberto.sassu@huawei.com> References: <20181106150159.1136-1-roberto.sassu@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.204.65.153] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rename tpm2_* to tpm_* and move the definitions to include/linux/tpm.h so that these can be used by other kernel subsystems (e.g. IMA). Signed-off-by: Roberto Sassu Reviewed-by: Jarkko Sakkinen Acked-by: Mimi Zohar --- drivers/char/tpm/tpm-interface.c | 2 +- drivers/char/tpm/tpm.h | 13 +------------ drivers/char/tpm/tpm2-cmd.c | 18 +++++++++--------- include/linux/tpm.h | 18 ++++++++++++++++++ include/linux/tpm_eventlog.h | 9 ++------- 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index ba7ca6b3e664..07b62734598c 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -1039,7 +1039,7 @@ static int tpm1_pcr_extend(struct tpm_chip *chip, int pcr_idx, const u8 *hash, int tpm_pcr_extend(struct tpm_chip *chip, int pcr_idx, const u8 *hash) { int rc; - struct tpm2_digest *digest_list; + struct tpm_digest *digest_list; int i; chip = tpm_find_get_ops(chip); diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 98368c3a6ff7..fc2cc16e5080 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -122,17 +122,6 @@ enum tpm2_return_codes { TPM2_RC_RETRY = 0x0922, }; -enum tpm2_algorithms { - TPM2_ALG_ERROR = 0x0000, - TPM2_ALG_SHA1 = 0x0004, - TPM2_ALG_KEYEDHASH = 0x0008, - TPM2_ALG_SHA256 = 0x000B, - TPM2_ALG_SHA384 = 0x000C, - TPM2_ALG_SHA512 = 0x000D, - TPM2_ALG_NULL = 0x0010, - TPM2_ALG_SM3_256 = 0x0012, -}; - enum tpm2_command_codes { TPM2_CC_FIRST = 0x011F, TPM2_CC_CREATE_PRIMARY = 0x0131, @@ -578,7 +567,7 @@ static inline u32 tpm2_rc_value(u32 rc) int tpm2_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf); int tpm2_pcr_extend(struct tpm_chip *chip, int pcr_idx, u32 count, - struct tpm2_digest *digests); + struct tpm_digest *digests); int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max); void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle, unsigned int flags); diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index 533089cede07..584dba6cdf3e 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -33,11 +33,11 @@ struct tpm2_hash { }; static struct tpm2_hash tpm2_hash_map[] = { - {HASH_ALGO_SHA1, TPM2_ALG_SHA1}, - {HASH_ALGO_SHA256, TPM2_ALG_SHA256}, - {HASH_ALGO_SHA384, TPM2_ALG_SHA384}, - {HASH_ALGO_SHA512, TPM2_ALG_SHA512}, - {HASH_ALGO_SM3_256, TPM2_ALG_SM3_256}, + {HASH_ALGO_SHA1, TPM_ALG_SHA1}, + {HASH_ALGO_SHA256, TPM_ALG_SHA256}, + {HASH_ALGO_SHA384, TPM_ALG_SHA384}, + {HASH_ALGO_SHA512, TPM_ALG_SHA512}, + {HASH_ALGO_SM3_256, TPM_ALG_SM3_256}, }; /* @@ -200,7 +200,7 @@ int tpm2_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf) pcr_select[pcr_idx >> 3] = 1 << (pcr_idx & 0x7); tpm_buf_append_u32(&buf, 1); - tpm_buf_append_u16(&buf, TPM2_ALG_SHA1); + tpm_buf_append_u16(&buf, TPM_ALG_SHA1); tpm_buf_append_u8(&buf, TPM2_PCR_SELECT_MIN); tpm_buf_append(&buf, (const unsigned char *)pcr_select, sizeof(pcr_select)); @@ -234,7 +234,7 @@ struct tpm2_null_auth_area { * Return: Same as with tpm_transmit_cmd. */ int tpm2_pcr_extend(struct tpm_chip *chip, int pcr_idx, u32 count, - struct tpm2_digest *digests) + struct tpm_digest *digests) { struct tpm_buf buf; struct tpm2_null_auth_area auth_area; @@ -457,7 +457,7 @@ int tpm2_seal_trusted(struct tpm_chip *chip, /* public */ tpm_buf_append_u16(&buf, 14 + options->policydigest_len); - tpm_buf_append_u16(&buf, TPM2_ALG_KEYEDHASH); + tpm_buf_append_u16(&buf, TPM_ALG_KEYEDHASH); tpm_buf_append_u16(&buf, hash); /* policy */ @@ -472,7 +472,7 @@ int tpm2_seal_trusted(struct tpm_chip *chip, } /* public parameters */ - tpm_buf_append_u16(&buf, TPM2_ALG_NULL); + tpm_buf_append_u16(&buf, TPM_ALG_NULL); tpm_buf_append_u16(&buf, 0); /* outside info */ diff --git a/include/linux/tpm.h b/include/linux/tpm.h index 4609b94142d4..71d7bbf5f690 100644 --- a/include/linux/tpm.h +++ b/include/linux/tpm.h @@ -22,12 +22,30 @@ #ifndef __LINUX_TPM_H__ #define __LINUX_TPM_H__ +#include + #define TPM_DIGEST_SIZE 20 /* Max TPM v1.2 PCR size */ struct tpm_chip; struct trusted_key_payload; struct trusted_key_options; +enum tpm_algorithms { + TPM_ALG_ERROR = 0x0000, + TPM_ALG_SHA1 = 0x0004, + TPM_ALG_KEYEDHASH = 0x0008, + TPM_ALG_SHA256 = 0x000B, + TPM_ALG_SHA384 = 0x000C, + TPM_ALG_SHA512 = 0x000D, + TPM_ALG_NULL = 0x0010, + TPM_ALG_SM3_256 = 0x0012, +}; + +struct tpm_digest { + u16 alg_id; + u8 digest[SHA512_DIGEST_SIZE]; +} __packed; + enum TPM_OPS_FLAGS { TPM_OPS_AUTO_STARTUP = BIT(0), }; diff --git a/include/linux/tpm_eventlog.h b/include/linux/tpm_eventlog.h index 3d5d162f09cc..c9f28b4be4ae 100644 --- a/include/linux/tpm_eventlog.h +++ b/include/linux/tpm_eventlog.h @@ -3,7 +3,7 @@ #ifndef __LINUX_TPM_EVENTLOG_H__ #define __LINUX_TPM_EVENTLOG_H__ -#include +#include #define TCG_EVENT_NAME_LEN_MAX 255 #define MAX_TEXT_EVENT 1000 /* Max event string length */ @@ -107,16 +107,11 @@ struct tcg_event_field { u8 event[0]; } __packed; -struct tpm2_digest { - u16 alg_id; - u8 digest[SHA512_DIGEST_SIZE]; -} __packed; - struct tcg_pcr_event2 { u32 pcr_idx; u32 event_type; u32 count; - struct tpm2_digest digests[0]; + struct tpm_digest digests[0]; struct tcg_event_field event; } __packed; -- 2.17.1