ECPublicKeyParameters.cs 2.2 KB

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