/** * Reads the next bytes as the CipherSuites and writes them in the message * * @param message * Message to write in */ private void parseCipherSuites(SSL2ServerHelloMessage message) { message.setCipherSuites(parseByteArrayField(message.getCipherSuitesLength().getValue())); LOGGER.debug("CipherSuites: " + ArrayConverter.bytesToHexString(message.getCipherSuites().getValue())); }
/** * Reads the next bytes as the Certificate and writes them in the message * * @param message * Message to write in */ private void parseCertificate(SSL2ServerHelloMessage message) { message.setCertificate(parseByteArrayField(message.getCertificateLength().getValue())); LOGGER.debug("Certificate: " + ArrayConverter.bytesToHexString(message.getCertificate().getValue())); }
/** * Reads the next bytes as the CertificateType and writes them in the * message * * @param message * Message to write in */ private void parseCertificateType(SSL2ServerHelloMessage message) { message.setCertificateType(parseByteField(SSL2ByteLength.CERTIFICATE_TYPE)); LOGGER.debug("CertificateType: " + message.getCertificateType().getValue()); }
/** * Reads the next bytes as the CertificateLength and writes them in the * message * * @param message * Message to write in */ private void parseCertificateLength(SSL2ServerHelloMessage message) { message.setCertificateLength(parseIntField(SSL2ByteLength.CERTIFICATE_LENGTH)); LOGGER.debug("CertificateLength: " + message.getCertificateLength().getValue()); }
/** * Reads the next bytes as the CipherSuitesLength and writes them in the * message * * @param message * Message to write in */ private void parseCipherSuitesLength(SSL2ServerHelloMessage message) { message.setCipherSuitesLength(parseIntField(SSL2ByteLength.CIPHERSUITE_LENGTH)); LOGGER.debug("CipherSuitesLength: " + message.getCipherSuitesLength().getValue()); }
sb.append("SSL2ServerHelloMessage:"); sb.append("\n Protocol Version: "); if (getProtocolVersion() != null && getProtocolVersion().getValue() != null) { sb.append(ProtocolVersion.getProtocolVersion(getProtocolVersion().getValue())); } else { sb.append("null"); if (getType() != null && getType().getValue() != null) { sb.append(getType().getValue()); } else { sb.append("null"); if (getCipherSuites() != null && getCipherSuites().getValue() != null) { sb.append(ArrayConverter.bytesToHexString(getCipherSuites().getValue())); } else { sb.append("null"); if (getSessionIdHit() != null && getSessionIdHit().getValue() != null) { sb.append(getSessionIdHit().getValue()); } else { sb.append("null"); if (getCertificate() != null && getCertificate().getValue() != null) { sb.append(ArrayConverter.bytesToHexString(getCertificate().getValue())); } else { sb.append("null"); if (getSessionId() != null && getSessionId().getValue() != null) { sb.append(ArrayConverter.bytesToHexString(getSessionId().getValue()));
/** * Reads the next bytes as the SessionID and writes them in the message * * @param message * Message to write in */ private void parseSessionID(SSL2ServerHelloMessage message) { message.setSessionID(parseByteArrayField(message.getSessionIdLength().getValue())); LOGGER.debug("SessionID: " + ArrayConverter.bytesToHexString(message.getSessionId().getValue())); } }
@Override public void adjustTLSContext(SSL2ServerHelloMessage message) { byte[] serverRandom = message.getSessionId().getValue(); if (serverRandom != null) { tlsContext.setServerRandom(serverRandom); } Certificate cert = parseCertificate(message.getCertificateLength().getValue(), message.getCertificate() .getValue()); LOGGER.debug("Setting ServerCertificate in Context"); tlsContext.setServerCertificate(cert); if (cert == null || !CertificateUtils.hasRSAParameters(cert)) { LOGGER.error("Cannot parse Certificate from SSL2ServerHello"); } else { LOGGER.debug("Adjusting RSA PublicKey"); try { tlsContext.setServerRSAPublicKey(CertificateUtils.extractRSAPublicKey(cert)); tlsContext.setServerRsaModulus(CertificateUtils.extractRSAModulus(cert)); } catch (IOException e) { throw new AdjustmentException("Could not adjust PublicKey Information from Certificate", e); } } } }
/** * Writes the CipherSuites of the SSL2ServerHello into the final byte[] */ private void writeCipherSuites(SSL2ServerHelloMessage message) { appendBytes(message.getCipherSuites().getValue()); LOGGER.debug("CipherSuites: " + ArrayConverter.bytesToHexString(message.getCipherSuites().getValue())); }
/** * Reads the next bytes as the SessionIdHit and writes them in the message * * @param message * Message to write in */ private void parseSessionIdHit(SSL2ServerHelloMessage message) { message.setSessionIdHit(parseByteField(SSL2ByteLength.SESSION_ID_HIT)); LOGGER.debug("SessionIdHit: " + message.getSessionIdHit().getValue()); }
/** * Reads the next bytes as the ProtocolVersion and writes them in the * message * * @param message * Message to write in */ private void parseProtocolVersion(SSL2ServerHelloMessage message) { message.setProtocolVersion(parseByteArrayField(SSL2ByteLength.VERSION)); LOGGER.debug("ProtocolVersion: " + ArrayConverter.bytesToHexString(message.getProtocolVersion().getValue())); }
@Override protected SSL2ServerHelloMessage parseMessageContent() { LOGGER.debug("Parsing SSL2ServerHello"); SSL2ServerHelloMessage message = new SSL2ServerHelloMessage(); parseMessageLength(message); parseType(message); parseSessionIdHit(message); parseCertificateType(message); parseProtocolVersion(message); parseCertificateLength(message); parseCipherSuitesLength(message); parseSessionIDLength(message); parseCertificate(message); parseCipherSuites(message); parseSessionID(message); return message; }
/** * Writes the SessionIdHit of the SSL2ServerHello into the final byte[] */ private void writeSessionIdHit(SSL2ServerHelloMessage message) { appendByte(message.getSessionIdHit().getValue()); LOGGER.debug("SessionIdHit: " + message.getSessionIdHit().getValue()); }
/** * Writes the MessageLength of the SSL2ServerHello into the final byte[] */ private void writeMessageLength(SSL2ServerHelloMessage message) { appendInt(message.getMessageLength().getValue(), SSL2ByteLength.LENGTH); LOGGER.debug("MessageLength: " + message.getMessageLength().getValue()); }
/** * Writes the CertificateType of the SSL2ServerHello into the final byte[] */ private void writeCetificateType(SSL2ServerHelloMessage message) { appendByte(message.getCertificateType().getValue()); LOGGER.debug("CertificateType: " + message.getCertificateType().getValue()); }
/** * Writes the CipherSuitesLength of the SSL2ServerHello into the final * byte[] */ private void writeCipherSuitesLength(SSL2ServerHelloMessage message) { appendInt(message.getCipherSuitesLength().getValue(), SSL2ByteLength.CIPHERSUITE_LENGTH); LOGGER.debug("ChipherSuitesLength: " + message.getCipherSuitesLength().getValue()); }
/** * Writes the CertificateLength of the SSL2ServerHello into the final byte[] */ private void writeCertificateLength(SSL2ServerHelloMessage message) { appendInt(message.getCertificateLength().getValue(), SSL2ByteLength.CERTIFICATE_LENGTH); LOGGER.debug("CertificateLength: " + message.getCertificateLength().getValue()); }
/** * Writes the ProtocolVersion of the SSL2ServerHello into the final byte[] */ private void writeProtocolVersion(SSL2ServerHelloMessage message) { appendBytes(message.getProtocolVersion().getValue()); LOGGER.debug("ProtocolVersion: " + ArrayConverter.bytesToHexString(message.getProtocolVersion().getValue())); }
/** * Writes the Certificate of the SSL2ServerHello into the final byte[] */ private void writeCertificate(SSL2ServerHelloMessage message) { appendBytes(message.getCertificate().getValue()); LOGGER.debug("Certificate: " + ArrayConverter.bytesToHexString(message.getCertificate().getValue())); }
/** * Writes the SessionID of the SSL2ServerHello into the final byte[] */ private void writeSessionID(SSL2ServerHelloMessage message) { appendBytes(message.getSessionId().getValue()); LOGGER.debug("SessionID: " + ArrayConverter.bytesToHexString(message.getSessionId().getValue())); }