> > > On 10/09/2016 11:58 AM, Winkler, Tomas wrote: > >> Like TPM 1.2, the current device driver for TPM 2.0 supports > >> extending only to the SHA1 PCR bank. But the TPM 2.0 supports > >> multiple PCR banks and the specification recommends extending to all > >> active PCR banks, this patch enhances the existing device driver > >> support for TPM 2.0 extend function and its in-kernel interface to extend > >> to > all active PCR banks. > >> > >> The existing in-kernel interface expects only a SHA1 digest. > >> Hence, to extend all active PCR banks with differing digest sizes for > >> TPM 2.0, the SHA1 digest is padded with trailing 0's as needed. > >> > >> Signed-off-by: Nayna Jain <na...@linux.vnet.ibm.com> > >> --- > >> drivers/char/tpm/tpm-interface.c | 17 ++++++++-- > >> drivers/char/tpm/tpm2-cmd.c | 71 ++++++++++++++++++++++++++------- > ----- > >> -- > >> drivers/char/tpm/tpm2.h | 18 ++++++++++ > >> 3 files changed, 79 insertions(+), 27 deletions(-) > >> > >> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm- > >> interface.c index 7743e8a..5dd5005 100644 > >> --- a/drivers/char/tpm/tpm-interface.c > >> +++ b/drivers/char/tpm/tpm-interface.c > >> @@ -7,6 +7,7 @@ > >> * Dave Safford <saff...@watson.ibm.com> > >> * Reiner Sailer <sai...@watson.ibm.com> > >> * Kylene Hall <kjh...@us.ibm.com> > >> + * Nayna Jain <na...@linux.vnet.ibm.com> > >> * > >> * Maintained by: <tpmdd-devel@lists.sourceforge.net> > >> * > >> @@ -32,6 +33,7 @@ > >> #include <linux/pm_runtime.h> > >> > >> #include "tpm.h" > >> +#include "tpm2.h" > >> #include "tpm_eventlog.h" > >> > >> #define TPM_MAX_ORDINAL 243 > >> @@ -752,7 +754,7 @@ static const struct tpm_input_header > >> pcrextend_header = { int tpm_pcr_extend(u32 chip_num, int pcr_idx, > >> const u8 > >> *hash) { > >> struct tpm_cmd_t cmd; > >> - int rc; > >> + int i, rc; > >> struct tpm_chip *chip; > >> > >> chip = tpm_chip_find_get(chip_num); @@ -760,7 +762,18 @@ int > >> tpm_pcr_extend(u32 chip_num, int pcr_idx, const > >> u8 *hash) > >> return -ENODEV; > >> > >> if (chip->flags & TPM_CHIP_FLAG_TPM2) { > >> - rc = tpm2_pcr_extend(chip, pcr_idx, hash); > >> + struct tpml_digest_values d_values; > >> + > >> + memset(&d_values, 0, sizeof(d_values)); > >> + > >> + for (i = 0; i < chip->no_of_active_banks; i++) { > >> + d_values.digests[i].alg_id = > >> + chip->active_banks[i]; > >> + memcpy(d_values.digests[i].digest, hash, > >> + TPM_DIGEST_SIZE); > >> + d_values.count++; > >> + } > > > > This is tpm2 only feature so I suggest to create a function inside > > tpm2-chip.c > instead of open coding it here. > > This will probably also prevent all this code movement. > > Thanks Tomas for reviewing, will look at this. > And I think you meant inside tpm2-cmd.c ?
Right. Tomas ------------------------------------------------------------------------------ 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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tpmdd-devel