cleanup

cleanup

--- Tests/crypto/test/ECTest.cs
+++ Tests/crypto/test/ECTest.cs
@@ -1,916 +1,974 @@
 using NUnit.Framework;
-
 using Org.BouncyCastle.Asn1.Nist;
 using Org.BouncyCastle.Asn1.Sec;
 using Org.BouncyCastle.Asn1.X9;
-using Org.BouncyCastle.Math;
-using Org.BouncyCastle.Math.EC;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Crypto.Agreement;
 using Org.BouncyCastle.Crypto.Generators;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Crypto.Signers;
+using Org.BouncyCastle.Math;
+using Org.BouncyCastle.Math.EC;
+using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.Utilities.Test;

 namespace Org.BouncyCastle.Crypto.Tests
 {
-	/**
+    /**
 	 * ECDSA tests are taken from X9.62.
 	 */
-	[TestFixture]
-	public class ECTest
-		: SimpleTest
-	{
-		/**
+
+    [TestFixture]
+    public class ECTest : SimpleTest
+    {
+        /**
 		* X9.62 - 1998,

 		* J.3.1, Page 152, ECDSA over the field Fp

 		* an example with 192 bit prime
 		*/
-		[Test]
-		public void TestECDsa192bitPrime()
-		{
-			IBigInteger r = new BigInteger("3342403536405981729393488334694600415596881826869351677613");
-			IBigInteger s = new BigInteger("5735822328888155254683894997897571951568553642892029982342");
-
-			byte[] kData = BigIntegers.AsUnsignedByteArray(new BigInteger("6140507067065001063065065565667405560006161556565665656654"));
-
-			SecureRandom k = FixedSecureRandom.From(kData);
-
-			FPCurve curve = new FPCurve(
-				new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
-				new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
-				new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b
-
-			ECDomainParameters parameters = new ECDomainParameters(
-				curve,
-				curve.DecodePoint(Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")), // G
-				new BigInteger("6277101735386680763835789423176059013767194773182842284081")); // n
-
-			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
-				"ECDSA",
-				new BigInteger("651056770906015076056810763456358567190100156695615665659"), // d
-				parameters);
-
-			ParametersWithRandom param = new ParametersWithRandom(priKey, k);
-
-			ECDsaSigner ecdsa = new ECDsaSigner();
-
-			ecdsa.Init(true, param);
-
-			byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
-			IBigInteger[] sig = ecdsa.GenerateSignature(message);
-
-			if (!r.Equals(sig[0]))
-			{
-				Fail("r component wrong." + SimpleTest.NewLine
-					+ " expecting: " + r + SimpleTest.NewLine
-					+ " got      : " + sig[0]);
-			}
-
-			if (!s.Equals(sig[1]))
-			{
-				Fail("s component wrong." + SimpleTest.NewLine
-					+ " expecting: " + s + SimpleTest.NewLine
-					+ " got      : " + sig[1]);
-			}
-
-			// Verify the signature
-			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
-				"ECDSA",
-				curve.DecodePoint(Hex.Decode("0262b12d60690cdcf330babab6e69763b471f994dd702d16a5")), // Q
-				parameters);
-
-			ecdsa.Init(false, pubKey);
-			if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
-			{
-				Fail("verification fails");
-			}
-		}
-
-		[Test]
-		public void TestDecode()
-		{
-			FPCurve curve = new FPCurve(
-				new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
-				new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
-				new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b
-
-			ECPoint p = curve.DecodePoint(Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"));
-
-			if (!p.X.ToBigInteger().Equals(new BigInteger("188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", 16)))
-			{
-				Fail("x uncompressed incorrectly");
-			}
-
-			if (!p.Y.ToBigInteger().Equals(new BigInteger("7192b95ffc8da78631011ed6b24cdd573f977a11e794811", 16)))
-			{
-				Fail("y uncompressed incorrectly");
-			}
-
-			byte[] encoding = p.GetEncoded();
-
-			if (!AreEqual(encoding, Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")))
-			{
-				Fail("point compressed incorrectly");
-			}
-		}
-
-		/**
+
+        private static IBigInteger CalculateAgreement(
+            IAsymmetricCipherKeyPair u1,
+            IAsymmetricCipherKeyPair u2,
+            IAsymmetricCipherKeyPair v1,
+            IAsymmetricCipherKeyPair v2)
+        {
+            var u = new ECMqvBasicAgreement();
+            u.Init(new MqvPrivateParameters(
+                       (ECPrivateKeyParameters) u1.Private,
+                       (ECPrivateKeyParameters) u2.Private,
+                       (ECPublicKeyParameters) u2.Public));
+            IBigInteger ux = u.CalculateAgreement(new MqvPublicParameters(
+                                                      (ECPublicKeyParameters) v1.Public,
+                                                      (ECPublicKeyParameters) v2.Public));
+
+            var v = new ECMqvBasicAgreement();
+            v.Init(new MqvPrivateParameters(
+                       (ECPrivateKeyParameters) v1.Private,
+                       (ECPrivateKeyParameters) v2.Private,
+                       (ECPublicKeyParameters) v2.Public));
+            IBigInteger vx = v.CalculateAgreement(new MqvPublicParameters(
+                                                      (ECPublicKeyParameters) u1.Public,
+                                                      (ECPublicKeyParameters) u2.Public));
+
+            if (ux.Equals(vx))
+                return ux;
+
+            return null;
+        }
+
+        public override string Name
+        {
+            get { return "EC"; }
+        }
+
+        public override void PerformTest()
+        {
+            TestDecode();
+            TestECDsa192BitPrime();
+            TestECDsa239BitPrime();
+            TestECDsa191BitBinary();
+            TestECDsa239BitBinary();
+            TestECDsaKeyGenTest();
+            TestECBasicAgreementTest();
+
+            TestECDsaP224Sha224();
+            TestECDsaP224OneByteOver();
+            TestECDsaP256Sha256();
+            TestECDsaP521Sha512();
+            TestECDsaSecP224K1Sha256();
+            TestECDsa239BitBinaryAndLargeDigest();
+
+            TestECMqvTestVector1();
+            TestECMqvTestVector2();
+            TestECMqvRandom();
+        }
+
+        public static void Main(
+            string[] args)
+        {
+            RunTest(new ECTest());
+        }
+
+        [Test]
+        public void TestDecode()
+        {
+            var curve = new FPCurve(
+                new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
+                new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
+                new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b
+
+            ECPoint p = curve.DecodePoint(Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"));
+
+            if (!p.X.ToBigInteger().Equals(new BigInteger("188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", 16)))
+            {
+                Fail("x uncompressed incorrectly");
+            }
+
+            if (!p.Y.ToBigInteger().Equals(new BigInteger("7192b95ffc8da78631011ed6b24cdd573f977a11e794811", 16)))
+            {
+                Fail("y uncompressed incorrectly");
+            }
+
+            byte[] encoding = p.GetEncoded();
+
+            if (!AreEqual(encoding, Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")))
+            {
+                Fail("point compressed incorrectly");
+            }
+        }
+
+        [Test]
+        public void TestECBasicAgreementTest()
+        {
+            var random = new SecureRandom();
+
+            var curve = new FPCurve(
+                new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
+                new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
+                new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b
+
+            var parameters = new ECDomainParameters(
+                curve,
+                curve.DecodePoint(Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
+                new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n
+
+
+            var pGen = new ECKeyPairGenerator();
+            var genParam = new ECKeyGenerationParameters(parameters, random);
+
+            pGen.Init(genParam);
+
+            IAsymmetricCipherKeyPair p1 = pGen.GenerateKeyPair();
+            IAsymmetricCipherKeyPair p2 = pGen.GenerateKeyPair();
+
+            //
+            // two way
+            //
+            IBasicAgreement e1 = new EcdhBasicAgreement();
+            IBasicAgreement e2 = new EcdhBasicAgreement();
+
+            e1.Init(p1.Private);
+            e2.Init(p2.Private);
+
+            IBigInteger k1 = e1.CalculateAgreement(p2.Public);
+            IBigInteger k2 = e2.CalculateAgreement(p1.Public);
+
+            if (!k1.Equals(k2))
+            {
+                Fail("calculated agreement test failed");
+            }
+
+            //
+            // two way
+            //
+            e1 = new EcdhcBasicAgreement();
+            e2 = new EcdhcBasicAgreement();
+
+            e1.Init(p1.Private);
+            e2.Init(p2.Private);
+
+            k1 = e1.CalculateAgreement(p2.Public);
+            k2 = e2.CalculateAgreement(p1.Public);
+
+            if (!k1.Equals(k2))
+            {
+                Fail("calculated agreement test failed");
+            }
+        }
+
+        /**
 		 * X9.62 - 1998,

 		 * J.3.2, Page 155, ECDSA over the field Fp

 		 * an example with 239 bit prime
 		 */
-		[Test]
-		public void TestECDsa239bitPrime()
-		{
-			IBigInteger r = new BigInteger("308636143175167811492622547300668018854959378758531778147462058306432176");
-			IBigInteger s = new BigInteger("323813553209797357708078776831250505931891051755007842781978505179448783");
-
-			byte[] kData = BigIntegers.AsUnsignedByteArray(new BigInteger("700000017569056646655505781757157107570501575775705779575555657156756655"));
-
-			SecureRandom k = FixedSecureRandom.From(kData);
-
-			FPCurve curve = new FPCurve(
-				new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
-				new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
-				new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b
-
-			ECDomainParameters parameters = new ECDomainParameters(
-				curve,
-				curve.DecodePoint(Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
-				new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n
-
-			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
-				"ECDSA",
-				new BigInteger("876300101507107567501066130761671078357010671067781776716671676178726717"), // d
-				parameters);
-
-			ECDsaSigner ecdsa = new ECDsaSigner();
-			ParametersWithRandom param = new ParametersWithRandom(priKey, k);
-
-			ecdsa.Init(true, param);
-
-			byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
-			IBigInteger[] sig = ecdsa.GenerateSignature(message);
-
-			if (!r.Equals(sig[0]))
-			{
-				Fail("r component wrong." + SimpleTest.NewLine
-					+ " expecting: " + r + SimpleTest.NewLine
-					+ " got      : " + sig[0]);
-			}
-
-			if (!s.Equals(sig[1]))
-			{
-				Fail("s component wrong." + SimpleTest.NewLine
-					+ " expecting: " + s + SimpleTest.NewLine
-					+ " got      : " + sig[1]);
-			}
-
-			// Verify the signature
-			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
-				"ECDSA",
-				curve.DecodePoint(Hex.Decode("025b6dc53bc61a2548ffb0f671472de6c9521a9d2d2534e65abfcbd5fe0c70")), // Q
-				parameters);
-
-			ecdsa.Init(false, pubKey);
-			if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
-			{
-				Fail("signature fails");
-			}
-		}
-
-
-		/**
+
+
+        /**
 		 * X9.62 - 1998,

 		 * J.2.1, Page 100, ECDSA over the field F2m

 		 * an example with 191 bit binary field
 		 */
-		[Test]
-		public void TestECDsa191bitBinary()
-		{
-			IBigInteger r = new BigInteger("87194383164871543355722284926904419997237591535066528048");
-			IBigInteger s = new BigInteger("308992691965804947361541664549085895292153777025772063598");
-
-			byte[] kData = BigIntegers.AsUnsignedByteArray(new BigInteger("1542725565216523985789236956265265265235675811949404040041"));
-
-			SecureRandom k = FixedSecureRandom.From(kData);
-
-			F2MCurve curve = new F2MCurve(
-				191, // m
-				9, //k
-				new BigInteger("2866537B676752636A68F56554E12640276B649EF7526267", 16), // a
-				new BigInteger("2E45EF571F00786F67B0081B9495A3D95462F5DE0AA185EC", 16)); // b
-
-			ECDomainParameters parameters = new ECDomainParameters(
-				curve,
-				curve.DecodePoint(Hex.Decode("0436B3DAF8A23206F9C4F299D7B21A9C369137F2C84AE1AA0D765BE73433B3F95E332932E70EA245CA2418EA0EF98018FB")), // G
-				new BigInteger("1569275433846670190958947355803350458831205595451630533029"), // n
-				BigInteger.Two); // h
-
-			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
-				"ECDSA",
-				new BigInteger("1275552191113212300012030439187146164646146646466749494799"), // d
-				parameters);
-
-			ECDsaSigner ecdsa = new ECDsaSigner();
-			ParametersWithRandom param = new ParametersWithRandom(priKey, k);
-
-			ecdsa.Init(true, param);
-
-			byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
-			IBigInteger[] sig = ecdsa.GenerateSignature(message);
-
-			if (!r.Equals(sig[0]))
-			{
-				Fail("r component wrong." + SimpleTest.NewLine
-					+ " expecting: " + r + SimpleTest.NewLine
-					+ " got      : " + sig[0]);
-			}
-
-			if (!s.Equals(sig[1]))
-			{
-				Fail("s component wrong." + SimpleTest.NewLine
-					+ " expecting: " + s + SimpleTest.NewLine
-					+ " got      : " + sig[1]);
-			}
-
-			// Verify the signature
-			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
-				"ECDSA",
-				curve.DecodePoint(Hex.Decode("045DE37E756BD55D72E3768CB396FFEB962614DEA4CE28A2E755C0E0E02F5FB132CAF416EF85B229BBB8E1352003125BA1")), // Q
-				parameters);
-
-			ecdsa.Init(false, pubKey);
-			if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
-			{
-				Fail("signature fails");
-			}
-		}
-
-		/**
+
+        [Test]
+        public void TestECDsa191BitBinary()
+        {
+            IBigInteger r = new BigInteger("87194383164871543355722284926904419997237591535066528048");
+            IBigInteger s = new BigInteger("308992691965804947361541664549085895292153777025772063598");
+
+            byte[] kData =
+                BigIntegers.AsUnsignedByteArray(
+                    new BigInteger("1542725565216523985789236956265265265235675811949404040041"));
+
+            SecureRandom k = FixedSecureRandom.From(kData);
+
+            var curve = new F2MCurve(
+                191, // m
+                9, //k
+                new BigInteger("2866537B676752636A68F56554E12640276B649EF7526267", 16), // a
+                new BigInteger("2E45EF571F00786F67B0081B9495A3D95462F5DE0AA185EC", 16)); // b
+
+            var parameters = new ECDomainParameters(
+                curve,
+                curve.DecodePoint(
+                    Hex.Decode(
+                        "0436B3DAF8A23206F9C4F299D7B21A9C369137F2C84AE1AA0D765BE73433B3F95E332932E70EA245CA2418EA0EF98018FB")),
+                // G
+                new BigInteger("1569275433846670190958947355803350458831205595451630533029"), // n
+                BigInteger.Two); // h
+
+            var priKey = new ECPrivateKeyParameters(
+                "ECDSA",
+                new BigInteger("1275552191113212300012030439187146164646146646466749494799"), // d
+                parameters);
+
+            var ecdsa = new ECDsaSigner();
+            var param = new ParametersWithRandom(priKey, k);
+
+            ecdsa.Init(true, param);
+
+            byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
+            IBigInteger[] sig = ecdsa.GenerateSignature(message);
+
+            if (!r.Equals(sig[0]))
+            {
+                Fail("r component wrong." + NewLine
+                     + " expecting: " + r + NewLine
+                     + " got      : " + sig[0]);
+            }
+
+            if (!s.Equals(sig[1]))
+            {
+                Fail("s component wrong." + NewLine
+                     + " expecting: " + s + NewLine
+                     + " got      : " + sig[1]);
+            }
+
+            // Verify the signature
+            var pubKey = new ECPublicKeyParameters(
+                "ECDSA",
+                curve.DecodePoint(
+                    Hex.Decode(
+                        "045DE37E756BD55D72E3768CB396FFEB962614DEA4CE28A2E755C0E0E02F5FB132CAF416EF85B229BBB8E1352003125BA1")),
+                // Q
+                parameters);
+
+            ecdsa.Init(false, pubKey);
+            if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
+            {
+                Fail("signature fails");
+            }
+        }
+
+        [Test]
+        public void TestECDsa192BitPrime()
+        {
+            IBigInteger r = new BigInteger("3342403536405981729393488334694600415596881826869351677613");
+            IBigInteger s = new BigInteger("5735822328888155254683894997897571951568553642892029982342");
+
+            byte[] kData =
+                BigIntegers.AsUnsignedByteArray(
+                    new BigInteger("6140507067065001063065065565667405560006161556565665656654"));
+
+            SecureRandom k = FixedSecureRandom.From(kData);
+
+            var curve = new FPCurve(
+                new BigInteger("6277101735386680763835789423207666416083908700390324961279"), // q
+                new BigInteger("fffffffffffffffffffffffffffffffefffffffffffffffc", 16), // a
+                new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16)); // b
+
+            var parameters = new ECDomainParameters(
+                curve,
+                curve.DecodePoint(Hex.Decode("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012")), // G
+                new BigInteger("6277101735386680763835789423176059013767194773182842284081")); // n
+
+            var priKey = new ECPrivateKeyParameters(
+                "ECDSA",
+                new BigInteger("651056770906015076056810763456358567190100156695615665659"), // d
+                parameters);
+
+            var param = new ParametersWithRandom(priKey, k);
+
+            var ecdsa = new ECDsaSigner();
+
+            ecdsa.Init(true, param);
+
+            byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
+            IBigInteger[] sig = ecdsa.GenerateSignature(message);
+
+            if (!r.Equals(sig[0]))
+            {
+                Fail("r component wrong." + NewLine
+                     + " expecting: " + r + NewLine
+                     + " got      : " + sig[0]);
+            }
+
+            if (!s.Equals(sig[1]))
+            {
+                Fail("s component wrong." + NewLine
+                     + " expecting: " + s + NewLine
+                     + " got      : " + sig[1]);
+            }
+
+            // Verify the signature
+            var pubKey = new ECPublicKeyParameters(
+                "ECDSA",
+                curve.DecodePoint(Hex.Decode("0262b12d60690cdcf330babab6e69763b471f994dd702d16a5")), // Q
+                parameters);
+
+            ecdsa.Init(false, pubKey);
+            if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
+            {
+                Fail("verification fails");
+            }
+        }
+
+        /**
 		 * X9.62 - 1998,

 		 * J.2.1, Page 100, ECDSA over the field F2m

 		 * an example with 191 bit binary field
 		 */
-		[Test]
-		public void TestECDsa239bitBinary()
-		{
-			IBigInteger r = new BigInteger("21596333210419611985018340039034612628818151486841789642455876922391552");
-			IBigInteger s = new BigInteger("197030374000731686738334997654997227052849804072198819102649413465737174");
-
-			byte[] kData = BigIntegers.AsUnsignedByteArray(new BigInteger("171278725565216523967285789236956265265265235675811949404040041670216363"));
-
-			SecureRandom k = FixedSecureRandom.From(kData);
-
-			F2MCurve curve = new F2MCurve(
-				239, // m
-				36, //k
-				new BigInteger("32010857077C5431123A46B808906756F543423E8D27877578125778AC76", 16), // a
-				new BigInteger("790408F2EEDAF392B012EDEFB3392F30F4327C0CA3F31FC383C422AA8C16", 16)); // b
-
-			ECDomainParameters parameters = new ECDomainParameters(
-				curve,
-				curve.DecodePoint(Hex.Decode("0457927098FA932E7C0A96D3FD5B706EF7E5F5C156E16B7E7C86038552E91D61D8EE5077C33FECF6F1A16B268DE469C3C7744EA9A971649FC7A9616305")), // G
-				new BigInteger("220855883097298041197912187592864814557886993776713230936715041207411783"), // n
-				BigInteger.ValueOf(4)); // h
-
-			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
-				"ECDSA",
-				new BigInteger("145642755521911534651321230007534120304391871461646461466464667494947990"), // d
-				parameters);
-
-			ECDsaSigner ecdsa = new ECDsaSigner();
-			ParametersWithRandom param = new ParametersWithRandom(priKey, k);
-
-			ecdsa.Init(true, param);
-
-			byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
-			IBigInteger[] sig = ecdsa.GenerateSignature(message);
-
-			if (!r.Equals(sig[0]))
-			{
-				Fail("r component wrong." + SimpleTest.NewLine
-					+ " expecting: " + r + SimpleTest.NewLine
-					+ " got      : " + sig[0]);
-			}
-
-			if (!s.Equals(sig[1]))
-			{
-				Fail("s component wrong." + SimpleTest.NewLine
-					+ " expecting: " + s + SimpleTest.NewLine
-					+ " got      : " + sig[1]);
-			}
-
-			// Verify the signature
-			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
-				"ECDSA",
-				curve.DecodePoint(Hex.Decode("045894609CCECF9A92533F630DE713A958E96C97CCB8F5ABB5A688A238DEED6DC2D9D0C94EBFB7D526BA6A61764175B99CB6011E2047F9F067293F57F5")), // Q
-				parameters);
-
-			ecdsa.Init(false, pubKey);
-			if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
-			{
-				Fail("signature fails");
-			}
-		}
-
-		// L 4.1  X9.62 2005
-		[Test]
-		public void TestECDsaP224Sha224()
-		{
-			X9ECParameters p = NistNamedCurves.GetByName("P-224");
-			ECDomainParameters parameters = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
-			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
-				new BigInteger("6081831502424510080126737029209236539191290354021104541805484120491"), // d
-				parameters);
-			SecureRandom k = FixedSecureRandom.From(BigIntegers.AsUnsignedByteArray(new BigInteger("15456715103636396133226117016818339719732885723579037388121116732601")));
-
-			byte[] M = Hex.Decode("8797A3C693CC292441039A4E6BAB7387F3B4F2A63D00ED384B378C79");
-
-			ECDsaSigner dsa = new ECDsaSigner();
-
-			dsa.Init(true, new ParametersWithRandom(priKey, k));
-
-			IBigInteger[] sig = dsa.GenerateSignature(M);
-
-			IBigInteger r = new BigInteger("26477406756127720855365980332052585411804331993436302005017227573742");
-			IBigInteger s = new BigInteger("17694958233103667059888193972742186995283044672015112738919822429978");
-
-			if (!r.Equals(sig[0]))
-			{
-				Fail("r component wrong." + SimpleTest.NewLine
-					+ " expecting: " + r + SimpleTest.NewLine
-					+ " got      : " + sig[0]);
-			}
-
-			if (!s.Equals(sig[1]))
-			{
-				Fail("s component wrong." + SimpleTest.NewLine
-					+ " expecting: " + s + SimpleTest.NewLine
-					+ " got      : " + sig[1]);
-			}
-
-			// Verify the signature
-			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
-				parameters.Curve.DecodePoint(Hex.Decode("03FD44EC11F9D43D9D23B1E1D1C9ED6519B40ECF0C79F48CF476CC43F1")), // Q
-				parameters);
-
-			dsa.Init(false, pubKey);
-			if (!dsa.VerifySignature(M, sig[0], sig[1]))
-			{
-				Fail("signature fails");
-			}
-		}
-
-		[Test]
-		public void TestECDsaSecP224k1Sha256()
-		{
-			X9ECParameters p = SecNamedCurves.GetByName("secp224k1");
-			ECDomainParameters parameters = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
-			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
-				new BigInteger("BE6F6E91FE96840A6518B56F3FE21689903A64FA729057AB872A9F51", 16), // d
-				parameters);
-			SecureRandom k = FixedSecureRandom.From(Hex.Decode("00c39beac93db21c3266084429eb9b846b787c094f23a4de66447efbb3"));
-
-			byte[] M = Hex.Decode("E5D5A7ADF73C5476FAEE93A2C76CE94DC0557DB04CDC189504779117920B896D");
-
-			ECDsaSigner dsa = new ECDsaSigner();
-
-			dsa.Init(true, new ParametersWithRandom(priKey, k));
-
-			IBigInteger[] sig = dsa.GenerateSignature(M);
-
-			IBigInteger r = new BigInteger("8163E5941BED41DA441B33E653C632A55A110893133351E20CE7CB75", 16);
-			IBigInteger s = new BigInteger("D12C3FC289DDD5F6890DCE26B65792C8C50E68BF551D617D47DF15A8", 16);
-
-			if (!r.Equals(sig[0]))
-			{
-				Fail("r component wrong." + SimpleTest.NewLine
-					+ " expecting: " + r + SimpleTest.NewLine
-					+ " got      : " + sig[0]);
-			}
-
-			if (!s.Equals(sig[1]))
-			{
-				Fail("s component wrong." + SimpleTest.NewLine
-					+ " expecting: " + s + SimpleTest.NewLine
-					+ " got      : " + sig[1]);
-			}
-
-			// Verify the signature
-			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
-				parameters.Curve.DecodePoint(Hex.Decode("04C5C9B38D3603FCCD6994CBB9594E152B658721E483669BB42728520F484B537647EC816E58A8284D3B89DFEDB173AFDC214ECA95A836FA7C")), // Q
-				parameters);
-
-			dsa.Init(false, pubKey);
-			if (!dsa.VerifySignature(M, sig[0], sig[1]))
-			{
-				Fail("signature fails");
-			}
-		}
-
-		// L4.2  X9.62 2005
-		[Test]
-		public void TestECDsaP256Sha256()
-		{
-			X9ECParameters p = NistNamedCurves.GetByName("P-256");
-			ECDomainParameters parameters = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
-			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
-				new BigInteger("20186677036482506117540275567393538695075300175221296989956723148347484984008"), // d
-				parameters);
-			SecureRandom k = FixedSecureRandom.From(BigIntegers.AsUnsignedByteArray(new BigInteger("72546832179840998877302529996971396893172522460793442785601695562409154906335")));
-
-			byte[] M = Hex.Decode("1BD4ED430B0F384B4E8D458EFF1A8A553286D7AC21CB2F6806172EF5F94A06AD");
-
-			ECDsaSigner dsa = new ECDsaSigner();
-
-			dsa.Init(true, new ParametersWithRandom(priKey, k));
-
-			IBigInteger[] sig = dsa.GenerateSignature(M);
-
-			IBigInteger r = new BigInteger("97354732615802252173078420023658453040116611318111190383344590814578738210384");
-			IBigInteger s = new BigInteger("98506158880355671805367324764306888225238061309262649376965428126566081727535");
-
-			if (!r.Equals(sig[0]))
-			{
-				Fail("r component wrong." + SimpleTest.NewLine
-					+ " expecting: " + r + SimpleTest.NewLine
-					+ " got      : " + sig[0]);
-			}
-
-			if (!s.Equals(sig[1]))
-			{
-				Fail("s component wrong." + SimpleTest.NewLine
-					+ " expecting: " + s + SimpleTest.NewLine
-					+ " got      : " + sig[1]);
-			}
-
-			// Verify the signature
-			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
-				parameters.Curve.DecodePoint(Hex.Decode("03596375E6CE57E0F20294FC46BDFCFD19A39F8161B58695B3EC5B3D16427C274D")), // Q
-				parameters);
-
-			dsa.Init(false, pubKey);
-			if (!dsa.VerifySignature(M, sig[0], sig[1]))
-			{
-				Fail("signature fails");
-			}
-		}
-
-		[Test]
-		public void TestECDsaP224OneByteOver()
-		{
-			X9ECParameters p = NistNamedCurves.GetByName("P-224");
-			ECDomainParameters parameters = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
-			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
-				new BigInteger("6081831502424510080126737029209236539191290354021104541805484120491"), // d
-				parameters);
-			SecureRandom    k = FixedSecureRandom.From(BigIntegers.AsUnsignedByteArray(new BigInteger("15456715103636396133226117016818339719732885723579037388121116732601")));
-
-			byte[] M = Hex.Decode("8797A3C693CC292441039A4E6BAB7387F3B4F2A63D00ED384B378C79FF");
-
-			ECDsaSigner dsa = new ECDsaSigner();
-
-			dsa.Init(true, new ParametersWithRandom(priKey, k));
-
-			IBigInteger[] sig = dsa.GenerateSignature(M);
-
-			IBigInteger r = new BigInteger("26477406756127720855365980332052585411804331993436302005017227573742");
-			IBigInteger s = new BigInteger("17694958233103667059888193972742186995283044672015112738919822429978");
-
-			if (!r.Equals(sig[0]))
-			{
-				Fail("r component wrong." + SimpleTest.NewLine
-					+ " expecting: " + r + SimpleTest.NewLine
-					+ " got      : " + sig[0]);
-			}
-
-			if (!s.Equals(sig[1]))
-			{
-				Fail("s component wrong." + SimpleTest.NewLine
-					+ " expecting: " + s + SimpleTest.NewLine
-					+ " got      : " + sig[1]);
-			}
-
-			// Verify the signature
-			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
-				parameters.Curve.DecodePoint(Hex.Decode("03FD44EC11F9D43D9D23B1E1D1C9ED6519B40ECF0C79F48CF476CC43F1")), // Q
-				parameters);
-
-			dsa.Init(false, pubKey);
-			if (!dsa.VerifySignature(M, sig[0], sig[1]))
-			{
-				Fail("signature fails");
-			}
-		}
-
-		// L4.3  X9.62 2005
-		[Test]
-		public void TestECDsaP521Sha512()
-		{
-			X9ECParameters p = NistNamedCurves.GetByName("P-521");
-			ECDomainParameters parameters = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
-			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
-				new BigInteger("617573726813476282316253885608633222275541026607493641741273231656161177732180358888434629562647985511298272498852936680947729040673640492310550142822667389"), // d
-				parameters);
-			SecureRandom k = FixedSecureRandom.From(BigIntegers.AsUnsignedByteArray(new BigInteger("6806532878215503520845109818432174847616958675335397773700324097584974639728725689481598054743894544060040710846048585856076812050552869216017728862957612913")));
-
-			byte[] M = Hex.Decode("6893B64BD3A9615C39C3E62DDD269C2BAAF1D85915526083183CE14C2E883B48B193607C1ED871852C9DF9C3147B574DC1526C55DE1FE263A676346A20028A66");
-
-			ECDsaSigner dsa = new ECDsaSigner();
-
-			dsa.Init(true, new ParametersWithRandom(priKey, k));
-
-			IBigInteger[] sig = dsa.GenerateSignature(M);
-
-			IBigInteger r = new BigInteger("1368926195812127407956140744722257403535864168182534321188553460365652865686040549247096155740756318290773648848859639978618869784291633651685766829574104630");
-			IBigInteger s = new BigInteger("1624754720348883715608122151214003032398685415003935734485445999065609979304811509538477657407457976246218976767156629169821116579317401249024208611945405790");
-
-			if (!r.Equals(sig[0]))
-			{
-				Fail("r component wrong." + SimpleTest.NewLine
-					+ " expecting: " + r + SimpleTest.NewLine
-					+ " got      : " + sig[0]);
-			}
-
-			if (!s.Equals(sig[1]))
-			{
-				Fail("s component wrong." + SimpleTest.NewLine
-					+ " expecting: " + s + SimpleTest.NewLine
-					+ " got      : " + sig[1]);
-			}
-
-			// Verify the signature
-			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
-				parameters.Curve.DecodePoint(Hex.Decode("020145E221AB9F71C5FE740D8D2B94939A09E2816E2167A7D058125A06A80C014F553E8D6764B048FB6F2B687CEC72F39738F223D4CE6AFCBFF2E34774AA5D3C342CB3")), // Q
-				parameters);
-
-			dsa.Init(false, pubKey);
-			if (!dsa.VerifySignature(M, sig[0], sig[1]))
-			{
-				Fail("signature fails");
-			}
-		}
-
-		/**
+
+        [Test]
+        public void TestECDsa239BitBinary()
+        {
+            IBigInteger r = new BigInteger("21596333210419611985018340039034612628818151486841789642455876922391552");
+            IBigInteger s = new BigInteger("197030374000731686738334997654997227052849804072198819102649413465737174");
+
+            byte[] kData =
+                BigIntegers.AsUnsignedByteArray(
+                    new BigInteger("171278725565216523967285789236956265265265235675811949404040041670216363"));
+
+            SecureRandom k = FixedSecureRandom.From(kData);
+
+            var curve = new F2MCurve(
+                239, // m
+                36, //k
+                new BigInteger("32010857077C5431123A46B808906756F543423E8D27877578125778AC76", 16), // a
+                new BigInteger("790408F2EEDAF392B012EDEFB3392F30F4327C0CA3F31FC383C422AA8C16", 16)); // b
+
+            var parameters = new ECDomainParameters(
+                curve,
+                curve.DecodePoint(
+                    Hex.Decode(
+                        "0457927098FA932E7C0A96D3FD5B706EF7E5F5C156E16B7E7C86038552E91D61D8EE5077C33FECF6F1A16B268DE469C3C7744EA9A971649FC7A9616305")),
+                // G
+                new BigInteger("220855883097298041197912187592864814557886993776713230936715041207411783"), // n
+                BigInteger.ValueOf(4)); // h
+
+            var priKey = new ECPrivateKeyParameters(
+                "ECDSA",
+                new BigInteger("145642755521911534651321230007534120304391871461646461466464667494947990"), // d
+                parameters);
+
+            var ecdsa = new ECDsaSigner();
+            var param = new ParametersWithRandom(priKey, k);
+
+            ecdsa.Init(true, param);
+
+            byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
+            IBigInteger[] sig = ecdsa.GenerateSignature(message);
+
+            if (!r.Equals(sig[0]))
+            {
+                Fail("r component wrong." + NewLine
+                     + " expecting: " + r + NewLine
+                     + " got      : " + sig[0]);
+            }
+
+            if (!s.Equals(sig[1]))
+            {
+                Fail("s component wrong." + NewLine
+                     + " expecting: " + s + NewLine
+                     + " got      : " + sig[1]);
+            }
+
+            // Verify the signature
+            var pubKey = new ECPublicKeyParameters(
+                "ECDSA",
+                curve.DecodePoint(
+                    Hex.Decode(
+                        "045894609CCECF9A92533F630DE713A958E96C97CCB8F5ABB5A688A238DEED6DC2D9D0C94EBFB7D526BA6A61764175B99CB6011E2047F9F067293F57F5")),
+                // Q
+                parameters);
+
+            ecdsa.Init(false, pubKey);
+            if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
+            {
+                Fail("signature fails");
+            }
+        }
+
+        [Test]
+        public void TestECDsa239BitBinaryAndLargeDigest()
+        {
+            IBigInteger r = new BigInteger("21596333210419611985018340039034612628818151486841789642455876922391552");
+            IBigInteger s = new BigInteger("144940322424411242416373536877786566515839911620497068645600824084578597");
+
+            byte[] kData = BigIntegers.AsUnsignedByteArray(
+                new BigInteger("171278725565216523967285789236956265265265235675811949404040041670216363"));
+
+            SecureRandom k = FixedSecureRandom.From(kData);
+
+            var curve = new F2MCurve(
+                239, // m
+                36, //k
+                new BigInteger("32010857077C5431123A46B808906756F543423E8D27877578125778AC76", 16), // a
+                new BigInteger("790408F2EEDAF392B012EDEFB3392F30F4327C0CA3F31FC383C422AA8C16", 16)); // b
+
+            var parameters = new ECDomainParameters(
+                curve,
+                curve.DecodePoint(
+                    Hex.Decode(
+                        "0457927098FA932E7C0A96D3FD5B706EF7E5F5C156E16B7E7C86038552E91D61D8EE5077C33FECF6F1A16B268DE469C3C7744EA9A971649FC7A9616305")),
+                // G
+                new BigInteger("220855883097298041197912187592864814557886993776713230936715041207411783"), // n
+                BigInteger.ValueOf(4)); // h
+
+            var priKey = new ECPrivateKeyParameters(
+                "ECDSA",
+                new BigInteger("145642755521911534651321230007534120304391871461646461466464667494947990"), // d
+                parameters);
+
+            var ecdsa = new ECDsaSigner();
+            var param = new ParametersWithRandom(priKey, k);
+
+            ecdsa.Init(true, param);
+
+            byte[] message =
+                new BigInteger(
+                    "968236873715988614170569073515315707566766479517968236873715988614170569073515315707566766479517968236873715988614170569073515315707566766479517")
+                    .ToByteArray();
+            IBigInteger[] sig = ecdsa.GenerateSignature(message);
+
+            if (!r.Equals(sig[0]))
+            {
+                Fail("r component wrong." + NewLine
+                     + " expecting: " + r + NewLine
+                     + " got      : " + sig[0]);
+            }
+
+            if (!s.Equals(sig[1]))
+            {
+                Fail("s component wrong." + NewLine
+                     + " expecting: " + s + NewLine
+                     + " got      : " + sig[1]);
+            }
+
+            // Verify the signature
+            var pubKey = new ECPublicKeyParameters(
+                "ECDSA",
+                curve.DecodePoint(
+                    Hex.Decode(
+                        "045894609CCECF9A92533F630DE713A958E96C97CCB8F5ABB5A688A238DEED6DC2D9D0C94EBFB7D526BA6A61764175B99CB6011E2047F9F067293F57F5")),
+                // Q
+                parameters);
+
+            ecdsa.Init(false, pubKey);
+            if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
+            {
+                Fail("signature fails");
+            }
+        }
+
+        [Test]
+        public void TestECDsa239BitPrime()
+        {
+            IBigInteger r = new BigInteger("308636143175167811492622547300668018854959378758531778147462058306432176");
+            IBigInteger s = new BigInteger("323813553209797357708078776831250505931891051755007842781978505179448783");
+
+            byte[] kData =
+                BigIntegers.AsUnsignedByteArray(
+                    new BigInteger("700000017569056646655505781757157107570501575775705779575555657156756655"));
+
+            SecureRandom k = FixedSecureRandom.From(kData);
+
+            var curve = new FPCurve(
+                new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
+                new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
+                new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b
+
+            var parameters = new ECDomainParameters(
+                curve,
+                curve.DecodePoint(Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
+                new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n
+
+            var priKey = new ECPrivateKeyParameters(
+                "ECDSA",
+                new BigInteger("876300101507107567501066130761671078357010671067781776716671676178726717"), // d
+                parameters);
+
+            var ecdsa = new ECDsaSigner();
+            var param = new ParametersWithRandom(priKey, k);
+
+            ecdsa.Init(true, param);
+
+            byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
+            IBigInteger[] sig = ecdsa.GenerateSignature(message);
+
+            if (!r.Equals(sig[0]))
+            {
+                Fail("r component wrong." + NewLine
+                     + " expecting: " + r + NewLine
+                     + " got      : " + sig[0]);
+            }
+
+            if (!s.Equals(sig[1]))
+            {
+                Fail("s component wrong." + NewLine
+                     + " expecting: " + s + NewLine
+                     + " got      : " + sig[1]);
+            }
+
+            // Verify the signature
+            var pubKey = new ECPublicKeyParameters(
+                "ECDSA",
+                curve.DecodePoint(Hex.Decode("025b6dc53bc61a2548ffb0f671472de6c9521a9d2d2534e65abfcbd5fe0c70")), // Q
+                parameters);
+
+            ecdsa.Init(false, pubKey);
+            if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
+            {
+                Fail("signature fails");
+            }
+        }
+
+        [Test]
+        public void TestECDsaKeyGenTest()
+        {
+            var random = new SecureRandom();
+
+            var curve = new FPCurve(
+                new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
+                new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
+                new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b
+
+            var parameters = new ECDomainParameters(
+                curve,
+                curve.DecodePoint(Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
+                new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n
+
+
+            var pGen = new ECKeyPairGenerator();
+            var genParam = new ECKeyGenerationParameters(
+                parameters,
+                random);
+
+            pGen.Init(genParam);
+
+            IAsymmetricCipherKeyPair pair = pGen.GenerateKeyPair();
+
+            var param = new ParametersWithRandom(pair.Private, random);
+
+            var ecdsa = new ECDsaSigner();
+
+            ecdsa.Init(true, param);
+
+            byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
+            IBigInteger[] sig = ecdsa.GenerateSignature(message);
+
+            ecdsa.Init(false, pair.Public);
+
+            if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
+            {
+                Fail("signature fails");
+            }
+        }
+
+        [Test]
+        public void TestECDsaP224OneByteOver()
+        {
+            X9ECParameters p = NistNamedCurves.GetByName("P-224");
+            var parameters = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
+            var priKey = new ECPrivateKeyParameters(
+                new BigInteger("6081831502424510080126737029209236539191290354021104541805484120491"), // d
+                parameters);
+            SecureRandom k =
+                FixedSecureRandom.From(
+                    BigIntegers.AsUnsignedByteArray(
+                        new BigInteger("15456715103636396133226117016818339719732885723579037388121116732601")));
+
+            byte[] m = Hex.Decode("8797A3C693CC292441039A4E6BAB7387F3B4F2A63D00ED384B378C79FF");
+
+            var dsa = new ECDsaSigner();
+
+            dsa.Init(true, new ParametersWithRandom(priKey, k));
+
+            IBigInteger[] sig = dsa.GenerateSignature(m);
+
+            IBigInteger r = new BigInteger("26477406756127720855365980332052585411804331993436302005017227573742");
+            IBigInteger s = new BigInteger("17694958233103667059888193972742186995283044672015112738919822429978");
+
+            if (!r.Equals(sig[0]))
+            {
+                Fail("r component wrong." + NewLine
+                     + " expecting: " + r + NewLine
+                     + " got      : " + sig[0]);
+            }
+
+            if (!s.Equals(sig[1]))
+            {
+                Fail("s component wrong." + NewLine
+                     + " expecting: " + s + NewLine
+                     + " got      : " + sig[1]);
+            }
+
+            // Verify the signature
+            var pubKey = new ECPublicKeyParameters(
+                parameters.Curve.DecodePoint(Hex.Decode("03FD44EC11F9D43D9D23B1E1D1C9ED6519B40ECF0C79F48CF476CC43F1")),
+                // Q
+                parameters);
+
+            dsa.Init(false, pubKey);
+            if (!dsa.VerifySignature(m, sig[0], sig[1]))
+            {
+                Fail("signature fails");
+            }
+        }
+
+        // L 4.1  X9.62 2005
+        [Test]
+        public void TestECDsaP224Sha224()
+        {
+            X9ECParameters p = NistNamedCurves.GetByName("P-224");
+            var parameters = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
+            var priKey = new ECPrivateKeyParameters(
+                new BigInteger("6081831502424510080126737029209236539191290354021104541805484120491"), // d
+                parameters);
+            SecureRandom k =
+                FixedSecureRandom.From(
+                    BigIntegers.AsUnsignedByteArray(
+                        new BigInteger("15456715103636396133226117016818339719732885723579037388121116732601")));
+
+            byte[] m = Hex.Decode("8797A3C693CC292441039A4E6BAB7387F3B4F2A63D00ED384B378C79");
+
+            var dsa = new ECDsaSigner();
+
+            dsa.Init(true, new ParametersWithRandom(priKey, k));
+
+            IBigInteger[] sig = dsa.GenerateSignature(m);
+
+            IBigInteger r = new BigInteger("26477406756127720855365980332052585411804331993436302005017227573742");
+            IBigInteger s = new BigInteger("17694958233103667059888193972742186995283044672015112738919822429978");
+
+            if (!r.Equals(sig[0]))
+            {
+                Fail("r component wrong." + NewLine
+                     + " expecting: " + r + NewLine
+                     + " got      : " + sig[0]);
+            }
+
+            if (!s.Equals(sig[1]))
+            {
+                Fail("s component wrong." + NewLine
+                     + " expecting: " + s + NewLine
+                     + " got      : " + sig[1]);
+            }
+
+            // Verify the signature
+            var pubKey = new ECPublicKeyParameters(
+                parameters.Curve.DecodePoint(Hex.Decode("03FD44EC11F9D43D9D23B1E1D1C9ED6519B40ECF0C79F48CF476CC43F1")),
+                // Q
+                parameters);
+
+            dsa.Init(false, pubKey);
+            if (!dsa.VerifySignature(m, sig[0], sig[1]))
+            {
+                Fail("signature fails");
+            }
+        }
+
+        // L4.2  X9.62 2005
+        [Test]
+        public void TestECDsaP256Sha256()
+        {
+            X9ECParameters p = NistNamedCurves.GetByName("P-256");
+            var parameters = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
+            var priKey = new ECPrivateKeyParameters(
+                new BigInteger("20186677036482506117540275567393538695075300175221296989956723148347484984008"), // d
+                parameters);
+            SecureRandom k =
+                FixedSecureRandom.From(
+                    BigIntegers.AsUnsignedByteArray(
+                        new BigInteger("72546832179840998877302529996971396893172522460793442785601695562409154906335")));
+
+            byte[] m = Hex.Decode("1BD4ED430B0F384B4E8D458EFF1A8A553286D7AC21CB2F6806172EF5F94A06AD");
+
+            var dsa = new ECDsaSigner();
+
+            dsa.Init(true, new ParametersWithRandom(priKey, k));
+
+            IBigInteger[] sig = dsa.GenerateSignature(m);
+
+            IBigInteger r =
+                new BigInteger("97354732615802252173078420023658453040116611318111190383344590814578738210384");
+            IBigInteger s =
+                new BigInteger("98506158880355671805367324764306888225238061309262649376965428126566081727535");
+
+            if (!r.Equals(sig[0]))
+            {
+                Fail("r component wrong." + NewLine
+                     + " expecting: " + r + NewLine
+                     + " got      : " + sig[0]);
+            }
+
+            if (!s.Equals(sig[1]))
+            {
+                Fail("s component wrong." + NewLine
+                     + " expecting: " + s + NewLine
+                     + " got      : " + sig[1]);
+            }
+
+            // Verify the signature
+            var pubKey = new ECPublicKeyParameters(
+                parameters.Curve.DecodePoint(
+                    Hex.Decode("03596375E6CE57E0F20294FC46BDFCFD19A39F8161B58695B3EC5B3D16427C274D")), // Q
+                parameters);
+
+            dsa.Init(false, pubKey);
+            if (!dsa.VerifySignature(m, sig[0], sig[1]))
+            {
+                Fail("signature fails");
+            }
+        }
+
+        // L4.3  X9.62 2005
+        [Test]
+        public void TestECDsaP521Sha512()
+        {
+            X9ECParameters p = NistNamedCurves.GetByName("P-521");
+            var parameters = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
+            var priKey = new ECPrivateKeyParameters(
+                new BigInteger(
+                    "617573726813476282316253885608633222275541026607493641741273231656161177732180358888434629562647985511298272498852936680947729040673640492310550142822667389"),
+                // d
+                parameters);
+            SecureRandom k =
+                FixedSecureRandom.From(
+                    BigIntegers.AsUnsignedByteArray(
+                        new BigInteger(
+                            "6806532878215503520845109818432174847616958675335397773700324097584974639728725689481598054743894544060040710846048585856076812050552869216017728862957612913")));
+
+            byte[] m =
+                Hex.Decode(
+                    "6893B64BD3A9615C39C3E62DDD269C2BAAF1D85915526083183CE14C2E883B48B193607C1ED871852C9DF9C3147B574DC1526C55DE1FE263A676346A20028A66");
+
+            var dsa = new ECDsaSigner();
+
+            dsa.Init(true, new ParametersWithRandom(priKey, k));
+
+            IBigInteger[] sig = dsa.GenerateSignature(m);
+
+            IBigInteger r =
+                new BigInteger(
+                    "1368926195812127407956140744722257403535864168182534321188553460365652865686040549247096155740756318290773648848859639978618869784291633651685766829574104630");
+            IBigInteger s =
+                new BigInteger(
+                    "1624754720348883715608122151214003032398685415003935734485445999065609979304811509538477657407457976246218976767156629169821116579317401249024208611945405790");
+
+            if (!r.Equals(sig[0]))
+            {
+                Fail("r component wrong." + NewLine
+                     + " expecting: " + r + NewLine
+                     + " got      : " + sig[0]);
+            }
+
+            if (!s.Equals(sig[1]))
+            {
+                Fail("s component wrong." + NewLine
+                     + " expecting: " + s + NewLine
+                     + " got      : " + sig[1]);
+            }
+
+            // Verify the signature
+            var pubKey = new ECPublicKeyParameters(
+                parameters.Curve.DecodePoint(
+                    Hex.Decode(
+                        "020145E221AB9F71C5FE740D8D2B94939A09E2816E2167A7D058125A06A80C014F553E8D6764B048FB6F2B687CEC72F39738F223D4CE6AFCBFF2E34774AA5D3C342CB3")),
+                // Q
+                parameters);
+
+            dsa.Init(false, pubKey);
+            if (!dsa.VerifySignature(m, sig[0], sig[1]))
+            {
+                Fail("signature fails");
+            }
+        }
+
+        [Test]
+        public void TestECDsaSecP224K1Sha256()
+        {
+            X9ECParameters p = SecNamedCurves.GetByName("secp224k1");
+            var parameters = new ECDomainParameters(p.Curve, p.G, p.N, p.H);
+            var priKey = new ECPrivateKeyParameters(
+                new BigInteger("BE6F6E91FE96840A6518B56F3FE21689903A64FA729057AB872A9F51", 16), // d
+                parameters);
+            SecureRandom k =
+                FixedSecureRandom.From(Hex.Decode("00c39beac93db21c3266084429eb9b846b787c094f23a4de66447efbb3"));
+
+            byte[] m = Hex.Decode("E5D5A7ADF73C5476FAEE93A2C76CE94DC0557DB04CDC189504779117920B896D");
+
+            var dsa = new ECDsaSigner();
+
+            dsa.Init(true, new ParametersWithRandom(priKey, k));
+
+            IBigInteger[] sig = dsa.GenerateSignature(m);
+
+            IBigInteger r = new BigInteger("8163E5941BED41DA441B33E653C632A55A110893133351E20CE7CB75", 16);
+            IBigInteger s = new BigInteger("D12C3FC289DDD5F6890DCE26B65792C8C50E68BF551D617D47DF15A8", 16);
+
+            if (!r.Equals(sig[0]))
+            {
+                Fail("r component wrong." + NewLine
+                     + " expecting: " + r + NewLine
+                     + " got      : " + sig[0]);
+            }
+
+            if (!s.Equals(sig[1]))
+            {
+                Fail("s component wrong." + NewLine
+                     + " expecting: " + s + NewLine
+                     + " got      : " + sig[1]);
+            }
+
+            // Verify the signature
+            var pubKey = new ECPublicKeyParameters(
+                parameters.Curve.DecodePoint(
+                    Hex.Decode(
+                        "04C5C9B38D3603FCCD6994CBB9594E152B658721E483669BB42728520F484B537647EC816E58A8284D3B89DFEDB173AFDC214ECA95A836FA7C")),
+                // Q
+                parameters);
+
+            dsa.Init(false, pubKey);
+            if (!dsa.VerifySignature(m, sig[0], sig[1]))
+            {
+                Fail("signature fails");
+            }
+        }
+
+        [Test]
+        public void TestECMqvRandom()
+        {
+            var random = new SecureRandom();
+
+            var curve = new FPCurve(
+                new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
+                new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
+                new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b
+
+            var parameters = new ECDomainParameters(
+                curve,
+                curve.DecodePoint(Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
+                new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n
+
+            var pGen = new ECKeyPairGenerator();
+
+            pGen.Init(new ECKeyGenerationParameters(parameters, random));
+
+
+            // Pre-established key pairs
+            IAsymmetricCipherKeyPair u1 = pGen.GenerateKeyPair();
+            IAsymmetricCipherKeyPair v1 = pGen.GenerateKeyPair();
+
+            // Ephemeral key pairs
+            IAsymmetricCipherKeyPair u2 = pGen.GenerateKeyPair();
+            IAsymmetricCipherKeyPair v2 = pGen.GenerateKeyPair();
+
+            IBigInteger x = CalculateAgreement(u1, u2, v1, v2);
+
+            if (x == null)
+            {
+                Fail("MQV Test Vector (random) agreement failed");
+            }
+        }
+
+        /**
 		 * General test for long digest.
 		 */
-		[Test]
-		public void TestECDsa239bitBinaryAndLargeDigest()
-		{
-			IBigInteger r = new BigInteger("21596333210419611985018340039034612628818151486841789642455876922391552");
-			IBigInteger s = new BigInteger("144940322424411242416373536877786566515839911620497068645600824084578597");
-
-			byte[] kData = BigIntegers.AsUnsignedByteArray(
-				new BigInteger("171278725565216523967285789236956265265265235675811949404040041670216363"));
-
-			SecureRandom k = FixedSecureRandom.From(kData);
-
-			F2MCurve curve = new F2MCurve(
-				239, // m
-				36, //k
-				new BigInteger("32010857077C5431123A46B808906756F543423E8D27877578125778AC76", 16), // a
-				new BigInteger("790408F2EEDAF392B012EDEFB3392F30F4327C0CA3F31FC383C422AA8C16", 16)); // b
-
-			ECDomainParameters parameters = new ECDomainParameters(
-				curve,
-				curve.DecodePoint(
-					Hex.Decode("0457927098FA932E7C0A96D3FD5B706EF7E5F5C156E16B7E7C86038552E91D61D8EE5077C33FECF6F1A16B268DE469C3C7744EA9A971649FC7A9616305")), // G
-				new BigInteger("220855883097298041197912187592864814557886993776713230936715041207411783"), // n
-				BigInteger.ValueOf(4)); // h
-
-			ECPrivateKeyParameters priKey = new ECPrivateKeyParameters(
-				"ECDSA",
-				new BigInteger("145642755521911534651321230007534120304391871461646461466464667494947990"), // d
-				parameters);
-
-			ECDsaSigner ecdsa = new ECDsaSigner();
-			ParametersWithRandom param = new ParametersWithRandom(priKey, k);
-
-			ecdsa.Init(true, param);
-
-			byte[] message = new BigInteger("968236873715988614170569073515315707566766479517968236873715988614170569073515315707566766479517968236873715988614170569073515315707566766479517").ToByteArray();
-			IBigInteger[] sig = ecdsa.GenerateSignature(message);
-
-			if (!r.Equals(sig[0]))
-			{
-				Fail("r component wrong." + SimpleTest.NewLine
-					+ " expecting: " + r + SimpleTest.NewLine
-					+ " got      : " + sig[0]);
-			}
-
-			if (!s.Equals(sig[1]))
-			{
-				Fail("s component wrong." + SimpleTest.NewLine
-					+ " expecting: " + s + SimpleTest.NewLine
-					+ " got      : " + sig[1]);
-			}
-
-			// Verify the signature
-			ECPublicKeyParameters pubKey = new ECPublicKeyParameters(
-				"ECDSA",
-				curve.DecodePoint(
-					Hex.Decode("045894609CCECF9A92533F630DE713A958E96C97CCB8F5ABB5A688A238DEED6DC2D9D0C94EBFB7D526BA6A61764175B99CB6011E2047F9F067293F57F5")), // Q
-				parameters);
-
-			ecdsa.Init(false, pubKey);
-			if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
-			{
-				Fail("signature fails");
-			}
-		}
-
-		/**
-		 * key generation test
-		 */
-		[Test]
-		public void TestECDsaKeyGenTest()
-		{
-			SecureRandom random = new SecureRandom();
-
-			FPCurve curve = new FPCurve(
-				new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
-				new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
-				new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b
-
-			ECDomainParameters parameters = new ECDomainParameters(
-				curve,
-				curve.DecodePoint(Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
-				new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n
-
-
-			ECKeyPairGenerator pGen = new ECKeyPairGenerator();
-			ECKeyGenerationParameters genParam = new ECKeyGenerationParameters(
-				parameters,
-				random);
-
-			pGen.Init(genParam);
-
-			IAsymmetricCipherKeyPair pair = pGen.GenerateKeyPair();
-
-			ParametersWithRandom param = new ParametersWithRandom(pair.Private, random);
-
-			ECDsaSigner ecdsa = new ECDsaSigner();
-
-			ecdsa.Init(true, param);
-
-			byte[] message = new BigInteger("968236873715988614170569073515315707566766479517").ToByteArray();
-			IBigInteger[] sig = ecdsa.GenerateSignature(message);
-
-			ecdsa.Init(false, pair.Public);
-
-			if (!ecdsa.VerifySignature(message, sig[0], sig[1]))
-			{
-				Fail("signature fails");
-			}
-		}
-
-		/**
-		 * Basic Key Agreement Test
-		 */
-		[Test]
-		public void TestECBasicAgreementTest()
-		{
-			SecureRandom random = new SecureRandom();
-
-			FPCurve curve = new FPCurve(
-				new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
-				new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
-				new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b
-
-			ECDomainParameters parameters = new ECDomainParameters(
-				curve,
-				curve.DecodePoint(Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
-				new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n
-
-
-			ECKeyPairGenerator pGen = new ECKeyPairGenerator();
-			ECKeyGenerationParameters genParam = new ECKeyGenerationParameters(parameters, random);
-
-			pGen.Init(genParam);
-
-			IAsymmetricCipherKeyPair p1 = pGen.GenerateKeyPair();
-			IAsymmetricCipherKeyPair p2 = pGen.GenerateKeyPair();
-
-			//
-			// two way
-			//
-			IBasicAgreement e1 = new EcdhBasicAgreement();
-			IBasicAgreement e2 = new EcdhBasicAgreement();
-
-			e1.Init(p1.Private);
-			e2.Init(p2.Private);
-
-			IBigInteger   k1 = e1.CalculateAgreement(p2.Public);
-			IBigInteger   k2 = e2.CalculateAgreement(p1.Public);
-
-			if (!k1.Equals(k2))
-			{
-				Fail("calculated agreement test failed");
-			}
-
-			//
-			// two way
-			//
-			e1 = new EcdhcBasicAgreement();
-			e2 = new EcdhcBasicAgreement();
-
-			e1.Init(p1.Private);
-			e2.Init(p2.Private);
-
-			k1 = e1.CalculateAgreement(p2.Public);
-			k2 = e2.CalculateAgreement(p1.Public);
-
-			if (!k1.Equals(k2))
-			{
-				Fail("calculated agreement test failed");
-			}
-		}
-
-		[Test]
-		public void TestECMqvTestVector1()
-		{
-			// Test Vector from GEC-2
-
-			X9ECParameters x9 = SecNamedCurves.GetByName("secp160r1");
-			ECDomainParameters p = new ECDomainParameters(
-				x9.Curve, x9.G, x9.N, x9.H, x9.GetSeed());
-
-			IAsymmetricCipherKeyPair U1 = new AsymmetricCipherKeyPair(
-				new ECPublicKeyParameters(
-					p.Curve.DecodePoint(Hex.Decode("0251B4496FECC406ED0E75A24A3C03206251419DC0")), p),
-				new ECPrivateKeyParameters(
-					new BigInteger("AA374FFC3CE144E6B073307972CB6D57B2A4E982", 16), p));
-
-			IAsymmetricCipherKeyPair U2 = new AsymmetricCipherKeyPair(
-				new ECPublicKeyParameters(
-					p.Curve.DecodePoint(Hex.Decode("03D99CE4D8BF52FA20BD21A962C6556B0F71F4CA1F")), p),
-				new ECPrivateKeyParameters(
-					new BigInteger("149EC7EA3A220A887619B3F9E5B4CA51C7D1779C", 16), p));
-
-			IAsymmetricCipherKeyPair V1 = new AsymmetricCipherKeyPair(
-				new ECPublicKeyParameters(
-					p.Curve.DecodePoint(Hex.Decode("0349B41E0E9C0369C2328739D90F63D56707C6E5BC")), p),
-				new ECPrivateKeyParameters(
-					new BigInteger("45FB58A92A17AD4B15101C66E74F277E2B460866", 16), p));
-
-			IAsymmetricCipherKeyPair V2 = new AsymmetricCipherKeyPair(
-				new ECPublicKeyParameters(
-					p.Curve.DecodePoint(Hex.Decode("02706E5D6E1F640C6E9C804E75DBC14521B1E5F3B5")), p),
-				new ECPrivateKeyParameters(
-					new BigInteger("18C13FCED9EADF884F7C595C8CB565DEFD0CB41E", 16), p));
-
-			IBigInteger x = calculateAgreement(U1, U2, V1, V2);
-
-			if (x == null
-				|| !x.Equals(new BigInteger("5A6955CEFDB4E43255FB7FCF718611E4DF8E05AC", 16)))
-			{
-				Fail("MQV Test Vector #1 agreement failed");
-			}
-		}
-
-		[Test]
-		public void TestECMqvTestVector2()
-		{
-			// Test Vector from GEC-2
-
-			X9ECParameters x9 = SecNamedCurves.GetByName("sect163k1");
-			ECDomainParameters p = new ECDomainParameters(
-				x9.Curve, x9.G, x9.N, x9.H, x9.GetSeed());
-
-			IAsymmetricCipherKeyPair U1 = new AsymmetricCipherKeyPair(
-				new ECPublicKeyParameters(
-					p.Curve.DecodePoint(Hex.Decode("03037D529FA37E42195F10111127FFB2BB38644806BC")), p),
-				new ECPrivateKeyParameters(
-					new BigInteger("03A41434AA99C2EF40C8495B2ED9739CB2155A1E0D", 16), p));
-
-			IAsymmetricCipherKeyPair U2 = new AsymmetricCipherKeyPair(
-				new ECPublicKeyParameters(
-					p.Curve.DecodePoint(Hex.Decode("02015198E74BC2F1E5C9A62B80248DF0D62B9ADF8429")), p),
-				new ECPrivateKeyParameters(
-					new BigInteger("032FC4C61A8211E6A7C4B8B0C03CF35F7CF20DBD52", 16), p));
-
-			IAsymmetricCipherKeyPair V1 = new AsymmetricCipherKeyPair(
-				new ECPublicKeyParameters(
-					p.Curve.DecodePoint(Hex.Decode("03072783FAAB9549002B4F13140B88132D1C75B3886C")), p),
-				new ECPrivateKeyParameters(
-					new BigInteger("57E8A78E842BF4ACD5C315AA0569DB1703541D96", 16), p));
-
-			IAsymmetricCipherKeyPair V2 = new AsymmetricCipherKeyPair(
-				new ECPublicKeyParameters(
-					p.Curve.DecodePoint(Hex.Decode("03067E3AEA3510D69E8EDD19CB2A703DDC6CF5E56E32")), p),
-				new ECPrivateKeyParameters(
-					new BigInteger("02BD198B83A667A8D908EA1E6F90FD5C6D695DE94F", 16), p));
-
-			IBigInteger x = calculateAgreement(U1, U2, V1, V2);
-
-			if (x == null
-				|| !x.Equals(new BigInteger("038359FFD30C0D5FC1E6154F483B73D43E5CF2B503", 16)))
-			{
-				Fail("MQV Test Vector #2 agreement failed");
-			}
-		}
-
-		[Test]
-		public void TestECMqvRandom()
-		{
-			SecureRandom random = new SecureRandom();
-
-			FPCurve curve = new FPCurve(
-				new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
-				new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
-				new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b
-
-			ECDomainParameters parameters = new ECDomainParameters(
-				curve,
-				curve.DecodePoint(Hex.Decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
-				new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n
-
-			ECKeyPairGenerator pGen = new ECKeyPairGenerator();
-
-			pGen.Init(new ECKeyGenerationParameters(parameters, random));
-
-
-			// Pre-established key pairs
-			IAsymmetricCipherKeyPair U1 = pGen.GenerateKeyPair();
-			IAsymmetricCipherKeyPair V1 = pGen.GenerateKeyPair();
-
-			// Ephemeral key pairs
-			IAsymmetricCipherKeyPair U2 = pGen.GenerateKeyPair();
-			IAsymmetricCipherKeyPair V2 = pGen.GenerateKeyPair();
-
-			IBigInteger x = calculateAgreement(U1, U2, V1, V2);
-
-			if (x == null)
-			{
-				Fail("MQV Test Vector (random) agreement failed");
-			}
-		}
-
-		private static IBigInteger calculateAgreement(
-			IAsymmetricCipherKeyPair U1,
-			IAsymmetricCipherKeyPair U2,
-			IAsymmetricCipherKeyPair V1,
-			IAsymmetricCipherKeyPair V2)
-		{
-			ECMqvBasicAgreement u = new ECMqvBasicAgreement();
-			u.Init(new MqvPrivateParameters(
-				(ECPrivateKeyParameters)U1.Private,
-				(ECPrivateKeyParameters)U2.Private,
-				(ECPublicKeyParameters)U2.Public));
-			IBigInteger ux = u.CalculateAgreement(new MqvPublicParameters(
-				(ECPublicKeyParameters)V1.Public,
-				(ECPublicKeyParameters)V2.Public));
-
-			ECMqvBasicAgreement v = new ECMqvBasicAgreement();
-			v.Init(new MqvPrivateParameters(
-				(ECPrivateKeyParameters)V1.Private,
-				(ECPrivateKeyParameters)V2.Private,
-				(ECPublicKeyParameters)V2.Public));
-			IBigInteger vx = v.CalculateAgreement(new MqvPublicParameters(
-				(ECPublicKeyParameters)U1.Public,
-				(ECPublicKeyParameters)U2.Public));
-
-			if (ux.Equals(vx))
-				return ux;
-
-			return null;
-		}
-
-		public override string Name
-		{
-			get { return "EC"; }
-		}
-
-		public override void PerformTest()
-		{
-			TestDecode();
-			TestECDsa192bitPrime();
-			TestECDsa239bitPrime();
-			TestECDsa191bitBinary();
-			TestECDsa239bitBinary();
-			TestECDsaKeyGenTest();
-			TestECBasicAgreementTest();
-
-			TestECDsaP224Sha224();
-			TestECDsaP224OneByteOver();
-			TestECDsaP256Sha256();
-			TestECDsaP521Sha512();
-			TestECDsaSecP224k1Sha256();
-			TestECDsa239bitBinaryAndLargeDigest();
-
-			TestECMqvTestVector1();
-			TestECMqvTestVector2();
-			TestECMqvRandom();
-		}
-
-		public static void Main(
-			string[] args)
-		{
-			RunTest(new ECTest());
-		}
-	}
-}
+
+        [Test]
+        public void TestECMqvTestVector1()
+        {
+            // Test Vector from GEC-2
+
+            X9ECParameters x9 = SecNamedCurves.GetByName("secp160r1");
+            var p = new ECDomainParameters(
+                x9.Curve, x9.G, x9.N, x9.H, x9.GetSeed());
+
+            IAsymmetricCipherKeyPair u1 = new AsymmetricCipherKeyPair(
+                new ECPublicKeyParameters(
+                    p.Curve.DecodePoint(Hex.Decode("0251B4496FECC406ED0E75A24A3C03206251419DC0")), p),
+                new ECPrivateKeyParameters(
+                    new BigInteger("AA374FFC3CE144E6B073307972CB6D57B2A4E982", 16), p));
+
+            IAsymmetricCipherKeyPair u2 = new AsymmetricCipherKeyPair(
+                new ECPublicKeyParameters(
+                    p.Curve.DecodePoint(Hex.Decode("03D99CE4D8BF52FA20BD21A962C6556B0F71F4CA1F")), p),
+                new ECPrivateKeyParameters(
+                    new BigInteger("149EC7EA3A220A887619B3F9E5B4CA51C7D1779C", 16), p));
+
+            IAsymmetricCipherKeyPair v1 = new AsymmetricCipherKeyPair(
+                new ECPublicKeyParameters(
+                    p.Curve.DecodePoint(Hex.Decode("0349B41E0E9C0369C2328739D90F63D56707C6E5BC")), p),
+                new ECPrivateKeyParameters(
+                    new BigInteger("45FB58A92A17AD4B15101C66E74F277E2B460866", 16), p));
+
+            IAsymmetricCipherKeyPair v2 = new AsymmetricCipherKeyPair(
+                new ECPublicKeyParameters(
+                    p.Curve.DecodePoint(Hex.Decode("02706E5D6E1F640C6E9C804E75DBC14521B1E5F3B5")), p),
+                new ECPrivateKeyParameters(
+                    new BigInteger("18C13FCED9EADF884F7C595C8CB565DEFD0CB41E", 16), p));
+
+            IBigInteger x = CalculateAgreement(u1, u2, v1, v2);
+
+            if (x == null
+                || !x.Equals(new BigInteger("5A6955CEFDB4E43255FB7FCF718611E4DF8E05AC", 16)))
+            {
+                Fail("MQV Test Vector #1 agreement failed");
+            }
+        }
+
+        [Test]
+        public void TestECMqvTestVector2()
+        {
+            // Test Vector from GEC-2
+
+            X9ECParameters x9 = SecNamedCurves.GetByName("sect163k1");
+            var p = new ECDomainParameters(
+                x9.Curve, x9.G, x9.N, x9.H, x9.GetSeed());
+
+            IAsymmetricCipherKeyPair u1 = new AsymmetricCipherKeyPair(
+                new ECPublicKeyParameters(
+                    p.Curve.DecodePoint(Hex.Decode("03037D529FA37E42195F10111127FFB2BB38644806BC")), p),
+                new ECPrivateKeyParameters(
+                    new BigInteger("03A41434AA99C2EF40C8495B2ED9739CB2155A1E0D", 16), p));
+
+            IAsymmetricCipherKeyPair u2 = new AsymmetricCipherKeyPair(
+                new ECPublicKeyParameters(
+                    p.Curve.DecodePoint(Hex.Decode("02015198E74BC2F1E5C9A62B80248DF0D62B9ADF8429")), p),
+                new ECPrivateKeyParameters(
+                    new BigInteger("032FC4C61A8211E6A7C4B8B0C03CF35F7CF20DBD52", 16), p));
+
+            IAsymmetricCipherKeyPair v1 = new AsymmetricCipherKeyPair(
+                new ECPublicKeyParameters(
+                    p.Curve.DecodePoint(Hex.Decode("03072783FAAB9549002B4F13140B88132D1C75B3886C")), p),
+                new ECPrivateKeyParameters(
+                    new BigInteger("57E8A78E842BF4ACD5C315AA0569DB1703541D96", 16), p));
+
+            IAsymmetricCipherKeyPair v2 = new AsymmetricCipherKeyPair(
+                new ECPublicKeyParameters(
+                    p.Curve.DecodePoint(Hex.Decode("03067E3AEA3510D69E8EDD19CB2A703DDC6CF5E56E32")), p),
+                new ECPrivateKeyParameters(
+                    new BigInteger("02BD198B83A667A8D908EA1E6F90FD5C6D695DE94F", 16), p));
+
+            IBigInteger x = CalculateAgreement(u1, u2, v1, v2);
+
+            if (x == null
+                || !x.Equals(new BigInteger("038359FFD30C0D5FC1E6154F483B73D43E5CF2B503", 16)))
+            {
+                Fail("MQV Test Vector #2 agreement failed");
+            }
+        }
+    }
+}


CI fixes

CI fixes

--- osu.Framework/Graphics/Containers/ModelBackedDrawable.cs
+++ osu.Framework/Graphics/Containers/ModelBackedDrawable.cs
@@ -110,7 +110,7 @@
             if (hidingSource != null)
                 hideTransform = HideDrawable(hidingSource);

-            (showTransform ?? hideTransform)?.OnComplete((d) => source?.Expire());
+            (showTransform ?? hideTransform)?.OnComplete(d => source?.Expire());
         }

         private void updateDrawable()


Remove unused constants

Remove unused constants

--- osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
+++ osu.Game.Tournament/Components/TournamentBeatmapPanel.cs
@@ -23,9 +23,6 @@
         public readonly APIBeatmap Beatmap;

         private readonly string mod;
-
-        private const float horizontal_padding = 10;
-        private const float vertical_padding = 10;

         public const float HEIGHT = 50;


Fix state never getting set.

Fix state never getting set.

--- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs
+++ osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs
@@ -124,6 +124,18 @@

             judgements.Add(judgement);

+            switch (judgement.Result)
+            {
+                case HitResult.None:
+                    break;
+                case HitResult.Miss:
+                    State = ArmedState.Miss;
+                    break;
+                default:
+                    State = ArmedState.Hit;
+                    break;
+            }
+
             OnJudgement?.Invoke(this, judgement);
         }


Remove PrinterChanged event listener from printer

- Reload on Settings on Settings changed setter
- Invalidate BedMesh in RecreateBed method

--- ApplicationView/PrinterModels.cs
+++ ApplicationView/PrinterModels.cs
@@ -132,7 +132,7 @@

 		public WorldView World { get; } = new WorldView(0, 0);

-		public double BuildHeight { get; internal set; }
+		public double BuildHeight  { get; internal set; }
 		public Vector3 ViewerVolume { get; internal set; }
 		public Vector2 BedCenter { get; internal set; }
 		public BedShape BedShape { get; internal set; }
@@ -309,10 +309,8 @@

 		public void RecreateBed()
 		{
-			if (bedGenerator != null)
-			{
-				_bedMesh = bedGenerator.CreatePrintBed(Printer);
-			}
+			// Invalidate bed mesh
+			_bedMesh = null;
 		}
 	}

@@ -358,30 +356,37 @@
 	{
 		public BedConfig Bed { get; }
 		public PrinterViewState ViewState { get; } = new PrinterViewState();
-		public PrinterSettings Settings { get; private set; }
+
+		private PrinterSettings _settings;
+		public PrinterSettings Settings
+		{
+			get => _settings;
+			private set
+			{
+				if (_settings != value)
+				{
+					_settings = value;
+					this.ReloadSettings();
+					this.Bed.RecreateBed();
+				}
+			}
+		}
+
 		public PrinterConnection Connection { get; private set; }

 		private EventHandler unregisterEvents;

-		public PrinterConfig(bool loadLastBedplate, PrinterSettings settings = null)
-		{
-			this.Connection = new PrinterConnection();
-			this.Settings = settings ?? ActiveSliceSettings.Instance;
+		public PrinterConfig(bool loadLastBedplate, PrinterSettings settings)
+		{
+			this.Bed = new BedConfig(this, loadLastBedplate);
+
+			this.Settings = settings;
 			this.Settings.printer = this;
-			this.Connection.printer = this;
-
-			this.Bed = new BedConfig(this, loadLastBedplate);
+
+			this.Connection = new PrinterConnection(printer: this);
+

 			ActiveSliceSettings.SettingChanged.RegisterEvent(Printer_SettingChanged, ref unregisterEvents);
-
-			ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) =>
-			{
-				this.Settings = ActiveSliceSettings.Instance;
-				this.Settings.printer = this;
-
-				this.ReloadSettings();
-				this.Bed.RecreateBed();
-			}, ref unregisterEvents);
 		}

 		private void ReloadSettings()


Changed installer logic. If the installer succeeds or fails, it should still cleanup. If the install task failed (isFaulted), then it won't set the progress from Cleanup().

--- RelhaxModpack/RelhaxModpack/InstallerComponents/InstallEngine.cs
+++ RelhaxModpack/RelhaxModpack/InstallerComponents/InstallEngine.cs
@@ -346,6 +346,48 @@
                 //check for cancellation
                 CheckForCancel();

+                //step 13: cleanup
+                OldTime = InstallStopWatch.Elapsed;
+
+                //only update the task status for cleanup if the task is not faulted
+                if (!taskk.IsFaulted)
+                {
+                    Prog.TotalCurrent++;
+                    InstallFinishedArgs.ExitCode = InstallerExitCodes.CleanupError;
+                    Prog.InstallStatus = InstallerExitCodes.CleanupError;
+                    Progress.Report(Prog);
+                }
+
+                //but we still want to always cleanup
+                Logging.Info(string.Format("Cleanup, current install time = {0} msec", (int)InstallStopWatch.Elapsed.TotalMilliseconds));
+                if (!ModpackSettings.ExportMode)
+                {
+                    if (Cleanup())
+                    {
+                        Logging.Info("Cleanup complete, took {0} msec", (int)(InstallStopWatch.Elapsed.TotalMilliseconds - OldTime.TotalMilliseconds));
+                        if (!taskk.IsFaulted)
+                        {
+                            Prog.TotalCurrent++;
+                            InstallFinishedArgs.ExitCode = InstallerExitCodes.Success;
+                            Prog.InstallStatus = InstallerExitCodes.Success;
+                            Progress.Report(Prog);
+                        }
+                    }
+                    else
+                    {
+                        Logging.Info("Cleanup failed, took {0} msec", (int)(InstallStopWatch.Elapsed.TotalMilliseconds - OldTime.TotalMilliseconds));
+                        if (!taskk.IsFaulted)
+                        {
+                            Prog.TotalCurrent++;
+                            InstallFinishedArgs.ExitCode = InstallerExitCodes.CleanupError;
+                            Prog.InstallStatus = InstallerExitCodes.CleanupError;
+                            Progress.Report(Prog);
+                        }
+                    }
+                }
+                else
+                    Logging.Info("...skipped (ModpackSettings.ExportMode = true)");
+
                 //stop the log file if it was started
                 if (Logging.IsLogOpen(Logfiles.Installer))
                     Logging.DisposeLogging(Logfiles.Installer);
@@ -793,25 +835,6 @@
             }
             else
                 Logging.Info("...skipped (ModpackSettings.DeleteCacheFiles = false)");
-
-
-            //step 13: cleanup
-            OldTime = InstallStopWatch.Elapsed;
-            Prog.TotalCurrent++;
-            InstallFinishedArgs.ExitCode = InstallerExitCodes.CleanupError;
-            Prog.InstallStatus = InstallerExitCodes.CleanupError;
-            Progress.Report(Prog);
-
-            Logging.Info(string.Format("Cleanup, current install time = {0} msec", (int)InstallStopWatch.Elapsed.TotalMilliseconds));
-            if(!ModpackSettings.ExportMode)
-            {
-                if (!Cleanup())
-                    return InstallFinishedArgs;
-                Logging.Info("Cleanup complete, took {0} msec", (int)(InstallStopWatch.Elapsed.TotalMilliseconds - OldTime.TotalMilliseconds));
-            }
-            else
-                Logging.Info("...skipped (ModpackSettings.ExportMode = true)");
-

             if (!DisableTriggersForInstall)
             {


add some fail and inconclusive for better report

--- ReportUnit/TestReports/Reports.Import.Tests/ExcelImporterTest.cs
+++ ReportUnit/TestReports/Reports.Import.Tests/ExcelImporterTest.cs
@@ -9,21 +9,26 @@
         [TestMethod]
         public void Import_non_existing_file_throws_exception()
         {
+            Assert.Fail("Exception missing");
         }

         [TestMethod]
         public void Import_empty_file_throws_exception()
         {
+            Assert.Fail("Exception missing");
         }

         [TestMethod]
+        [Ignore]
         public void Import_file_wit_single_record_returns_1_row()
         {
+            Assert.Inconclusive("pending");
         }

         [TestMethod]
         public void Import_file_wit_multiple_record_returns_all_rows()
         {
+            Assert.Inconclusive("pending");
         }
     }
 }


Added deletion guard for temporary file

Added deletion guard for temporary file

--- src/Squirrel/DeltaPackage.cs
+++ src/Squirrel/DeltaPackage.cs
@@ -187,38 +187,40 @@
             var finalTarget = Path.Combine(workingDirectory, Regex.Replace(relativeFilePath, @".diff$", ""));

             var tempTargetFile = Path.GetTempFileName();
-
-            // NB: Zero-length diffs indicate the file hasn't actually changed
-            if (new FileInfo(inputFile).Length == 0) {
-                this.Log().Info("{0} exists unchanged, skipping", relativeFilePath);
-                return;
-            }
-
-            if (relativeFilePath.EndsWith(".diff", StringComparison.InvariantCultureIgnoreCase)) {
-                this.Log().Info("Applying Diff to {0}", relativeFilePath);
-                var msDelta = new MsDeltaCompression();
-                msDelta.ApplyDelta(inputFile, finalTarget, tempTargetFile);
-
-                try {
+            try
+            {
+                // NB: Zero-length diffs indicate the file hasn't actually changed
+                if (new FileInfo(inputFile).Length == 0) {
+                    this.Log().Info("{0} exists unchanged, skipping", relativeFilePath);
+                    return;
+                }
+
+                if (relativeFilePath.EndsWith(".diff", StringComparison.InvariantCultureIgnoreCase)) {
+                    this.Log().Info("Applying Diff to {0}", relativeFilePath);
+                    var msDelta = new MsDeltaCompression();
+                    msDelta.ApplyDelta(inputFile, finalTarget, tempTargetFile);
+
                     verifyPatchedFile(relativeFilePath, inputFile, tempTargetFile);
-                } catch (Exception) {
-                    File.Delete(tempTargetFile);
-                    throw;
-                }
-            } else {
-                using (var of = File.OpenWrite(tempTargetFile))
-                using (var inf = File.OpenRead(inputFile)) {
-                    this.Log().Info("Adding new file: {0}", relativeFilePath);
-                    inf.CopyTo(of);
-                }
-            }
-
-            if (File.Exists(finalTarget)) File.Delete(finalTarget);
-
-            var targetPath = Directory.GetParent(finalTarget);
-            if (!targetPath.Exists) targetPath.Create();
-
-            File.Move(tempTargetFile, finalTarget);
+
+                } else {
+                    using (var of = File.OpenWrite(tempTargetFile))
+                    using (var inf = File.OpenRead(inputFile)) {
+                        this.Log().Info("Adding new file: {0}", relativeFilePath);
+                        inf.CopyTo(of);
+                    }
+                }
+
+                if (File.Exists(finalTarget)) File.Delete(finalTarget);
+
+                var targetPath = Directory.GetParent(finalTarget);
+                if (!targetPath.Exists) targetPath.Create();
+
+                File.Move(tempTargetFile, finalTarget);
+            }
+            finally
+            {
+                File.Delete(tempTargetFile);
+            }
         }

         void verifyPatchedFile(string relativeFilePath, string inputFile, string tempTargetFile)


Add more IetfLanguageTagHelperTests (part 2)

Moved some ListLabel tests to WritingSystemDefinitionPropertyTests

--- SIL.WritingSystems.Tests/WritingSystemDefinitionPropertyTests.cs
+++ SIL.WritingSystems.Tests/WritingSystemDefinitionPropertyTests.cs
@@ -5,7 +5,6 @@
 using System.Reflection;
 using NUnit.Framework;
 using Palaso.TestUtilities;
-using SIL.Data;
 using SIL.Keyboarding;

 namespace SIL.WritingSystems.Tests
@@ -1484,6 +1483,7 @@
 			Assert.That(ws.GetDefaultFontSizeOrMinimum(), Is.GreaterThan(6));
 		}

+		#region ListLabel
 		[Test]
 		public void ListLabel_ScriptRegionVariantEmpty_LabelIsLanguage()
 		{
@@ -1497,7 +1497,6 @@
 			var ws = new WritingSystemDefinition("de") {Script = "Armi"};
 			Assert.That(ws.ListLabel, Is.EqualTo("German (Armi)"));
 		}
-

 		[Test]
 		public void ListLabel_RegionSet_LabelIsLanguageWithRegionInBrackets()
@@ -1567,6 +1566,43 @@
 			ws.Variants.Add("garble");
 			Assert.That(ws.ListLabel, Is.EqualTo("German (x-garble)"));
 		}
+
+		[Test]
+		public void ListLabel_VariantContainsDuplwithNumber_LabelIsLanguageWithCopyAndNumberInBrackets()
+		{
+			var ws = new WritingSystemDefinition("de");
+			ws.IetfLanguageTag = IetfLanguageTagHelper.ToUniqueIetfLanguageTag(ws.IetfLanguageTag, new[] { "de", "de-x-dupl0" });
+			Assert.That(ws.ListLabel, Is.EqualTo("German (Copy1)"));
+		}
+
+		[Test]
+		public void ListLabel_VariantContainsDuplwithZero_LabelIsLanguageWithCopyAndNoNumberInBrackets()
+		{
+			var ws = new WritingSystemDefinition("de");
+			ws.IetfLanguageTag = IetfLanguageTagHelper.ToUniqueIetfLanguageTag(ws.IetfLanguageTag, new[] { "de" });
+			Assert.That(ws.ListLabel, Is.EqualTo("German (Copy)"));
+		}
+
+		[Test]
+		public void ListLabel_VariantContainsmulitpleDuplswithNumber_LabelIsLanguageWithCopyAndNumbersInBrackets()
+		{
+			var ws = new WritingSystemDefinition("de-x-dupl0");
+			ws.IetfLanguageTag = IetfLanguageTagHelper.ToUniqueIetfLanguageTag(ws.IetfLanguageTag, new[] { "de", "de-x-dupl0" });
+			Assert.That(ws.ListLabel, Is.EqualTo("German (Copy-Copy1)"));
+		}
+
+		[Test]
+		public void ListLabel_AllSortsOfThingsSet_LabelIsCorrect()
+		{
+			var ws = new WritingSystemDefinition("de-x-dupl0");
+			ws.IetfLanguageTag = IetfLanguageTagHelper.ToUniqueIetfLanguageTag(ws.IetfLanguageTag, new[] { "de", "de-x-dupl0" });
+			ws.Region = "US";
+			ws.Script = "Armi";
+			ws.IpaStatus = IpaStatusChoices.IpaPhonetic;
+			ws.Variants.AddRange(new VariantSubtag[] { "garble", "1901" });
+			Assert.That(ws.ListLabel, Is.EqualTo("German (IPA-etic-Copy-Copy1-Armi-US-1901-x-garble)"));
+		}
+		#endregion

 		[Test]
 		public void OtherAvailableKeyboards_DefaultsToAllAvailable()
@@ -1702,9 +1738,9 @@
 			ws.Fonts.Add(fd1);
 			ws.Fonts.Add(fd2);
 			ws.DefaultFont = fd1;
-			var newFD2 = new FontDefinition("font2");
-			ws.DefaultFont = newFD2;
-			Assert.That(ws.Fonts[1], Is.EqualTo(newFD2));
+			var newFd2 = new FontDefinition("font2");
+			ws.DefaultFont = newFd2;
+			Assert.That(ws.Fonts[1], Is.EqualTo(newFd2));
 		}

 		[Test]
@@ -1749,9 +1785,9 @@
 			ws.Collations.Add(cd2);
 			ws.DefaultCollation = cd2;

-			var newCD2 = new IcuCollationDefinition("standard");
-			ws.DefaultCollation = newCD2;
-			Assert.That(ws.Collations[1], Is.EqualTo(newCD2));
+			var newCd2 = new IcuCollationDefinition("standard");
+			ws.DefaultCollation = newCd2;
+			Assert.That(ws.Collations[1], Is.EqualTo(newCd2));
 		}

 		private void VerifySubtagCodes(WritingSystemDefinition ws, string langCode, string scriptCode, string regionCode, string variantCode, string id)


added content_access enum constant for admin events (#469)

--- Box.V2/Config/Constants.cs
+++ Box.V2/Config/Constants.cs
@@ -850,6 +850,11 @@
             /// An OAuth2 access token was generated for a user.
             /// </summary>
             public const string UserAuthenticateOAuth2AccessTokenCreate = "USER_AUTHENTICATE_OAUTH2_ACCESS_TOKEN_CREATE";
+
+            /// <summary>
+            /// A content was accessed by a user.
+            /// </summary>
+            public const string ContentAccess = "CONTENT_ACCESS";
         }

         /*** required direction for collaboration whitelists endpoint. Can only be one of value: inbound, outbound, or both ***/


Added to bug list.

Added to bug list.

--- Assets/Scripts/GameController.cs
+++ Assets/Scripts/GameController.cs
@@ -13,6 +13,7 @@
 // Bug** can keep game going after Game Over by pressing pause continually
 // Bug** on occasion after several finalised collision groups there might be a gap of a jewel - the model is saying there is still something there
 // Bug** game over text didn't stretch as expected on Mac OSX build
+// Bug** sound sources are not mixing, for instance only hearing the level up noise when it continually goes up

 /// <summary>
 /// Game controller manages the major components


Fixed issue where play button showed if player went back to level select and selected new level.

--- Assets/Scripts/InterstitialUI.cs
+++ Assets/Scripts/InterstitialUI.cs
@@ -31,6 +31,8 @@

 		_nextButton = transform.Find("NextButton").gameObject.GetComponent<Button>();
 		_playButton = transform.Find("PlayButton").gameObject.GetComponent<Button>();
+		_nextButton.gameObject.SetActive(true);
+		_playButton.gameObject.SetActive(false);

 		switch (GameConfig.CurrentChapter)
 		{


made hunger meter decrease faster

made hunger meter decrease faster

--- Assets/Scripts/UI/HungerMeter.cs
+++ Assets/Scripts/UI/HungerMeter.cs
@@ -8,6 +8,7 @@
 public class HungerMeter : MonoBehaviour
 {
 	[SerializeField] private Image hungerBar;
+	[SerializeField] private float percentDecreaseTime = 0.4f;
 	private float hungerPercent = 100;
 	private bool refill = true;
 	private bool death = false;
@@ -59,7 +60,7 @@
 		UpdateUIArt();
 		if (hungerPercent >= 0  && !death)
 		{
-			Invoke ("DecreaseHunger", .7f);
+			Invoke ("DecreaseHunger", percentDecreaseTime);
 		}
 		else
 		{


Kan nu op alle 2 kanten vanmde muren springen, met doublejump erin!

Ä£.≥¼

--- Assets/Scripts/playerMovement.cs
+++ Assets/Scripts/playerMovement.cs
@@ -16,7 +16,9 @@
     private bool speedUpR = false;
     private bool speedUpL = false;
     private bool hitRechter;
-    private bool wall;
+    private bool hitLinker;
+    private bool wallR;
+    private bool wallL;
     private bool canDoubleJump = false;
     private float hitTimer = 2f;
     public GameObject target;
@@ -57,27 +59,27 @@
         {
             hitTimer -= Time.deltaTime;
         }
-        if(hitTimer < 0)
+        if (hitTimer < 0)
         {
             hitRechter = false;
             hitTimer = 2f;
         }
         if (Ground)
-        {
+        {
             maxSpeedL = -10f;
             maxSpeedR = 10f;
             _rigidbody.gravityScale = 1;
-                if (Input.GetKeyDown("up"))
-                {
-                    timerCheck = true;
-                    _rigidbody.AddForce(transform.up * jumpHeight);
-                    Ground = false;
-                }
+            if (Input.GetKeyDown("up"))
+            {
+                timerCheck = true;
+                _rigidbody.AddForce(transform.up * jumpHeight);
+                Ground = false;
+            }
         }
         if (!Ground)
         {
-            maxSpeedL = -6f;
-            maxSpeedR = 6f;
+            maxSpeedL = -8f;
+            maxSpeedR = 8f;
         }
         Debug.Log(timer);
         if (timerCheck)
@@ -91,14 +93,15 @@
             timer = 0.75f;
         }

-        Debug.Log(wall + "muur");
-        Debug.Log(speedUpR +"cancer");
+        Debug.Log(wallR + "muur");
+        Debug.Log(wallL + "wow");
+        Debug.Log(speedUpR + "cancer");

         //transform.position += Vector3.right * speedR * Time.deltaTime;
-        transform.position += Vector3.right * speedL * Time.deltaTime;
-        if (!wall)
+        //transform.position += Vector3.right * speedL * Time.deltaTime;
+        if (!wallR)
         {
             transform.position += Vector3.right * speedR * Time.deltaTime;
             if (Input.GetKeyDown("right"))
@@ -112,12 +115,12 @@
                 speedUpR = false;
             }

-            if (speedUpR == true && speedR < maxSpeedR && !wall)
+            if (speedUpR == true && speedR < maxSpeedR && !wallR)
             {
                 speedR += 0.5f;
             }

-            if (speedUpR == false && speedR > 0 && !wall)
+            if (speedUpR == false && speedR > 0 && !wallR)
             {
                 speedR -= 0.5f;
             }
@@ -126,26 +129,34 @@
         {
             speedUpR = false;
         }
-
-        if (Input.GetKeyDown("left"))
+        if (!wallL)
         {
-            speedUpL = true;
-            Debug.Log(speedUpL);
+            transform.position += Vector3.right * speedL * Time.deltaTime;
+            if (Input.GetKeyDown("left"))
+            {
+                speedUpL = true;
+                Debug.Log(speedUpL);
+            }
+            else if (Input.GetKeyUp("left"))
+            {
+                speedUpL = false;
+                Debug.Log(speedUpL);
+            }
+            if (speedUpL == true && speedL > maxSpeedL)
+            {
+                speedL -= 0.5f;
+            }
+            if (speedUpL == false && speedL < 0)
+            {
+                speedL += 0.5f;
+            }
         }
-        else if (Input.GetKeyUp("left"))
+
+        if (Input.GetKeyUp("left"))
         {
             speedUpL = false;
             Debug.Log(speedUpL);
         }
-        if (speedUpL == true && speedL > maxSpeedL)
-        {
-            speedL -= 0.5f;
-        }
-        if (speedUpL == false && speedL < 0)
-        {
-            speedL += 0.5f;
-        }
-
     }
     void OnCollisionEnter2D(Collision2D other)
     {
@@ -156,15 +167,25 @@
         if (other.gameObject.CompareTag("RechterMuur"))
         {
             hitRechter = true;
-            transform.parent = target.transform;
-            wall = true;
+            wallR = true;
+            canDoubleJump = true;
+        }
+        if (other.gameObject.CompareTag("LinkerMuur"))
+        {
+            hitLinker = true;
+            wallL = true;
+            canDoubleJump = true;
         }
     }
     void OnCollisionExit2D(Collision2D other)
     {
         if (other.gameObject.CompareTag("RechterMuur"))
         {
-            wall = false;
+            wallR = false;
+        }
+        if (other.gameObject.CompareTag("LinkerMuur"))
+        {
+            wallL = false;
         }
     }
 }


fix ref valuetype

fix ref valuetype

--- Assets/Slua/Editor/LuaCodeGen.cs
+++ Assets/Slua/Editor/LuaCodeGen.cs
@@ -1192,7 +1192,7 @@
 				Write(file, "checkEnum(l,{2}{0},out {1});", n, v, nprefix);
 			else if (t.BaseType == typeof(System.MulticastDelegate))
 				Write(file, "int op=LuaDelegation.checkDelegate(l,{2}{0},out {1});", n, v, nprefix);
-			else if (t.BaseType==typeof(ValueType) && !IsBaseType(t))
+			else if (IsValueType(t))
 				Write(file, "checkValueType(l,{2}{0},out {1});", n, v, nprefix);
 			else
 				Write(file, "checkType(l,{2}{0},out {1});", n, v, nprefix);
@@ -1727,11 +1727,16 @@
 				else if (t.IsByRef && t.GetElementType().IsValueType && !IsBaseType(t.GetElementType())){
 					Write(file, "checkValueType(l,{0},out a{1});", n + argstart, n + 1);
 				}
-				else if (t.BaseType==typeof(ValueType) && !IsBaseType(t))
+				else if (IsValueType(t))
 					Write(file, "checkValueType(l,{0},out a{1});", n + argstart, n + 1);
 				else
 					Write(file, "checkType(l,{0},out a{1});", n + argstart, n + 1);
 			}
+		}
+
+		bool IsValueType(Type t)
+		{
+			return t.BaseType == typeof(ValueType) && !IsBaseType(t);
 		}

 		bool IsBaseType(Type t)
@@ -1741,7 +1746,12 @@
 				|| t == typeof(Vector2)
 				|| t == typeof(Vector3)
 				|| t == typeof(Vector4)
-				|| t == typeof(Quaternion);
+				|| t == typeof(Quaternion)
+				|| t.Name == "Color2&"
+				|| t.Name == "Vector2&"
+				|| t.Name == "Vector3&"
+				|| t.Name == "Vector4&"
+				|| t.Name == "Quaternion&";
 		}

 		string FullName(string str)


Use craftID for persistent names across saves/reloads

--- AutoAsparagus/ASPConsoleStuff.cs
+++ AutoAsparagus/ASPConsoleStuff.cs
@@ -290,7 +290,7 @@
 			if (p==null){
 				AAprint (header + ": part is null!");
 			} else {
-				AAprint (header + ": " + p.name.ToString () + ": " + getFriendlyName(p.GetInstanceID().ToString ()) + "/"+ p.GetInstanceID().ToString()+ "/" + p.symmetryCounterparts.Count.ToString ()+"/"+p.children.Count.ToString()+"/"+p.attachMode.ToString());
+				AAprint (header + ": " + p.name.ToString () + ": " + getFriendlyName(p.craftID.ToString ()) + "/"+ p.craftID.ToString()+ "/" + p.symmetryCounterparts.Count.ToString ()+"/"+p.children.Count.ToString()+"/"+p.attachMode.ToString());
 			}
 			#if superDEBUG
 			printTransform ("transform", p.transform);
@@ -303,7 +303,7 @@
 			dumpPartModule (pm);
 			}
 			foreach (Part child in p.children) {
-			AAprint ("child: "+child.name.ToString () + ": " + child.GetInstanceID().ToString () + "/" + child.symmetryCounterparts.Count.ToString ()+"/"+child.children.Count.ToString());
+			AAprint ("child: "+child.name.ToString () + ": " + child.craftID().ToString () + "/" + child.symmetryCounterparts.Count.ToString ()+"/"+child.children.Count.ToString());
 			}
 			#endif
 		}