/* This function sets up the seed value for the pseudorandom number generator. If Seed is not NULL, then the seed passed in is used. If Seed is NULL, then default seed is used. */
BOOLEAN EFIAPI RandomSeed(IN CONST UINT8 *Seed OPTIONAL, IN UINTN SeedSize)
/* This function sets up the seed value for the pseudorandom number generator. If Seed is not NULL, then the seed passed in is used. If Seed is NULL, then default seed is used. */
BOOLEAN EFIAPI RandomSeed(IN CONST UINT8 *Seed OPTIONAL, IN UINTN SeedSize)
{
  CHAR8  DefaultSeed[128];
  if (SeedSize > INT_MAX) {
    return FALSE;
  }
  if (EVP_add_digest (EVP_sha1 ()) == 0) {
    return FALSE;
  }
  if (Seed != NULL) {
    RAND_seed (Seed, (UINT32)SeedSize);
  } else {
    AsciiSPrint (
      DefaultSeed,
      sizeof (DefaultSeed),
      "UEFI Crypto Library default seed (%ld)",
      AsmReadTsc ()
      );
    RAND_seed (DefaultSeed, sizeof (DefaultSeed));
  }
  if (RAND_status () == 1) {
    return TRUE;
  }
  return FALSE;
}