SecT409R1Curve.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 SecT409R1Curve
  7. : AbstractF2mCurve
  8. {
  9. private const int SecT409R1_DEFAULT_COORDS = COORD_LAMBDA_PROJECTIVE;
  10. protected readonly SecT409R1Point m_infinity;
  11. public SecT409R1Curve()
  12. : base(409, 87, 0, 0)
  13. {
  14. this.m_infinity = new SecT409R1Point(this, null, null);
  15. this.m_a = FromBigInteger(BigInteger.One);
  16. this.m_b = FromBigInteger(new BigInteger(1, Hex.Decode("0021A5C2C8EE9FEB5C4B9A753B7B476B7FD6422EF1F3DD674761FA99D6AC27C8A9A197B272822F6CD57A55AA4F50AE317B13545F")));
  17. this.m_order = new BigInteger(1, Hex.Decode("010000000000000000000000000000000000000000000000000001E2AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173"));
  18. this.m_cofactor = BigInteger.Two;
  19. this.m_coord = SecT409R1_DEFAULT_COORDS;
  20. }
  21. protected override ECCurve CloneCurve()
  22. {
  23. return new SecT409R1Curve();
  24. }
  25. public override bool SupportsCoordinateSystem(int coord)
  26. {
  27. switch (coord)
  28. {
  29. case COORD_LAMBDA_PROJECTIVE:
  30. return true;
  31. default:
  32. return false;
  33. }
  34. }
  35. public override ECPoint Infinity
  36. {
  37. get { return m_infinity; }
  38. }
  39. public override int FieldSize
  40. {
  41. get { return 409; }
  42. }
  43. public override ECFieldElement FromBigInteger(BigInteger x)
  44. {
  45. return new SecT409FieldElement(x);
  46. }
  47. protected internal override ECPoint CreateRawPoint(ECFieldElement x, ECFieldElement y, bool withCompression)
  48. {
  49. return new SecT409R1Point(this, x, y, withCompression);
  50. }
  51. protected internal override ECPoint CreateRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs, bool withCompression)
  52. {
  53. return new SecT409R1Point(this, x, y, zs, withCompression);
  54. }
  55. public override bool IsKoblitz
  56. {
  57. get { return false; }
  58. }
  59. public virtual int M
  60. {
  61. get { return 409; }
  62. }
  63. public virtual bool IsTrinomial
  64. {
  65. get { return true; }
  66. }
  67. public virtual int K1
  68. {
  69. get { return 87; }
  70. }
  71. public virtual int K2
  72. {
  73. get { return 0; }
  74. }
  75. public virtual int K3
  76. {
  77. get { return 0; }
  78. }
  79. }
  80. }
  81. #endif