DsaParameters.cs 1.8 KB

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