ECPrivateKeyParameters.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Globalization;
  5. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  6. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Math;
  7. namespace Best.HTTP.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. public ECPrivateKeyParameters(
  20. string algorithm,
  21. BigInteger d,
  22. ECDomainParameters parameters)
  23. : base(algorithm, true, parameters)
  24. {
  25. this.d = Parameters.ValidatePrivateScalar(d);
  26. }
  27. public ECPrivateKeyParameters(
  28. string algorithm,
  29. BigInteger d,
  30. DerObjectIdentifier publicKeyParamSet)
  31. : base(algorithm, true, publicKeyParamSet)
  32. {
  33. this.d = Parameters.ValidatePrivateScalar(d);
  34. }
  35. public BigInteger D
  36. {
  37. get { return d; }
  38. }
  39. public override bool Equals(
  40. object obj)
  41. {
  42. if (obj == this)
  43. return true;
  44. ECPrivateKeyParameters other = obj as ECPrivateKeyParameters;
  45. if (other == null)
  46. return false;
  47. return Equals(other);
  48. }
  49. protected bool Equals(
  50. ECPrivateKeyParameters other)
  51. {
  52. return d.Equals(other.d) && base.Equals(other);
  53. }
  54. public override int GetHashCode()
  55. {
  56. return d.GetHashCode() ^ base.GetHashCode();
  57. }
  58. }
  59. }
  60. #pragma warning restore
  61. #endif