From: Quan Xu Subject: [PATCH 11/12] vTPM/TPM2: Bind group keys and sectors data on disk Date: Sun, 14 Dec 2014 07:09:58 -0500 Message-ID: <1418558998-13755-1-git-send-email-quan.xu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: samuel.thibault@ens-lyon.org, dgdegra@tycho.nsa.gov, Quan Xu , stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org Signed-off-by: Quan Xu --- stubdom/vtpmmgr/disk_write.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/stubdom/vtpmmgr/disk_write.c b/stubdom/vtpmmgr/disk_write.c index 4c825c5..73018ef 100644 --- a/stubdom/vtpmmgr/disk_write.c +++ b/stubdom/vtpmmgr/disk_write.c @@ -83,12 +83,18 @@ static void generate_group_seals(struct mem_group *src, const struct mem_tpm_mgr if (src->nr_seals > NR_SEALS_PER_GROUP) abort(); - for(i=0; i < src->nr_seals; i++) { + for (i=0; i < src->nr_seals; i++) { struct disk_seal_entry *dst = &src->seal_bits.entry[i]; - dst->pcr_selection = src->seals[i].pcr_selection; - memcpy(&dst->digest_release, &src->seals[i].digest_release, 20); - TPM_pcr_digest(&dst->digest_at_seal, dst->pcr_selection); - TPM_disk_seal(dst, &sblob, sizeof(sblob)); + + /*TPM 2.0 bind | TPM 1.x seal*/ + if (hw_is_tpm2()) { + TPM2_disk_bind(dst, &sblob, sizeof(sblob)); + } else { + dst->pcr_selection = src->seals[i].pcr_selection; + memcpy(&dst->digest_release, &src->seals[i].digest_release, 20); + TPM_pcr_digest(&dst->digest_at_seal, dst->pcr_selection); + TPM_disk_seal(dst, &sblob, sizeof(sblob)); + } } src->seal_bits.nr_cfgs = native_be32(src->nr_seals); @@ -246,11 +252,16 @@ static void disk_write_seal_list(struct mem_tpm_mgr *mgr, struct mem_group *grou for(i=0; i < group->nr_seals; i++) { struct mem_seal *src = &group->seals[i]; struct disk_seal_entry *dst = &seal->entry[i]; - dst->pcr_selection = src->pcr_selection; - memcpy(&dst->digest_release, &src->digest_release, 20); - TPM_pcr_digest(&dst->digest_at_seal, dst->pcr_selection); - TPM_disk_seal(dst, &sblob, sizeof(sblob)); + /*TPM 2.0 bind / TPM 1.x seal*/ + if (hw_is_tpm2()) { + TPM2_disk_bind(dst, &sblob, sizeof(sblob)); + } else { + dst->pcr_selection = src->pcr_selection; + memcpy(&dst->digest_release, &src->digest_release, 20); + TPM_pcr_digest(&dst->digest_at_seal, dst->pcr_selection); + TPM_disk_seal(dst, &sblob, sizeof(sblob)); + } } memcpy(seal->hdr.magic, TPM_MGR_MAGIC, 12); -- 1.8.3.2