ECPublicKeyParameters.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.EC;
  7. namespace BestHTTP.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. [Obsolete("Use version with explicit 'algorithm' parameter")]
  20. public ECPublicKeyParameters(
  21. ECPoint q,
  22. DerObjectIdentifier publicKeyParamSet)
  23. : base("ECGOST3410", false, publicKeyParamSet)
  24. {
  25. if (q == null)
  26. throw new ArgumentNullException("q");
  27. this.q = ECDomainParameters.Validate(Parameters.Curve, q);
  28. }
  29. public ECPublicKeyParameters(
  30. string algorithm,
  31. ECPoint q,
  32. ECDomainParameters parameters)
  33. : base(algorithm, false, parameters)
  34. {
  35. if (q == null)
  36. throw new ArgumentNullException("q");
  37. this.q = ECDomainParameters.Validate(Parameters.Curve, q);
  38. }
  39. public ECPublicKeyParameters(
  40. string algorithm,
  41. ECPoint q,
  42. DerObjectIdentifier publicKeyParamSet)
  43. : base(algorithm, false, publicKeyParamSet)
  44. {
  45. if (q == null)
  46. throw new ArgumentNullException("q");
  47. this.q = ECDomainParameters.Validate(Parameters.Curve, q);
  48. }
  49. public ECPoint Q
  50. {
  51. get { return q; }
  52. }
  53. public override bool Equals(object obj)
  54. {
  55. if (obj == this)
  56. return true;
  57. ECPublicKeyParameters other = obj as ECPublicKeyParameters;
  58. if (other == null)
  59. return false;
  60. return Equals(other);
  61. }
  62. protected bool Equals(
  63. ECPublicKeyParameters other)
  64. {
  65. return q.Equals(other.q) && base.Equals(other);
  66. }
  67. public override int GetHashCode()
  68. {
  69. return q.GetHashCode() ^ base.GetHashCode();
  70. }
  71. }
  72. }
  73. #pragma warning restore
  74. #endif