1 | /** @file
|
---|
2 | Null version of the Arm TRNG (True Random Number Generator) services
|
---|
3 | (Cf [1]).
|
---|
4 |
|
---|
5 | Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.<BR>
|
---|
6 |
|
---|
7 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
8 |
|
---|
9 | @par Reference(s):
|
---|
10 | - [1] Arm True Random Number Generator Firmware, Interface 1.0,
|
---|
11 | Platform Design Document.
|
---|
12 | (https://developer.arm.com/documentation/den0098/latest/)
|
---|
13 | - [2] NIST Special Publication 800-90B, Recommendation for the Entropy
|
---|
14 | Sources Used for Random Bit Generation.
|
---|
15 | (https://csrc.nist.gov/publications/detail/sp/800-90b/final)
|
---|
16 |
|
---|
17 | @par Glossary:
|
---|
18 | - TRNG - True Random Number Generator
|
---|
19 | **/
|
---|
20 |
|
---|
21 | #include <Library/DebugLib.h>
|
---|
22 | #include <Library/ArmTrngLib.h>
|
---|
23 |
|
---|
24 | /** Get the version of the Arm TRNG backend.
|
---|
25 |
|
---|
26 | A TRNG may be implemented by the system firmware, in which case this
|
---|
27 | function shall return the version of the Arm TRNG backend.
|
---|
28 | The implementation must return NOT_SUPPORTED if a Back end is not present.
|
---|
29 |
|
---|
30 | @param [out] MajorRevision Major revision.
|
---|
31 | @param [out] MinorRevision Minor revision.
|
---|
32 |
|
---|
33 | @retval RETURN_SUCCESS The function completed successfully.
|
---|
34 | @retval RETURN_INVALID_PARAMETER Invalid parameter.
|
---|
35 | @retval RETURN_UNSUPPORTED Backend not present.
|
---|
36 | **/
|
---|
37 | RETURN_STATUS
|
---|
38 | EFIAPI
|
---|
39 | GetArmTrngVersion (
|
---|
40 | OUT UINT16 *MajorRevision,
|
---|
41 | OUT UINT16 *MinorRevision
|
---|
42 | )
|
---|
43 | {
|
---|
44 | ASSERT (FALSE);
|
---|
45 | return RETURN_UNSUPPORTED;
|
---|
46 | }
|
---|
47 |
|
---|
48 | /** Get the UUID of the Arm TRNG backend.
|
---|
49 |
|
---|
50 | A TRNG may be implemented by the system firmware, in which case this
|
---|
51 | function shall return the UUID of the TRNG backend.
|
---|
52 | Returning the Arm TRNG UUID is optional and if not implemented,
|
---|
53 | RETURN_UNSUPPORTED shall be returned.
|
---|
54 |
|
---|
55 | Note: The caller must not rely on the returned UUID as a trustworthy Arm TRNG
|
---|
56 | Back end identity
|
---|
57 |
|
---|
58 | @param [out] Guid UUID of the Arm TRNG backend.
|
---|
59 |
|
---|
60 | @retval RETURN_SUCCESS The function completed successfully.
|
---|
61 | @retval RETURN_INVALID_PARAMETER Invalid parameter.
|
---|
62 | @retval RETURN_UNSUPPORTED Function not implemented.
|
---|
63 | **/
|
---|
64 | RETURN_STATUS
|
---|
65 | EFIAPI
|
---|
66 | GetArmTrngUuid (
|
---|
67 | OUT GUID *Guid
|
---|
68 | )
|
---|
69 | {
|
---|
70 | ASSERT (FALSE);
|
---|
71 | return RETURN_UNSUPPORTED;
|
---|
72 | }
|
---|
73 |
|
---|
74 | /** Returns maximum number of entropy bits that can be returned in a single
|
---|
75 | call.
|
---|
76 |
|
---|
77 | @return Returns the maximum number of Entropy bits that can be returned
|
---|
78 | in a single call to GetArmTrngEntropy().
|
---|
79 | **/
|
---|
80 | UINTN
|
---|
81 | EFIAPI
|
---|
82 | GetArmTrngMaxSupportedEntropyBits (
|
---|
83 | VOID
|
---|
84 | )
|
---|
85 | {
|
---|
86 | ASSERT (FALSE);
|
---|
87 | return 0;
|
---|
88 | }
|
---|
89 |
|
---|
90 | /** Returns N bits of conditioned entropy.
|
---|
91 |
|
---|
92 | See [2] Section 2.3.1 GetEntropy: An Interface to the Entropy Source
|
---|
93 | GetEntropy
|
---|
94 | Input:
|
---|
95 | bits_of_entropy: the requested amount of entropy
|
---|
96 | Output:
|
---|
97 | entropy_bitstring: The string that provides the requested entropy.
|
---|
98 | status: A Boolean value that is TRUE if the request has been satisfied,
|
---|
99 | and is FALSE otherwise.
|
---|
100 |
|
---|
101 | @param [in] EntropyBits Number of entropy bits requested.
|
---|
102 | @param [in] BufferSize Size of the Buffer in bytes.
|
---|
103 | @param [out] Buffer Buffer to return the entropy bits.
|
---|
104 |
|
---|
105 | @retval RETURN_SUCCESS The function completed successfully.
|
---|
106 | @retval RETURN_INVALID_PARAMETER Invalid parameter.
|
---|
107 | @retval RETURN_UNSUPPORTED Function not implemented.
|
---|
108 | @retval RETURN_BAD_BUFFER_SIZE Buffer size is too small.
|
---|
109 | @retval RETURN_NOT_READY No Entropy available.
|
---|
110 | **/
|
---|
111 | RETURN_STATUS
|
---|
112 | EFIAPI
|
---|
113 | GetArmTrngEntropy (
|
---|
114 | IN UINTN EntropyBits,
|
---|
115 | IN UINTN BufferSize,
|
---|
116 | OUT UINT8 *Buffer
|
---|
117 | )
|
---|
118 | {
|
---|
119 | ASSERT (FALSE);
|
---|
120 | return RETURN_UNSUPPORTED;
|
---|
121 | }
|
---|