ParametersWithRandom.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters
  6. {
  7. public class ParametersWithRandom
  8. : ICipherParameters
  9. {
  10. private readonly ICipherParameters parameters;
  11. private readonly SecureRandom random;
  12. public ParametersWithRandom(
  13. ICipherParameters parameters,
  14. SecureRandom random)
  15. {
  16. if (parameters == null)
  17. throw new ArgumentNullException("parameters");
  18. if (random == null)
  19. throw new ArgumentNullException("random");
  20. this.parameters = parameters;
  21. this.random = random;
  22. }
  23. public ParametersWithRandom(
  24. ICipherParameters parameters)
  25. : this(parameters, new SecureRandom())
  26. {
  27. }
  28. public SecureRandom GetRandom()
  29. {
  30. return Random;
  31. }
  32. public SecureRandom Random
  33. {
  34. get { return random; }
  35. }
  36. public ICipherParameters Parameters
  37. {
  38. get { return parameters; }
  39. }
  40. }
  41. }
  42. #pragma warning restore
  43. #endif