]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/X86RdRand.c
SecurityPkg: Change default value source
[mirror_edk2.git] / MdePkg / Library / BaseLib / X86RdRand.c
1 /** @file
2 IA-32/x64 AsmRdRandxx()
3 Generates random number through CPU RdRand instruction.
4
5 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include "BaseLibInternals.h"
11
12 /**
13 Generates a 16-bit random number through RDRAND instruction.
14
15 if Rand is NULL, then ASSERT().
16
17 @param[out] Rand Buffer pointer to store the random result.
18
19 @retval TRUE RDRAND call was successful.
20 @retval FALSE Failed attempts to call RDRAND.
21
22 **/
23 BOOLEAN
24 EFIAPI
25 AsmRdRand16 (
26 OUT UINT16 *Rand
27 )
28 {
29 ASSERT (Rand != NULL);
30 return InternalX86RdRand16 (Rand);
31 }
32
33 /**
34 Generates a 32-bit random number through RDRAND instruction.
35
36 if Rand is NULL, then ASSERT().
37
38 @param[out] Rand Buffer pointer to store the random result.
39
40 @retval TRUE RDRAND call was successful.
41 @retval FALSE Failed attempts to call RDRAND.
42
43 **/
44 BOOLEAN
45 EFIAPI
46 AsmRdRand32 (
47 OUT UINT32 *Rand
48 )
49 {
50 ASSERT (Rand != NULL);
51 return InternalX86RdRand32 (Rand);
52 }
53
54 /**
55 Generates a 64-bit random number through RDRAND instruction.
56
57 if Rand is NULL, then ASSERT().
58
59 @param[out] Rand Buffer pointer to store the random result.
60
61 @retval TRUE RDRAND call was successful.
62 @retval FALSE Failed attempts to call RDRAND.
63
64 **/
65 BOOLEAN
66 EFIAPI
67 AsmRdRand64 (
68 OUT UINT64 *Rand
69 )
70 {
71 ASSERT (Rand != NULL);
72 return InternalX86RdRand64 (Rand);
73 }