@Override protected ClientHelloMessage createHandshakeMessage() { return new ClientHelloMessage(); }
private void prepareCipherSuitesLength(ClientHelloMessage msg) { msg.setCipherSuiteLength(msg.getCipherSuites().getValue().length); LOGGER.debug("CipherSuitesLength: " + msg.getCipherSuiteLength().getValue()); }
private void prepareCompressionLength(ClientHelloMessage msg) { msg.setCompressionLength(msg.getCompressions().getValue().length); LOGGER.debug("CompressionLength: " + msg.getCompressionLength().getValue()); }
private void prepareCookieLength(ClientHelloMessage msg) { msg.setCookieLength((byte) msg.getCookie().getValue().length); LOGGER.debug("CookieLength: " + msg.getCookieLength().getValue()); }
private void removeExtensions(TlsContext ctx, ClientHelloMessage ch) { if (ch.getExtensions() == null) { return; List<ExtensionMessage> extensions = ch.getExtensions(); List<ExtensionMessage> markedForRemoval = new ArrayList<>(); ByteArrayOutputStream newExtensionBytes = new ByteArrayOutputStream(); String msg_name = ch.toCompactString(); int msgLength = ch.getLength().getValue(); int origExtLength = ch.getExtensionBytes().getValue().length; ch.setExtensionBytes(newExtensionBytes.toByteArray()); extensions.removeAll(markedForRemoval); int newExtLength = ch.getExtensionBytes().getValue().length; int diffExtLength = origExtLength - newExtLength; ch.setLength(msgLength - diffExtLength); ch.setExtensionsLength(newExtLength);
sb.append("ClientHelloMessage:"); sb.append("\n Protocol Version: "); if (getProtocolVersion() != null && getProtocolVersion().getValue() != null) { sb.append(ProtocolVersion.getProtocolVersion(getProtocolVersion().getValue())); } else { sb.append("null"); if (getUnixTime() != null && getUnixTime().getValue() != null) { sb.append(new Date(ArrayConverter.bytesToLong(getUnixTime().getValue()) * 1000)); } else { sb.append("null"); if (getRandom() != null && getRandom().getValue() != null) { sb.append(ArrayConverter.bytesToHexString(getRandom().getValue())); } else { sb.append("null"); if (getSessionId() != null && getSessionId().getValue() != null) { sb.append(ArrayConverter.bytesToHexString(getSessionId().getValue())); } else { sb.append("null"); if (getCipherSuites() != null && getCipherSuites().getValue() != null) { sb.append(ArrayConverter.bytesToHexString(getCipherSuites().getValue())); } else { sb.append("null"); if (getCompressions() != null && getCompressions().getValue() != null) { sb.append(ArrayConverter.bytesToHexString(getCompressions().getValue()));
private void removeCiphers(TlsContext ctx, ClientHelloMessage ch) { String msg_name = ch.toCompactString(); if (ch.getCipherSuites() == null) { LOGGER.debug("No cipher suites found in " + msg_name + ". Nothing to do."); return; byte[] ciphersBytes = ch.getCipherSuites().getValue(); List<CipherSuite> ciphers = CipherSuite.getCiphersuites(ciphersBytes); int origCiphersLength = ciphersBytes.length; ch.setCipherSuites(newCiphersBytes.toByteArray()); int newSuitesLength = ch.getCipherSuites().getValue().length; int diffSuitesLength = origCiphersLength - newSuitesLength; int newMsgLength = ch.getLength().getValue() - diffSuitesLength; ch.setLength(newMsgLength); ch.setCipherSuiteLength(newSuitesLength);
/** * Reads the next bytes as the CypherSuites and writes them in the message * * @param msg * Message to write in */ private void parseCipherSuites(ClientHelloMessage msg) { msg.setCipherSuites(parseByteArrayField(msg.getCipherSuiteLength().getValue())); LOGGER.debug("CipherSuites: " + ArrayConverter.bytesToHexString(msg.getCipherSuites().getValue())); }
/** * Reads the next bytes as the Compression and writes them in the message * * @param msg * Message to write in */ private void parseCompressions(ClientHelloMessage message) { message.setCompressions(parseByteArrayField(message.getCompressionLength().getValue())); LOGGER.debug("Compressions: " + ArrayConverter.bytesToHexString(message.getCompressions().getValue())); } }
/** * Summarize the extension data for pretty printing. * * @return a summary of the extension information contained in the CH * message */ public String summarizeExtensions(ClientHelloMessage ch) { StringBuilder sb = new StringBuilder(); sb.append("message length: ").append(ch.getLength().getValue()); sb.append("\nextension bytes length: ").append(ch.getExtensionBytes().getValue().length); sb.append("\nextension bytes:"); sb.append(ArrayConverter.bytesToHexString(ch.getExtensionBytes().getValue())); sb.append("\nreadable extension list:\n"); for (ExtensionMessage ext : ch.getExtensions()) { sb.append(ext.getExtensionTypeConstant()); sb.append(" (").append(ext.getExtensionBytes().toString()).append(")\n"); } return sb.toString(); }
if (config.getHighestProtocolVersion() == ProtocolVersion.DTLS10 || config.getHighestProtocolVersion() == ProtocolVersion.DTLS12) { clientHello = new ClientHelloMessage(config); clientHello.setIncludeInDigest(false); } else { clientHello = new ClientHelloMessage(config); workflowTrace.addTlsAction(MessageActionFactory .createAction(connection, ConnectionEndType.SERVER, messages)); clientHello = new ClientHelloMessage(config); messages = new LinkedList<>(); messages.add(clientHello);
/** * Reads the next bytes as the CypherSuiteLength and writes them in the * message * * @param msg * Message to write in */ private void parseCipherSuiteLength(ClientHelloMessage msg) { msg.setCipherSuiteLength(parseIntField(HandshakeByteLength.CIPHER_SUITES_LENGTH)); LOGGER.debug("CipherSuiteLength: " + msg.getCipherSuiteLength().getValue()); }
/** * Reads the next bytes as the CompressionLength and writes them in the * message * * @param msg * Message to write in */ private void parseCompressionLength(ClientHelloMessage message) { message.setCompressionLength(parseIntField(HandshakeByteLength.COMPRESSION_LENGTH)); LOGGER.debug("CompressionLength: " + message.getCompressionLength().getValue()); }
private void prepareCipherSuites(ClientHelloMessage msg) { msg.setCipherSuites(convertCipherSuites(chooser.getConfig().getDefaultClientSupportedCiphersuites())); LOGGER.debug("CipherSuites: " + ArrayConverter.bytesToHexString(msg.getCipherSuites().getValue())); }
private void prepareCompressions(ClientHelloMessage msg) { if (chooser.getConfig().getHighestProtocolVersion().isTLS13()) { msg.setCompressions(CompressionMethod.NULL.getArrayValue()); } else { msg.setCompressions(convertCompressions(chooser.getConfig().getDefaultClientSupportedCompressionMethods())); } LOGGER.debug("Compressions: " + ArrayConverter.bytesToHexString(msg.getCompressions().getValue())); }
/** * Writes the CihperSuites of the ClientHelloMessage into the final byte[] */ private void writeCipherSuites(ClientHelloMessage msg) { appendBytes(msg.getCipherSuites().getValue()); LOGGER.debug("CipherSuite: " + ArrayConverter.bytesToHexString(msg.getCipherSuites().getValue())); }
private boolean isCookieFieldSet(ClientHelloMessage message) { return message.getCookie() != null; }
/** * Writes the Compressions of the ClientHelloMessage into the final byte[] */ private void writeCompressions(ClientHelloMessage msg) { appendBytes(msg.getCompressions().getValue()); LOGGER.debug("Compressions: " + ArrayConverter.bytesToHexString(msg.getCompressions().getValue())); }
/** * Writes the CompressionLength of the ClientHelloMessage into the final * byte[] */ private void writeCompressionLength(ClientHelloMessage msg) { appendInt(msg.getCompressionLength().getValue(), HandshakeByteLength.COMPRESSION_LENGTH); LOGGER.debug("CompressionLength: " + msg.getCompressionLength().getValue()); }