ECPrivateKeyParameters.cs 2.3 KB

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