DsaParameters.cs 1.7 KB

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