SecP384R1Curve.cs 2.5 KB

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