ECPrivateKeyParameters.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using System.Globalization;
  4. using Org.BouncyCastle.Asn1;
  5. using Org.BouncyCastle.Math;
  6. namespace Org.BouncyCastle.Crypto.Parameters
  7. {
  8. public class ECPrivateKeyParameters
  9. : ECKeyParameters
  10. {
  11. private readonly BigInteger d;
  12. public ECPrivateKeyParameters(
  13. BigInteger d,
  14. ECDomainParameters parameters)
  15. : this("EC", d, parameters)
  16. {
  17. }
  18. [Obsolete("Use version with explicit 'algorithm' parameter")]
  19. public ECPrivateKeyParameters(
  20. BigInteger d,
  21. DerObjectIdentifier publicKeyParamSet)
  22. : base("ECGOST3410", true, publicKeyParamSet)
  23. {
  24. if (d == null)
  25. throw new ArgumentNullException("d");
  26. this.d = d;
  27. }
  28. public ECPrivateKeyParameters(
  29. string algorithm,
  30. BigInteger d,
  31. ECDomainParameters parameters)
  32. : base(algorithm, true, parameters)
  33. {
  34. if (d == null)
  35. throw new ArgumentNullException("d");
  36. this.d = d;
  37. }
  38. public ECPrivateKeyParameters(
  39. string algorithm,
  40. BigInteger d,
  41. DerObjectIdentifier publicKeyParamSet)
  42. : base(algorithm, true, publicKeyParamSet)
  43. {
  44. if (d == null)
  45. throw new ArgumentNullException("d");
  46. this.d = d;
  47. }
  48. public BigInteger D
  49. {
  50. get { return d; }
  51. }
  52. public override bool Equals(
  53. object obj)
  54. {
  55. if (obj == this)
  56. return true;
  57. ECPrivateKeyParameters other = obj as ECPrivateKeyParameters;
  58. if (other == null)
  59. return false;
  60. return Equals(other);
  61. }
  62. protected bool Equals(
  63. ECPrivateKeyParameters other)
  64. {
  65. return d.Equals(other.d) && base.Equals(other);
  66. }
  67. public override int GetHashCode()
  68. {
  69. return d.GetHashCode() ^ base.GetHashCode();
  70. }
  71. }
  72. }
  73. #endif