From nobody Wed Feb 11 04:36:36 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+104349+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+104349+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1683618164; cv=none; d=zohomail.com; s=zohoarc; b=livNhc7mcWBDPhwtFc4i0Ley2INpIZvVtRXbExQLvMKWn/cQisV1sKu/cYn2zP/wcR9Xe6WA67cl1K/XNkwyGFLKs/mFrGLk/60MsG4Tj1nUbprsANNg893qKsn+qV91bQgbzGCFPOwwGloLjRDb+hF+QhccUxpakJf6HbXn8Bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683618164; 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=QgVxULAH2y6Mk1pVeL0ZMHomMYv9PnTl32JNNdSY4mk=; b=bmNOBqqpYZh7Lg/AIqjD7krIrHjEPTB6UKMd/Zum2xLZDQq6g69gG6GcwhK31Qj+i5/p2dMmWl0qT+x1EQcosvSpvdc8oL8du5qKJVHnbBhDhfHpEGFgmFRcoYYbRzwhrcuOsgeXzn5zp9d5fL8c28ViYbxTjZ2HA/uG5oG+ZIo= 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+104349+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 1683618164182230.3664421208066; Tue, 9 May 2023 00:42:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id C8AhYY1788612xeYggyaHe18; Tue, 09 May 2023 00:42:43 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.26291.1683618163349760589 for ; Tue, 09 May 2023 00:42:43 -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 830B41595; Tue, 9 May 2023 00:43:27 -0700 (PDT) X-Received: from e126645.arm.com (e126645.nice.arm.com [10.34.100.110]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 87CCB3F5A1; Tue, 9 May 2023 00:42:41 -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 , Samer El-Haj-Mahmoud Subject: [edk2-devel] [PATCH v1 8/8] SecurityPkg/RngDxe: Simplify Rng algorithm selection for Arm Date: Tue, 9 May 2023 09:40:42 +0200 Message-Id: <20230509074042.1523428-9-pierre.gondois@arm.com> In-Reply-To: <20230509074042.1523428-1-pierre.gondois@arm.com> References: <20230509074042.1523428-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: oF1FNUwYLFnchFK3By61Mwqjx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1683618163; bh=oB6EHBirLx7G/Qy3oSD5ZSdKJRQfcxeo+wEWhWV4w5w=; h=Cc:Date:From:Reply-To:Subject:To; b=M6rYhTo0u6rBt3gQFTKZDeZCAQvGq2cPd443zJUtMViFV2QwPOFa08ycRcNDJPCm1TA jiOJuKXuDx9o1X+dtMFG8R1kG7s6v7JAepy0AMXjvJtShQD2Wf3ash5RFxEt4DTWZuW5w EQv+FN2cvGbo+zlgsSBqA7DSfLut+g5vhCQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1683618164882100015 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 (#104349): https://edk2.groups.io/g/devel/message/104349 Mute This Topic: https://groups.io/mt/98779045/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-