summary refs log tree commit diff
path: root/crypto/test/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-10-17 14:35:17 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-10-17 14:35:17 +0700
commit2bb4400d228fd41191bc7aac4f1529c9c02a4e83 (patch)
treeecb69c6bdf10787751f5543864917a02bd91dfcc /crypto/test/src
parentMerge branch 'master' of https://github.com/avanpo/bc-csharp into avanpo-master (diff)
downloadBouncyCastle.NET-ed25519-2bb4400d228fd41191bc7aac4f1529c9c02a4e83.tar.xz
Various JPAKE changes to fit existing code conventions
- Update project file with new entries
- Tests moved to crypto/agreement/test
Diffstat (limited to 'crypto/test/src')
-rw-r--r--crypto/test/src/crypto/agreement/test/AllTests.cs31
-rw-r--r--crypto/test/src/crypto/agreement/test/JPAKEParticipantTest.cs (renamed from crypto/test/src/crypto/test/JPAKEParticipantTest.cs)132
-rw-r--r--crypto/test/src/crypto/agreement/test/JPakePrimeOrderGroupTest.cs (renamed from crypto/test/src/crypto/test/JPAKEPrimeOrderGroupTest.cs)24
-rw-r--r--crypto/test/src/crypto/agreement/test/JPakeUtilitiesTest.cs (renamed from crypto/test/src/crypto/test/JPAKEUtilTest.cs)104
4 files changed, 161 insertions, 130 deletions
diff --git a/crypto/test/src/crypto/agreement/test/AllTests.cs b/crypto/test/src/crypto/agreement/test/AllTests.cs
new file mode 100644
index 000000000..ea8f438e5
--- /dev/null
+++ b/crypto/test/src/crypto/agreement/test/AllTests.cs
@@ -0,0 +1,31 @@
+using System;
+
+using NUnit.Core;
+using NUnit.Framework;
+
+using Org.BouncyCastle.Utilities.Test;
+
+namespace Org.BouncyCastle.Crypto.Agreement.Tests
+{
+    [TestFixture]
+    public class AllTests
+    {
+        public static void Main(string[] args)
+        {
+            Suite.Run(new NullListener(), NUnit.Core.TestFilter.Empty);
+        }
+
+        [Suite]
+        public static TestSuite Suite
+        {
+            get
+            {
+                TestSuite suite = new TestSuite("JPAKE Engine Tests");
+                suite.Add(new JPakeParticipantTest());
+                suite.Add(new JPakePrimeOrderGroupTest());
+                suite.Add(new JPakeUtilitiesTest());
+                return suite;
+            }
+        }
+    }
+}
diff --git a/crypto/test/src/crypto/test/JPAKEParticipantTest.cs b/crypto/test/src/crypto/agreement/test/JPAKEParticipantTest.cs
index 7c01bf237..c84264aa5 100644
--- a/crypto/test/src/crypto/test/JPAKEParticipantTest.cs
+++ b/crypto/test/src/crypto/agreement/test/JPAKEParticipantTest.cs
@@ -2,16 +2,16 @@
 
 using NUnit.Framework;
 
-using Org.BouncyCastle.Crypto.Agreement.Jpake;
+using Org.BouncyCastle.Crypto.Agreement.JPake;
 using Org.BouncyCastle.Crypto.Digests;
 using Org.BouncyCastle.Math;
 using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities.Test;
 
-namespace Org.BouncyCastle.Crypto.Tests
+namespace Org.BouncyCastle.Crypto.Agreement.Tests
 {
     [TestFixture]
-    public class JPAKEParticipantTest
+    public class JPakeParticipantTest
         : SimpleTest
     {
         public override void PerformTest()
@@ -26,13 +26,13 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public override string Name
         {
-            get { return "JPAKEParticipant"; }
+            get { return "JPakeParticipant"; }
         }
 
         public static void Main(
             string[] args)
         {
-            RunTest(new JPAKEParticipantTest());
+            RunTest(new JPakeParticipantTest());
         }
 
         [Test]
@@ -45,23 +45,23 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public void TestConstruction()
         {
-            JPAKEPrimeOrderGroup group = JPAKEPrimeOrderGroups.SUN_JCE_1024;
+            JPakePrimeOrderGroup group = JPakePrimeOrderGroups.SUN_JCE_1024;
             SecureRandom random = new SecureRandom();
             IDigest digest = new Sha256Digest();
             string participantId = "participantId";
             char[] password = "password".ToCharArray();
 
             // should succeed
-            new JPAKEParticipant(participantId, password, group, digest, random);
+            new JPakeParticipant(participantId, password, group, digest, random);
 
             // null participantId
             try
             {
-                new JPAKEParticipant(null, password, group, digest, random);
+                new JPakeParticipant(null, password, group, digest, random);
 
                 Fail("failed to throw exception on null participantId");
             }
-            catch (NullReferenceException)
+            catch (ArgumentNullException)
             {
                 // expected
             }
@@ -69,11 +69,11 @@ namespace Org.BouncyCastle.Crypto.Tests
             // null password
             try
             {
-                new JPAKEParticipant(participantId, null, group, digest, random);
+                new JPakeParticipant(participantId, null, group, digest, random);
 
                 Fail("failed to throw exception on null password");
             }
-            catch (NullReferenceException)
+            catch (ArgumentNullException)
             {
                 // expected
             }
@@ -81,7 +81,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // empty password
             try
             {
-                new JPAKEParticipant(participantId, "".ToCharArray(), group, digest, random);
+                new JPakeParticipant(participantId, "".ToCharArray(), group, digest, random);
 
                 Fail("failed to throw exception on empty password");
             }
@@ -93,11 +93,11 @@ namespace Org.BouncyCastle.Crypto.Tests
             // null group
             try
             {
-                new JPAKEParticipant(participantId, password, null, digest, random);
+                new JPakeParticipant(participantId, password, null, digest, random);
 
                 Fail("failed to throw exception on null group");
             }
-            catch (NullReferenceException)
+            catch (ArgumentNullException)
             {
                 // expected
             }
@@ -105,11 +105,11 @@ namespace Org.BouncyCastle.Crypto.Tests
             // null digest
             try
             {
-                new JPAKEParticipant(participantId, password, group, null, random);
+                new JPakeParticipant(participantId, password, group, null, random);
 
                 Fail("failed to throw exception on null digest");
             }
-            catch (NullReferenceException)
+            catch (ArgumentNullException)
             {
                 // expected
             }
@@ -117,11 +117,11 @@ namespace Org.BouncyCastle.Crypto.Tests
             // null random
             try
             {
-                new JPAKEParticipant(participantId, password, group, digest, null);
+                new JPakeParticipant(participantId, password, group, digest, null);
 
                 Fail("failed to throw exception on null random");
             }
-            catch (NullReferenceException)
+            catch (ArgumentNullException)
             {
                 // expected
             }
@@ -129,8 +129,8 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public void TestSuccessfulExchange()
         {
-            JPAKEParticipant alice = CreateAlice();
-            JPAKEParticipant bob = CreateBob();
+            JPakeParticipant alice = CreateAlice();
+            JPakeParticipant bob = CreateBob();
 
             ExchangeAfterRound2Creation exchange = RunExchangeUntilRound2Creation(alice, bob);
 
@@ -140,8 +140,8 @@ namespace Org.BouncyCastle.Crypto.Tests
             BigInteger aliceKeyingMaterial = alice.CalculateKeyingMaterial();
             BigInteger bobKeyingMaterial = bob.CalculateKeyingMaterial();
 
-            JPAKERound3Payload aliceRound3Payload = alice.CreateRound3PayloadToSend(aliceKeyingMaterial);
-            JPAKERound3Payload bobRound3Payload = bob.CreateRound3PayloadToSend(bobKeyingMaterial);
+            JPakeRound3Payload aliceRound3Payload = alice.CreateRound3PayloadToSend(aliceKeyingMaterial);
+            JPakeRound3Payload bobRound3Payload = bob.CreateRound3PayloadToSend(bobKeyingMaterial);
 
             alice.ValidateRound3PayloadReceived(bobRound3Payload, aliceKeyingMaterial);
             bob.ValidateRound3PayloadReceived(aliceRound3Payload, bobKeyingMaterial);
@@ -151,8 +151,8 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public void TestIncorrectPassword()
         {
-            JPAKEParticipant alice = CreateAlice();
-            JPAKEParticipant bob = CreateBobWithWrongPassword();
+            JPakeParticipant alice = CreateAlice();
+            JPakeParticipant bob = CreateBobWithWrongPassword();
 
             ExchangeAfterRound2Creation exchange = RunExchangeUntilRound2Creation(alice, bob);
 
@@ -162,8 +162,8 @@ namespace Org.BouncyCastle.Crypto.Tests
             BigInteger aliceKeyingMaterial = alice.CalculateKeyingMaterial();
             BigInteger bobKeyingMaterial = bob.CalculateKeyingMaterial();
 
-            JPAKERound3Payload aliceRound3Payload = alice.CreateRound3PayloadToSend(aliceKeyingMaterial);
-            JPAKERound3Payload bobRound3Payload = bob.CreateRound3PayloadToSend(bobKeyingMaterial);
+            JPakeRound3Payload aliceRound3Payload = alice.CreateRound3PayloadToSend(aliceKeyingMaterial);
+            JPakeRound3Payload bobRound3Payload = bob.CreateRound3PayloadToSend(bobKeyingMaterial);
 
             try
             {
@@ -190,14 +190,14 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public void TestStateValidation()
         {
-            JPAKEParticipant alice = CreateAlice();
-            JPAKEParticipant bob = CreateBob();
+            JPakeParticipant alice = CreateAlice();
+            JPakeParticipant bob = CreateBob();
 
             // We're testing alice here. Bob is just used for help.
 
             // START ROUND 1 CHECKS
 
-            Assert.AreEqual(JPAKEParticipant.STATE_INITIALIZED, alice.State);
+            Assert.AreEqual(JPakeParticipant.STATE_INITIALIZED, alice.State);
 
             // create round 2 before round 1
             try
@@ -211,8 +211,8 @@ namespace Org.BouncyCastle.Crypto.Tests
                 // expected
             }
 
-            JPAKERound1Payload aliceRound1Payload = alice.CreateRound1PayloadToSend();
-            Assert.AreEqual(JPAKEParticipant.STATE_ROUND_1_CREATED, alice.State);
+            JPakeRound1Payload aliceRound1Payload = alice.CreateRound1PayloadToSend();
+            Assert.AreEqual(JPakeParticipant.STATE_ROUND_1_CREATED, alice.State);
 
             // create round 1 twice
             try
@@ -250,9 +250,9 @@ namespace Org.BouncyCastle.Crypto.Tests
                 // expected
             }
 
-            JPAKERound1Payload bobRound1Payload = bob.CreateRound1PayloadToSend();
+            JPakeRound1Payload bobRound1Payload = bob.CreateRound1PayloadToSend();
             alice.ValidateRound1PayloadReceived(bobRound1Payload);
-            Assert.AreEqual(JPAKEParticipant.STATE_ROUND_1_VALIDATED, alice.State);
+            Assert.AreEqual(JPakeParticipant.STATE_ROUND_1_VALIDATED, alice.State);
 
             // validate round 1 payload twice
             try
@@ -270,8 +270,8 @@ namespace Org.BouncyCastle.Crypto.Tests
 
             // START ROUND 2 CHECKS
 
-            JPAKERound2Payload aliceRound2Payload = alice.CreateRound2PayloadToSend();
-            Assert.AreEqual(JPAKEParticipant.STATE_ROUND_2_CREATED, alice.State);
+            JPakeRound2Payload aliceRound2Payload = alice.CreateRound2PayloadToSend();
+            Assert.AreEqual(JPakeParticipant.STATE_ROUND_2_CREATED, alice.State);
 
             // create round 2 payload twice
             try
@@ -309,9 +309,9 @@ namespace Org.BouncyCastle.Crypto.Tests
                 // expected
             }
 
-            JPAKERound2Payload bobRound2Payload = bob.CreateRound2PayloadToSend();
+            JPakeRound2Payload bobRound2Payload = bob.CreateRound2PayloadToSend();
             alice.ValidateRound2PayloadReceived(bobRound2Payload);
-            Assert.AreEqual(JPAKEParticipant.STATE_ROUND_2_VALIDATED, alice.State);
+            Assert.AreEqual(JPakeParticipant.STATE_ROUND_2_VALIDATED, alice.State);
 
             // validate round 2 payload twice
             try
@@ -342,7 +342,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // START KEY CALCULATION CHECKS
 
             BigInteger aliceKeyingMaterial = alice.CalculateKeyingMaterial();
-            Assert.AreEqual(JPAKEParticipant.STATE_KEY_CALCULATED, alice.State);
+            Assert.AreEqual(JPakeParticipant.STATE_KEY_CALCULATED, alice.State);
 
             // calculate key twice
             try
@@ -360,8 +360,8 @@ namespace Org.BouncyCastle.Crypto.Tests
 
             // START ROUND 3 CHECKS
 
-            JPAKERound3Payload aliceRound3Payload = alice.CreateRound3PayloadToSend(aliceKeyingMaterial);
-            Assert.AreEqual(JPAKEParticipant.STATE_ROUND_3_CREATED, alice.State);
+            JPakeRound3Payload aliceRound3Payload = alice.CreateRound3PayloadToSend(aliceKeyingMaterial);
+            Assert.AreEqual(JPakeParticipant.STATE_ROUND_3_CREATED, alice.State);
 
             // create round 3 payload twice
             try
@@ -375,9 +375,9 @@ namespace Org.BouncyCastle.Crypto.Tests
                 // expected
             }
 
-            JPAKERound3Payload bobRound3Payload = bob.CreateRound3PayloadToSend(bobKeyingMaterial);
+            JPakeRound3Payload bobRound3Payload = bob.CreateRound3PayloadToSend(bobKeyingMaterial);
             alice.ValidateRound3PayloadReceived(bobRound3Payload, aliceKeyingMaterial);
-            Assert.AreEqual(JPAKEParticipant.STATE_ROUND_3_VALIDATED, alice.State);
+            Assert.AreEqual(JPakeParticipant.STATE_ROUND_3_VALIDATED, alice.State);
 
             // validate round 3 payload twice
             try
@@ -398,7 +398,7 @@ namespace Org.BouncyCastle.Crypto.Tests
         {
             // We're testing alice here. Bob is just used for help.
 
-            JPAKERound1Payload bobRound1Payload = CreateBob().CreateRound1PayloadToSend();
+            JPakeRound1Payload bobRound1Payload = CreateBob().CreateRound1PayloadToSend();
 
             // should succeed
             CreateAlice().ValidateRound1PayloadReceived(bobRound1Payload);
@@ -406,7 +406,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // alice verifies alice's payload
             try
             {
-                JPAKEParticipant alice = CreateAlice();
+                JPakeParticipant alice = CreateAlice();
                 alice.ValidateRound1PayloadReceived(alice.CreateRound1PayloadToSend());
 
                 Fail("failed to throw on participant validating own payload");
@@ -419,7 +419,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // g^x4 == 1
             try
             {
-                CreateAlice().ValidateRound1PayloadReceived(new JPAKERound1Payload(
+                CreateAlice().ValidateRound1PayloadReceived(new JPakeRound1Payload(
                     bobRound1Payload.ParticipantId,
                     bobRound1Payload.Gx1,
                     BigInteger.One,
@@ -436,8 +436,8 @@ namespace Org.BouncyCastle.Crypto.Tests
             // zero knowledge proof for x3 fails
             try
             {
-                JPAKERound1Payload bobRound1Payload2 = CreateBob().CreateRound1PayloadToSend();
-                CreateAlice().ValidateRound1PayloadReceived(new JPAKERound1Payload(
+                JPakeRound1Payload bobRound1Payload2 = CreateBob().CreateRound1PayloadToSend();
+                CreateAlice().ValidateRound1PayloadReceived(new JPakeRound1Payload(
                     bobRound1Payload.ParticipantId,
                     bobRound1Payload.Gx1,
                     bobRound1Payload.Gx2,
@@ -454,8 +454,8 @@ namespace Org.BouncyCastle.Crypto.Tests
             // zero knowledge proof for x4 fails
             try
             {
-                JPAKERound1Payload bobRound1Payload2 = CreateBob().CreateRound1PayloadToSend();
-                CreateAlice().ValidateRound1PayloadReceived(new JPAKERound1Payload(
+                JPakeRound1Payload bobRound1Payload2 = CreateBob().CreateRound1PayloadToSend();
+                CreateAlice().ValidateRound1PayloadReceived(new JPakeRound1Payload(
                     bobRound1Payload.ParticipantId,
                     bobRound1Payload.Gx1,
                     bobRound1Payload.Gx2,
@@ -508,14 +508,14 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         private class ExchangeAfterRound2Creation
         {
-            public JPAKEParticipant alice;
-            public JPAKERound2Payload aliceRound2Payload;
-            public JPAKERound2Payload bobRound2Payload;
+            public JPakeParticipant alice;
+            public JPakeRound2Payload aliceRound2Payload;
+            public JPakeRound2Payload bobRound2Payload;
 
             public ExchangeAfterRound2Creation(
-                JPAKEParticipant alice,
-                JPAKERound2Payload aliceRound2Payload,
-                JPAKERound2Payload bobRound2Payload)
+                JPakeParticipant alice,
+                JPakeRound2Payload aliceRound2Payload,
+                JPakeRound2Payload bobRound2Payload)
             {
                 this.alice = alice;
                 this.aliceRound2Payload = aliceRound2Payload;
@@ -523,16 +523,16 @@ namespace Org.BouncyCastle.Crypto.Tests
             }
         }
 
-        private ExchangeAfterRound2Creation RunExchangeUntilRound2Creation(JPAKEParticipant alice, JPAKEParticipant bob)
+        private ExchangeAfterRound2Creation RunExchangeUntilRound2Creation(JPakeParticipant alice, JPakeParticipant bob)
         {
-            JPAKERound1Payload aliceRound1Payload = alice.CreateRound1PayloadToSend();
-            JPAKERound1Payload bobRound1Payload = bob.CreateRound1PayloadToSend();
+            JPakeRound1Payload aliceRound1Payload = alice.CreateRound1PayloadToSend();
+            JPakeRound1Payload bobRound1Payload = bob.CreateRound1PayloadToSend();
 
             alice.ValidateRound1PayloadReceived(bobRound1Payload);
             bob.ValidateRound1PayloadReceived(aliceRound1Payload);
 
-            JPAKERound2Payload aliceRound2Payload = alice.CreateRound2PayloadToSend();
-            JPAKERound2Payload bobRound2Payload = bob.CreateRound2PayloadToSend();
+            JPakeRound2Payload aliceRound2Payload = alice.CreateRound2PayloadToSend();
+            JPakeRound2Payload bobRound2Payload = bob.CreateRound2PayloadToSend();
 
             return new ExchangeAfterRound2Creation(
                 alice,
@@ -540,27 +540,27 @@ namespace Org.BouncyCastle.Crypto.Tests
                 bobRound2Payload);
         }
 
-        private JPAKEParticipant CreateAlice()
+        private JPakeParticipant CreateAlice()
         {
             return CreateParticipant("alice", "password");
         }
 
-        private JPAKEParticipant CreateBob()
+        private JPakeParticipant CreateBob()
         {
             return CreateParticipant("bob", "password");
         }
 
-        private JPAKEParticipant CreateBobWithWrongPassword()
+        private JPakeParticipant CreateBobWithWrongPassword()
         {
             return CreateParticipant("bob", "wrong");
         }
 
-        private JPAKEParticipant CreateParticipant(string participantId, string password)
+        private JPakeParticipant CreateParticipant(string participantId, string password)
         {
-            return new JPAKEParticipant(
+            return new JPakeParticipant(
                 participantId,
                 password.ToCharArray(),
-                JPAKEPrimeOrderGroups.SUN_JCE_1024);
+                JPakePrimeOrderGroups.SUN_JCE_1024);
         }
     }
 }
diff --git a/crypto/test/src/crypto/test/JPAKEPrimeOrderGroupTest.cs b/crypto/test/src/crypto/agreement/test/JPakePrimeOrderGroupTest.cs
index d9749cb53..0f089f93c 100644
--- a/crypto/test/src/crypto/test/JPAKEPrimeOrderGroupTest.cs
+++ b/crypto/test/src/crypto/agreement/test/JPakePrimeOrderGroupTest.cs
@@ -2,14 +2,14 @@
 
 using NUnit.Framework;
 
-using Org.BouncyCastle.Crypto.Agreement.Jpake;
+using Org.BouncyCastle.Crypto.Agreement.JPake;
 using Org.BouncyCastle.Math;
 using Org.BouncyCastle.Utilities.Test;
 
-namespace Org.BouncyCastle.Crypto.Tests
+namespace Org.BouncyCastle.Crypto.Agreement.Tests
 {
     [TestFixture]
-    public class JPAKEPrimeOrderGroupTest
+    public class JPakePrimeOrderGroupTest
         : SimpleTest
     {
         public override void PerformTest()
@@ -19,13 +19,13 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public override string Name
         {
-            get { return "JPAKEPrimeOrderGroup"; }
+            get { return "JPakePrimeOrderGroup"; }
         }
 
         public static void Main(
             string[] args)
         {
-            RunTest(new JPAKEPrimeOrderGroupTest());
+            RunTest(new JPakePrimeOrderGroupTest());
         }
 
         [Test]
@@ -41,7 +41,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // p-1 not evenly divisible by q
             try
             {
-                new JPAKEPrimeOrderGroup(BigInteger.ValueOf(7), BigInteger.ValueOf(5), BigInteger.ValueOf(6));
+                new JPakePrimeOrderGroup(BigInteger.ValueOf(7), BigInteger.ValueOf(5), BigInteger.ValueOf(6));
 
                 Fail("failed to throw exception on p-1 not evenly divisible by q");
             }
@@ -53,7 +53,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // g < 2
             try
             {
-                new JPAKEPrimeOrderGroup(BigInteger.ValueOf(11), BigInteger.ValueOf(5), BigInteger.ValueOf(1));
+                new JPakePrimeOrderGroup(BigInteger.ValueOf(11), BigInteger.ValueOf(5), BigInteger.ValueOf(1));
 
                 Fail("failed to throw exception on g < 2");
             }
@@ -65,7 +65,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // g > p - 1
             try
             {
-                new JPAKEPrimeOrderGroup(BigInteger.ValueOf(11), BigInteger.ValueOf(5), BigInteger.ValueOf(11));
+                new JPakePrimeOrderGroup(BigInteger.ValueOf(11), BigInteger.ValueOf(5), BigInteger.ValueOf(11));
 
                 Fail("failed to throw exception on g > p - 1");
             }
@@ -77,7 +77,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             //g^q mod p not equal 1
             try
             {
-                new JPAKEPrimeOrderGroup(BigInteger.ValueOf(11), BigInteger.ValueOf(5), BigInteger.ValueOf(6));
+                new JPakePrimeOrderGroup(BigInteger.ValueOf(11), BigInteger.ValueOf(5), BigInteger.ValueOf(6));
 
                 Fail("failed to throw exception on g^q mod p not equal 1");
             }
@@ -89,7 +89,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // p not prime
             try
             {
-                new JPAKEPrimeOrderGroup(BigInteger.ValueOf(15), BigInteger.ValueOf(2), BigInteger.ValueOf(4));
+                new JPakePrimeOrderGroup(BigInteger.ValueOf(15), BigInteger.ValueOf(2), BigInteger.ValueOf(4));
 
                 Fail("failed to throw exception on p not prime");
             }
@@ -101,7 +101,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // q not prime
             try
             {
-                new JPAKEPrimeOrderGroup(BigInteger.ValueOf(7), BigInteger.ValueOf(6), BigInteger.ValueOf(3));
+                new JPakePrimeOrderGroup(BigInteger.ValueOf(7), BigInteger.ValueOf(6), BigInteger.ValueOf(3));
 
                 Fail("failed to throw exception on q not prime");
             }
@@ -111,7 +111,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             }
 
             // should succeed
-            new JPAKEPrimeOrderGroup(BigInteger.ValueOf(7), BigInteger.ValueOf(3), BigInteger.ValueOf(4));
+            new JPakePrimeOrderGroup(BigInteger.ValueOf(7), BigInteger.ValueOf(3), BigInteger.ValueOf(4));
         }
     }
 }
diff --git a/crypto/test/src/crypto/test/JPAKEUtilTest.cs b/crypto/test/src/crypto/agreement/test/JPakeUtilitiesTest.cs
index 7ac54aba0..04a52cc06 100644
--- a/crypto/test/src/crypto/test/JPAKEUtilTest.cs
+++ b/crypto/test/src/crypto/agreement/test/JPakeUtilitiesTest.cs
@@ -2,16 +2,16 @@
 
 using NUnit.Framework;
 
-using Org.BouncyCastle.Crypto.Agreement.Jpake;
+using Org.BouncyCastle.Crypto.Agreement.JPake;
 using Org.BouncyCastle.Crypto.Digests;
 using Org.BouncyCastle.Math;
 using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities.Test;
 
-namespace Org.BouncyCastle.Crypto.Tests
+namespace Org.BouncyCastle.Crypto.Agreement.Tests
 {
     [TestFixture]
-    public class JPAKEUtilTest
+    public class JPakeUtilitiesTest
         : SimpleTest
     {
         private static readonly BigInteger Ten = BigInteger.ValueOf(10);
@@ -29,13 +29,13 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public override string Name
         {
-            get { return "JPAKEUtil"; }
+            get { return "JPakeUtilities"; }
         }
 
         public static void Main(
             string[] args)
         {
-            RunTest(new JPAKEUtilTest());
+            RunTest(new JPakeUtilitiesTest());
         }
 
         [Test]
@@ -48,11 +48,11 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public void TestValidateGx4()
         {
-            JPAKEUtil.ValidateGx4(Ten);
+            JPakeUtilities.ValidateGx4(Ten);
 
             try
             {
-                JPAKEUtil.ValidateGx4(BigInteger.One);
+                JPakeUtilities.ValidateGx4(BigInteger.One);
 
                 Fail("exception not thrown for g^x4 equal to 1");
             }
@@ -64,11 +64,11 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public void TestValidateGa()
         {
-            JPAKEUtil.ValidateGa(Ten);
+            JPakeUtilities.ValidateGa(Ten);
 
             try
             {
-                JPAKEUtil.ValidateGa(BigInteger.One);
+                JPakeUtilities.ValidateGa(BigInteger.One);
 
                 Fail("exception not thrown for g^a equal to 1");
             }
@@ -80,12 +80,12 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public void TestValidateParticipantIdsDiffer()
         {
-            JPAKEUtil.ValidateParticipantIdsDiffer("a", "b");
-            JPAKEUtil.ValidateParticipantIdsDiffer("a", "A");
+            JPakeUtilities.ValidateParticipantIdsDiffer("a", "b");
+            JPakeUtilities.ValidateParticipantIdsDiffer("a", "A");
 
             try
             {
-                JPAKEUtil.ValidateParticipantIdsDiffer("a", "a");
+                JPakeUtilities.ValidateParticipantIdsDiffer("a", "a");
 
                 Fail("validate participant ids differ not throwing exception for equal participant ids");
             }
@@ -97,11 +97,11 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public void TestValidateParticipantsIdsEqual()
         {
-            JPAKEUtil.ValidateParticipantIdsEqual("a", "a");
+            JPakeUtilities.ValidateParticipantIdsEqual("a", "a");
 
             try
             {
-                JPAKEUtil.ValidateParticipantIdsEqual("a", "b");
+                JPakeUtilities.ValidateParticipantIdsEqual("a", "b");
 
                 Fail("validate participant ids equal not throwing exception for different participant ids");
             }
@@ -113,40 +113,40 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public void TestValidateMacTag()
         {
-            JPAKEPrimeOrderGroup pg1 = JPAKEPrimeOrderGroups.SUN_JCE_1024;
+            JPakePrimeOrderGroup pg1 = JPakePrimeOrderGroups.SUN_JCE_1024;
 
             SecureRandom random = new SecureRandom();
             IDigest digest = new Sha256Digest();
 
-            BigInteger x1 = JPAKEUtil.GenerateX1(pg1.Q, random);
-            BigInteger x2 = JPAKEUtil.GenerateX2(pg1.Q, random);
-            BigInteger x3 = JPAKEUtil.GenerateX1(pg1.Q, random);
-            BigInteger x4 = JPAKEUtil.GenerateX2(pg1.Q, random);
+            BigInteger x1 = JPakeUtilities.GenerateX1(pg1.Q, random);
+            BigInteger x2 = JPakeUtilities.GenerateX2(pg1.Q, random);
+            BigInteger x3 = JPakeUtilities.GenerateX1(pg1.Q, random);
+            BigInteger x4 = JPakeUtilities.GenerateX2(pg1.Q, random);
 
-            BigInteger gx1 = JPAKEUtil.CalculateGx(pg1.P, pg1.G, x1);
-            BigInteger gx2 = JPAKEUtil.CalculateGx(pg1.P, pg1.G, x2);
-            BigInteger gx3 = JPAKEUtil.CalculateGx(pg1.P, pg1.G, x3);
-            BigInteger gx4 = JPAKEUtil.CalculateGx(pg1.P, pg1.G, x4);
+            BigInteger gx1 = JPakeUtilities.CalculateGx(pg1.P, pg1.G, x1);
+            BigInteger gx2 = JPakeUtilities.CalculateGx(pg1.P, pg1.G, x2);
+            BigInteger gx3 = JPakeUtilities.CalculateGx(pg1.P, pg1.G, x3);
+            BigInteger gx4 = JPakeUtilities.CalculateGx(pg1.P, pg1.G, x4);
 
-            BigInteger gB = JPAKEUtil.CalculateGA(pg1.P, gx3, gx1, gx2);
+            BigInteger gB = JPakeUtilities.CalculateGA(pg1.P, gx3, gx1, gx2);
 
-            BigInteger s = JPAKEUtil.CalculateS("password".ToCharArray());
+            BigInteger s = JPakeUtilities.CalculateS("password".ToCharArray());
 
-            BigInteger xs = JPAKEUtil.CalculateX2s(pg1.Q, x4, s);
+            BigInteger xs = JPakeUtilities.CalculateX2s(pg1.Q, x4, s);
 
-            BigInteger B = JPAKEUtil.CalculateA(pg1.P, pg1.Q, gB, xs);
+            BigInteger B = JPakeUtilities.CalculateA(pg1.P, pg1.Q, gB, xs);
 
-            BigInteger keyingMaterial = JPAKEUtil.CalculateKeyingMaterial(pg1.P, pg1.Q, gx4, x2, s, B);
+            BigInteger keyingMaterial = JPakeUtilities.CalculateKeyingMaterial(pg1.P, pg1.Q, gx4, x2, s, B);
 
-            BigInteger macTag = JPAKEUtil.CalculateMacTag("participantId", "partnerParticipantId", gx1, gx2, gx3, gx4, keyingMaterial, digest);
+            BigInteger macTag = JPakeUtilities.CalculateMacTag("participantId", "partnerParticipantId", gx1, gx2, gx3, gx4, keyingMaterial, digest);
 
             // should succeed
-            JPAKEUtil.ValidateMacTag("partnerParticipantId", "participantId", gx3, gx4, gx1, gx2, keyingMaterial, digest, macTag);
+            JPakeUtilities.ValidateMacTag("partnerParticipantId", "participantId", gx3, gx4, gx1, gx2, keyingMaterial, digest, macTag);
 
             // validating own macTag (as opposed to the other party's mactag)
             try
             {
-                JPAKEUtil.ValidateMacTag("participantId", "partnerParticipantId", gx1, gx2, gx3, gx4, keyingMaterial, digest, macTag);
+                JPakeUtilities.ValidateMacTag("participantId", "partnerParticipantId", gx1, gx2, gx3, gx4, keyingMaterial, digest, macTag);
 
                 Fail("failed to throw exception on validating own macTag (calculated partner macTag)");
             }
@@ -158,7 +158,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // participant ids switched
             try
             {
-                JPAKEUtil.ValidateMacTag("participantId", "partnerParticipantId", gx3, gx4, gx1, gx2, keyingMaterial, digest, macTag);
+                JPakeUtilities.ValidateMacTag("participantId", "partnerParticipantId", gx3, gx4, gx1, gx2, keyingMaterial, digest, macTag);
 
                 Fail("failed to throw exception on validating own macTag (calculated partner macTag");
             }
@@ -170,15 +170,15 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public void TestValidateNotNull()
         {
-            JPAKEUtil.ValidateNotNull("a", "description");
+            JPakeUtilities.ValidateNotNull("a", "description");
 
             try
             {
-                JPAKEUtil.ValidateNotNull(null, "description");
+                JPakeUtilities.ValidateNotNull(null, "description");
 
                 Fail("failed to throw exception on null");
             }
-            catch (NullReferenceException)
+            catch (ArgumentNullException)
             {
                 // expected
             }
@@ -186,25 +186,25 @@ namespace Org.BouncyCastle.Crypto.Tests
 
         public void TestValidateZeroKnowledgeProof()
         {
-            JPAKEPrimeOrderGroup pg1 = JPAKEPrimeOrderGroups.SUN_JCE_1024;
+            JPakePrimeOrderGroup pg1 = JPakePrimeOrderGroups.SUN_JCE_1024;
 
             SecureRandom random = new SecureRandom();
             IDigest digest1 = new Sha256Digest();
 
-            BigInteger x1 = JPAKEUtil.GenerateX1(pg1.Q, random);
-            BigInteger gx1 = JPAKEUtil.CalculateGx(pg1.P, pg1.G, x1);
+            BigInteger x1 = JPakeUtilities.GenerateX1(pg1.Q, random);
+            BigInteger gx1 = JPakeUtilities.CalculateGx(pg1.P, pg1.G, x1);
             string participantId1 = "participant1";
 
-            BigInteger[] zkp1 = JPAKEUtil.CalculateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx1, x1, participantId1, digest1, random);
+            BigInteger[] zkp1 = JPakeUtilities.CalculateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx1, x1, participantId1, digest1, random);
 
             // should succeed
-            JPAKEUtil.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx1, zkp1, participantId1, digest1);
+            JPakeUtilities.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx1, zkp1, participantId1, digest1);
 
             // wrong group
-            JPAKEPrimeOrderGroup pg2 = JPAKEPrimeOrderGroups.NIST_3072;
+            JPakePrimeOrderGroup pg2 = JPakePrimeOrderGroups.NIST_3072;
             try
             {
-                JPAKEUtil.ValidateZeroKnowledgeProof(pg2.P, pg2.Q, pg2.G, gx1, zkp1, participantId1, digest1);
+                JPakeUtilities.ValidateZeroKnowledgeProof(pg2.P, pg2.Q, pg2.G, gx1, zkp1, participantId1, digest1);
 
                 Fail("failed to throw exception on wrong prime order group");
             }
@@ -217,7 +217,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             IDigest digest2 = new Sha1Digest();
             try
             {
-                JPAKEUtil.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx1, zkp1, participantId1, digest2);
+                JPakeUtilities.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx1, zkp1, participantId1, digest2);
 
                 Fail("failed to throw exception on wrong digest");
             }
@@ -230,7 +230,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             string participantId2 = "participant2";
             try
             {
-                JPAKEUtil.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx1, zkp1, participantId2, digest1);
+                JPakeUtilities.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx1, zkp1, participantId2, digest1);
 
                 Fail("failed to throw exception on wrong participant");
             }
@@ -240,11 +240,11 @@ namespace Org.BouncyCastle.Crypto.Tests
             }
 
             // wrong gx
-            BigInteger x2 = JPAKEUtil.GenerateX2(pg1.Q, random);
-            BigInteger gx2 = JPAKEUtil.CalculateGx(pg1.P, pg1.G, x2);
+            BigInteger x2 = JPakeUtilities.GenerateX2(pg1.Q, random);
+            BigInteger gx2 = JPakeUtilities.CalculateGx(pg1.P, pg1.G, x2);
             try
             {
-                JPAKEUtil.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx2, zkp1, participantId1, digest1);
+                JPakeUtilities.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx2, zkp1, participantId1, digest1);
 
                 Fail("failed to throw exception on wrong gx");
             }
@@ -254,10 +254,10 @@ namespace Org.BouncyCastle.Crypto.Tests
             }
 
             // wrong zkp
-            BigInteger[] zkp2 = JPAKEUtil.CalculateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx2, x2, participantId1, digest1, random);
+            BigInteger[] zkp2 = JPakeUtilities.CalculateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx2, x2, participantId1, digest1, random);
             try
             {
-                JPAKEUtil.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx1, zkp2, participantId1, digest1);
+                JPakeUtilities.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, gx1, zkp2, participantId1, digest1);
 
                 Fail("failed to throw exception on wrong zero knowledge proof");
             }
@@ -269,7 +269,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // gx <= 0
             try
             {
-                JPAKEUtil.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, BigInteger.Zero, zkp1, participantId1, digest1);
+                JPakeUtilities.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, BigInteger.Zero, zkp1, participantId1, digest1);
 
                 Fail("failed to throw exception on g^x <= 0");
             }
@@ -281,7 +281,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // gx >= p
             try
             {
-                JPAKEUtil.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, pg1.P, zkp1, participantId1, digest1);
+                JPakeUtilities.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, pg1.P, zkp1, participantId1, digest1);
 
                 Fail("failed to throw exception on g^x >= p");
             }
@@ -293,7 +293,7 @@ namespace Org.BouncyCastle.Crypto.Tests
             // gx mod q == 1
             try
             {
-                JPAKEUtil.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, pg1.Q.Add(BigInteger.One), zkp1, participantId1, digest1);
+                JPakeUtilities.ValidateZeroKnowledgeProof(pg1.P, pg1.Q, pg1.G, pg1.Q.Add(BigInteger.One), zkp1, participantId1, digest1);
 
                 Fail("failed to throw exception on g^x mod q == 1");
             }