]>
Commit | Line | Data |
---|---|---|
b7396789 XL |
1 | /** @file\r |
2 | Provide rand noise source.\r | |
3 | \r | |
4 | Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | #include <Library/BaseLib.h>\r | |
10 | #include <Library/DebugLib.h>\r | |
11 | #include <Library/TimerLib.h>\r | |
12 | \r | |
13 | /**\r | |
14 | Get 64-bit noise source\r | |
15 | \r | |
16 | @param[out] Rand Buffer pointer to store 64-bit noise source\r | |
17 | \r | |
18 | @retval TRUE Get randomness successfully.\r | |
19 | @retval FALSE Failed to generate\r | |
20 | **/\r | |
21 | BOOLEAN\r | |
22 | EFIAPI\r | |
23 | GetRandomNoise64 (\r | |
24 | OUT UINT64 *Rand\r | |
25 | )\r | |
26 | {\r | |
27 | UINT32 Index;\r | |
28 | UINT32 *RandPtr;\r | |
29 | \r | |
30 | if (NULL == Rand) {\r | |
31 | return FALSE;\r | |
32 | }\r | |
33 | \r | |
34 | RandPtr = (UINT32 *)Rand;\r | |
35 | \r | |
36 | for (Index = 0; Index < 2; Index ++) {\r | |
37 | *RandPtr = (UINT32) ((AsmReadTsc ()) & 0xFF);\r | |
38 | RandPtr++;\r | |
39 | MicroSecondDelay (10);\r | |
40 | }\r | |
41 | \r | |
42 | return TRUE;\r | |
43 | }\r |