SecT571R1Curve.cs 2.9 KB

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