PWDClientKeyExchangePreparator extends ClientKeyExchangePreparator<PWDClientKeyExchangeMessage> { @Override public void prepareHandshakeMessageContents() { LOGGER.debug("Preparing PWDClientKeyExchangeMessage"); msg.prepareComputations(); EllipticCurve curve = CurveFactory.getCurve(chooser.getSelectedNamedGroup()); LOGGER.debug(chooser.getSelectedNamedGroup().getJavaName()); try { preparePasswordElement(msg); } catch (CryptoException e) { throw new PreparationException("Failed to generate password element", e); } prepareScalarElement(msg); byte[] premasterSecret = generatePremasterSecret(msg.getComputations().getPasswordElement(), msg .getComputations().getPrivateKeyScalar(), curve); preparePremasterSecret(msg, premasterSecret); prepareClientServerRandom(msg); } PWDClientKeyExchangePreparator(Chooser chooser, PWDClientKeyExchangeMessage msg); @Override void prepareHandshakeMessageContents(); @Override void prepareAfterParse(boolean clientMode);  }
@Test public void testPrepareHandshakeMessageContents() { preparator.prepareHandshakeMessageContents(); assertEquals(32, (long) msg.getScalarLength().getValue()); assertArrayEquals(scalar, msg.getScalar().getValue()); assertEquals(65, (long) msg.getElementLength().getValue()); assertArrayEquals(element, msg.getElement().getValue()); assertArrayEquals(premaster, msg.getComputations().getPremasterSecret().getValue()); }