DHEServerKeyExchangeHandler extends ServerKeyExchangeHandler<DHEServerKeyExchangeMessage> { @Override public void adjustTLSContext(DHEServerKeyExchangeMessage message) { adjustDhGenerator(message); adjustDhModulus(message); adjustServerPublicKey(message); if (message.getComputations() != null && message.getComputations().getPrivateKey() != null) { adjustServerPrivateKey(message); } } DHEServerKeyExchangeHandler(TlsContext tlsContext); @Override DHEServerKeyExchangeParser getParser(byte[] message, int pointer); @Override DHEServerKeyExchangePreparator getPreparator(DHEServerKeyExchangeMessage message); @Override DHEServerKeyExchangeSerializer getSerializer(DHEServerKeyExchangeMessage message); @Override void adjustTLSContext(DHEServerKeyExchangeMessage message);  }
@Test public void testAdjustTLSContext() { DHEServerKeyExchangeMessage message = new DHEServerKeyExchangeMessage(); message.setModulus(BigInteger.TEN.toByteArray()); message.setGenerator(BigInteger.ONE.toByteArray()); message.setPublicKey(new byte[] { 0, 1, 2, 3 }); context.setSelectedCipherSuite(CipherSuite.TLS_DHE_RSA_WITH_AES_128_CBC_SHA); message.prepareComputations(); message.getComputations().setPrivateKey(BigInteger.ZERO); handler.adjustTLSContext(message); }
@Test public void testAdjustTLSContextWithoutComputations() { DHEServerKeyExchangeMessage message = new DHEServerKeyExchangeMessage(); message.setModulus(BigInteger.TEN.toByteArray()); message.setGenerator(BigInteger.ONE.toByteArray()); message.setPublicKey(new byte[] { 0, 1, 2, 3 }); handler.adjustTLSContext(message); }