Skip to content

Commit e3e785c

Browse files
Obito93ic0ns
authored andcommitted
SSL2ClientHelloParserTest seems finished (#354)
Added SSL2ClientHelloParserTest
1 parent 5350c2b commit e3e785c

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* TLS-Attacker - A Modular Penetration Testing Framework for TLS
3+
*
4+
* Copyright 2014-2017 Ruhr University Bochum / Hackmanit GmbH
5+
*
6+
* Licensed under Apache License 2.0
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*/
9+
package de.rub.nds.tlsattacker.core.protocol.parser;
10+
11+
import de.rub.nds.modifiablevariable.util.ArrayConverter;
12+
import de.rub.nds.tlsattacker.core.constants.HandshakeMessageType;
13+
import de.rub.nds.tlsattacker.core.constants.ProtocolVersion;
14+
import de.rub.nds.tlsattacker.core.protocol.message.SSL2ClientHelloMessage;
15+
import java.util.Arrays;
16+
import java.util.Collection;
17+
import static org.junit.Assert.*;
18+
import org.junit.Test;
19+
import org.junit.runner.RunWith;
20+
import org.junit.runners.Parameterized;
21+
22+
/**
23+
*
24+
* @author Steve Ehleringer - steve.ehleringer@rub.de
25+
*/
26+
27+
@RunWith(Parameterized.class)
28+
public class SSL2ClientHelloParserTest {
29+
30+
/*
31+
* Constructing a SSL2 ClientHelloMessage, captured from www.aspray24.com
32+
*/
33+
@Parameterized.Parameters
34+
public static Collection<Object[]> generateData() {
35+
return Arrays
36+
.asList(new Object[][] { {
37+
ArrayConverter
38+
.hexStringToByteArray("802b0100020012000000100100800700c0030080060040020080040080bc4c7de14f6fc8bff4428f159fb24f2b"),
39+
ProtocolVersion.SSL2, 0x802B, HandshakeMessageType.CLIENT_HELLO,
40+
ProtocolVersion.SSL2.getValue(), 18/* 0x0012 */, 0, 16/* 0x0010 */,
41+
ArrayConverter.hexStringToByteArray("0100800700c0030080060040020080040080"), new byte[0],
42+
ArrayConverter.hexStringToByteArray("bc4c7de14f6fc8bff4428f159fb24f2b") } });
43+
}
44+
45+
private final byte[] message;
46+
private final ProtocolVersion version;
47+
private final int messageLength;
48+
private final HandshakeMessageType type;
49+
private final byte[] protocolVersion;
50+
private final int cipherSuiteLength;
51+
private final int sessionIdLength;
52+
private final int challengeLength;
53+
private final byte[] cipherSuites;
54+
private final byte[] sessionId;
55+
private final byte[] challenge;
56+
57+
public SSL2ClientHelloParserTest(byte[] message, ProtocolVersion version, int messageLength,
58+
HandshakeMessageType type, byte[] protocolVersion, int cipherSuiteLength, int sessionIdLength,
59+
int challengeLength, byte[] cipherSuites, byte[] sessionId, byte[] challenge) {
60+
this.message = message;
61+
this.version = version;
62+
this.messageLength = messageLength;
63+
this.type = type;
64+
this.protocolVersion = protocolVersion;
65+
this.cipherSuiteLength = cipherSuiteLength;
66+
this.sessionIdLength = sessionIdLength;
67+
this.challengeLength = challengeLength;
68+
this.cipherSuites = cipherSuites;
69+
this.sessionId = sessionId;
70+
this.challenge = challenge;
71+
}
72+
73+
/**
74+
* Test of parse method, of class SSL2ClientHelloParser.
75+
*/
76+
@Test
77+
public void testParse() {
78+
SSL2ClientHelloParser parser = new SSL2ClientHelloParser(message, 0, version);
79+
SSL2ClientHelloMessage msg = (SSL2ClientHelloMessage) parser.parse();
80+
assertArrayEquals(message, msg.getCompleteResultingMessage().getValue());
81+
assertTrue(msg.getMessageLength().getValue() == messageLength);
82+
assertTrue(msg.getType().getValue() == type.getValue());
83+
assertArrayEquals(protocolVersion, msg.getProtocolVersion().getValue());
84+
assertTrue(msg.getCipherSuiteLength().getValue() == cipherSuiteLength);
85+
assertTrue(msg.getSessionIdLength().getValue() == sessionIdLength);
86+
assertTrue(msg.getChallengeLength().getValue() == challengeLength);
87+
assertArrayEquals(cipherSuites, msg.getCipherSuites().getValue());
88+
assertArrayEquals(sessionId, msg.getSessionId().getValue());
89+
assertArrayEquals(challenge, msg.getChallenge().getValue());
90+
}
91+
}

0 commit comments

Comments
 (0)