private ExchangeAfterRound2Creation runExchangeUntilRound2Creation(JPAKEParticipant alice, JPAKEParticipant bob) throws CryptoException { JPAKERound1Payload aliceRound1Payload = alice.createRound1PayloadToSend(); JPAKERound1Payload bobRound1Payload = bob.createRound1PayloadToSend(); alice.validateRound1PayloadReceived(bobRound1Payload); bob.validateRound1PayloadReceived(aliceRound1Payload); JPAKERound2Payload aliceRound2Payload = alice.createRound2PayloadToSend(); JPAKERound2Payload bobRound2Payload = bob.createRound2PayloadToSend(); return new ExchangeAfterRound2Creation( alice, aliceRound2Payload, bobRound2Payload); }
public ExchangeAfterRound2Creation( JPAKEParticipant alice, JPAKERound2Payload aliceRound2Payload, JPAKERound2Payload bobRound2Payload) { this.alice = alice; this.aliceRound2Payload = aliceRound2Payload; this.bobRound2Payload = bobRound2Payload; }
private JPAKEParticipant createParticipant(String participantId, String password) { return new JPAKEParticipant( participantId, password.toCharArray(), JPAKEPrimeOrderGroups.SUN_JCE_1024); }
public void testSuccessfulExchange() throws CryptoException { 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); assertEquals(aliceKeyingMaterial, bobKeyingMaterial); }
private JPAKEParticipant createAlice() { return createParticipant("alice", "password"); }
private JPAKEParticipant createBob() { return createParticipant("bob", "password"); }
private JPAKEParticipant createBobWithWrongPassword() { return createParticipant("bob", "wrong"); }