GOST3410Parameters.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
  6. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters
  7. {
  8. public class Gost3410Parameters
  9. : ICipherParameters
  10. {
  11. private readonly BigInteger p, q, a;
  12. private readonly Gost3410ValidationParameters validation;
  13. public Gost3410Parameters(
  14. BigInteger p,
  15. BigInteger q,
  16. BigInteger a)
  17. : this(p, q, a, null)
  18. {
  19. }
  20. public Gost3410Parameters(
  21. BigInteger p,
  22. BigInteger q,
  23. BigInteger a,
  24. Gost3410ValidationParameters validation)
  25. {
  26. if (p == null)
  27. throw new ArgumentNullException("p");
  28. if (q == null)
  29. throw new ArgumentNullException("q");
  30. if (a == null)
  31. throw new ArgumentNullException("a");
  32. this.p = p;
  33. this.q = q;
  34. this.a = a;
  35. this.validation = validation;
  36. }
  37. public BigInteger P
  38. {
  39. get { return p; }
  40. }
  41. public BigInteger Q
  42. {
  43. get { return q; }
  44. }
  45. public BigInteger A
  46. {
  47. get { return a; }
  48. }
  49. public Gost3410ValidationParameters ValidationParameters
  50. {
  51. get { return validation; }
  52. }
  53. public override bool Equals(
  54. object obj)
  55. {
  56. if (obj == this)
  57. return true;
  58. Gost3410Parameters other = obj as Gost3410Parameters;
  59. if (other == null)
  60. return false;
  61. return Equals(other);
  62. }
  63. protected bool Equals(
  64. Gost3410Parameters other)
  65. {
  66. return p.Equals(other.p) && q.Equals(other.q) && a.Equals(other.a);
  67. }
  68. public override int GetHashCode()
  69. {
  70. return p.GetHashCode() ^ q.GetHashCode() ^ a.GetHashCode();
  71. }
  72. }
  73. }
  74. #pragma warning restore
  75. #endif