PWDServerKeyExchangeHandler extends ServerKeyExchangeHandler<PWDServerKeyExchangeMessage> { @Override public void adjustTLSContext(PWDServerKeyExchangeMessage message) { tlsContext.setSelectedGroup(NamedGroup.getNamedGroup(message.getNamedGroup().getValue())); tlsContext.setServerPWDSalt(message.getSalt().getValue()); tlsContext.setServerPWDElement(PointFormatter.formatFromByteArray(tlsContext.getChooser() .getSelectedNamedGroup(), message.getElement().getValue())); tlsContext.setServerPWDScalar(new BigInteger(1, message.getScalar().getValue())); if (message.getComputations() != null) { tlsContext.setPWDPE(message.getComputations().getPasswordElement()); tlsContext.setServerPWDPrivate(message.getComputations().getPrivateKeyScalar()); } } PWDServerKeyExchangeHandler(TlsContext tlsContext); @Override PWDServerKeyExchangeParser getParser(byte[] message, int pointer); @Override PWDServerKeyExchangePreparator getPreparator(PWDServerKeyExchangeMessage message); @Override PWDServerKeyExchangeSerializer getSerializer(PWDServerKeyExchangeMessage message); @Override void adjustTLSContext(PWDServerKeyExchangeMessage message);  }
@Test public void testAdjustTLSContext() { PWDServerKeyExchangeMessage message = new PWDServerKeyExchangeMessage(); message.setNamedGroup(NamedGroup.BRAINPOOLP256R1.getValue()); byte[] element = ArrayConverter .hexStringToByteArray("0422bbd56b481d7fa90c35e8d42fcd06618a0778de506b1bc38882abc73132eef37f02e13bd544acc145bdd806450d43be34b9288348d03d6cd9832487b129dbe1"); BigInteger scalar = new BigInteger("2f704896699fc424d3cec33717644f5adf7f68483424ee51492bb96613fc4921", 16); byte[] salt = ArrayConverter .hexStringToByteArray("963c77cdc13a2a8d75cdddd1e0449929843711c21d47ce6e6383cdda37e47da3"); message.setElement(element); message.setScalar(scalar.toByteArray()); message.setSalt(salt); handler.adjustTLSContext(message); assertArrayEquals( ArrayConverter.bigIntegerToByteArray(PointFormatter .formatFromByteArray(NamedGroup.BRAINPOOLP256R1, element).getX().getData()), ArrayConverter.bigIntegerToByteArray(context.getServerPWDElement().getX().getData())); assertArrayEquals(salt, context.getServerPWDSalt()); assertArrayEquals(scalar.toByteArray(), context.getServerPWDScalar().toByteArray()); assertEquals(NamedGroup.BRAINPOOLP256R1, context.getSelectedGroup()); }