public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Leif Lindholm" <quic_llindhol@quicinc.com>
To: <devel@edk2.groups.io>, <jiewen.yao@intel.com>
Cc: "pierre.gondois@arm.com" <pierre.gondois@arm.com>,
	Sami Mujawar <sami.mujawar@arm.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Rebecca Cran <rebecca@bsdio.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Gao, Liming" <gaoliming@byosoft.com.cn>,
	"Wang, Jian J" <jian.j.wang@intel.com>
Subject: Re: [edk2-devel] [PATCH v8 06/19] MdePkg/TrngLib: Definition for TRNG library class interface
Date: Wed, 26 Oct 2022 16:44:03 +0100	[thread overview]
Message-ID: <2b288a1a-2a51-6b97-fae1-5f0eb9fc1a77@quicinc.com> (raw)
In-Reply-To: <MW4PR11MB5872CFC0DB569F0676E7E0208C309@MW4PR11MB5872.namprd11.prod.outlook.com>

On 2022-10-26 15:06, Yao, Jiewen wrote:
> Oh, I did not realize we are planning to deprecate ArmPkg.
> Is there a Bugzilla I can refer to?

There wasn't, and that's a very good point.
I have raised https://bugzilla.tianocore.org/show_bug.cgi?id=4121

> If so, I don't think MdeModulePkg is better, because we usually say: industry standard can be in MdePkg. With this justification, I would suggest to name this library class to be ArmTrngLib.

That works for me.

Best Regards,

Leif

> In the library header, I recommend to say: it follows "Arm True Random Number Generator Firmware, Interface 1.0", but not NIST SP800-90A/B/C. The latter is quite misleading, because there is not GetVersion/GetUUID in NIST document at all.
> 
> Thank you
> Yao Jiewen
> 
> 
>> -----Original Message-----
>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Leif
>> Lindholm
>> Sent: Wednesday, October 26, 2022 9:56 PM
>> To: Yao, Jiewen <jiewen.yao@intel.com>
>> Cc: devel@edk2.groups.io; pierre.gondois@arm.com; Sami Mujawar
>> <sami.mujawar@arm.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>;
>> Rebecca Cran <rebecca@bsdio.com>; Kinney, Michael D
>> <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
>> Wang, Jian J <jian.j.wang@intel.com>
>> Subject: Re: [edk2-devel] [PATCH v8 06/19] MdePkg/TrngLib: Definition for
>> TRNG library class interface
>>
>> Hi Jiewen,
>>
>> There could be an argument for moving it to MdeModulePkg, but there is
>> no argument for it moving to ArmPkg.
>>
>> ArmPkg does not have any reason to exist other than that it has not
>> yet been properly integrated in the core packages. Which clearly is
>> becoming more urgent, as I seem to be raising this point even more
>> frequently these days.
>>
>> Best Regards,
>>
>> Leif
>>
>> On Wed, Oct 26, 2022 at 13:25:54 +0000, Yao, Jiewen wrote:
>>> Hi
>>> This API is very ARM platform specific.
>>>
>>> I don't see any interface like GetVersion or GetUUID is defined in 800-
>> 90A/90B/90C.
>>> What it is following is "Arm True Random Number Generator Firmware,
>> Interface 1.0". As such, I feel uncomfortable to define TrngLib in MdePkg.
>>>
>>> I have raised my concern before. My recommend is to move ArmPkg, for
>> example ArmTrngLib.
>>>
>>>
>>>
>>> Thank you
>>> Yao Jiewen
>>>
>>>
>>>> -----Original Message-----
>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
>>>> PierreGondois
>>>> Sent: Tuesday, October 18, 2022 9:21 PM
>>>> To: devel@edk2.groups.io
>>>> Cc: Sami Mujawar <sami.mujawar@arm.com>; Leif Lindholm
>>>> <quic_llindhol@quicinc.com>; Ard Biesheuvel
>>>> <ardb+tianocore@kernel.org>; Rebecca Cran <rebecca@bsdio.com>;
>> Kinney,
>>>> Michael D <michael.d.kinney@intel.com>; Gao, Liming
>>>> <gaoliming@byosoft.com.cn>; Yao, Jiewen <jiewen.yao@intel.com>;
>> Wang,
>>>> Jian J <jian.j.wang@intel.com>
>>>> Subject: [edk2-devel] [PATCH v8 06/19] MdePkg/TrngLib: Definition for
>>>> TRNG library class interface
>>>>
>>>> From: Sami Mujawar <sami.mujawar@arm.com>
>>>>
>>>> Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3668)
>>>>
>>>> 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: Pierre Gondois <pierre.gondois@arm.com>
>>>> ---
>>>>   MdePkg/Include/Library/TrngLib.h | 103
>>>> +++++++++++++++++++++++++++++++
>>>>   MdePkg/MdePkg.dec                |   5 ++
>>>>   2 files changed, 108 insertions(+)
>>>>   create mode 100644 MdePkg/Include/Library/TrngLib.h
>>>>
>>>> diff --git a/MdePkg/Include/Library/TrngLib.h
>>>> b/MdePkg/Include/Library/TrngLib.h
>>>> new file mode 100644
>>>> index 000000000000..535fd53f4305
>>>> --- /dev/null
>>>> +++ b/MdePkg/Include/Library/TrngLib.h
>>>> @@ -0,0 +1,103 @@
>>>> +/** @file
>>>> +  TRNG interface library definitions.
>>>> +
>>>> +  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
>>>> +**/
>>>> +
>>>> +#ifndef TRNG_LIB_H_
>>>> +#define TRNG_LIB_H_
>>>> +
>>>> +/** Get the version of the TRNG backend.
>>>> +
>>>> +  A TRNG may be implemented by the system firmware, in which case
>> this
>>>> +  function shall return the version of the TRNG backend.
>>>> +  The implementation must return NOT_SUPPORTED if a Back end is
>> not
>>>> 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
>>>> +  );
>>>> +
>>>> +/** 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
>>>> +  );
>>>> +
>>>> +/** 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
>>>> +  );
>>>> +
>>>> +/** 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
>>>> +  );
>>>> +
>>>> +#endif // TRNG_LIB_H_
>>>> diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
>>>> index 4c81cbd75ab2..0a7859fc1d3f 100644
>>>> --- a/MdePkg/MdePkg.dec
>>>> +++ b/MdePkg/MdePkg.dec
>>>> @@ -8,6 +8,7 @@
>>>>   # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
>>>>   # (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development
>>>> LP<BR>
>>>>   # Copyright (c) 2022, Loongson Technology Corporation Limited. All
>> rights
>>>> reserved.<BR>
>>>> +# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.<BR>
>>>>   #
>>>>   # SPDX-License-Identifier: BSD-2-Clause-Patent
>>>>   #
>>>> @@ -279,6 +280,10 @@ [LibraryClasses]
>>>>     ## @libraryclass  Provides function for SMM CPU Rendezvous Library.
>>>>     SmmCpuRendezvousLib|Include/Library/SmmCpuRendezvousLib.h
>>>>
>>>> +  ##  @libraryclass  Provides services to generate Entropy using a TRNG.
>>>> +  #
>>>> +  TrngLib|Include/Library/TrngLib.h
>>>> +
>>>>   [LibraryClasses.IA32, LibraryClasses.X64, LibraryClasses.AARCH64]
>>>>     ##  @libraryclass  Provides services to generate random number.
>>>>     #
>>>> --
>>>> 2.25.1
>>>>
>>>>
>>>>
>>>> -=-=-=-=-=-=
>>>> Groups.io Links: You receive all messages sent to this group.
>>>> View/Reply Online (#95322):
>>>> https://edk2.groups.io/g/devel/message/95322
>>>> Mute This Topic: https://groups.io/mt/94407745/1772286
>>>> Group Owner: devel+owner@edk2.groups.io
>>>> Unsubscribe: https://edk2.groups.io/g/devel/unsub
>> [jiewen.yao@intel.com]
>>>> -=-=-=-=-=-=
>>>>
>>>
>>
>>
>>
>>
> 
> 
> 
> 
> 
> 


  reply	other threads:[~2022-10-26 15:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 13:20 [PATCH v8 00/19] Add Raw algorithm support using Arm FW-TRNG interface PierreGondois
2022-10-18 13:20 ` [PATCH v8 01/19] ArmPkg: PCD to select conduit for monitor calls PierreGondois
2022-10-18 13:20 ` [PATCH v8 02/19] ArmPkg/ArmMonitorLib: Definition for ArmMonitorLib library class PierreGondois
2022-10-18 13:20 ` [PATCH v8 03/19] ArmPkg/ArmMonitorLib: Add ArmMonitorLib PierreGondois
2022-10-18 13:20 ` [PATCH v8 04/19] ArmPkg: Sort HVC/SMC section alphbetically in ArmPkg.dsc PierreGondois
2022-10-18 13:20 ` [PATCH v8 05/19] ArmPkg/ArmHvcLibNull: Add NULL instance of ArmHvcLib PierreGondois
2022-10-18 13:20 ` [PATCH v8 06/19] MdePkg/TrngLib: Definition for TRNG library class interface PierreGondois
2022-10-26 13:25   ` [edk2-devel] " Yao, Jiewen
2022-10-26 13:56     ` Leif Lindholm
2022-10-26 14:06       ` Yao, Jiewen
2022-10-26 15:44         ` Leif Lindholm [this message]
2022-10-18 13:20 ` [PATCH v8 07/19] MdePkg/TrngLib: Add NULL instance of TRNG Library PierreGondois
2022-10-18 13:20 ` [PATCH v8 08/19] ArmPkg: Add FID definitions for Firmware TRNG PierreGondois
2022-10-20  8:55   ` Leif Lindholm
2022-10-18 13:20 ` [PATCH v8 09/19] ArmPkg/TrngLib: Add Arm Firmware TRNG library PierreGondois
2022-10-18 13:20 ` [PATCH v8 10/19] SecurityPkg/RngDxe: Rename RdRandGenerateEntropy to generic name PierreGondois
2022-10-18 13:20 ` [PATCH v8 11/19] SecurityPkg/RngDxe: Replace Pcd with Sp80090Ctr256Guid PierreGondois
2022-10-18 13:20 ` [PATCH v8 12/19] SecurityPkg/RngDxe: Remove ArchGetSupportedRngAlgorithms() PierreGondois
2022-10-18 13:20 ` [PATCH v8 13/19] SecurityPkg/RngDxe: Documentation/include/parameter cleanup PierreGondois
2022-10-18 13:20 ` [PATCH v8 14/19] SecurityPkg/RngDxe: Check before advertising Cpu Rng algo PierreGondois
2022-10-18 13:20 ` [PATCH v8 15/19] SecurityPkg/RngDxe: Add AArch64 RawAlgorithm support through TrngLib PierreGondois
2022-10-18 13:20 ` [PATCH v8 16/19] SecurityPkg/RngDxe: Add debug warning for NULL PcdCpuRngSupportedAlgorithm PierreGondois
2022-10-18 13:20 ` [PATCH v8 17/19] SecurityPkg/RngDxe: Rename AArch64/RngDxe.c PierreGondois
2022-10-18 13:20 ` [PATCH v8 18/19] SecurityPkg/RngDxe: Add Arm support of RngDxe PierreGondois
2022-10-18 13:20 ` [PATCH v8 19/19] 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=2b288a1a-2a51-6b97-fae1-5f0eb9fc1a77@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