summary refs log tree commit diff
path: root/crypto/src/math/ec/ECAlgorithms.cs
diff options
context:
space:
mode:
authorJeffrey Stedfast <jeff@xamarin.com>2015-03-28 11:34:48 -0400
committerJeffrey Stedfast <jeff@xamarin.com>2015-03-28 11:34:48 -0400
commit393ff28f041de50a02acf45e9c0ba603a08e31b2 (patch)
tree4e48155cc30595686cf48631dff5f04f9cbfc2a8 /crypto/src/math/ec/ECAlgorithms.cs
parentMerge branch 'master' into vs2010 (diff)
parentImproved docs and code cleanup (diff)
downloadBouncyCastle.NET-ed25519-393ff28f041de50a02acf45e9c0ba603a08e31b2.tar.xz
Merge branch 'master' into vs2010
Diffstat (limited to 'crypto/src/math/ec/ECAlgorithms.cs')
-rw-r--r--crypto/src/math/ec/ECAlgorithms.cs18
1 files changed, 13 insertions, 5 deletions
diff --git a/crypto/src/math/ec/ECAlgorithms.cs b/crypto/src/math/ec/ECAlgorithms.cs
index a1349a9e0..5d60de40f 100644
--- a/crypto/src/math/ec/ECAlgorithms.cs
+++ b/crypto/src/math/ec/ECAlgorithms.cs
@@ -10,14 +10,23 @@ namespace Org.BouncyCastle.Math.EC
     {
         public static bool IsF2mCurve(ECCurve c)
         {
-            IFiniteField field = c.Field;
+            return IsF2mField(c.Field);
+        }
+
+        public static bool IsF2mField(IFiniteField field)
+        {
             return field.Dimension > 1 && field.Characteristic.Equals(BigInteger.Two)
                 && field is IPolynomialExtensionField;
         }
 
         public static bool IsFpCurve(ECCurve c)
         {
-            return c.Field.Dimension == 1;
+            return IsFpField(c.Field);
+        }
+
+        public static bool IsFpField(IFiniteField field)
+        {
+            return field.Dimension == 1;
         }
 
         public static ECPoint SumOfMultiplies(ECPoint[] ps, BigInteger[] ks)
@@ -61,10 +70,9 @@ namespace Org.BouncyCastle.Math.EC
             Q = ImportPoint(cp, Q);
 
             // Point multiplication for Koblitz curves (using WTNAF) beats Shamir's trick
-            if (cp is F2mCurve)
             {
-                F2mCurve f2mCurve = (F2mCurve) cp;
-                if (f2mCurve.IsKoblitz)
+                AbstractF2mCurve f2mCurve = cp as AbstractF2mCurve;
+                if (f2mCurve != null && f2mCurve.IsKoblitz)
                 {
                     return ValidatePoint(P.Multiply(a).Add(Q.Multiply(b)));
                 }