ECDHClientKeyExchangeHandler extends ClientKeyExchangeHandler<ECDHClientKeyExchangeMessage> { @Override public void adjustTLSContext(ECDHClientKeyExchangeMessage message) { adjustPremasterSecret(message); adjustMasterSecret(message); adjustClientPublicKey(message); setRecordCipher(); spawnNewSession(); } ECDHClientKeyExchangeHandler(TlsContext tlsContext); @Override ECDHClientKeyExchangeParser getParser(byte[] message, int pointer); @Override ECDHClientKeyExchangePreparator getPreparator(ECDHClientKeyExchangeMessage message); @Override ECDHClientKeyExchangeSerializer getSerializer(ECDHClientKeyExchangeMessage message); @Override void adjustTLSContext(ECDHClientKeyExchangeMessage message);  }
@Test public void testAdjustTLSContext() { context.setSelectedProtocolVersion(ProtocolVersion.TLS12); context.setSelectedCipherSuite(CipherSuite.TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256); context.setClientRandom(new byte[] {}); context.setServerRandom(new byte[] {}); context.getConfig().setDefaultSelectedNamedGroup(NamedGroup.SECP192R1); context.setSelectedGroup(NamedGroup.SECP192R1); context.setServerEcPublicKey(Point.createPoint(new BigInteger( "1336698681267683560144780033483217462176613397209956026562"), new BigInteger( "4390496211885670837594012513791855863576256216444143941964"), NamedGroup.SECP192R1)); context.getConfig().setDefaultClientEcPrivateKey(new BigInteger("3")); context.getConfig().setDefaultServerEcPrivateKey(new BigInteger("3")); context.setRecordLayer(new TlsRecordLayer(context)); ECDHClientKeyExchangeMessage message = new ECDHClientKeyExchangeMessage(context.getConfig()); ECDHClientKeyExchangePreparator prep = new ECDHClientKeyExchangePreparator(context.getChooser(), message); prep.prepare(); handler.adjustTLSContext(message); assertArrayEquals(ArrayConverter.hexStringToByteArray("273CF78A3DB2E37EE97935DEF45E3C82F126807C31A498E9"), context.getPreMasterSecret()); assertArrayEquals( ArrayConverter .hexStringToByteArray("5686D5F789AEDC43162480112E94C7C60F1292B1C5D688AE58F237BD054594775B94AC5F0B18A01B808ADBBE78BCC8C7"), context.getMasterSecret()); }