DHValidationParameters.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters
  6. {
  7. public class DHValidationParameters
  8. {
  9. private readonly byte[] seed;
  10. private readonly int counter;
  11. public DHValidationParameters(
  12. byte[] seed,
  13. int counter)
  14. {
  15. if (seed == null)
  16. throw new ArgumentNullException("seed");
  17. this.seed = (byte[]) seed.Clone();
  18. this.counter = counter;
  19. }
  20. public byte[] GetSeed()
  21. {
  22. return (byte[]) seed.Clone();
  23. }
  24. public int Counter
  25. {
  26. get { return counter; }
  27. }
  28. public override bool Equals(
  29. object obj)
  30. {
  31. if (obj == this)
  32. return true;
  33. DHValidationParameters other = obj as DHValidationParameters;
  34. if (other == null)
  35. return false;
  36. return Equals(other);
  37. }
  38. protected bool Equals(
  39. DHValidationParameters other)
  40. {
  41. return counter == other.counter
  42. && Arrays.AreEqual(this.seed, other.seed);
  43. }
  44. public override int GetHashCode()
  45. {
  46. return counter.GetHashCode() ^ Arrays.GetHashCode(seed);
  47. }
  48. }
  49. }
  50. #pragma warning restore
  51. #endif