Skip to content

Commit

Permalink
Added check to detect redundant CCS messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaehren committed Oct 23, 2023
1 parent 8693369 commit 6d4f84f
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package de.rub.nds.tlstest.suite.tests.server.tls13.rfc8446;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import de.rub.nds.modifiablevariable.util.Modifiable;
Expand All @@ -15,6 +16,7 @@
import de.rub.nds.tlsattacker.core.constants.CipherSuite;
import de.rub.nds.tlsattacker.core.constants.ExtensionType;
import de.rub.nds.tlsattacker.core.constants.HandshakeMessageType;
import de.rub.nds.tlsattacker.core.constants.ProtocolMessageType;
import de.rub.nds.tlsattacker.core.protocol.message.ChangeCipherSpecMessage;
import de.rub.nds.tlsattacker.core.protocol.message.ClientHelloMessage;
import de.rub.nds.tlsattacker.core.protocol.message.ServerHelloMessage;
Expand Down Expand Up @@ -165,6 +167,7 @@ public void selectsSameCipherSuiteAllAtOnce(
.validateFinal(
i -> {
Validator.executedAsPlanned(i);
checkForDuplicateCcs(workflowTrace);

ServerHelloMessage helloRetryRequest =
(ServerHelloMessage)
Expand Down Expand Up @@ -219,6 +222,7 @@ public void selectsSameCipherSuite(ArgumentsAccessor argumentAccessor, WorkflowR
.validateFinal(
i -> {
Validator.executedAsPlanned(i);
checkForDuplicateCcs(workflowTrace);

ServerHelloMessage helloRetryRequest =
(ServerHelloMessage)
Expand Down Expand Up @@ -270,6 +274,7 @@ public void retainsProtocolVersion(ArgumentsAccessor argumentAccessor, WorkflowR
.validateFinal(
i -> {
Validator.executedAsPlanned(i);
checkForDuplicateCcs(workflowTrace);

ServerHelloMessage helloRetryRequest =
(ServerHelloMessage)
Expand Down Expand Up @@ -370,4 +375,16 @@ private WorkflowTrace getHelloRetryWorkflowTrace(WorkflowRunner runner) {
workflowTrace.addTlsActions(secondHelloTrace.getTlsActions());
return workflowTrace;
}

private void checkForDuplicateCcs(WorkflowTrace executedTrace) {
// due to our workflow structure, CCS may be parsed with the first ServerHello or before the
// new
// ServerHello but it must not be sent twice by the server
assertFalse(
"Received more than one compatibility CCS from Server",
WorkflowTraceUtil.getAllReceivedMessages(
executedTrace, ProtocolMessageType.CHANGE_CIPHER_SPEC)
.size()
> 1);
}
}

0 comments on commit 6d4f84f

Please sign in to comment.