@Override protected ServerHelloMessage createHandshakeMessage() { return new ServerHelloMessage(); } }
sb.append("ServerHelloMessage:"); sb.append("\n Protocol Version: "); if (getProtocolVersion() != null) { sb.append(ProtocolVersion.getProtocolVersion(getProtocolVersion().getValue())); } else { sb.append("null"); if (getProtocolVersion() != null) { if (!ProtocolVersion.getProtocolVersion(getProtocolVersion().getValue()).isTLS13()) { sb.append(new Date(ArrayConverter.bytesToLong(getUnixTime().getValue()) * 1000)); } else { sb.append("null"); if (getRandom() != null) { sb.append(ArrayConverter.bytesToHexString(getRandom().getValue())); } else { sb.append("null"); if (getProtocolVersion() != null && getProtocolVersion().getValue() != null) { if (!ProtocolVersion.getProtocolVersion(getProtocolVersion().getValue()).isTLS13()) { sb.append(ArrayConverter.bytesToHexString(getSessionId().getValue())); } else { sb.append("null"); if (getProtocolVersion() != null && getProtocolVersion().getValue() != null) { if (!ProtocolVersion.getProtocolVersion(getProtocolVersion().getValue()).isTLS13()) { sb.append(CompressionMethod.getCompressionMethod(selectedCompressionMethod.getValue())); } else {
/** * Writes the SelectedCiphersuite of the message into the final byte[] */ protected void writeSelectedCiphersuite() { appendBytes(msg.getSelectedCipherSuite().getValue()); LOGGER.debug("SelectedCipherSuite: " + ArrayConverter.bytesToHexString(msg.getSelectedCipherSuite().getValue())); }
private void prepareSessionID() { if (chooser.getSelectedProtocolVersion().isTLS13()) { msg.setSessionId(new byte[0]); } else { msg.setSessionId(chooser.getServerSessionId()); } LOGGER.debug("SessionID: " + ArrayConverter.bytesToHexString(msg.getSessionId().getValue())); }
private void prepareCipherSuite() { if (chooser.getConfig().isEnforceSettings()) { msg.setSelectedCipherSuite(chooser.getConfig().getDefaultSelectedCipherSuite().getByteValue()); } else { CipherSuite selectedSuite = null; for (CipherSuite suite : chooser.getConfig().getDefaultServerSupportedCiphersuites()) { if (chooser.getClientSupportedCiphersuites().contains(suite)) { selectedSuite = suite; break; } } if (selectedSuite == null) { throw new WorkflowExecutionException("No Ciphersuites in common"); } msg.setSelectedCipherSuite(selectedSuite.getByteValue()); } LOGGER.debug("SelectedCipherSuite: " + ArrayConverter.bytesToHexString(msg.getSelectedCipherSuite().getValue())); }
private void prepareCompressionMethod() { if (chooser.getConfig().isEnforceSettings()) { msg.setSelectedCompressionMethod(chooser.getConfig().getDefaultSelectedCompressionMethod().getValue()); } else { CompressionMethod selectedCompressionMethod = null; for (CompressionMethod method : chooser.getConfig().getDefaultServerSupportedCompressionMethods()) { if (chooser.getClientSupportedCompressions().contains(method)) { selectedCompressionMethod = method; break; } } if (selectedCompressionMethod == null) { throw new WorkflowExecutionException("No Compression in common"); } msg.setSelectedCompressionMethod(selectedCompressionMethod.getValue()); } LOGGER.debug("SelectedCompressionMethod: " + msg.getSelectedCompressionMethod().getValue()); }
int intRepresentationClientVersion = clientVersion.getValue()[0] * 0x100 + clientVersion.getValue()[1]; if (chooser.getConfig().isEnforceSettings()) { msg.setProtocolVersion(ourVersion.getValue()); } else { if (chooser.getHighestClientProtocolVersion().isDTLS() msg.setProtocolVersion(ourVersion.getValue()); } else { msg.setProtocolVersion(clientVersion.getValue()); msg.setProtocolVersion(ourVersion.getValue()); } else { msg.setProtocolVersion(clientVersion.getValue()); msg.setProtocolVersion(chooser.getSelectedProtocolVersion().getValue()); LOGGER.debug("ProtocolVersion: " + ArrayConverter.bytesToHexString(msg.getProtocolVersion().getValue()));
/** * Writes the SelectedCompressionMethod of the message into the final byte[] */ protected void writeSelectedComressionMethod() { appendByte(msg.getSelectedCompressionMethod().getValue()); LOGGER.debug("SelectedCompressionMethod: " + msg.getSelectedCompressionMethod().getValue()); }
private void adjustSelectedProtocolVersion(ServerHelloMessage message) { ProtocolVersion version = null; if (message.getProtocolVersion() != null) { version = ProtocolVersion.getProtocolVersion(message.getProtocolVersion().getValue()); } if (version != null) { tlsContext.setSelectedProtocolVersion(version); LOGGER.debug("Set SelectedProtocolVersion in Context to " + version.name()); } else { LOGGER.warn("Did not Adjust ProtocolVersion since version is undefined " + ArrayConverter.bytesToHexString(message.getProtocolVersion().getValue())); } }
private void adjustSelectedSessionID(ServerHelloMessage message) { byte[] sessionID = message.getSessionId().getValue(); tlsContext.setServerSessionId(sessionID); LOGGER.debug("Set SessionID in Context to " + ArrayConverter.bytesToHexString(sessionID, false)); }
private void adjustServerRandom(ServerHelloMessage message) { tlsContext.setServerRandom(message.getRandom().getValue()); LOGGER.debug("Set ServerRandom in Context to " + ArrayConverter.bytesToHexString(tlsContext.getServerRandom())); }
public ServerHelloMessage(Config tlsConfig) { super(tlsConfig, HandshakeMessageType.SERVER_HELLO); if (tlsConfig.isAddHeartbeatExtension()) { addExtension(new HeartbeatExtensionMessage()); addExtension(new ECPointFormatExtensionMessage()); addExtension(new MaxFragmentLengthExtensionMessage()); pair.setServerNameConfig(tlsConfig.getSniHostname().getBytes()); extension.getServerNameList().add(pair); addExtension(extension); addExtension(new KeyShareExtensionMessage(ExtensionType.KEY_SHARE_OLD, tlsConfig)); } else { addExtension(new KeyShareExtensionMessage(ExtensionType.KEY_SHARE, tlsConfig)); addExtension(new ExtendedMasterSecretExtensionMessage()); addExtension(new SessionTicketTLSExtensionMessage()); addExtension(new SignedCertificateTimestampExtensionMessage()); addExtension(new PaddingExtensionMessage()); addExtension(new RenegotiationInfoExtensionMessage()); addExtension(new TokenBindingExtensionMessage()); addExtension(new CertificateStatusRequestExtensionMessage());
private void adjustSelectedCompression(ServerHelloMessage message) { CompressionMethod method = null; if (message.getSelectedCompressionMethod() != null) { method = CompressionMethod.getCompressionMethod(message.getSelectedCompressionMethod().getValue()); } if (method != null) { tlsContext.setSelectedCompressionMethod(method); LOGGER.debug("Set SelectedCompressionMethod in Context to " + method.name()); } else { LOGGER.warn("Not adjusting CompressionMethod - Method is null!"); } }
@Override protected void parseHandshakeMessageContent(ServerHelloMessage msg) { LOGGER.debug("Parsing ServerHelloMessage"); parseProtocolVersion(msg); ProtocolVersion version = ProtocolVersion.getProtocolVersion(msg.getProtocolVersion().getValue()); if (version != null) { setVersion(version); } parseRandom(msg); if (!getVersion().isTLS13()) { parseSessionIDLength(msg); parseSessionID(msg); } parseSelectedCiphersuite(msg); if (!getVersion().isTLS13()) { parseSelectedComressionMethod(msg); } if (hasExtensionLengthField(msg)) { parseExtensionLength(msg); if (hasExtensions(msg)) { parseExtensionBytes(msg); } } }
serverHello = new ServerHelloMessage(); encExtMsg = new EncryptedExtensionsMessage(); encExtMsg.addExtension(new EarlyDataExtensionMessage()); } else { serverHello = new ServerHelloMessage(config); encExtMsg = new EncryptedExtensionsMessage(config); encExtMsg.addExtension(new EarlyDataExtensionMessage());
private void adjustSelectedCiphersuite(ServerHelloMessage message) { CipherSuite suite = null; if (message.getSelectedCipherSuite() != null) { suite = CipherSuite.getCipherSuite(message.getSelectedCipherSuite().getValue()); } if (suite != null) { tlsContext.setSelectedCipherSuite(suite); LOGGER.debug("Set SelectedCipherSuite in Context to " + suite.name()); } else { LOGGER.warn("Unknown CipherSuite, did not adjust Context"); } }
private WorkflowTrace createShortHelloWorkflow() { AliasedConnection connection = getConnection(); WorkflowTrace trace = new WorkflowTrace(); if (config.getStarttlsType() != StarttlsType.NONE) { addStartTlsActions(connection, config.getStarttlsType(), trace); } trace.addTlsAction(MessageActionFactory.createAction(connection, ConnectionEndType.CLIENT, new ClientHelloMessage(config))); trace.addTlsAction(MessageActionFactory.createAction(connection, ConnectionEndType.SERVER, new ServerHelloMessage(config))); return trace; }
messages.add(new ServerHelloMessage(config));
messageList.add(new ServerHelloMessage(tlsConfig)); messageList.add(new CertificateMessage(tlsConfig)); messageList.add(new ServerHelloDoneMessage(tlsConfig));
private WorkflowTrace createResumptionWorkflow() { AliasedConnection connection = getConnection(); WorkflowTrace trace = new WorkflowTrace(); MessageAction action = MessageActionFactory.createAction(connection, ConnectionEndType.CLIENT, new ClientHelloMessage(config)); trace.addTlsAction(action); action = MessageActionFactory.createAction(connection, ConnectionEndType.SERVER, new ServerHelloMessage(config), new ChangeCipherSpecMessage(config), new FinishedMessage(config)); trace.addTlsAction(action); action = MessageActionFactory.createAction(connection, ConnectionEndType.CLIENT, new ChangeCipherSpecMessage( config), new FinishedMessage(config)); trace.addTlsAction(action); return trace; }