SecT239K1Curve.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using Org.BouncyCastle.Math.EC.Multiplier;
  4. using Org.BouncyCastle.Utilities.Encoders;
  5. namespace Org.BouncyCastle.Math.EC.Custom.Sec
  6. {
  7. internal class SecT239K1Curve
  8. : AbstractF2mCurve
  9. {
  10. private const int SecT239K1_DEFAULT_COORDS = COORD_LAMBDA_PROJECTIVE;
  11. protected readonly SecT239K1Point m_infinity;
  12. public SecT239K1Curve()
  13. : base(239, 158, 0, 0)
  14. {
  15. this.m_infinity = new SecT239K1Point(this, null, null);
  16. this.m_a = FromBigInteger(BigInteger.Zero);
  17. this.m_b = FromBigInteger(BigInteger.One);
  18. this.m_order = new BigInteger(1, Hex.Decode("2000000000000000000000000000005A79FEC67CB6E91F1C1DA800E478A5"));
  19. this.m_cofactor = BigInteger.ValueOf(4);
  20. this.m_coord = SecT239K1_DEFAULT_COORDS;
  21. }
  22. protected override ECCurve CloneCurve()
  23. {
  24. return new SecT239K1Curve();
  25. }
  26. public override bool SupportsCoordinateSystem(int coord)
  27. {
  28. switch (coord)
  29. {
  30. case COORD_LAMBDA_PROJECTIVE:
  31. return true;
  32. default:
  33. return false;
  34. }
  35. }
  36. protected override ECMultiplier CreateDefaultMultiplier()
  37. {
  38. return new WTauNafMultiplier();
  39. }
  40. public override ECPoint Infinity
  41. {
  42. get { return m_infinity; }
  43. }
  44. public override int FieldSize
  45. {
  46. get { return 239; }
  47. }
  48. public override ECFieldElement FromBigInteger(BigInteger x)
  49. {
  50. return new SecT239FieldElement(x);
  51. }
  52. protected internal override ECPoint CreateRawPoint(ECFieldElement x, ECFieldElement y, bool withCompression)
  53. {
  54. return new SecT239K1Point(this, x, y, withCompression);
  55. }
  56. protected internal override ECPoint CreateRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs, bool withCompression)
  57. {
  58. return new SecT239K1Point(this, x, y, zs, withCompression);
  59. }
  60. public override bool IsKoblitz
  61. {
  62. get { return true; }
  63. }
  64. public virtual int M
  65. {
  66. get { return 239; }
  67. }
  68. public virtual bool IsTrinomial
  69. {
  70. get { return true; }
  71. }
  72. public virtual int K1
  73. {
  74. get { return 158; }
  75. }
  76. public virtual int K2
  77. {
  78. get { return 0; }
  79. }
  80. public virtual int K3
  81. {
  82. get { return 0; }
  83. }
  84. }
  85. }
  86. #endif