Source:
private void receivedServerHelloDone(ServerHelloDone message) throws HandshakeException, GeneralSecurityException { flightNumber += 2; PskPublicInformation clientIdentity; PskSecretResult masterSecretResult; XECDHECryptography ecdhe = serverKeyExchange == null ? null : new XECDHECryptography(serverKeyExchange.getSupportedGroup()); switch (getKeyExchangeAlgorithm()) { case EC_DIFFIE_HELLMAN: clientKeyExchange = new ECDHClientKeyExchange(ecdhe.getEncodedPoint(), session.getPeer()); SecretKey premasterSecret = ecdhe.generateSecret(serverKeyExchange.getEncodedPoint()); SecretKey masterSecret = PseudoRandomFunction.generateMasterSecret(session.getCipherSuite().getThreadLocalPseudoRandomFunctionMac(), premasterSecret, generateRandomSeed()); SecretUtil.destroy(premasterSecret); processMasterSecret(masterSecret); break; case PSK: clientIdentity = getPskClientIdentity(); LOGGER.debug("Using PSK identity: {}", clientIdentity); clientKeyExchange = new PSKClientKeyExchange(clientIdentity, session.getPeer()); masterSecretResult = requestPskSecretResult(clientIdentity, null); if (masterSecretResult != null) { processPskSecretResult(masterSecretResult); } break; case ECDHE_PSK: clientIdentity = getPskClientIdentity(); LOGGER.debug("Using PSK identity: {}", clientIdentity); clientKeyExchange = new EcdhPskClientKeyExchange(clientIdentity, ecdhe.getEncodedPoint(), session.getPeer()); SecretKey otherSecret = ecdhe.generateSecret(serverKeyExchange.getEncodedPoint()); masterSecretResult = requestPskSecretResult(clientIdentity, otherSecret); SecretUtil.destroy(otherSecret); if (masterSecretResult != null) { processPskSecretResult(masterSecretResult); } break; default: throw new HandshakeException( "Unknown key exchange algorithm: " + getKeyExchangeAlgorithm(), new AlertMessage(AlertLevel.FATAL, AlertDescription.HANDSHAKE_FAILURE, session.getPeer())); } SecretUtil.destroy(ecdhe); }

Target:
private void receivedServerHelloDone(ServerHelloDone message) throws HandshakeException, GeneralSecurityException { flightNumber += 2; PskPublicInformation clientIdentity; PskSecretResult masterSecretResult; XECDHECryptography ecdhe = serverKeyExchange == null ? null : new XECDHECryptography(serverKeyExchange.getSupportedGroup()); switch (getKeyExchangeAlgorithm()) { case EC_DIFFIE_HELLMAN: clientKeyExchange = new ECDHClientKeyExchange(ecdhe.getEncodedPoint(), session.getPeer()); SecretKey premasterSecret = ecdhe.generateSecret(serverKeyExchange.getEncodedPoint()); SecretKey masterSecret = PseudoRandomFunction.generateMasterSecret(session.getCipherSuite().getThreadLocalPseudoRandomFunctionMac(), premasterSecret, generateRandomSeed()); SecretUtil.destroy(premasterSecret); processMasterSecret(masterSecret); break; case PSK: clientIdentity = getPskClientIdentity(); LOGGER.trace("Using PSK identity: {}", clientIdentity); clientKeyExchange = new PSKClientKeyExchange(clientIdentity, session.getPeer()); masterSecretResult = requestPskSecretResult(clientIdentity, null); if (masterSecretResult != null) { processPskSecretResult(masterSecretResult); } break; case ECDHE_PSK: clientIdentity = getPskClientIdentity(); LOGGER.trace("Using ECDHE PSK identity: {}", clientIdentity); clientKeyExchange = new EcdhPskClientKeyExchange(clientIdentity, ecdhe.getEncodedPoint(), session.getPeer()); SecretKey otherSecret = ecdhe.generateSecret(serverKeyExchange.getEncodedPoint()); masterSecretResult = requestPskSecretResult(clientIdentity, otherSecret); SecretUtil.destroy(otherSecret); if (masterSecretResult != null) { processPskSecretResult(masterSecretResult); } break; default: throw new HandshakeException( "Unknown key exchange algorithm: " + getKeyExchangeAlgorithm(), new AlertMessage(AlertLevel.FATAL, AlertDescription.HANDSHAKE_FAILURE, session.getPeer())); } SecretUtil.destroy(ecdhe); }