@Test public void testAdjustTLSContext() { ServerHelloMessage message = new ServerHelloMessage(); message.setUnixTime(new byte[] { 0, 1, 2 }); message.setRandom(new byte[] { 0, 1, 2, 3, 4, 5 }); message.setSelectedCompressionMethod(CompressionMethod.DEFLATE.getValue()); message.setSelectedCipherSuite(CipherSuite.TLS_CECPQ1_ECDSA_WITH_AES_256_GCM_SHA384.getByteValue()); message.setSessionId(new byte[] { 6, 6, 6 }); message.setProtocolVersion(ProtocolVersion.TLS12.getValue()); handler.adjustTLSContext(message); assertArrayEquals(context.getServerRandom(), new byte[] { 0, 1, 2, 3, 4, 5 }); assertTrue(context.getSelectedCompressionMethod() == CompressionMethod.DEFLATE); assertArrayEquals(context.getServerSessionId(), new byte[] { 6, 6, 6 }); assertArrayEquals(context.getSelectedCipherSuite().getByteValue(), CipherSuite.TLS_CECPQ1_ECDSA_WITH_AES_256_GCM_SHA384.getByteValue()); assertArrayEquals(context.getSelectedProtocolVersion().getValue(), ProtocolVersion.TLS12.getValue()); }
@Override public void adjustTLSContext(ServerHelloMessage message) { adjustSelectedProtocolVersion(message); adjustSelectedCompression(message); adjustSelectedSessionID(message); adjustSelectedCiphersuite(message); adjustServerRandom(message); adjustExtensions(message, HandshakeMessageType.SERVER_HELLO); if (!message.isTls13HelloRetryRequest()) { if (tlsContext.getChooser().getSelectedProtocolVersion().isTLS13()) { adjustHandshakeTrafficSecrets(); if (tlsContext.getTalkingConnectionEndType() != tlsContext.getChooser().getConnectionEndType()) { setServerRecordCipher(); } } adjustPRF(message); if (tlsContext.hasSession(tlsContext.getChooser().getServerSessionId())) { LOGGER.info("Resuming Session"); LOGGER.debug("Loading Mastersecret"); Session session = tlsContext.getSession(tlsContext.getChooser().getServerSessionId()); tlsContext.setMasterSecret(session.getMasterSecret()); setRecordCipher(); } } }
ServerHelloHandler extends HandshakeMessageHandler<ServerHelloMessage> { @Override public void adjustTLSContext(ServerHelloMessage message) { adjustSelectedProtocolVersion(message); adjustSelectedCompression(message); adjustSelectedSessionID(message); adjustSelectedCiphersuite(message); adjustServerRandom(message); adjustExtensions(message, HandshakeMessageType.SERVER_HELLO); if (!message.isTls13HelloRetryRequest()) { if (tlsContext.getChooser().getSelectedProtocolVersion().isTLS13()) { adjustHandshakeTrafficSecrets(); if (tlsContext.getTalkingConnectionEndType() != tlsContext.getChooser().getConnectionEndType()) { setServerRecordCipher(); } } adjustPRF(message); if (tlsContext.hasSession(tlsContext.getChooser().getServerSessionId())) { LOGGER.info("Resuming Session"); LOGGER.debug("Loading Mastersecret"); Session session = tlsContext.getSession(tlsContext.getChooser().getServerSessionId()); tlsContext.setMasterSecret(session.getMasterSecret()); setRecordCipher(); } } } }
ServerHelloHandler extends HandshakeMessageHandler<ServerHelloMessage> { @Override public void adjustTLSContext(ServerHelloMessage message) { adjustSelectedProtocolVersion(message); adjustSelectedCompression(message); adjustSelectedSessionID(message); adjustSelectedCiphersuite(message); adjustServerRandom(message); adjustExtensions(message, HandshakeMessageType.SERVER_HELLO); if (!message.isTls13HelloRetryRequest()) { if (tlsContext.getChooser().getSelectedProtocolVersion().isTLS13()) { adjustHandshakeTrafficSecrets(); if (tlsContext.getTalkingConnectionEndType() != tlsContext.getChooser().getConnectionEndType()) { setServerRecordCipher(); } } adjustPRF(message); if (tlsContext.hasSession(tlsContext.getChooser().getServerSessionId())) { LOGGER.info("Resuming Session"); LOGGER.debug("Loading Mastersecret"); Session session = tlsContext.getSession(tlsContext.getChooser().getServerSessionId()); tlsContext.setMasterSecret(session.getMasterSecret()); setRecordCipher(); } } } ServerHelloHandler(TlsContext tlsContext); }
ServerHelloHandler extends HandshakeMessageHandler<ServerHelloMessage> { @Override public void adjustTLSContext(ServerHelloMessage message) { adjustSelectedProtocolVersion(message); adjustSelectedCompression(message); adjustSelectedSessionID(message); adjustSelectedCiphersuite(message); adjustServerRandom(message); adjustExtensions(message, HandshakeMessageType.SERVER_HELLO); if (!message.isTls13HelloRetryRequest()) { if (tlsContext.getChooser().getSelectedProtocolVersion().isTLS13()) { adjustHandshakeTrafficSecrets(); if (tlsContext.getTalkingConnectionEndType() != tlsContext.getChooser().getConnectionEndType()) { setServerRecordCipher(); } } adjustPRF(message); if (tlsContext.hasSession(tlsContext.getChooser().getServerSessionId())) { LOGGER.info("Resuming Session"); LOGGER.debug("Loading Mastersecret"); Session session = tlsContext.getSession(tlsContext.getChooser().getServerSessionId()); tlsContext.setMasterSecret(session.getMasterSecret()); setRecordCipher(); } } } ServerHelloHandler(TlsContext tlsContext); @Override ServerHelloPreparator getPreparator(ServerHelloMessage message); @Override ServerHelloSerializer getSerializer(ServerHelloMessage message); @Override ServerHelloParser getParser(byte[] message, int pointer); @Override void adjustTLSContext(ServerHelloMessage message); @Override void adjustTlsContextAfterSerialize(ServerHelloMessage message); }
ServerHelloHandler extends HandshakeMessageHandler<ServerHelloMessage> { @Override public void adjustTLSContext(ServerHelloMessage message) { adjustSelectedProtocolVersion(message); adjustSelectedCompression(message); adjustSelectedSessionID(message); adjustSelectedCiphersuite(message); adjustServerRandom(message); adjustExtensions(message, HandshakeMessageType.SERVER_HELLO); if (!message.isTls13HelloRetryRequest()) { if (tlsContext.getChooser().getSelectedProtocolVersion().isTLS13()) { adjustHandshakeTrafficSecrets(); if (tlsContext.getTalkingConnectionEndType() != tlsContext.getChooser().getConnectionEndType()) { setServerRecordCipher(); } } adjustPRF(message); if (tlsContext.hasSession(tlsContext.getChooser().getServerSessionId())) { LOGGER.info("Resuming Session"); LOGGER.debug("Loading Mastersecret"); Session session = tlsContext.getSession(tlsContext.getChooser().getServerSessionId()); tlsContext.setMasterSecret(session.getMasterSecret()); setRecordCipher(); } } } ServerHelloHandler(TlsContext tlsContext); @Override ServerHelloPreparator getPreparator(ServerHelloMessage message); @Override ServerHelloSerializer getSerializer(ServerHelloMessage message); @Override ServerHelloParser getParser(byte[] message, int pointer); @Override void adjustTLSContext(ServerHelloMessage message); @Override void adjustTlsContextAfterSerialize(ServerHelloMessage message);  }