ParametersWithRandom.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Security;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters
  6. {
  7. public class ParametersWithRandom
  8. : ICipherParameters
  9. {
  10. private readonly ICipherParameters m_parameters;
  11. private readonly SecureRandom m_random;
  12. public ParametersWithRandom(ICipherParameters parameters)
  13. : this(parameters, CryptoServicesRegistrar.GetSecureRandom())
  14. {
  15. }
  16. public ParametersWithRandom(ICipherParameters parameters, SecureRandom random)
  17. {
  18. if (parameters == null)
  19. throw new ArgumentNullException(nameof(parameters));
  20. if (random == null)
  21. throw new ArgumentNullException(nameof(random));
  22. m_parameters = parameters;
  23. m_random = random;
  24. }
  25. public ICipherParameters Parameters => m_parameters;
  26. public SecureRandom Random => m_random;
  27. }
  28. }
  29. #pragma warning restore
  30. #endif