ECPublicKeyParameters.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.EC;
  7. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters
  8. {
  9. public class ECPublicKeyParameters
  10. : ECKeyParameters
  11. {
  12. private readonly ECPoint q;
  13. public ECPublicKeyParameters(
  14. ECPoint q,
  15. ECDomainParameters parameters)
  16. : this("EC", q, parameters)
  17. {
  18. }
  19. public ECPublicKeyParameters(
  20. string algorithm,
  21. ECPoint q,
  22. ECDomainParameters parameters)
  23. : base(algorithm, false, parameters)
  24. {
  25. this.q = ECDomainParameters.ValidatePublicPoint(Parameters.Curve, q);
  26. }
  27. public ECPublicKeyParameters(
  28. string algorithm,
  29. ECPoint q,
  30. DerObjectIdentifier publicKeyParamSet)
  31. : base(algorithm, false, publicKeyParamSet)
  32. {
  33. this.q = ECDomainParameters.ValidatePublicPoint(Parameters.Curve, q);
  34. }
  35. public ECPoint Q
  36. {
  37. get { return q; }
  38. }
  39. public override bool Equals(object obj)
  40. {
  41. if (obj == this)
  42. return true;
  43. ECPublicKeyParameters other = obj as ECPublicKeyParameters;
  44. if (other == null)
  45. return false;
  46. return Equals(other);
  47. }
  48. protected bool Equals(
  49. ECPublicKeyParameters other)
  50. {
  51. return q.Equals(other.q) && base.Equals(other);
  52. }
  53. public override int GetHashCode()
  54. {
  55. return q.GetHashCode() ^ base.GetHashCode();
  56. }
  57. }
  58. }
  59. #pragma warning restore
  60. #endif