SecP224K1Curve.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 SecP224K1Curve
  7. : AbstractFpCurve
  8. {
  9. public static readonly BigInteger q = new BigInteger(1,
  10. Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFE56D"));
  11. private const int SECP224K1_DEFAULT_COORDS = COORD_JACOBIAN;
  12. protected readonly SecP224K1Point m_infinity;
  13. public SecP224K1Curve()
  14. : base(q)
  15. {
  16. this.m_infinity = new SecP224K1Point(this, null, null);
  17. this.m_a = FromBigInteger(BigInteger.Zero);
  18. this.m_b = FromBigInteger(BigInteger.ValueOf(5));
  19. this.m_order = new BigInteger(1, Hex.Decode("010000000000000000000000000001DCE8D2EC6184CAF0A971769FB1F7"));
  20. this.m_cofactor = BigInteger.One;
  21. this.m_coord = SECP224K1_DEFAULT_COORDS;
  22. }
  23. protected override ECCurve CloneCurve()
  24. {
  25. return new SecP224K1Curve();
  26. }
  27. public override bool SupportsCoordinateSystem(int coord)
  28. {
  29. switch (coord)
  30. {
  31. case COORD_JACOBIAN:
  32. return true;
  33. default:
  34. return false;
  35. }
  36. }
  37. public virtual BigInteger Q
  38. {
  39. get { return q; }
  40. }
  41. public override ECPoint Infinity
  42. {
  43. get { return m_infinity; }
  44. }
  45. public override int FieldSize
  46. {
  47. get { return q.BitLength; }
  48. }
  49. public override ECFieldElement FromBigInteger(BigInteger x)
  50. {
  51. return new SecP224K1FieldElement(x);
  52. }
  53. protected internal override ECPoint CreateRawPoint(ECFieldElement x, ECFieldElement y, bool withCompression)
  54. {
  55. return new SecP224K1Point(this, x, y, withCompression);
  56. }
  57. protected internal override ECPoint CreateRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs, bool withCompression)
  58. {
  59. return new SecP224K1Point(this, x, y, zs, withCompression);
  60. }
  61. }
  62. }
  63. #endif