/* Creates a 128bit random value that is fully forward and backward prediction resistant, suitable for seeding a NIST SP800-90 Compliant, FIPS 1402-2 certifiable SW DRBG. This function takes multiple random numbers through RDRAND without intervening delays to ensure reseeding and performs AES-CBC-MAC over the data to compute the seed value. */
EFI_STATUS EFIAPI RdRandGetSeed128(OUT UINT8 *SeedBuffer)
/* Creates a 128bit random value that is fully forward and backward prediction resistant, suitable for seeding a NIST SP800-90 Compliant, FIPS 1402-2 certifiable SW DRBG. This function takes multiple random numbers through RDRAND without intervening delays to ensure reseeding and performs AES-CBC-MAC over the data to compute the seed value. */
EFI_STATUS EFIAPI RdRandGetSeed128(OUT UINT8 *SeedBuffer)
{
  EFI_STATUS  Status;
  UINT8       RandByte[16];
  UINT8       Key[16];
  UINT8       Ffv[16];
  UINT8       Xored[16];
  UINT32      Index;
  UINT32      Index2;
  for (Index = 0; Index < 16; Index++) {
    Key[Index] = (UINT8)Index;
    Ffv[Index] = 0;
  }
  for (Index = 0; Index < 32; Index++) {
    MicroSecondDelay (10);
    Status = RngGetBytes (16, RandByte);
    if (EFI_ERROR (Status)) {
      return Status;
    }
    for (Index2 = 0; Index2 < 16; Index2++) {
      Xored[Index2] = RandByte[Index2] ^ Ffv[Index2];
    }
    AesEncrypt (Key, Xored, Ffv);
  }
  for (Index = 0; Index < 16; Index++) {
    SeedBuffer[Index] = Ffv[Index];
  }
  return EFI_SUCCESS;
}