diff options
author | Sami Mujawar <sami.mujawar@arm.com> | 2022-10-28 17:32:46 +0200 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-11-06 16:32:28 +0000 |
commit | cbce5a1a93ab092d9c2c4c7949f26f6a9d753995 (patch) | |
tree | d8cf05f5b31d2cf0c5a79d36c180215628babab6 | |
parent | 3d480a93defc0e39410877b477519592b7656b3d (diff) | |
download | edk2-cbce5a1a93ab092d9c2c4c7949f26f6a9d753995.zip edk2-cbce5a1a93ab092d9c2c4c7949f26f6a9d753995.tar.gz edk2-cbce5a1a93ab092d9c2c4c7949f26f6a9d753995.tar.bz2 |
MdePkg/ArmTrngLib: Definition for Arm TRNG library class interface
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 Arm True Random Number Generator (TRNG) library defines an
interface to access the entropy source on a platform, following
the 'Arm True Random Number Generator Firmware Interface'
specification.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
-rw-r--r-- | MdePkg/Include/Library/ArmTrngLib.h | 106 | ||||
-rw-r--r-- | MdePkg/MdePkg.dec | 5 |
2 files changed, 111 insertions, 0 deletions
diff --git a/MdePkg/Include/Library/ArmTrngLib.h b/MdePkg/Include/Library/ArmTrngLib.h new file mode 100644 index 0000000..551c244 --- /dev/null +++ b/MdePkg/Include/Library/ArmTrngLib.h @@ -0,0 +1,106 @@ +/** @file
+ Arm TRNG interface library definitions (Cf. [1]).
+
+ Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.<BR>
+
+ 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-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 ARM_TRNG_LIB_H_
+#define ARM_TRNG_LIB_H_
+
+/** Get the version of the Arm TRNG backend.
+
+ A TRNG may be implemented by the system firmware, in which case this
+ function shall return the version of the Arm 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
+GetArmTrngVersion (
+ OUT UINT16 *MajorRevision,
+ OUT UINT16 *MinorRevision
+ );
+
+/** Get the UUID of the Arm 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 Arm 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 Arm TRNG
+ Back end identity
+
+ @param [out] Guid UUID of the Arm TRNG backend.
+
+ @retval RETURN_SUCCESS The function completed successfully.
+ @retval RETURN_INVALID_PARAMETER Invalid parameter.
+ @retval RETURN_UNSUPPORTED Function not implemented.
+**/
+RETURN_STATUS
+EFIAPI
+GetArmTrngUuid (
+ 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 GetArmTrngEntropy().
+**/
+UINTN
+EFIAPI
+GetArmTrngMaxSupportedEntropyBits (
+ VOID
+ );
+
+/** Returns N bits of conditioned entropy.
+
+ See [2] 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
+GetArmTrngEntropy (
+ IN UINTN EntropyBits,
+ IN UINTN BufferSize,
+ OUT UINT8 *Buffer
+ );
+
+#endif // ARM_TRNG_LIB_H_
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index ba287d9..e49b2d5 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 @@ ## @libraryclass Provides function for SMM CPU Rendezvous Library.
SmmCpuRendezvousLib|Include/Library/SmmCpuRendezvousLib.h
+ ## @libraryclass Provides services to generate Entropy using a TRNG.
+ #
+ ArmTrngLib|Include/Library/ArmTrngLib.h
+
[LibraryClasses.IA32, LibraryClasses.X64, LibraryClasses.AARCH64]
## @libraryclass Provides services to generate random number.
#
|