/* 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;
  if ((This == NULL) || (RNGValueLength == 0) || (RNGValue == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  Status = EFI_UNSUPPORTED;
  if (RNGAlgorithm == NULL) {
    RNGAlgorithm = &gEfiRngAlgorithmSp80090Ctr256Guid;
  }
  if (CompareGuid (RNGAlgorithm, &gEfiRngAlgorithmSp80090Ctr256Guid)) {
    Status = RngGetBytes (RNGValueLength, RNGValue);
    return Status;
  }
  if (CompareGuid (RNGAlgorithm, &gEfiRngAlgorithmRaw)) {
    if (RNGValueLength < 32) {
      return EFI_INVALID_PARAMETER;
    }
    Status = GenerateEntropy (RNGValueLength, RNGValue);
    return Status;
  }
  return Status;
}