GOST3410Parameters.cs 1.6 KB

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