ISP80090Drbg.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Prng.Drbg
  5. {
  6. /**
  7. * Interface to SP800-90A deterministic random bit generators.
  8. */
  9. public interface ISP80090Drbg
  10. {
  11. /**
  12. * Return the block size of the DRBG.
  13. *
  14. * @return the block size (in bits) produced by each round of the DRBG.
  15. */
  16. int BlockSize { get; }
  17. /**
  18. * Populate a passed in array with random data.
  19. *
  20. * @param output output array for generated bits.
  21. * @param additionalInput additional input to be added to the DRBG in this step.
  22. * @param predictionResistant true if a reseed should be forced, false otherwise.
  23. *
  24. * @return number of bits generated, -1 if a reseed required.
  25. */
  26. int Generate(byte[] output, int outputOff, int outputLen, byte[] additionalInput, bool predictionResistant);
  27. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  28. int Generate(Span<byte> output, bool predictionResistant);
  29. int GenerateWithInput(Span<byte> output, ReadOnlySpan<byte> additionalInput, bool predictionResistant);
  30. #endif
  31. /**
  32. * Reseed the DRBG.
  33. *
  34. * @param additionalInput additional input to be added to the DRBG in this step.
  35. */
  36. void Reseed(byte[] additionalInput);
  37. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  38. void Reseed(ReadOnlySpan<byte> additionalInput);
  39. #endif
  40. }
  41. }
  42. #pragma warning restore
  43. #endif