ParametersWithRandom.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using Org.BouncyCastle.Security;
  4. namespace Org.BouncyCastle.Crypto.Parameters
  5. {
  6. public class ParametersWithRandom
  7. : ICipherParameters
  8. {
  9. private readonly ICipherParameters parameters;
  10. private readonly SecureRandom random;
  11. public ParametersWithRandom(
  12. ICipherParameters parameters,
  13. SecureRandom random)
  14. {
  15. if (parameters == null)
  16. throw new ArgumentNullException("parameters");
  17. if (random == null)
  18. throw new ArgumentNullException("random");
  19. this.parameters = parameters;
  20. this.random = random;
  21. }
  22. public ParametersWithRandom(
  23. ICipherParameters parameters)
  24. : this(parameters, new SecureRandom())
  25. {
  26. }
  27. [Obsolete("Use Random property instead")]
  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. #endif