DsaValidationParameters.cs 1.8 KB

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