public void TestSuccessfulExchange() { JPakeParticipant alice = CreateAlice(); JPakeParticipant bob = CreateBob(); ExchangeAfterRound2Creation exchange = RunExchangeUntilRound2Creation(alice, bob); alice.ValidateRound2PayloadReceived(exchange.bobRound2Payload); bob.ValidateRound2PayloadReceived(exchange.aliceRound2Payload); BigInteger aliceKeyingMaterial = alice.CalculateKeyingMaterial(); BigInteger bobKeyingMaterial = bob.CalculateKeyingMaterial(); JPakeRound3Payload aliceRound3Payload = alice.CreateRound3PayloadToSend(aliceKeyingMaterial); JPakeRound3Payload bobRound3Payload = bob.CreateRound3PayloadToSend(bobKeyingMaterial); alice.ValidateRound3PayloadReceived(bobRound3Payload, aliceKeyingMaterial); bob.ValidateRound3PayloadReceived(aliceRound3Payload, bobKeyingMaterial); Assert.AreEqual(aliceKeyingMaterial, bobKeyingMaterial); }
public void TestValidateRound2PayloadReceived() { // We're testing alice here. Bob is just used for help. // should succeed ExchangeAfterRound2Creation exchange1 = RunExchangeUntilRound2Creation(CreateAlice(), CreateBob()); exchange1.alice.ValidateRound2PayloadReceived(exchange1.bobRound2Payload); // alice verified alice's payload ExchangeAfterRound2Creation exchange2 = RunExchangeUntilRound2Creation(CreateAlice(), CreateBob()); try { exchange2.alice.ValidateRound2PayloadReceived(exchange2.aliceRound2Payload); Fail("failed to throw on participant verifying own payload 2"); } catch (CryptoException) { // expected } // wrong z ExchangeAfterRound2Creation exchange3 = RunExchangeUntilRound2Creation(CreateAlice(), CreateBob()); ExchangeAfterRound2Creation exchange4 = RunExchangeUntilRound2Creation(CreateAlice(), CreateBob()); try { exchange3.alice.ValidateRound2PayloadReceived(exchange4.bobRound2Payload); Fail("failed to throw on wrong z"); } catch (CryptoException) { // expected } }
public void TestIncorrectPassword() { JPakeParticipant alice = CreateAlice(); JPakeParticipant bob = CreateBobWithWrongPassword(); ExchangeAfterRound2Creation exchange = RunExchangeUntilRound2Creation(alice, bob); alice.ValidateRound2PayloadReceived(exchange.bobRound2Payload); bob.ValidateRound2PayloadReceived(exchange.aliceRound2Payload); BigInteger aliceKeyingMaterial = alice.CalculateKeyingMaterial(); BigInteger bobKeyingMaterial = bob.CalculateKeyingMaterial(); JPakeRound3Payload aliceRound3Payload = alice.CreateRound3PayloadToSend(aliceKeyingMaterial); JPakeRound3Payload bobRound3Payload = bob.CreateRound3PayloadToSend(bobKeyingMaterial); try { alice.ValidateRound3PayloadReceived(bobRound3Payload, aliceKeyingMaterial); Fail("failed to throw exception on incorrect password"); } catch (CryptoException) { // expected } try { bob.ValidateRound3PayloadReceived(aliceRound3Payload, bobKeyingMaterial); Fail("failed to throw exception on incorrect password"); } catch (CryptoException) { // expected } }