@Override protected HelloRetryRequestMessage createHandshakeMessage() { return new HelloRetryRequestMessage(); }
protected void parseProtocolVersion(HelloRetryRequestMessage message) { message.setProtocolVersion(parseByteArrayField(HandshakeByteLength.VERSION)); LOGGER.debug("ProtocolVersion:" + ArrayConverter.bytesToHexString(message.getProtocolVersion().getValue())); }
protected void parseSelectedCiphersuite(HelloRetryRequestMessage message) { message.setSelectedCipherSuite(parseByteArrayField(HandshakeByteLength.CIPHER_SUITE)); LOGGER.debug("CipherSuite:" + ArrayConverter.bytesToHexString(message.getSelectedCipherSuite().getValue())); }
protected void writeProtocolVersion() { appendBytes(msg.getProtocolVersion().getValue()); LOGGER.debug("ProtocolVersion: " + ArrayConverter.bytesToHexString(msg.getProtocolVersion().getValue())); }
protected void writeSelectedCiphersuite() { appendBytes(msg.getSelectedCipherSuite().getValue()); LOGGER.debug("SelectedCipherSuite: " + ArrayConverter.bytesToHexString(msg.getSelectedCipherSuite().getValue())); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("HelloRetryRequestMessage:"); sb.append("\n Protocol Version: "); if (protocolVersion != null && protocolVersion.getValue() != null) { sb.append(ProtocolVersion.getProtocolVersion(protocolVersion.getValue())); } else { sb.append("null"); } sb.append("\n Selected Cipher Suite: "); if (selectedCipherSuite != null && selectedCipherSuite.getValue() != null) { sb.append(CipherSuite.getCipherSuite(selectedCipherSuite.getValue())).append("\n Extensions: "); } else { sb.append("null"); } sb.append("\n Extensions: "); if (getExtensions() == null) { sb.append("null"); } else { for (ExtensionMessage e : getExtensions()) { sb.append("\n ").append(e.toString()); } } return sb.toString(); }
private void adjustProtocolVersion(HelloRetryRequestMessage message) { ProtocolVersion 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 adjustSelectedCiphersuite(HelloRetryRequestMessage message) { CipherSuite suite = CipherSuite.getCipherSuite(message.getSelectedCipherSuite().getValue()); tlsContext.setSelectedCipherSuite(suite); if (suite != null) { LOGGER.debug("Set SelectedCipherSuite in Context to " + suite.name()); } else { LOGGER.warn("Could not determine selected CipherSuite. Not Adjusting Context"); } }
@Override public void adjustTLSContext(HelloRetryRequestMessage message) { adjustProtocolVersion(message); adjustSelectedCiphersuite(message); if (message.getExtensions() != null) { for (ExtensionMessage extension : message.getExtensions()) { HandshakeMessageType handshakeMessageType = HandshakeMessageType.HELLO_RETRY_REQUEST; if (extension instanceof KeyShareExtensionMessage) { handshakeMessageType = HandshakeMessageType.CLIENT_HELLO; } ExtensionHandler handler = HandlerFactory.getExtensionHandler(tlsContext, extension.getExtensionTypeConstant(), handshakeMessageType); handler.adjustTLSContext(extension); } } }
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 prepareProtocolVersion() { ProtocolVersion ourVersion = chooser.getConfig().getHighestProtocolVersion(); if (chooser.getConfig().isEnforceSettings()) { msg.setProtocolVersion(ourVersion.getValue()); } else { msg.setProtocolVersion(ProtocolVersion.TLS13.getValue()); } LOGGER.debug("ProtocolVersion: " + ArrayConverter.bytesToHexString(msg.getProtocolVersion().getValue())); }