]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/RandomNumberGenerator/RngDxe/RdRand.h
d6378778cf15401eb6bb2f9533719480423f3f99
[mirror_edk2.git] / SecurityPkg / RandomNumberGenerator / RngDxe / RdRand.h
1 /** @file
2 Header for the RDRAND APIs used by RNG DXE driver.
3
4 Support API definitions for RDRAND instruction access, which will leverage
5 Intel Secure Key technology to provide high-quality random numbers for use
6 in applications, or entropy for seeding other random number generators.
7 Refer to http://software.intel.com/en-us/articles/intel-digital-random-number
8 -generator-drng-software-implementation-guide/ for more information about Intel
9 Secure Key technology.
10
11 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
12 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
13 This program and the accompanying materials
14 are licensed and made available under the terms and conditions of the BSD License
15 which accompanies this distribution. The full text of the license may be found at
16 http://opensource.org/licenses/bsd-license.php
17
18 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
19 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20
21 **/
22
23 #ifndef __RD_RAND_H__
24 #define __RD_RAND_H__
25
26 #include <Library/BaseLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/UefiBootServicesTableLib.h>
29 #include <Library/TimerLib.h>
30 #include <Protocol/Rng.h>
31
32 /**
33 Calls RDRAND to fill a buffer of arbitrary size with random bytes.
34
35 @param[in] Length Size of the buffer, in bytes, to fill with.
36 @param[out] RandBuffer Pointer to the buffer to store the random result.
37
38 @retval EFI_SUCCESS Random bytes generation succeeded.
39 @retval EFI_NOT_READY Failed to request random bytes.
40
41 **/
42 EFI_STATUS
43 EFIAPI
44 RdRandGetBytes (
45 IN UINTN Length,
46 OUT UINT8 *RandBuffer
47 );
48
49 /**
50 Generate high-quality entropy source through RDRAND.
51
52 @param[in] Length Size of the buffer, in bytes, to fill with.
53 @param[out] Entropy Pointer to the buffer to store the entropy data.
54
55 @retval EFI_SUCCESS Entropy generation succeeded.
56 @retval EFI_NOT_READY Failed to request random data.
57
58 **/
59 EFI_STATUS
60 EFIAPI
61 RdRandGenerateEntropy (
62 IN UINTN Length,
63 OUT UINT8 *Entropy
64 );
65
66 #endif // __RD_RAND_H__