GF2Polynomial.cs 1.1 KB

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