VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/CryptoPkg/Application/Cryptest/RandVerify.c@ 58466

Last change on this file since 58466 was 58466, checked in by vboxsync, 9 years ago

EFI/Firmware: Merged in the svn:eol-style, svn:mime-type and trailing whitespace cleanup that was done after the initial UDK2014.SP1 import: svn merge /vendor/edk2/UDK2014.SP1 /vendor/edk2/current .

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1/** @file
2 Application for Pseudorandom Number Generator Validation.
3
4Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5This program and the accompanying materials
6are licensed and made available under the terms and conditions of the BSD License
7which accompanies this distribution. The full text of the license may be found at
8http://opensource.org/licenses/bsd-license.php
9
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13**/
14
15#include "Cryptest.h"
16
17#define RANDOM_NUMBER_SIZE 256
18
19CONST UINT8 SeedString[] = "This is the random seed for PRNG verification.";
20
21UINT8 PreviousRandomBuffer[RANDOM_NUMBER_SIZE] = { 0x0 };
22
23UINT8 RandomBuffer[RANDOM_NUMBER_SIZE] = { 0x0 };
24
25/**
26 Validate UEFI-OpenSSL pseudorandom number generator interfaces.
27
28 @retval EFI_SUCCESS Validation succeeded.
29 @retval EFI_ABORTED Validation failed.
30
31**/
32EFI_STATUS
33ValidateCryptPrng (
34 VOID
35 )
36{
37 UINTN Index;
38 BOOLEAN Status;
39
40 Print (L" \nUEFI-OpenSSL PRNG Engine Testing:\n");
41
42 Print (L"- Random Generation...");
43
44 Status = RandomSeed (SeedString, sizeof (SeedString));
45 if (!Status) {
46 Print (L"[Fail]");
47 return EFI_ABORTED;
48 }
49
50 for (Index = 0; Index < 10; Index ++) {
51 Status = RandomBytes (RandomBuffer, RANDOM_NUMBER_SIZE);
52 if (!Status) {
53 Print (L"[Fail]");
54 return EFI_ABORTED;
55 }
56
57 if (CompareMem (PreviousRandomBuffer, RandomBuffer, RANDOM_NUMBER_SIZE) == 0) {
58 Print (L"[Fail]");
59 return EFI_ABORTED;
60 }
61
62 CopyMem (PreviousRandomBuffer, RandomBuffer, RANDOM_NUMBER_SIZE);
63 }
64
65 Print (L"[Pass]\n");
66
67 return EFI_SUCCESS;
68
69}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette