From nobody Tue Feb 10 11:33:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+106637+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106637+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1688460748; cv=none; d=zohomail.com; s=zohoarc; b=fq8kmyi/QHDZn+3Ly61yE6iJzdg13UmBM+yNLroGUN5uk4iofUzB3P14riL4qTyZyd6qZeBvtWISfn8FeSOlqYvzkemdfVqlMa2+FNagChMqpYQdBnHy8EyQQ/kays2+5Lsbim4KLE717m6O6Z+AlwTXy9WC+lPlNEVBZVnk96Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688460748; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=zl3WGxhJ/u9QgIgce5dmKObPv6zh2N5XCWaDtzwfF0U=; b=Fkor7fgSgMGXmlkD/XLzg0WosWDkSoccmxovmYoXgXblcPnyusEj5tNNpOtmyC6+SHWee60wM+tZCCOBmLGtGBRgODRcdJRn0o4wHUz6F3XbbZZTB3sKOUDqN7IqBiSTYeByV3Q1nSPrQnaS9w2F/uDzT+uTzX+PvvnkhpneLvE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106637+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 168846074841951.70805324594119; Tue, 4 Jul 2023 01:52:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 3tSgYY1788612xF0DsiwdaL6; Tue, 04 Jul 2023 01:52:28 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.54441.1688460747617391153 for ; Tue, 04 Jul 2023 01:52:27 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B07262F4; Tue, 4 Jul 2023 01:53:09 -0700 (PDT) X-Received: from e126645.arm.com (e126645.nice.arm.com [10.34.100.101]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CA61E3F73F; Tue, 4 Jul 2023 01:52:25 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu , Jiewen Yao , Jian J Wang , Ard Biesheuvel , Sami Mujawar , Jose Marinho , Kun Qin Subject: [edk2-devel] [PATCH v2 6/6] SecurityPkg/RngDxe: Simplify Rng algorithm selection for Arm Date: Tue, 4 Jul 2023 10:52:01 +0200 Message-Id: <20230704085201.260801-7-pierre.gondois@arm.com> In-Reply-To: <20230704085201.260801-1-pierre.gondois@arm.com> References: <20230704085201.260801-1-pierre.gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: KzefVJQabHdbjNYCrEBTWpiRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1688460748; bh=BL4dJN6QD3BN0c3/WBRJEhsgxoBeh9KbOmHgIf7KPro=; h=Cc:Date:From:Reply-To:Subject:To; b=uKIT2XhH7SO9l+xPGQ6bzFyEApyb5BzpEuq8fuQHVfZREpcPu7ItdaujHBt8e3OmpSG z12yIOFfOJ1VcUeo9yxORs6XHqY38q6AJHyyQ2iMT6J/KGexLcpWDrG6qfqx+9Bpxlugr GRiduNm4hUV0Kacty9KY0CNjoAh9EWg08nk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1688460749236100011 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The first element of mAvailableAlgoArray is defined as the default Rng algorithm to use. Don't go through the array at each RngGetRNG() call and just return the first element of the array. Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../RandomNumberGenerator/RngDxe/ArmRngDxe.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c b/Securit= yPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c index 78a18c5e1177..7a42e3cbe3d2 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c @@ -77,7 +77,6 @@ RngGetRNG ( ) { EFI_STATUS Status; - UINTN Index; GUID RngGuid; =20 if ((This =3D=3D NULL) || (RNGValueLength =3D=3D 0) || (RNGValue =3D=3D = NULL)) { @@ -88,21 +87,13 @@ RngGetRNG ( // // Use the default RNG algorithm if RNGAlgorithm is NULL. // - for (Index =3D 0; Index < mAvailableAlgoArrayCount; Index++) { - if (!IsZeroGuid (&mAvailableAlgoArray[Index])) { - RNGAlgorithm =3D &mAvailableAlgoArray[Index]; - goto FoundAlgo; - } - } - - if (Index =3D=3D mAvailableAlgoArrayCount) { - // No algorithm available. - ASSERT (Index !=3D mAvailableAlgoArrayCount); - return EFI_DEVICE_ERROR; + if (mAvailableAlgoArrayCount !=3D 0) { + RNGAlgorithm =3D &mAvailableAlgoArray[0]; + } else { + return EFI_UNSUPPORTED; } } =20 -FoundAlgo: Status =3D GetRngGuid (&RngGuid); if (!EFI_ERROR (Status) && CompareGuid (RNGAlgorithm, &RngGuid)) --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#106637): https://edk2.groups.io/g/devel/message/106637 Mute This Topic: https://groups.io/mt/99943079/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-