EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

CryptoPkg/Application/Cryptest/RandVerify.c

Go to the documentation of this file.
00001 
00015 #include "Cryptest.h"
00016 
00017 #define  RANDOM_NUMBER_SIZE  256
00018 
00019 CONST  UINT8  SeedString[] = "This is the random seed for PRNG verification.";
00020 
00021 UINT8  PreviousRandomBuffer[RANDOM_NUMBER_SIZE] = { 0x0 };
00022 
00023 UINT8  RandomBuffer[RANDOM_NUMBER_SIZE] = { 0x0 };
00024 
00032 EFI_STATUS
00033 ValidateCryptPrng (
00034   VOID
00035   )
00036 {
00037   UINTN    Index;
00038   BOOLEAN  Status;
00039 
00040   Print (L" \nUEFI-OpenSSL PRNG Engine Testing:\n");
00041 
00042   Print (L"- Random Generation...");
00043 
00044   Status = RandomSeed (SeedString, sizeof (SeedString));
00045   if (!Status) {
00046     Print (L"[Fail]");
00047     return EFI_ABORTED;
00048   }
00049 
00050   for (Index = 0; Index < 10; Index ++) {
00051     Status = RandomBytes (RandomBuffer, RANDOM_NUMBER_SIZE);
00052     if (!Status) {
00053       Print (L"[Fail]");
00054       return EFI_ABORTED;
00055     }
00056 
00057     if (CompareMem (PreviousRandomBuffer, RandomBuffer, RANDOM_NUMBER_SIZE) == 0) {
00058       Print (L"[Fail]");
00059       return EFI_ABORTED;
00060     }
00061 
00062     CopyMem (PreviousRandomBuffer, RandomBuffer, RANDOM_NUMBER_SIZE);
00063   }
00064 
00065   Print (L"[Pass]\n");
00066 
00067   return EFI_SUCCESS;
00068 
00069 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines