1 | /** @file
|
---|
2 | Provides random number generator services.
|
---|
3 |
|
---|
4 | Copyright (c) 2023, Arm Limited. All rights reserved.<BR>
|
---|
5 | Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #ifndef __RNG_LIB_H__
|
---|
11 | #define __RNG_LIB_H__
|
---|
12 |
|
---|
13 | /**
|
---|
14 | Generates a 16-bit random number.
|
---|
15 |
|
---|
16 | if Rand is NULL, then ASSERT().
|
---|
17 |
|
---|
18 | @param[out] Rand Buffer pointer to store the 16-bit random value.
|
---|
19 |
|
---|
20 | @retval TRUE Random number generated successfully.
|
---|
21 | @retval FALSE Failed to generate the random number.
|
---|
22 |
|
---|
23 | **/
|
---|
24 | BOOLEAN
|
---|
25 | EFIAPI
|
---|
26 | GetRandomNumber16 (
|
---|
27 | OUT UINT16 *Rand
|
---|
28 | );
|
---|
29 |
|
---|
30 | /**
|
---|
31 | Generates a 32-bit random number.
|
---|
32 |
|
---|
33 | if Rand is NULL, then ASSERT().
|
---|
34 |
|
---|
35 | @param[out] Rand Buffer pointer to store the 32-bit random value.
|
---|
36 |
|
---|
37 | @retval TRUE Random number generated successfully.
|
---|
38 | @retval FALSE Failed to generate the random number.
|
---|
39 |
|
---|
40 | **/
|
---|
41 | BOOLEAN
|
---|
42 | EFIAPI
|
---|
43 | GetRandomNumber32 (
|
---|
44 | OUT UINT32 *Rand
|
---|
45 | );
|
---|
46 |
|
---|
47 | /**
|
---|
48 | Generates a 64-bit random number.
|
---|
49 |
|
---|
50 | if Rand is NULL, then ASSERT().
|
---|
51 |
|
---|
52 | @param[out] Rand Buffer pointer to store the 64-bit random value.
|
---|
53 |
|
---|
54 | @retval TRUE Random number generated successfully.
|
---|
55 | @retval FALSE Failed to generate the random number.
|
---|
56 |
|
---|
57 | **/
|
---|
58 | BOOLEAN
|
---|
59 | EFIAPI
|
---|
60 | GetRandomNumber64 (
|
---|
61 | OUT UINT64 *Rand
|
---|
62 | );
|
---|
63 |
|
---|
64 | /**
|
---|
65 | Generates a 128-bit random number.
|
---|
66 |
|
---|
67 | if Rand is NULL, then ASSERT().
|
---|
68 |
|
---|
69 | @param[out] Rand Buffer pointer to store the 128-bit random value.
|
---|
70 |
|
---|
71 | @retval TRUE Random number generated successfully.
|
---|
72 | @retval FALSE Failed to generate the random number.
|
---|
73 |
|
---|
74 | **/
|
---|
75 | BOOLEAN
|
---|
76 | EFIAPI
|
---|
77 | GetRandomNumber128 (
|
---|
78 | OUT UINT64 *Rand
|
---|
79 | );
|
---|
80 |
|
---|
81 | /**
|
---|
82 | Get a GUID identifying the RNG algorithm implementation.
|
---|
83 |
|
---|
84 | @param [out] RngGuid If success, contains the GUID identifying
|
---|
85 | the RNG algorithm implementation.
|
---|
86 |
|
---|
87 | @retval EFI_SUCCESS Success.
|
---|
88 | @retval EFI_UNSUPPORTED Not supported.
|
---|
89 | @retval EFI_INVALID_PARAMETER Invalid parameter.
|
---|
90 | **/
|
---|
91 | EFI_STATUS
|
---|
92 | EFIAPI
|
---|
93 | GetRngGuid (
|
---|
94 | GUID *RngGuid
|
---|
95 | );
|
---|
96 |
|
---|
97 | #endif // __RNG_LIB_H__
|
---|