WNafPreCompInfo.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Multiplier
  4. {
  5. /**
  6. * Class holding precomputation data for the WNAF (Window Non-Adjacent Form)
  7. * algorithm.
  8. */
  9. public class WNafPreCompInfo
  10. : PreCompInfo
  11. {
  12. internal volatile int m_promotionCountdown = 4;
  13. protected int m_confWidth = -1;
  14. /**
  15. * Array holding the precomputed <code>ECPoint</code>s used for a Window
  16. * NAF multiplication.
  17. */
  18. protected ECPoint[] m_preComp = null;
  19. /**
  20. * Array holding the negations of the precomputed <code>ECPoint</code>s used
  21. * for a Window NAF multiplication.
  22. */
  23. protected ECPoint[] m_preCompNeg = null;
  24. /**
  25. * Holds an <code>ECPoint</code> representing Twice(this). Used for the
  26. * Window NAF multiplication to create or extend the precomputed values.
  27. */
  28. protected ECPoint m_twice = null;
  29. protected int m_width = -1;
  30. internal int DecrementPromotionCountdown()
  31. {
  32. int t = m_promotionCountdown;
  33. if (t > 0)
  34. {
  35. m_promotionCountdown = --t;
  36. }
  37. return t;
  38. }
  39. internal int PromotionCountdown
  40. {
  41. get { return m_promotionCountdown; }
  42. set { this.m_promotionCountdown = value; }
  43. }
  44. public virtual bool IsPromoted
  45. {
  46. get { return m_promotionCountdown <= 0; }
  47. }
  48. public virtual int ConfWidth
  49. {
  50. get { return m_confWidth; }
  51. set { this.m_confWidth = value; }
  52. }
  53. public virtual ECPoint[] PreComp
  54. {
  55. get { return m_preComp; }
  56. set { this.m_preComp = value; }
  57. }
  58. public virtual ECPoint[] PreCompNeg
  59. {
  60. get { return m_preCompNeg; }
  61. set { this.m_preCompNeg = value; }
  62. }
  63. public virtual ECPoint Twice
  64. {
  65. get { return m_twice; }
  66. set { this.m_twice = value; }
  67. }
  68. public virtual int Width
  69. {
  70. get { return m_width; }
  71. set { this.m_width = value; }
  72. }
  73. }
  74. }
  75. #pragma warning restore
  76. #endif