public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Leif Lindholm" <quic_llindhol@quicinc.com>
To: <Pierre.Gondois@arm.com>, <devel@edk2.groups.io>
Cc: Sami Mujawar <sami.mujawar@arm.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Rebecca Cran <rebecca@bsdio.com>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Jian J Wang <jian.j.wang@intel.com>
Subject: Re: [PATCH v5 06/21] MdePkg/TrngLib: Add NULL instance of TRNG Library
Date: Tue, 27 Sep 2022 12:02:49 -0700	[thread overview]
Message-ID: <8dd4dc9f-3c98-af25-78a2-e575e8d4ec4d@quicinc.com> (raw)
In-Reply-To: <20220919192207.637786-7-Pierre.Gondois@arm.com>

On 2022-09-19 12:21, Pierre.Gondois@arm.com wrote:
> From: Sami Mujawar <sami.mujawar@arm.com>
> 
> 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 <sami.mujawar@arm.com>

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.<BR>
> +
> +  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 <Library/DebugLib.h>
> +#include <Library/TrngLib.h>
> +
> +/** Get the version of the TRNG backend.
> +
> +  A TRNG may be implemented by the system firmware, in which case this
> +  function shall return the version of the TRNG backend.
> +  The implementation must return NOT_SUPPORTED if a Back end is not 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.<BR>
> +#
> +#  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.<BR>
> +//
> +// 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


  reply	other threads:[~2022-09-27 19:03 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 19:21 [PATCH v5 00/21] Add Raw algorithm support using Arm FW-TRNG interface PierreGondois
2022-09-19 19:21 ` [PATCH v5 01/21] ArmPkg: PCD to select conduit for monitor calls PierreGondois
2022-09-27 18:59   ` Leif Lindholm
2022-09-19 19:21 ` [PATCH v5 02/21] ArmPkg/ArmMonitorLib: Definition for ArmMonitorLib library class PierreGondois
2022-09-19 19:21 ` [PATCH v5 03/21] ArmPkg/ArmMonitorLib: Add ArmMonitorLib PierreGondois
2022-09-27 18:51   ` Leif Lindholm
2022-09-27 19:00   ` [edk2-devel] " Rebecca Cran
2022-09-27 19:10   ` Rebecca Cran
2022-09-19 19:21 ` [PATCH v5 04/21] ArmPkg/ArmHvcNullLib: Add NULL instance of ArmHvcLib PierreGondois
2022-09-27 18:55   ` Leif Lindholm
2022-09-19 19:21 ` [PATCH v5 05/21] MdePkg/TrngLib: Definition for TRNG library class interface PierreGondois
2022-09-27 19:00   ` Leif Lindholm
2022-09-19 19:21 ` [PATCH v5 06/21] MdePkg/TrngLib: Add NULL instance of TRNG Library PierreGondois
2022-09-27 19:02   ` Leif Lindholm [this message]
2022-09-19 19:21 ` [PATCH v5 07/21] ArmPkg: Add FID definitions for Firmware TRNG PierreGondois
2022-09-27 19:04   ` Leif Lindholm
2022-09-19 19:21 ` [PATCH v5 08/21] ArmPkg/TrngLib: Add Arm Firmware TRNG library PierreGondois
2022-09-19 19:21 ` [PATCH v5 09/21] MdePkg/BaseRngLib: Rename ArmReadIdIsar0() to ArmGetFeatRng() PierreGondois
2022-09-27 21:44   ` [edk2-devel] " Rebecca Cran
2022-09-28 17:10   ` Leif Lindholm
2022-09-29 16:21     ` PierreGondois
2022-09-29 17:09       ` Leif Lindholm
2022-09-19 19:21 ` [PATCH v5 10/21] ArmPkg/ArmLib: Add ArmReadIdIsar0() helper PierreGondois
2022-09-19 19:21 ` [PATCH v5 11/21] ArmPkg/ArmLib: Add ArmHasRngExt() PierreGondois
2022-09-19 19:21 ` [PATCH v5 12/21] SecurityPkg/RngDxe: Rename RdRandGenerateEntropy to generic name PierreGondois
2022-09-19 19:21 ` [PATCH v5 13/21] SecurityPkg/RngDxe: Replace Pcd with Sp80090Ctr256Guid PierreGondois
2022-09-19 19:22 ` [PATCH v5 14/21] SecurityPkg/RngDxe: Remove ArchGetSupportedRngAlgorithms() PierreGondois
2022-09-19 19:22 ` [PATCH v5 15/21] SecurityPkg/RngDxe: Documentation/include/parameter cleanup PierreGondois
2022-09-19 19:22 ` [PATCH v5 16/21] SecurityPkg/RngDxe: Check before advertising Cpu Rng algo PierreGondois
2022-09-19 19:22 ` [PATCH v5 17/21] SecurityPkg/RngDxe: Add AArch64 RawAlgorithm support through TrngLib PierreGondois
2022-09-19 19:22 ` [PATCH v5 18/21] SecurityPkg/RngDxe: Add debug warning for NULL PcdCpuRngSupportedAlgorithm PierreGondois
2022-09-19 19:22 ` [PATCH v5 19/21] SecurityPkg/RngDxe: Rename AArch64/RngDxe.c PierreGondois
2022-09-19 19:22 ` [PATCH v5 20/21] SecurityPkg/RngDxe: Add Arm support of RngDxe PierreGondois
2022-09-19 19:22 ` [PATCH v5 21/21] ArmVirtPkg: Kvmtool: Add RNG support using FW-TRNG interface PierreGondois

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8dd4dc9f-3c98-af25-78a2-e575e8d4ec4d@quicinc.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox