DsaValidationParameters.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 DsaValidationParameters
  7. {
  8. private readonly byte[] seed;
  9. private readonly int counter;
  10. private readonly int usageIndex;
  11. public DsaValidationParameters(byte[] seed, int counter)
  12. : this(seed, counter, -1)
  13. {
  14. }
  15. public DsaValidationParameters(
  16. byte[] seed,
  17. int counter,
  18. int usageIndex)
  19. {
  20. if (seed == null)
  21. throw new ArgumentNullException("seed");
  22. this.seed = (byte[]) seed.Clone();
  23. this.counter = counter;
  24. this.usageIndex = usageIndex;
  25. }
  26. public virtual byte[] GetSeed()
  27. {
  28. return (byte[]) seed.Clone();
  29. }
  30. public virtual int Counter
  31. {
  32. get { return counter; }
  33. }
  34. public virtual int UsageIndex
  35. {
  36. get { return usageIndex; }
  37. }
  38. public override bool Equals(
  39. object obj)
  40. {
  41. if (obj == this)
  42. return true;
  43. DsaValidationParameters other = obj as DsaValidationParameters;
  44. if (other == null)
  45. return false;
  46. return Equals(other);
  47. }
  48. protected virtual bool Equals(
  49. DsaValidationParameters other)
  50. {
  51. return counter == other.counter
  52. && Arrays.AreEqual(seed, other.seed);
  53. }
  54. public override int GetHashCode()
  55. {
  56. return counter.GetHashCode() ^ Arrays.GetHashCode(seed);
  57. }
  58. }
  59. }
  60. #endif