From: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Roberto Sassu <roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: linux-ima-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH 3/4] tpm: introduce tpm_pcr_algorithms()
Date: Wed, 5 Apr 2017 15:13:31 +0300 [thread overview]
Message-ID: <20170405121331.w5njxsf3nrztvlzb@intel.com> (raw)
In-Reply-To: <20170329102452.32212-4-roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
On Wed, Mar 29, 2017 at 12:24:51PM +0200, Roberto Sassu wrote:
> Return the algorithms supported by the TPM. The limit
> (TPM_ACTIVE_BANKS_MAX) has been exported to include/linux/tpm.h.
>
> Signed-off-by: Roberto Sassu <roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Why is this needed?
/Jarkko
> ---
> drivers/char/tpm/tpm-interface.c | 39 +++++++++++++++++++++++++++++++++++++++
> drivers/char/tpm/tpm.h | 2 +-
> include/linux/tpm.h | 8 ++++++++
> 3 files changed, 48 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index 0b6cb87..44e7c99 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -876,6 +876,45 @@ int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash)
> EXPORT_SYMBOL_GPL(tpm_pcr_extend);
>
> /**
> + * tpm_pcr_algorithms - get TPM IDs of active PCR banks algorithms
> + * @chip_num: tpm idx # or ANY
> + * @algorithms: array of TPM IDs
> + * @algo_num: size of array
> + *
> + * Returns < 0 on error, and the number of active PCR banks on success.
> + */
> +int tpm_pcr_algorithms(u32 chip_num, u32 count,
> + enum tpm2_algorithms *algorithms)
> +{
> + struct tpm_chip *chip;
> + int rc = -ENODEV;
> + int i;
> +
> + chip = tpm_chip_find_get(chip_num);
> + if (chip == NULL)
> + return rc;
> +
> + if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
> + goto out;
> +
> + for (i = 0; i < ARRAY_SIZE(chip->active_banks) &&
> + chip->active_banks[i] != TPM2_ALG_ERROR; i++) {
> + if (i >= count) {
> + rc = -EINVAL;
> + goto out;
> + }
> +
> + algorithms[i] = chip->active_banks[i];
> + }
> +
> + rc = i;
> +out:
> + tpm_put_ops(chip);
> + return rc;
> +}
> +EXPORT_SYMBOL_GPL(tpm_pcr_algorithms);
> +
> +/**
> * tpm_do_selftest - have the TPM continue its selftest and wait until it
> * can receive further commands
> * @chip: TPM chip to use
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index e20f3ae..f15279b 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -183,7 +183,7 @@ struct tpm_chip {
> const struct attribute_group *groups[3];
> unsigned int groups_cnt;
>
> - u16 active_banks[7];
> + u16 active_banks[TPM_ACTIVE_BANKS_MAX];
> #ifdef CONFIG_ACPI
> acpi_handle acpi_dev_handle;
> char ppi_version[TPM_PPI_VERSION_LEN + 1];
> diff --git a/include/linux/tpm.h b/include/linux/tpm.h
> index 14b4a42..6552e43 100644
> --- a/include/linux/tpm.h
> +++ b/include/linux/tpm.h
> @@ -23,6 +23,7 @@
> #define __LINUX_TPM_H__
>
> #define TPM_DIGEST_SIZE 20 /* Max TPM v1.2 PCR size */
> +#define TPM_ACTIVE_BANKS_MAX 7 /* Max num of active banks for TPM 2.0 */
>
> /*
> * Chip num is this value or a valid tpm idx
> @@ -69,6 +70,8 @@ extern enum tpm2_algorithms tpm2_pcr_algo_from_crypto(enum hash_algo crypto_id);
> extern int tpm_is_tpm2(u32 chip_num);
> extern int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf);
> extern int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash);
> +extern int tpm_pcr_algorithms(u32 chip_num, u32 count,
> + enum tpm2_algorithms *algorithms);
> extern int tpm_send(u32 chip_num, void *cmd, size_t buflen);
> extern int tpm_get_random(u32 chip_num, u8 *data, size_t max);
> extern int tpm_seal_trusted(u32 chip_num,
> @@ -97,6 +100,11 @@ static inline int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf) {
> static inline int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash) {
> return -ENODEV;
> }
> +static inline int tpm_pcr_algorithms(u32 chip_num, u32 count,
> + enum tpm2_algorithms *algorithms)
> +{
> + return -ENODEV;
> +}
> static inline int tpm_send(u32 chip_num, void *cmd, size_t buflen) {
> return -ENODEV;
> }
> --
> 2.9.3
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> tpmdd-devel mailing list
> tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/tpmdd-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
next prev parent reply other threads:[~2017-04-05 12:13 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-29 10:24 [PATCH 0/4] Extend TPM 2.0 PCR banks each with corresponding digest Roberto Sassu
[not found] ` <20170329102452.32212-1-roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-03-29 10:24 ` [PATCH 1/4] tpm: check whether all digests have been provided for TPM 2.0 extend Roberto Sassu
[not found] ` <20170329102452.32212-2-roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-05 12:12 ` Jarkko Sakkinen
[not found] ` <20170405121200.rjbojlwchfw43ted-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-05 12:25 ` Roberto Sassu
[not found] ` <e0c01100-df24-6632-fed5-dfe355470ac6-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-05 13:38 ` Jarkko Sakkinen
2017-03-29 10:24 ` [PATCH 2/4] tpm: introduce tpm2_pcr_algo_to_crypto() and tpm2_pcr_algo_from_crypto() Roberto Sassu
[not found] ` <20170329102452.32212-3-roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-05 12:12 ` Jarkko Sakkinen
[not found] ` <20170405121256.jyyj474dux5cb62m-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-05 13:03 ` Roberto Sassu
[not found] ` <96aeb2ef-5b0b-7c10-cbf1-7f51aeb902ae-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-05 13:43 ` Jarkko Sakkinen
[not found] ` <20170405134316.bnlaqqo2uz5lncau-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-05 14:24 ` Roberto Sassu
2017-03-29 10:24 ` [PATCH 3/4] tpm: introduce tpm_pcr_algorithms() Roberto Sassu
[not found] ` <20170329102452.32212-4-roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-05 12:13 ` Jarkko Sakkinen [this message]
[not found] ` <20170405121331.w5njxsf3nrztvlzb-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-05 13:33 ` Roberto Sassu
[not found] ` <f422a7e4-e214-b426-3be0-49d1a5560575-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-05 13:54 ` Jarkko Sakkinen
[not found] ` <20170405135418.nagoj6s2oi2m67qb-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-05 13:57 ` Jarkko Sakkinen
2017-03-29 10:24 ` [PATCH 4/4] tpm: introduce tpm_extend_pcr_digests() Roberto Sassu
[not found] ` <20170329102452.32212-5-roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-05 12:14 ` Jarkko Sakkinen
[not found] ` <20170405121416.2rly5pizs2hll56k-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-05 13:50 ` Roberto Sassu
[not found] ` <259b67e8-216b-ad91-52c3-c4b39a8f3d1c-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-05 14:36 ` Roberto Sassu
[not found] ` <88284005-3a53-1b37-e1f2-bfa88987c989-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-07 9:50 ` Roberto Sassu
[not found] ` <e6444fe7-5726-c763-0fd5-93b1c3ec47f6-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-07 19:31 ` Jarkko Sakkinen
[not found] ` <20170407193156.thwubykqqleaszrt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-07 20:10 ` Jarkko Sakkinen
[not found] ` <20170407201037.sarb4mjgfj64hfhr-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-07 20:12 ` Jarkko Sakkinen
2017-04-10 11:51 ` Roberto Sassu
[not found] ` <2f61ea60-6143-3bd4-8b3c-9342625cb326-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-12 20:59 ` Jarkko Sakkinen
2017-04-10 11:46 ` Roberto Sassu
[not found] ` <5be4713f-d34b-f73f-15a4-7a215aeb7ee8-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-12 19:44 ` Jarkko Sakkinen
2017-04-06 7:51 ` Jarkko Sakkinen
2017-03-30 9:16 ` [PATCH 0/4] Extend TPM 2.0 PCR banks each with corresponding digest Nayna
[not found] ` <58DCCCD3.7010300-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2017-03-30 11:07 ` Roberto Sassu
[not found] ` <212fdaf4-f5f3-8615-bb5a-7f21864e33e1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-04-05 9:53 ` Nayna
2017-03-31 8:16 ` Jarkko Sakkinen
2017-04-05 12:16 ` Jarkko Sakkinen
[not found] ` <20170405121617.kpdrtuhb5ipj33ea-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-05 12:24 ` [Linux-ima-devel] " Mimi Zohar
[not found] ` <1491395052.2898.4.camel-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2017-04-05 13:39 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170405121331.w5njxsf3nrztvlzb@intel.com \
--to=jarkko.sakkinen-vuqaysv1563yd54fqh9/ca@public.gmane.org \
--cc=linux-ima-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=roberto.sassu-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).