summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
authorJeffrey Stedfast <jeff@xamarin.com>2015-06-14 20:41:57 -0400
committerJeffrey Stedfast <jeff@xamarin.com>2015-06-14 20:41:57 -0400
commit4aacc522e9a593e6c2de6bf4f7f12f1dcf34cf05 (patch)
treeeb302c25ef382a2351adc2ceac7a1d9278259806 /crypto
parentMerge branch 'master' into vs2010 (diff)
parentAdd range checks to F2m field elements (diff)
downloadBouncyCastle.NET-ed25519-4aacc522e9a593e6c2de6bf4f7f12f1dcf34cf05.tar.xz
Merge branch 'master' into vs2010
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/math/ec/ECFieldElement.cs3
-rw-r--r--crypto/src/math/ec/custom/sec/SecT113FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT131FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT163FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT233FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT239FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT283FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT409FieldElement.cs2
-rw-r--r--crypto/src/math/ec/custom/sec/SecT571FieldElement.cs2
9 files changed, 11 insertions, 8 deletions
diff --git a/crypto/src/math/ec/ECFieldElement.cs b/crypto/src/math/ec/ECFieldElement.cs
index 844bed649..4d4fb3e4d 100644
--- a/crypto/src/math/ec/ECFieldElement.cs
+++ b/crypto/src/math/ec/ECFieldElement.cs
@@ -604,6 +604,9 @@ namespace Org.BouncyCastle.Math.EC
             int			k3,
             BigInteger	x)
         {
+            if (x == null || x.SignValue < 0 || x.BitLength > m)
+                throw new ArgumentException("value invalid in F2m field element", "x");
+
             if ((k2 == 0) && (k3 == 0))
             {
                 this.representation = Tpb;
diff --git a/crypto/src/math/ec/custom/sec/SecT113FieldElement.cs b/crypto/src/math/ec/custom/sec/SecT113FieldElement.cs
index 7e9d53e44..e3a923f62 100644
--- a/crypto/src/math/ec/custom/sec/SecT113FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecT113FieldElement.cs
@@ -12,7 +12,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
         public SecT113FieldElement(BigInteger x)
         {
-            if (x == null || x.SignValue < 0)
+            if (x == null || x.SignValue < 0 || x.BitLength > 113)
                 throw new ArgumentException("value invalid for SecT113FieldElement", "x");
 
             this.x = SecT113Field.FromBigInteger(x);
diff --git a/crypto/src/math/ec/custom/sec/SecT131FieldElement.cs b/crypto/src/math/ec/custom/sec/SecT131FieldElement.cs
index d60c7ed7d..65aaf01ba 100644
--- a/crypto/src/math/ec/custom/sec/SecT131FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecT131FieldElement.cs
@@ -12,7 +12,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
         public SecT131FieldElement(BigInteger x)
         {
-            if (x == null || x.SignValue < 0)
+            if (x == null || x.SignValue < 0 || x.BitLength > 131)
                 throw new ArgumentException("value invalid for SecT131FieldElement", "x");
 
             this.x = SecT131Field.FromBigInteger(x);
diff --git a/crypto/src/math/ec/custom/sec/SecT163FieldElement.cs b/crypto/src/math/ec/custom/sec/SecT163FieldElement.cs
index 0ef421c71..3ab383a1d 100644
--- a/crypto/src/math/ec/custom/sec/SecT163FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecT163FieldElement.cs
@@ -12,7 +12,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
         public SecT163FieldElement(BigInteger x)
         {
-            if (x == null || x.SignValue < 0)
+            if (x == null || x.SignValue < 0 || x.BitLength > 163)
                 throw new ArgumentException("value invalid for SecT163FieldElement", "x");
 
             this.x = SecT163Field.FromBigInteger(x);
diff --git a/crypto/src/math/ec/custom/sec/SecT233FieldElement.cs b/crypto/src/math/ec/custom/sec/SecT233FieldElement.cs
index 439c41d37..60b204604 100644
--- a/crypto/src/math/ec/custom/sec/SecT233FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecT233FieldElement.cs
@@ -12,7 +12,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
         public SecT233FieldElement(BigInteger x)
         {
-            if (x == null || x.SignValue < 0)
+            if (x == null || x.SignValue < 0 || x.BitLength > 233)
                 throw new ArgumentException("value invalid for SecT233FieldElement", "x");
 
             this.x = SecT233Field.FromBigInteger(x);
diff --git a/crypto/src/math/ec/custom/sec/SecT239FieldElement.cs b/crypto/src/math/ec/custom/sec/SecT239FieldElement.cs
index c89b484b1..e7bfffd1f 100644
--- a/crypto/src/math/ec/custom/sec/SecT239FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecT239FieldElement.cs
@@ -12,7 +12,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
         public SecT239FieldElement(BigInteger x)
         {
-            if (x == null || x.SignValue < 0)
+            if (x == null || x.SignValue < 0 || x.BitLength > 239)
                 throw new ArgumentException("value invalid for SecT239FieldElement", "x");
 
             this.x = SecT239Field.FromBigInteger(x);
diff --git a/crypto/src/math/ec/custom/sec/SecT283FieldElement.cs b/crypto/src/math/ec/custom/sec/SecT283FieldElement.cs
index 09243e859..9181b8685 100644
--- a/crypto/src/math/ec/custom/sec/SecT283FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecT283FieldElement.cs
@@ -12,7 +12,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
         public SecT283FieldElement(BigInteger x)
         {
-            if (x == null || x.SignValue < 0)
+            if (x == null || x.SignValue < 0 || x.BitLength > 283)
                 throw new ArgumentException("value invalid for SecT283FieldElement", "x");
 
             this.x = SecT283Field.FromBigInteger(x);
diff --git a/crypto/src/math/ec/custom/sec/SecT409FieldElement.cs b/crypto/src/math/ec/custom/sec/SecT409FieldElement.cs
index 6dabf6a7a..b60ceafee 100644
--- a/crypto/src/math/ec/custom/sec/SecT409FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecT409FieldElement.cs
@@ -12,7 +12,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
         public SecT409FieldElement(BigInteger x)
         {
-            if (x == null || x.SignValue < 0)
+            if (x == null || x.SignValue < 0 || x.BitLength > 409)
                 throw new ArgumentException("value invalid for SecT409FieldElement", "x");
 
             this.x = SecT409Field.FromBigInteger(x);
diff --git a/crypto/src/math/ec/custom/sec/SecT571FieldElement.cs b/crypto/src/math/ec/custom/sec/SecT571FieldElement.cs
index 8474c912e..a26e1e336 100644
--- a/crypto/src/math/ec/custom/sec/SecT571FieldElement.cs
+++ b/crypto/src/math/ec/custom/sec/SecT571FieldElement.cs
@@ -12,7 +12,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec
 
         public SecT571FieldElement(BigInteger x)
         {
-            if (x == null || x.SignValue < 0)
+            if (x == null || x.SignValue < 0 || x.BitLength > 571)
                 throw new ArgumentException("value invalid for SecT571FieldElement", "x");
 
             this.x = SecT571Field.FromBigInteger(x);