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. [Obsolete("Use Random property instead")]
  29. public SecureRandom GetRandom()
  30. {
  31. return Random;
  32. }
  33. public SecureRandom Random
  34. {
  35. get { return random; }
  36. }
  37. public ICipherParameters Parameters
  38. {
  39. get { return parameters; }
  40. }
  41. }
  42. }
  43. #pragma warning restore
  44. #endif