PskEcDheServerKeyExchangeHandler extends ECDHEServerKeyExchangeHandler<PskEcDheServerKeyExchangeMessage> { @Override public void adjustTLSContext(PskEcDheServerKeyExchangeMessage message) { super.adjustECParameter(message); if (message.getComputations() != null) { tlsContext.setServerEcPrivateKey(message.getComputations().getPrivateKey().getValue()); } } PskEcDheServerKeyExchangeHandler(TlsContext tlsContext); @Override PskEcDheServerKeyExchangeParser getParser(byte[] message, int pointer); @Override PskEcDheServerKeyExchangePreparator getPreparator(PskEcDheServerKeyExchangeMessage message); @Override PskEcDheServerKeyExchangeSerializer getSerializer(PskEcDheServerKeyExchangeMessage message); @Override void adjustTLSContext(PskEcDheServerKeyExchangeMessage message);  }
@Test public void testAdjustTLSContext() { PskEcDheServerKeyExchangeMessage message = new PskEcDheServerKeyExchangeMessage(); message.setCurveType(EllipticCurveType.NAMED_CURVE.getValue()); message.setNamedGroup(NamedGroup.SECP256R1.getValue()); message.setPublicKey(ArrayConverter .hexStringToByteArray("04f660a88e9dae015684be56c25610f9c62cf120cb075eea60c560e5e6dd5d10ef6e391d7213a298985470dc2268949317ce24940d474a0c8386ab13b312ffc104")); message.setPublicKeyLength(65); message.prepareComputations(); message.getComputations().setPremasterSecret(new byte[] { 0, 1, 2, 3 }); message.getComputations().setPrivateKey(new BigInteger("12345")); handler.adjustTLSContext(message); assertNull(context.getPreMasterSecret()); }
@Test public void testAdjustTLSContextWithoutComputations() { PskEcDheServerKeyExchangeMessage message = new PskEcDheServerKeyExchangeMessage(); message.setCurveType(EllipticCurveType.NAMED_CURVE.getValue()); message.setNamedGroup(NamedGroup.SECP256R1.getValue()); message.setPublicKey(ArrayConverter .hexStringToByteArray("04f660a88e9dae015684be56c25610f9c62cf120cb075eea60c560e5e6dd5d10ef6e391d7213a298985470dc2268949317ce24940d474a0c8386ab13b312ffc104")); message.setPublicKeyLength(65); handler.adjustTLSContext(message); assertNull(context.getPreMasterSecret()); assertNull(context.getMasterSecret()); }