From nobody Sat May 18 01:52:21 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+81346+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 1633017209429318.37925313263577; Thu, 30 Sep 2021 08:53:29 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id NogIYY1788612xcWuoPTQT2x; Thu, 30 Sep 2021 08:53:29 -0700 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.70]) by mx.groups.io with SMTP id smtpd.web11.14654.1633017207927246736 for ; Thu, 30 Sep 2021 08:53:28 -0700 X-Received: from AS9PR06CA0289.eurprd06.prod.outlook.com (2603:10a6:20b:45a::29) by DB6PR0801MB1719.eurprd08.prod.outlook.com (2603:10a6:4:3a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.16; Thu, 30 Sep 2021 15:53:12 +0000 X-Received: from VE1EUR03FT064.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45a:cafe::6d) by AS9PR06CA0289.outlook.office365.com (2603:10a6:20b:45a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:53:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.33.187.114) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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+81346+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.33.187.114 as permitted sender) receiver=protection.outlook.com; client-ip=63.33.187.114; helo=64aa7808-outbound-2.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-2.mta.getcheckrecipient.com (63.33.187.114) by VE1EUR03FT064.mail.protection.outlook.com (10.152.19.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:53:12 +0000 X-Received: ("Tessian outbound 0e48c0de19a3:v103"); Thu, 30 Sep 2021 15:53:12 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d07357faefae0e18 X-CR-MTA-TID: 64aa7808 X-Received: from 3645dc4442f6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FA7B68F0-1167-4F3B-AC0A-DE6CD8D0E37F.1; Thu, 30 Sep 2021 15:40:46 +0000 X-Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3645dc4442f6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 15:40:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I1nNnz3qnLamM9499a9o+u5BGGWn7VOqBFIOevvgp3g80pfgBIZscgFkFGJkzd2CjQSAHHKHFqpPf4IRwIMRSI3YwYwvp+58D01ad4ND/0Yt/E0hh8+/oJ622zVQjFJ1Zc9GRw2J13rdpJJ6z4meS3eKWznlKf8IT/Rq/VUP/R0bL0dVJj1aQbiOcp3JVqacWVECDXYnDjiSOc+4q1mZgBqlu5zaevDO4HdNFEP54f9pwY8YJSTQEQ6i+26xhQjmJFlkQkSVawcK8ZcFQHL4mEsq0j+Lrksu4/FEDEwhUtNGRanu8aZbbhL2iuFb2c2bULhDL4gXNdBE8Xar7E+6mA== 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; bh=+Il5ie4/RGcpvO3P0ml9BqmYV0A3lZwuWgoJp3J++og=; b=LR1NFVG8vX0N8Ch6AQva6d7g6dc/89fhO5vER7fZ+FnZiFBJ4qbf6vfG29km9wtpgm9h54oisudcSi7n50yXVjlALxXwUoQDYB0E63C5CEEfOgzrXlPRt71buwCPofk/hgpthWnCojNdUigvD7NocAeIU/0bMXodN8fT1MN5cknG/BOM1f/qCLR9vWtGs0S4dll0mEqWHszJdjzo7ah1EMmJ5nqorjFlih9ww2rqyGP01MGg2HzRFeS6Tjx/o8o5Dpo01FSOuB5p58/HbZqbd5CBWAtt/FIj3cfWBUxCN6b7Aur95LlVMq7rW4QKWbo45tNGHJ7X2Dqlgtz9E42dIg== 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 AM6P194CA0007.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::20) by AM6PR08MB4166.eurprd08.prod.outlook.com (2603:10a6:20b:a6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Thu, 30 Sep 2021 15:40:44 +0000 X-Received: from VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:90:cafe::9e) by AM6P194CA0007.outlook.office365.com (2603:10a6:209:90::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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 VE1EUR03FT004.mail.protection.outlook.com (10.152.18.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:43 +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.14; Thu, 30 Sep 2021 15:40:46 +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.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:46 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v1 1/9] MdePkg: Definition for TRNG library class interface Date: Thu, 30 Sep 2021 16:40:36 +0100 Message-ID: <20210930154044.37336-2-sami.mujawar@arm.com> In-Reply-To: <20210930154044.37336-1-sami.mujawar@arm.com> References: <20210930154044.37336-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75f19c24-82d2-4694-664c-08d9842a6883 X-MS-TrafficTypeDiagnostic: AM6PR08MB4166:|DB6PR0801MB1719: 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: k++RhndvZcipMPAiYtmcMfF8g1fYvwC661/Qy+kxzV5NYYt3TX/aEkBSBDmsKw2t92JoQLIxTcKe1OZkObBvpovZzVuqiG6Nl/SImcYK/p3nlQqY+QWfwNeC8Yi40KzCb8k8mtrF+X8Up6LT1lcvw2gYmDAsZy3DUwBppxUG4sIARnX0ht96nrQlvIS/IdtxZ5ODREhrkY7fkClU7AHdMHU8F2P5SYwyaVLvW3S6AINN/62vQ0aFCg3C52HqZKMI1wlfhKJgvxfi9ork3aHTHxT/GlG/AoR/p5ejOmTOs//CpfVXeFg6umrUXYZueK9GdiF268/ijGYufA66nuPXpT+AGxXpQN/yVFaVN3Ji6F7zktRc3kKLC5OoHI+4h3nI2+gxekgqR8se+6Xi4f5RqYbpJRqB/yk4A/6DBGNGUYPRnPudxpui0I7Tfon5zi2fm93WYxeXORQ1GSGFr7dp1laf/ytQ9Ljt4LGc6iyJ5lI0tk1EhyXMIzWHkVA/ScOyhG3M5KfbpyqHTIGl1pfSMztU8J6deNBIQqEy7YoNnxbygkDv1O5p9dUxvsUgAjBW/tXoASKjH1SeP+EzYeZEmX1TRd35mJTiY5CTmw/OFINk+fTGplLIN3YeN9jxWg8tTmiIr2LsZA0Q2g4wjjqfamsYijOEyuZFaPqjG2Lwzup2PcfRuyDGYQEoayvlJWlkotn4bUEFU/wGAxsiULMwvQF1xAos8pv2qg8auyi35ox57aoz4rmMVQ56GNUkiBI7xBqG1BxW8cdZe+QVhQPxNClF0IYkbKuhr8Wiccs5QQ+Fnn3FeWzxYIOFE1gbtrPqdMBewpE/tOAtXOnDloXf6f9oHFSer05Dane4E+tBLao= 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)(5660300002)(26005)(8676002)(508600001)(81166007)(83380400001)(47076005)(2616005)(36756003)(1076003)(8936002)(316002)(426003)(36860700001)(86362001)(70586007)(2906002)(7696005)(6666004)(4326008)(44832011)(82310400003)(6916009)(336012)(7416002)(70206006)(54906003)(186003)(356005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4166 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT064.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 85a7471b-f7ed-4d82-f69e-08d98428aa44 X-Microsoft-Antispam-Message-Info: snTytchdmA2KdBY7w5P8OL9JoEsAMeNCHIUOYI4DDxigiGQv7yHs5IqH1l4urMoa2FENr2QSre+ktW4xYZOCi0cyKU820GqbfM5V2DpqCFHSuhv9novIRI9KcBe6rIS1gc4fJAUuYd/4ybTt+Xogawq3uqmRQ6ggm4NU/Hf/M/SpaOKo5yznG+PJUiKXTJdwqqwokpKaFNEE4i4J9h/Nd2D+U928i+JzNlKJ4sv0WvvH4Oeb/G9PuRMdvVcnirLNc8S4uO0GHGxiJX2g0eQmUXR9J84TKpKUW/3Ss8OY2TTiAemKQD/xg74b2Z7PPDa/xo0i6ysDCZMNY1ZnsniOQyqFzHMsZlNh8z4DnDuACzCbBjGB9/ci1M/vIAeaKL8hztvFaMu/OMbZGlQKzRrIziXPsaDt+4g1I/xZYnx8hS+5eC0Wnwq0pYiHrTDFpxPmSWNUaMIIl/ZPPQ4KL0iRpwntx4H/n9CYq7BsmxaIBqWzJFoysa08qpBXzEpMErM+hsiwQH+UchI8wQe36ILPqO9UNSuprYr/UAbzE+RxZLbhLRJ27+RVCyH+j2AFXKbuLPhhHDGEj2qbvS66SxCNuuEDTSkRpkG1WvAOx7iaOQKBa929UN2Dp8PHPXDo1ZEhxQEScv+KWsat8wCHQpoGoaCuw2yZVKlV27sIGBCKJmQrokCgqb+poEaWU8Xt5R/ukRbPbldkERuITYI4xYScMMEnCwnf6NnI3SqoEaK7/uiwwpzFmLf6HatW/7GjnCrDL1msfunzAmZ7pNJshFdASiKp2UNt4I7RRuixx7/nE5WnDj537ig6lejaf0BUX5BAzKRbu6n7ZeKs1Njc7SW8og== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 15:53:12.5491 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75f19c24-82d2-4694-664c-08d9842a6883 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.33.187.114];Helo=[64aa7808-outbound-2.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT064.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1719 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: d463ppryqBL7Z8IMSWEMoClHx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633017209; bh=pJgoPGd5HKVWpsnhgzdZmfY6Qo8ACdkod8GCucQ28Zg=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=HskNSFlhLvCPRGYyAa0IEBpRwasxhq9vmouy2uNTIWxNGXhHS3jlbMji2Yr54gTfCSp UyVY6ZuVRoBmBfE3drpIod8g/u4TNg0o1VRkFpuUETWz6KeAO6O199t2mk55l+M2/VCYK FCHh2jYp+jrJLDu7uLWBIyAItQgKATROJko= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633017211615100001 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 --- MdePkg/Include/Library/TrngLib.h | 123 ++++++++++++++++++++ MdePkg/MdePkg.dec | 7 +- 2 files changed, 129 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Library/TrngLib.h b/MdePkg/Include/Library/Trng= Lib.h new file mode 100644 index 0000000000000000000000000000000000000000..8a02fe4bfe305a5249ceafceb40= 43b3f3df95c62 --- /dev/null +++ b/MdePkg/Include/Library/TrngLib.h @@ -0,0 +1,123 @@ +/** @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_ + +#include + +/** 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 EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Backend not present. +**/ +EFI_STATUS +EFIAPI +GetTrngVersion ( + OUT UINT16 * CONST MajorRevision, + OUT UINT16 * CONST 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, EFI_UNSUPPOR= TED + 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 EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Function not implemented. +**/ +EFI_STATUS +EFIAPI +GetTrngUuid ( + OUT GUID * CONST 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 EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Function not implemented. + @retval EFI_BAD_BUFFER_SIZE Buffer size is too small. + @retval EFI_NOT_READY No Entropy available. +**/ +EFI_STATUS +EFIAPI +GetEntropy ( + IN CONST UINTN EntropyBits, + OUT UINT8 * CONST Buffer, + IN CONST UINTN BufferSize + ); + +#endif // TRNG_LIB_H_ diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 9cdc915ebae94fa246c3883db5627819079add7e..492c3c3fd83e632dbf902bd8093= b7d5e62597433 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 (#81346): https://edk2.groups.io/g/devel/message/81346 Mute This Topic: https://groups.io/mt/85977029/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 Sat May 18 01:52:21 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+81348+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 1633017234720125.043571842147; Thu, 30 Sep 2021 08:53:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 4XwzYY1788612xiVw683v6zl; Thu, 30 Sep 2021 08:53:54 -0700 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.107.6.56]) by mx.groups.io with SMTP id smtpd.web09.14617.1633017233150177596 for ; Thu, 30 Sep 2021 08:53:53 -0700 X-Received: from AS9PR06CA0103.eurprd06.prod.outlook.com (2603:10a6:20b:465::21) by AM6PR08MB4472.eurprd08.prod.outlook.com (2603:10a6:20b:bf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15; Thu, 30 Sep 2021 15:53:50 +0000 X-Received: from AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:465:cafe::c6) by AS9PR06CA0103.outlook.office365.com (2603:10a6:20b:465::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.16 via Frontend Transport; Thu, 30 Sep 2021 15:53:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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+81348+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 AM5EUR03FT059.mail.protection.outlook.com (10.152.17.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:53:49 +0000 X-Received: ("Tessian outbound 45760a30af4a:v103"); Thu, 30 Sep 2021 15:53:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 85c17119e5b9d706 X-CR-MTA-TID: 64aa7808 X-Received: from 99d364a45415.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3787DCFC-2885-4735-9770-ADD0B0DDCD4F.1; Thu, 30 Sep 2021 15:41:14 +0000 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 99d364a45415.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 15:41:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NJA7YhNHIVhvHF8hNBoh6PM9iQenlwGtYQoqjFsO1gh8hGFCiv2a8UXWT6gTnWVMI7eQDKzwm/vqrlTTLtZbB8QmmwtLVizJ4awDiJfLd/A4OqnVDHHw7sdn4qS0OOyhiZaJKKalPwaxShqPBofPVHHOEHrKsoGJ5dvj6r0rALFkkCUbxf/KRj5ajIm3iqKFW70X7EbLbopyD5eBxjClz5boQdU7slQoxz8PsdfPz9abiMF1Sd3r9asg/Ggps2sAK2usEyy+i56eFMGfUapt/DZ408NJ8qRqG/KiO+Qg01PQAqkTrw9AbMruIzQ4TCovQt5jB7IJor0z6P9uPMlQlw== 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; bh=JuP3uNJO7Vd4knBmOk3ieXwRYd0ZjdognkWoj+xNQN4=; b=MxRV3t6Xx1+ykVJZ5D/0I6Nx+Nftk1ePcVGUvhSv7arJnbyW9G3y9Trh0tSaKwpqtDXw4Isl2FUhuzZVj2IZ3cdGVPgxwY+8KD60/1LuZOXSc0M4fQpHzot/nh4z0hE4CcgAYoAHZNIsHFYJrV66JQSrB3XkK61xp6eel2hNnUFIPbE8tsbvsHMjcVZzQGVsNw7XwIk2sTYT7cl8UH4mK3chV6JyXLHrJhUCx04DSizfV9LfB9Ap7hu9VEh48NA8VykH9Geag5QOqCHFSrLl/2/rvKUNYwrEdfa3gv+Z7bZomWkk2EZfrFpkTG+dhWajk/LW7cynTfb0xNJ7f1cWNA== 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 AM6P192CA0068.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::45) by PAXPR08MB6429.eurprd08.prod.outlook.com (2603:10a6:102:dc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15; Thu, 30 Sep 2021 15:41:11 +0000 X-Received: from VE1EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::1d) by AM6P192CA0068.outlook.office365.com (2603:10a6:209:82::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.16 via Frontend Transport; Thu, 30 Sep 2021 15:41:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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 VE1EUR03FT018.mail.protection.outlook.com (10.152.18.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:10 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.14; Thu, 30 Sep 2021 15:40:47 +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.14; Thu, 30 Sep 2021 15:40:43 +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.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:46 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v1 2/9] ArmPkg: PCD to select conduit for monitor calls Date: Thu, 30 Sep 2021 16:40:37 +0100 Message-ID: <20210930154044.37336-3-sami.mujawar@arm.com> In-Reply-To: <20210930154044.37336-1-sami.mujawar@arm.com> References: <20210930154044.37336-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f741cbd-aab1-4496-e83b-08d9842a7e7b X-MS-TrafficTypeDiagnostic: PAXPR08MB6429:|AM6PR08MB4472: 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: X6PW5yi27RfC4fNbG59wP8Xjbvt++uFxVkzjAZglBdHxjzHO+nU8LmpKqpgyQh2N2HEGN46nWH4w9ip+QpNEfUpPobKuRVKD1cC8WGPvmg0FeHvjRZMH2p+7jHeRucbX+HL/AuuK6jFfHUlJaLCFTmIIdU1me1eKllk0LbpIDJD3ueBz8MCxBuU3urzXc6MoZJgbDQf45oC38ylVfak1bdDkqikzd8U8Rto+woU+t4AIIOfDo7x7zofteJcQLMi8ID8eSOfFrWw2hql4gxHdl/v4Q2ncDwgD6Z2O9oXE9ayvECW93/7I+151o7risx0Epc5+TBm0qG7U6Yjsr7FyOtTtlRoTUMGG13AVRMisPmRSvxLgGjYiAyHJedU/BBT6zmVLgRKIgJnsn3viHe6JaDG5oPve90foWfl43MxiWkmumUVwGbkzBnq4rgZKN52R5WeGad7j+O6c/6yx+tKcjVAIBPJcrFqGYUZB7+p8uh25atYldYGXYPzfyisAiefia2S1vMODnVxRAlY5qMf6ZoJ0oHJv5Dj0p/pWoAqSzpf3E1AUCWo19nKwHhZUQleJCU/vhtyV0YLOJKlnKAVJ1LQpMA7/eF53fHr8xFYuUhAs1pGhHpbfCqv5QoFw0WprgEyxmXboQbtXcc3n+0hqmw2I/1k3gtW6ratBVJrqqnzUs1oHgl3cRKhAVaBxinaCAGeGWn7uh+KF2L5KiqyZwNuW5YCYuB+uP66jKSbVqLbRiku3Fg+KN/jAP7E0cZU18TaXFmx7NauR7EcYyaCk26Zfo4fn8JuzoryAEVtSOxyp7BSLEqBxSNYzPlbOe50S 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)(44832011)(4326008)(36860700001)(508600001)(8936002)(7416002)(5660300002)(47076005)(316002)(54906003)(356005)(81166007)(8676002)(82310400003)(86362001)(26005)(186003)(2616005)(426003)(36756003)(336012)(6666004)(7696005)(1076003)(70586007)(70206006)(2906002)(6916009)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6429 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ff33e89c-07cb-4c81-fc02-08d98428ba60 X-Microsoft-Antispam-Message-Info: zuKdTyTCAc4NFdrRBxfN7FxyjNOc6BwCLPyxszsnDV6znqyf6B2VEy9JvCOPXYQBEvMb9ltdjH3lWGJ7YBZXD0T+CJqF56iyq5lgeg9jlkttoAV178HLyizln3953M03UfDPQSwGHtDQyjK0yicorJ2vjMaGUujepaEVHFONvij2iSSLY4FqX4J7pdpb5smtXkVgumkaj9FnYNBnEljYUUImvtalDfhAbpNu1gsZv34Q4ubqH1rhYLF3GSj7SE15UlAXqJc7q01QVZ7MvPPEtcRx0k5NyKxRHj8RbYNS58znnjbo2I7Lu0aXLponqvzWb91Z16sqG53w8Ik1xVr31Aoj1jdYjX8x82wO0XjG0pkDtnfcw0IIPP8UZRFZNPlyAz3JOyyzxe/Z9AC2S9RZ2viSxKCUMdMPxMGpyYal5YNStNnsyB1IK+WGW98MhyDUy7FoEld+Ib7OSpFvC66GjtUZgrVKZ8nVnqMr+aI8vtFqyMYeZgBoBZm+/GlsQB1CU9cTaNFqEdrNnMHkzZKhDULukAwHw6F1TuUwvujafaQXKfQNMR4wIdWSKv9w6/iRPdvGJMsVHvduobbSN89fTwCTAiuQIxKwKp+fwcABeSEnFYX/9kAxiYsFMaVN00PZDO/Y/9dLGLagw/KgrsuYBvusIaaSOulRr1XlIC04Vvb4tDX3Ij9aj4fgqk+zWAUriyvM3fOY4gY7l1YyvLEKc+cY4wvRF95rfuQJ+gpcNhHcB5uTjopxG/D43clpX6k9tQWdHTNlvmwQCqnhI80+31h7yGR+L3cm5VSjwqe812A= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 15:53:49.4308 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f741cbd-aab1-4496-e83b-08d9842a7e7b 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: AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4472 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: CZCaWdNs2iDUl5W3cCdycbmUx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633017234; bh=ruqg42gEaZrUpjWkhiqRfnf96jBIbRHo3Kf2ur+RssQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=LJrDSV8cViX+hMIKJ938A3QDg92Ym7uR9HVGDIwxntScz6JXs3ttaeCJ3H0tDW6VNhV 3vW6bJqbIrwYn1n4hBuWolJ7dYw0rRsIyG4d+/5kbZY/WOkfLsVFTc2sD+VWDhgphQ6LP ubBC+GnJXQXD+hq31VbJHGvCIO074F7rFk4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633017236782100001 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 --- ArmPkg/ArmPkg.dec | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index 6ed51edd0340605639d4b34f77bdb59dca1827be..395d64d8aaeb772a6e094b3d90c= d3920b844e372 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -131,6 +131,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 (#81348): https://edk2.groups.io/g/devel/message/81348 Mute This Topic: https://groups.io/mt/85977045/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 Sat May 18 01:52:21 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+81347+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 1633017218443323.95757767478165; Thu, 30 Sep 2021 08:53:38 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UxYeYY1788612xPgToF3cMvm; Thu, 30 Sep 2021 08:53:38 -0700 X-Received: from EUR01-DB5-obe.outbound.protection.outlook.com (EUR01-DB5-obe.outbound.protection.outlook.com [40.107.15.51]) by mx.groups.io with SMTP id smtpd.web09.14615.1633017217059613269 for ; Thu, 30 Sep 2021 08:53:37 -0700 X-Received: from DB8PR06CA0057.eurprd06.prod.outlook.com (2603:10a6:10:120::31) by PA4PR08MB5936.eurprd08.prod.outlook.com (2603:10a6:102:f1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 15:53:33 +0000 X-Received: from DB5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:120:cafe::ff) by DB8PR06CA0057.outlook.office365.com (2603:10a6:10:120::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:53:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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+81347+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 DB5EUR03FT024.mail.protection.outlook.com (10.152.20.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:53:33 +0000 X-Received: ("Tessian outbound 71ebfb754289:v103"); Thu, 30 Sep 2021 15:53:33 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 94b32b2725f26c7f X-CR-MTA-TID: 64aa7808 X-Received: from 1985e89e2a7c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 08279689-DE73-4F5A-96D7-33BBAEEE193F.1; Thu, 30 Sep 2021 15:40:53 +0000 X-Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1985e89e2a7c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 15:40:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OMDUlqnmV/lJ0aT354pwjSwfSUyRVSGQ0rPJSegHM8F0+vNFlMtvLpBvAvk4IGdhhRWgoeRwnj0rp2jZzSadUKyXaTc0UjSkaF/6JCb07zYZvcT7IDWlfiG8eYk/v8IMD2rc0l91sOSKHhvD3/eqp4knI5B01jquo60JZj0cGZf6PDISruHRsFYb75BUX2mJ7xx5ziiZ1Gp8PyTTmCXW10KewsdRLUINe2sfc9YD5sjUiXne9t1/MnJ4i/8QMnzioaNz2s9llmQs5thfNIJo9ceedBFgRi8pLXPNZGAqV/eNTFnhq9x3a3lRrA1oFkluRUvMfTnfr1miiwU0MririQ== 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; bh=058d/XHz/h3aTreXhyeBmpkCO1LUin0mjAmlv4r4qRU=; b=B/3FV8hvcGBBg60lVtNmfpz8ugX/0gpzJ5pXusPmo30n3LaamZqhKlA1uyhnFtFjfwrnElI5CJKu+SK0um7swQSf1LgOOn0NwkR5F3pFYfpCIWPRQ0/YyLOL++8TdssWviWMM4+r2Imte/CnPuWySj3z1vjam/JRtRJDzj3sdKNyj58gGsBsMPtB/OOXjBkQfwkVUbJXaNiiylFLk9DMRZ7YXG1HLtO2DFBYr7w1drFo7QS4Scra5fYbRiVloiHagZAPna1roRKEYvnIxKaeHQ2elzQkzk62ywYi8QWGu8VVW2rxpw+wDQq6gd5H42xWTZbdxBlHOmsQKn3bZ5hz3w== 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 DB6PR07CA0084.eurprd07.prod.outlook.com (2603:10a6:6:2b::22) by AM6PR08MB3173.eurprd08.prod.outlook.com (2603:10a6:209:4c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15; Thu, 30 Sep 2021 15:40:50 +0000 X-Received: from DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2b:cafe::eb) by DB6PR07CA0084.outlook.office365.com (2603:10a6:6:2b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.7 via Frontend Transport; Thu, 30 Sep 2021 15:40:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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 DB5EUR03FT050.mail.protection.outlook.com (10.152.21.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:50 +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.14; Thu, 30 Sep 2021 15:40:48 +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.14; Thu, 30 Sep 2021 15:40:43 +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.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:47 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v1 3/9] ArmPkg: Add Arm Firmware TRNG library Date: Thu, 30 Sep 2021 16:40:38 +0100 Message-ID: <20210930154044.37336-4-sami.mujawar@arm.com> In-Reply-To: <20210930154044.37336-1-sami.mujawar@arm.com> References: <20210930154044.37336-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc747753-879d-4759-615f-08d9842a74f7 X-MS-TrafficTypeDiagnostic: AM6PR08MB3173:|PA4PR08MB5936: 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: a9a8aJ0zyzb1iGF8Pza0WJc3AWc3sULqpxGfe5RSpHBrP4R76nYfa7jZnL+bo6kcp6UMpLSgMEn0/m5awlgpsXs9MLvhmpcpRvFWwqQ+twXa4d7qV/1di8pc+7sfjzi5K6C3QiXCk74rbYIKEKUCc6qsqqn2NXI5x6SLNY1XP/2ez+cp0JWuCUcLGi9O5hABi3Tte1V7gA3/yzIHreET9NKkyQnQWZuhtnS+VeAd6i6B1fbLbrnBnmv0OJ6x6W7UjwE5ee8JZfekisuqGCDMWMgENap0nO6huP5Nd9I0enoIxrRj3garOZ2si4CoWwdMmnIfnHUy9ztp0DMRsk7Ii5oSed9rsU/y+CMhL/jxyrSw2KSX019sD1bIpKDv5nn/I2qY2OejJTuJkniolCPO+SCAt+9iU8GwGQ46/IJoDqOxBPzEI8uXHiL48o+7IlYbj3a1kzXZwrVusS1EXkQ52mOl73Dek8Bx61zHR7f2BfUfKxKMQCF1btGXLSWShfj96QaYZhxat9iENQSW+LNnRZAG39V7lqVkvce35Lrgocfay4zBFE/Ul/sL4YKyYhrWLLaTxePAzRbXBmmDrtRkZD3P4IRZju80uJB8zDnLgeTce7owtupkqPAUzD/GbnMsY/u7aw8xyurg/grVjyNYlXjGKfYwB7Iq5C8W59RpXCrqok58CgdnqOqFkt/t//i50UEkoUAyC67qAM9yGivRuGj30BSaO/gxJ7XkrGHtTE9KBoM2WVSejrB8e7foHFhYFxmjjV+dp9fZ0ICar09y3FIsJ+pEhIC1SndfAqA6KqCnbzQ+WLMYv+JlBmDuCepqwFvwfJvZbU+uvc3O8VhXTk1ikmyET/l3TuKo0lldvo0= 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)(316002)(30864003)(1076003)(86362001)(7416002)(356005)(8676002)(508600001)(70206006)(81166007)(54906003)(8936002)(70586007)(82310400003)(44832011)(6666004)(36756003)(336012)(83380400001)(26005)(5660300002)(426003)(36860700001)(6916009)(2616005)(47076005)(4326008)(7696005)(2906002)(186003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3173 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5f37570f-6b28-4763-3745-08d98428ae40 X-Microsoft-Antispam-Message-Info: fIFWSH4BWmda1Xjo/cRnueTg7QxPH4QiyifPxcvNjGSOuz1zrsgHCigLiaWbH50Kc79WcCyyqdU5Hptl/UdwQWzYaZVBRK4EvcyDvrUxah9rFNhTss0ImF/GlE4ZI7PTR/NV2O9yp0+4vKTcD3XMVHfwJUMPXtIGVM/+KTn9MUdQacTxU+dl4N+SzurAA/AfBDwt2bjqQZy/zp6vC6QYNPO029SSWfvGdlne33YayU0ULBZllBN2QvzILpWo2t6veMEeLCK4ls6MOWFD5awJwQyQ40HcvQET/phYAu2hh5Sj6duy1zHsnJSmXW9qpexwinehawWvmim6325oQWcI12y1C0dJIQjJcYgi6kCxMZFS51qTg1xZvqk1b35aziyAm8KLLH9HKnpYBcug4q3NF9CTt/6Yl17wsDQVQYmdx99Om365iJf6JE+Y27D9JJBOSLv0eIrgPhR8lZqZ6x2e8tqNjZJbDDvDCx94rrhL2F//TbcwvBgK4JezmpQeAMFJow8FvnILFrP/EsdjRgMbCSsgGtK3wkNPLec6sx0wVsX+W/8jl0NkcXeTbYi+GdTe5ABoT7nEOdVZEW4zcgkxa37w+P+ywvJMDQmpL6oJoUymKYbD/8Ng+vCZdJR4mneTp7H1qrHIc1q3op/VHs9+0/wstS21jjZ2nqHscyrK0EC8gJzUHRkBFut3jLLGFnQhCxMd7oCGn9Bm/nqBLJF85F7dGLA4a9fuesDvIf7QYEemaBKvf5sF3patzFPhKXvOFQ5qun9e75U5iErH7bncbsDISIhQU2Ewv2qv+o4WE5/0THV1WnK/RNGeN8d2aSqf X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 15:53:33.5408 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc747753-879d-4759-615f-08d9842a74f7 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: DB5EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB5936 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: PCwivc6T5u57OFgxJBRGh5TCx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633017218; bh=rAMtW0i3vrUaBzGRJfvEK7k1wE+7Ajtfj0CniiKQYnw=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=g16SGdGq4uCcuAZvX7Ym9xzbZYehB1RhDMLWHFEv+TJYSdkRGxAAQSTobFF1qre8/Ye 92U3ZC/ZrNijtjWseKVh6ZR4qCmRBrC0jxsb6Povanf7/SRUX5G7Q/3L072Tp6yR3yO7m wnZs4IyskrwN7mOJ2pknCM6F8WrjG6nKSw4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633017218878100002 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 --- 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 8abe3713c829cbe81842c52de6982e7cbef5c323..2b78ee197d4c5fa30726d2cf3da= 11a7a4175a9b3 100644 --- a/ArmPkg/ArmPkg.dsc +++ b/ArmPkg/ArmPkg.dsc @@ -154,6 +154,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..442072fc088d4d53e71869284d0= ebb1c6de285b5 --- /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 EFI_SUCCESS Success. + @retval EFI_UNSUPPORTED Function not implemented. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_READY No Entropy available. +**/ +STATIC +EFI_STATUS +TrngStatusToEfiStatus ( + IN INT32 TrngStatus + ) +{ + switch (TrngStatus) { + case TRNG_NOT_SUPPORTED: + return EFI_UNSUPPORTED; + + case TRNG_INVALID_PARAMETER: + return EFI_INVALID_PARAMETER; + + case TRNG_NO_ENTROPY: + return EFI_NOT_READY; + + case TRNG_STATUS_SUCCESS: + default: + return EFI_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 EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Backend not present. +**/ +EFI_STATUS +EFIAPI +GetTrngVersion ( + OUT UINT16 * CONST MajorRevision, + OUT UINT16 * CONST MinorRevision + ) +{ + EFI_STATUS Status; + ARM_MONITOR_ARGS Parameters; + INT32 Revision; + + if ((MajorRevision =3D=3D NULL) || (MinorRevision =3D=3D NULL)) { + return EFI_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 EFI_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 EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Function not implemented. +**/ +STATIC +EFI_STATUS +EFIAPI +GetTrngFeatures ( + IN CONST UINT32 FunctionId, + OUT UINT32 * CONST 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 EFI_UNSUPPORTED; + } + + if (Capability !=3D NULL) { + *Capability =3D Parameters.Arg0; + } + + return EFI_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, EFI_UNSUPPOR= TED + 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 EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Function not implemented. +**/ +EFI_STATUS +EFIAPI +GetTrngUuid ( + OUT GUID * CONST Guid + ) +{ + EFI_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 EFI_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 EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Function not implemented. + @retval EFI_BAD_BUFFER_SIZE Buffer size is too small. + @retval EFI_NOT_READY No Entropy available. +**/ +EFI_STATUS +EFIAPI +GetEntropy ( + IN CONST UINTN EntropyBits, + OUT UINT8 * CONST Buffer, + IN CONST UINTN BufferSize + ) +{ + EFI_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 EFI_INVALID_PARAMETER; + } + + EntropyBytes =3D (EntropyBits + 7) >> 3; + if (EntropyBytes > BufferSize) { + return EFI_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 EFI_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 EFI_SUCCESS. + + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. +**/ +EFI_STATUS +EFIAPI +ArmFwTrngLibConstructor ( + VOID + ) +{ + EFI_STATUS Status; + UINT16 MajorRev; + UINT16 MinorRev; + GUID Guid; + + Status =3D GetTrngVersion (&MajorRev, &MinorRev); + if (EFI_ERROR (Status)) { + return EFI_SUCCESS; + } + +#ifndef MDEPKG_NDEBUG + // Check that the required features are present. + Status =3D GetTrngFeatures (FID_TRNG_RND, NULL); + if (EFI_ERROR (Status)) { + return EFI_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 EFI_SUCCESS; + } +#endif + + Status =3D GetTrngUuid (&Guid); + if (EFI_ERROR (Status)) { + return EFI_SUCCESS; + } + + DEBUG (( + DEBUG_INFO, + "FW-TRNG: Version %d.%d, GUID {%g}\n", + MajorRev, + MinorRev, + Guid + )); + + return EFI_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 (#81347): https://edk2.groups.io/g/devel/message/81347 Mute This Topic: https://groups.io/mt/85977032/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 Sat May 18 01:52:21 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+81342+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 1633016491126808.1496813127648; Thu, 30 Sep 2021 08:41:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id B6xUYY1788612xctclIhTOeK; Thu, 30 Sep 2021 08:41:30 -0700 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com (EUR05-DB8-obe.outbound.protection.outlook.com [40.107.20.69]) by mx.groups.io with SMTP id smtpd.web08.14265.1633016489648936948 for ; Thu, 30 Sep 2021 08:41:30 -0700 X-Received: from DU2PR04CA0330.eurprd04.prod.outlook.com (2603:10a6:10:2b5::35) by HE1PR0801MB2028.eurprd08.prod.outlook.com (2603:10a6:3:56::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15; Thu, 30 Sep 2021 15:41:27 +0000 X-Received: from DB5EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b5:cafe::a2) by DU2PR04CA0330.outlook.office365.com (2603:10a6:10:2b5::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Thu, 30 Sep 2021 15:41:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.33.187.114) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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+81342+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.33.187.114 as permitted sender) receiver=protection.outlook.com; client-ip=63.33.187.114; helo=64aa7808-outbound-2.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-2.mta.getcheckrecipient.com (63.33.187.114) by DB5EUR03FT038.mail.protection.outlook.com (10.152.21.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:26 +0000 X-Received: ("Tessian outbound 0e48c0de19a3:v103"); Thu, 30 Sep 2021 15:41:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 19ee1c93765cec6c X-CR-MTA-TID: 64aa7808 X-Received: from 3acd4f47e4b4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4EDC5F84-BA7C-42CF-AF88-A50482B18AC5.1; Thu, 30 Sep 2021 15:41:16 +0000 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3acd4f47e4b4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 15:41:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eYPTvFI19EspOyFsgC8WTHeumcPLnGAlK2eWqu18KTd65W5ZR75whp4o730t0YUXfsGYYJKWxTrT6+rP4cezfqTqvQ3aj3Ht7Q3uiJ7vHUkYwmknOB+xhjGlK0k+VfZXT0rdt3JkrVDsPP4UbavOH1PZZbqWztnijceND+MApc93hHbpI9VUgxfPuzUuCBt77MldcWhQflTz1ABDiz+n6BqRwOfQpMiO0QoDV+TDossG/IUedUmkAZxvFWZM4TKti+ehya/bp//vvkuorRamqLGp5ZrlwQ4OS6HJlf1dVzVtPCr1OSHugVolTK+oDQ+zC56b/MlhEuwKTFTeVVqMrg== 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; bh=Oe3QFD1p6Rl6T//lsPDmuzBKqhrYWgZSj5ILNUkC1gE=; b=Vg1TNMFaU4/ob/zzCFO8xjQaYsjaIuqcE73kbYUqjCVZJSIgNDbYV2QkKU/TfK1kiei1SBuUwrGOm79jJEsfU5aB1TfOKOCjV9RyciURTZa9sYMi6e4eqx20APm7anyzY9eR+7L6ISDWq7onM1UU+i/hXuMKsEVsKRXz+B8tjZxKY+stwHfy07I61fqu+MF7hZJrnFIeXmTLgPEGiPEGPajt3iQJb60I/SxeMCzMUfGiUytnKKPC7oVYrBDboETgQwR67aWWOdgez6ewTKhBCVs4JwE2ABvLA6aEUdWi5lhTZzVRfq465d1nOz7IfKXP/fPUlqn+OdcFXk6gwaJpmw== 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 AM6P192CA0047.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::24) by PAXPR08MB6640.eurprd08.prod.outlook.com (2603:10a6:102:dd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 15:41:14 +0000 X-Received: from VE1EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::ef) by AM6P192CA0047.outlook.office365.com (2603:10a6:209:82::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.16 via Frontend Transport; Thu, 30 Sep 2021 15:41:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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 VE1EUR03FT018.mail.protection.outlook.com (10.152.18.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:14 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.14; Thu, 30 Sep 2021 15:40:49 +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.14; Thu, 30 Sep 2021 15:40:45 +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.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:48 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v1 4/9] MdePkg: Add definition for NULL GUID Date: Thu, 30 Sep 2021 16:40:39 +0100 Message-ID: <20210930154044.37336-5-sami.mujawar@arm.com> In-Reply-To: <20210930154044.37336-1-sami.mujawar@arm.com> References: <20210930154044.37336-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 433a103c-4ea8-4681-0b12-08d98428c3c5 X-MS-TrafficTypeDiagnostic: PAXPR08MB6640:|HE1PR0801MB2028: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2958;OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: TatynPB48cup5ot2kxi7uzn1yufd7FPloBJDuf+TiQDMhedNq06ohC7BtFUr2gX7donPDruiHYE9pdmjNoLAf54gWYSEzLn7ITLRpKwxrtIGQ6deE+T8upvIogeP2O9KCpPA1v02/16vpRHk8oG/TD18d1GyDIQ0o8+oL6mZDN65L5E11jP+FmJ/UCSWfJHzyhRFLuqBm2uK1ezIj7hs9xNzbs4p874XZwNsdpc1IzTlhSdLIJfB5wHE+wwRrtpwOMIuD6K2PF5fxLCi172dxGMTMChyB2tk1EMGU2hMiJqhREA4r4ZF+67fyuj5bQxyrT4qDayhBHS0LudtqeduvC+6IZ+Mpj4CEJOvD5rjI6i8W5OnpDBN5wylr4oMHzPJAAXbWHU2V3z4FzRTwK4qNqJSPGmRbcgnkm9oAnw5sdg6eZcNqeGsaQr5KuDyMj88wb35gaiY3WEgL7rTP1HLhxdhidN4CUm+fc83RrWg0W8SoIV9NZe10hc31Jmh3NZyc7oQd5Typ+zvGXxjMjCVfeh5RmAMPFbVLpFxrNfD51nP5Somwjh23CW+OItE80S/E/iChQaBbt6mOjI7cvZpbMt+l6AqyCtmrlZ/PSMoLS19J+QiI64QqduoJkb+4YjZkPzqWLhn9yQ+D1xEG6QEC1h20nqvu8cEXotZ1ndxwU8t5KIWliksHx7EAW6SXI2wFy2m2ZuO4etMxcdmGkbCSByeNNo7wadfNbpaRvu8Qxm5ctXTAqD+nZzsyE3hrydhWHpDGNjwfvvCfAmRpQzgdtf8pDh3F9Wo1ziluTyMU3IzpjdnXAT+hCoM7tyXH7+g 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)(5660300002)(4326008)(186003)(316002)(7416002)(54906003)(44832011)(86362001)(2906002)(356005)(8936002)(36756003)(8676002)(81166007)(7696005)(47076005)(83380400001)(1076003)(70206006)(36860700001)(2616005)(426003)(6916009)(70586007)(26005)(508600001)(82310400003)(19627235002)(336012)(6666004)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6640 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 75044d4f-75cb-4c3a-d82e-08d98428bc55 X-Microsoft-Antispam-Message-Info: A5aVddJ54ByyrYCq9uDCB+dICjOVtI9Y5AuBdbB6jPL3J/m4GL5StSqOmdwWqBgQl1WdgMBrSc8M3R/ETN4IU2vGqYNcdD3hlPdVg4m9GOZZgLxfFxyd3Tl9ICa6c2Jphy+PdXm2pIXzySBMloIblsBfd7mj6g8COpEDhpg977jtLBDejo9/N5Q+sWKuUMXcO+4BF8qnro2NFoYW+TB2BbNtxcSdh4VxtUhHooUDuXBT0PIExVY1WvRlQmcg/EdlngkN8dBr9odKS1WBawz9L2Uc8SRUWKZTLOeNmvjLzLdYRfjxX/fRKLYIYAhU15jRDgqzQD8MldLDGYboRT9hVdaM0B10z+7HyAyUKUmiLa40PcZqd8jUxAAe5FvcMLWnWL4fFyk9JhtNfBDCtMtOKyuMTR3wurNbOCojC0ourOfrCZh+WnGwY1kk9a5srcWKgOtnJmdQl7+YNHI+Kp2naM43rQ9BM91k4dzQcMuarYgrqJdrWU5gPFeYxMWnEuqEoF+vII3iKgOYZv5OZOJyi8YdvdFPJPr0Y2j3G8hL8wbG4Fo7vCzH7CtVp2XorxRAoAxJynNV0Qe4sL2HAQSoPB9JfXkgtyqGg/yzl+4Rzd9nph4k9ocWMYRL0058NR/091ipO56o/Sxf7VEOmNAgAL6SXYQwlGR3km8pJbcjU6QWDydCiy9AdvZOuq/b+5twXya9fmkhTkeHF1NfZLfKrKO4ez3Z0lZXmc3Jot3KdRcewuvNoRZo6+oExFrPC22kaNwGH5f6wxSoCW+/pKUwpoPj6rL+enaOQbiH1HFrl9E= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 15:41:26.7584 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 433a103c-4ea8-4681-0b12-08d98428c3c5 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.33.187.114];Helo=[64aa7808-outbound-2.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB2028 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: He8ut1SZPK4I2EoON7FBkmcTx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633016490; bh=Qwo4MeEpqg7WQE7f/uPPWKs0FPlaWvjVDj+yNLrjGXQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=GCuyCVNbyerdyeCNM9QNJyy2uRXsbJlgcSLwdT6mp3p3qv0H6hWR6rprsDTb4IRIz0x wKtJTbqHGGegWDSnFP2chrKLQBRIYeuYtzyLa9SKEj2yXNXLlcLc9LLwDO9LDiHNqWcDA ASjcnVJTzXolpc+0zRGd58/7l7joJLTWbIs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633016493231100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) Some PCDs e.g. PcdCpuRngSupportedAlgorithm are defined as GUIDs and may be initialised as NULL (all zeros) by default. Therefore, define a NULL GUID (128 bit zeros), so that it can be used for comparison using CompareGuid(). Signed-off-by: Sami Mujawar --- MdePkg/Include/Guid/NullGuid.h | 21 ++++++++++++++++++++ MdePkg/MdePkg.dec | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/MdePkg/Include/Guid/NullGuid.h b/MdePkg/Include/Guid/NullGuid.h new file mode 100644 index 0000000000000000000000000000000000000000..e44a92c7863f0573ce10d6d98e4= a67e3d63f5743 --- /dev/null +++ b/MdePkg/Include/Guid/NullGuid.h @@ -0,0 +1,21 @@ +/** @file + Definition of a NULL GUID. + + Copyright (c) 2021, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef NULL_GUID_H_ +#define NULL_GUID_H_ + +// {00000000-0000-0000-0000-000000000000} +#define NULL_GUID \ + { \ + 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,= 0x00 } \ + } + +extern EFI_GUID gNullGuid; + +#endif // NULL_GUID_H_ diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 492c3c3fd83e632dbf902bd8093b7d5e62597433..dcdccf2b68b58536b84f1c360ef= 048ca8f2f1690 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -828,6 +828,12 @@ [Guids] # gLinuxEfiInitrdMediaGuid =3D {0x5568e427, 0x68fc, 0x4f3d, {0xac, 0= x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68}} =20 + # + # Definition of a NULL GUID + # + ## Include/Guid/NullGuid.h + gNullGuid =3D { 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x= 00, 0x00, 0x00, 0x00 }} + [Guids.IA32, Guids.X64] ## Include/Guid/Cper.h gEfiIa32X64ErrorTypeCacheCheckGuid =3D { 0xA55701F5, 0xE3EF, 0x43de, { 0= xAC, 0x72, 0x24, 0x9B, 0x57, 0x3F, 0xAD, 0x2C }} --=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 (#81342): https://edk2.groups.io/g/devel/message/81342 Mute This Topic: https://groups.io/mt/85976758/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 Sat May 18 01:52:21 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+81341+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 1633016476038682.8148284617299; Thu, 30 Sep 2021 08:41:16 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id c4kyYY1788612xAALkDrl2Lt; Thu, 30 Sep 2021 08:41:15 -0700 X-Received: from EUR02-HE1-obe.outbound.protection.outlook.com (EUR02-HE1-obe.outbound.protection.outlook.com [40.107.1.60]) by mx.groups.io with SMTP id smtpd.web08.14262.1633016474077014679 for ; Thu, 30 Sep 2021 08:41:14 -0700 X-Received: from DB8PR03CA0013.eurprd03.prod.outlook.com (2603:10a6:10:be::26) by AM0PR08MB5299.eurprd08.prod.outlook.com (2603:10a6:208:18d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 15:41:10 +0000 X-Received: from DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:be:cafe::8) by DB8PR03CA0013.outlook.office365.com (2603:10a6:10:be::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.33.187.114) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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+81341+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.33.187.114 as permitted sender) receiver=protection.outlook.com; client-ip=63.33.187.114; helo=64aa7808-outbound-2.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-2.mta.getcheckrecipient.com (63.33.187.114) by DB5EUR03FT049.mail.protection.outlook.com (10.152.20.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:10 +0000 X-Received: ("Tessian outbound c9f4ff96a6ad:v103"); Thu, 30 Sep 2021 15:41:10 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: bc264024c91f1d98 X-CR-MTA-TID: 64aa7808 X-Received: from f4ef29a8f0a1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 245AD979-2852-48D4-8E26-3F2A8E9DF8FB.1; Thu, 30 Sep 2021 15:40:59 +0000 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f4ef29a8f0a1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 15:40:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QOnX0XqP6B4udw/1WV1EVlXROmJoWqcsx8Q4/FOt6OxREWvLoVW/dfaWIdCFfxPJ5qUt4fX4zwq0NrnhBsUR/qRc4NkByBeF18FLB+YNuNuPkXU/5REr4PWNVMzgwdbpQw6qNft6utrCX4FRTxC00SWY9wNPNcdqt8uo6eU9WTPrwUXffKFGpECAAWDZnWT2QYwASYeQfdEqS5x+Oe0SnqI+hfRYKHO19tVMJb30n3RQEIHMqYcUuCGLjaN1nBgb7xVWCS2lAz0Ba3xW5Xe7TN2q7opnnx+bCYciys5J91AMYZxRsd0RJ8DZs786cYzux6N3GwImPq0KmdxOeLuN/Q== 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; bh=U6YnW6qK1Gf5ZMOxgNebjGagxqNmiaPoiO0IwsUFTqE=; b=AGMl2V8/LKiYXr8aWBS1sHcdAJbvB3ylouFymYWIbVHlcguVnN1WPHYRVKPqxdSbX1/iknonxeq3KUcAWgeWA1whDply8LlVvFMwyXFAIv9dYgEE3D8JS/neD427LjSXYdE+L4n4uRwBY67y5Erp6eEn24SVJ4KcHul/qHjlA8B+zZ0+y87jumhwEijqW7Kd88/XobxKNEskOGD14yjRKF3c7H8EhcbIOM5PeKDLS+9l1XAAybu+bU9N0EFpJYeQV+tCiVYEVTU9MNcr3f40He9xtUfWeA3sM9JGEOiW+FHii6ZZX4OlRVRSUjQ5MaQUGYIpRPfK+2PGu77DFqDvRQ== 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 DBBPR09CA0043.eurprd09.prod.outlook.com (2603:10a6:10:d4::31) by AM0PR08MB4546.eurprd08.prod.outlook.com (2603:10a6:208:148::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15; Thu, 30 Sep 2021 15:40:51 +0000 X-Received: from DB5EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:d4:cafe::a9) by DBBPR09CA0043.outlook.office365.com (2603:10a6:10:d4::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Thu, 30 Sep 2021 15:40:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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 DB5EUR03FT042.mail.protection.outlook.com (10.152.21.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:51 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Thu, 30 Sep 2021 15:40:49 +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.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:49 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v1 5/9] MdePkg: Add NULL instance of TRNG Library Date: Thu, 30 Sep 2021 16:40:40 +0100 Message-ID: <20210930154044.37336-6-sami.mujawar@arm.com> In-Reply-To: <20210930154044.37336-1-sami.mujawar@arm.com> References: <20210930154044.37336-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9f5fb86b-a5eb-4b92-200b-08d98428ba4d X-MS-TrafficTypeDiagnostic: AM0PR08MB4546:|AM0PR08MB5299: 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: GRUc/7Xz2VihGw+TeeRk/d91V41ql8cVLejzS7opyjymtobsT3WuNGkBbZf7umvqgUf88lC0RktK6MZ0fYZnJD5ZfYCrNu5duQt55rJVoons/eUPLAcZo2KZD9+0qQIPE92UCIotGTcGhjOVKWId45Fr6+nVpOFYXA2HGj4QsLkV1Attwrh8Dhjhst5+SrTd+Ru0/241ZvubzPc81S7f1BjiqRQTIzUejNA2cq4xNkwksMZQFdM5R8PvwwxVSkG6bTpmWOvbSCDvUNvdVLPb6kv+wPU7fGeZpHDf7U7Lz5U0O4DjaFXqbM2oPMj4pdBvFPUTDkYr1fHPtpLqkB8pSVaRECTkFyPvM/8hgQuRMUJxo5XN3tGioN5kXkJxtHe2EAOD5qQcefC9wEVWlDwOUeP0zgSEpsa6gLoOe8PsdnExzhJs+OF7xl//Qi6Re2fTM68PU98C+/VkpTkG8Dfr8f9cES3VDmMl9R/joSZf4CgbJeGSx90xXF3GeOYqNwD0kDHTm/VNNh0Cq6CrmR9adOczlNlUZpqHlOyobAjrsXiSWHJMREO0+/GEpy/fAMnYWZ8QAzI680SRpJIOthiYV2uen8vek8kAEe5uFbOjxB/rBiUbv1S5Pha4QBXfiNXMRohZ8SKI0B7Hpl2MLrXTvJKK80Jtig5anbhfxzQFWrn/TOfzqLKQ7JSKb0419e/YtxRXZtwPiC1bShEF2BL5iCVC3KSJ9ezHH2KuLFch6w682rTgTqSOhZmQzDutC/DLs/pzy8u5BiPqUHYJWrZsya5SbvBqZ+uvl7FVNuZjHZyrB6GC/U7zg+40WMOx82IB 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)(6916009)(54906003)(83380400001)(36756003)(86362001)(8676002)(1076003)(5660300002)(6666004)(2906002)(186003)(36860700001)(26005)(4326008)(47076005)(8936002)(7696005)(356005)(70206006)(316002)(70586007)(82310400003)(44832011)(508600001)(2616005)(336012)(7416002)(426003)(81166007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4546 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ad7b04d5-9bfe-4e76-59bb-08d98428ae85 X-Microsoft-Antispam-Message-Info: f74CUVZKGP04SekwUkQvOO3zehScADYxAxIDojBHkr3i2NVJuUIt9DRtxCwy4Fd3fw5rH0JvIydq6fE7yNQs5aWI4j9h58TESFvvE4D65Lopb4E7F+Iw70AZKMK4f34qFpZIV9y+8pqi1ljBBspfZYg/3TMp2UoSYtv8qc+ayvTcW//l2GMc05BtmxrqmoslxVbG0tfvYmJ2HbduNS7XW9pvhtVVfRC3EndQub7jHwQKF1JIETzi/FvxvGSlCB6Ngt8FlCr7wua5vwaDyj5BF0L/9cA9ZaOzc5N22WGhMimgtQ9vkWSPe1Qn3w5eGkpgpLwTFHrLddbAt+M6UxzMtR0mwDBBKL7lb//hhDG9AeFavLGAHtJyI7mG+eBwmc693+t9BO7pkKwrzwgthoJH3SKNzQxNmhcR1wfWoku0rYLdjUgkgO9qX0U+jUf1Gn31l+w0xKKWNvWtm0/LSVLWA37nhx8O0IDMaXKYp3X1Wd/CyvxO12hczhjFVfMDgU7eRPfqWXsudoBrnEaY/f/++JyBrJhMnnV61q/7mGX29zFjo0gOE3eMwMu+5vqLLAjk4R6yGlGrdzneMbWUkW8lkkqreFXJHVefg3Q5q5x8/crO7KZDYVd4XtIXOWfBHA+pguAIY3mN34Y+z5aXnnkD87KGw/XmTlXRfoZITB8Bp3f4rHweIjDxM5fHAcxjIUAy3+ibm1zfyUltUuiR0DV6Q/+Y5K/pXJkxQujy2FrxuZzGohmX7joW7seMp2j8PDsTQDScCvirdrSFyF8K+KTMeCLkHF30msWEWvjgf2LaXXI= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 15:41:10.8750 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f5fb86b-a5eb-4b92-200b-08d98428ba4d X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.33.187.114];Helo=[64aa7808-outbound-2.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5299 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: DpZlSrfc31xIOxcbHgM7FaXCx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633016475; bh=ogTM7QIJsirKCKWQdMGN/9H13ItOZmNkbaJIIf/dKRk=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=WtWwb3/i5IMAT6ucfDTOzQR4H2jZis0LNrTmfn/MQtH8xfgw66b3DYxv7EEA+lkDEGZ IrfddS2tz/fTL3mVeTnOeQzvM8tn/AIthvE4f+/z2tRSGn/7lQS8ZQuSWOUimF1Dh1kO+ hJI7Tchb5ZCDmp93wVEfXhDZ0+N/1zvRuyI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633016477615100008 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 --- 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..0511df2d99176f97d353f7b5a0a= 00562960e8165 --- /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, + EFI_UNSUPPORTED shall be returned. + + @param [out] MajorRevision Major revision. + @param [out] MinorRevision Minor revision. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Function not implemented. +**/ +EFI_STATUS +EFIAPI +GetTrngVersion ( + OUT UINT16 * CONST MajorRevision, + OUT UINT16 * CONST MinorRevision + ) +{ + ASSERT (FALSE); + return EFI_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, EFI_UNSUPPOR= TED + shall be returned. + + @param [out] Guid UUID of the TRNG backend. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Function not implemented. +**/ +EFI_STATUS +EFIAPI +GetTrngUuid ( + OUT GUID * CONST Guid + ) +{ + ASSERT (FALSE); + return EFI_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 EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_UNSUPPORTED Function not implemented. + @retval EFI_BAD_BUFFER_SIZE Buffer size is too small. + @retval EFI_NOT_READY No Entropy available. +**/ +EFI_STATUS +EFIAPI +GetEntropy ( + IN CONST UINTN EntropyBits, + OUT UINT8 * CONST Buffer, + IN CONST UINTN BufferSize + ) +{ + ASSERT (FALSE); + return EFI_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 (#81341): https://edk2.groups.io/g/devel/message/81341 Mute This Topic: https://groups.io/mt/85976752/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 Sat May 18 01:52:21 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+81339+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 1633016471900869.0974120433721; Thu, 30 Sep 2021 08:41:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id iYMhYY1788612xBkz1s3UzjF; Thu, 30 Sep 2021 08:41:11 -0700 X-Received: from EUR01-VE1-obe.outbound.protection.outlook.com (EUR01-VE1-obe.outbound.protection.outlook.com [40.107.14.48]) by mx.groups.io with SMTP id smtpd.web09.14432.1633016470265058032 for ; Thu, 30 Sep 2021 08:41:11 -0700 X-Received: from AS8PR04CA0194.eurprd04.prod.outlook.com (2603:10a6:20b:2f3::19) by VI1PR08MB3534.eurprd08.prod.outlook.com (2603:10a6:803:85::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.18; Thu, 30 Sep 2021 15:41:05 +0000 X-Received: from AM5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f3:cafe::8a) by AS8PR04CA0194.outlook.office365.com (2603:10a6:20b:2f3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.33.187.114) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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+81339+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.33.187.114 as permitted sender) receiver=protection.outlook.com; client-ip=63.33.187.114; helo=64aa7808-outbound-2.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-2.mta.getcheckrecipient.com (63.33.187.114) by AM5EUR03FT040.mail.protection.outlook.com (10.152.17.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:04 +0000 X-Received: ("Tessian outbound ac52c8afb262:v103"); Thu, 30 Sep 2021 15:41:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 24745b8f97766697 X-CR-MTA-TID: 64aa7808 X-Received: from bebd7768af9a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A739F08C-B53E-445D-A833-A215734D4172.1; Thu, 30 Sep 2021 15:40:54 +0000 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id bebd7768af9a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 15:40:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HXXflCB60KFmF4ktykHRQCmg5Xl60L/S86Edfd6YW8dJBYRArwYLlgYbojG2v5BEZr6e1wXenDhWoT1mYfjj8w963FXLeS8tjUVj57qNPR7dX8bxRLMssdunA25qcKc3c+PJdGqMyz8wxsPTRDsqNfD6O6guk11ZMUM2tatvPF/eNc8HT+jkJBoH7OkVW8AIQYmGC/C8hmiikOSX/IpjvGGAZl6H0+nNhNa7u1vy6wk2TyCKzvqV1lhR5eYKXKF9pZOK/lxAnGwHyWJLuk56uqBWur++M1wNJ5381qIWh3bC2c/Sb+vm/0FOuCO9BQRYXvd3SsAZPZemP3J0JzSmGw== 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; bh=HEZ91jCvEkNkKeLvMx+os4t+RBcKbnUiCqIpPnrZPS8=; b=AH2vEkLrwzubXaP3kT5n7wsKP9hSnny/pD+mK9K/kGk5YWmAUXPKCPOsl21VpcGkrgjyq7FW5Nl0bH/WwgN3J/9X9gI0fVcRwGZNkMggQEFyO6hiGMQGOfGnbVQz/eG5pycjkgzMewOi1vePdCc8z1oBNdb1RZbz5rh5Jam/oKDt7RWJgFEp36/J4/YeEoWUIdrZWS5abNNgrZ0Jtv80jYw/sj4N7iWqm69nc6u6+gSRalQCJWjg2jFkQSmjzqe6FX6ghyv1tNEcmIXhnQRewriaDxWTg7TTN0EP5nwyZda0G58YR5LR1GLfvFy6LFm4xHNDJh7eLaIZrBkyyav/1w== 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 DB6PR07CA0093.eurprd07.prod.outlook.com (2603:10a6:6:2b::31) by DB8PR08MB4970.eurprd08.prod.outlook.com (2603:10a6:10:e7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15; Thu, 30 Sep 2021 15:40:51 +0000 X-Received: from DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2b:cafe::62) by DB6PR07CA0093.outlook.office365.com (2603:10a6:6:2b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.9 via Frontend Transport; Thu, 30 Sep 2021 15:40:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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 DB5EUR03FT050.mail.protection.outlook.com (10.152.21.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:51 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Thu, 30 Sep 2021 15:40:50 +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.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:49 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v1 6/9] SecurityPkg: Rename RdRandGenerateEntropy to common name Date: Thu, 30 Sep 2021 16:40:41 +0100 Message-ID: <20210930154044.37336-7-sami.mujawar@arm.com> In-Reply-To: <20210930154044.37336-1-sami.mujawar@arm.com> References: <20210930154044.37336-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 110e0960-ac9d-42a6-249c-08d98428b6b4 X-MS-TrafficTypeDiagnostic: DB8PR08MB4970:|VI1PR08MB3534: 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: JaETzacMXyEzGx11ujax2GtCEL+hay7ZKNt78Jz0gcb/WfVAcYDpzNzJapWVTrj6yJbs0teU10yCRCm6grbNOj0yjFqJJ+I8UgBGOnzrZ5M4/T08q5wM/eLuaTCE/lYBeKkpEAg+Fvsd/8mkagFLMJnUzlrQ9FloxkCyKmdxUUjPjmzFaOVCPSV3Nkf7L2yuZw/Y7ZZn8+ar8vLBP7MoPVBd4oMmQ5JroYK9Tn/rH6W2XBH+G4pnwuSW9W/6F4/oc48c4mxwJvPmlTV711Ec30P5iU112s2f7m9eKVPLllAiOQDHM+kkdlrQfGQqbOr1qqeaGfSGZIQC83qfxf7HcfJ/HsXpKb7BGnXoFuEKp85Tg/4yBKFsjWVTG91BUZ2svNJJi+lm7RibqbUT7TiArEKL4zxrdN1YWcjlkwnRmphUNrvrvxRqQ0STszpDON8DczY3i8naZ4WCO82rP7E4CFutfYCTun3r0JJcUOkLpgjK+udfZ5coCzMfT7whcin9B/Qk4Wd4pKSA3KvW1K48bR7oGxV6AlamtiihU/S9e8GwnDdt8Snmg2XaO6lvZXVINIsgukQDeBsE+phZ48t9kyQHRM3kuPgOCKs3P/puhD3pTz00jOcwFU7xPVXeAIWfjSS+P3Ju32H7+zKX/ddcr5wiqxEpIKgvTFU4zq23vK2ZLohcTSpEN1kxeoJ50KIHWWKtFs7fAmFWyQQpozpeeqo4xf9AIrNeQH5h03XNDh2mOHyJjpTO2DzjSAdsk2fodYPZWPP6mE0Vl5jabWTOf7p7qpqhXOUpNUVx+HrOOMTnGokKRFH6iGivegQjoVl2YSHtc7KDD6oWOJJ2BDqUapIALkVoiAHDeR1JhzplK5U= 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)(44832011)(426003)(36756003)(70206006)(54906003)(70586007)(1076003)(316002)(15650500001)(356005)(508600001)(86362001)(81166007)(36860700001)(6666004)(82310400003)(2616005)(8936002)(47076005)(26005)(7416002)(83380400001)(7696005)(966005)(4326008)(186003)(2906002)(8676002)(6916009)(336012)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB4970 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: f47afff7-c148-45c2-b65d-08d98428aee3 X-Microsoft-Antispam-Message-Info: mzz6r1j5mBlT3FcAPV8VRlaIz7K1B9dslG4QyHReJHyoxsEMBEhdGPr0ZhU/iWps2qpYX6JdCo4D36ddb0MsEJUqF3Raof9CKPwlzgM3Uiam5aECLC7PpnAD+DeF0xPVLYVGb6uy2KS4NYdx3FHoSFB2T+qXJPitMnWaRLHS5TOqlqnleo11ADafkbIOE9h5zvruyxEzSOXB3dyanfbErzFQfcuBGDAfU7ss5hEx9Epj4cUIce9PzBDzU+KuswzHzHttDiTJwzXL8P5mjIcLPBwMGjisdMX9e6uiCx2FaDKymbKlJ285niv/QT5YdUd9dAnA6Fxv+TIp9HW50NCfR1s7QIJfCsgDLM59hz73MvKMNcZkoBmSms1mkFz3yNWCbfY+SfYWQQCUViVLz8d3y6ZVuX6Agxo+L6W8nCk3tZNPdacLrEqASTbBbJcG7qGVatDEWj0KCD3AQUraDZn78p2YVDpMk9Vq2wXZG2y6tdRMjlEVae8iAjsHOmG+jnvpnbrspdNX0Sp9OvtR68twjoivwnVShl+Gtab51yNKmMIHtgpWBzuxnq5LZjyvW/gUq6P0PSLQTjbZGza0BmMH4zNhwhcWCRjR+QXbMQnnJSG/0CQZbhfFfR6jWjJVwaIryBBgLDlE/0mvBKdRVNUuBQd0hGBZ+VfjvX6coNL2prU93114hcO03BqpR6w0f7t4wYnFgnKCph+SMsWsjbsYb9pAGrUl4GFjFPtBsYQPpMKJUDktT1ARIanWGFwXPIxgCQZ+nU+9vjd7cMmxKxK5ZrX/4SDokTzrzozQNbMB+W1HDjhFCvNVkAj7r5Arzq2d09Go2IZI8euseqBA2vhruw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 15:41:04.7733 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 110e0960-ac9d-42a6-249c-08d98428b6b4 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.33.187.114];Helo=[64aa7808-outbound-2.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3534 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: RtXUDogAtjy0GPCsmrf3DL6Ax1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633016471; bh=DxJIP3fc7mMH6AbmeDSnmXE1grnErDd21sLl6CUIDZk=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=WnGVVfVyYNjAMOiRY79AkYUpXO0HBTzys1ZLLNnKiO3qd3pXYkCEbvYDUO/3Irz3RQO ErsZBdmO017e6qr35dbJg0qOWwf/Z71Tdvh1T99M9mnXn7XeZc6XXbeEUN7KILu5gVOtj 8HvTvPHwrIGl6dsGHwPx70TS40jsQ7Npvno= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633016473050100001 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 --- 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 (#81339): https://edk2.groups.io/g/devel/message/81339 Mute This Topic: https://groups.io/mt/85976749/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 Sat May 18 01:52:21 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+81344+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 1633016491985349.0706591140013; Thu, 30 Sep 2021 08:41:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EtPPYY1788612xf2RLv3ksA2; Thu, 30 Sep 2021 08:41:31 -0700 X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.42]) by mx.groups.io with SMTP id smtpd.web11.14464.1633016490443292661 for ; Thu, 30 Sep 2021 08:41:30 -0700 X-Received: from AS8PR04CA0104.eurprd04.prod.outlook.com (2603:10a6:20b:31e::19) by AM6PR08MB4785.eurprd08.prod.outlook.com (2603:10a6:20b:d2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15; Thu, 30 Sep 2021 15:41:26 +0000 X-Received: from VE1EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31e:cafe::b8) by AS8PR04CA0104.outlook.office365.com (2603:10a6:20b:31e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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+81344+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 VE1EUR03FT014.mail.protection.outlook.com (10.152.19.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:26 +0000 X-Received: ("Tessian outbound 71ebfb754289:v103"); Thu, 30 Sep 2021 15:41:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d822c66c013f0b3c X-CR-MTA-TID: 64aa7808 X-Received: from 2dd6ed84b9df.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id ED8383ED-5866-45A5-88C8-3B846BB31C5B.1; Thu, 30 Sep 2021 15:41:17 +0000 X-Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2dd6ed84b9df.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 15:41:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=edWVQNhbxASgDKwDpy1YBB3+E8E/OWD4dbxnLdKxBEivCbCEfyO/YsKnhOMpLB4JsaXkXw3Cp5x9H9uSOOqAW93m6ORLRfbKKxBdTp6+k901ZYkYf8JHZHJwLGGzRLudmqQRLUFeUj1prf6D9TPJ2dQ71FZMO99YVwJiQOYVBgMUkB3kqti//jxd23BBWE9vBOpLf3dZMNf0/VQwunwErTtDbQFlBZhVGn74Iloy9YAb6l1VETOf2rw1HPW/an6cEnFV+hhccRRcc2uepVopvjeyDpmWjzndA+qPAX4Wdsn7YzzCOG4xfofLMjFSlM07WStOj+Gl69+h+rU9c6+Asg== 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; bh=pdE7feaM8wDfF8sTPPuJCl9IkaYoGsRfhn7UPZeqyw0=; b=bIa1IAtqq1+x94Dh2STKOWZS0DgAUUbMLu0oXKJY9Hv7jjFn6kI92lXhl5XIaUkvi+cYsyrdb0VBQfn3b2gHqbTlL1Bz0Ilg4vjZMvMuW42jcrYt5RMYl6mwW4n1Ac2BkGu3JjE6Z8q5/M2N94+jZRqHXwdRA56TOTiA7eDQ9Hdlq4Lqlm6B2xnyfDCequ122jl+OUaf5CC/NTkUhakbwEgq9ktSND4GnG9QOq/yCWLKq9I8CVUk49sa5wjMqVZfT5VPvtFLDuDi7HHx/gChr93Dm82cZapU1lbIMc98Yofup8yWoSCiNB/4t+1vbM17JMTTE7UFOR8z1iMqLDXNTQ== 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 AM6P192CA0039.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::16) by DB6PR0802MB2437.eurprd08.prod.outlook.com (2603:10a6:4:9f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.20; Thu, 30 Sep 2021 15:41:15 +0000 X-Received: from VE1EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::d7) by AM6P192CA0039.outlook.office365.com (2603:10a6:209:82::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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 VE1EUR03FT018.mail.protection.outlook.com (10.152.18.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:15 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.14; Thu, 30 Sep 2021 15:40:51 +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.14; Thu, 30 Sep 2021 15:40:47 +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.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:50 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v1 7/9] SecurityPkg: Restructure checks in RngGetInfo Date: Thu, 30 Sep 2021 16:40:42 +0100 Message-ID: <20210930154044.37336-8-sami.mujawar@arm.com> In-Reply-To: <20210930154044.37336-1-sami.mujawar@arm.com> References: <20210930154044.37336-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 494f9091-826a-49ba-99dd-08d98428c3ac X-MS-TrafficTypeDiagnostic: DB6PR0802MB2437:|AM6PR08MB4785: 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: ZkbDVswK00Qs9c7Gc8WyLrIOa8YvAqcf5jX/8wwaHtzctofDPuWlMP/QrCP5wyovH3sb6YI1i1pNfb/9amec0TQrQl/Z7hhQQ6YTZSEmxI5cMqvjaZyTfzg/MpHhJFBNk0X/3C26fuIexzkCbEUhtUZpSO7FR/ktVZ5EKJ0zDAuYEsFAVaNuE3FrtaplLzEwplZWOnfwrWQ6tmtmEwai56iawZ7Dj2rlIuVtDQYKV21JNIsjuqXzjrCiWbjivWxtSsVd+QxHDO+jbNrZWUSvT8xwoovhaAVKJsfn3m7zj4HVEXZEiiWFzriafIhehYMjoudZe5iSD5RoQPuUkBqOSRzTLQsn1UCOSgK+Wngg7zho6ZgOwVD2geoD4f1vfxFaZeK3/YmM/NpPapCNiU1G9iOE0Bo/IXwnCLCQw5lvtiv9N1k9xVEFWOz2WyZbUP5uHzF6MzrFx12UiIPPBZPrpFdJuTrwgbO8LRxwwXLg9IOodtHiKpb8TMA/h0FHwn0G1bGqmSZkwbZcYQRCMX0fm/cUaNbyRylPYp7txwLMiTrgSkh4vOWOj/TedVzqKdQe2Yt9kQ1L3tDFxvb1vS0YIkAOt2RKUcDqFSvAxEgbXNOEvpi/lQYjBp+5Ih6pzKkYsn8k3Uq7FYWzlszv7rY73oTZLZGmpIz5+rIFa7NraYTIVhG6YBWRIHMXjK0rOPGZQOZHEBC6dah/6gtBkgZJ5lR6nNI0NVirJTlA7aIzLVi/OWpYSTAtqFq9yeNuovHR/n2Ohr7MTNq37YrfiuRqegrWI4JEoZYmBGoXdT12ft+PXAyjvmKlbxFwpEOUxXqc 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)(81166007)(2906002)(36756003)(86362001)(186003)(4326008)(8676002)(1076003)(356005)(5660300002)(26005)(6666004)(70586007)(6916009)(70206006)(316002)(44832011)(336012)(8936002)(36860700001)(83380400001)(2616005)(426003)(54906003)(508600001)(15650500001)(7416002)(47076005)(82310400003)(7696005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2437 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8b7e7c70-ac5a-421e-3e3e-08d98428bce1 X-Microsoft-Antispam-Message-Info: RYoY16hev7P7oIF2FyXKAx5T061hUPNRyMFYeFeOsamo7aZX2VhlDGGvUKNbYHOrhFbFFKTW2/PjLaT5gjodAY+Pq6adBegfq3Gi8wcIIKz4wjeGX2xt63yZruD5/ORuRrs6P693GgmvgerEA2c2MAQ1zYbObv1zf8oOqXMvOm+Npke97KTr/36XtMDEGpWLOVq5SF32VoBwB6qx+fMgCGbx7GKFej6n11Qbcuc1Svnn6WjpJlmb8GkRjJ1wiWczIrfsFivmEdzPa6+Grprs3gJ49/RdOWGGnZ0UrcOYAsWOZfEy54+uQ9uS/rGcg6r7jjvHD2NOMtnJqy7lyXYUinFevpikZkcB9VgpF62rNoXFYpdjRS1+ZNhmC1nIBuivogtDBKG3wUAD7qKiUr2xzsrvwZVzQSV9/56Qk4aPxgfs3ycq97PiTiXVJR3t0Xe4PW2jGTYj5ZCdBtte9FijV7O8BxYZnn5+7qPz5CmKLFmOWqIi2F7j6DHpFdh0aRQD4kKqTk1SgfEKo8h828Q6FEpWXv8fur9WMf0T5Sm5eUvKukbRHRVrsavJ1CvtyIZoHoVxj1bcwHfQnTEnbj8MjKLnFQIHLerbpRGKp1GrIIf7pqe7RB8DFQV2Bi3+mqkqxvmAe2ZutjTr/F/M/mOAY4zaZyAzhPS2yyksLMQ+RYD4u3kWptu9P6L2GjKgkXXayvJg2jmchocjwbYqesEa4cesVZ0ifWa8ZusoraTDrfZflmrPZGjYrJpCoJxojrVermpyXdjcpsQXVPFNSnvzcscvMtjmahQliI47xjntbd0= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 15:41:26.5013 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 494f9091-826a-49ba-99dd-08d98428c3ac 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: VE1EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4785 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: 2sf3DuyJqxLPUZ614YkRShPWx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633016491; bh=XAz/X7DVmxB3JroO3v4EdD6XTv0GF8FLGCvUlSDlvsU=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=YlMDAg+xKejfDfRFWmvgG/FfYEUjCBgGEu9fUg1iYPYVNOFZWkJVXTGTraWcu5TwKz2 wA+0VuLqLU57x1esp705f9Q6YfGAKpK5FF+TgbILI815VBXR0mt5Ys88uyt/ueIJ76hmc txXxJX39tpa8RQarzN1VfsW9k/oxDY8Bv/E= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633016493441100009 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 --- 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 (#81344): https://edk2.groups.io/g/devel/message/81344 Mute This Topic: https://groups.io/mt/85976760/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 Sat May 18 01:52:21 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+81340+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 1633016475582537.3829560320154; Thu, 30 Sep 2021 08:41:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id CIEoYY1788612xRDHbxtSO5s; Thu, 30 Sep 2021 08:41:15 -0700 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.62]) by mx.groups.io with SMTP id smtpd.web09.14434.1633016474017549043 for ; Thu, 30 Sep 2021 08:41:14 -0700 X-Received: from DB8PR06CA0014.eurprd06.prod.outlook.com (2603:10a6:10:100::27) by AM0PR08MB5345.eurprd08.prod.outlook.com (2603:10a6:208:18c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 30 Sep 2021 15:41:10 +0000 X-Received: from DB5EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:100:cafe::eb) by DB8PR06CA0014.outlook.office365.com (2603:10a6:10:100::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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+81340+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 DB5EUR03FT032.mail.protection.outlook.com (10.152.20.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:10 +0000 X-Received: ("Tessian outbound a77cafe56b47:v103"); Thu, 30 Sep 2021 15:41:10 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6dcd7b79597f4bab X-CR-MTA-TID: 64aa7808 X-Received: from 95dc3a3cb880.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 00B01390-6698-46CA-87FC-E673E296383D.1; Thu, 30 Sep 2021 15:40:55 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 95dc3a3cb880.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 15:40:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aiXb3zNsP8jX7scIgWgG/ar7AYXXQuMuJg8mvftb1XDm6ni+VHS5ur3fCGFzyMm2O1QMQQ48PZGG++gN6AxqpPNBPfD0hKyWSW2u8fbcNuaX+WU1P9uzTRWpDcf3rAPLmH4t6Jq9yULCgQjQPbPbgxzIYeMjzEIKed2zXG+uLoznEB+ysw8+rqS9EVI61+jc+nROA8bdGG5BFGgFSPgC0KNlbmQ/RiheAnzIopHi0ZWkn3/c6lMB2l52OgbAWvTCLTpHzoPO+ZIX10r/gHpZk+msGOPiFzL004/5EuvVBOQyZxqtFH+PDPo3FxH0yI18ZNz+pOyg8I4ckagyT5TFJg== 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; bh=p6JhvCjo59bf93LTkD8I71T4gGXx2QudePiVa7FiZYk=; b=hrF0nf+/0hzLdi5L1mRLUn8kEvI0uXYEu3KCzaTfXeRqfFXoaoMz0K5mQL9NUGygCRBQQWJ7BvywoG67WpljoYp66hOOxfU+jtUAO/7YZugFKjA40RuGdUN/YJ51Ul3sgiZ2bmGF5XeG6G6NUznigg0mOmi8Niw2/GqVg46tBTKgIpcqKt1Ut+lWiPd6v+sRsgwxlpP/5OWcHT1zt4J+rv37tXIQuq2tR/D2C2UtyjvDkICse6qSAo7h8+WK9kCigBLGa4/ds2ki70EYvr2k0vGULC3rSlXtwmjjqUPmlJestFLbyphlIquM9DgcCY1v+FlFs1RAXucPaoP5b78t8g== 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 DB6PR07CA0078.eurprd07.prod.outlook.com (2603:10a6:6:2b::16) by DB8PR08MB5068.eurprd08.prod.outlook.com (2603:10a6:10:e9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.21; Thu, 30 Sep 2021 15:40:51 +0000 X-Received: from DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2b:cafe::10) by DB6PR07CA0078.outlook.office365.com (2603:10a6:6:2b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.7 via Frontend Transport; Thu, 30 Sep 2021 15:40:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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 DB5EUR03FT050.mail.protection.outlook.com (10.152.21.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:51 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Thu, 30 Sep 2021 15:40:51 +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.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:51 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v1 8/9] SecurityPkg: Add RawAlgorithm support using TRNG library Date: Thu, 30 Sep 2021 16:40:43 +0100 Message-ID: <20210930154044.37336-9-sami.mujawar@arm.com> In-Reply-To: <20210930154044.37336-1-sami.mujawar@arm.com> References: <20210930154044.37336-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed14579b-2354-46cc-e050-08d98428b9d8 X-MS-TrafficTypeDiagnostic: DB8PR08MB5068:|AM0PR08MB5345: 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: 1GpRqM3YNNvi1WvtpqOnODv+maSpTMwiCZEzChRrKabJRk1dr6vgva6tiQmBwUShf10FSimbW3eVgHYZ5hEcbRhPVVEjY+Xm5bcnF58wqM6mNmHhyMUmNXfFbUJRWTY0sF+IpSrUNXiHyaDc6KSCoBRa4+YP7EdJlctyAf2/rq66VUY9C9Z/HSEB9xpQEW7ysZ+WUYIVa5wrUxhe2m6kZwUw9LOahp2DPiAhCreuNxedWZFNRBBe9ao1CuLSzYp43oc1sgJ9mhs1SqGYsTio/MPOhDxfN2FAGcvMPXAYSPeZ+p06o63RAdl/MDPlVtQXXbgHIonRn3z7VIQgpkg+KwH0CdKiRlVgEh5AxFde5JEWZ4GlCUxtNHRfYBsR3vEGKSi9lexv5EY4X76JJLOCYVJGFGSzdWbF8MZxqOBSIiF2IlUM9uW08NPtchaw/MAHOUEdnzRuWIM2ilYQ274+IyliPDR8U8jvJ/aqc9FY5/Dg7aNOx2GnRINW9mMfmaR1CPqEbwnlkJ/UtY3o7vTzI2+C0V4Nq5FWaai4L2J5KwXh0wbDfHcpIW8vOLxO/CkVeWcBIYl6MmNtqxB9E5oxkG2JbcIZRJY9EaLo/F63+Vcfma43e0OI3oazoY3/UyWJ1Qq6d/Xt0H/ttTrhvHnnakFruKg30TcMYUYgQMLJneBgabS/KQVZHMpej56GqVrGVgzszSxrd/9Xd+8Nbs70urKgh6lqvJ8Khb7gfuESFohQShhIZyVqRi2iqo+NstlvwDxNopFaFLB0//eY3LjP3IXRk0P1GTyviYS2JTrbs7Ahpk7W5z+y23fZ4Zq+6Uub 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)(47076005)(186003)(5660300002)(54906003)(356005)(19627235002)(70206006)(86362001)(30864003)(26005)(70586007)(8936002)(7696005)(36860700001)(81166007)(36756003)(83380400001)(44832011)(316002)(8676002)(4326008)(7416002)(6666004)(2906002)(2616005)(82310400003)(6916009)(426003)(336012)(1076003)(15650500001)(508600001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5068 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5b7a8bd0-1b02-4a32-a3e5-08d98428aefd X-Microsoft-Antispam-Message-Info: FpZEpiqCuaKWLH+EFyo3TJeUeAA2aKemlpQOgDp07rJZiwKg+XiNWAg1CfE8GAmUsvekuRG2f6N18RYE2FwM9/Clrcyl4kXjPZVYDbZy0IckY+Ga6r7JU6QK2H6t2IbAE4vI/bzC8e82Xvbd4qH/kjEVxgwIx+Z1T3mAnD8/OHBTVVlJUqnNOLmzW3vbEUJC+D9I7DOA5141pF+1Ez3aZj1ADQ4+MA0j5F1gp/IHp8e+b5f/SGPNfiMg2Kxbb8DNT3+jbg2vkriwFzr2dFohVkCrnbx4NpfEfz3dGx+lHPk0mHhx6MsnGgE/+OEPgrLj/CNCJxWNasyCq/p3qhLsO+8cxHf/lbLVf7W1oy8zt35PmhGQ2KtdBDWEpSpd2NoSTzH+MLKxhfQ7QQ+oiwnAwd/01d1oNhxxDa6ZCamNDyXLVDQI61COWfLRZ2sM+GUB8xBQJEQ33uyPzzCVo0DbLfM8wjl6fvtaPHs+YgfXJfJJjK7JXeelBKWHt5IIDhPCHjhXiSqoKVcYprBNXKvpSe9h3NdmtiHn7dg0c7EjdC7Tj6nJpJe7Aq03aW7D8DHuaNhyBRvo/yWqLJ5bTL8bCIvk5Ah/7sV2ULXPjN4QDasDQZXBIWiLIrA1MObwzF8awl4oPpIxjhtgTcIvYGH5jpnk1u8gcM3zqglG3EXMGu6sSPdx7daXZyC30CFHlBSOIdmoD1RcKr+cYkgYBPlABhreoi2t45O1HSur2OLLBnrTZhvMaWQHnseebHctpI0xN9fDyAjlg5c5sFHlzeCRbCoJmTk2QDyyG+m/Jx5ZvKM= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 15:41:10.1112 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed14579b-2354-46cc-e050-08d98428b9d8 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: DB5EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5345 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: s0sBtm1QLvtyXJRHSJchNrRzx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633016475; bh=8gCDK4DaYQdPLvG/7T8yWSwFIenzPr0GwcmpKlcuBSM=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=obpSEKCB0dWYr/SkViZHZuI/cj8X+2+jGP+0LHpSyq3l/mEqfV3b/IGUu3Amr4A79N6 1oQP1mEC2da6cFgnfwYzyHK0Ds8Rrxsu+lejEmxQklrgFBDhcn2hINpfuTgQzoS/yzG3b 6NQi2hR27APmRWFJZ/bRcoAEiuJ9oyxXmhM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633016477546100006 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 --- SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c | 79 ++++++++-- SecurityPkg/RandomNumberGenerator/RngDxe/Arm/RngDxe.c | 164 +++++++++= +++++++++++ SecurityPkg/RandomNumberGenerator/RngDxe/ArmTrng.c | 61 ++++++++ SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c | 2 +- SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf | 12 +- SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h | 1 + SecurityPkg/SecurityPkg.dsc | 12 +- 7 files changed, 318 insertions(+), 13 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c b/Se= curityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c index 282fdca9d334b77e02ca47734df08729e0f4fd31..bae15adf3435897cdb7e781bfb2= 7e2932b5a7dd7 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, &gNullGuid)) { + 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..1f03beec5e5766bb9ca749ad151= 06928b092c1c3 --- /dev/null +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/RngDxe.c @@ -0,0 +1,164 @@ +/** @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 + +#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..6c78948f4659f93203abde1de8b= fbd280ea47e29 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,6 +42,11 @@ [Sources.IA32, Sources.X64] =20 [Sources.AARCH64] AArch64/RngDxe.c + ArmTrng.c + +[Sources.ARM] + Arm/RngDxe.c + ArmTrng.c =20 [Packages] MdePkg/MdePkg.dec @@ -55,6 +61,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 +71,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 + gNullGuid ## 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 f1f678c492b343651c63c075a1d601385d1c2b06..28c9d4328069a8457e5591a05e5= dab8d3a8262d8 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 # ## @@ -84,6 +85,15 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64] # Add support for GCC stack protector NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.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] + ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf + RngLib|MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf + [LibraryClasses.common.PEIM] PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf @@ -268,7 +278,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 (#81340): https://edk2.groups.io/g/devel/message/81340 Mute This Topic: https://groups.io/mt/85976751/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 Sat May 18 01:52:21 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+81343+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 163301649155839.756524468391035; Thu, 30 Sep 2021 08:41:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id JmrhYY1788612xIyVMy7mRJ7; Thu, 30 Sep 2021 08:41:31 -0700 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.72]) by mx.groups.io with SMTP id smtpd.web11.14463.1633016490001719289 for ; Thu, 30 Sep 2021 08:41:30 -0700 X-Received: from AM6P192CA0024.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:83::37) by DB7PR08MB3628.eurprd08.prod.outlook.com (2603:10a6:10:44::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 15:41:26 +0000 X-Received: from VE1EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:83:cafe::50) by AM6P192CA0024.outlook.office365.com (2603:10a6:209:83::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.15 via Frontend Transport; Thu, 30 Sep 2021 15:41:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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+81343+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 VE1EUR03FT026.mail.protection.outlook.com (10.152.18.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:26 +0000 X-Received: ("Tessian outbound 010023020eef:v103"); Thu, 30 Sep 2021 15:41:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d12a593f355e7c97 X-CR-MTA-TID: 64aa7808 X-Received: from 83737c7c919b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4F7606A4-D40B-4925-9D07-7DC5353BE623.1; Thu, 30 Sep 2021 15:40:55 +0000 X-Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 83737c7c919b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 15:40:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hq57IBzpXmb16WLPmA8QveiG7PyuDbEtYQK2c+z9gMOz2sCmVdFQQCZTHDN5tGgfpWyJrrN+cR4kV3gOPb48yaMV6ekEo1oYN9KyPR4v2bfhxVkL4wlbng5vFt5oGptegc2akoHXBhU0n0Y99F31HuuDpG9zyOJSnrthW+gy7vKXGFF+1guR/4xJGlci8lEPCD6m+qNfwpFTbqjGT/ese6zpNJcBcnf604xGJtrRAVAIWWbF297aw5ieG7SeGF+HNiAMEBclc+4Vo9LIRARlp+OZj1/IywRZ9yAV4sqJ0u6L9pTZbrZ/DdiFjUG19vMSxXLUe38IBjRa+8ayFpgPvQ== 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; bh=UaTwglVDq0YozHNUv4pXEtsVDeCp0xwzpkV8eEsfALA=; b=kADYSwztYOqYO1/JCv8O10TR0tT8pBhZzOn+0OeRHZaONjt8ijo/PDqINbnigQk0T0LHF0HXD2X6xMaNOWlVhCSjif/0eNNstpWa+oOPIo8Z9BSQNYSmYAEMWxazosFSy0vCdxfqL4sBUY8QoyBmox8AlUtV7uJFkpXOY+CxSVl5ZuBFvBu5MffNvBiJTy4wc+MKDizbeiDnpA8ebO2MVul4NhwRkW4LBCTuzwwdESnReYK0z66vW5Z0ABxzoyj7MdRvz77wQ8Nb5g6KWi+n08Vs42ec34SpJ6eqlqbv2UwSMJ/GkY4DzAQF3r373fR2qbpRTrTV9CmcaPujlD8WkA== 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 DB6PR07CA0085.eurprd07.prod.outlook.com (2603:10a6:6:2b::23) by AM0PR08MB5380.eurprd08.prod.outlook.com (2603:10a6:208:183::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Thu, 30 Sep 2021 15:40:52 +0000 X-Received: from DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2b:cafe::3c) by DB6PR07CA0085.outlook.office365.com (2603:10a6:6:2b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.8 via Frontend Transport; Thu, 30 Sep 2021 15:40:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; 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 DB5EUR03FT050.mail.protection.outlook.com (10.152.21.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:52 +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.14; Thu, 30 Sep 2021 15:40: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.14; Thu, 30 Sep 2021 15:40:48 +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.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:52 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [edk2-devel] [PATCH v1 9/9] ArmVirtPkg: Kvmtool: Add RNG support using FW-TRNG interface Date: Thu, 30 Sep 2021 16:40:44 +0100 Message-ID: <20210930154044.37336-10-sami.mujawar@arm.com> In-Reply-To: <20210930154044.37336-1-sami.mujawar@arm.com> References: <20210930154044.37336-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76660532-9b23-4bc5-662d-08d98428c379 X-MS-TrafficTypeDiagnostic: AM0PR08MB5380:|DB7PR08MB3628: 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: JXk1+pZC4bwHL9MNBnxUbzDb9g8sXm1Y2dLq2SmDes1HIFPP/ebwOhPAgu96ldD7JjPMbP7uespqlwWP/oodJrxF5XnNdFQbmnQXcTtAX6nwjcObaxwun9iLtIiPIjRuwX6ncHSrH7RovjyD5KKYIAIk+cvVLOWXMip2n8tELDvWlqD+NYcRWzJUOtl3K1Ye5f/I/mNEqRMN1+DhJRS27VzGkwI7kKASYO6yGfLziyA4fpHsIvuPigvHRNxazqDytgxLvJ8zQVFaCOCdMJFEftnFED/VBNGNhvBSr3rQr6xqV2DCTbyUKnfBk0cbw4QETBpNPiFNb+cIb3xOZQSesdxsFn6DgDQZRmfCy+zkgGa6wKwv3vx2eDe/7aJqoYavURLFRn8utgWLhXF6+gLASA+DhTihO3tl4zKcDzdO7rWG6MRcMRzAuaA1n9zBoKPv/SchHOGDKyu/KgXvwHqR45HrwOe4Zm82iUw3shMk34dsV0lM2Ju3d0tx5ZOXfOBJ/SvI66Km1bOrNLDs+24axaDaUmCDqe20SnNR5PxPAXbqhITyQVTELpzrn8vF61K039NVKIeNBwTAMNhSsVTw4k12Weqm4mHk2ALbIEbk4A52yXwdE2iDtL75eeY4qXIpZxKEV/2s7a70GMl4Mb6UEF0u5irqwcphKZr6URGcYu574vh1Z//WmeMOa60sU0esLMoS6OkbNmufg5yx9opNls0zdFv8Px2tDYwWzu/dBCiIRMgytHoPymHXp2fBT4/cHZc7x5L5kDwUWMoeQu2PLQSDHqrAiuhnleGIltdIhHW4rVGinNVo0CQkzJoAQBoo 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)(81166007)(7696005)(6916009)(44832011)(4326008)(5660300002)(6666004)(186003)(356005)(83380400001)(82310400003)(70206006)(2906002)(86362001)(508600001)(426003)(47076005)(8676002)(70586007)(2616005)(336012)(7416002)(36756003)(316002)(54906003)(1076003)(36860700001)(19627235002)(8936002)(26005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5380 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 113756cf-d742-43a3-9423-08d98428af9a X-Microsoft-Antispam-Message-Info: x0+HylsmatRTpBaCs7EoNB86AXQ/48bNS3sEAa+WfMN6VY320B55e6UlxsXl2ZUQIS5Syxc519jdaaTEDO3xHukgp266TnfIQgdwH8zkxaa+TKU/BGtE83schKvO3V1eIe+WceoEoZR8+Hv8NHXK/W77KPP477XW7jgqMMyhyXZeQpeXgWwYjUqmqp/9pewZy49Sf16Mc0tbQvgPZ2bS1grUUo99/QwfEjZ03jxgALRolpzmEhyGQ/5i+dGf3GsSAogGCtCRVbaA2Lr3w4dYKNQRhCJPRjMMJu9OFC64rvPNfz21vkfxBEvJjmBjEDaAPHR93PBohGmNjEFS6fY0zpqxco79Ibk0d9C0Mdg/92LYeVSmGts4KnkkVWfDFQEUU3eSIl9Q2p3TUlXJQKwedD15HJQRHPsMTKmwQ+hkLfKHFc3aJkAwehcHuy1ehHRVQh6bdIW/l3VZCDO5ZNOPdX55O4qI9Yl/gZDfp2kDO7TwPdP3ApS9E8RAm+RescscX+MX0XO4nVoaUQaWeabV5vd2vEIqCI8Tip/ajtfvl4XrgiSY9NDHEJhkwWBlaFLkuCGn+xup0SoG3Ti41YpJ4MEJE0Aglq7vQv9XVXXYqkQ9Pk/pUO1MuK7HwGOVjqlWKcZ5MysQ321w+/EFa0NHrzNl9NxjyK4+ac4jPRCi4buFp97HPamg7XDpHTumYMG00Adil0udFfQFQfQ+s37X6bGDoxGXX8CiHdwAQGK+Az3uPjghj7WFfRn/JAtzTc5Df/50l5/l0vUYZ03SuCPXt1SPqwubSvSYXCVsXgHyzUA= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 15:41:26.1647 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76660532-9b23-4bc5-662d-08d98428c379 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: VE1EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3628 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: LL0JIvh04lKNmx7efyEb4FrYx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633016491; bh=7QG4mrP8QXiHaLHwtjqXfz351XS9hXZ2FErSMJFM+tM=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=PfQkCkUtp6L2icClG7J3DKm605yMy1Z4yrxpM/9fR8APhBv+r7pCqvdMZwlzsPebYwX GUnZ6lS2izUy3ptVzu6iaKgIxM+cGw05K7c7en2E8v/cWZUVAFvmo3xk0jOa+nj8W2ltz AFN2tqv9rJvuYX8dQNKIcp5ffy8vDCT2EWs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633016493296100005 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 Tested-by: Joey Gouly --- ArmVirtPkg/ArmVirtKvmTool.dsc | 10 ++++++++++ ArmVirtPkg/ArmVirtKvmTool.fdf | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index 3bd1cc72a1eb856ad5b48e01915e58f1ee216878..7a1745f59c67c5f9d1f1adb6686= 5afcfc0dfb2a9 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 152453dc4bb3508e75c58fd6dbc8181a86020b2c..cd67121ff2a5d50a1697504f7e3= 100907b6f3e59 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 (#81343): https://edk2.groups.io/g/devel/message/81343 Mute This Topic: https://groups.io/mt/85976759/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-