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