/* Produces and returns an RNG value using either the default or specified RNG algorithm. */
EFI_STATUS EFIAPI RngGetRNG(IN EFI_RNG_PROTOCOL *This, IN EFI_RNG_ALGORITHM *RNGAlgorithm OPTIONAL, IN UINTN RNGValueLength, OUT UINT8 *RNGValue)
/* Produces and returns an RNG value using either the default or specified RNG algorithm. */
EFI_STATUS EFIAPI RngGetRNG(IN EFI_RNG_PROTOCOL *This, IN EFI_RNG_ALGORITHM *RNGAlgorithm OPTIONAL, IN UINTN RNGValueLength, OUT UINT8 *RNGValue)
{
  EFI_STATUS  Status;
  GUID        RngGuid;
  if ((This == NULL) || (RNGValueLength == 0) || (RNGValue == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  if (RNGAlgorithm == NULL) {
    if (mAvailableAlgoArrayCount != 0) {
      RNGAlgorithm = &mAvailableAlgoArray[0];
    } else {
      return EFI_UNSUPPORTED;
    }
  }
  Status = GetRngGuid (&RngGuid);
  if (!EFI_ERROR (Status) &&
      CompareGuid (RNGAlgorithm, &RngGuid))
  {
    Status = RngGetBytes (RNGValueLength, RNGValue);
    return Status;
  }
  if (CompareGuid (RNGAlgorithm, &gEfiRngAlgorithmRaw)) {
    return GenerateEntropy (RNGValueLength, RNGValue);
  }
  return EFI_UNSUPPORTED;
}