From nobody Fri Mar 29 05:26:44 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org ARC-Seal: i=1; a=rsa-sha256; t=1585569878; cv=none; d=zohomail.com; s=zohoarc; b=CjuPBSlHR/zj9S7ecNAXEaAvY83KoLngP7SKJ1HjkdQtZglJg8vb/VMA9qIIZcWHIZ0vv7rIHy4sg114g95J8CjL2ISck6ivIqz+IU9R+o7vkEN/J2yBZsEBfreAY43mIl3av/JWpVOuCAWzNrH6aCXePP7+Ysny67mcVH5l3YY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585569878; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=ILse3pQB04FYNMEWWkhVR4g57+V/5zbx7u6ZzBoIdBQ=; b=CL166zwxrl1WkhITVF8LvLeY9kSYAwIW4YA8pm6PHBTz0FNIyujQbci6I5OSvVd0qXP3/jF2BdTsN8QdMxXY/1uNPQTLwanXb+orvQrwKPQ9SjnbF09wI6AI3bXMdVHBsuY07Lfyb4a16A/NrrHXePjbZ+fPtmf0/5UWY7OXiWc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1585569878104690.6312714673319; Mon, 30 Mar 2020 05:04:38 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 8E6B3B01A89; Mon, 30 Mar 2020 12:04:33 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id ECFCAB01A88 for ; Mon, 30 Mar 2020 12:04:19 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02UBWda2066184; Mon, 30 Mar 2020 07:56:04 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0a-001b2d01.pphosted.com with ESMTP id 3021vtgqye-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Mar 2020 07:56:04 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 02UBZ32Z073611; Mon, 30 Mar 2020 07:56:03 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0a-001b2d01.pphosted.com with ESMTP id 3021vtgqy2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Mar 2020 07:56:03 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by ppma04dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 02UBtB0K010052; Mon, 30 Mar 2020 11:56:02 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by ppma04dal.us.ibm.com with ESMTP id 301x764fd9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Mar 2020 11:56:02 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02UBu1wW28180864 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Mar 2020 11:56:01 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id 826266A04D; Mon, 30 Mar 2020 11:56:01 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id 08F326A04F; Mon, 30 Mar 2020 11:56:00 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 30 Mar 2020 11:56:00 +0000 (GMT) From: Stefan Berger To: seabios@seabios.org, kevin@koconnor.net Date: Mon, 30 Mar 2020 07:55:55 -0400 Message-Id: <20200330115557.865734-2-stefanb@linux.vnet.ibm.com> In-Reply-To: <20200330115557.865734-1-stefanb@linux.vnet.ibm.com> References: <20200330115557.865734-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-30_01:2020-03-27,2020-03-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003300106 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id 02UBWda2066184 Message-ID-Hash: DKOXO4AAABAXEIF5J7ZYJFK3AJ6HVIDD X-Message-ID-Hash: DKOXO4AAABAXEIF5J7ZYJFK3AJ6HVIDD X-MailFrom: stefanb@linux.vnet.ibm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Stefan Berger X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v2 1/3] tcgbios: Only write logs for PCRs that are in active PCR banks List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ++++ X-Spam-Level: **** Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org Only write the logs for those PCRs that are in active PCR banks. A PCR banks is assumed to be active if any of the BIOS relevant PCRs 0 - 7 is enabled, thus pcrSelect[0] !=3D 0. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau --- src/tcgbios.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/tcgbios.c b/src/tcgbios.c index 95c1e94..cc3a51f 100644 --- a/src/tcgbios.c +++ b/src/tcgbios.c @@ -265,7 +265,7 @@ tpm20_write_EfiSpecIdEventStruct(void) struct tpms_pcr_selection *sel =3D tpm20_pcr_selection->selections; void *nsel, *end =3D (void*)tpm20_pcr_selection + tpm20_pcr_selection_= size; =20 - u32 count; + u32 count, numAlgs =3D 0; for (count =3D 0; count < be32_to_cpu(tpm20_pcr_selection->count); cou= nt++) { u8 sizeOfSelect =3D sel->sizeOfSelect; =20 @@ -273,6 +273,11 @@ tpm20_write_EfiSpecIdEventStruct(void) if (nsel > end) break; =20 + if (!sizeOfSelect || sel->pcrSelect[0] =3D=3D 0) { + sel =3D nsel; + continue; + } + int hsize =3D tpm20_get_hash_buffersize(be16_to_cpu(sel->hashAlg)); if (hsize < 0) { dprintf(DEBUG_tcg, "TPM is using an unsupported hash: %d\n", @@ -287,8 +292,9 @@ tpm20_write_EfiSpecIdEventStruct(void) return -1; } =20 - event.hdr.digestSizes[count].algorithmId =3D be16_to_cpu(sel->hash= Alg); - event.hdr.digestSizes[count].digestSize =3D hsize; + event.hdr.digestSizes[numAlgs].algorithmId =3D be16_to_cpu(sel->ha= shAlg); + event.hdr.digestSizes[numAlgs].digestSize =3D hsize; + numAlgs++; =20 sel =3D nsel; } @@ -298,9 +304,9 @@ tpm20_write_EfiSpecIdEventStruct(void) return -1; } =20 - event.hdr.numberOfAlgorithms =3D count; + event.hdr.numberOfAlgorithms =3D numAlgs; int event_size =3D offsetof(struct TCG_EfiSpecIdEventStruct - , digestSizes[count]); + , digestSizes[numAlgs]); u32 *vendorInfoSize =3D (void*)&event + event_size; *vendorInfoSize =3D 0; event_size +=3D sizeof(*vendorInfoSize); @@ -336,7 +342,7 @@ tpm20_build_digest(struct tpm_log_entry *le, const u8 *= sha1, int bigEndian) void *nsel, *end =3D (void*)tpm20_pcr_selection + tpm20_pcr_selection_= size; void *dest =3D le->hdr.digest + sizeof(struct tpm2_digest_values); =20 - u32 count; + u32 count, numAlgs =3D 0; for (count =3D 0; count < be32_to_cpu(tpm20_pcr_selection->count); cou= nt++) { u8 sizeOfSelect =3D sel->sizeOfSelect; =20 @@ -344,6 +350,12 @@ tpm20_build_digest(struct tpm_log_entry *le, const u8 = *sha1, int bigEndian) if (nsel > end) break; =20 + /* PCR 0-7 unused? -- skip */ + if (!sizeOfSelect || sel->pcrSelect[0] =3D=3D 0) { + sel =3D nsel; + continue; + } + int hsize =3D tpm20_get_hash_buffersize(be16_to_cpu(sel->hashAlg)); if (hsize < 0) { dprintf(DEBUG_tcg, "TPM is using an unsupported hash: %d\n", @@ -368,6 +380,8 @@ tpm20_build_digest(struct tpm_log_entry *le, const u8 *= sha1, int bigEndian) =20 dest +=3D sizeof(*v) + hsize; sel =3D nsel; + + numAlgs++; } =20 if (sel !=3D end) { @@ -377,9 +391,9 @@ tpm20_build_digest(struct tpm_log_entry *le, const u8 *= sha1, int bigEndian) =20 struct tpm2_digest_values *v =3D (void*)le->hdr.digest; if (bigEndian) - v->count =3D cpu_to_be32(count); + v->count =3D cpu_to_be32(numAlgs); else - v->count =3D count; + v->count =3D numAlgs; =20 return dest - (void*)le->hdr.digest; } --=20 2.24.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Fri Mar 29 05:26:44 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org ARC-Seal: i=1; a=rsa-sha256; t=1585573209; cv=none; d=zohomail.com; s=zohoarc; b=Mina/B3FW5U+bgvW+nsWZVJiDKjG+bXeHfejidsaJBXvZKY9kDkRsi8agugsTTUSK7oCAVo2QJMFArercKLx4HRArqZnp74YK48y+fO5718Oxm7dzs7qrfs77NjhwmD70UKg0ojY51wmzfbwrQewWv571DMnJKxNORywUExvDA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585573209; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=SLP2rErgXgQDC+fMHFdOvZ+dxVAq6XGVkVY7bTOlMo8=; b=glAfEci/2DJhiiV86LyWMFQBzje3ClBfOXvrjX8sRMow0/Q16oK/xw8pbzrJbt2gelpbdKQUHF551GPSkvZkVQMKwhJlAR5ls/IQQjS9RCHMiOp3THvYW0ieg2Os2Fgtg2R7XYjyo6wdhn5Htg7QYAaAT3p+I7Ugb2L2XDStYu4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1585573209853195.6123339115975; Mon, 30 Mar 2020 06:00:09 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 8D6B5B01A8A; Mon, 30 Mar 2020 13:00:05 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 68A91B00003 for ; Mon, 30 Mar 2020 12:59:52 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02UBX21T118946; Mon, 30 Mar 2020 07:56:04 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0b-001b2d01.pphosted.com with ESMTP id 3022qg060p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Mar 2020 07:56:04 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 02UBX5EK119246; Mon, 30 Mar 2020 07:56:04 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0b-001b2d01.pphosted.com with ESMTP id 3022qg060b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Mar 2020 07:56:04 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by ppma04dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 02UBtAFW010047; Mon, 30 Mar 2020 11:56:03 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by ppma04dal.us.ibm.com with ESMTP id 301x764fdd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Mar 2020 11:56:03 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02UBu2jN45154728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Mar 2020 11:56:02 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id 470C86A05A; Mon, 30 Mar 2020 11:56:02 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id B92696A047; Mon, 30 Mar 2020 11:56:01 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 30 Mar 2020 11:56:01 +0000 (GMT) From: Stefan Berger To: seabios@seabios.org, kevin@koconnor.net Date: Mon, 30 Mar 2020 07:55:56 -0400 Message-Id: <20200330115557.865734-3-stefanb@linux.vnet.ibm.com> In-Reply-To: <20200330115557.865734-1-stefanb@linux.vnet.ibm.com> References: <20200330115557.865734-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-30_01:2020-03-27,2020-03-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 adultscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003300110 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0b-001b2d01.pphosted.com id 02UBX21T118946 Message-ID-Hash: UUJK2IEF7CU6N5O3HRP33CLLMRATC6PN X-Message-ID-Hash: UUJK2IEF7CU6N5O3HRP33CLLMRATC6PN X-MailFrom: stefanb@linux.vnet.ibm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Stefan Berger X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v2 2/3] tcgbios: Fix the vendorInfoSize to be of type u8 List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / The vendorInfoSize is a u8 rather than a u32. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau --- src/tcgbios.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tcgbios.c b/src/tcgbios.c index cc3a51f..6a3a613 100644 --- a/src/tcgbios.c +++ b/src/tcgbios.c @@ -287,7 +287,7 @@ tpm20_write_EfiSpecIdEventStruct(void) =20 int event_size =3D offsetof(struct TCG_EfiSpecIdEventStruct , digestSizes[count+1]); - if (event_size > sizeof(event) - sizeof(u32)) { + if (event_size > sizeof(event) - sizeof(u8)) { dprintf(DEBUG_tcg, "EfiSpecIdEventStruct pad too small\n"); return -1; } @@ -307,7 +307,7 @@ tpm20_write_EfiSpecIdEventStruct(void) event.hdr.numberOfAlgorithms =3D numAlgs; int event_size =3D offsetof(struct TCG_EfiSpecIdEventStruct , digestSizes[numAlgs]); - u32 *vendorInfoSize =3D (void*)&event + event_size; + u8 *vendorInfoSize =3D (void*)&event + event_size; *vendorInfoSize =3D 0; event_size +=3D sizeof(*vendorInfoSize); =20 --=20 2.24.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org From nobody Fri Mar 29 05:26:44 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org ARC-Seal: i=1; a=rsa-sha256; t=1585569831; cv=none; d=zohomail.com; s=zohoarc; b=FhwJX2odpbU5aeCBVmpvoRWyjGqNNsfPtYmGOsDvFL+eE34c3wUVHzD8gKLjgVTqJ33cEUfIl3xLjK9gWPYfGWfHn1zFGixue1fh2e4XIZ0L9uZ7OJMcleZ/Y686GaNLyFYAMEhGPenuVi485E5/X4tI2HJ8BPyxU1QY4KAs4Ic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585569831; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=VHc7WWnNEsKRSjmDtVRb/XIoMD4ULQH+eLCnpdX95rI=; b=HjNHb2NIkUbll5huQUYvsldKxp9RX6N1XLudCxweoM2CGi4lS4wdMzgbrjbgIp1thDSg67TqWF7UMUeVBlW+SJjLmebj9aGzsTvqEqwct41HvTTjkrZjHOF3ShBhjWRNxkME5YjuikERWsWe/MVWEQsbY1Ci8lHsOj51RGMcoiw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1585569831399554.8265485375488; Mon, 30 Mar 2020 05:03:51 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 1122FB01A88; Mon, 30 Mar 2020 12:03:47 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 5F34BB01A29 for ; Mon, 30 Mar 2020 12:03:28 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02UBYCII011266; Mon, 30 Mar 2020 07:56:05 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0a-001b2d01.pphosted.com with ESMTP id 3022f288ar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Mar 2020 07:56:05 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 02UBZ2FT014479; Mon, 30 Mar 2020 07:56:05 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0a-001b2d01.pphosted.com with ESMTP id 3022f288ae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Mar 2020 07:56:05 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by ppma01dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 02UBtAgN028912; Mon, 30 Mar 2020 11:56:04 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by ppma01dal.us.ibm.com with ESMTP id 301x76vemr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Mar 2020 11:56:04 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02UBu2rL49217840 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Mar 2020 11:56:03 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id E0CCA6A05A; Mon, 30 Mar 2020 11:56:02 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id 677806A051; Mon, 30 Mar 2020 11:56:02 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 30 Mar 2020 11:56:02 +0000 (GMT) From: Stefan Berger To: seabios@seabios.org, kevin@koconnor.net Date: Mon, 30 Mar 2020 07:55:57 -0400 Message-Id: <20200330115557.865734-4-stefanb@linux.vnet.ibm.com> In-Reply-To: <20200330115557.865734-1-stefanb@linux.vnet.ibm.com> References: <20200330115557.865734-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-30_01:2020-03-27,2020-03-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003300106 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id 02UBYCII011266 Message-ID-Hash: NBOI7CQZN2P35ZOGAVV7W6G3JHIFNEZX X-Message-ID-Hash: NBOI7CQZN2P35ZOGAVV7W6G3JHIFNEZX X-MailFrom: stefanb@linux.vnet.ibm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Stefan Berger X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v2 3/3] tcgbios: Add support for SHA3 type of algorithms List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ++++ X-Spam-Level: **** Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org Add support for SHA3 type of algorithms that a TPM2 may support some time in the future. Signed-off-by: Stefan Berger Reviewed-by: Marc-Andr=C3=A9 Lureau --- src/std/tcg.h | 9 +++++++++ src/tcgbios.c | 22 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/std/tcg.h b/src/std/tcg.h index 1c9eeb4..98cca49 100644 --- a/src/std/tcg.h +++ b/src/std/tcg.h @@ -8,6 +8,9 @@ #define SHA384_BUFSIZE 48 #define SHA512_BUFSIZE 64 #define SM3_256_BUFSIZE 32 +#define SHA3_256_BUFSIZE 32 +#define SHA3_384_BUFSIZE 48 +#define SHA3_512_BUFSIZE 64 =20 =20 /**************************************************************** @@ -335,12 +338,18 @@ struct tpm_res_sha1complete { #define TPM2_ALG_SHA384 0x000c #define TPM2_ALG_SHA512 0x000d #define TPM2_ALG_SM3_256 0x0012 +#define TPM2_ALG_SHA3_256 0x0027 +#define TPM2_ALG_SHA3_384 0x0028 +#define TPM2_ALG_SHA3_512 0x0029 =20 #define TPM2_ALG_SHA1_FLAG (1 << 0) #define TPM2_ALG_SHA256_FLAG (1 << 1) #define TPM2_ALG_SHA384_FLAG (1 << 2) #define TPM2_ALG_SHA512_FLAG (1 << 3) #define TPM2_ALG_SM3_256_FLAG (1 << 4) +#define TPM2_ALG_SHA3_256_FLAG (1 << 5) +#define TPM2_ALG_SHA3_384_FLAG (1 << 6) +#define TPM2_ALG_SHA3_512_FLAG (1 << 7) =20 /* TPM 2 command tags */ #define TPM2_ST_NO_SESSIONS 0x8001 diff --git a/src/tcgbios.c b/src/tcgbios.c index 6a3a613..82894f5 100644 --- a/src/tcgbios.c +++ b/src/tcgbios.c @@ -156,9 +156,10 @@ static struct tpml_pcr_selection *tpm20_pcr_selection; struct tpm_log_entry { struct tpm_log_header hdr; u8 pad[sizeof(struct tpm2_digest_values) - + 5 * sizeof(struct tpm2_digest_value) + + 8 * sizeof(struct tpm2_digest_value) + SHA1_BUFSIZE + SHA256_BUFSIZE + SHA384_BUFSIZE - + SHA512_BUFSIZE + SM3_256_BUFSIZE]; + + SHA512_BUFSIZE + SM3_256_BUFSIZE + SHA3_256_BUFSIZE + + SHA3_384_BUFSIZE + SHA3_512_BUFSIZE]; } PACKED; =20 static const struct hash_parameters { @@ -192,6 +193,21 @@ static const struct hash_parameters { .hashalg_flag =3D TPM2_ALG_SM3_256_FLAG, .hash_buffersize =3D SM3_256_BUFSIZE, .name =3D "SM3-256", + }, { + .hashalg =3D TPM2_ALG_SHA3_256, + .hashalg_flag =3D TPM2_ALG_SHA3_256_FLAG, + .hash_buffersize =3D SHA3_256_BUFSIZE, + .name =3D "SHA3-256", + }, { + .hashalg =3D TPM2_ALG_SHA3_384, + .hashalg_flag =3D TPM2_ALG_SHA3_384_FLAG, + .hash_buffersize =3D SHA3_384_BUFSIZE, + .name =3D "SHA3-384", + }, { + .hashalg =3D TPM2_ALG_SHA3_512, + .hashalg_flag =3D TPM2_ALG_SHA3_512_FLAG, + .hash_buffersize =3D SHA3_512_BUFSIZE, + .name =3D "SHA3-512", } }; =20 @@ -252,7 +268,7 @@ tpm20_write_EfiSpecIdEventStruct(void) =20 struct { struct TCG_EfiSpecIdEventStruct hdr; - u8 pad[256]; + u8 pad[sizeof(struct tpm_log_entry) + sizeof(u8)]; } event =3D { .hdr.signature =3D "Spec ID Event03", .hdr.platformClass =3D TPM_TCPA_ACPI_CLASS_CLIENT, --=20 2.24.1 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org