GF2Polynomial.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Math.Field
  6. {
  7. internal class GF2Polynomial
  8. : IPolynomial
  9. {
  10. protected readonly int[] exponents;
  11. internal GF2Polynomial(int[] exponents)
  12. {
  13. this.exponents = Arrays.Clone(exponents);
  14. }
  15. public virtual int Degree
  16. {
  17. get { return exponents[exponents.Length - 1]; }
  18. }
  19. public virtual int[] GetExponentsPresent()
  20. {
  21. return Arrays.Clone(exponents);
  22. }
  23. public override bool Equals(object obj)
  24. {
  25. if (this == obj)
  26. {
  27. return true;
  28. }
  29. GF2Polynomial other = obj as GF2Polynomial;
  30. if (null == other)
  31. {
  32. return false;
  33. }
  34. return Arrays.AreEqual(exponents, other.exponents);
  35. }
  36. public override int GetHashCode()
  37. {
  38. return Arrays.GetHashCode(exponents);
  39. }
  40. }
  41. }
  42. #pragma warning restore
  43. #endif