From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by mx.groups.io with SMTP id smtpd.web09.14971.1664305382951376438 for ; Tue, 27 Sep 2022 12:03:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=WZYAQJKu; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: quicinc.com, ip: 205.220.168.131, mailfrom: quic_llindhol@quicinc.com) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28RG78ck016511; Tue, 27 Sep 2022 19:02:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=0pSAN7/zGNyB5qbNnP7hI2D/Zi5vfgqFhh5FvIcHENs=; b=WZYAQJKu9p6/EKMA3BqQyZVVn19dg7vxsyjhSd+GfHPAJ4tXZR404n4nHPvxIJUchu9X St8dGi5DrfEUbbEtpNpe9abUlGnjcbnW6rR1UeJtBsA8tgjJM9GI0dSmrfG4yTwKvSs7 WO0tLzTrxdtQuL7y03KhkhgDegY/tmAA/bdtc9byi/iwO+9MABpGmDQ/u2NhxyKP0tpp kGeX5tcnAqbTSoa4ZCy5N/MFao4Un7C2WNsiWPXdHwRbQHGHnBd/wVFBX+J0IzXXqzlB haw++Z44SFn2hHee1xmTitm+qSyFWs2X0AJEt+2UqbwIphGtst/Z91ty0vyYK20gTO4n cw== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jupssu777-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Sep 2022 19:02:51 +0000 Received: from nasanex01c.na.qualcomm.com (corens_vlan604_snip.qualcomm.com [10.53.140.1]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 28RJ2px6008880 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Sep 2022 19:02:51 GMT Received: from [10.110.17.52] (10.80.80.8) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 27 Sep 2022 12:02:50 -0700 Message-ID: <8dd4dc9f-3c98-af25-78a2-e575e8d4ec4d@quicinc.com> Date: Tue, 27 Sep 2022 12:02:49 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH v5 06/21] MdePkg/TrngLib: Add NULL instance of TRNG Library To: , CC: Sami Mujawar , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang References: <20220919192207.637786-1-Pierre.Gondois@arm.com> <20220919192207.637786-7-Pierre.Gondois@arm.com> From: "Leif Lindholm" In-Reply-To: <20220919192207.637786-7-Pierre.Gondois@arm.com> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: XIgc1b7pLKtXav_HkV2L0pFhV7d9aJy2 X-Proofpoint-ORIG-GUID: XIgc1b7pLKtXav_HkV2L0pFhV7d9aJy2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-27_09,2022-09-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 mlxscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 phishscore=0 adultscore=0 impostorscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209270119 Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit On 2022-09-19 12:21, Pierre.Gondois@arm.com wrote: > From: Sami Mujawar > > Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3668) > > 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 The patch needs to be signed off by the contributor (you), and no one else. You cannot make legal statements on their behalf, and you must make the statement on your own behalf. > --- > .../Library/BaseTrngLibNull/BaseTrngLibNull.c | 117 ++++++++++++++++++ > .../BaseTrngLibNull/BaseTrngLibNull.inf | 30 +++++ > .../BaseTrngLibNull/BaseTrngLibNull.uni | 12 ++ > MdePkg/MdePkg.dsc | 1 + > 4 files changed, 160 insertions(+) > create mode 100644 MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.c > create mode 100644 MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf > create mode 100644 MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.uni > > diff --git a/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.c b/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.c > new file mode 100644 > index 000000000000..60774b33dd58 > --- /dev/null > +++ b/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.c > @@ -0,0 +1,117 @@ > +/** @file > + Null version of TRNG (True Random Number Generator) services. > + > + Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > + @par Reference(s): > + - [1] 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) > + > + @par Glossary: > + - TRNG - True Random Number Generator > +**/ > + > +#include > +#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 present. > + > + @param [out] MajorRevision Major revision. > + @param [out] MinorRevision Minor revision. > + > + @retval RETURN_SUCCESS The function completed successfully. > + @retval RETURN_INVALID_PARAMETER Invalid parameter. > + @retval RETURN_UNSUPPORTED Backend not present. > +**/ > +RETURN_STATUS > +EFIAPI > +GetTrngVersion ( > + OUT UINT16 *MajorRevision, > + OUT UINT16 *MinorRevision > + ) > +{ > + ASSERT (FALSE); > + return RETURN_UNSUPPORTED; > +} > + > +/** Get the UUID of the TRNG backend. > + > + A TRNG may be implemented by the system firmware, in which case this > + function shall return the UUID of the TRNG backend. > + Returning the TRNG UUID is optional and if not implemented, RETURN_UNSUPPORTED > + shall be returned. > + > + Note: The caller must not rely on the returned UUID as a trustworthy TRNG > + Back end identity > + > + @param [out] Guid UUID of the TRNG backend. > + > + @retval RETURN_SUCCESS The function completed successfully. > + @retval RETURN_INVALID_PARAMETER Invalid parameter. > + @retval RETURN_UNSUPPORTED Function not implemented. > +**/ > +RETURN_STATUS > +EFIAPI > +GetTrngUuid ( > + OUT GUID *Guid > + ) > +{ > + ASSERT (FALSE); > + return RETURN_UNSUPPORTED; > +} > + > +/** Returns maximum number of entropy bits that can be returned in a single > + call. > + > + @return Returns the maximum number of Entropy bits that can be returned > + in a single call to GetTrngEntropy(). > +**/ > +UINTN > +EFIAPI > +GetTrngMaxSupportedEntropyBits ( > + VOID > + ) > +{ > + ASSERT (FALSE); > + return 0; > +} > + > +/** Returns N bits of conditioned entropy. > + > + See [1] 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 satisfied, > + and is FALSE otherwise. > + > + @param [in] EntropyBits Number of entropy bits requested. > + @param [in] BufferSize Size of the Buffer in bytes. > + @param [out] Buffer Buffer to return the entropy bits. > + > + @retval RETURN_SUCCESS The function completed successfully. > + @retval RETURN_INVALID_PARAMETER Invalid parameter. > + @retval RETURN_UNSUPPORTED Function not implemented. > + @retval RETURN_BAD_BUFFER_SIZE Buffer size is too small. > + @retval RETURN_NOT_READY No Entropy available. > +**/ > +RETURN_STATUS > +EFIAPI > +GetTrngEntropy ( > + IN UINTN EntropyBits, > + IN UINTN BufferSize, > + OUT UINT8 *Buffer > + ) > +{ > + ASSERT (FALSE); > + return RETURN_UNSUPPORTED; > +} > diff --git a/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf b/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf > new file mode 100644 > index 000000000000..004aa8445a25 > --- /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 - 2022, Arm Limited. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION = 0x0001001B > + BASE_NAME = BaseTrngLibNull > + MODULE_UNI_FILE = BaseTrngLibNull.uni > + FILE_GUID = ABDE1C87-4F50-4B82-9133-7A79E13F69AB > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = TrngLib > + > +# > +# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 RISCV64? > +# > + > +[Sources] > + BaseTrngLibNull.c > + > +[Packages] > + MdePkg/MdePkg.dec > + > +[LibraryClasses] > + DebugLib > diff --git a/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.uni b/MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.uni > new file mode 100644 > index 000000000000..952e4354c0cc > --- /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 - 2022, 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 instance should be used with modules that inherit an (indirect) dependency on the TrngLib class, but never actually call TrngLib APIs for consuming Entropy." > diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc > index cc1ac196a931..1a3a3c3243f5 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 Indentation? / Leif > > MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf > MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf