From nobody Fri Apr 26 11:11:04 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=1585368131; cv=none; d=zohomail.com; s=zohoarc; b=ECB320V8tlYE9Tu+mOVauISyznXbgsp7QIAOD01m5FAFLbnQIllTh4CGJJB2+6SnPyDAPGK8BN1g/xiOJSMnFNSJnPmkMxeukc0eGC8e7jvtTnLLtDAIctJJfE84GV/L+cxOIlfr4yhH3dA8rNsnlMr+Zpq7F0HXYXAwgCghv74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585368131; 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=dMGKsyxutfI5/SiomyzERrKRIg1KY+hxUbZ8piGyvSw=; b=GntpfuLLqB23DGJEShF4LRe5152BIFh4lLvh+DqznTv9vSKYzeEJuyaqtSEWM4HxVrql7TFOEU9tM1tzLqfb4UWQCY6bXswJ29kSYZxluMZI4riBVPjVRzZmOY205DQg/dNNKPZ9qMnJ0I87VgXqpNpHfV9RzcktXbEoFoIxZwE= 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 1585368131923319.39857312652293; Fri, 27 Mar 2020 21:02:11 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 530EAB01A2F; Sat, 28 Mar 2020 04:02:07 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 0C6B8B00165 for ; Sat, 28 Mar 2020 04:01:49 +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 02S349jj188517; Fri, 27 Mar 2020 23:27:36 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ywdra8db6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Mar 2020 23:27:36 -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 02S3RNdx017528; Sat, 28 Mar 2020 03:27:35 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by ppma01dal.us.ibm.com with ESMTP id 301x768720-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 28 Mar 2020 03:27:35 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02S3RZ3A15532984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 03:27:35 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id E75BCB2064; Sat, 28 Mar 2020 03:27:34 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id D970DB2067; Sat, 28 Mar 2020 03:27:34 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Sat, 28 Mar 2020 03:27:34 +0000 (GMT) From: Stefan Berger To: seabios@seabios.org, kevin@koconnor.net Date: Fri, 27 Mar 2020 23:27:31 -0400 Message-Id: <20200328032733.841258-2-stefanb@linux.vnet.ibm.com> In-Reply-To: <20200328032733.841258-1-stefanb@linux.vnet.ibm.com> References: <20200328032733.841258-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-27_09:2020-03-27,2020-03-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 clxscore=1011 suspectscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003280023 X-Spam-Level: **** Message-ID-Hash: CILM5LTY23D63LYBQIVVQK2NDERB7DU2 X-Message-ID-Hash: CILM5LTY23D63LYBQIVVQK2NDERB7DU2 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 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-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / Content-Type: text/plain; charset="utf-8" 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..997da87 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 (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 (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 Apr 26 11:11:04 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=1585369835; cv=none; d=zohomail.com; s=zohoarc; b=SBTaJdr4YI4Uy4MsmLT4Fc9+HU6pKqyO45QYZqbpxeGJ1zquC6LmCMiIlr1OmmhPYhTCmVxqku4Yqa+QwfVYVpwL2jZscAyzvV03F8rNNZeyN/iVQUHq6oeFeNIlDZPOOa44zw6/R/SqDGdSbTmMMRt5u2hzOrZe4mg7TeCnzV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585369835; 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=1IAmQmI7+H8sCPSMD/UAwK/5DvVhqI84ctKBGQWkNLc=; b=Fb5I7ANoV9Mw8dJ9zEhfw+NB+Nf5DUNFRPZZ5dvEwjmUlKtvQYKyjlJGZmXeknD7KvXsTRfrNLOorkl7A8eggDigNtdYj4tjK3zCPS4zqY0MQ6OhTiqZQofF7x94AThDl6r6ViMDLD34twjCvEy6F+2yDJGvsYAyqmvqHRcpXRQ= 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 1585369835283646.5191810249048; Fri, 27 Mar 2020 21:30:35 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id B9B21B01A1B; Sat, 28 Mar 2020 04:30:31 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 18C2FB00165 for ; Sat, 28 Mar 2020 04:30:13 +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 02S33FKC186618; Fri, 27 Mar 2020 23:27:36 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ywcj2ck2h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Mar 2020 23:27:36 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 02S3RQe6007173; Sat, 28 Mar 2020 03:27:35 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by ppma03dal.us.ibm.com with ESMTP id 301x76g70n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 28 Mar 2020 03:27:35 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02S3RZui15532986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 03:27:35 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id 1AD61B2064; Sat, 28 Mar 2020 03:27:35 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id 0022BB205F; Sat, 28 Mar 2020 03:27:34 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Sat, 28 Mar 2020 03:27:34 +0000 (GMT) From: Stefan Berger To: seabios@seabios.org, kevin@koconnor.net Date: Fri, 27 Mar 2020 23:27:32 -0400 Message-Id: <20200328032733.841258-3-stefanb@linux.vnet.ibm.com> In-Reply-To: <20200328032733.841258-1-stefanb@linux.vnet.ibm.com> References: <20200328032733.841258-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-27_09:2020-03-27,2020-03-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=890 impostorscore=0 suspectscore=0 clxscore=1015 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003280023 Message-ID-Hash: 2AMKGTUNBSMTPZ3ZFBGNS3GWMCCZVPGC X-Message-ID-Hash: 2AMKGTUNBSMTPZ3ZFBGNS3GWMCCZVPGC 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 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-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / Content-Type: text/plain; charset="utf-8" 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 997da87..99005b9 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 Apr 26 11:11:04 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=1585369576; cv=none; d=zohomail.com; s=zohoarc; b=QFGhLkNGx8oOf2DJwmHi15buOxomJklDawTzJgiDCMpyIbWMzUW38DFrmCW2UODW/pLCHvxazqhWgNq+ueqtpMbuI+94sBL6pLE3BE75kxfKcAvYmiUVM32FLcXTApFVNBbZvYqV1P2wCNJM+CSSMiEtxAumqmFTiW7NVr0gbXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585369576; 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=QfVkIr+Hk/wAC23r6tyr/kHJd//GDCqi2cwIVfTRhYY=; b=diLD+L3Q0THwHcoGgim+1zWbB6o9w3DaSwCGnO2IYKESVsdfBFVI55Q6RpHQQx3f9B2JOb/P/UmAzWwFcV9cJdu14PvGyilAK2UiQoT7Ee6brfLLM6kRAD4C7p+fWR6QXKitWk6Pc9AxUnSsrbB2SAbW0QHeg2VENAZj+lQTXYU= 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 158536957678760.73494693373857; Fri, 27 Mar 2020 21:26:16 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 3C77EB01A30; Sat, 28 Mar 2020 04:26:13 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id ABF29B00165 for ; Sat, 28 Mar 2020 04:25:54 +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 02S33d1W125666; Fri, 27 Mar 2020 23:27:37 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ywd8hgv4u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Mar 2020 23:27:37 -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 02S3ROKX017531; Sat, 28 Mar 2020 03:27:36 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by ppma01dal.us.ibm.com with ESMTP id 301x768722-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 28 Mar 2020 03:27:36 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02S3RZft14090796 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 03:27:35 GMT Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id 35B3AB205F; Sat, 28 Mar 2020 03:27:35 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by IMSVA (Postfix) with ESMTP id 1EB96B2065; Sat, 28 Mar 2020 03:27:35 +0000 (GMT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Sat, 28 Mar 2020 03:27:35 +0000 (GMT) From: Stefan Berger To: seabios@seabios.org, kevin@koconnor.net Date: Fri, 27 Mar 2020 23:27:33 -0400 Message-Id: <20200328032733.841258-4-stefanb@linux.vnet.ibm.com> In-Reply-To: <20200328032733.841258-1-stefanb@linux.vnet.ibm.com> References: <20200328032733.841258-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-27_09:2020-03-27,2020-03-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003280023 X-Spam-Level: *** Message-ID-Hash: 5KKOPOV2VZVYQI74UWTNF35MHCPB5YSU X-Message-ID-Hash: 5KKOPOV2VZVYQI74UWTNF35MHCPB5YSU 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 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-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / Content-Type: text/plain; charset="utf-8" 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 99005b9..25ae0c8 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)]; } 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