Codota Logo
ProtocolMessage
Code IndexAdd Codota to your IDE (free)

How to use
ProtocolMessage
in
de.rub.nds.tlsattacker.core.protocol.message

Best Java code snippets using de.rub.nds.tlsattacker.core.protocol.message.ProtocolMessage (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: RUB-NDS/TLS-Attacker

/**
 * Reads the next bytes as the CompleteResultingMessage and writes them in
 * the message
 *
 * @param msg
 *            Message to write in
 */
private void parseCompleteResultingMessage(ProtocolMessage msg) {
  msg.setCompleteResultingMessage(getAlreadyParsed());
  LOGGER.debug("CompleteResultMessage: "
      + ArrayConverter.bytesToHexString(msg.getCompleteResultingMessage().getValue()));
}
origin: RUB-NDS/TLS-Attacker

private static List<ProtocolMessage> filterMessageList(List<ProtocolMessage> messages, ProtocolMessageType type) {
  List<ProtocolMessage> returnedMessages = new LinkedList<>();
  for (ProtocolMessage protocolMessage : messages) {
    if (protocolMessage.getProtocolMessageType() == type) {
      returnedMessages.add(protocolMessage);
    }
  }
  return returnedMessages;
}
origin: RUB-NDS/TLS-Attacker

public static List<HandshakeMessage> filterHandshakeMessagesFromList(List<ProtocolMessage> messages) {
  List<HandshakeMessage> returnedMessages = new LinkedList<>();
  for (ProtocolMessage protocolMessage : messages) {
    if (protocolMessage.isHandshakeMessage()) {
      returnedMessages.add((HandshakeMessage) protocolMessage);
    }
  }
  return returnedMessages;
}
origin: RUB-NDS/TLS-Attacker

/**
 * Apply the contents of the messages to the given TLS context.
 * 
 * @param protocolMessages
 * @param tlsContext
 */
private void applyMessages(TlsContext ctx) {
  for (ProtocolMessage msg : receivedMessages) {
    LOGGER.debug("Applying " + msg.toCompactString() + " to forward context " + ctx);
    ProtocolMessageHandler h = msg.getHandler(ctx);
    h.adjustTLSContext(msg);
  }
}
origin: RUB-NDS/TLS-Attacker

public String getReadableString(List<ProtocolMessage> messages, Boolean verbose) {
  StringBuilder builder = new StringBuilder();
  if (messages == null) {
    return builder.toString();
  }
  for (ProtocolMessage message : messages) {
    if (verbose) {
      builder.append(message.toString());
    } else {
      builder.append(message.toCompactString());
    }
    if (!message.isRequired()) {
      builder.append("*");
    }
    builder.append(", ");
  }
  return builder.toString();
}
origin: RUB-NDS/TLS-Attacker

@Override
public String toString() {
  StringBuilder sb = new StringBuilder("PopAndSendAction:\n");
  sb.append("Messages:\n");
  for (ProtocolMessage message : messages) {
    sb.append(message.toCompactString());
    sb.append(", ");
  }
  return sb.toString();
}
origin: RUB-NDS/TLS-Attacker

  Serializer serializer = getSerializer(message);
  byte[] completeMessage = serializer.serialize();
  message.setCompleteResultingMessage(completeMessage);
  if (message instanceof HandshakeMessage) {
    if (((HandshakeMessage) message).getIncludeInDigest()) {
      tlsContext.getDigest().append(message.getCompleteResultingMessage().getValue());
  if (message.getAdjustContext()) {
    adjustTLSContext(message);
  } else {
    LOGGER.debug("Not adjusting TLSContext for " + message.toCompactString());
  LOGGER.debug(E);
return message.getCompleteResultingMessage().getValue();
origin: RUB-NDS/TLS-Attacker

MessageBytesCollector messageBytesCollector = new MessageBytesCollector();
for (ProtocolMessage message : messages) {
  if (message.getProtocolMessageType() != lastType && lastMessage != null
      && context.getConfig().isFlushOnMessageTypeChange()) {
    recordPosition = flushBytesToRecords(messageBytesCollector, lastType, records, recordPosition, context);
    lastMessage.getHandler(context).adjustTlsContextAfterSerialize(lastMessage);
    lastMessage = null;
  lastType = message.getProtocolMessageType();
  byte[] protocolMessageBytes;
  if (prepareMessages) {
    LOGGER.debug("Preparing " + message.toCompactString());
    protocolMessageBytes = handleProtocolMessage(message, context);
  } else {
    protocolMessageBytes = handleProtocolMessageWithoutPrepare(message, context);
  if (message.isGoingToBeSent()) {
    messageBytesCollector.appendProtocolMessageBytes(protocolMessageBytes);
  } else {
    LOGGER.debug("Not adding message bytes for " + message.toCompactString() + " - goingToBeSent is false!");
    message.getHandler(context).adjustTlsContextAfterSerialize(message);
    lastMessage = null;
  lastMessage.getHandler(context).adjustTlsContextAfterSerialize(lastMessage);
origin: RUB-NDS/TLS-Attacker

  private byte[] computeControlValue(WorkflowTrace trace, TlsContext tlsContext) throws CryptoException {
    tlsContext.getDigest().reset();
    for (MessageAction messageAction : trace.getMessageActions()) {
      for (ProtocolMessage message : messageAction.getMessages()) {
        if (message instanceof ChangeCipherSpecMessage) {
          break;
        }
        if (message.isHandshakeMessage()) {
          HandshakeMessage handshakeMessage = (HandshakeMessage) message;
          if (handshakeMessage.getIncludeInDigest()) {
            tlsContext.getDigest().append(message.getCompleteResultingMessage().getValue());
          }
        }
      }
    }

    byte[] handshakeMessageHash = tlsContext.getDigest().digest(tlsContext.getSelectedProtocolVersion(),
        tlsContext.getSelectedCipherSuite());
    PRFAlgorithm prfAlgorithm = tlsContext.getChooser().getPRFAlgorithm();
    byte[] control = PseudoRandomFunction.compute(prfAlgorithm, tlsContext.getMasterSecret(),
        PseudoRandomFunction.CLIENT_FINISHED_LABEL, handshakeMessageHash, HandshakeByteLength.VERIFY_DATA);
    byte[] compare = ArrayConverter.concatenate(HandshakeMessageType.FINISHED.getArrayValue(),
        ArrayConverter.intToBytes(control.length, HandshakeByteLength.MESSAGE_LENGTH_FIELD), control);
    return compare;
  }
}
origin: RUB-NDS/TLS-Attacker

  @Override
  public List<ModifiableVariableHolder> getAllModifiableVariableHolders() {
    List<ModifiableVariableHolder> holders = super.getAllModifiableVariableHolders();
    if (getExtensions() != null) {
      for (ExtensionMessage em : getExtensions()) {
        if (em != null) {
          holders.addAll(em.getAllModifiableVariableHolders());
        }
      }
    }
    return holders;
  }
}
origin: RUB-NDS/TLS-Attacker

/**
 * Parses a byteArray from a Position into a MessageObject and returns the
 * parsed MessageObjet and parser position in a parser result. The current
 * Chooser is adjusted as
 *
 * @param message
 *            The byte[] messages which should be parsed
 * @param pointer
 *            The pointer (startposition) into the message bytes
 * @return The Parser result
 */
public ParserResult parseMessage(byte[] message, int pointer) {
  Parser<Message> parser = getParser(message, pointer);
  Message parsedMessage = parser.parse();
  try {
    prepareAfterParse(parsedMessage);
    if (parsedMessage instanceof HandshakeMessage) {
      if (((HandshakeMessage) parsedMessage).getIncludeInDigest()) {
        tlsContext.getDigest().append(parsedMessage.getCompleteResultingMessage().getValue());
      }
    }
    adjustTLSContext(parsedMessage);
  } catch (AdjustmentException | UnsupportedOperationException E) {
    LOGGER.warn("Could not adjust TLSContext");
    LOGGER.debug(E);
  }
  return new ParserResult(parsedMessage, parser.getPointer());
}
origin: RUB-NDS/TLS-Attacker

private byte[] handleProtocolMessageWithoutPrepare(ProtocolMessage message, TlsContext context) {
  ProtocolMessageHandler handler = message.getHandler(context);
  byte[] protocolMessageBytes = handler.prepareMessage(message, false);
  return protocolMessageBytes;
}
origin: RUB-NDS/TLS-Attacker

@Override
public Field getRandomModifiableVariableField(Random random) {
  List<Field> fields = getAllModifiableVariableFields();
  int randomField = random.nextInt(fields.size());
  return fields.get(randomField);
}
origin: RUB-NDS/TLS-Attacker

@Override
public String toString() {
  StringBuilder sb = new StringBuilder("BufferedSend Action:\n");
  sb.append("Messages:\n");
  for (ProtocolMessage message : messages) {
    sb.append(message.toCompactString());
    sb.append(", ");
  }
  return sb.toString();
}
origin: RUB-NDS/TLS-Attacker

@Override
public void execute(State state) throws WorkflowExecutionException, IOException {
  TlsContext ctx = state.getTlsContext(connectionAlias);
  if (isExecuted()) {
    throw new WorkflowExecutionException("Action already executed!");
  }
  List<ProtocolMessage> messages = ctx.getMessageBuffer();
  if (messages.isEmpty()) {
    LOGGER.debug("Empty buffer, no messages to apply");
  } else {
    for (ProtocolMessage msg : messages) {
      LOGGER.debug("Applying buffered " + msg.toCompactString() + " to context " + ctx);
      ProtocolMessageHandler h = msg.getHandler(ctx);
      h.adjustTLSContext(msg);
    }
  }
  setExecuted(true);
}
origin: RUB-NDS/TLS-Attacker

public String getReadableString(List<ProtocolMessage> messages, Boolean verbose) {
  StringBuilder builder = new StringBuilder();
  if (messages == null) {
    return builder.toString();
  }
  for (ProtocolMessage message : messages) {
    if (verbose) {
      builder.append(message.toString());
    } else {
      builder.append(message.toCompactString());
    }
    if (!message.isRequired()) {
      builder.append("*");
    }
    builder.append(", ");
  }
  return builder.toString();
}
origin: RUB-NDS/TLS-Attacker

if (messages != null) {
  for (ProtocolMessage message : messages) {
    holders.addAll(message.getAllModifiableVariableHolders());
origin: RUB-NDS/TLS-Attacker

  private byte[] handleProtocolMessage(ProtocolMessage message, TlsContext context) {
    ProtocolMessageHandler handler = message.getHandler(context);
    byte[] protocolMessageBytes = handler.prepareMessage(message);
    return protocolMessageBytes;
  }
}
origin: RUB-NDS/TLS-Attacker

@Override
public String toString() {
  StringBuilder sb = new StringBuilder("Receive Action:\n");
  sb.append("\tActual:");
  for (ProtocolMessage message : messages) {
    sb.append(message.toCompactString());
    sb.append(", ");
  }
  return sb.toString();
}
origin: RUB-NDS/TLS-Attacker

public static List<ProtocolMessage> getAllReceivedMessages(WorkflowTrace trace, ProtocolMessageType type) {
  List<ProtocolMessage> receivedMessage = new LinkedList<>();
  for (ProtocolMessage message : getAllReceivedMessages(trace)) {
    if (message.getProtocolMessageType() == type) {
      receivedMessage.add(message);
    }
  }
  return receivedMessage;
}
de.rub.nds.tlsattacker.core.protocol.messageProtocolMessage

Javadoc

TLS Protocol message is the message included in the Record message.

Most used methods

  • getAllModifiableVariableHolders
  • getCompleteResultingMessage
  • getProtocolMessageType
  • isHandshakeMessage
  • toCompactString
  • getAdjustContext
  • getAllModifiableVariableFields
  • getHandler
  • isGoingToBeSent
  • isRequired
  • setCompleteResultingMessage
  • setCompleteResultingMessage

Popular in Java

  • Running tasks concurrently on multiple threads
  • getResourceAsStream (ClassLoader)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • findViewById (Activity)
  • MalformedURLException (java.net)
    Thrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a s
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • DecimalFormat (java.text)
    DecimalFormat is a concrete subclass ofNumberFormat that formats decimal numbers. It has a variety o
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now