From nobody Thu Apr 18 17:30:37 2024 Delivered-To: importer@patchew.org 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+83779+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637062415226173.88477397832253; Tue, 16 Nov 2021 03:33:35 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Ux3XYY1788612xTUBQunUXhl; Tue, 16 Nov 2021 03:33:34 -0800 X-Received: from EUR03-VE1-obe.outbound.protection.outlook.com (EUR03-VE1-obe.outbound.protection.outlook.com [40.107.5.65]) by mx.groups.io with SMTP id smtpd.web11.8743.1637062413834500406 for ; Tue, 16 Nov 2021 03:33:34 -0800 X-Received: from AM4PR0202CA0001.eurprd02.prod.outlook.com (2603:10a6:200:89::11) by AM0PR08MB5364.eurprd08.prod.outlook.com (2603:10a6:208:186::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 11:33:29 +0000 X-Received: from VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:200:89:cafe::9d) by AM4PR0202CA0001.outlook.office365.com (2603:10a6:200:89::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Tue, 16 Nov 2021 11:33:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+83779+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT049.mail.protection.outlook.com (10.152.19.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:28 +0000 X-Received: ("Tessian outbound dbb52aec1fa6:v110"); Tue, 16 Nov 2021 11:33:28 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3e10d90032aaf4bb X-CR-MTA-TID: 64aa7808 X-Received: from 95d02e50afdb.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6AE20456-8100-4EA7-AE12-E1ED73CB9DCC.1; Tue, 16 Nov 2021 11:33:12 +0000 X-Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 95d02e50afdb.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Nov 2021 11:33:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZIRa5g8TU1QXlLkIGK9bBygJfiNmEp+6BnzsJnuWT1/G2cT5DrbXvcSF2Vy8Bfq8bpP2wcHaiHSDcAHgv64ytsPme0wvSu7dJVwRxtLkATkl/s0J2bWiUekTRVOdErU2LfzjPUkfx0nqxFlgg6pQZIzI7ACORTxCOKhY9lAPmxItaq0kAUTSqyRv7rm3u5NwdIeYIFvW63wZtH7/F05oJf5JGH2TdofhnpdZ2K8tqfxCKvwaCQRzgRiRfy+P6BdzyYlLwA3K+N1O0UpwWkeVDrfYoJ1oK78T4q7TgVj46mWotPCnOzpx9i8qVmpxEwL3MBucItIrxIeAHoquEbqnrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jk475Oowf/SCipQK7UFMhsxB0WS9mc3MIGhYhEYF+e8=; b=O09YTCHI0GurKKIPkh/txov4G2OmIneWXZSNYCqaK2eWbRPM09asLLK8NjRMukhyVrd4hVKWwMdslOxwUTc4q3k7cglJsMVn//cMRV05s4xCROZbEkszZII8vw1p6cqWb6Dmln/CPiHqRr3KxHG9Zh4swd1VwyIDpcMjFziTZafTjD5KDmnZvqDCTgRNdGPqPNHgoppsi8YD+ct0xOklGwRtBdJFBRisnwew4nsaSjX0OyJMeylvbRK0H2dKIhIQcNMeUpPECI/X1BhNeTE+8YLZrX90kfjt6zpjqKKDJ8scHGr2SvqE6Kw/U3eLF6oZ0hAGgGzcbD0lILAQDayo+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AS9PR06CA0327.eurprd06.prod.outlook.com (2603:10a6:20b:45b::22) by AM0PR08MB5186.eurprd08.prod.outlook.com (2603:10a6:208:156::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 11:33:06 +0000 X-Received: from VE1EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45b:cafe::30) by AS9PR06CA0327.outlook.office365.com (2603:10a6:20b:45b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26 via Frontend Transport; Tue, 16 Nov 2021 11:33:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT032.mail.protection.outlook.com (10.152.18.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:06 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 16 Nov 2021 11:32:52 +0000 X-Received: from E114225.Arm.com (10.1.196.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 16 Nov 2021 11:32:51 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v2 1/8] MdePkg: Definition for TRNG library class interface Date: Tue, 16 Nov 2021 11:32:53 +0000 Message-ID: <20211116113301.31088-2-sami.mujawar@arm.com> In-Reply-To: <20211116113301.31088-1-sami.mujawar@arm.com> References: <20211116113301.31088-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e6975b2-6ab9-40e6-2063-08d9a8f4e944 X-MS-TrafficTypeDiagnostic: AM0PR08MB5186:|AM0PR08MB5364: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:5516;OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: P/ohJ43RcgtytqtvSe5NEd18CpzoRmkQxD+EKj4U+Nk2wv/Rn6JDSk/YCmo+HoVg7SODLbtBsyqOOabRP/XnR7I1TPH1+MEmk4WgqHQrgKpwTyxSbpGENEAehgocv/ha8asrkW6uqVgc3c+QiCOLNHa+eq5tKyGCL1XMDNRaxIMxfd6CjbqTnCuK+2SLZE3XAjYwGMe9AEDEbRsw9hhFyFre2K3dF9AxZmIQYDefx8Mp+zhscxztMMGZBxqcZC24KcisVg7ATtvsdE9n6cTPIR6BiOL+tKpCvmdhyc0t2zW7DnjyL7exQbv7gMig4OlaCRs7xG/MKkzqn4Ei+sRYf5ULA+NjHXIhPtkIg7ccjNzLkQ912EruV+xI9eDNnl4/fIDETDcFtYDKHWyouJFIJOSdCH38nZ8d6XZRRqIDRQMvs0iwj5ZOuGqULnAm04RfmoocO8Bm9p+3tVMr/Exb61hd4JhEELGNqipJuKaO2THvV7A7UyaFue3xV42bKRZ0mntAkfZ64wdHPOd+3faf7o1tAMMswYUOKj8DNFr4M8vu8szKffusvi29vqt0Fec472j42ySeypSn9WM+359ByPrDETaiPKAriQDC5P/OGgUj16cV7AD7aJGvaNjOf5X4gEBIEcjHbrt7gqy+u1pnKWe/f4BfyA52fJ/cBKluMOHsDYoey24ncuFa6agbcCfP6Y9DkHK+olHp6gvmff7vgaoajb/ZUuOgakJEDzT1+ePKnVX/j76LLp9vmqLozUeLk/bF/5ySds8SiPx6O5YE+Lv7r2mwDrbB4E0yWrB/0jbmXqt4AVrCHI9WdnDNS3Lpom8xkAjFz9CijVLQspUY3bWeOthITEVFCBrLueZfGVY= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(356005)(36860700001)(8936002)(336012)(81166007)(5660300002)(1076003)(186003)(70586007)(70206006)(7696005)(7416002)(26005)(36756003)(82310400003)(44832011)(6916009)(86362001)(316002)(2906002)(47076005)(83380400001)(54906003)(4326008)(426003)(508600001)(8676002)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5186 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 7ab14152-801a-4c99-be84-08d9a8f4dbf0 X-Microsoft-Antispam-Message-Info: litCKJS/9QCdRuW26bVtZaH9RPgn/NABMA1wV/MozMXbWEEywyeC9ZNqH5IIlHW8qTn2+tCFOccaTDtiUKUQsyyOxWwO4CptLSyQcAOL3FGcUjDptwUC6Ap4bJ8ghf+pSg63PXVROBz4lanQrc0/mPg+6kYYAj6aD3gTtSislOUJ8WXx/sTtW+5uY4g5hcrRYy20L5+lGu505/QHfYsrS1BRTty3gVZFQvJkxUynWLrTtoQzTohFoAXHF/ClLiHpzksczRUTlhUiY7euePwYoDU62por/nxfyGhkcquPTHozcfMj8pOREbzprYiaF6Yg+/OjrPvaghSrbZIf+syg46HW+dlZdWBe1yizobksaxLvSBKuofu6QL+qBlG0RjIsx14UCryUnTNq0PZxw8H1Tqm99VtyWgonXQ6SZEjZR/vB1eKxuvlIwXx8A92F8rrOQA34YkB6gQVrOMGCJaCw4HuTS6lftyXwGvcEPLzdWiHM+GPHCU/ELrUTUnPaIfoWolTpFdDmabpLvNbFrzE6D6Rzi6Qlk8tMDo9EKjonSBriMN+vDly2gPVYxh8A/07nCGlHGhpe6Iq6Z6sGwvW9qmcZJrMe7p+jQY2pp/TTY0d0WpgFLGTSz1W6mcgTMeLP0sh/hqCkOyGexb20Wm7+iibosWZMqmQr0NbclGygfm172HQlg8FgQ0GKKyTaR6Oq39gwjQ+EtlBW4VDh1OBlx2miBkrcEdKt9pqc6ShKJqqAXubWno+3rzfpitx5zvFqV1lvZPQVByKTCzQkgdv1RXhIGTgfSWrNrhcgGNKOLYUJXXOsMqw31bVbfDVaVQL4 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 11:33:28.7209 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e6975b2-6ab9-40e6-2063-08d9a8f4e944 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5364 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,sami.mujawar@arm.com X-Gm-Message-State: jKQy0jLYDzPSOHKbxvyoX4wZx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637062414; bh=434PtD4Hmx8MjQd+swdEK3u5Pg3SF6sfCNonhm2xbWY=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=tEtsqRq0H93bylsQXvvPcH5RwRvw0Y0Tr514B/G+aDOY8Fbo4F/ZkqSmnkVWfkzpiw+ +GMwOsIuP19VlRFU9saMQOIBNusBnwfHepoYVFOBZwtXlpBMySwl9JTI+3xn1Zt5hNmHj R7DQ1ydkB5ClJmyCuUIGPvtnIEv61gaiqJs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637062417170100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) The NIST Special Publications 800-90A, 800-90B and 800-90C provide recommendations for random number generation. The NIST 800-90C, Recommendation for Random Bit Generator (RBG) Constructions, defines the GetEntropy() interface that is used to access the entropy source. The GetEntropy() interface is further used by Deterministic Random Bit Generators (DRBG) to generate random numbers. The True Random Number Generator (TRNG) library defines an interface to access the entropy source on a platform. Some platforms/architectures may provide access to the entropy using a firmware interface. In such cases the TRNG library shall be used to provide an abstraction. Signed-off-by: Sami Mujawar --- Notes: v2: - MdePkg\Include\Library\TrngLib.h is base type [LIMING] library. It can use RETURN_STATUS instead of EFI_STATUS. Then, it doesn't need to include - Replaced EFI_STATUS with RETURN_STATUS and [SAMI] removed include of /UefiBaseType.h. - MdePkg\Include\Library\TrngLib.h API parameter [LIMING] doesn't require CONST. CONST means the value specified by the input pointer will not be changed in API implementation. - Removed the use of constant pointers in the [SAMI] TRNG API. MdePkg/Include/Library/TrngLib.h | 121 ++++++++++++++++++++ MdePkg/MdePkg.dec | 7 +- 2 files changed, 127 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Library/TrngLib.h b/MdePkg/Include/Library/Trng= Lib.h new file mode 100644 index 0000000000000000000000000000000000000000..082c83d0a6c67aa88c789a35b8f= 2f73ba7cf46cd --- /dev/null +++ b/MdePkg/Include/Library/TrngLib.h @@ -0,0 +1,121 @@ +/** @file + TRNG interface library definitions. + + Copyright (c) 2021, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - [1] Arm True Random Number Generator Firmware, Interface 1.0, + Platform Design Document. + (https://developer.arm.com/documentation/den0098/latest/) + - [2] NIST Special Publication 800-90A Revision 1, June 2015, Recommenda= tion + for Random Number Generation Using Deterministic Random Bit Genera= tors. + (https://csrc.nist.gov/publications/detail/sp/800-90a/rev-1/final) + - [3] NIST Special Publication 800-90B, Recommendation for the Entropy + Sources Used for Random Bit Generation. + (https://csrc.nist.gov/publications/detail/sp/800-90b/final) + - [4] (Second Draft) NIST Special Publication 800-90C, Recommendation for + Random Bit Generator (RBG) Constructions. + (https://csrc.nist.gov/publications/detail/sp/800-90c/draft) + + @par Glossary: + - TRNG - True Random Number Generator +**/ +#ifndef TRNG_LIB_H_ +#define TRNG_LIB_H_ + +/** Get the version of the TRNG backend. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the version of the TRNG backend. + The implementation must return NOT_SUPPORTED if a Back end is not presen= t. + + @param [out] MajorRevision Major revision. + @param [out] MinorRevision Minor revision. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Backend not present. +**/ +RETURN_STATUS +EFIAPI +GetTrngVersion ( + OUT UINT16 *MajorRevision, + OUT UINT16 *MinorRevision + ); + +/** Get the UUID of the TRNG backend. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the UUID of the TRNG backend. + Returning the TRNG UUID is optional and if not implemented, RETURN_UNSUP= PORTED + shall be returned. + + Note: The caller must not rely on the returned UUID as a trustworthy TRNG + Back end identity + + @param [out] Guid UUID of the TRNG backend. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. +**/ +RETURN_STATUS +EFIAPI +GetTrngUuid ( + OUT GUID *Guid + ); + +/** Returns maximum number of entropy bits that can be returned in a single + call. + + @return Returns the maximum number of Entropy bits that can be returned + in a single call to GetEntropy(). + If this feature is not supported MAX_UINTN is returned. +**/ +UINTN +EFIAPI +GetTrngMaxSupportedEntropyBits ( + VOID + ); + +/** Returns N bits of conditioned entropy. + + See [3] Section 2.3.1 GetEntropy: An Interface to the Entropy Source + GetEntropy + Input: + bits_of_entropy: the requested amount of entropy + Output: + entropy_bitstring: The string that provides the requested entropy. + status: A Boolean value that is TRUE if the request has been satisfi= ed, + and is FALSE otherwise. + + Note: In this implementation this function returns a status code instead + of a boolean value. + This is also compatible with the definition of Get_Entropy, see [4] + Section 7.4 Entropy Source Calls. + (status, entropy_bitstring) =3D Get_Entropy ( + requested_entropy, + max_length + ) + + @param [in] EntropyBits Number of entropy bits requested. + @param [out] Buffer Buffer to return the entropy bits. + @param [in] Buffersize Size of the Buffer in bytes. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. + @retval RETURN_BAD_BUFFER_SIZE Buffer size is too small. + @retval RETURN_NOT_READY No Entropy available. +**/ +RETURN_STATUS +EFIAPI +GetEntropy ( + IN CONST UINTN EntropyBits, + OUT UINT8 *Buffer, + IN CONST UINTN BufferSize + ); + +#endif // TRNG_LIB_H_ diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 8b18415b107a03b11dc984341bb788cf9cd6e0ea..e612b5c57429d1af591de8e111f= 328e19a030ca0 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -7,6 +7,7 @@ # Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
# (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2021, Arm Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -267,11 +268,15 @@ [LibraryClasses] # RegisterFilterLib|Include/Library/RegisterFilterLib.h =20 -[LibraryClasses.IA32, LibraryClasses.X64, LibraryClasses.AARCH64] +[LibraryClasses.IA32, LibraryClasses.X64, LibraryClasses.AARCH64, LibraryC= lasses.ARM] ## @libraryclass Provides services to generate random number. # RngLib|Include/Library/RngLib.h =20 + ## @libraryclass Provides services to generate Entropy using a TRNG. + # + TrngLib|Include/Library/TrngLib.h + [LibraryClasses.IA32, LibraryClasses.X64] ## @libraryclass Abstracts both S/W SMI generation and detection. ## --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=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 (#83779): https://edk2.groups.io/g/devel/message/83779 Mute This Topic: https://groups.io/mt/87092739/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- From nobody Thu Apr 18 17:30:37 2024 Delivered-To: importer@patchew.org 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+83783+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637062427648728.5568938135715; Tue, 16 Nov 2021 03:33:47 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id SQI5YY1788612xmUzv0cArYH; Tue, 16 Nov 2021 03:33:46 -0800 X-Received: from EUR03-DB5-obe.outbound.protection.outlook.com (EUR03-DB5-obe.outbound.protection.outlook.com [40.107.4.64]) by mx.groups.io with SMTP id smtpd.web11.8745.1637062425622373955 for ; Tue, 16 Nov 2021 03:33:46 -0800 X-Received: from AM8P251CA0025.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::30) by AM4PR08MB2883.eurprd08.prod.outlook.com (2603:10a6:205:9::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 11:33:43 +0000 X-Received: from AM5EUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:21b:cafe::a3) by AM8P251CA0025.outlook.office365.com (2603:10a6:20b:21b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26 via Frontend Transport; Tue, 16 Nov 2021 11:33:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+83783+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT056.mail.protection.outlook.com (10.152.17.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:42 +0000 X-Received: ("Tessian outbound dbb52aec1fa6:v110"); Tue, 16 Nov 2021 11:33:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1eb8d05edf38da94 X-CR-MTA-TID: 64aa7808 X-Received: from cd35f2021d9f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 36673CEF-12B3-4702-9E5D-1F99E0B82BA9.1; Tue, 16 Nov 2021 11:33:28 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cd35f2021d9f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Nov 2021 11:33:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Va0VbPbQYLu9dXA0k8wVixhj3AAs5qaX3VF5uJMa8zxhIcZMVEBRReVye35DYfxodjMbfOA1N3IacktiG1lDg7XMi0QtWd3bWz6w/ByvP20WJPeTepnmymo4jkjzf5pcDwA/Us7UE/FOFKquslK1Ttb0Edb88VXcBWYeydUbtW1abRpypOzex4j6DoaXxxQzbw6IMMQrt0Cc/xitpsCt5aShpwTeUoDEW5GVpcyHybghAwi8fpny3pTin4KG5zdeVmc0nhgK/xzVSNp7jbLR9yP7JRYr6VnZVC3jhGRSSDrYmN9K/jr3yAGO5HVu9RqiyqPPRDupJfRTwK27YM4e2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RN2rydr+6mHTLzw3MHFKIvV+2x0VzuRic4FPx9zdN+U=; b=B/hN9STmfzj1onetO0XpLLo3bB6skcm8JZgHQQ6eV1mqwUTgnN25WLY+Oaszpfn3iX/ZazrUN6D3PgkYjfAASiuvpHVMtG6Vk1UxqFn9lY+cLYM88hT/4u3iuwCmuBlgYw+zx3wrQ44smYNnxgKvMkXdJHvcgFCOAYe5Nm/A05krVo/DjhzABY9DWXfykzBI+GlySG0xu40bTjfaO9RBDkveLuN1wqGNXBAWJL1odI0i6OMiENTG2pnOaoxgld6y/13GmYtGh8Sjt1whsjeuWoYOzFfo6hJq8RZ2FTDXxVZrfypKZjLIzsO2S1eTgiIdYeCbtyf9/qHE6nZXIbxUjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AS9PR06CA0133.eurprd06.prod.outlook.com (2603:10a6:20b:467::34) by AM6PR08MB3639.eurprd08.prod.outlook.com (2603:10a6:20b:51::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19; Tue, 16 Nov 2021 11:33:14 +0000 X-Received: from AM5EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:467:cafe::8e) by AS9PR06CA0133.outlook.office365.com (2603:10a6:20b:467::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Tue, 16 Nov 2021 11:33:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT055.mail.protection.outlook.com (10.152.17.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:13 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Tue, 16 Nov 2021 11:32:53 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Tue, 16 Nov 2021 11:32:52 +0000 X-Received: from E114225.Arm.com (10.1.196.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 16 Nov 2021 11:32:52 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v2 2/8] ArmPkg: PCD to select conduit for monitor calls Date: Tue, 16 Nov 2021 11:32:54 +0000 Message-ID: <20211116113301.31088-3-sami.mujawar@arm.com> In-Reply-To: <20211116113301.31088-1-sami.mujawar@arm.com> References: <20211116113301.31088-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 12ea41c1-2669-405a-3620-08d9a8f4f162 X-MS-TrafficTypeDiagnostic: AM6PR08MB3639:|AM4PR08MB2883: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6790;OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: O2h+0wJQiLhnX7tYeKSgfTIACjsp2vzaAW9HhUartAORYQLYEfIJhCmi18WUI7vJGtbB0RMZ507lJVDmTTuQxoXBWGLo7R4mwRqtrHYyWiiZiT2kWqb/RpS0uwg8x5H84+Rz1ymANbb9oChyy9XGq5crqLZlYNpzPwLE4uFgHEwMLT3RUSkHoy63j3SgSSPOyRUbyFheGd3ICRGyzpc9c0wZVSNR4GMDcdvkZCC9xGt8h/+kA7wauVKnSsj1FVlNv/Mvy1HaEE80w31FpSD+nVMI+M72IIWi0aK3MnpDB3HdB12QAIAz4NSbsk3VH07/hDHSUV2YYYGJZrmahd5Sub9UQEIGs84UEPi5Btz6NOnEyMO0FQxdbmL3M0Q6U5WpFMMWMv1+GZjmBn7B9wxc1MYf08NvCHkWfmA6Wq1CQEm6Z5UMl9fuTcanZ+g9BTyc+hJMDsy1UuSn3oKTuZaCiekShRYI8vXkzUrVd5HOcKbYi3vgkUcT59GgVsKa1cnRV4GBAYgIm0FiCxr5Hzgu9lLGcvpvNZbX0xCeU0POf9HWOh00yVToawOpKuuSA/CqPiEXF23zY+mUaGUm2aBGHUrwYVks3vk+7mFnW4iyu7Cwrcv6nz6IFCQtukqu9BOuOo7v6Wci0Dt3tm2bph5faUDv+eGy5jmXy0QlkjrA9p8xvEHGNPwBfl5jaC2s6H+GYd9f5hvemzeaRcL6JsSnYDXUpSkjUbTMwRkYlA6lNAQYbEnMJ9Z6Rgv8I5k4xGFlrlZgwj+tUJr72u1sL2ll1Y3x7sEe5+VtJs9ORMbhS/hsDt6cpl9TXx0BPKZFl3nk X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(70206006)(6916009)(316002)(2616005)(356005)(70586007)(36860700001)(81166007)(44832011)(1076003)(336012)(426003)(7416002)(47076005)(5660300002)(8676002)(186003)(26005)(8936002)(36756003)(82310400003)(2906002)(508600001)(86362001)(4326008)(54906003)(7696005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3639 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8a58c18b-0041-40cd-0ce7-08d9a8f4e014 X-Microsoft-Antispam-Message-Info: reaPUFtar+lVw3GOq4d8fyn8gMbZ7xUixmlDSLEPaDqEZOv1V8HEg9A9Qg1mi5oQelWxC/MObU81m02Cs/iYVjZx1cjOvAIIXUurmRpr03DyFfEpAqhoxpZDeQvSERjZ1gFbz1SCVLrFDzDxvQIdPSaePdcZGSmWVzT5HE/REcaM9afcoKPMwWBrIhjRcJDutSw7a3miqaGEiwLvVqqIjhfxRFeZompFX1gGYAxDVIWeK+oPdlaF5o3afeESzy3JGmVOf0Fo4aHi5OBtk4i5K/5/S630jGsyEwf0SVHjl6G5y1ttJx33nEegFi6+dDTIEASgwHvleB4UF1y7EHzRNkXz8pBwvrgmHYcuSyD+2WKvhncZ5ZH1CSVOji1wXVtMXS7n+tT6ZOuckaEnGDxKi6gGv69+tHxKB/EJEJBXJA3iQ3yYsELVcXIOKiqRyseq20x4iLcjUdN8LbvVlujWMka3o877pSkFAw6ZQb5V6oDIQEUhHdNxZBNCPfDW1fGD6EnX2hn9PGCkCVa+xTwHsy/aAFtzZKd+QUSJL5TaEGD3dS/OSVOl8WI7WceCOxsbNR7jP/fofdqYCCzIztRK6FsaIAi2J8iKNDjOzt6RoNaN4nsdYqS7lQ+WeGFyTqJBotjR/biOpZkvDIhNeWh4a8Fy9PjnpaFsb9VWXG68PqGRRqLHUZTQiUXOguQSMyGLx3Aai0JTd00+858sskbeqGoVLSwsiUo7UbqHxKz0zExar40rm+Ja4xt4nIgITCgYslJqlonxjTKnNsGjfrbn7VZ6TdyQRSCZ1E17A2OJlWM= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 11:33:42.4308 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12ea41c1-2669-405a-3620-08d9a8f4f162 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2883 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,sami.mujawar@arm.com X-Gm-Message-State: QLyfofBgxrJSiRnRVAzDkeuox1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637062426; bh=t8vp1e4R9WD99EJbPREZ7zEvoW3F9VIf6Evz40OCZIQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=o6LkUlY9f6On0GU0zKOPBRGpX9Jm7rtd9czmSO8LV2sXWUAAdudthVzDq70/1y7uE2X V4vTZTYje+A8kL/S6atlvilnXdCK1s/XyEvGRTpuvJWNVvYp5S6uOT6080mgCHk4ea8wu ONmcxIZnU+8sUbWoOQ4+DtEPxGGXdfm8edY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637062428450100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) Define a PCD 'PcdMonitorConduitHvc' to select the conduit to use for monitor calls. PcdMonitorConduitHvc is defined as FALSE by default, meaning the SMC conduit is enabled as default. Adding PcdMonitorConduitHvc allows selection of HVC conduit to be used by virtual firmware implementations. Signed-off-by: Sami Mujawar --- Notes: v2: - No code change since v1. Re-sending with V2 series. [SAMI] ArmPkg/ArmPkg.dec | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index 9da1bbc9f2166dc8ae93f96a34d3165fffed34dc..9a53888ae52f00eec50e631cf1b= fcacecf8bba87 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -132,6 +132,11 @@ [PcdsFeatureFlag.common] # Define if the GICv3 controller should use the GICv2 legacy gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042 =20 + ## Define the conduit to use for monitor calls. + # Default PcdMonitorConduitHvc =3D FALSE, conduit =3D SMC + # If PcdMonitorConduitHvc =3D TRUE, conduit =3D HVC + gArmTokenSpaceGuid.PcdMonitorConduitHvc|FALSE|BOOLEAN|0x00000047 + [PcdsFeatureFlag.ARM] # Whether to map normal memory as non-shareable. FALSE is the safe choic= e, but # TRUE may be appropriate to fix performance problems if you don't care = about --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=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 (#83783): https://edk2.groups.io/g/devel/message/83783 Mute This Topic: https://groups.io/mt/87092744/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- From nobody Thu Apr 18 17:30:37 2024 Delivered-To: importer@patchew.org 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+83777+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637062406479437.68585895672766; Tue, 16 Nov 2021 03:33:26 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id JgqjYY1788612xmb6MAjei2M; Tue, 16 Nov 2021 03:33:26 -0800 X-Received: from EUR03-AM5-obe.outbound.protection.outlook.com (EUR03-AM5-obe.outbound.protection.outlook.com [40.107.3.78]) by mx.groups.io with SMTP id smtpd.web10.8752.1637062404430784394 for ; Tue, 16 Nov 2021 03:33:25 -0800 X-Received: from DB6PR0201CA0032.eurprd02.prod.outlook.com (2603:10a6:4:3f::42) by DB6PR0802MB2325.eurprd08.prod.outlook.com (2603:10a6:4:85::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Tue, 16 Nov 2021 11:33:19 +0000 X-Received: from DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:3f:cafe::de) by DB6PR0201CA0032.outlook.office365.com (2603:10a6:4:3f::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Tue, 16 Nov 2021 11:33:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+83777+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT008.mail.protection.outlook.com (10.152.20.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Tue, 16 Nov 2021 11:33:19 +0000 X-Received: ("Tessian outbound de6049708a0a:v110"); Tue, 16 Nov 2021 11:33:19 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2542778084ff1813 X-CR-MTA-TID: 64aa7808 X-Received: from 0a93b2d29aa1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 692187F6-B125-480E-A173-5AEFB79DA606.1; Tue, 16 Nov 2021 11:33:10 +0000 X-Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0a93b2d29aa1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Nov 2021 11:33:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TEmwU5NXff0fmxax9kSM1YGOmJC6ttpAv4ASkVzpvDIIIZ8q83zpllYRf18iqho21Pbi1DRoe57zl6i3ey77/x5lAbxIdXZQJDMQ6VbID0geH5OEq9D0tEdWsV8KDq1/ixQS6/68LHugFL2xkoLXG28MFPPnpNp+pAT1G9vIOenSof/SgVg3ZXoNKvQB5Ln9U/1TWeveNDaBjsazSpgKkBfwfIusl2G+lzenZ+0HKW2o4nvOKejSXwTGizypZxdzbbKWkoRQpI23EdpT3sT3emJ0Lez5O5v1QzyccJKBzceR3jfyGhWQbU+oXmvNcQSXdi6sgXGkJk6GBS1DyMJnEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iFu8FUOfiojjENUiUGRxdQ0t2l0bUhtJJ3WZL/2zXHg=; b=mmGN8bp6u8CvzyZMf8Hegv/Dr1t4T9JFMZTYowcLnPi1/14wvqMNt01cdgJ9K66xGIiJ/JqKqcSzqSxax00FeyHz/w/zL7e7TtSdhqSQxdARY8QLsG0V0lw66QwBPqQJ9u2yxIOtwumqGT6pwCxoHS23rJvJvxVGKeRP5PL2hIiUAL9cUtI0lxBouVdTpWuqa/cmGplX19R77jyAGwRyf0dGMwIDuZCrTkVuFQnLJzfEKZP9tfuMD2agLuW4ZqA8U8H6CfBhtcmJXA+7cHWEg2s+9sU0hXuewGxDqTMsNm4hzFbLqa9tyTz+fN+B4bhC4Is/9MyMmBdvXKKxZxVKWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AS9PR06CA0328.eurprd06.prod.outlook.com (2603:10a6:20b:45b::31) by AM4PR0802MB2146.eurprd08.prod.outlook.com (2603:10a6:200:5b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Tue, 16 Nov 2021 11:33:07 +0000 X-Received: from VE1EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45b:cafe::98) by AS9PR06CA0328.outlook.office365.com (2603:10a6:20b:45b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26 via Frontend Transport; Tue, 16 Nov 2021 11:33:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT032.mail.protection.outlook.com (10.152.18.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:07 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 16 Nov 2021 11:32:53 +0000 X-Received: from E114225.Arm.com (10.1.196.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 16 Nov 2021 11:32:53 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v2 3/8] ArmPkg: Add Arm Firmware TRNG library Date: Tue, 16 Nov 2021 11:32:55 +0000 Message-ID: <20211116113301.31088-4-sami.mujawar@arm.com> In-Reply-To: <20211116113301.31088-1-sami.mujawar@arm.com> References: <20211116113301.31088-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63a6df21-6dc6-4230-58ff-08d9a8f4e368 X-MS-TrafficTypeDiagnostic: AM4PR0802MB2146:|DB6PR0802MB2325: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1303;OLM:1303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: cEFXKqFbpw9F2fr4quqWjegUx4J+ttmtly2Xsptxh907akZUOFPXFw+j9yOzAyITVkd3ZgbiOloZKozpIHVMPnXXNCt4aD8q3BQi12EFM/UKKjMpVnVRjLKXTKWMafwQg9ixjTG+F9CZIBys78MSjsYLUKLNx8fCywdhN7JrcewfiX7FUpVwkIG9Rv2a8ntCTlM+GMJWNmYiAaXsbLs/noD6eEkdV+nNWc9WGdCu2+1lBQC3DIhUaGBIwSnFb0mnuB/BBIznDSTkaz+LBGZc24Fi6tslsMnVqM9gaOi3S6WJrtsxDRsLB2qaCTKkKzYZ8+xA1muB4jkbGREgJaUpM3YL/z1AFDN5/Gcs+CDmcTG5raVWaHLhipMsMcsf29YbNKDgvMRs4QFj7fu8xyi0c8KF2L5AIPG5Sc8OuD7euhR69tq9y6RQv/mn1qVpfsqtMlFS/FcMRFew6pBgVJvewhmqVVajrYB4eyOu2Mqu2ytiL3G3E0pPoi2upTd11lAw4GGJbd3equ6IqhfdYdlDLCD+obX1Ed49c7STrKf8U4qc3BD51mJpBsH+qkoeJSPjBqi5jEDfVq/gMHU/m4vimQSpCUndwU8VduvJv4mkuKfCglrRqkv+JoFJXYHO0SAGiePCv5qglE0YGvk//ou66Eeg5OgvuCcBtMZhemLKI/UdOtPa5WPU00l6uRYENLYSrrJ2jacrhPQZBG2rH9LCX7RUNyJLnQ65ILlL5yr25p/3eE+OCwAH+wrS1bU8LB8HEGEjq+iR3DLIARg+qdZAUg6623Ui/yMlZywlYDXCbz2WL38d3fDD40o7Th5yzXr2MEHmwzgDBSJd4UIPFVkAEpKInxPLcsQI89Kh4P7SoE8= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(356005)(30864003)(5660300002)(508600001)(44832011)(7416002)(6916009)(2906002)(83380400001)(8936002)(2616005)(86362001)(81166007)(82310400003)(1076003)(4326008)(47076005)(54906003)(316002)(36860700001)(7696005)(8676002)(426003)(70586007)(70206006)(36756003)(186003)(336012)(26005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0802MB2146 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: c47a40f2-20e5-4d2b-45c6-08d9a8f4dc53 X-Microsoft-Antispam-Message-Info: QJ+r3391VtJqUHPm5D+cJSxZj7i1g269UX0liGDJItPrVv0l9egDtGNUenWKCUoB7Rv/0JeqqaB9NH3NL0baO5yJTyFHtA1SuLuCaDp8iKeo9zhNUTaWaGEg/n+hdrADZW0+Pywnw8g27wuCNk6Yc7c4P1uegU/goD85mOnbEgOZCn80GDEKFQ1ZcUd0TuzR2/qEoL7hNUJgWtIqHi8OWZC2mvjYQoXleeANbBgfXsnLOLASw9ftnMw3Sye820bjulazFOG4VcPkDm8VFJNbbLUDmqy5EC1bgD1KmEqQpnWRM5Kbr3Q7m5nVH+zMqYjbbQnI8uzfE6PC6UeR4jlPO9wcIkdLLwN/svZoF9M5/Tq/007g00dj2QUQqehzeM8ymj6yIFZO+dGmb0fYa3zCCwvyfgl5bME0BQ2xLaz49VNlFdbi6QerUQol0h7ovqwNE30HsWswXE8p0XaZxjtfbyM2hrvPyuvKW7G8516EeSp735705P1jQEZF9U7q/Q+DZ3p4qKE8dTET/eCK9QxKFgNVM9wjbehpxrTGjwongZsX3qIPX4aFz/PeVklMsDcxyxevqlOvD+n3FV3ROVvTDrRZ6mDq03ovpzPihXIOtjMgjOK0FbTKejM//wuvFLuom+EziZtZ/TZYwS1Gg21TbrJzRZ1dR2Vf0Uw8x0Hx9tlL7f4m9L+H5E9pSVW3JxIU6tMcTJjyNzuKZaVBrL01e3Uc5UTlqvKqhXKwxsqUSRdKzYy9lDn9pJWRgsvbUOegkt4xtpUHT3ymHKrYwPjJ9Pg5IZqPn44mKtSXKXghxQDNX0sUHdqIMPNXQq/PMzmmHaUj3TmhnNXoDn53WzpRLg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 11:33:19.0279 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 63a6df21-6dc6-4230-58ff-08d9a8f4e368 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2325 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,sami.mujawar@arm.com X-Gm-Message-State: sPQdoXXxydoNLvfsesTwTPeWx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637062406; bh=4svKsNG7/F+Olkzdfab9JRSuXCHa93RSibFS/FUkQGU=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=hQ6KoE3OUx2OOAOZxWnLHhhCNGgvt3kxT49eZi41Ubq0Av4g2YhKe1G1IGrs+Sfwhju GqX/mj+Bkijvj6lcYM6QQsA+tVOvJWgpNZqjqeQGFJm+aRQg/0Qlx4L5xmTENFrzLZ05p XtTk0ey0dy6/kcPUkQnN147J16Qk42DV3Zo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637062408467100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) The Arm True Random Number Generator Firmware, Interface 1.0, Platform Design Document (https://developer.arm.com/documentation/den0098/latest/) defines an interface between an Operating System (OS) executing at EL1 and Firmware (FW) exposing a conditioned entropy source that is provided by a TRNG back end. The conditioned entropy, that is provided by the TRNG FW interface, is commonly used to seed deterministic random number generators. This patch adds a TrngLib library that implements the Arm TRNG firmware interface. Signed-off-by: Sami Mujawar --- Notes: v2: - MdePkg\Include\Library\TrngLib.h is base type [LIMING] library. It can use RETURN_STATUS instead of EFI_STATUS. - Replaced EFI_STATUS with RETURN_STATUS. [SAMI] - MdePkg\Include\Library\TrngLib.h API parameter [LIMING] doesn't require CONST. CONST means the value specified by the input pointer will not be changed in API implementation. - Removed the use of constant pointers in the [SAMI] TRNG API. ArmPkg/ArmPkg.dsc | 1 + ArmPkg/Library/ArmFwTrngLib/ArmFwTrngDefs.h | 64 +++ ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.c | 483 ++++++++++++++++++++ ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf | 34 ++ 4 files changed, 582 insertions(+) diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc index 59fd8f295d4f614cc68ee1021e691f94e279ab81..23df68c5eb53df11de5d96bde49= 49f3c833c9b2c 100644 --- a/ArmPkg/ArmPkg.dsc +++ b/ArmPkg/ArmPkg.dsc @@ -156,6 +156,7 @@ [Components.common] ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.inf ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf =20 + ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf ArmPkg/Universal/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf ArmPkg/Universal/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf ArmPkg/Universal/Smbios/OemMiscLibNull/OemMiscLibNull.inf diff --git a/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngDefs.h b/ArmPkg/Library/A= rmFwTrngLib/ArmFwTrngDefs.h new file mode 100644 index 0000000000000000000000000000000000000000..42236e743d972df0df205b15654= 96afeff5785f3 --- /dev/null +++ b/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngDefs.h @@ -0,0 +1,64 @@ +/** @file + Arm Firmware TRNG definitions. + + Copyright (c) 2021, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - [1] Arm True Random Number Generator Firmware, Interface 1.0, + Platform Design Document. + (https://developer.arm.com/documentation/den0098/latest/) + + @par Glossary: + - TRNG - True Random Number Generator + - FID - Function ID +**/ + +#ifndef ARM_FW_TRNG_DEFS_H_ +#define ARM_FW_TRNG_DEFS_H_ + +// Firmware TRNG interface Function IDs +#define FID_TRNG_VERSION 0x84000050 +#define FID_TRNG_FEATURES 0x84000051 +#define FID_TRNG_GET_UUID 0x84000052 +#define FID_TRNG_RND_AARCH32 0x84000053 +#define FID_TRNG_RND_AARCH64 0xC4000053 + +// Firmware TRNG revision mask and shift +#define TRNG_REV_MAJOR_MASK 0x7FFF +#define TRNG_REV_MINOR_MASK 0xFFFF +#define TRNG_REV_MAJOR_SHIFT 16 +#define TRNG_REV_MINOR_SHIFT 0 + +// Firmware TRNG status codes +#define TRNG_STATUS_SUCCESS (INT32)(0) +#define TRNG_NOT_SUPPORTED (INT32)(-1) +#define TRNG_INVALID_PARAMETER (INT32)(-2) +#define TRNG_NO_ENTROPY (INT32)(-3) + +#if defined (MDE_CPU_ARM) +/** FID to use on AArch32 platform to request entropy. +*/ +#define FID_TRNG_RND FID_TRNG_RND_AARCH32 + +/** Maximum bits of entropy supported on AArch32. +*/ +#define MAX_ENTROPY_BITS 96 +#elif defined (MDE_CPU_AARCH64) +/** FID to use on AArch64 platform to request entropy. +*/ +#define FID_TRNG_RND FID_TRNG_RND_AARCH64 + +/** Maximum bits of entropy supported on AArch64. +*/ +#define MAX_ENTROPY_BITS 192 +#else +#error "Firmware TRNG not supported. Unknown chipset." +#endif + +/** Typedef for SMC or HVC arguments. +*/ +typedef ARM_SMC_ARGS ARM_MONITOR_ARGS; + +#endif // ARM_FW_TRNG_DEFS_H_ diff --git a/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.c b/ArmPkg/Library/Ar= mFwTrngLib/ArmFwTrngLib.c new file mode 100644 index 0000000000000000000000000000000000000000..314e7ffbc232ae90bbb77306f9c= 7113ce63012c8 --- /dev/null +++ b/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.c @@ -0,0 +1,483 @@ +/** @file + Arm Firmware TRNG interface library. + + Copyright (c) 2021, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - [1] Arm True Random Number Generator Firmware, Interface 1.0, + Platform Design Document. + (https://developer.arm.com/documentation/den0098/latest/) + - [2] NIST Special Publication 800-90A Revision 1, June 2015, Recommenda= tion + for Random Number Generation Using Deterministic Random Bit Genera= tors. + (https://csrc.nist.gov/publications/detail/sp/800-90a/rev-1/final) + - [3] NIST Special Publication 800-90B, Recommendation for the Entropy + Sources Used for Random Bit Generation. + (https://csrc.nist.gov/publications/detail/sp/800-90b/final) + - [4] (Second Draft) NIST Special Publication 800-90C, Recommendation for + Random Bit Generator (RBG) Constructions. + (https://csrc.nist.gov/publications/detail/sp/800-90c/draft) + + @par Glossary: + - TRNG - True Random Number Generator + - FID - Function ID +**/ + +#include +#include +#include +#include +#include +#include + +#include "ArmFwTrngDefs.h" + +/** Convert TRNG status codes to EFI status codes. + + @param [in] TrngStatus TRNG status code. + + @retval RETURN_SUCCESS Success. + @retval RETURN_UNSUPPORTED Function not implemented. + @retval RETURN_INVALID_PARAMETER A parameter is invalid. + @retval RETURN_NOT_READY No Entropy available. +**/ +STATIC +RETURN_STATUS +TrngStatusToEfiStatus ( + IN INT32 TrngStatus + ) +{ + switch (TrngStatus) { + case TRNG_NOT_SUPPORTED: + return RETURN_UNSUPPORTED; + + case TRNG_INVALID_PARAMETER: + return RETURN_INVALID_PARAMETER; + + case TRNG_NO_ENTROPY: + return RETURN_NOT_READY; + + case TRNG_STATUS_SUCCESS: + default: + return RETURN_SUCCESS; + } +} + +/** Invoke the monitor call using the appropriate conduit. + If PcdMonitorConduitHvc is TRUE use the HVC conduit else use SMC condu= it. + + @param [in, out] Args Arguments passed to and returned from the moni= tor. + + @return VOID +**/ +STATIC +VOID +ArmCallMonitor ( + IN OUT ARM_MONITOR_ARGS *Args + ) +{ + if (FeaturePcdGet (PcdMonitorConduitHvc)) { + ArmCallHvc ((ARM_HVC_ARGS*)Args); + } else { + ArmCallSmc ((ARM_SMC_ARGS*)Args); + } +} + +/** Get the version of the TRNG backend. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the version of the TRNG backend. + The implementation must return NOT_SUPPORTED if a Back end is not presen= t. + + @param [out] MajorRevision Major revision. + @param [out] MinorRevision Minor revision. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Backend not present. +**/ +RETURN_STATUS +EFIAPI +GetTrngVersion ( + OUT UINT16 *MajorRevision, + OUT UINT16 *MinorRevision + ) +{ + RETURN_STATUS Status; + ARM_MONITOR_ARGS Parameters; + INT32 Revision; + + if ((MajorRevision =3D=3D NULL) || (MinorRevision =3D=3D NULL)) { + return RETURN_INVALID_PARAMETER; + } + + ZeroMem (&Parameters, sizeof (Parameters)); + + /* + Cf. [1], 2.1 TRNG_VERSION + Function ID (W0) 0x8400_0050 + Parameters + W1-W7 Reserved (MBZ) + Returns + Success (W0 > 0) W0[31] MBZ + W0[30:16] Major revision + W0[15:0] Minor revision + W1 - W3 Reserved (MBZ) + Error (W0 < 0) + NOT_SUPPORTED Function not implemented + */ + Parameters.Arg0 =3D FID_TRNG_VERSION; + ArmCallMonitor (&Parameters); + + Revision =3D (INT32)Parameters.Arg0; + // Convert status codes to EFI status codes. + Status =3D TrngStatusToEfiStatus (Revision); + if (EFI_ERROR (Status)) { + return Status; + } + + *MinorRevision =3D (Revision & TRNG_REV_MINOR_MASK); + *MajorRevision =3D ((Revision >> TRNG_REV_MAJOR_SHIFT) & TRNG_REV_MAJOR_= MASK); + return RETURN_SUCCESS; +} + +#ifndef MDEPKG_NDEBUG +/** Get the features supported by the TRNG backend. + + The caller can determine if functions defined in the TRNG ABI are + present in the ABI implementation. + + @param [in] FunctionId Function Id. + @param [out] Capability Function specific capability if present + otherwise Zero is returned. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. +**/ +STATIC +RETURN_STATUS +EFIAPI +GetTrngFeatures ( + IN CONST UINT32 FunctionId, + OUT UINT32 *Capability OPTIONAL + ) +{ + ARM_MONITOR_ARGS Parameters; + + ZeroMem (&Parameters, sizeof (Parameters)); + + /* + Cf. [1], Section 2.2 TRNG_FEATURES + Function ID (W0) 0x8400_0051 + Parameters + W1 trng_func_id + W2-W7 Reserved (MBZ) + Returns + Success (W0 >=3D 0) + SUCCESS Function is implemented. + > 0 Function is implemented and + has specific capabilities, + see function definition. + Error (W0 < 0) + NOT_SUPPORTED Function with FID=3Dtrng_func_id + is not implemented + */ + Parameters.Arg0 =3D FID_TRNG_FEATURES; + Parameters.Arg1 =3D FunctionId; + ArmCallMonitor (&Parameters); + if (Parameters.Arg0 < TRNG_STATUS_SUCCESS) { + return RETURN_UNSUPPORTED; + } + + if (Capability !=3D NULL) { + *Capability =3D Parameters.Arg0; + } + + return RETURN_SUCCESS; +} +#endif //MDEPKG_NDEBUG + +/** Get the UUID of the TRNG backend. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the UUID of the TRNG backend. + Returning the TRNG UUID is optional and if not implemented, RETURN_UNSUP= PORTED + shall be returned. + + Note: The caller must not rely on the returned UUID as a trustworthy TRNG + Back end identity + + @param [out] Guid UUID of the TRNG backend. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. +**/ +RETURN_STATUS +EFIAPI +GetTrngUuid ( + OUT GUID *Guid + ) +{ + RETURN_STATUS Status; + ARM_MONITOR_ARGS Parameters; + + ZeroMem (&Parameters, sizeof (Parameters)); + + /* + Cf. [1], Section 2.3 TRNG_GET_UUID + Function ID (W0) 0x8400_0052 + Parameters + W1-W7 Reserved (MBZ) + Returns + Success (W0 !=3D -1) + W0 UUID[31:0] + W1 UUID[63:32] + W2 UUID[95:64] + W3 UUID[127:96] + Error (W0 =3D -1) + W0 NOT_SUPPORTED + */ + Parameters.Arg0 =3D FID_TRNG_GET_UUID; + ArmCallMonitor (&Parameters); + + // Convert status codes to EFI status codes. + Status =3D TrngStatusToEfiStatus ((INT32)Parameters.Arg0); + if (EFI_ERROR (Status)) { + return Status; + } + + Guid->Data1 =3D (Parameters.Arg0 & MAX_UINT32); + Guid->Data2 =3D (Parameters.Arg1 & MAX_UINT16); + Guid->Data3 =3D ((Parameters.Arg1 >> 16) & MAX_UINT16); + + Guid->Data4[0] =3D (Parameters.Arg2 & MAX_UINT8); + Guid->Data4[1] =3D ((Parameters.Arg2 >> 8) & MAX_UINT8); + Guid->Data4[2] =3D ((Parameters.Arg2 >> 16) & MAX_UINT8); + Guid->Data4[3] =3D ((Parameters.Arg2 >> 24) & MAX_UINT8); + + Guid->Data4[4] =3D (Parameters.Arg3 & MAX_UINT8); + Guid->Data4[5] =3D ((Parameters.Arg3 >> 8) & MAX_UINT8); + Guid->Data4[6] =3D ((Parameters.Arg3 >> 16) & MAX_UINT8); + Guid->Data4[7] =3D ((Parameters.Arg3 >> 24) & MAX_UINT8); + + DEBUG ((DEBUG_INFO, "FW-TRNG: UUID %g\n", Guid)); + + return RETURN_SUCCESS; +} + +/** Returns maximum number of entropy bits that can be returned in a single + call. + + @return Returns the maximum number of Entropy bits that can be returned + in a single call to GetEntropy(). +**/ +UINTN +EFIAPI +GetTrngMaxSupportedEntropyBits ( + VOID + ) +{ + return MAX_ENTROPY_BITS; +} + +/** Returns N bits of conditioned entropy. + + See [3] Section 2.3.1 GetEntropy: An Interface to the Entropy Source + GetEntropy + Input: + bits_of_entropy: the requested amount of entropy + Output: + entropy_bitstring: The string that provides the requested entropy. + status: A Boolean value that is TRUE if the request has been satisfi= ed, + and is FALSE otherwise. + + Note: In this implementation this function returns a status code instead + of a boolean value. + This is also compatible with the definition of Get_Entropy, see [2] + Section 7.4 Entropy Source Calls. + (status, entropy_bitstring) =3D Get_Entropy ( + requested_entropy, + max_length + ) + + @param [in] EntropyBits Number of entropy bits requested. + @param [out] Buffer Buffer to return the entropy bits. + @param [in] BufferSize Size of the Buffer in bytes. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. + @retval RETURN_BAD_BUFFER_SIZE Buffer size is too small. + @retval RETURN_NOT_READY No Entropy available. +**/ +RETURN_STATUS +EFIAPI +GetEntropy ( + IN CONST UINTN EntropyBits, + OUT UINT8 *Buffer, + IN CONST UINTN BufferSize + ) +{ + RETURN_STATUS Status; + ARM_MONITOR_ARGS Parameters; + UINTN EntropyBytes; + UINTN LastValidBits; + UINTN ArgSelector; + UINTN BytesToClear; + + // [1] Section 2.4.3 Caller responsibilities. + // The caller cannot request more than MAX_BITS bits of conditioned + // entropy per call. + if ((EntropyBits =3D=3D 0) || (EntropyBits > MAX_ENTROPY_BITS)) { + return RETURN_INVALID_PARAMETER; + } + + EntropyBytes =3D (EntropyBits + 7) >> 3; + if (EntropyBytes > BufferSize) { + return RETURN_BAD_BUFFER_SIZE; + } + + ZeroMem (Buffer, BufferSize); + ZeroMem (&Parameters, sizeof (Parameters)); + + /* + Cf. [1], Section 2.4 TRNG_RND + Function ID (W0) 0x8400_0053 + 0xC400_0053 + SMC32 Parameters + W1 N bits of entropy (1 6 N 6 96) + W2-W7 Reserved (MBZ) + SMC64 Parameters + X1 N bits of entropy (1 6 N 6 192) + X2-X7 Reserved (MBZ) + SMC32 Returns + Success (W0 =3D 0): + W0 MBZ + W1 Entropy[95:64] + W2 Entropy[63:32] + W3 Entropy[31:0] + Error (W0 < 0) + W0 NOT_SUPPORTED + NO_ENTROPY + INVALID_PARAMETERS + W1 - W3 Reserved (MBZ) + SMC64 Returns + Success (X0 =3D 0): + X0 MBZ + X1 Entropy[191:128] + X2 Entropy[127:64] + X3 Entropy[63:0] + Error (X0 < 0) + X0 NOT_SUPPORTED + NO_ENTROPY + INVALID_PARAMETERS + X1 - X3 Reserved (MBZ) + */ + Parameters.Arg0 =3D FID_TRNG_RND; + Parameters.Arg1 =3D EntropyBits; + ArmCallMonitor (&Parameters); + + // Convert status codes to EFI status codes. + Status =3D TrngStatusToEfiStatus ((INT32)Parameters.Arg0); + if (EFI_ERROR (Status)) { + return Status; + } + + // Extract Data + // ArgSelector =3D ((EntropyBytes + 3) >> 2); for AArch32 + // ArgSelector =3D ((EntropyBytes + 7) >> 3); for AArch64 + // ((sizeof (UINTN) >> 2) + 1) is 3 or 2 depending on size of UINTN + ArgSelector =3D ((EntropyBytes + (sizeof (UINTN) - 1)) >> + ((sizeof (UINTN) >> 2) + 1)); + + switch (ArgSelector) { + case 3: + CopyMem (&Buffer[(sizeof (UINTN) * 2)], &Parameters.Arg1, sizeof (UI= NTN)); + + case 2: + CopyMem (&Buffer[sizeof (UINTN)], &Parameters.Arg2, sizeof (UINTN)); + + case 1: + CopyMem (&Buffer[0], &Parameters.Arg3, sizeof (UINTN)); + break; + + default: + ASSERT (0); + return RETURN_INVALID_PARAMETER; + } // switch + + + // [1] Section 2.4.3 Caller responsibilities. + // The caller must ensure that only the value in Entropy[N-1:0] is consu= med + // and that the remaining bits in Entropy[MAX_BITS-1:N] are ignored. + // Therefore, Clear the unused upper bytes. + BytesToClear =3D (sizeof (UINTN) * ArgSelector) - EntropyBytes; + if (BytesToClear !=3D 0) { + ZeroMem (&Buffer[EntropyBytes], BytesToClear); + } + + // Clear the unused MSB bits of the last byte. + LastValidBits =3D EntropyBits & 0x7; + if (LastValidBits !=3D 0) { + Buffer[EntropyBytes - 1] &=3D (0xFF >> (8 - LastValidBits)); + } + + return Status; +} + +/** The constructor checks that the FW-TRNG interface is supported + by the host firmware. + + It will ASSERT() if FW-TRNG is not supported. + It will always return RETURN_SUCCESS. + + @retval RETURN_SUCCESS The constructor always returns RETURN_SUCCESS. +**/ +RETURN_STATUS +EFIAPI +ArmFwTrngLibConstructor ( + VOID + ) +{ + RETURN_STATUS Status; + UINT16 MajorRev; + UINT16 MinorRev; + GUID Guid; + + Status =3D GetTrngVersion (&MajorRev, &MinorRev); + if (EFI_ERROR (Status)) { + return RETURN_SUCCESS; + } + +#ifndef MDEPKG_NDEBUG + // Check that the required features are present. + Status =3D GetTrngFeatures (FID_TRNG_RND, NULL); + if (EFI_ERROR (Status)) { + return RETURN_SUCCESS; + } + + // Check if TRNG UUID is supported and if so trace the GUID. + Status =3D GetTrngFeatures (FID_TRNG_GET_UUID, NULL); + if (EFI_ERROR (Status)) { + return RETURN_SUCCESS; + } +#endif + + Status =3D GetTrngUuid (&Guid); + if (EFI_ERROR (Status)) { + return RETURN_SUCCESS; + } + + DEBUG (( + DEBUG_INFO, + "FW-TRNG: Version %d.%d, GUID {%g}\n", + MajorRev, + MinorRev, + Guid + )); + + return RETURN_SUCCESS; +} diff --git a/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf b/ArmPkg/Library/= ArmFwTrngLib/ArmFwTrngLib.inf new file mode 100644 index 0000000000000000000000000000000000000000..4b2c58251fbe8fbcb5af308736d= b014e8d954720 --- /dev/null +++ b/ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf @@ -0,0 +1,34 @@ +## @file +# Arm Firmware TRNG interface library. +# +# Copyright (c) 2021, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D ArmFwTrngLib + FILE_GUID =3D 10DE97C9-28E4-4C9B-A53E-8D7D1B0DD4E0 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D TrngLib + CONSTRUCTOR =3D ArmFwTrngLibConstructor + +[Sources] + ArmFwTrngDefs.h + ArmFwTrngLib.c + +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + ArmSmcLib + ArmHvcLib + BaseLib + BaseMemoryLib + +[Pcd] + gArmTokenSpaceGuid.PcdMonitorConduitHvc + --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=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 (#83777): https://edk2.groups.io/g/devel/message/83777 Mute This Topic: https://groups.io/mt/87092734/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- From nobody Thu Apr 18 17:30:37 2024 Delivered-To: importer@patchew.org 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+83776+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637062405122836.0405506916372; Tue, 16 Nov 2021 03:33:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id KISpYY1788612xE10F2xb4Xz; Tue, 16 Nov 2021 03:33:24 -0800 X-Received: from EUR01-DB5-obe.outbound.protection.outlook.com (EUR01-DB5-obe.outbound.protection.outlook.com [40.107.15.45]) by mx.groups.io with SMTP id smtpd.web11.8737.1637062403022671247 for ; Tue, 16 Nov 2021 03:33:24 -0800 X-Received: from AM6PR04CA0062.eurprd04.prod.outlook.com (2603:10a6:20b:f0::39) by HE1PR08MB2891.eurprd08.prod.outlook.com (2603:10a6:7:2b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Tue, 16 Nov 2021 11:33:17 +0000 X-Received: from AM5EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:f0:cafe::a6) by AM6PR04CA0062.outlook.office365.com (2603:10a6:20b:f0::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16 via Frontend Transport; Tue, 16 Nov 2021 11:33:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+83776+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT033.mail.protection.outlook.com (10.152.16.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:16 +0000 X-Received: ("Tessian outbound de6049708a0a:v110"); Tue, 16 Nov 2021 11:33:16 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 85250ccf2b949d0c X-CR-MTA-TID: 64aa7808 X-Received: from 3d5122ab076a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1CB0CB20-D0A6-4A00-95CC-F1BBEE25CB41.1; Tue, 16 Nov 2021 11:33:10 +0000 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3d5122ab076a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Nov 2021 11:33:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fmZIu8W9CAsGCg7hMx5DOXrJnDEuKxF22BNPl5KM9RPKjWD9IGy8pqziiYCcVquLg1VD8KSaW9JGikpHZ6FztNsleeChj6zNgtnZNQ5NyTYe1V5sAF0dI2Pme77wi8ZqXO/1kF5Wvo7xIzJfY0mEw/F8MeEguSf8RJ/12bq6tPtStwKhoeZpI7mJ4X7qge0a8GWnNbMRVNjXXMUgaaGSF9F0rTLTPyY6V3zW0HzYMijSk+gVtJm0frhUbmLk2EwPVgeIi/TPJq13nqHIlojSDVUVd+D3Q3Mu0KIe3jgZpEQthSAFRrsmKgN57SkdPzW0rhF0AvNCD63LYOJzrQHukw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Q4q8yjEGSx6qCCv7fiuKVa6P3dfrCMvywSi5q4RLa88=; b=VirOfYlJQ5oGOWgTspvMvncv/0aC/zYSmiwXiDE0lEhJzsA/qr+8nvGzq7v0kbIpm5z3QsbKrxe8ideZX4vrgfWeUHLUKHlDvC2gy03MSQk74M1NIPf3zWrahSBysVS1A3o8AcqOF50iaukZXCu166c5wJQj8697errEk0Glbmgq3boi9+CXrBf0a9aEjBNw9jai0AjWTVw4Y2xZuVZsgCZHkrzsE6QFENBVpxg9NA361/AXUrhOD8fNEpWLtlO/DkNSkB3iNkJ3tuMrci5BE2HGHdsgyjpnyuUhSFeLhR4FejXTQ3gWg9sS9Z+oQm4CqvoECDZMe7XRnUwIFzGB/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AS9PR05CA0048.eurprd05.prod.outlook.com (2603:10a6:20b:489::14) by AM0PR08MB3682.eurprd08.prod.outlook.com (2603:10a6:208:fb::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 11:33:09 +0000 X-Received: from VE1EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:489:cafe::46) by AS9PR05CA0048.outlook.office365.com (2603:10a6:20b:489::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Tue, 16 Nov 2021 11:33:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT029.mail.protection.outlook.com (10.152.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:08 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 16 Nov 2021 11:32:54 +0000 X-Received: from E114225.Arm.com (10.1.196.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 16 Nov 2021 11:32:54 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v2 4/8] MdePkg: Add NULL instance of TRNG Library Date: Tue, 16 Nov 2021 11:32:56 +0000 Message-ID: <20211116113301.31088-5-sami.mujawar@arm.com> In-Reply-To: <20211116113301.31088-1-sami.mujawar@arm.com> References: <20211116113301.31088-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 44e6d380-a77b-4c2a-dc8d-08d9a8f4e220 X-MS-TrafficTypeDiagnostic: AM0PR08MB3682:|HE1PR08MB2891: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6430;OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: +xpsZDQXqJJ7KNsXWqEXpvA+MsEXVZsBDCq73lykBPmKb2TIMJwIDdmKm+xaqTXwK3nlWxbyu3q0wekU0DNQGGdOvJiqozMx7E+8XVjpNO3Q5FqcMHO3V3lvYEAuBJMFCqtLDxegmmOs5fTKdvkUM8pThIgeZ3mgzqVfQeK52hv2Vg9Fd9UT5uqO3NmQqYZMCDip9NZ9ffP7N5fPCiosl1U05Idlg0+3BBOFy7r/hdewfX8quRt2xn5olRjhVXN7AHHbEIXZDF1DRt5LLrs2BLAxsiZqdEmVZyR98SFJrWqNOTieyVyRRJlDei7mcd2/oudNzamo1hkWlqzTVTwVJ8YSWwGUJ93cEKvX+TNDn7WgutKfWmYtmwlsiDpxWRH5lpssx6hQKX2cALz05YtfqnCgEuSKe2GUnstqd2EA/v0NdDgNS++dGb7UMQ0U5YJ15uwGFbc7+VRA3dfqYlHaUykJSqDO/s1BQYiPoJM49f2vhSlQnBQur2IAzoCA8oDgBB+OB4reewDhHJUWIldXAFcyirp1F9XcKfYxZiWeEZfsVGXwtvUJe2IRTm2o/15WV/eT+ONOLeI8OTlMvNz1K9Sakeesq0W9BsPLHpj+4zIEcpAihjMuilVAswZnTHAY8qHhWhKHavdWbSFqSrmF8wNKaMRqjff225jh2o8v2K/efHlicig9lOzjxRzP0FkcvS9vjnI6MyyXT1n0/1ywjRykTRJ6WMvGkHUa+XzPm8oi8xHFeip7dH4NK9ruXGZoFVHHGmHtYu0Y+XPQ8zb4e0CgGulivzQJvfFL2EoM93bQn1K0JtnKVOaih6fr61P0 X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(70206006)(8936002)(36756003)(316002)(7416002)(5660300002)(54906003)(82310400003)(8676002)(86362001)(26005)(6916009)(7696005)(1076003)(2906002)(36860700001)(81166007)(186003)(4326008)(47076005)(426003)(44832011)(2616005)(356005)(83380400001)(508600001)(336012)(70586007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3682 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 97e2470d-d9f9-4fb1-1078-08d9a8f4dd3a X-Microsoft-Antispam-Message-Info: Se6M+47uuXK7Kjtlhy7KjiFkynYo+TppXxPtDFJGYk4jS6zUQm7yUtqSCjiS7DFyIWmjngE2CNPstbQuBTp9WfwzTPeKGltVDoV18jlStT8Y6jCU0zA4vZgeenHVMwYVMI/mTUm1tV8cZCOZ2r8/swa6oandD6dndR/GKgqv+cveVJaBtTwtLvOlZiYZmG5jflTmBqSc+pjM4hhzWFySHL25RtL8Mp6gRaWJ5IyY7k8pHKdmb4+FErkpX5ZiSZ6JEDM9cltgt69b8o+/Ty2Uj34Met+Yp+O9XrQgAfy7bUGndbt3ka6QxkT843gwn3vRj+VBRXZTlol+kPENuyarWo+x36llo0rEXghYMYgVFO5P5E19dFJFwIc3Cmef+4IN3egsS4JjsrvO9mN3J+zmevkK8Pyd7FT+6wEDhzJ+5eJcrfF7HJouf2s5Q2AnTjW/Vv9hosurM0DL+E//oARXm1WdZKzv2sTyJN60vKxP8Htaw3njPWk9rG9EfFq95B9CwkEQDS1nL5ocKogkXMm/ntzD25WDc8DVAQzk9WvvyiKhAq/nTzMwxA10wYtkAXHaFG0K0QmSadVoGEQOohLA71wX73cDFuZlcpZd1bqdDJ3AnXeTdS3FmX76oeOfC64c67Rsj0gCAfxlbOOD1iliSTz08AUkbM8sdIoOAR4piXctdLFPki2++Gpj/AI5rWqZeqbJgJwJMp+RniWaAxxoDwEZDJ6vsVx1juzRu2fXj4QZi41xsQBOJ2YyKurDkERBVPQKdviA40L3Mqh07JrRwxRh9NEcxFED/kc9Bd4Uits= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 11:33:16.8237 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 44e6d380-a77b-4c2a-dc8d-08d9a8f4e220 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR08MB2891 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,sami.mujawar@arm.com X-Gm-Message-State: NxnUVJ6GUhqQfNRQaENDYfuux1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637062404; bh=6YxAy9tguG/3EESjzaymFuJBy+Gsd2cZagT6ZyWZTM0=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=r4bDq5HdD0KcIgGOm/HjWPw90kURf/LFqJSFDmIyVVxn4SC1ppJyprs5xQ/CZKIh660 EgPtDBB3wT+RyRglzWl15kRmPeLWwgIHERNA1SXjrTreUhsmRo6YqtQdcJjkP1hSkpvsx OMIZ5zhrzMuSQAiWLS0NaO1Jvx1H4+J4o0c= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637062406169100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) The True Random Number Generator (TRNG) library defines an interface to access the entropy source on a platform. On platforms that do not have access to an entropy source, a NULL instance of the TRNG library may be useful to satisfy the build dependency. Therefore, add a NULL instance of the TRNG library. Signed-off-by: Sami Mujawar --- Notes: v2: - MdePkg\Include\Library\TrngLib.h is base type [LIMING] library. It can use RETURN_STATUS instead of EFI_STATUS. - Replaced EFI_STATUS with RETURN_STATUS. [SAMI] - MdePkg\Include\Library\TrngLib.h API parameter [LIMING] doesn't require CONST. CONST means the value specified by the input pointer will not be changed in API implementation. - Removed the use of constant pointers in the [SAMI] TRNG API. MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.c | 111 +++++++++++++++++= +++ MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf | 30 ++++++ MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.uni | 12 +++ MdePkg/MdePkg.dsc | 1 + 4 files changed, 154 insertions(+) diff --git a/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.c b/MdePkg/Libr= ary/BaseTrngLibNull/BaseTrngLibNull.c new file mode 100644 index 0000000000000000000000000000000000000000..406a1e8587ccfb0cd903bf7a379= 4f16627eb0a84 --- /dev/null +++ b/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.c @@ -0,0 +1,111 @@ +/** @file + Null version of TRNG (True Random Number Generator) services. + + Copyright (c) 2021, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - TRNG - True Random Number Generator +**/ + +#include +#include + +/** Get the TRNG version. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the version information for the TRNG implementatio= n. + Returning version information is optional and if not implemented, + RETURN_UNSUPPORTED shall be returned. + + @param [out] MajorRevision Major revision. + @param [out] MinorRevision Minor revision. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. +**/ +RETURN_STATUS +EFIAPI +GetTrngVersion ( + OUT UINT16 *MajorRevision, + OUT UINT16 *MinorRevision + ) +{ + ASSERT (FALSE); + return RETURN_UNSUPPORTED; +} + +/** Get the UUID of the TRNG backend. + + A TRNG may be implemented by the system firmware, in which case this + function shall return the UUID for the TRNG implementation. + Returning the TRNG UUID is optional and if not implemented, RETURN_UNSUP= PORTED + shall be returned. + + @param [out] Guid UUID of the TRNG backend. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. +**/ +RETURN_STATUS +EFIAPI +GetTrngUuid ( + OUT GUID *Guid + ) +{ + ASSERT (FALSE); + return RETURN_UNSUPPORTED; +} + +/** Returns maximum number of entropy bits that can be returned in a single + call. + + @return Returns the maximum number of Entropy bits that can be returned + in a single call to GetEntropy(). +**/ +UINTN +EFIAPI +GetTrngMaxSupportedEntropyBits ( + VOID + ) +{ + ASSERT (FALSE); + return 0; +} + +/** Returns N bits of conditioned entropy. + + See [3] Section 2.3.1 GetEntropy: An Interface to the Entropy Source + GetEntropy + Input: + bits_of_entropy: the requested amount of entropy + Output: + entropy_bitstring: The string that provides the requested entropy. + status: A Boolean value that is TRUE if the request has been satisfi= ed, + and is FALSE otherwise. + Note: In this implementation this function returns a status code inste= ad + of a boolean value. + + @param [in] EntropyBits Number of entropy bits requested. + @param [out] Buffer Buffer to return the entropy bits. + @param [in] BufferSize Size of the Buffer in bytes. + + @retval RETURN_SUCCESS The function completed successfully. + @retval RETURN_INVALID_PARAMETER Invalid parameter. + @retval RETURN_UNSUPPORTED Function not implemented. + @retval RETURN_BAD_BUFFER_SIZE Buffer size is too small. + @retval RETURN_NOT_READY No Entropy available. +**/ +RETURN_STATUS +EFIAPI +GetEntropy ( + IN CONST UINTN EntropyBits, + OUT UINT8 *Buffer, + IN CONST UINTN BufferSize + ) +{ + ASSERT (FALSE); + return RETURN_UNSUPPORTED; +} diff --git a/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf b/MdePkg/Li= brary/BaseTrngLibNull/BaseTrngLibNull.inf new file mode 100644 index 0000000000000000000000000000000000000000..a700cf66f457f8898d5c51a7b9c= 0b3d7643ff7f9 --- /dev/null +++ b/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf @@ -0,0 +1,30 @@ +## @file +# Null instance of TRNG (True Random Number Generator) Library. +# +# Copyright (c) 2021, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D BaseTrngLibNull + MODULE_UNI_FILE =3D BaseTrngLibNull.uni + FILE_GUID =3D ABDE1C87-4F50-4B82-9133-7A79E13F69AB + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D TrngLib + +# +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# + +[Sources] + BaseTrngLibNull.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib diff --git a/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.uni b/MdePkg/Li= brary/BaseTrngLibNull/BaseTrngLibNull.uni new file mode 100644 index 0000000000000000000000000000000000000000..1ec7def522e5975e9621eb28077= 6251b1e5502ca --- /dev/null +++ b/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.uni @@ -0,0 +1,12 @@ +// /** @file +// Null Instance of TRNG (True Random Number Generator) Library. +// +// Copyright (c) 2021, Arm Limited. All rights reserved.
+// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "Null instance of = TRNG Library" + +#string STR_MODULE_DESCRIPTION #language en-US "This library inst= ance should be used with modules that inherit an (indirect) dependency on t= he TrngLib class, but never actually call TrngLib APIs for consuming Entrop= y." diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index a94959169b2fd9d4b5bf7ad903bf5ce06566c60e..f83753e132e9b9eb4152927fc18= 2701fb1e70ca4 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -67,6 +67,7 @@ [Components] MdePkg/Library/DxeRngLib/DxeRngLib.inf MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf + MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf =20 MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=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 (#83776): https://edk2.groups.io/g/devel/message/83776 Mute This Topic: https://groups.io/mt/87092733/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- From nobody Thu Apr 18 17:30:37 2024 Delivered-To: importer@patchew.org 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+83780+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637062418559796.9684677722241; Tue, 16 Nov 2021 03:33:38 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ur6fYY1788612xIsjirwddfl; Tue, 16 Nov 2021 03:33:38 -0800 X-Received: from EUR02-AM5-obe.outbound.protection.outlook.com (EUR02-AM5-obe.outbound.protection.outlook.com [40.107.0.59]) by mx.groups.io with SMTP id smtpd.web12.8617.1637062415103211695 for ; Tue, 16 Nov 2021 03:33:37 -0800 X-Received: from AS9P194CA0013.EURP194.PROD.OUTLOOK.COM (2603:10a6:20b:46d::17) by AS8PR08MB6325.eurprd08.prod.outlook.com (2603:10a6:20b:332::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Tue, 16 Nov 2021 11:33:29 +0000 X-Received: from AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46d:cafe::70) by AS9P194CA0013.outlook.office365.com (2603:10a6:20b:46d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.18 via Frontend Transport; Tue, 16 Nov 2021 11:33:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+83780+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT018.mail.protection.outlook.com (10.152.16.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:28 +0000 X-Received: ("Tessian outbound c61f076cbd30:v110"); Tue, 16 Nov 2021 11:33:28 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 08fa2737907bfeb1 X-CR-MTA-TID: 64aa7808 X-Received: from 652cc0100523.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BAA5B4B7-3FDA-437B-8504-AB18E805A2B9.1; Tue, 16 Nov 2021 11:33:21 +0000 X-Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 652cc0100523.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Nov 2021 11:33:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d3x8VPivFE3EbCDQ8pM/d9/AFx3HQxu2sQlA0AvLw6UIw2l4YPFEuyNUoSQqyve9ssPByTEUsIqhe+zNJvyRyx/K6hY/859nZ2XIBZWdPoqjU62zZbmn4G0HwXp3lsCcusBnkR7BWGJo2dopx+sh5WQhk/vSy+kRalMw0z81d2wlXz3SZpJiwIYFd9RAwJykcgxCYJ4Q2lxbc5ywMr0mMb5lT/hEjETqe8EKG3o4mSfEiU+iHV1LacIIOEOI2QJn099j8iMzr+GDMNVnO0UE1Z61JIEqlr9rqqE25ta0IFatwAwZqj5mHa6TlCWi7JNC4BYOEPDVugvm/GYxpTVFbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Q/YH9yklmbqn+UHUj6imBJCMq+RFIipLAxft5CRxxgI=; b=R7Ct7hI5aUulywA2qTny6OKBafjZg1qPrxyan+qCFciKrvB9BN9kGV6T2eeDbUJydRyIKVkxHaY4UhnztehOdDF/k3HXjR3plWFg34FORfjp0v5mKy5gqv1ZZDqsA6Dr/KOOGvsVv7yOrhPIANUq+mXg/offcBwWTXAH6XAgLuNLSRUAqtOxORmOoTpOjqqzL3gUHG5ayl1DIEmeMiJtiSX6ydmCo1J7nxJqANvIZqFzRi43ifFSJ3WaU5sP9ciP+O3nIrBPHQghJc3KOFvuQzxGhnVyDDuvO5qoK4lNqnTZItjKbOYB/yJI0w/plYX7zhMmQIYpFEzaLsS5GHK59A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AS9PR06CA0149.eurprd06.prod.outlook.com (2603:10a6:20b:467::31) by AM6PR08MB5128.eurprd08.prod.outlook.com (2603:10a6:20b:e3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Tue, 16 Nov 2021 11:33:19 +0000 X-Received: from AM5EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:467:cafe::83) by AS9PR06CA0149.outlook.office365.com (2603:10a6:20b:467::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Tue, 16 Nov 2021 11:33:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT055.mail.protection.outlook.com (10.152.17.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:19 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Tue, 16 Nov 2021 11:32:56 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Tue, 16 Nov 2021 11:32:55 +0000 X-Received: from E114225.Arm.com (10.1.196.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 16 Nov 2021 11:32:55 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v2 5/8] SecurityPkg: Rename RdRandGenerateEntropy to common name Date: Tue, 16 Nov 2021 11:32:57 +0000 Message-ID: <20211116113301.31088-6-sami.mujawar@arm.com> In-Reply-To: <20211116113301.31088-1-sami.mujawar@arm.com> References: <20211116113301.31088-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: db4011d6-2d03-44af-cc59-08d9a8f4e8fc X-MS-TrafficTypeDiagnostic: AM6PR08MB5128:|AS8PR08MB6325: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:5797;OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: DfEZ5O53O8m8dsbLjY6xYUuDDZA2X3ejkHtbChWbmaDGdJcUYSpj43dNZYqhmrOkGT0xe9pca5itdpaucRes2SOo/tAxYH0oR+HjCwRHI6wkDw34ua02phbmR4wEEcNZJwrFw/OTZhirMpIj02jVFPxAEJJOQEM1PpaxHfQbsn4PeupOlRBk7u0sRn3+zgh7sFHS69KFOi169GDZQTpwl33zDOqgZxPxBCAeawMMenPFr+b4Dy4OPJ0n2ITEbo4bb6GJ2DnDRh6qKs9c0dWDmFg3N8LAku2dlfOnEocaZiA9wlhZSCNub80rs7k4JBxQKYhcqVxd9T0AR+IW1JgzOF0FW8MZmTS7exjwgyVCCtO3+EWycZcbcj9VLZvcj3To0dIFzDjadeyahU4r3iESfGfQmh3VC/vOO6QcrL80W2KOU96YF7sQGWebdlmH01C35HazjGjSdGmh5/4NHrA4lBloVg5iUvfiFhDN61dNCcGo5Jio/RbDjrCiQUP7DGqnWz6gQA+27tpruHK5/cML+wcXD2ImFLCzXYNOMQZ3PqffCSAdPpFDuYnwYu3cLRWbD2y/KYasJ4uWSO5xP9jMzGlhSmmENQKu861boyhNPh54PJre5NfdzCHxIGprAsSEdoOtCM0k+MrAiTcICPqOKnPfMtr3H7UsT3OmSrIF6MHg9uxJHNQC5sdxOI5S3RnrF7QdLoqiBvHvgTHnVsuKPSYEY9CVCpKjPKyujZiL5jWhngyE7lMBjyyVfAUnQvy3UP/LxD7OLZYky5SSbxrHdtlDnD4gz76Onc8TH5G5UXomv4p5Cn+FDfGC5UktTA3WZRf23Sotwu93zTUDcUt5Sw+Ga2DeOhhanXOdyt0WujU= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(6029001)(4636009)(36840700001)(46966006)(426003)(1076003)(2616005)(6916009)(83380400001)(966005)(356005)(26005)(36756003)(2906002)(508600001)(7696005)(54906003)(47076005)(8936002)(86362001)(4326008)(36860700001)(44832011)(186003)(8676002)(336012)(316002)(82310400003)(5660300002)(15650500001)(70586007)(70206006)(7416002)(81166007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5128 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 615da9f7-13c9-45b9-e826-08d9a8f4e37c X-Microsoft-Antispam-Message-Info: YUjmcNVSW9NZIodPlkxpzAFqDAjwg0ctRVM+G/EVGWEWfOilsELYnLGXNGAU2WfKYoQUR5rB04d3FKQ/IXaKC9gbE0zfHvMns9JW9a7Flug76DHOZZQcN8DWpkI338fqgJsDDAjVgJV40veaV1yAC3lTWpMwEV8bfjFMFFJWP4tyeIdsjkC0GonihkiV41VgVNJvUwKhI56sj4+mFEuzaOx4nB9GsXgOPPUAhPB46uecGccNGQgaq4nBcOu0BHaCV4ARm55nSFNNZyG8CM/hhOgs2Pln+Lq8B9hxj2NHPkFvvOto2HR/P4mdmYktUg5fA1WNhcJPC9LYy45oZhLQnX7VQIgF0Uithmns7Z4swt9/+vYD19KSKNA/t3NFbx2hVNkgbyFNhZTAbMM8i1cq/opSqoOYr+BLobKdciZ6RW0kWQvYEAZnP+k+q2wXdg37NXA8Qk/303QQEP2n8gl4iPm5Xu0p4a+Q4KwZOyEOAqpKMV07iGNkkVK1qq5MRWsgctBI1/1ings55XTI58dX1/ykYfZPPnE1bzGsrDtIha60XT/xQgZyzCLgWkbyVA6W3hz2dckSQfn1UXKkvI7nS8GIxmDtOOuXaXjaRAT7n6dMuyeZ/2m8uGflddFVD4m2VNsl0ORxBPjzoe7eEpuKAVRbYQ9cEFGAaDVPYwZ9hb1ZJHVD7Do0IDWvrXSp3xdvmQxxFGzSdY84DB6fBjf2WkZUXkFI0hv4+TWddBAYUkPpIDtNGSTy7hWvPHPhaIMAt5fT6jyepqyAyF/Oa4zNpIy8UMCiZKpuPshLFCbMniIMdxK28xxH4UgKGXKpYAtz X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 11:33:28.3439 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db4011d6-2d03-44af-cc59-08d9a8f4e8fc X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6325 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,sami.mujawar@arm.com X-Gm-Message-State: xXdaHBcjMm2C6gyhneGl6fBux1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637062418; bh=qwLatq7VoZUT319iCfrNOgc4KTQka/ge1qPPs7Z0O1c=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=QCMKZd1cQvAV4dqtl6+1OZ7dr3CRyMLeboNMPW6NI86ErTmMpbvFe06VKNCPqJFkG4M Sr+u/gOWMc6XT0liU7EnIieGgZ4Qs1ONXZxcyC8E0of7VUMQycOD53lJHf0rptHZ9NNHo dtX/1GffN/9ZXWhDq/hFBYSI8mv9nOsPZsc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637062419550100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) Rename RdRandGenerateEntropy() to GenerateEntropy() to provide a common interface to generate entropy on other architectures. Also move the definition to RngDxeInternals.h Signed-off-by: Sami Mujawar --- Notes: v2: - No code change since v1. Re-sending with V2 series. [SAMI] SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c | 13 ++++-- SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.h | 43 ----------= ---------- SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 6 ++- SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf | 1 - SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h | 19 +++++++++ 5 files changed, 33 insertions(+), 49 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c index 83025a47d43d442bfe1c324eda2916e6b5599a7e..0ee99a8661fc20094daef019a2f= 8015597073be4 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.c @@ -1,15 +1,22 @@ /** @file - Support routines for RDRAND instruction access. + Support routines for RDRAND instruction access, which will leverage + Intel Secure Key technology to provide high-quality random numbers for u= se + in applications, or entropy for seeding other random number generators. + Refer to http://software.intel.com/en-us/articles/intel-digital-random-n= umber + -generator-drng-software-implementation-guide/ for more information abou= t Intel + Secure Key technology. =20 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ +#include +#include #include +#include =20 #include "AesCore.h" -#include "RdRand.h" #include "RngDxeInternals.h" =20 /** @@ -87,7 +94,7 @@ RdRandGetSeed128 ( **/ EFI_STATUS EFIAPI -RdRandGenerateEntropy ( +GenerateEntropy ( IN UINTN Length, OUT UINT8 *Entropy ) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.h b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.h deleted file mode 100644 index 072378e062e7bee81a7e763fe9b4ed4517e4d82c..000000000000000000000000000= 0000000000000 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RdRand.h +++ /dev/null @@ -1,43 +0,0 @@ -/** @file - Header for the RDRAND APIs used by RNG DXE driver. - - Support API definitions for RDRAND instruction access, which will levera= ge - Intel Secure Key technology to provide high-quality random numbers for u= se - in applications, or entropy for seeding other random number generators. - Refer to http://software.intel.com/en-us/articles/intel-digital-random-n= umber - -generator-drng-software-implementation-guide/ for more information abou= t Intel - Secure Key technology. - -Copyright (c) 2013, Intel Corporation. All rights reserved.
-(C) Copyright 2015 Hewlett Packard Enterprise Development LP
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef __RD_RAND_H__ -#define __RD_RAND_H__ - -#include -#include -#include -#include -#include - -/** - Generate high-quality entropy source through RDRAND. - - @param[in] Length Size of the buffer, in bytes, to fill with. - @param[out] Entropy Pointer to the buffer to store the entropy da= ta. - - @retval EFI_SUCCESS Entropy generation succeeded. - @retval EFI_NOT_READY Failed to request random data. - -**/ -EFI_STATUS -EFIAPI -RdRandGenerateEntropy ( - IN UINTN Length, - OUT UINT8 *Entropy - ); - -#endif // __RD_RAND_H__ diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c index d0e6b7de06352b6a92a823681eab92b7a4ca720f..2009f95b4cadb07fc9073c3c066= 0cf549965422a 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c @@ -20,7 +20,9 @@ =20 **/ =20 -#include "RdRand.h" +#include +#include + #include "RngDxeInternals.h" =20 /** @@ -88,7 +90,7 @@ RngGetRNG ( return EFI_INVALID_PARAMETER; } =20 - Status =3D RdRandGenerateEntropy (RNGValueLength, RNGValue); + Status =3D GenerateEntropy (RNGValueLength, RNGValue); return Status; } =20 diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/Security= Pkg/RandomNumberGenerator/RngDxe/RngDxe.inf index f3300971993f7c6fcdca441858de4c2fb35912e8..ef5cd73273e68c67bec7411279b= b8433c45ab2d4 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf @@ -36,7 +36,6 @@ [Sources.common] [Sources.IA32, Sources.X64] Rand/RngDxe.c Rand/RdRand.c - Rand/RdRand.h Rand/AesCore.c Rand/AesCore.h =20 diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h b/S= ecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h index 2660ed5875e0d52a6b9d806341431859374b1047..34886adcf549efdedc1a7b8f16b= 81a5148531de2 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h @@ -10,6 +10,8 @@ #ifndef RNGDXE_INTERNALS_H_ #define RNGDXE_INTERNALS_H_ =20 +#include + /** Returns information about the random number generation implementation. =20 @@ -114,4 +116,21 @@ RngGetBytes ( OUT UINT8 *RandBuffer ); =20 +/** + Generate high-quality entropy source using a TRNG or through RDRAND. + + @param[in] Length Size of the buffer, in bytes, to fill with. + @param[out] Entropy Pointer to the buffer to store the entropy da= ta. + + @retval EFI_SUCCESS Entropy generation succeeded. + @retval EFI_NOT_READY Failed to request random data. + +**/ +EFI_STATUS +EFIAPI +GenerateEntropy ( + IN UINTN Length, + OUT UINT8 *Entropy + ); + #endif // RNGDXE_INTERNALS_H_ --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=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 (#83780): https://edk2.groups.io/g/devel/message/83780 Mute This Topic: https://groups.io/mt/87092740/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- From nobody Thu Apr 18 17:30:37 2024 Delivered-To: importer@patchew.org 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+83781+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637062422208680.4305126576185; Tue, 16 Nov 2021 03:33:42 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id zC0pYY1788612xCRrjTQVGDT; Tue, 16 Nov 2021 03:33:41 -0800 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.70]) by mx.groups.io with SMTP id smtpd.web09.8739.1637062420217431990 for ; Tue, 16 Nov 2021 03:33:40 -0800 X-Received: from AM6P195CA0060.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::37) by DBBPR08MB4476.eurprd08.prod.outlook.com (2603:10a6:10:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Tue, 16 Nov 2021 11:33:24 +0000 X-Received: from AM5EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:87:cafe::2c) by AM6P195CA0060.outlook.office365.com (2603:10a6:209:87::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Tue, 16 Nov 2021 11:33:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+83781+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT011.mail.protection.outlook.com (10.152.16.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:23 +0000 X-Received: ("Tessian outbound dbb52aec1fa6:v110"); Tue, 16 Nov 2021 11:33:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 67b9317c91f8021f X-CR-MTA-TID: 64aa7808 X-Received: from ffff9a5acdf2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EFAF0FB6-72A7-4E0A-B2E1-A8773F069024.1; Tue, 16 Nov 2021 11:33:15 +0000 X-Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ffff9a5acdf2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Nov 2021 11:33:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TQskKhAwoTcwvQNyfIzGl45CPhG2U4GlzFHVHNvNk7a0U0BBA1aEvS070YuZ0RFmGgoFwkyqdpJYKlnzjRI3HiUXZevsdXTXEOu2jBGcDZvDebHRSFkWKrhziKeLrInVhWsQpKPO1BDXGBotOECwKYEOWZoCPym5MJcbKNHaXbijWievCTNkLSxo2UZ3vqtjXeQNCdhjLZYUtegWKPABFWDsoDPLNClGIrr1O4hWlOHRqegpKZCNo7N6W2sVe2OCTC1bxrnVB9x1Vut1fUFgzPqUjMRNZJDg0PnQwyJ6DVWKoyEN+xVrXL6ikjvuY8BlPglCr97LJ3z5MUDveqTVsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mvP8MHYfH6H/tBRGvDjVFxYu65a8Pf1CzOmqd15FsRA=; b=AYGq7OZ3ZqdEyDgfvGU8uB3rfHLcx8E/laRZ3QHKKWGoKjuuahke0ss5ZyYdkTRFS1ZmtLea33ZN6B1d9RlSCdAdn5++hFU+35+C2Aalqfb20ehRaPLthA+5uvn4B/ybNq6GMGBAceaJn1CS+zeW6kLplB2rvwd2tFV6QIqivPgH1LP/nPy168hT/aiuIhnqqTE1nqXuw3Nvc25Wjznq2ahjHjGqSQ0x6+iK6VstFwZ+Yc5iT3W1a3uU6SO/dhC2afUXi92LHjqNV7L9pVF9KDt9RTwR9+e0OCIDw7LtWzxCbyINvlJ7BKWSP3ZcY1OJroVd/O6IaL/W5/67ZnmxKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AS9PR05CA0038.eurprd05.prod.outlook.com (2603:10a6:20b:489::25) by VI1PR08MB3424.eurprd08.prod.outlook.com (2603:10a6:803:88::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Tue, 16 Nov 2021 11:33:09 +0000 X-Received: from VE1EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:489:cafe::54) by AS9PR05CA0038.outlook.office365.com (2603:10a6:20b:489::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Tue, 16 Nov 2021 11:33:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT029.mail.protection.outlook.com (10.152.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:09 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 16 Nov 2021 11:32:56 +0000 X-Received: from E114225.Arm.com (10.1.196.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 16 Nov 2021 11:32:55 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v2 6/8] SecurityPkg: Restructure checks in RngGetInfo Date: Tue, 16 Nov 2021 11:32:58 +0000 Message-ID: <20211116113301.31088-7-sami.mujawar@arm.com> In-Reply-To: <20211116113301.31088-1-sami.mujawar@arm.com> References: <20211116113301.31088-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4019b80-dc5d-4e5a-98ce-08d9a8f4e640 X-MS-TrafficTypeDiagnostic: VI1PR08MB3424:|DBBPR08MB4476: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3276;OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Xy8SFjJ5oHVgs9pBUKUvv6t0jLibdTCjh63zOnAc/Czda1ppBRniM1nQx/eQ2jHhip0Twg9+GCfMvkGdIDSD4ZkjsVU7PPNqNpi/QwJFR2Ru1pxnKztUgE/zjSzrKcSI7W4wsYZ3Pccq4Vv2jH5iBOFbGcnq3/0JqPp5vKxs/jD9ciac9GvgFpoSaSyZ19RplrD2czsapPMIRNAn6IlHhgu1EKQU00ZMf3mfe9y6Eh+H/YkN4jcvWvWaDNZt/+0JeNLOH4JWSQ/sBk9tvcMlZI57zsur6/rfRP6IeYwJ1+20KJeRsKVEHjtaiHKHCvah3fe95dQCSoKNp+zS+uenvkjMrNhZvcqvtvi1PAUc7T1qvNYYZui9ku0AjObz1r+fWcYG4a7C+7O+/l3cG9ctsusPlD9navIrKQvVhxnxglgjQt6+ZsZqpO5JTLFvx6D6hjFLj6PwgNj+deJ6RDWFo7sEaj8o5vu7TNjAT4UttXxB5F/6Nz0M0DMjjOlgnDiBl4z3ieOIShXjrIiKdvsePs0qgxaHR1YibNx8GLhOMIm4LfPsF6RK28VY1sFaoevXx1yyrxuTDjiMm9S1324faIRoPOoIyOSVa/+Y1Y+Z0F9Gj5q32mX5XyDunmz5rhCdVk/utTOlzyxWZvlpQHBSMSdyrMdSUZZveW1yUBYQN7hIYMZxNNxYMrM2zCZ5RVT7Cmx28jFBmEumcsuwdJFTh0QgtNbzRh+b+m4nfM+ER5EUxzC14cFhqr++EY3AeUvewgYq7DiBsZXxKMbTBHO2msrpWd45qc45VV6ToRHC4S3JS51lFPil/cIxd5RClZX/ X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(36860700001)(7696005)(336012)(44832011)(81166007)(36756003)(86362001)(4326008)(426003)(8676002)(5660300002)(2906002)(15650500001)(2616005)(6916009)(26005)(47076005)(7416002)(316002)(82310400003)(1076003)(70206006)(54906003)(356005)(70586007)(8936002)(508600001)(83380400001)(186003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3424 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4d0ceda0-8bd6-487f-cca6-08d9a8f4dd9f X-Microsoft-Antispam-Message-Info: CUOpNddlTn+or7fP8b+bDivM3+mypt2ZlrjCbfCNz2k31/Kc2lgQJUpujt6rYv3bz0ByWhAZDLHEfSnJlBp1shFvtQVohcaOsTuOEOvBaV63VfsCttqOPk1yCC6PbI0cET3exmrqoLD2KUGIrzSwB9cPqGsA2klpPm9V2KGfB1zhGKPXBomfXdFaP6AhuwlXBGaL+1zLqipUeA508nRx9jCB7QQ5sQZm8ocCWL16jS0CIZ+La53iW2YfmE+ZtA+Sul1AQh4hxe+/qZwT+kqY22p1xVkdJ0ooMEedkgZY0uRKP2+xGb6wsnSXJmkFoAiGmfCGhwfsNCRAPPN93ryy1i7zAkBz0FiNYMgahgTKdSH/XgRJNXF/baxBcmu3npP3jtDenB1SZBqLxmv8rFzbYuZbNM2ZsRV87BXKgFd+ovCsFUVy9xXH7QF90KOfsrgxdj8JX3fNhiE2QlX1rosCfuzvCG6SWxReGlfWuQGPUvU6rv47ndxI2BC9FrWgjr4Uq2E9H0bZHiF/TULjNpAH1Po2M/rUMvwy9eITw/BFmlKJ25vCbvPfyfrjLM4QJ6P/ncrI9t9+GX/vVQ1e+wYhJxKxqYVxemxR7F/oxOdbAr/DNrYqOgk+P5XIc/wpS+ssgs3ymhxvvq4UsAcp1gAIzfzlvaUn9oD2rqqw0LA8+Ce+wGHF1SyT2NkwBYKNmSDlIjcUo7Jhx6MliitzYVM0FjwFNaSEaDvKs6bd4qBL2aAvwt+5Xcn3c68g/50KS2NwuzsvTUiITu/1PPc1iq7nH6gKmQRUaQKNgrOqShuDx5M= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 11:33:23.7505 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4019b80-dc5d-4e5a-98ce-08d9a8f4e640 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4476 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,sami.mujawar@arm.com X-Gm-Message-State: HmZ3JY8ytz2lnEHwd2myR4Mkx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637062421; bh=nJv3qNzPzceD3dv8R/8im69zEVoBu8FgplccIfP445s=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=dKix3W5lg5uZpYyBLjlNzyGt9kn9GcKl7EUOK+obG4d6BRR4Hg90sEP2wk2ttOfI2Wo 9HwnKTsJFmD1Da5/LUFuWwLmiKE3WD1URK1mAtvROl1Ehm75rIGgq90WxJtY3zn+FEG1U 8KIjqy0LpcXhV5sL59aMtpNeyXE83YbZ9gY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637062423855100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) Move the check to see if the RNGAlgorithmList pointer is NULL to ArchGetSupportedRngAlgorithms(). This allows the caller to obtain the buffer size required to store the Algorithm List by passing RNGAlgorithmListSize as zero and RNGAlgorithmList as NULL. Signed-off-by: Sami Mujawar --- Notes: v2: - No code change since v1. Re-sending with V2 series. [SAMI] SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 6 ++++++ SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c | 11 ++--------- SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/Secur= ityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c index 2009f95b4cadb07fc9073c3c0660cf549965422a..f1122a48102595506cc423c3ab5= 01d9a72f50543 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c @@ -16,6 +16,7 @@ =20 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -116,6 +117,7 @@ RngGetRNG ( =20 @retval EFI_SUCCESS The RNG algorithm list was returned = successfully. @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too s= mall to hold the result. + @retval EFI_INVALID_PARAMETER The pointer to the buffer RNGAlgorit= hmList is invalid. =20 **/ UINTN @@ -135,6 +137,10 @@ ArchGetSupportedRngAlgorithms ( return EFI_BUFFER_TOO_SMALL; } =20 + if (RNGAlgorithmList =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + CpuRngSupportedAlgorithm =3D PcdGetPtr (PcdCpuRngSupportedAlgorithm); =20 CopyMem(&RNGAlgorithmList[0], CpuRngSupportedAlgorithm, sizeof (EFI_RNG_= ALGORITHM)); diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/SecurityPk= g/RandomNumberGenerator/RngDxe/RngDxe.c index b959c70536ea3b9049905bbfd3d973fc9b2f6dcf..2e3b714bc691e4e517866369c03= 4b721fbccfa24 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c @@ -14,6 +14,7 @@ =20 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2021, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -59,8 +60,6 @@ RngGetInfo ( OUT EFI_RNG_ALGORITHM *RNGAlgorithmList ) { - EFI_STATUS Status; - if ((This =3D=3D NULL) || (RNGAlgorithmListSize =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } @@ -68,13 +67,7 @@ RngGetInfo ( // // Return algorithm list supported by driver. // - if (RNGAlgorithmList !=3D NULL) { - Status =3D ArchGetSupportedRngAlgorithms (RNGAlgorithmListSize, RNGAlg= orithmList); - } else { - Status =3D EFI_INVALID_PARAMETER; - } - - return Status; + return ArchGetSupportedRngAlgorithms (RNGAlgorithmListSize, RNGAlgorithm= List); } =20 // diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h b/S= ecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h index 34886adcf549efdedc1a7b8f16b81a5148531de2..37c27c4094e5302dfe2e7d9bbee= f33a24b0c73ea 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h @@ -90,7 +90,7 @@ RngGetRNG ( =20 @retval EFI_SUCCESS The RNG algorithm list was returned = successfully. @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too s= mall to hold the result. - + @retval EFI_INVALID_PARAMETER The pointer to the buffer RNGAlgorit= hmList is invalid. **/ UINTN EFIAPI --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=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 (#83781): https://edk2.groups.io/g/devel/message/83781 Mute This Topic: https://groups.io/mt/87092741/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- From nobody Thu Apr 18 17:30:37 2024 Delivered-To: importer@patchew.org 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+83778+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637062410060348.5141530075506; Tue, 16 Nov 2021 03:33:30 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id lIgOYY1788612x3oMQOnypPU; Tue, 16 Nov 2021 03:33:29 -0800 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.59]) by mx.groups.io with SMTP id smtpd.web10.8754.1637062408518693623 for ; Tue, 16 Nov 2021 03:33:29 -0800 X-Received: from AM9P193CA0011.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::16) by AM4PR0802MB2291.eurprd08.prod.outlook.com (2603:10a6:200:5e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 11:33:25 +0000 X-Received: from VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:21e:cafe::80) by AM9P193CA0011.outlook.office365.com (2603:10a6:20b:21e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Tue, 16 Nov 2021 11:33:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+83778+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT048.mail.protection.outlook.com (10.152.19.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:24 +0000 X-Received: ("Tessian outbound c61f076cbd30:v110"); Tue, 16 Nov 2021 11:33:24 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0900c155886d1757 X-CR-MTA-TID: 64aa7808 X-Received: from 050cd6d199f3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CE57262B-BE7C-418A-BC44-E4CB9F0F5D15.1; Tue, 16 Nov 2021 11:33:15 +0000 X-Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 050cd6d199f3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Nov 2021 11:33:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JnPv0E99h3+4aRzhE+sKadlUt19snXOaaNUbDKrU8cUuKq3SkpW368rsNovq+c51UvUdjmA7u57lBD4bd//RoY80rPqqQUBvg5aFl/5bVDRfAJ33qm8/g6LlizJ7Oh0vmxhqnlK7YBoEZUysprpdHyF73cmDh9ivaV5iFPA5KwZwGdrla2IYi40DyNPhXbljuqMoJ7n/rRvAlN7EfeHKtATu50/v34w8IbnxNViZvMt90OWpYmKubocXUJjqWOWBFNObRlKReLP00qzRWfBlSUB3crMuugvZPUPhBkJ7zphLAJRko97ITQ4WFtdrBF5I3cKBVmmenJtnaYecQgKcDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LdtEmakL7VobbuelFHSGht6ks1rDOhx5+LTqhguCXak=; b=kg02rRkO0b5GZMhd+OwiQPR8Kje9zq0mlpRI9jhZzq5KgrSzUkgBBsYla92HGuJzNQVWouCHihbfo/wI5q+iBZ4DljMeP+rZYkr4j2LcOtsB24F+mTAVC0azYzDO8v9eTyfYldT/qsoPXmhGis9gQ2QI4y1QtLT3qreM4snN1fA2acncApEaI1KOPsziECkeo70NDQo53pOYVbWzf8dt1f73ypXeXvUeAimtGAN+Nu3eHvT/0E8t/pP2zWrbM94RA4kC8ybLhcz8qXJpTdVxBE/BpjhVumMyXMKDasY8TPXZyjUh1yqu+JRbZZ/GSoM0LqumFjEa0DCvysCvhzGsCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AS9PR05CA0040.eurprd05.prod.outlook.com (2603:10a6:20b:489::23) by AM0PR08MB4355.eurprd08.prod.outlook.com (2603:10a6:208:13a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 11:33:12 +0000 X-Received: from VE1EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:489:cafe::48) by AS9PR05CA0040.outlook.office365.com (2603:10a6:20b:489::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Tue, 16 Nov 2021 11:33:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT029.mail.protection.outlook.com (10.152.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:12 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 16 Nov 2021 11:32:56 +0000 X-Received: from E114225.Arm.com (10.1.196.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 16 Nov 2021 11:32:56 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v2 7/8] SecurityPkg: Add RawAlgorithm support using TRNG library Date: Tue, 16 Nov 2021 11:32:59 +0000 Message-ID: <20211116113301.31088-8-sami.mujawar@arm.com> In-Reply-To: <20211116113301.31088-1-sami.mujawar@arm.com> References: <20211116113301.31088-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5f2dc340-5571-4156-5b99-08d9a8f4e697 X-MS-TrafficTypeDiagnostic: AM0PR08MB4355:|AM4PR0802MB2291: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: aeRWvfI/uB0WopLLxh99Dk4TBPbIqGmFyuqbXHJqtKmkUn78Zruezz9e4OpJNyJXsD+ko+5nWH14RoBw/95EzT0G7F3rfqNOMj8YZx6TKrPUitBdzeEfi/3RqlpmV2/Wo4QYxTm51FyU+CZl3DJGP7GBMiVI2WbQ10jCv6Q0xG6eUWTr3X6bmWSyuqes9jZ4NkNC/mTI+8nLVtQ/BIWjZVWNf9PZ+vnBqZExjwjXMGso0tOICPVBM0xl/SV/b8EWX1NW5HaE0EeO7t8JAIDhQ2qvi1bYr+otPEImilft/Y7hCIHnnW+e6OUbxtb9pG129+HBOcs6JlHVuRJp3nfXNUWWI4vPIby+2gMCdVCrgJmay9nYF+7PIZPK9obMq3jigHtGTtoFxpaZTxT+aYIjOhwvZyhcG6Is98mMLFWZtghuHJugc8J0aTlWXSMP6rd/EAZwA7iWQhUsYvOWZb2fS3QUX0d9TgS9j+6xuO+6+JJw7+P/9PvZo1jsZkh1Q7h9tQC5MuQ0AWrIj0rnVsdXuem51tZByGS44OD473UKhpCM7wRtTtBkxuf48TXCilFpMjraEP4j98d6I01NG1T2Xl9il7/WLZX9Ouwy13Qj9lHqbZgawDWuSlGc5aPnrDsnVCrvV4xu/z+USg4dHUGOL327IPflGBDmMBMgCsw3QGTS76ezAKC6MFpTPwIsjNDS8FJCQzdqq2ElOpNlkCEImQZiE1mfSXC9Hxqfo8y51HO+RSQbwJD9WESxTvMcYTyeQucWrs02wh1yRBgjCik1O/pq6+vGQw65oKsQcD290OlL9KVmJ+46JXO+lqHqGhUG X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(83380400001)(19627235002)(54906003)(7416002)(186003)(8676002)(6916009)(82310400003)(316002)(44832011)(30864003)(2616005)(26005)(36860700001)(426003)(8936002)(336012)(15650500001)(356005)(508600001)(47076005)(1076003)(5660300002)(81166007)(4326008)(86362001)(2906002)(7696005)(36756003)(70206006)(70586007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4355 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 13385be7-d5c5-44e6-1ad2-08d9a8f4df80 X-Microsoft-Antispam-Message-Info: t5Xy6eVLQYiEoIHp3cJWcJN6UAg/9EIkEmSRbBK7BM6NXydPao58foFw8O+n+WzC5yIOZNfBjiDBFBY+2aAf68QtusQKSpqLNu7nWZdr7hcMqyNMBoAaZRPWr9JLewPPmPY3tKKw5E1ttTYePwfHuanFZ4SZgt2bvfGOXDzJHCrLR0nxwdBPen8YyoQXf/pp91fRFzsyamlw04ISyjUzuN3Pd8JbW0BNcj/eAqbQUoTJ35fcaB1yKJzHWsdnuXOJuhITm0BoCj/Oh5SvRDQ9n16iudW1vo80JaypdR4lCy8EGf0dtfjT2isExoUKRweewIhwi/jzIiJHeynvn+8dx0pbOmZBZeQe//Y0Z2Jz5uThXx6+tLa5wQAz1ZSvfCP/Gltz2LgVgoQTM/2aGVLQqWFzciWqe71ypARMiTg35jpd3moPlKKCo6gST16Tstt2folUcMA9Z8w5Exe1I+Bad2HgzdEgAliWjWs63E2GPRglvVcSmNvdNN8n07forM3QbIqd+n8rQUuOcX5n43vDmt0+GC5Wmdu1HbmB0K27b6sPyxI7CI5QnLLZLnZKtlL552UKfGzdkaci2q2oH1mhzZ1fkl5UEl3+oxsyI57RWSuS1SewMZC/1QULRgUtkK8QiRhlj1Rni6ljLcHooylgQgRn/dTOjMgFcO7WN7lxmvjwT/qXmS9RS+cgn71UKsts2EGNmJYXGvV2kbfNIBs+VBvdefNcOVuCc//+CJYje4W3P7A/NjiawCvCUjolryipih1y4xpW2WeLgSzDD6pCh+M4/dh7duhibtMl5Y2T11U= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 11:33:24.2382 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f2dc340-5571-4156-5b99-08d9a8f4e697 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0802MB2291 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,sami.mujawar@arm.com X-Gm-Message-State: gkLVhS0Ekc2NNPTwG6Wod9q7x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637062409; bh=cu6wYxPcxsHNeJaz3NoeUYVCwgUqszuAniLp1Hmd074=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Vkari/Gl7f2rptnPRarqvP4iOz1+F24iRMnaH8aOj/5jPnKv63mBi8Ul3mqPhNBNNDh 3Q1jVNxvRxHB60g22ePc4gN6xHGQdghHiAeDheS/fDjdD4T2uFMfR8bmoc8G8EVM1H5Wk tpwPyYtEUI2ecfy0+M9pwCW7k1zHsS/oIK4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637062410832100007 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) RawAlgorithm is used to provide access to entropy that is suitable for cryptographic applications. Therefore, add RawAlgorithm support that provides access to entropy using the TRNG library interface. Signed-off-by: Sami Mujawar --- Notes: v2: - MdeModulePkg\Include\Guid\ZeroGuid.h has defined [LIMING] gZeroGuid. You don't define it again. - Replaced use of gNullGuid with gZeroGuid. [SAMI] SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c | 79 ++++++++-- SecurityPkg/RandomNumberGenerator/RngDxe/Arm/RngDxe.c | 163 +++++++++= +++++++++++ SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c | 61 ++++++++ SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c | 2 +- SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf | 13 +- SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h | 1 + SecurityPkg/SecurityPkg.dsc | 8 +- 7 files changed, 314 insertions(+), 13 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/Se= curityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c index 282fdca9d334b77e02ca47734df08729e0f4fd31..d1c8f4c69b4d65c10141da320d4= 4cd8f01bb0c74 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c @@ -1,11 +1,12 @@ /** @file RNG Driver to produce the UEFI Random Number Generator protocol. =20 - The driver will use the RNDR instruction to produce random numbers. + The driver will use the RNDR instruction to produce random numbers. It a= lso + uses the Arm FW-TRNG interface to implement EFI_RNG_ALGORITHM_RAW. =20 RNG Algorithms defined in UEFI 2.4: - EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID - - EFI_RNG_ALGORITHM_RAW - Unsupported + - EFI_RNG_ALGORITHM_RAW - EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID - EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID - EFI_RNG_ALGORITHM_X9_31_3DES_GUID - Unsupported @@ -14,15 +15,17 @@ Copyright (c) 2021, NUVIA Inc. All rights reserved.
Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2021, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 +#include #include #include -#include -#include +#include +#include #include =20 #include "RngDxeInternals.h" @@ -58,7 +61,9 @@ RngGetRNG ( OUT UINT8 *RNGValue ) { - EFI_STATUS Status; + EFI_STATUS Status; + UINT16 MajorRevision; + UINT16 MinorRevision; =20 if ((RNGValueLength =3D=3D 0) || (RNGValue =3D=3D NULL)) { return EFI_INVALID_PARAMETER; @@ -76,6 +81,17 @@ RngGetRNG ( return Status; } =20 + // + // The "raw" algorithm is intended to provide entropy directly + // + if (CompareGuid (RNGAlgorithm, &gEfiRngAlgorithmRaw)) { + Status =3D GetTrngVersion (&MajorRevision, &MinorRevision); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + return GenerateEntropy (RNGValueLength, RNGValue); + } + // // Other algorithms are unsupported by this driver. // @@ -97,8 +113,9 @@ RngGetRNG ( is the default algorithm for the dri= ver. =20 @retval EFI_SUCCESS The RNG algorithm list was returned = successfully. + @retval EFI_UNSUPPORTED No supported algorithms found. @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too s= mall to hold the result. - + @retval EFI_INVALID_PARAMETER The pointer to the buffer RNGAlgorit= hmList is invalid. **/ UINTN EFIAPI @@ -107,19 +124,61 @@ ArchGetSupportedRngAlgorithms ( OUT EFI_RNG_ALGORITHM *RNGAlgorithmList ) { - UINTN RequiredSize; + EFI_STATUS Status; + UINT16 MajorRevision; + UINT16 MinorRevision; + UINTN RequiredSize; + BOOLEAN CpuRngAlgorithmSupported; + BOOLEAN RawAlgorithmSupported; + UINTN Index; EFI_RNG_ALGORITHM *CpuRngSupportedAlgorithm; =20 - RequiredSize =3D sizeof (EFI_RNG_ALGORITHM); + RequiredSize =3D 0; + CpuRngAlgorithmSupported =3D FALSE; + RawAlgorithmSupported =3D FALSE; + + CpuRngSupportedAlgorithm =3D PcdGetPtr (PcdCpuRngSupportedAlgorithm); + if (!CompareGuid (CpuRngSupportedAlgorithm, &gZeroGuid)) { + CpuRngAlgorithmSupported =3D TRUE; + RequiredSize +=3D sizeof (EFI_RNG_ALGORITHM); + } + + Status =3D GetTrngVersion (&MajorRevision, &MinorRevision); + if (!EFI_ERROR (Status)) { + RawAlgorithmSupported =3D TRUE; + RequiredSize +=3D sizeof (EFI_RNG_ALGORITHM); + } =20 if (*RNGAlgorithmListSize < RequiredSize) { *RNGAlgorithmListSize =3D RequiredSize; return EFI_BUFFER_TOO_SMALL; } =20 - CpuRngSupportedAlgorithm =3D PcdGetPtr (PcdCpuRngSupportedAlgorithm); + if (RequiredSize =3D=3D 0) { + // No supported algorithms found. + return EFI_UNSUPPORTED; + } =20 - CopyMem(&RNGAlgorithmList[0], CpuRngSupportedAlgorithm, sizeof (EFI_RNG_= ALGORITHM)); + if (RNGAlgorithmList =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Index =3D 0; + if (CpuRngAlgorithmSupported) { + CopyMem ( + &RNGAlgorithmList[Index++], + CpuRngSupportedAlgorithm, + sizeof (EFI_RNG_ALGORITHM) + ); + } + + if (RawAlgorithmSupported) { + CopyMem ( + &RNGAlgorithmList[Index++], + &gEfiRngAlgorithmRaw, + sizeof (EFI_RNG_ALGORITHM) + ); + } =20 *RNGAlgorithmListSize =3D RequiredSize; return EFI_SUCCESS; diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/RngDxe.c b/Securi= tyPkg/RandomNumberGenerator/RngDxe/Arm/RngDxe.c new file mode 100644 index 0000000000000000000000000000000000000000..cba9883e50cefbb22495190d17d= e99bfeab33cf3 --- /dev/null +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/RngDxe.c @@ -0,0 +1,163 @@ +/** @file + RNG Driver to produce the UEFI Random Number Generator protocol. + + The driver implements the EFI_RNG_ALGORITHM_RAW using the FW-TRNG + interface to provide entropy. + + RNG Algorithms defined in UEFI 2.4: + - EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID + - EFI_RNG_ALGORITHM_RAW + - EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID + - EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID + - EFI_RNG_ALGORITHM_X9_31_3DES_GUID - Unsupported + - EFI_RNG_ALGORITHM_X9_31_AES_GUID - Unsupported + + Copyright (c) 2021, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +#include "RngDxeInternals.h" + +/** + Produces and returns an RNG value using either the default or specified + RNG algorithm. + + @param[in] This A pointer to the EFI_RNG_PROTOCOL inst= ance. + @param[in] RNGAlgorithm A pointer to the EFI_RNG_ALGORITHM that + identifies the RNG algorithm to use. M= ay be + NULL in which case the function will u= se its + default RNG algorithm. + @param[in] RNGValueLength The length in bytes of the memory buff= er + pointed to by RNGValue. The driver sha= ll + return exactly this numbers of bytes. + @param[out] RNGValue A caller-allocated memory buffer fille= d by + the driver with the resulting RNG valu= e. + + @retval EFI_SUCCESS The RNG value was returned successfull= y. + @retval EFI_UNSUPPORTED The algorithm specified by RNGAlgorith= m is + not supported by this driver. + @retval EFI_DEVICE_ERROR An RNG value could not be retrieved du= e to + a hardware or firmware error. + @retval EFI_NOT_READY There is not enough random data availa= ble + to satisfy the length requested by + RNGValueLength. + @retval EFI_INVALID_PARAMETER RNGValue is NULL or RNGValueLength is = zero. + +**/ +EFI_STATUS +EFIAPI +RngGetRNG ( + IN EFI_RNG_PROTOCOL *This, + IN EFI_RNG_ALGORITHM *RNGAlgorithm, OPTIONAL + IN UINTN RNGValueLength, + OUT UINT8 *RNGValue + ) +{ + EFI_STATUS Status; + UINT16 MajorRevision; + UINT16 MinorRevision; + + if ((RNGValueLength =3D=3D 0) || (RNGValue =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + if (RNGAlgorithm =3D=3D NULL) { + // + // Use the default RNG algorithm if RNGAlgorithm is NULL. + // + RNGAlgorithm =3D &gEfiRngAlgorithmRaw; + } + + // + // The "raw" algorithm is intended to provide entropy directly + // + if (CompareGuid (RNGAlgorithm, &gEfiRngAlgorithmRaw)) { + Status =3D GetTrngVersion (&MajorRevision, &MinorRevision); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + return GenerateEntropy (RNGValueLength, RNGValue); + } + + // + // Other algorithms are unsupported by this driver. + // + return EFI_UNSUPPORTED; +} + +/** + Returns information about the random number generation implementation. + + @param[in,out] RNGAlgorithmListSize On input, the size in bytes of + RNGAlgorithmList. + On output with a return code of + EFI_SUCCESS, the size in bytes of the + data returned in RNGAlgorithmList. + On output with a return code of + EFI_BUFFER_TOO_SMALL, the size of + RNGAlgorithmList required to obtain = the + list. + @param[out] RNGAlgorithmList A caller-allocated memory buffer fil= led + by the driver with one EFI_RNG_ALGOR= ITHM + element for each supported RNG algor= ithm. + The list must not change across mult= iple + calls to the same driver. The first + algorithm in the list is the default + algorithm for the driver. + + @retval EFI_SUCCESS The RNG algorithm list was returned + successfully. + @retval EFI_UNSUPPORTED No supported algorithms found. + @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too s= mall + to hold the result. + @retval EFI_INVALID_PARAMETER The pointer to the buffer RNGAlgorit= hmList + is invalid. +**/ +UINTN +EFIAPI +ArchGetSupportedRngAlgorithms ( + IN OUT UINTN *RNGAlgorithmListSize, + OUT EFI_RNG_ALGORITHM *RNGAlgorithmList + ) +{ + EFI_STATUS Status; + UINTN RequiredSize; + UINT16 MajorRevision; + UINT16 MinorRevision; + + RequiredSize =3D 0; + + Status =3D GetTrngVersion (&MajorRevision, &MinorRevision); + if (EFI_ERROR (Status)) { + // No supported algorithms found. + return EFI_UNSUPPORTED; + } + + RequiredSize +=3D sizeof (EFI_RNG_ALGORITHM); + + if (*RNGAlgorithmListSize < RequiredSize) { + *RNGAlgorithmListSize =3D RequiredSize; + return EFI_BUFFER_TOO_SMALL; + } + + if (RNGAlgorithmList =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + CopyMem ( + &RNGAlgorithmList[0], + &gEfiRngAlgorithmRaw, + sizeof (EFI_RNG_ALGORITHM) + ); + + *RNGAlgorithmListSize =3D RequiredSize; + return EFI_SUCCESS; +} diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c b/SecurityP= kg/RandomNumberGenerator/RngDxe/ArmTrng.c new file mode 100644 index 0000000000000000000000000000000000000000..8df37d82e2051854f74816711a1= 4ee23472f6b41 --- /dev/null +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c @@ -0,0 +1,61 @@ +/** @file + Arm FW-TRNG interface helper common for AArch32 and AArch64. + + Copyright (c) 2021, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +/** + Generate high-quality entropy source using a TRNG. + + @param[in] Length Size of the buffer, in bytes, to fill with. + @param[out] Entropy Pointer to the buffer to store the entropy da= ta. + + @retval EFI_SUCCESS Entropy generation succeeded. + @retval EFI_NOT_READY Failed to request random data. + +**/ +EFI_STATUS +EFIAPI +GenerateEntropy ( + IN UINTN Length, + OUT UINT8 *Entropy + ) +{ + EFI_STATUS Status; + UINTN CollectedEntropyBits; + UINTN RequiredEntropyBits; + UINTN EntropyBits; + UINTN Index; + UINTN MaxBits; + + ZeroMem (Entropy, Length); + + RequiredEntropyBits =3D (Length << 3); + Index =3D 0; + CollectedEntropyBits =3D 0; + MaxBits =3D GetTrngMaxSupportedEntropyBits (); + while (CollectedEntropyBits < RequiredEntropyBits) { + EntropyBits =3D MIN ((RequiredEntropyBits - CollectedEntropyBits), Max= Bits); + Status =3D GetEntropy ( + EntropyBits, + &Entropy[Index], + (Length - Index) + ); + if (EFI_ERROR (Status)) { + // Discard the collected bits. + ZeroMem (Entropy, Length); + return Status; + } + CollectedEntropyBits +=3D EntropyBits; + Index +=3D (EntropyBits >> 3); + } // while + + return Status; +} diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/SecurityPk= g/RandomNumberGenerator/RngDxe/RngDxe.c index 2e3b714bc691e4e517866369c034b721fbccfa24..b7ac0baf3f8216c9a86029b3037= bfe4fd59269f6 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c @@ -45,7 +45,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent is the default algorithm for the dri= ver. =20 @retval EFI_SUCCESS The RNG algorithm list was returned = successfully. - @retval EFI_UNSUPPORTED The services is not supported by thi= s driver. + @retval EFI_UNSUPPORTED No supported algorithms found. @retval EFI_DEVICE_ERROR The list of algorithms could not be = retrieved due to a hardware or firmware error. @retval EFI_INVALID_PARAMETER One or more of the parameters are in= correct. diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/Security= Pkg/RandomNumberGenerator/RngDxe/RngDxe.inf index ef5cd73273e68c67bec7411279bb8433c45ab2d4..9f2e92512bfa48bd772c7f887a2= 3453756421b80 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf @@ -10,6 +10,7 @@ # # Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
# (C) Copyright 2015 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2021, Arm Limited. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -26,7 +27,7 @@ [Defines] # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 X64 AARCH64 +# VALID_ARCHITECTURES =3D IA32 X64 AARCH64 ARM # =20 [Sources.common] @@ -41,8 +42,14 @@ [Sources.IA32, Sources.X64] =20 [Sources.AARCH64] AArch64/RngDxe.c + ArmTrng.c + +[Sources.ARM] + Arm/RngDxe.c + ArmTrng.c =20 [Packages] + MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec SecurityPkg/SecurityPkg.dec =20 @@ -55,6 +62,9 @@ [LibraryClasses] TimerLib RngLib =20 +[LibraryClasses.AARCH64, LibraryClasses.ARM] + TrngLib + [Guids] gEfiRngAlgorithmSp80090Hash256Guid ## SOMETIMES_PRODUCES ## GUID = # Unique ID of the algorithm for RNG gEfiRngAlgorithmSp80090Hmac256Guid ## SOMETIMES_PRODUCES ## GUID = # Unique ID of the algorithm for RNG @@ -62,6 +72,7 @@ [Guids] gEfiRngAlgorithmX9313DesGuid ## SOMETIMES_PRODUCES ## GUID = # Unique ID of the algorithm for RNG gEfiRngAlgorithmX931AesGuid ## SOMETIMES_PRODUCES ## GUID = # Unique ID of the algorithm for RNG gEfiRngAlgorithmRaw ## SOMETIMES_PRODUCES ## GUID = # Unique ID of the algorithm for RNG + gZeroGuid ## CONSUMES =20 [Protocols] gEfiRngProtocolGuid ## PRODUCES diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h b/S= ecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h index 37c27c4094e5302dfe2e7d9bbeef33a24b0c73ea..8978d54f51d4e72ad881ee584e1= 6dcdda72a66ae 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h @@ -89,6 +89,7 @@ RngGetRNG ( is the default algorithm for the dri= ver. =20 @retval EFI_SUCCESS The RNG algorithm list was returned = successfully. + @retval EFI_UNSUPPORTED No supported algorithms found. @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too s= mall to hold the result. @retval EFI_INVALID_PARAMETER The pointer to the buffer RNGAlgorit= hmList is invalid. **/ diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc index 73a93c2285b13a2e0ce45b08a1230a766e0d759a..63da3d8c92e5a2c559b7731dd6d= c0654caab30b8 100644 --- a/SecurityPkg/SecurityPkg.dsc +++ b/SecurityPkg/SecurityPkg.dsc @@ -3,6 +3,7 @@ # # Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
# (C) Copyright 2015-2020 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2021, Arm Limited. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -86,6 +87,11 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64] =20 ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf =20 + # Arm FW-TRNG interface library. + TrngLib|ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf + ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf + ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf + [LibraryClasses.ARM] RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf =20 @@ -277,7 +283,7 @@ [Components.IA32, Components.X64, Components.ARM, Compo= nents.AARCH64] SecurityPkg/EnrollFromDefaultKeysApp/EnrollFromDefaultKeysApp.inf SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDef= aultKeysDxe.inf =20 -[Components.IA32, Components.X64, Components.AARCH64] +[Components.IA32, Components.X64, Components.AARCH64, Components.ARM] # # Random Number Generator # --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=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 (#83778): https://edk2.groups.io/g/devel/message/83778 Mute This Topic: https://groups.io/mt/87092737/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- From nobody Thu Apr 18 17:30:37 2024 Delivered-To: importer@patchew.org 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+83782+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=arm.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1637062430042201.38892780722108; Tue, 16 Nov 2021 03:33:50 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id rBwQYY1788612x8LasGF3a0F; Tue, 16 Nov 2021 03:33:49 -0800 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.41]) by mx.groups.io with SMTP id smtpd.web11.8744.1637062423182703751 for ; Tue, 16 Nov 2021 03:33:43 -0800 X-Received: from AM6P195CA0038.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::15) by AM6PR08MB4232.eurprd08.prod.outlook.com (2603:10a6:20b:b4::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19; Tue, 16 Nov 2021 11:33:24 +0000 X-Received: from VE1EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:87:cafe::ca) by AM6P195CA0038.outlook.office365.com (2603:10a6:209:87::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Tue, 16 Nov 2021 11:33:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; 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+83782+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT040.mail.protection.outlook.com (10.152.18.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:23 +0000 X-Received: ("Tessian outbound c61f076cbd30:v110"); Tue, 16 Nov 2021 11:33:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 77a241f314c2d2c5 X-CR-MTA-TID: 64aa7808 X-Received: from e3f28bad79e9.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 659C0923-DB4E-406D-9B75-9AA957F783B7.1; Tue, 16 Nov 2021 11:33:16 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e3f28bad79e9.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Nov 2021 11:33:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eR3+4nO5Ov9+0JgQYsCvk4vxzmEVQs/ztmBs/ujFNUBNvlt6WxH91t/Rnb12nc7LLdSaNKh/oZp5nInKqfOr9ViUDzz618nuHbpilEN2Dr2Uu9XhQZi/vtITwliJ5J6lgxauedF8Zu/thIwjnV9U4iJJMcJ5XneB3BMzWoxdfe+Or64aCLKdMW+UYPip3wimr0y7qmic6tBuJH3BzHNFOltOtg0h5KvkgsmHStPs8QoIYCgW0Y2clzmrqnXuodyKyDV9miDudLIZwP4iREVPFzc69tQtLgWyRXFJERmpEAsHzvlYJ7n91hervfzBSUpkigVbfAwo7dr3Nez8P8167w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H/Os2m7GP8X8smU0LQtnTOERqkUDESA0BIXrK5SscNM=; b=dzKiZRJdo1OFftQdo1YKLrEkblaQCrnX1gVOZbkuPc+lONMaJGQq8hdJ4ktS3CBM8yI24y3SLhR3R4/Qpc4KupdH5LxN/502ahUBV7pMETw5e/ru2+zGcMlAMv6pewkPv4NoRQQT/GodZJBFN0PkBGA0jhJT0MxPYmHg7GKAghU8zNp0RJiGiiGJTpfFocK2Y0RDE5c7M/Mpe2JcUXcSmBu5VARRE9DwrbGq3YrtoAvF22LiLf4OUYGV9bwr9ErZNi1OJPnsuk3E9UoaD9FXo2+m42lxlNgxofgshfsQIYdP+jLqjJjNs7uIvgowPvDMXbOo2vtX8ZUvT1misWoTYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AS9PR05CA0052.eurprd05.prod.outlook.com (2603:10a6:20b:489::10) by PA4PR08MB6063.eurprd08.prod.outlook.com (2603:10a6:102:ed::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.16; Tue, 16 Nov 2021 11:33:13 +0000 X-Received: from VE1EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:489:cafe::91) by AS9PR05CA0052.outlook.office365.com (2603:10a6:20b:489::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.19 via Frontend Transport; Tue, 16 Nov 2021 11:33:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT029.mail.protection.outlook.com (10.152.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:13 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 16 Nov 2021 11:32:58 +0000 X-Received: from E114225.Arm.com (10.1.196.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 16 Nov 2021 11:32:57 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v2 8/8] ArmVirtPkg: Kvmtool: Add RNG support using FW-TRNG interface Date: Tue, 16 Nov 2021 11:33:00 +0000 Message-ID: <20211116113301.31088-9-sami.mujawar@arm.com> In-Reply-To: <20211116113301.31088-1-sami.mujawar@arm.com> References: <20211116113301.31088-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 88e4c07b-5271-4853-238e-08d9a8f4e624 X-MS-TrafficTypeDiagnostic: PA4PR08MB6063:|AM6PR08MB4232: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6108;OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: L742mU3PAnulHd//jFZvDiJRXRlGGQGPtoTjtDe60XGM/en5hZTLivBwMljtLiYjfQh85FEXd5axHeNHY6/io5Uy044/V+6duxgoDBdXaaNCWAx5IBV0w23XfNDLFMt9TQ7ty6mvNw64xoVPnWuYJfqW2cGb1qqgeB1Ty0uMBKUW85AORxy2mBplOKItckoofTlolkIz9h00r3pl7GCgkv0vZtG5FtMHUjR527PjIGm3flmOMOr/CN5yl0heR2wA/JtAQ3wvTzBE9JGeaIVT6lcLH2x0Y0hU/P9wiycR9YMFWmNhoSZbPPimbP8grMCNKquekmcP7VsWskyxhf6IRR9/bZEkhMJVQRj8P6nLTEb9hXMS8ybFzPc3XKxxnUVG6qiDQiyuLtNz4SKYQE4xtsXPyP4xYhX7NrQYl8cttqJHR3ncECB/7OiRuKUEFxP9Gf9Oe4W6RQ/xFdl39MVWo6QXi3bBr5NyEyX8EV8egdILKk55nWt4w+QBhKR35ltqSq5pW5D3fK/ONYnXSw1lX19XWUMvjYH2Fu3M/oKq6VmI7TXXHbL+aAh1IqtedNFwcxiKOcUrBMlCVgOhI3weN6KIoS8SObnRXu+vm/Y89DAi2oBbJ06imoyP5jaZSp32sZpE/UitnZhELF+XDKsbkUe4L2WTnMbfmfSJQAqTSRNRiUesgpu8+sJiBKxedNbvx/AS2O7BoiYRbGwx2T15L/JUgnQDfueULCxOaVj0UElY0RbwOaqqIi7j3LUKOIHoMeUWCjeHUV+YBl2Iz77AF3hCsftlas9lCMpdmm97lMDjGWwTfNIbo9fLjr8Q0DrJ X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(70206006)(356005)(70586007)(26005)(82310400003)(54906003)(36756003)(6666004)(6916009)(2906002)(336012)(47076005)(7416002)(4326008)(186003)(426003)(86362001)(83380400001)(8676002)(508600001)(8936002)(44832011)(5660300002)(81166007)(36860700001)(316002)(2616005)(7696005)(1076003)(19627235002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6063 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 37f6e690-40b8-43c6-bf50-08d9a8f4e02e X-Microsoft-Antispam-Message-Info: 8Cd3rgSSRR0oLV2FACyPLAm3s0acFZCJ9xee/rzRWA5sGmgHGU224CIga+C1LjrP3BOlc9VI4pGFJSsgt2UPgGSuFIwNOwbZO+H4AOezmLnpD+7Cds5C1VJ4SQr/ZybHmMtLF99jgSDQ5X4ENOZqp4h+SIUdFuCDxjxu6Ekpqz22RE2l01aGBg7S7fdF6nxyTmB7XXzpdMFkDLroOt/PBSIgaqJnmAM5l5t21547NVkzOCaHq6V4ZgNDKHScz5fUXELQTTWgj61p1WhnwUyWDzgA4VYgsNMSYAnohGvLgaLOk7MhUMrk9iDWZcJHQ+0J4qemnRIrP8gfYYBREy1jViiXO7uCL92/MaSbUA7hPiWhHfs8yqBRiGUrBZap5LS1hR63oj0sJh7e7owqkb1LWInDxlxXmlV9IsA+6DAwDOR3CKx6bPXRrTVoEojwM/y/2K8aIZcUtCVktHGJ4NEWG6I2IoHSCJ0b1ogT/rXim1nR6TAARX5k7B0i4GPgVU2XFNUNgTykobAF+j5PpFAOAZFC+JcogHZqyIj1aY3LjAexMu5bbFbb21cZQUrLIDkPdYc9RNkePJlfRXKOfxAFCQcF6qG9+KlDqr505A966gLAb8yQEU7e8WXlt7kXa3j+PVfRS1HcqrDtMxrJCy32dkVJONDlBgRC7Kwx7sx3AB7XFdrpq4cIgzaUOrVcPYZIcP9AvfybzZ9TBvJQkkNX5Pqgha7q9ZsQcKy2rlhHbritfo3TjTZGcdXnUApAFleFKG+OUKSwhXnsxWT7J3FT6QKpkEDxnu2DORehLH8pB2U= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 11:33:23.5212 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 88e4c07b-5271-4853-238e-08d9a8f4e624 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4232 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,sami.mujawar@arm.com X-Gm-Message-State: yFxCcP9LnvR78I0dFcIqu2M8x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1637062429; bh=SvhvZyxvLsTjpc1YwQTQYPqyAdm8i37wQVnOUFt3fb8=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=qMz5vvjQkPmkoazf4FCWv/HZhi5FUaDdtvC+G++3FWNKtBUuLyKJwllfDJ7nCiOppmz T1ER3pafRlTZwIpCtTbbZ3QJNiPiTrG/TWBwuHU8VOxX9zLw3PTOm21LRJDe9Ei81zY8d keg8nqW6sUckeaPGtHu0GEMBVZBzt2qriAU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1637062431161100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) The EFI_RNG_PROTOCOL published by RngDxe has been updated to implement the EFI_RNG_ALGORITHM_RAW using the Arm FW-TRNG interface to provide access to entropy. Therefore, enable EFI_RNG_PROTOCOL for the Kvmtool guest/virtual firmware. Signed-off-by: Sami Mujawar --- Notes: v2: - No code change since v1. Re-sending with V2 series. [SAMI] ArmVirtPkg/ArmVirtKvmTool.dsc | 10 ++++++++++ ArmVirtPkg/ArmVirtKvmTool.fdf | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index 9d23072d8fa893907848ef105b2c96953a68c56e..418ae894681d0390907ff25538b= 58bf0162018b0 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -71,6 +71,8 @@ [LibraryClasses.common] PlatformHookLib|ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550Ser= ialPortHookLib.inf SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPort= Lib16550.inf =20 + TrngLib|ArmPkg/Library/ArmFwTrngLib/ArmFwTrngLib.inf + [LibraryClasses.common.SEC, LibraryClasses.common.PEI_CORE, LibraryClasses= .common.PEIM] PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf PlatformHookLib|ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt165= 50SerialPortHookLib.inf @@ -102,6 +104,8 @@ [PcdsFeatureFlag.common] # Use MMIO for accessing RTC controller registers. gPcAtChipsetPkgTokenSpaceGuid.PcdRtcUseMmio|TRUE =20 + gArmTokenSpaceGuid.PcdMonitorConduitHvc|TRUE + [PcdsFixedAtBuild.common] gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000000F =20 @@ -353,3 +357,9 @@ [Components.common] } OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf OvmfPkg/Virtio10Dxe/Virtio10.inf + + # + # Rng Support + # + SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf + diff --git a/ArmVirtPkg/ArmVirtKvmTool.fdf b/ArmVirtPkg/ArmVirtKvmTool.fdf index 14a5fce43a0928d6d78b1af5d7bc3a16b6f07918..ed7e5cfcfad8ef762921de52af6= 6f76351736468 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.fdf +++ b/ArmVirtPkg/ArmVirtKvmTool.fdf @@ -211,6 +211,11 @@ [FV.FvMain] # INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf =20 + # + # Rng Support + # + INF SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf + [FV.FVMAIN_COMPACT] FvAlignment =3D 16 ERASE_POLARITY =3D 1 --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=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 (#83782): https://edk2.groups.io/g/devel/message/83782 Mute This Topic: https://groups.io/mt/87092743/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-