DHValidationParameters.cs 1.2 KB

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